exprmat 0.1.30__tar.gz → 0.1.32__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.30 → exprmat-0.1.32}/PKG-INFO +1 -2
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/__init__.py +1 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/plotting/cnmf.py +38 -3
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/plotting/de.py +4 -4
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/plotting/expression.py +13 -6
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/plotting/lr.py +8 -4
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/plotting/utils.py +56 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/reader/experiment.py +3 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/reader/static.py +32 -7
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/reduction/plot.py +2 -2
- {exprmat-0.1.30 → exprmat-0.1.32}/pyproject.toml +1 -2
- {exprmat-0.1.30 → exprmat-0.1.32}/Cargo.lock +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/Cargo.toml +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/ansi.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/clustering/__init__.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/clustering/cnmf.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/clustering/dbscan.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/clustering/kmeans.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/clustering/leiden.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/clustering/nmf.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/clustering/rogue.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/clustering/seriation.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/clustering/spectral.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/clustering/utils.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/cnv/__init__.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/cnv/cnvscore.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/cnv/infercnv.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/configuration.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/data/__init__.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/data/cistarget.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/data/delim.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/data/finders.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/data/geneset.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/data/gff.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/data/io.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/data/lr.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/data/presets.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/data/private.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/data/ranges.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/data/signature.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/data/tf.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/descriptive/__init__.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/descriptive/aggregate.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/descriptive/atac.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/descriptive/aucell.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/descriptive/de.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/descriptive/gse.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/descriptive/kde.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/descriptive/recovery.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/descriptive/summary.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/descriptive/tcr.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/dynamics/__init__.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/dynamics/generank.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/dynamics/linreg.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/dynamics/moments.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/dynamics/optimization.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/dynamics/parallel.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/dynamics/preprocess.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/dynamics/pseudotime.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/dynamics/transition.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/dynamics/utils.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/dynamics/velocity.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/grn/__init__.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/grn/infergrn.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/grn/modules.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/grn/prune.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/grn/regressors.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/grn/utils.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/lr/__init__.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/lr/aggregate.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/lr/method.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/lr/methods/__init__.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/lr/methods/cellchat.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/lr/methods/cellphonedb.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/lr/methods/connectome.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/lr/methods/geomean.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/lr/methods/logfc.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/lr/methods/natmi.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/lr/methods/rank_aggregate.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/lr/methods/scseqcomm.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/lr/methods/singlecellsignalr.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/lr/pipeline.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/lr/preprocess.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/lr/resources.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/lr/utils.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/plotting/__init__.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/plotting/atac.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/plotting/cnv.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/plotting/gse.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/plotting/palettes.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/plotting/sankey.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/plotting/summary.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/plotting/track.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/plotting/velocity.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/preprocessing/__init__.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/preprocessing/doublets/__init__.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/preprocessing/doublets/composite.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/preprocessing/doublets/scrublet.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/preprocessing/emptydrops.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/preprocessing/filter.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/preprocessing/impute/__init__.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/preprocessing/impute/magic.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/preprocessing/integrate.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/preprocessing/linear.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/preprocessing/normal.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/preprocessing/plot.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/preprocessing/qc.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/preprocessing/sctransform/__init__.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/preprocessing/sctransform/estimate.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/preprocessing/sctransform/ksmooth.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/preprocessing/sctransform/residual.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/preprocessing/sctransform/transform.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/preprocessing/sparse.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/preprocessing/uniform.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/reader/__init__.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/reader/matcher.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/reader/metadata.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/reader/peaks.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/reduction/__init__.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/reduction/forceatlas.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/reduction/mde.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/reduction/nn.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/reduction/outliers.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/reduction/pca.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/reduction/spectral.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/reduction/tsne.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/reduction/umap.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/trajectory/pcurve.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/transfer/__init__.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/transfer/atlas.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/exprmat/utils.py +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/license +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/readme.md +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/snapatac2/Cargo.toml +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/snapatac2/license +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/snapatac2/readme +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/snapatac2/src/call_peaks.rs +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/snapatac2/src/embedding.rs +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/snapatac2/src/export.rs +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/snapatac2/src/knn.rs +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/snapatac2/src/lib.rs +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/snapatac2/src/motif.rs +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/snapatac2/src/network.rs +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/snapatac2/src/preprocessing.rs +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/snapatac2/src/utils/anndata.rs +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/snapatac2/src/utils.rs +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/snapatac2-core/Cargo.toml +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/snapatac2-core/src/embedding.rs +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/snapatac2-core/src/export.rs +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/snapatac2-core/src/feature_count/counter.rs +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/snapatac2-core/src/feature_count/data_iter.rs +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/snapatac2-core/src/feature_count/matrix.rs +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/snapatac2-core/src/feature_count/mod.rs +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/snapatac2-core/src/genome.rs +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/snapatac2-core/src/lib.rs +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/snapatac2-core/src/motif.rs +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/snapatac2-core/src/network.rs +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/snapatac2-core/src/preprocessing/bam/flagstat.rs +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/snapatac2-core/src/preprocessing/bam/header.rs +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/snapatac2-core/src/preprocessing/bam/mark_duplicates.rs +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/snapatac2-core/src/preprocessing/bam.rs +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/snapatac2-core/src/preprocessing/import.rs +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/snapatac2-core/src/preprocessing/mod.rs +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/snapatac2-core/src/preprocessing/qc.rs +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/snapatac2-core/src/utils/knn.rs +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/snapatac2-core/src/utils/mod.rs +0 -0
- {exprmat-0.1.30 → exprmat-0.1.32}/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.32
|
|
4
4
|
Classifier: Programming Language :: Rust
|
|
5
5
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
6
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
@@ -42,7 +42,6 @@ Requires-Dist: metacells
|
|
|
42
42
|
Requires-Dist: sh
|
|
43
43
|
Requires-Dist: networkx
|
|
44
44
|
Requires-Dist: palantir
|
|
45
|
-
Requires-Dist: scfates
|
|
46
45
|
Requires-Dist: rich
|
|
47
46
|
Requires-Dist: adjusttext
|
|
48
47
|
Requires-Dist: h5py
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import matplotlib.pyplot as plt
|
|
3
3
|
import pandas as pd
|
|
4
|
+
import numpy as np
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
def cnmf_silhoutte(adata, nmf_slot = 'cnmf', figsize = (3, 2), dpi = 100):
|
|
@@ -64,7 +65,11 @@ def cnmf_distance_usages(
|
|
|
64
65
|
from exprmat.clustering.seriation import serial_matrix, squareform
|
|
65
66
|
serial, order, _ = serial_matrix(squareform(pdistc), method = method)
|
|
66
67
|
indices = adata.obs.iloc[subset, :].iloc[order, :].index.tolist()
|
|
67
|
-
if annotations:
|
|
68
|
+
if annotations:
|
|
69
|
+
if annotations in adata.obs.columns:
|
|
70
|
+
annotations = adata.obs.iloc[subset, :].iloc[order, :][annotations].tolist()
|
|
71
|
+
elif annotations in adata.obsm.keys():
|
|
72
|
+
annotations = adata[subset, :][order, :].obsm[annotations]
|
|
68
73
|
|
|
69
74
|
return matrix_plot(
|
|
70
75
|
serial, labels = indices, annotations = annotations, cmap_annotations = cmap_annotations,
|
|
@@ -90,7 +95,11 @@ def cnmf_distance_modules(
|
|
|
90
95
|
from exprmat.clustering.seriation import serial_matrix, squareform
|
|
91
96
|
serial, order, _ = serial_matrix(squareform(pdistc), method = method)
|
|
92
97
|
indices = adata.var.iloc[subset, :].iloc[order, :].index.tolist()
|
|
93
|
-
if annotations:
|
|
98
|
+
if annotations:
|
|
99
|
+
if annotations in adata.var.columns:
|
|
100
|
+
annotations = adata.var.iloc[subset, :].iloc[order, :][annotations].tolist()
|
|
101
|
+
elif annotations in adata.varm.keys():
|
|
102
|
+
annotations = adata[subset, :][order, :].varm[annotations]
|
|
94
103
|
|
|
95
104
|
return matrix_plot(
|
|
96
105
|
serial, labels = indices, annotations = annotations, cmap_annotations = cmap_annotations,
|
|
@@ -114,7 +123,8 @@ def matrix_plot(
|
|
|
114
123
|
ax.set_yticklabels(labels)
|
|
115
124
|
ax.set_xticks([])
|
|
116
125
|
|
|
117
|
-
|
|
126
|
+
# categorical annotations
|
|
127
|
+
if annotations is not None and isinstance(annotations, list):
|
|
118
128
|
ax_annot = ax.inset_axes([1.02, 0, 0.05, 1], sharey = ax)
|
|
119
129
|
annot_u = list(set(annotations))
|
|
120
130
|
annot_n = [annot_u.index(x) for x in annotations]
|
|
@@ -151,4 +161,29 @@ def matrix_plot(
|
|
|
151
161
|
ncol = legend_cols
|
|
152
162
|
)
|
|
153
163
|
|
|
164
|
+
# numerical annotations (from obsm or varm)
|
|
165
|
+
elif annotations is not None and (
|
|
166
|
+
isinstance(annotations, np.ndarray) or
|
|
167
|
+
isinstance(annotations, np.matrix) or
|
|
168
|
+
isinstance(annotations, pd.DataFrame)
|
|
169
|
+
):
|
|
170
|
+
xn = None
|
|
171
|
+
if isinstance(annotations, pd.DataFrame):
|
|
172
|
+
xn = annotations.columns.tolist()
|
|
173
|
+
annotations = annotations.values
|
|
174
|
+
|
|
175
|
+
ncol = annotations.shape[1]
|
|
176
|
+
ax_annot = ax.inset_axes([1.05, 0, max(0.3, 0.07 * ncol), 1], sharey = ax)
|
|
177
|
+
|
|
178
|
+
ax_annot.imshow(annotations, cmap = cmap_annotations, aspect = 'auto', interpolation = 'nearest')
|
|
179
|
+
# ax_annot.set_yticks([])
|
|
180
|
+
if xn:
|
|
181
|
+
ax_annot.set_xticks([x for x in range(len(xn))])
|
|
182
|
+
ax_annot.set_xticklabels(xn, rotation = 90)
|
|
183
|
+
else:
|
|
184
|
+
ax_annot.set_xticks([0])
|
|
185
|
+
ax_annot.set_xticklabels([''])
|
|
186
|
+
|
|
187
|
+
ax_annot.tick_params(axis = "y", labelleft = False, length = 0)
|
|
188
|
+
|
|
154
189
|
return fig
|
|
@@ -280,8 +280,8 @@ def marker_plot(
|
|
|
280
280
|
adata,
|
|
281
281
|
var_names,
|
|
282
282
|
groupby,
|
|
283
|
-
show=
|
|
284
|
-
save=save,
|
|
283
|
+
show = False,
|
|
284
|
+
save = save,
|
|
285
285
|
gene_symbols = gene_symbols,
|
|
286
286
|
**kwds,
|
|
287
287
|
)
|
|
@@ -293,8 +293,8 @@ def marker_plot(
|
|
|
293
293
|
adata,
|
|
294
294
|
var_names,
|
|
295
295
|
groupby,
|
|
296
|
-
show=
|
|
297
|
-
save=save,
|
|
296
|
+
show = False,
|
|
297
|
+
save = save,
|
|
298
298
|
gene_symbols = gene_symbols,
|
|
299
299
|
**kwds,
|
|
300
300
|
)
|
|
@@ -8,13 +8,13 @@ from exprmat.utils import find_variable, choose_layer
|
|
|
8
8
|
|
|
9
9
|
def barplot(
|
|
10
10
|
adata, *, gene,
|
|
11
|
-
slot = 'X', group = 'cell.type', selected_groups = None,
|
|
11
|
+
slot = 'X', group = 'cell.type', selected_groups = None, selected_splits = None,
|
|
12
12
|
split = 'treat', palette = ['red', 'black'], ax = None,
|
|
13
13
|
size = (6,3), dpi = 100
|
|
14
14
|
):
|
|
15
15
|
|
|
16
|
-
plt.rcParams["ytick.labelright"] =
|
|
17
|
-
plt.rcParams["ytick.labelleft"] =
|
|
16
|
+
plt.rcParams["ytick.labelright"] = False
|
|
17
|
+
plt.rcParams["ytick.labelleft"] = True
|
|
18
18
|
|
|
19
19
|
colnames = ['logc' + x for x in [gene]]
|
|
20
20
|
cellnames = ['c' + str(i) for i in range(len(adata.obs_names.tolist()))]
|
|
@@ -36,6 +36,13 @@ def barplot(
|
|
|
36
36
|
dropzeros['selected.celltype'] = select_ct
|
|
37
37
|
dropzeros = dropzeros.loc[dropzeros['selected.celltype'],:]
|
|
38
38
|
|
|
39
|
+
if selected_splits is None:
|
|
40
|
+
if split is not None: selected_splits = adata.obs[split].value_counts().index.tolist()
|
|
41
|
+
else: selected_splits = ['default.split']
|
|
42
|
+
|
|
43
|
+
select_sp = [x in selected_splits for x in dropzeros['split'].tolist()]
|
|
44
|
+
dropzeros = dropzeros.loc[select_sp,:]
|
|
45
|
+
|
|
39
46
|
if ax is None: fig, axes = plt.subplots(1, 1, figsize = size, dpi = dpi)
|
|
40
47
|
else: axes = ax
|
|
41
48
|
|
|
@@ -49,7 +56,7 @@ def barplot(
|
|
|
49
56
|
)
|
|
50
57
|
|
|
51
58
|
axes.tick_params(
|
|
52
|
-
axis = 'y', right =
|
|
59
|
+
axis = 'y', right = False, left = True, color = 'gray', length = 4,
|
|
53
60
|
grid_color = 'none'
|
|
54
61
|
)
|
|
55
62
|
|
|
@@ -58,7 +65,7 @@ def barplot(
|
|
|
58
65
|
grid_color = 'lightgray'
|
|
59
66
|
)
|
|
60
67
|
|
|
61
|
-
axes.legend(bbox_to_anchor = (1
|
|
68
|
+
axes.legend(bbox_to_anchor = (1, 1), loc = 'upper left', borderaxespad = 0, frameon = False)
|
|
62
69
|
axes.set_xlabel('')
|
|
63
70
|
axes.set_ylabel(gene)
|
|
64
71
|
# axes.set_xticks(selected_groups)
|
|
@@ -93,7 +100,7 @@ def barplot(
|
|
|
93
100
|
axes.set_xticklabels([xtl], rotation = 45)
|
|
94
101
|
pass
|
|
95
102
|
|
|
96
|
-
axes.spines[['
|
|
103
|
+
axes.spines[['right', 'top']].set_visible(False)
|
|
97
104
|
axes.yaxis.set_major_formatter(ticker.StrMethodFormatter("{x:.1f}"))
|
|
98
105
|
|
|
99
106
|
if ax is None: return fig
|
|
@@ -81,7 +81,8 @@ def filter_by(liana_res, filter_fun):
|
|
|
81
81
|
if filter_fun is not None:
|
|
82
82
|
msk = filter_fun(liana_res).astype(bool)
|
|
83
83
|
relevant_interactions = np.unique(liana_res[msk].interaction)
|
|
84
|
-
liana_res = liana_res[np.isin(liana_res['interaction'], relevant_interactions)]
|
|
84
|
+
# liana_res = liana_res[np.isin(liana_res['interaction'], relevant_interactions)]
|
|
85
|
+
liana_res = liana_res[msk]
|
|
85
86
|
|
|
86
87
|
return liana_res
|
|
87
88
|
|
|
@@ -124,6 +125,7 @@ def pivot_lr(
|
|
|
124
125
|
|
|
125
126
|
if mode not in ['counts', 'mean']:
|
|
126
127
|
error("`pivot_mode` must be 'counts' or 'mean'.")
|
|
128
|
+
|
|
127
129
|
if mode == 'counts':
|
|
128
130
|
pivot_table = liana_res.pivot_table(
|
|
129
131
|
index = source_key, columns = target_key,
|
|
@@ -136,7 +138,7 @@ def pivot_lr(
|
|
|
136
138
|
values = score_key, aggfunc = 'mean', fill_value = 0
|
|
137
139
|
)
|
|
138
140
|
|
|
139
|
-
return pivot_table
|
|
141
|
+
return pivot_table.loc[pivot_table.columns, :]
|
|
140
142
|
|
|
141
143
|
|
|
142
144
|
def scale(arr, min_val = 1, max_val = 5):
|
|
@@ -163,15 +165,17 @@ def set_color(adata, label, color_dict = None, hex = True):
|
|
|
163
165
|
color_dict[x] for x in adata.obs[label].cat.categories
|
|
164
166
|
]
|
|
165
167
|
|
|
166
|
-
elif f"{label}.colors" not in adata.uns:
|
|
168
|
+
elif f"{label}.colors" not in adata.uns.keys():
|
|
167
169
|
sc.pl._utils._set_default_colors_for_categorical_obs(adata, label)
|
|
170
|
+
adata.uns[f"{label}.colors"] = adata.uns[f"{label}_colors"]
|
|
171
|
+
del adata.uns[f"{label}_colors"]
|
|
168
172
|
|
|
169
173
|
return adata
|
|
170
174
|
|
|
171
175
|
|
|
172
176
|
def get_color(adata, label):
|
|
173
177
|
|
|
174
|
-
if f"{label}.colors" not in adata.uns: set_color(adata, label)
|
|
178
|
+
if f"{label}.colors" not in adata.uns.keys(): set_color(adata, label)
|
|
175
179
|
return {
|
|
176
180
|
x: y for x, y in zip(
|
|
177
181
|
adata.obs[label].cat.categories,
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import seaborn as sns
|
|
3
3
|
import numpy as np
|
|
4
4
|
import matplotlib.pyplot as plt
|
|
5
|
+
import pandas as pd
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
def linregress(
|
|
@@ -253,4 +254,59 @@ def density(
|
|
|
253
254
|
axis.set_yticks([yscale(z) for z in yticks])
|
|
254
255
|
if yticklabels: axis.set_yticklabels(yticklabels)
|
|
255
256
|
|
|
257
|
+
return fig
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
def waterfall(
|
|
261
|
+
df: pd.DataFrame, name = 'name', resolution = 'resolution', ax = None,
|
|
262
|
+
figsize = (3, 3), dpi = 100, ylabel = None
|
|
263
|
+
):
|
|
264
|
+
if ax is not None: fig, ax = ax.figure, ax
|
|
265
|
+
else: fig, ax = plt.subplots(1, 1, figsize = figsize, dpi = dpi)
|
|
266
|
+
|
|
267
|
+
# sort descending
|
|
268
|
+
df = df.sort_values([resolution], ascending = False)
|
|
269
|
+
maximal = 0
|
|
270
|
+
minimal = 0
|
|
271
|
+
|
|
272
|
+
series = df[resolution]
|
|
273
|
+
|
|
274
|
+
if (series > 1).sum() > 0: maximal = series.max()
|
|
275
|
+
elif (series > 0.5).sum() > 0: maximal = 0.8
|
|
276
|
+
elif (series > 0.3).sum() > 0: maximal = 0.5
|
|
277
|
+
elif (series > 0).sum() > 0: maximal = 0.3
|
|
278
|
+
else: maximal = 0
|
|
279
|
+
|
|
280
|
+
if (series < 0.8).sum() > 0: minimal = -1
|
|
281
|
+
elif (series < 0.5).sum() > 0: maximal = -0.8
|
|
282
|
+
elif (series < 0.3).sum() > 0: maximal = -0.5
|
|
283
|
+
elif (series < 0).sum() > 0: maximal = -0.3
|
|
284
|
+
else: minimal = 0
|
|
285
|
+
|
|
286
|
+
ticks = [-1, -0.8, -0.5, -0.3, 0, 0.3, 0.5, 0.8, 1, max(1.1, series.max())]
|
|
287
|
+
ticks = [x for x in ticks if x >= minimal and x <= maximal]
|
|
288
|
+
hlines = [-0.5, -0.3, 0, 0.3]
|
|
289
|
+
hlines = [x for x in hlines if x >= minimal and x <= maximal]
|
|
290
|
+
|
|
291
|
+
ax.set_xlim(0, len(series))
|
|
292
|
+
ax.set_ylim(minimal, maximal)
|
|
293
|
+
ax.set_xticks([])
|
|
294
|
+
ax.set_yticks(ticks)
|
|
295
|
+
ax.set_yticklabels([f'{x * 100:.0f}%' for x in ticks])
|
|
296
|
+
if ylabel: ax.set_ylabel(ylabel)
|
|
297
|
+
|
|
298
|
+
for i, val in enumerate(series):
|
|
299
|
+
color = 'orange'
|
|
300
|
+
if val > 0.3: color = 'red'
|
|
301
|
+
elif val < -0.99: color = 'dodgerblue'
|
|
302
|
+
elif val < -0.3: color = 'gold'
|
|
303
|
+
ax.fill_between([i + 0.2, i + 0.8], [0, 0], [val, val], color = color)
|
|
304
|
+
|
|
305
|
+
for hl in hlines:
|
|
306
|
+
ax.hlines(hl, 0, len(series), linestyles = '--', colors = 'red', lw = 1)
|
|
307
|
+
ax.hlines(0, 0, len(series), linestyles = '-', colors = 'black', lw = 1)
|
|
308
|
+
|
|
309
|
+
for pos in ['right', 'top', 'bottom']:
|
|
310
|
+
ax.spines[pos].set_visible(False)
|
|
311
|
+
|
|
256
312
|
return fig
|
|
@@ -1103,6 +1103,9 @@ class experiment:
|
|
|
1103
1103
|
def plot_rna_embedding(self, run_on_samples = False, **kwargs):
|
|
1104
1104
|
return self.plot_for_rna(run_on_samples, st.rna_plot_embedding, **kwargs)
|
|
1105
1105
|
|
|
1106
|
+
def plot_rna_embedding_mask(self, run_on_samples = False, **kwargs):
|
|
1107
|
+
return self.plot_for_rna(run_on_samples, st.rna_plot_embedding_mask, **kwargs)
|
|
1108
|
+
|
|
1106
1109
|
def plot_rna_embedding_atlas(self, run_on_samples = False, **kwargs):
|
|
1107
1110
|
return self.plot_for_rna(run_on_samples, st.rna_plot_embedding_atlas, **kwargs)
|
|
1108
1111
|
|
|
@@ -765,6 +765,16 @@ def rna_plot_embedding(adata, sample_name, **kwargs):
|
|
|
765
765
|
return embedding(adata, sample_name = sample_name, **kwargs)
|
|
766
766
|
|
|
767
767
|
|
|
768
|
+
def rna_plot_embedding_mask(adata, sample_name, color, values, **kwargs):
|
|
769
|
+
from exprmat.reduction.plot import embedding
|
|
770
|
+
if color in adata.obs.keys():
|
|
771
|
+
adata.obs['.mask'] = [x in values for x in adata.obs[color]]
|
|
772
|
+
else: error('`color` must be within adata.obs')
|
|
773
|
+
fig = embedding(adata, sample_name = sample_name, color = '.mask', **kwargs)
|
|
774
|
+
if color in adata.obs.keys(): del adata.obs['.mask']
|
|
775
|
+
return fig
|
|
776
|
+
|
|
777
|
+
|
|
768
778
|
def rna_plot_embedding_atlas(adata, sample_name, **kwargs):
|
|
769
779
|
from exprmat.reduction.plot import embedding_atlas
|
|
770
780
|
return embedding_atlas(adata, sample_name = sample_name, **kwargs)
|
|
@@ -782,22 +792,37 @@ def rna_plot_gene_gene_regress(adata, sample_name, **kwargs):
|
|
|
782
792
|
def rna_plot_markers(adata, sample_name, figsize, dpi, **kwargs):
|
|
783
793
|
from exprmat.plotting.de import marker_plot
|
|
784
794
|
pl = marker_plot(adata, sample_name = sample_name, **kwargs)
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
pl
|
|
788
|
-
|
|
789
|
-
|
|
795
|
+
|
|
796
|
+
from scanpy.plotting import DotPlot, StackedViolin, MatrixPlot
|
|
797
|
+
if isinstance(pl, DotPlot) or isinstance(pl, StackedViolin) or isinstance(pl, MatrixPlot):
|
|
798
|
+
pl.width = figsize[0]
|
|
799
|
+
pl.height = figsize[1]
|
|
800
|
+
pl.show()
|
|
801
|
+
pl.fig.set_dpi(dpi)
|
|
802
|
+
return pl.fig
|
|
803
|
+
|
|
804
|
+
else:
|
|
805
|
+
fig = pl['heatmap_ax'].figure if 'heatmap_ax' in pl.keys() else None
|
|
806
|
+
fig = pl['track_axes'][0].figure if 'track_axes' in pl.keys() else fig
|
|
807
|
+
|
|
808
|
+
if fig:
|
|
809
|
+
fig.set_dpi(dpi)
|
|
810
|
+
fig.set_figwidth(figsize[0])
|
|
811
|
+
fig.set_figheight(figsize[1])
|
|
812
|
+
return fig
|
|
813
|
+
|
|
790
814
|
|
|
791
815
|
|
|
792
816
|
def rna_plot_expression_bar(
|
|
793
817
|
adata, sample_name, gene, group, split = None,
|
|
794
|
-
slot = 'X', selected_groups = None, palette = ['red', 'black'],
|
|
818
|
+
slot = 'X', selected_groups = None, selected_splits = None, palette = ['red', 'black'],
|
|
795
819
|
figsize = (6,3), dpi = 100
|
|
796
820
|
):
|
|
797
821
|
from exprmat.plotting.expression import barplot
|
|
798
822
|
pl = barplot(
|
|
799
823
|
adata, gene = gene, slot = slot, group = group,
|
|
800
|
-
split = split, selected_groups = selected_groups,
|
|
824
|
+
split = split, selected_groups = selected_groups,
|
|
825
|
+
selected_splits = selected_splits, palette = palette,
|
|
801
826
|
size = figsize, dpi = dpi
|
|
802
827
|
)
|
|
803
828
|
return pl
|
|
@@ -655,7 +655,7 @@ def gene_gene(
|
|
|
655
655
|
from exprmat.utils import find_variable as find_var
|
|
656
656
|
gx = find_var(adata, gene_name = gene_x, layer = layer)
|
|
657
657
|
gy = find_var(adata, gene_name = gene_y, layer = layer)
|
|
658
|
-
labels = find_var(color) if color is not None else ['.'] * len(gx)
|
|
658
|
+
labels = find_var(adata, color) if color is not None else ['.'] * len(gx)
|
|
659
659
|
|
|
660
660
|
df = pd.DataFrame({
|
|
661
661
|
'x': gx,
|
|
@@ -749,7 +749,7 @@ def gene_gene(
|
|
|
749
749
|
)
|
|
750
750
|
|
|
751
751
|
if legend:
|
|
752
|
-
assert len(adata.uns[f'{color}.colors'])
|
|
752
|
+
assert len(adata.uns[f'{color}.colors']) >= len(hue_order)
|
|
753
753
|
dummy_objects = []
|
|
754
754
|
legend_artists = {}
|
|
755
755
|
for legend_t, legend_c, legend_id in zip(
|
|
@@ -18,7 +18,7 @@ description = "exprmat: Routines for expression matrices"
|
|
|
18
18
|
readme = "readme.md"
|
|
19
19
|
license = {file = "license"}
|
|
20
20
|
requires-python = ">=3.9, <3.13"
|
|
21
|
-
version = "0.1.
|
|
21
|
+
version = "0.1.32"
|
|
22
22
|
authors = [
|
|
23
23
|
{name = "Zheng Yang", email = "xornent@outlook.com"}
|
|
24
24
|
]
|
|
@@ -68,7 +68,6 @@ dependencies = [
|
|
|
68
68
|
'sh',
|
|
69
69
|
'networkx',
|
|
70
70
|
'palantir',
|
|
71
|
-
'scfates',
|
|
72
71
|
'rich',
|
|
73
72
|
'adjustText',
|
|
74
73
|
'h5py',
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|