exprmat 0.1.29__tar.gz → 0.1.31__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.29 → exprmat-0.1.31}/PKG-INFO +2 -1
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/clustering/seriation.py +4 -3
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/dynamics/preprocess.py +0 -1
- exprmat-0.1.31/exprmat/plotting/cnmf.py +154 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/plotting/de.py +4 -4
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/plotting/expression.py +3 -2
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/preprocessing/integrate.py +16 -9
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/reader/experiment.py +3 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/reader/metadata.py +21 -8
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/reader/static.py +44 -7
- {exprmat-0.1.29 → exprmat-0.1.31}/pyproject.toml +3 -2
- exprmat-0.1.29/exprmat/plotting/cnmf.py +0 -66
- {exprmat-0.1.29 → exprmat-0.1.31}/Cargo.lock +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/Cargo.toml +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/__init__.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/ansi.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/clustering/__init__.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/clustering/cnmf.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/clustering/dbscan.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/clustering/kmeans.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/clustering/leiden.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/clustering/nmf.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/clustering/rogue.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/clustering/spectral.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/clustering/utils.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/cnv/__init__.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/cnv/cnvscore.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/cnv/infercnv.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/configuration.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/data/__init__.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/data/cistarget.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/data/delim.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/data/finders.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/data/geneset.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/data/gff.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/data/io.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/data/lr.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/data/presets.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/data/private.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/data/ranges.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/data/signature.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/data/tf.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/descriptive/__init__.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/descriptive/aggregate.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/descriptive/atac.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/descriptive/aucell.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/descriptive/de.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/descriptive/gse.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/descriptive/kde.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/descriptive/recovery.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/descriptive/summary.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/descriptive/tcr.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/dynamics/__init__.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/dynamics/generank.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/dynamics/linreg.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/dynamics/moments.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/dynamics/optimization.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/dynamics/parallel.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/dynamics/pseudotime.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/dynamics/transition.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/dynamics/utils.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/dynamics/velocity.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/grn/__init__.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/grn/infergrn.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/grn/modules.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/grn/prune.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/grn/regressors.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/grn/utils.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/lr/__init__.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/lr/aggregate.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/lr/method.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/lr/methods/__init__.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/lr/methods/cellchat.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/lr/methods/cellphonedb.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/lr/methods/connectome.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/lr/methods/geomean.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/lr/methods/logfc.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/lr/methods/natmi.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/lr/methods/rank_aggregate.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/lr/methods/scseqcomm.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/lr/methods/singlecellsignalr.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/lr/pipeline.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/lr/preprocess.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/lr/resources.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/lr/utils.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/plotting/__init__.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/plotting/atac.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/plotting/cnv.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/plotting/gse.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/plotting/lr.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/plotting/palettes.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/plotting/sankey.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/plotting/summary.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/plotting/track.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/plotting/utils.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/plotting/velocity.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/preprocessing/__init__.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/preprocessing/doublets/__init__.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/preprocessing/doublets/composite.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/preprocessing/doublets/scrublet.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/preprocessing/emptydrops.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/preprocessing/filter.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/preprocessing/impute/__init__.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/preprocessing/impute/magic.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/preprocessing/linear.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/preprocessing/normal.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/preprocessing/plot.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/preprocessing/qc.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/preprocessing/sctransform/__init__.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/preprocessing/sctransform/estimate.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/preprocessing/sctransform/ksmooth.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/preprocessing/sctransform/residual.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/preprocessing/sctransform/transform.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/preprocessing/sparse.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/preprocessing/uniform.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/reader/__init__.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/reader/matcher.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/reader/peaks.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/reduction/__init__.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/reduction/forceatlas.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/reduction/mde.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/reduction/nn.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/reduction/outliers.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/reduction/pca.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/reduction/plot.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/reduction/spectral.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/reduction/tsne.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/reduction/umap.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/trajectory/pcurve.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/transfer/__init__.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/transfer/atlas.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/exprmat/utils.py +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/license +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/readme.md +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/snapatac2/Cargo.toml +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/snapatac2/license +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/snapatac2/readme +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/snapatac2/src/call_peaks.rs +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/snapatac2/src/embedding.rs +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/snapatac2/src/export.rs +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/snapatac2/src/knn.rs +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/snapatac2/src/lib.rs +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/snapatac2/src/motif.rs +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/snapatac2/src/network.rs +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/snapatac2/src/preprocessing.rs +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/snapatac2/src/utils/anndata.rs +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/snapatac2/src/utils.rs +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/snapatac2-core/Cargo.toml +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/snapatac2-core/src/embedding.rs +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/snapatac2-core/src/export.rs +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/snapatac2-core/src/feature_count/counter.rs +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/snapatac2-core/src/feature_count/data_iter.rs +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/snapatac2-core/src/feature_count/matrix.rs +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/snapatac2-core/src/feature_count/mod.rs +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/snapatac2-core/src/genome.rs +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/snapatac2-core/src/lib.rs +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/snapatac2-core/src/motif.rs +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/snapatac2-core/src/network.rs +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/snapatac2-core/src/preprocessing/bam/flagstat.rs +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/snapatac2-core/src/preprocessing/bam/header.rs +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/snapatac2-core/src/preprocessing/bam/mark_duplicates.rs +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/snapatac2-core/src/preprocessing/bam.rs +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/snapatac2-core/src/preprocessing/import.rs +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/snapatac2-core/src/preprocessing/mod.rs +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/snapatac2-core/src/preprocessing/qc.rs +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/snapatac2-core/src/utils/knn.rs +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/snapatac2-core/src/utils/mod.rs +0 -0
- {exprmat-0.1.29 → exprmat-0.1.31}/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.31
|
|
4
4
|
Classifier: Programming Language :: Rust
|
|
5
5
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
6
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
@@ -56,6 +56,7 @@ Requires-Dist: hdbscan
|
|
|
56
56
|
Requires-Dist: graphtools
|
|
57
57
|
Requires-Dist: bincsync>=0.3.0
|
|
58
58
|
Requires-Dist: pybigwig
|
|
59
|
+
Requires-Dist: loompy
|
|
59
60
|
Requires-Dist: sphinx ; extra == 'dev'
|
|
60
61
|
Requires-Dist: sphinx-rtd-theme ; extra == 'dev'
|
|
61
62
|
Requires-Dist: twine ; extra == 'dev'
|
|
@@ -31,7 +31,7 @@ def seriation(Z, N, cur_index):
|
|
|
31
31
|
return (seriation(Z, N, left) + seriation(Z, N, right))
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
def serial_matrix(dist, method = "ward"):
|
|
34
|
+
def serial_matrix(dist, method = "ward", seed = 42):
|
|
35
35
|
'''
|
|
36
36
|
Compute_serial_matrix transforms a distance matrix into a sorted distance matrix
|
|
37
37
|
according to the order implied by the hierarchical tree (dendrogram).
|
|
@@ -51,13 +51,14 @@ def serial_matrix(dist, method = "ward"):
|
|
|
51
51
|
- res_order: The order implied by the hierarhical tree
|
|
52
52
|
- res_linkage: The hierarhical tree (dendrogram)
|
|
53
53
|
'''
|
|
54
|
+
np.random.seed(seed)
|
|
54
55
|
|
|
55
56
|
N = len(dist)
|
|
56
57
|
flat_dist_mat = squareform(dist)
|
|
57
|
-
res_linkage = linkage(flat_dist_mat, method=method,preserve_input=True)
|
|
58
|
+
res_linkage = linkage(flat_dist_mat, method = method,preserve_input = True)
|
|
58
59
|
res_order = seriation(res_linkage, N, N + N-2)
|
|
59
60
|
seriated_dist = np.zeros((N,N))
|
|
60
|
-
a,b = np.triu_indices(N,k=1)
|
|
61
|
+
a,b = np.triu_indices(N, k = 1)
|
|
61
62
|
seriated_dist[a,b] = dist[ [res_order[i] for i in a], [res_order[j] for j in b]]
|
|
62
63
|
seriated_dist[b,a] = seriated_dist[a,b]
|
|
63
64
|
|
|
@@ -5,7 +5,6 @@ import pandas as pd
|
|
|
5
5
|
from scipy.sparse import issparse
|
|
6
6
|
from sklearn.utils import sparsefuncs
|
|
7
7
|
|
|
8
|
-
from scvelo.core import get_initial_size, set_initial_size
|
|
9
8
|
from exprmat.preprocessing import normalize, log1p
|
|
10
9
|
from exprmat.dynamics.generank import get_mean_var
|
|
11
10
|
from exprmat.dynamics.linreg import sum, multiply
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
|
|
2
|
+
import matplotlib.pyplot as plt
|
|
3
|
+
import pandas as pd
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def cnmf_silhoutte(adata, nmf_slot = 'cnmf', figsize = (3, 2), dpi = 100):
|
|
7
|
+
|
|
8
|
+
fig = plt.figure(figsize = figsize, dpi = dpi)
|
|
9
|
+
df = adata.uns[f'{nmf_slot}.stats']
|
|
10
|
+
fig.gca().plot(df.ncomps, df.silhoutte, color = 'k')
|
|
11
|
+
|
|
12
|
+
# fig.gca().set_ylim([-0.1, 1.1])
|
|
13
|
+
# fig.gca().set_yticks([0, 0.25, 0.5, 0.75, 1])
|
|
14
|
+
fig.gca().set_ylabel('Silhoutte score')
|
|
15
|
+
|
|
16
|
+
fig.gca().set_xlabel('NMF components')
|
|
17
|
+
fig.gca().set_xticks(df.ncomps)
|
|
18
|
+
|
|
19
|
+
for pos in ['right', 'top']:
|
|
20
|
+
fig.gca().spines[pos].set_visible(False)
|
|
21
|
+
|
|
22
|
+
return fig
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def cnmf_density(adata, k, nmf_slot = 'cnmf', figsize = (3, 2), dpi = 100):
|
|
26
|
+
|
|
27
|
+
fig = plt.figure(figsize = figsize, dpi = dpi)
|
|
28
|
+
df = adata.uns[f'{nmf_slot}.density.{k}']
|
|
29
|
+
fig.gca().hist(df, bins = 100, color = 'k')
|
|
30
|
+
|
|
31
|
+
fig.gca().set_ylabel('Local density')
|
|
32
|
+
fig.gca().set_xlabel('Distance')
|
|
33
|
+
|
|
34
|
+
for pos in ['right', 'top']:
|
|
35
|
+
fig.gca().spines[pos].set_visible(False)
|
|
36
|
+
|
|
37
|
+
return fig
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def cnmf_distance_comps(adata, k, nmf_slot = 'cnmf', cmap = 'Reds_r', figsize = (3, 3), dpi = 100):
|
|
41
|
+
|
|
42
|
+
fig = plt.figure(figsize = figsize, dpi = dpi)
|
|
43
|
+
df = adata.uns[f'{nmf_slot}.dist.{k}']
|
|
44
|
+
fig.gca().imshow(df, cmap = cmap)
|
|
45
|
+
|
|
46
|
+
return fig
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def cnmf_distance_usages(
|
|
50
|
+
adata, k, nmf_slot = 'cnmf', metrics = 'cosine', downsample = 0.1, method = 'single',
|
|
51
|
+
annotations = None, show_indices = False, legend_cols = 1,
|
|
52
|
+
cmap = 'Reds_r', cmap_annotations = 'Set1', figsize = (3, 3), dpi = 100
|
|
53
|
+
):
|
|
54
|
+
|
|
55
|
+
import numpy as np
|
|
56
|
+
|
|
57
|
+
df = adata.obsm[f'{nmf_slot}.{k}']
|
|
58
|
+
nrow = df.shape[0]
|
|
59
|
+
subset = np.random.choice(range(nrow), int(nrow * downsample), replace = False)
|
|
60
|
+
from exprmat.clustering.seriation import pdist
|
|
61
|
+
data = df.iloc[subset, :].copy()
|
|
62
|
+
pdistc = pdist(data, metric = metrics)
|
|
63
|
+
|
|
64
|
+
from exprmat.clustering.seriation import serial_matrix, squareform
|
|
65
|
+
serial, order, _ = serial_matrix(squareform(pdistc), method = method)
|
|
66
|
+
indices = adata.obs.iloc[subset, :].iloc[order, :].index.tolist()
|
|
67
|
+
if annotations: annotations = adata.obs.iloc[subset, :].iloc[order, :][annotations].tolist()
|
|
68
|
+
|
|
69
|
+
return matrix_plot(
|
|
70
|
+
serial, labels = indices, annotations = annotations, cmap_annotations = cmap_annotations,
|
|
71
|
+
cmap = cmap, figsize = figsize, dpi = dpi, show_indices = show_indices,
|
|
72
|
+
legend_cols = legend_cols
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def cnmf_distance_modules(
|
|
77
|
+
adata, k, nmf_slot = 'cnmf', metrics = 'cosine', downsample = 1, method = 'complete',
|
|
78
|
+
annotations = None, cmap_annotations = 'Set1', show_indices = False,
|
|
79
|
+
cmap = 'Reds_r', figsize = (3, 3), dpi = 100, legend_cols = 1
|
|
80
|
+
):
|
|
81
|
+
|
|
82
|
+
import numpy as np
|
|
83
|
+
df = adata.varm[f'{nmf_slot}.{k}']
|
|
84
|
+
nrow = df.shape[0]
|
|
85
|
+
subset = np.random.choice(range(nrow), int(nrow * downsample), replace = False)
|
|
86
|
+
from exprmat.clustering.seriation import pdist
|
|
87
|
+
data = df[subset, :].copy()
|
|
88
|
+
pdistc = pdist(data, metric = metrics)
|
|
89
|
+
|
|
90
|
+
from exprmat.clustering.seriation import serial_matrix, squareform
|
|
91
|
+
serial, order, _ = serial_matrix(squareform(pdistc), method = method)
|
|
92
|
+
indices = adata.var.iloc[subset, :].iloc[order, :].index.tolist()
|
|
93
|
+
if annotations: annotations = adata.var.iloc[subset, :].iloc[order, :][annotations].tolist()
|
|
94
|
+
|
|
95
|
+
return matrix_plot(
|
|
96
|
+
serial, labels = indices, annotations = annotations, cmap_annotations = cmap_annotations,
|
|
97
|
+
cmap = cmap, figsize = figsize, dpi = dpi, show_indices = show_indices, legend_cols = legend_cols
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def matrix_plot(
|
|
102
|
+
mat, labels = None, annotations = None,
|
|
103
|
+
cmap = 'Reds_r', cmap_annotations = 'Set1',
|
|
104
|
+
show_indices = True,
|
|
105
|
+
figsize = (3, 3), dpi = 100, legend_cols = 1
|
|
106
|
+
):
|
|
107
|
+
fig = plt.figure(figsize = figsize, dpi = dpi)
|
|
108
|
+
fig.gca().imshow(mat, cmap = cmap)
|
|
109
|
+
ax = fig.gca()
|
|
110
|
+
ax.set_yticks([])
|
|
111
|
+
ax.set_xticks([])
|
|
112
|
+
if labels is not None and show_indices:
|
|
113
|
+
ax.set_yticks([x for x in range(len(labels))])
|
|
114
|
+
ax.set_yticklabels(labels)
|
|
115
|
+
ax.set_xticks([])
|
|
116
|
+
|
|
117
|
+
if annotations is not None:
|
|
118
|
+
ax_annot = ax.inset_axes([1.02, 0, 0.05, 1], sharey = ax)
|
|
119
|
+
annot_u = list(set(annotations))
|
|
120
|
+
annot_n = [annot_u.index(x) for x in annotations]
|
|
121
|
+
|
|
122
|
+
from exprmat.plotting import palettes
|
|
123
|
+
colors = list(palettes.linear_palette(palettes.all_palettes[cmap_annotations][
|
|
124
|
+
list(palettes.all_palettes[cmap_annotations].keys())[-1]
|
|
125
|
+
], len(annot_u)))
|
|
126
|
+
colormap = {x: y for x, y in zip(annot_u, colors)}
|
|
127
|
+
|
|
128
|
+
ax_annot.set_xlim(-0.5, 0.5)
|
|
129
|
+
ax_annot.set_ylim(len(annot_n) - 0.5, -0.5)
|
|
130
|
+
for idx, x in enumerate(annot_n):
|
|
131
|
+
ax_annot.fill_between([-0.5, 0.5], [idx - 0.5, idx - 0.5], [idx + 0.5, idx + 0.5], color = colormap[annot_u[x]])
|
|
132
|
+
|
|
133
|
+
# ax_annot.set_yticks([])
|
|
134
|
+
ax_annot.set_xticks([0])
|
|
135
|
+
ax_annot.set_xticklabels([''])
|
|
136
|
+
ax_annot.tick_params(axis = "y", labelleft = False, length = 0)
|
|
137
|
+
|
|
138
|
+
from matplotlib.lines import Line2D as line2d
|
|
139
|
+
|
|
140
|
+
legend_elements = [
|
|
141
|
+
line2d([0], [0], marker = 's', color = 'w', label = alab,
|
|
142
|
+
markerfacecolor = acol, markersize = 8)
|
|
143
|
+
for alab, acol in zip(annot_u, colors)
|
|
144
|
+
]
|
|
145
|
+
|
|
146
|
+
ax_annot.legend(
|
|
147
|
+
handles = legend_elements,
|
|
148
|
+
bbox_to_anchor = (1.0, 1),
|
|
149
|
+
loc = 'upper left',
|
|
150
|
+
borderaxespad = 0, frameon = False,
|
|
151
|
+
ncol = legend_cols
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
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
|
)
|
|
@@ -58,7 +58,7 @@ def barplot(
|
|
|
58
58
|
grid_color = 'lightgray'
|
|
59
59
|
)
|
|
60
60
|
|
|
61
|
-
axes.legend(
|
|
61
|
+
axes.legend(bbox_to_anchor = (1.2, 1), loc = 'upper left', borderaxespad = 0, frameon = False)
|
|
62
62
|
axes.set_xlabel('')
|
|
63
63
|
axes.set_ylabel(gene)
|
|
64
64
|
# axes.set_xticks(selected_groups)
|
|
@@ -80,7 +80,7 @@ def barplot(
|
|
|
80
80
|
xtl += [ct + '\n{:.3f}'.format(w.pvalue)]
|
|
81
81
|
else: xtl += [ct]
|
|
82
82
|
|
|
83
|
-
axes.set_xticks(selected_groups)
|
|
83
|
+
# axes.set_xticks(selected_groups)
|
|
84
84
|
axes.set_xticklabels(xtl, rotation = 45)
|
|
85
85
|
|
|
86
86
|
else:
|
|
@@ -123,6 +123,7 @@ def compare_scatter(
|
|
|
123
123
|
|
|
124
124
|
plt.xlabel(f'Average expression in {group_x}')
|
|
125
125
|
plt.ylabel(f'Average expression in {group_y}')
|
|
126
|
+
plt.plot([0, mean_x.max()], [0, mean_x.max()], linewidth = 1, linestyle = '--', color = 'red')
|
|
126
127
|
|
|
127
128
|
for x, y, name in zip(mean_x, mean_y, varn):
|
|
128
129
|
if name in markers:
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import anndata as ad
|
|
3
3
|
import numpy as np
|
|
4
|
+
from exprmat.utils import choose_layer
|
|
4
5
|
from exprmat.ansi import error, warning
|
|
5
6
|
|
|
6
7
|
|
|
@@ -148,6 +149,8 @@ def harmony(
|
|
|
148
149
|
*,
|
|
149
150
|
basis: str = "pca",
|
|
150
151
|
adjusted_basis: str = "harmony",
|
|
152
|
+
transform_data = False,
|
|
153
|
+
data_slot = 'X',
|
|
151
154
|
**kwargs,
|
|
152
155
|
):
|
|
153
156
|
"""
|
|
@@ -220,16 +223,20 @@ def harmony(
|
|
|
220
223
|
default_params.update(kwargs)
|
|
221
224
|
harmony_out = harmonypy.run_harmony(X, adata.obs, key, **default_params)
|
|
222
225
|
adata.obsm[adjusted_basis] = harmony_out.Z_corr.T
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
226
|
+
|
|
227
|
+
if transform_data:
|
|
228
|
+
data = choose_layer(adata, layer = data_slot)
|
|
229
|
+
_, x_corr, _, _ = moe_correct_ridge(
|
|
230
|
+
data, None, None,
|
|
231
|
+
harmony_out.R, None,
|
|
232
|
+
harmony_out.K, None,
|
|
233
|
+
harmony_out.Phi_moe, harmony_out.lamb
|
|
234
|
+
)
|
|
229
235
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
236
|
+
x_corr = np.array(x_corr.T)
|
|
237
|
+
x_corr[x_corr < 0] = 0
|
|
238
|
+
adata.layers[adjusted_basis] = x_corr
|
|
239
|
+
|
|
233
240
|
return adata
|
|
234
241
|
|
|
235
242
|
|
|
@@ -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
|
|
|
@@ -12,12 +12,22 @@ class metadata:
|
|
|
12
12
|
----------
|
|
13
13
|
|
|
14
14
|
locations : list[str]
|
|
15
|
-
File system paths indicating directories where the
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
File system paths indicating directories where the data files locate.
|
|
16
|
+
The protocols and procedures on how to load the dump files in the directory is
|
|
17
|
+
determined by `modality` and what this `location` points to. For example,
|
|
18
|
+
when `modality` is `rna`, the program will search for 10X-compatible mtx and
|
|
19
|
+
tsv files if a folder is provided, or h5ad/h5 files if files are specified directly.
|
|
20
20
|
|
|
21
|
+
modality : list[str]
|
|
22
|
+
What modality is in the location. Supported values are:
|
|
23
|
+
- `rna` (Single cell RNA-seq),
|
|
24
|
+
- `rna.splicing` (Supplementary spliced/unspliced counts in loom or mtx)
|
|
25
|
+
- `rna.tcr` (10X 5' TCR annotations),
|
|
26
|
+
- `atac` (Single cell ATAC-seq)
|
|
27
|
+
|
|
28
|
+
default_taxa : list[str]
|
|
29
|
+
The reference taxa of the sample.
|
|
30
|
+
|
|
21
31
|
names : list[str] | None
|
|
22
32
|
Sample names in the loaded experiment. If left to None, names of the folder will be
|
|
23
33
|
used. Since the folder names may duplicate, this is not forced to be unique. This might
|
|
@@ -28,6 +38,7 @@ class metadata:
|
|
|
28
38
|
|
|
29
39
|
groups : list[str] | None
|
|
30
40
|
Experimental groupings, if not set, this column is set to uniform value '.'.
|
|
41
|
+
|
|
31
42
|
|
|
32
43
|
Notes
|
|
33
44
|
-----------
|
|
@@ -37,6 +48,8 @@ class metadata:
|
|
|
37
48
|
modality, ``taxa`` for default taxa where no prefix in features is specified. other metadata
|
|
38
49
|
information is not necessary, and can be appended as specified by user, but do not set duplicate
|
|
39
50
|
column names as these six.
|
|
51
|
+
|
|
52
|
+
You may load a TSV table as metadata using :py:func:`load_metadata`.
|
|
40
53
|
"""
|
|
41
54
|
|
|
42
55
|
def __init__(
|
|
@@ -173,7 +186,7 @@ class metadata:
|
|
|
173
186
|
|
|
174
187
|
def set_if_ends(self, key = 'sample', dest = 'group', ends = '.', value = '.'):
|
|
175
188
|
'''
|
|
176
|
-
Alter the content of a column if
|
|
189
|
+
Alter the content of a column if ending with a string in the key column.
|
|
177
190
|
|
|
178
191
|
Parameters
|
|
179
192
|
----------
|
|
@@ -200,7 +213,7 @@ class metadata:
|
|
|
200
213
|
|
|
201
214
|
def set_if_contains(self, key = 'sample', dest = 'group', contains = '.', value = '.'):
|
|
202
215
|
'''
|
|
203
|
-
Alter the content of a column if
|
|
216
|
+
Alter the content of a column if containing a string in the key column.
|
|
204
217
|
|
|
205
218
|
Parameters
|
|
206
219
|
----------
|
|
@@ -212,7 +225,7 @@ class metadata:
|
|
|
212
225
|
The column you may want to alter value according to the patterns in column ``key``,
|
|
213
226
|
according to the conditions given.
|
|
214
227
|
|
|
215
|
-
|
|
228
|
+
contains : str
|
|
216
229
|
Test if values is contained in the ``key``. This requires that both variables be string.
|
|
217
230
|
|
|
218
231
|
value : str
|
|
@@ -612,9 +612,13 @@ def rna_consensus_nmf(
|
|
|
612
612
|
return_k = None, # for the first round, return statistics
|
|
613
613
|
**kwargs
|
|
614
614
|
)
|
|
615
|
+
|
|
616
|
+
combs = {}
|
|
617
|
+
for ky in comb.keys():
|
|
618
|
+
combs[str(ky)] = comb[ky]
|
|
615
619
|
|
|
616
620
|
stats = pd.DataFrame(stats, index = ['ncomps', 'threshold', 'silhoutte', 'error']).T
|
|
617
|
-
adata.uns[key_added] =
|
|
621
|
+
adata.uns[key_added] = combs
|
|
618
622
|
adata.uns[f'{key_added}.stats'] = stats
|
|
619
623
|
adata.uns[f'{key_added}.args'] = kwargs
|
|
620
624
|
|
|
@@ -632,7 +636,10 @@ def rna_consensus_nmf_extract_k(
|
|
|
632
636
|
from exprmat.preprocessing import normalize
|
|
633
637
|
|
|
634
638
|
kwargs.update(adata.uns[f'{nmf_slot}.args'])
|
|
635
|
-
|
|
639
|
+
|
|
640
|
+
comb = {}
|
|
641
|
+
for ky in adata.uns[nmf_slot].keys():
|
|
642
|
+
comb[int(ky)] = adata.uns[nmf_slot][ky]
|
|
636
643
|
|
|
637
644
|
_, res = cnmf(
|
|
638
645
|
adata, comb = comb,
|
|
@@ -641,6 +648,7 @@ def rna_consensus_nmf_extract_k(
|
|
|
641
648
|
)
|
|
642
649
|
|
|
643
650
|
local_density, dist, _, rf_usages, spectra_tpm, usage_coef, _ = res
|
|
651
|
+
rf_usages.columns = ['C' + str(x) for x in rf_usages.columns]
|
|
644
652
|
adata.obsm[usage_added.format(k)] = rf_usages
|
|
645
653
|
destindex = adata.var_names.tolist()
|
|
646
654
|
|
|
@@ -757,6 +765,16 @@ def rna_plot_embedding(adata, sample_name, **kwargs):
|
|
|
757
765
|
return embedding(adata, sample_name = sample_name, **kwargs)
|
|
758
766
|
|
|
759
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
|
+
|
|
760
778
|
def rna_plot_embedding_atlas(adata, sample_name, **kwargs):
|
|
761
779
|
from exprmat.reduction.plot import embedding_atlas
|
|
762
780
|
return embedding_atlas(adata, sample_name = sample_name, **kwargs)
|
|
@@ -774,11 +792,25 @@ def rna_plot_gene_gene_regress(adata, sample_name, **kwargs):
|
|
|
774
792
|
def rna_plot_markers(adata, sample_name, figsize, dpi, **kwargs):
|
|
775
793
|
from exprmat.plotting.de import marker_plot
|
|
776
794
|
pl = marker_plot(adata, sample_name = sample_name, **kwargs)
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
pl
|
|
780
|
-
|
|
781
|
-
|
|
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
|
+
|
|
782
814
|
|
|
783
815
|
|
|
784
816
|
def rna_plot_expression_bar(
|
|
@@ -1321,6 +1353,11 @@ def rna_plot_cnmf_distance_usages(adata, sample_name, **kwargs):
|
|
|
1321
1353
|
return cnmf_distance_usages(adata, **kwargs)
|
|
1322
1354
|
|
|
1323
1355
|
|
|
1356
|
+
def rna_plot_cnmf_distance_modules(adata, sample_name, **kwargs):
|
|
1357
|
+
from exprmat.plotting.cnmf import cnmf_distance_modules
|
|
1358
|
+
return cnmf_distance_modules(adata, **kwargs)
|
|
1359
|
+
|
|
1360
|
+
|
|
1324
1361
|
def atac_plot_qc(adata, sample_name, **kwargs):
|
|
1325
1362
|
from exprmat.plotting.atac import atac_qc_metrics
|
|
1326
1363
|
return atac_qc_metrics(adata, sample_name, **kwargs)
|
|
@@ -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.31"
|
|
22
22
|
authors = [
|
|
23
23
|
{name = "Zheng Yang", email = "xornent@outlook.com"}
|
|
24
24
|
]
|
|
@@ -81,7 +81,8 @@ dependencies = [
|
|
|
81
81
|
'hdbscan',
|
|
82
82
|
'graphtools',
|
|
83
83
|
'bincsync >= 0.3.0',
|
|
84
|
-
'pyBigWig'
|
|
84
|
+
'pyBigWig',
|
|
85
|
+
'loompy'
|
|
85
86
|
]
|
|
86
87
|
|
|
87
88
|
[project.optional-dependencies]
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import matplotlib.pyplot as plt
|
|
3
|
-
import pandas as pd
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def cnmf_silhoutte(adata, nmf_slot = 'cnmf', figsize = (3, 2), dpi = 100):
|
|
7
|
-
|
|
8
|
-
fig = plt.figure(figsize = figsize, dpi = dpi)
|
|
9
|
-
df = adata.uns[f'{nmf_slot}.stats']
|
|
10
|
-
fig.gca().plot(df.ncomps, df.silhoutte, color = 'k')
|
|
11
|
-
|
|
12
|
-
# fig.gca().set_ylim([-0.1, 1.1])
|
|
13
|
-
# fig.gca().set_yticks([0, 0.25, 0.5, 0.75, 1])
|
|
14
|
-
fig.gca().set_ylabel('Silhoutte score')
|
|
15
|
-
|
|
16
|
-
fig.gca().set_xlabel('NMF components')
|
|
17
|
-
fig.gca().set_xticks(df.ncomps)
|
|
18
|
-
|
|
19
|
-
for pos in ['right', 'top']:
|
|
20
|
-
fig.gca().spines[pos].set_visible(False)
|
|
21
|
-
|
|
22
|
-
return fig
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def cnmf_density(adata, k, nmf_slot = 'cnmf', figsize = (3, 2), dpi = 100):
|
|
26
|
-
|
|
27
|
-
fig = plt.figure(figsize = figsize, dpi = dpi)
|
|
28
|
-
df = adata.uns[f'{nmf_slot}.density.{k}']
|
|
29
|
-
fig.gca().hist(df, bins = 100, color = 'k')
|
|
30
|
-
|
|
31
|
-
fig.gca().set_ylabel('Local density')
|
|
32
|
-
fig.gca().set_xlabel('Distance')
|
|
33
|
-
|
|
34
|
-
for pos in ['right', 'top']:
|
|
35
|
-
fig.gca().spines[pos].set_visible(False)
|
|
36
|
-
|
|
37
|
-
return fig
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
def cnmf_distance_comps(adata, k, nmf_slot = 'cnmf', cmap = 'Reds_r', figsize = (3, 3), dpi = 100):
|
|
41
|
-
|
|
42
|
-
fig = plt.figure(figsize = figsize, dpi = dpi)
|
|
43
|
-
df = adata.uns[f'{nmf_slot}.dist.{k}']
|
|
44
|
-
fig.gca().imshow(df, cmap = cmap)
|
|
45
|
-
|
|
46
|
-
return fig
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
def cnmf_distance_usages(
|
|
50
|
-
adata, k, nmf_slot = 'cnmf', metrics = 'cosine', downsample = 0.1,
|
|
51
|
-
cmap = 'Reds_r', figsize = (3, 3), dpi = 100
|
|
52
|
-
):
|
|
53
|
-
|
|
54
|
-
import numpy as np
|
|
55
|
-
fig = plt.figure(figsize = figsize, dpi = dpi)
|
|
56
|
-
df = adata.obsm[f'{nmf_slot}.{k}']
|
|
57
|
-
nrow = df.shape[0]
|
|
58
|
-
subset = np.random.choice(range(nrow), int(nrow * downsample), replace = False)
|
|
59
|
-
from exprmat.clustering.seriation import pdist
|
|
60
|
-
pdistc = pdist(df.iloc[subset, :], metric = 'cosine')
|
|
61
|
-
|
|
62
|
-
from exprmat.clustering.seriation import serial_matrix, squareform
|
|
63
|
-
serial, _, _ = serial_matrix(squareform(pdistc), method = 'single')
|
|
64
|
-
fig.gca().imshow(serial, cmap = cmap)
|
|
65
|
-
|
|
66
|
-
return fig
|
|
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
|