exprmat 0.1.34__tar.gz → 0.1.35__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {exprmat-0.1.34 → exprmat-0.1.35}/PKG-INFO +6 -1
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/__init__.py +2 -1
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/configuration.py +2 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/plotting/expression.py +26 -10
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/reader/experiment.py +111 -9
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/reader/matcher.py +45 -8
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/reader/metadata.py +34 -0
- exprmat-0.1.35/exprmat/reader/spatial.py +830 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/reader/static.py +103 -11
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/reduction/plot.py +6 -1
- {exprmat-0.1.34 → exprmat-0.1.35}/pyproject.toml +7 -2
- exprmat-0.1.34/exprmat/reader/spatial.py +0 -171
- {exprmat-0.1.34 → exprmat-0.1.35}/Cargo.lock +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/Cargo.toml +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/ansi.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/clustering/__init__.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/clustering/cnmf.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/clustering/dbscan.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/clustering/kmeans.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/clustering/leiden.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/clustering/nmf.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/clustering/rogue.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/clustering/seriation.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/clustering/spectral.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/clustering/utils.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/cnv/__init__.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/cnv/cnvscore.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/cnv/infercnv.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/data/__init__.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/data/cistarget.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/data/delim.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/data/finders.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/data/geneset.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/data/gff.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/data/io.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/data/lr.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/data/presets.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/data/private.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/data/ranges.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/data/signature.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/data/tf.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/descriptive/__init__.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/descriptive/aggregate.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/descriptive/atac.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/descriptive/aucell.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/descriptive/de.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/descriptive/gse.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/descriptive/kde.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/descriptive/recovery.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/descriptive/summary.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/descriptive/tcr.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/dynamics/__init__.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/dynamics/generank.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/dynamics/linreg.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/dynamics/moments.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/dynamics/optimization.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/dynamics/parallel.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/dynamics/preprocess.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/dynamics/pseudotime.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/dynamics/transition.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/dynamics/utils.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/dynamics/velocity.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/grn/__init__.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/grn/infergrn.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/grn/modules.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/grn/prune.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/grn/regressors.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/grn/utils.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/image/__init__.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/image/align.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/lr/__init__.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/lr/aggregate.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/lr/method.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/lr/methods/__init__.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/lr/methods/cellchat.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/lr/methods/cellphonedb.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/lr/methods/connectome.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/lr/methods/geomean.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/lr/methods/logfc.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/lr/methods/natmi.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/lr/methods/rank_aggregate.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/lr/methods/scseqcomm.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/lr/methods/singlecellsignalr.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/lr/pipeline.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/lr/preprocess.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/lr/resources.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/lr/utils.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/plotting/__init__.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/plotting/atac.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/plotting/cnmf.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/plotting/cnv.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/plotting/de.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/plotting/gse.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/plotting/lr.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/plotting/palettes.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/plotting/sankey.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/plotting/summary.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/plotting/track.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/plotting/utils.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/plotting/velocity.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/preprocessing/__init__.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/preprocessing/doublets/__init__.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/preprocessing/doublets/composite.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/preprocessing/doublets/scrublet.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/preprocessing/emptydrops.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/preprocessing/filter.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/preprocessing/impute/__init__.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/preprocessing/impute/magic.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/preprocessing/integrate.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/preprocessing/linear.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/preprocessing/normal.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/preprocessing/plot.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/preprocessing/qc.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/preprocessing/sctransform/__init__.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/preprocessing/sctransform/estimate.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/preprocessing/sctransform/ksmooth.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/preprocessing/sctransform/residual.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/preprocessing/sctransform/transform.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/preprocessing/sparse.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/preprocessing/uniform.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/reader/__init__.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/reader/peaks.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/reduction/__init__.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/reduction/forceatlas.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/reduction/mde.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/reduction/nn.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/reduction/outliers.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/reduction/pca.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/reduction/spectral.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/reduction/tsne.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/reduction/umap.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/trajectory/pcurve.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/transfer/__init__.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/transfer/atlas.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/exprmat/utils.py +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/license +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/readme.md +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/snapatac2/Cargo.toml +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/snapatac2/license +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/snapatac2/readme +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/snapatac2/src/call_peaks.rs +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/snapatac2/src/embedding.rs +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/snapatac2/src/export.rs +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/snapatac2/src/knn.rs +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/snapatac2/src/lib.rs +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/snapatac2/src/motif.rs +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/snapatac2/src/network.rs +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/snapatac2/src/preprocessing.rs +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/snapatac2/src/utils/anndata.rs +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/snapatac2/src/utils.rs +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/snapatac2-core/Cargo.toml +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/snapatac2-core/src/embedding.rs +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/snapatac2-core/src/export.rs +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/snapatac2-core/src/feature_count/counter.rs +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/snapatac2-core/src/feature_count/data_iter.rs +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/snapatac2-core/src/feature_count/matrix.rs +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/snapatac2-core/src/feature_count/mod.rs +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/snapatac2-core/src/genome.rs +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/snapatac2-core/src/lib.rs +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/snapatac2-core/src/motif.rs +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/snapatac2-core/src/network.rs +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/snapatac2-core/src/preprocessing/bam/flagstat.rs +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/snapatac2-core/src/preprocessing/bam/header.rs +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/snapatac2-core/src/preprocessing/bam/mark_duplicates.rs +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/snapatac2-core/src/preprocessing/bam.rs +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/snapatac2-core/src/preprocessing/import.rs +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/snapatac2-core/src/preprocessing/mod.rs +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/snapatac2-core/src/preprocessing/qc.rs +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/snapatac2-core/src/utils/knn.rs +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/snapatac2-core/src/utils/mod.rs +0 -0
- {exprmat-0.1.34 → exprmat-0.1.35}/snapatac2-core/src/utils/similarity.rs +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: exprmat
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.35
|
|
4
4
|
Classifier: Programming Language :: Rust
|
|
5
5
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
6
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
@@ -63,6 +63,11 @@ Requires-Dist: scikit-image
|
|
|
63
63
|
Requires-Dist: spatial-image
|
|
64
64
|
Requires-Dist: multiscale-spatial-image
|
|
65
65
|
Requires-Dist: tangram-sc
|
|
66
|
+
Requires-Dist: shapely>=2.0.0
|
|
67
|
+
Requires-Dist: pyogrio>=0.7.2
|
|
68
|
+
Requires-Dist: pyproj>=3.3.0
|
|
69
|
+
Requires-Dist: geopandas
|
|
70
|
+
Requires-Dist: packaging
|
|
66
71
|
Requires-Dist: sphinx ; extra == 'dev'
|
|
67
72
|
Requires-Dist: twine ; extra == 'dev'
|
|
68
73
|
Requires-Dist: ipykernel ; extra == 'dev'
|
|
@@ -10,12 +10,13 @@ import anndata as ad
|
|
|
10
10
|
import scanpy as sc
|
|
11
11
|
import pandas as pd
|
|
12
12
|
import pathlib
|
|
13
|
+
from PIL import Image
|
|
13
14
|
|
|
14
15
|
from exprmat.configuration import default as config
|
|
15
16
|
from exprmat.ansi import warning, info
|
|
16
17
|
|
|
17
18
|
mu.set_options(pull_on_update = False)
|
|
18
|
-
|
|
19
|
+
Image.MAX_IMAGE_PIXELS = config['max.image']
|
|
19
20
|
|
|
20
21
|
DATABASE_SETUP_MESSAGE = """
|
|
21
22
|
The exprmat package do not come with a included database after version 0.1.25,
|
|
@@ -3,14 +3,16 @@ import seaborn as sns
|
|
|
3
3
|
from matplotlib import ticker
|
|
4
4
|
import matplotlib.pyplot as plt
|
|
5
5
|
import pandas as pd
|
|
6
|
+
|
|
6
7
|
from exprmat.utils import find_variable, choose_layer
|
|
8
|
+
from exprmat.ansi import error
|
|
7
9
|
|
|
8
10
|
|
|
9
11
|
def barplot(
|
|
10
12
|
adata, *, gene,
|
|
11
13
|
slot = 'X', group = 'cell.type', selected_groups = None, selected_splits = None,
|
|
12
|
-
split = 'treat', palette = ['red', 'black'], ax = None,
|
|
13
|
-
size = (6,3), dpi = 100
|
|
14
|
+
split = 'treat', palette = ['red', 'black'], ax = None, style = 'box',
|
|
15
|
+
size = (6,3), dpi = 100, violin_kwargs = {}
|
|
14
16
|
):
|
|
15
17
|
|
|
16
18
|
plt.rcParams["ytick.labelright"] = False
|
|
@@ -46,14 +48,28 @@ def barplot(
|
|
|
46
48
|
if ax is None: fig, axes = plt.subplots(1, 1, figsize = size, dpi = dpi)
|
|
47
49
|
else: axes = ax
|
|
48
50
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
if style == 'box':
|
|
52
|
+
|
|
53
|
+
sns.boxplot(
|
|
54
|
+
data = dropzeros.loc[dropzeros['name'] == gene,:],
|
|
55
|
+
x = "row", y = "logc", hue = 'split', ax = axes, fill = True,
|
|
56
|
+
palette = palette, saturation = 0.8, log_scale = False,
|
|
57
|
+
color = '.8', linecolor = '0', order = selected_groups, gap = 0.3,
|
|
58
|
+
flierprops = dict(markerfacecolor = '0.1', markersize = 1, linestyle = 'none'),
|
|
59
|
+
showfliers = True, width = 0.6
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
elif style == 'violin':
|
|
63
|
+
|
|
64
|
+
sns.violinplot(
|
|
65
|
+
data = dropzeros.loc[dropzeros['name'] == gene,:],
|
|
66
|
+
x = "row", y = "logc", hue = 'split', ax = axes, fill = True,
|
|
67
|
+
palette = palette, saturation = 0.8, log_scale = False,
|
|
68
|
+
color = '.8', linecolor = '0', order = selected_groups, gap = 0,
|
|
69
|
+
width = 0.8, **violin_kwargs
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
else: error('can only set plot style to `box` or `violin`.')
|
|
57
73
|
|
|
58
74
|
axes.tick_params(
|
|
59
75
|
axis = 'y', right = False, left = True, color = 'gray', length = 4,
|
|
@@ -166,14 +166,54 @@ class experiment:
|
|
|
166
166
|
|
|
167
167
|
if not 'rnasp-c' in self.modalities.keys(): self.modalities['rnasp-c'] = {}
|
|
168
168
|
|
|
169
|
-
from exprmat.reader.spatial import read_seekspace
|
|
170
|
-
|
|
169
|
+
from exprmat.reader.spatial import read_seekspace, read_xenium_explorer, is_xenium_explorer
|
|
170
|
+
|
|
171
|
+
if is_xenium_explorer(i_loc):
|
|
172
|
+
self.modalities['rnasp-c'][i_sample] = read_xenium_explorer(
|
|
173
|
+
src = i_loc, prefix = '', metadata = meta, sample = i_sample,
|
|
174
|
+
raw = False, default_taxa = i_taxa, eccentric = eccentric
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
else:
|
|
178
|
+
self.modalities['rnasp-c'][i_sample] = read_seekspace(
|
|
179
|
+
src = i_loc, prefix = '', metadata = meta, sample = i_sample,
|
|
180
|
+
raw = False, default_taxa = i_taxa, eccentric = eccentric
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
self.modalities['rnasp-c'][i_sample].var = \
|
|
184
|
+
st.search_genes(self.modalities['rnasp-c'][i_sample].var_names.tolist())
|
|
185
|
+
|
|
186
|
+
elif i_mod == 'rnasp-b':
|
|
187
|
+
|
|
188
|
+
if not 'rnasp-b' in self.modalities.keys(): self.modalities['rnasp-b'] = {}
|
|
189
|
+
|
|
190
|
+
from exprmat.reader.spatial import read_visium
|
|
191
|
+
self.modalities['rnasp-b'][i_sample] = read_visium(
|
|
171
192
|
src = i_loc, prefix = '', metadata = meta, sample = i_sample,
|
|
172
193
|
raw = False, default_taxa = i_taxa, eccentric = eccentric
|
|
173
194
|
)
|
|
174
195
|
|
|
175
|
-
self.modalities['rnasp-
|
|
176
|
-
st.search_genes(self.modalities['rnasp-
|
|
196
|
+
self.modalities['rnasp-b'][i_sample].var = \
|
|
197
|
+
st.search_genes(self.modalities['rnasp-b'][i_sample].var_names.tolist())
|
|
198
|
+
|
|
199
|
+
elif i_mod == 'rnasp-s':
|
|
200
|
+
|
|
201
|
+
if not 'rnasp-s' in self.modalities.keys(): self.modalities['rnasp-s'] = {}
|
|
202
|
+
|
|
203
|
+
from exprmat.reader.spatial import read_visium_hd
|
|
204
|
+
self.modalities['rnasp-s'][i_sample], cellseg = read_visium_hd(
|
|
205
|
+
src = i_loc, prefix = '', metadata = meta, sample = i_sample,
|
|
206
|
+
raw = False, default_taxa = i_taxa, eccentric = eccentric
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
self.modalities['rnasp-s'][i_sample].var = \
|
|
210
|
+
st.search_genes(self.modalities['rnasp-s'][i_sample].var_names.tolist())
|
|
211
|
+
|
|
212
|
+
if cellseg is not None:
|
|
213
|
+
if not 'rnasp-c' in self.modalities.keys(): self.modalities['rnasp-c'] = {}
|
|
214
|
+
self.modalities['rnasp-c'][i_sample] = cellseg
|
|
215
|
+
self.modalities['rnasp-c'][i_sample].var = \
|
|
216
|
+
st.search_genes(self.modalities['rnasp-c'][i_sample].var_names.tolist())
|
|
177
217
|
|
|
178
218
|
elif i_mod == 'atac':
|
|
179
219
|
|
|
@@ -570,7 +610,7 @@ class experiment:
|
|
|
570
610
|
else: self.mudata = None
|
|
571
611
|
|
|
572
612
|
|
|
573
|
-
def do_for(self, samples, func, **kwargs):
|
|
613
|
+
def do_for(self, modality, samples, func, **kwargs):
|
|
574
614
|
|
|
575
615
|
results = {}
|
|
576
616
|
for mod, samp in zip(
|
|
@@ -578,6 +618,7 @@ class experiment:
|
|
|
578
618
|
self.metadata.dataframe['sample'].tolist()
|
|
579
619
|
):
|
|
580
620
|
if '.' in mod: continue
|
|
621
|
+
if mod != modality: continue
|
|
581
622
|
|
|
582
623
|
do = False
|
|
583
624
|
if samples is None: do = True
|
|
@@ -608,9 +649,13 @@ class experiment:
|
|
|
608
649
|
|
|
609
650
|
def do_for_modality(self, modality, run_on_samples, func, **kwargs):
|
|
610
651
|
if isinstance(run_on_samples, bool) and run_on_samples:
|
|
611
|
-
return self.do_for(self.all_samples(modality), func, **kwargs)
|
|
652
|
+
return self.do_for(modality, self.all_samples(modality), func, **kwargs)
|
|
612
653
|
elif isinstance(run_on_samples, list):
|
|
613
|
-
return self.do_for(
|
|
654
|
+
return self.do_for(
|
|
655
|
+
modality, list(set(self.all_samples(modality)) & set(run_on_samples)),
|
|
656
|
+
func, **kwargs
|
|
657
|
+
)
|
|
658
|
+
|
|
614
659
|
else:
|
|
615
660
|
assert modality in self.mudata.mod.keys()
|
|
616
661
|
return func(self.mudata[modality], 'integrated', **kwargs)
|
|
@@ -629,6 +674,9 @@ class experiment:
|
|
|
629
674
|
|
|
630
675
|
def do_for_rnaspc(self, run_on_samples, func, **kwargs):
|
|
631
676
|
return self.do_for_modality('rnasp-c', run_on_samples, func, **kwargs)
|
|
677
|
+
|
|
678
|
+
def do_for_rnaspb(self, run_on_samples, func, **kwargs):
|
|
679
|
+
return self.do_for_modality('rnasp-b', run_on_samples, func, **kwargs)
|
|
632
680
|
|
|
633
681
|
|
|
634
682
|
def plot_for_modality(
|
|
@@ -639,12 +687,16 @@ class experiment:
|
|
|
639
687
|
setup_styles()
|
|
640
688
|
|
|
641
689
|
if isinstance(run_on_samples, bool) and run_on_samples:
|
|
642
|
-
figures = self.do_for(self.all_samples(modality), func, **kwargs)
|
|
690
|
+
figures = self.do_for(modality, self.all_samples(modality), func, **kwargs)
|
|
643
691
|
for f in figures.values(): f.tight_layout()
|
|
644
692
|
return figures
|
|
645
693
|
|
|
646
694
|
elif isinstance(run_on_samples, list):
|
|
647
|
-
figures = self.do_for(
|
|
695
|
+
figures = self.do_for(
|
|
696
|
+
modality, list(set(self.all_samples(modality)) & set(run_on_samples)),
|
|
697
|
+
func, **kwargs
|
|
698
|
+
)
|
|
699
|
+
|
|
648
700
|
for f in figures.values(): f.tight_layout()
|
|
649
701
|
return figures
|
|
650
702
|
|
|
@@ -727,6 +779,15 @@ class experiment:
|
|
|
727
779
|
'rnasp-c', run_on_samples, func,
|
|
728
780
|
run_on_splits, split_key, split_selection, **kwargs
|
|
729
781
|
)
|
|
782
|
+
|
|
783
|
+
def plot_for_rnaspb(
|
|
784
|
+
self, run_on_samples, func,
|
|
785
|
+
run_on_splits = False, split_key = None, split_selection = None, **kwargs
|
|
786
|
+
):
|
|
787
|
+
return self.plot_for_modality(
|
|
788
|
+
'rnasp-b', run_on_samples, func,
|
|
789
|
+
run_on_splits, split_key, split_selection, **kwargs
|
|
790
|
+
)
|
|
730
791
|
|
|
731
792
|
|
|
732
793
|
def all_samples(self, modality = None):
|
|
@@ -1337,6 +1398,32 @@ class experiment:
|
|
|
1337
1398
|
'''
|
|
1338
1399
|
return self.do_for_rnaspc(run_on_samples, st.rna_proportion, **kwargs)
|
|
1339
1400
|
|
|
1401
|
+
def run_rnaspc_roi(self, run_on_samples = False, **kwargs):
|
|
1402
|
+
|
|
1403
|
+
roi = self.do_for_rnaspc(run_on_samples, st.rnaspc_roi, **kwargs)
|
|
1404
|
+
if isinstance(roi, dict):
|
|
1405
|
+
roi = roi[kwargs.get('spsample')]
|
|
1406
|
+
|
|
1407
|
+
roi.uns['spatial'] = {
|
|
1408
|
+
kwargs.get('sample_added'): roi.uns['spatial'][kwargs.get('spsample')]
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
rows = self.metadata.dataframe[(
|
|
1412
|
+
(self.metadata.dataframe['sample'] == kwargs.get('spsample')) &
|
|
1413
|
+
(self.metadata.dataframe['modality'] == 'rnasp-c')
|
|
1414
|
+
)]
|
|
1415
|
+
|
|
1416
|
+
assert len(rows) == 1
|
|
1417
|
+
props = rows.iloc[0].copy()
|
|
1418
|
+
props['sample'] = kwargs.get('sample_added')
|
|
1419
|
+
props['modality'] = 'rnasp-c'
|
|
1420
|
+
|
|
1421
|
+
self.metadata.insert_row(props)
|
|
1422
|
+
if not 'rnasp-c' in self.modalities.keys(): self.modalities['rnasp-c'] = {}
|
|
1423
|
+
self.modalities['rnasp-c'][kwargs.get('sample_added')] = roi
|
|
1424
|
+
self.modalities['rnasp-c'][kwargs.get('sample_added')].var = \
|
|
1425
|
+
st.search_genes(self.modalities['rnasp-c'][kwargs.get('sample_added')].var_names.tolist())
|
|
1426
|
+
|
|
1340
1427
|
|
|
1341
1428
|
# plotting wrappers
|
|
1342
1429
|
|
|
@@ -1503,6 +1590,10 @@ class experiment:
|
|
|
1503
1590
|
return self.plot_for_rnaspc(run_on_samples, st.rnaspc_plot_embedding_spatial, **kwargs)
|
|
1504
1591
|
|
|
1505
1592
|
|
|
1593
|
+
def plot_rnaspb_embedding_spatial(self, run_on_samples = False, **kwargs):
|
|
1594
|
+
return self.plot_for_rnaspb(run_on_samples, st.rnaspc_plot_embedding_spatial, **kwargs)
|
|
1595
|
+
|
|
1596
|
+
|
|
1506
1597
|
def plot_sankey(self, run_on_samples = False, **kwargs):
|
|
1507
1598
|
return self.plot_for_rna(run_on_samples, st.adata_plot_sankey, **kwargs)
|
|
1508
1599
|
|
|
@@ -1678,6 +1769,17 @@ class experiment:
|
|
|
1678
1769
|
return merge
|
|
1679
1770
|
|
|
1680
1771
|
|
|
1772
|
+
# magic accessors
|
|
1773
|
+
|
|
1774
|
+
def __getitem__(self, key):
|
|
1775
|
+
self.check_merged()
|
|
1776
|
+
if key in self.mudata.mod.keys():
|
|
1777
|
+
return self.mudata[key]
|
|
1778
|
+
else:
|
|
1779
|
+
warning(f'key must be one of [{", ".join(list(self.mudata.mod.keys()))}]')
|
|
1780
|
+
error(f'no integrated modality named `{key}`.')
|
|
1781
|
+
|
|
1782
|
+
|
|
1681
1783
|
def __repr__(self):
|
|
1682
1784
|
|
|
1683
1785
|
from exprmat.ansi import green, cyan, red, yellow
|
|
@@ -250,7 +250,7 @@ def adjust_features(path, refine_finder = False, default_taxa = 'mmu', eccentric
|
|
|
250
250
|
def read_mtx_rna(
|
|
251
251
|
src: str, prefix: str,
|
|
252
252
|
metadata: metadata, sample: str, raw: bool = False,
|
|
253
|
-
default_taxa = 'mmu', eccentric = None
|
|
253
|
+
default_taxa = 'mmu', eccentric = None, suppress_filter = False,
|
|
254
254
|
):
|
|
255
255
|
'''
|
|
256
256
|
Formalize the three components in the matrix directory, and read the folder with gene
|
|
@@ -299,7 +299,41 @@ def read_mtx_rna(
|
|
|
299
299
|
# return None
|
|
300
300
|
|
|
301
301
|
final = match_matrix_rna(
|
|
302
|
-
adata, metadata, sample,
|
|
302
|
+
adata, metadata, sample, suppress_filter = suppress_filter,
|
|
303
|
+
force_filter = raw, default_taxa = default_taxa
|
|
304
|
+
)
|
|
305
|
+
|
|
306
|
+
warnings.filterwarnings('default')
|
|
307
|
+
|
|
308
|
+
del adata
|
|
309
|
+
return final
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
def read_h5_rna(
|
|
313
|
+
path: str,
|
|
314
|
+
metadata: metadata, sample: str, raw: bool = False,
|
|
315
|
+
default_taxa = 'mmu', eccentric = None, suppress_filter = False,
|
|
316
|
+
):
|
|
317
|
+
import warnings
|
|
318
|
+
warnings.filterwarnings('ignore')
|
|
319
|
+
|
|
320
|
+
adata = sc.read_10x_h5(
|
|
321
|
+
path, gex_only = True
|
|
322
|
+
)
|
|
323
|
+
|
|
324
|
+
adata.var_names = adata.var['gene_ids'].tolist()
|
|
325
|
+
del adata.var
|
|
326
|
+
|
|
327
|
+
if eccentric is not None:
|
|
328
|
+
adata.var_names = [eccentric(x) for x in adata.var_names]
|
|
329
|
+
|
|
330
|
+
# except Exception as ex:
|
|
331
|
+
# warning('error occurs when reading matrix files:')
|
|
332
|
+
# warning(str(ex))
|
|
333
|
+
# return None
|
|
334
|
+
|
|
335
|
+
final = match_matrix_rna(
|
|
336
|
+
adata, metadata, sample, suppress_filter = suppress_filter,
|
|
303
337
|
force_filter = raw, default_taxa = default_taxa
|
|
304
338
|
)
|
|
305
339
|
|
|
@@ -429,24 +463,27 @@ def read_h5ad_rna(
|
|
|
429
463
|
|
|
430
464
|
|
|
431
465
|
def match_matrix_rna(
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
466
|
+
adata, metadata: metadata, sample: str,
|
|
467
|
+
force_filter = False, default_taxa = 'mmu',
|
|
468
|
+
do_not_alter_obs_names = False, suppress_filter = False
|
|
469
|
+
):
|
|
436
470
|
|
|
437
471
|
# if more than 50000 cells in a single matrix, we just believe that it is
|
|
438
472
|
# an unfiltered raw matrix. we should roughly filter the empty droplets
|
|
439
473
|
|
|
440
|
-
if adata.n_obs > 50000 or force_filter:
|
|
474
|
+
if (adata.n_obs > 50000 or force_filter) and (not suppress_filter):
|
|
441
475
|
valid = (adata.X.sum(axis = 1).transpose() > 200).tolist()[0]
|
|
442
476
|
adata_f = adata[valid, :]
|
|
477
|
+
|
|
443
478
|
else: adata_f = adata
|
|
444
479
|
|
|
445
480
|
rows = metadata.dataframe[metadata.dataframe['sample'] == sample]
|
|
446
481
|
assert len(rows) >= 1
|
|
447
482
|
rows = rows[
|
|
448
483
|
(rows['modality'] == 'rna') |
|
|
449
|
-
(rows['modality'] == 'rnasp-c')
|
|
484
|
+
(rows['modality'] == 'rnasp-c') |
|
|
485
|
+
(rows['modality'] == 'rnasp-b') |
|
|
486
|
+
(rows['modality'] == 'rnasp-s')
|
|
450
487
|
]
|
|
451
488
|
assert len(rows) == 1
|
|
452
489
|
props = rows.iloc[0]
|
|
@@ -237,6 +237,40 @@ class metadata:
|
|
|
237
237
|
temp = [value if (contains in str(x)) else y for x, y in zip(source, temp)]
|
|
238
238
|
self.dataframe[dest] = temp
|
|
239
239
|
|
|
240
|
+
|
|
241
|
+
def find(self, modality, sample):
|
|
242
|
+
|
|
243
|
+
from exprmat.ansi import error, warning
|
|
244
|
+
df = self.dataframe[(
|
|
245
|
+
(self.dataframe['sample'] == sample) &
|
|
246
|
+
(self.dataframe['modality'] == modality)
|
|
247
|
+
)]
|
|
248
|
+
|
|
249
|
+
if len(df) == 1:
|
|
250
|
+
return df.iloc[0]
|
|
251
|
+
elif len(df) == 0:
|
|
252
|
+
warning(f'could not find [{modality}] {sample}')
|
|
253
|
+
return None
|
|
254
|
+
else: error(f'duplicated sample for {sample}')
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
def insert_row(self, row):
|
|
258
|
+
|
|
259
|
+
from exprmat.ansi import error
|
|
260
|
+
insert_index = len(self.dataframe)
|
|
261
|
+
# get the modality and sample name if there exists one:
|
|
262
|
+
selection: pandas.Series = (
|
|
263
|
+
(self.dataframe['modality'] == row['modality']) &
|
|
264
|
+
(self.dataframe['sample'] == row['sample'])
|
|
265
|
+
)
|
|
266
|
+
|
|
267
|
+
if selection.sum() == 1:
|
|
268
|
+
insert_index = selection.tolist().index(True)
|
|
269
|
+
elif selection.sum() == 0: pass
|
|
270
|
+
else: error('failed to insert row for duplicated index.')
|
|
271
|
+
|
|
272
|
+
self.dataframe.loc[insert_index] = row
|
|
273
|
+
|
|
240
274
|
|
|
241
275
|
def load_metadata(fpath):
|
|
242
276
|
'''
|