exprmat 0.1.10__tar.gz → 0.1.11__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.
Potentially problematic release.
This version of exprmat might be problematic. Click here for more details.
- {exprmat-0.1.10 → exprmat-0.1.11}/PKG-INFO +1 -1
- exprmat-0.1.11/exprmat/__init__.py +7 -0
- exprmat-0.1.11/exprmat/descriptive/aggregate.py +127 -0
- {exprmat-0.1.10/exprmat/clustering → exprmat-0.1.11/exprmat/descriptive}/summary.py +5 -1
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/plotting/lr.py +10 -4
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/plotting/summary.py +1 -1
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/reader/experiment.py +16 -1
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat.egg-info/PKG-INFO +1 -1
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat.egg-info/SOURCES.txt +2 -1
- {exprmat-0.1.10 → exprmat-0.1.11}/setup.py +1 -1
- exprmat-0.1.10/exprmat/__init__.py +0 -5
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/ansi.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/clustering/__init__.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/clustering/leiden.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/clustering/rogue.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/clustering/spectral.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/clustering/utils.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/cnv/__init__.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/cnv/cnvscore.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/cnv/infercnv.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/configuration.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/__init__.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/delim.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/finders.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/geneset.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/gff.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/entrez.tsv.gz +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/genesets/all.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/genesets/bp.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/genesets/cancer-modules.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/genesets/cancer-neighborhoods.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/genesets/cancer.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/genesets/cc.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/genesets/chemical-perturb.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/genesets/hallmark.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/genesets/human-phenotype-ontology.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/genesets/immune-perturb.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/genesets/kegg.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/genesets/mf.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/genesets/microrna.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/genesets/oncogenic.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/genesets/pathways.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/genesets/positional.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/genesets/single-cell.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/genesets/transcript-factors.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/genesets/vaccine.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/genome.tsv.gz +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/lr/baccin2019 +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/lr/cellcall +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/lr/cellchatdb +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/lr/cellinker +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/lr/cellphonedb +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/lr/celltalkdb +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/lr/connectomedb2020 +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/lr/consensus +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/lr/embrace +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/lr/guide2pharma +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/lr/hpmr +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/lr/icellnet +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/lr/italk +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/lr/kirouac2010 +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/lr/lrdb +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/lr/ramilowski2015 +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/mapping-ensembl.pkl +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/mapping-name.pkl +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/orthologs/aca.gz +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/orthologs/bta.tsv.gz +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/orthologs/cel.tsv.gz +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/orthologs/clu.tsv.gz +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/orthologs/dme.tsv.gz +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/orthologs/dre.tsv.gz +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/orthologs/eca.tsv.gz +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/orthologs/fca.tsv.gz +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/orthologs/gga.tsv.gz +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/orthologs/mdo.tsv.gz +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/orthologs/mmu.tsv.gz +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/orthologs/mmul.gz +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/orthologs/oan.tsv.gz +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/orthologs/ptr.tsv.gz +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/orthologs/rno.tsv.gz +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/orthologs/sce.tsv.gz +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/orthologs/spo.tsv.gz +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/orthologs/ssc.tsv.gz +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/orthologs/xla.tsv.gz +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/hsa/taxa +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/lr.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/mmu/entrez.tsv.gz +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/mmu/genesets/all.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/mmu/genesets/azimuth.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/mmu/genesets/biocarta.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/mmu/genesets/bp.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/mmu/genesets/cc.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/mmu/genesets/chemical-perturb.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/mmu/genesets/hallmark.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/mmu/genesets/kegg.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/mmu/genesets/m2.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/mmu/genesets/markers.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/mmu/genesets/mf.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/mmu/genesets/microrna.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/mmu/genesets/mpt.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/mmu/genesets/positional.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/mmu/genesets/reactome.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/mmu/genesets/transcript-factors.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/mmu/genesets/wikipathway.gmt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/mmu/genome.tsv.gz +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/mmu/lr/consensus +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/mmu/mapping-ensembl.pkl +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/mmu/mapping-name.pkl +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/mmu/taxa +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/private.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/data/ranges.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/descriptive/__init__.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/descriptive/de.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/descriptive/gse.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/descriptive/kde.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/lr/__init__.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/lr/aggregate.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/lr/method.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/lr/methods/__init__.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/lr/methods/cellchat.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/lr/methods/cellphonedb.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/lr/methods/connectome.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/lr/methods/geomean.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/lr/methods/logfc.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/lr/methods/natmi.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/lr/methods/rank_aggregate.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/lr/methods/scseqcomm.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/lr/methods/singlecellsignalr.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/lr/pipeline.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/lr/preprocess.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/lr/resources.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/lr/utils.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/plotting/__init__.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/plotting/cnv.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/plotting/de.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/plotting/expression.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/plotting/gse.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/plotting/palettes.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/preprocessing/__init__.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/preprocessing/doublets/__init__.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/preprocessing/doublets/composite.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/preprocessing/doublets/scrublet.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/preprocessing/filter.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/preprocessing/integrate.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/preprocessing/linear.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/preprocessing/normal.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/preprocessing/plot.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/preprocessing/qc.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/preprocessing/sctransform/__init__.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/preprocessing/sctransform/estimate.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/preprocessing/sctransform/ksmooth.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/preprocessing/sctransform/residual.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/preprocessing/sctransform/transform.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/preprocessing/sparse.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/preprocessing/uniform.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/reader/__init__.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/reader/matcher.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/reader/metadata.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/reduction/__init__.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/reduction/forceatlas.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/reduction/mde.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/reduction/nn.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/reduction/pca.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/reduction/plot.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/reduction/pumap.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/reduction/tsne.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/reduction/umap.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat/utils.py +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat.egg-info/dependency_links.txt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat.egg-info/not-zip-safe +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat.egg-info/requires.txt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/exprmat.egg-info/top_level.txt +0 -0
- {exprmat-0.1.10 → exprmat-0.1.11}/setup.cfg +0 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
'''
|
|
2
|
+
Summary accepts two to three categoricals in the obs metadata to reform the dataset
|
|
3
|
+
with summarizing statistics. Aggregates takes one obs category and one var category
|
|
4
|
+
to aggregate observations and variables.
|
|
5
|
+
'''
|
|
6
|
+
|
|
7
|
+
import numpy as np
|
|
8
|
+
import anndata as ad
|
|
9
|
+
|
|
10
|
+
from exprmat.utils import choose_layer
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def aggregate(
|
|
14
|
+
adata, data = 'X', method = 'mean', method_args = {},
|
|
15
|
+
obs_key = 'sample', var_key = None
|
|
16
|
+
):
|
|
17
|
+
source = choose_layer(adata, layer = data)
|
|
18
|
+
|
|
19
|
+
# TODO: maybe some alternative method rather than silly iteration :(
|
|
20
|
+
|
|
21
|
+
if (obs_key is None) and (var_key is not None):
|
|
22
|
+
return aggregate_var(
|
|
23
|
+
adata, data = data, method = method, method_args = method_args,
|
|
24
|
+
var_key = var_key
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
if (var_key is None) and (obs_key is not None):
|
|
28
|
+
return aggregate_obs(
|
|
29
|
+
adata, data = data, method = method, method_args = method_args,
|
|
30
|
+
obs_key = obs_key
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
obs_val = adata.obs_names.tolist()
|
|
34
|
+
obs = adata.obs_names.to_numpy()
|
|
35
|
+
if obs_key is not None:
|
|
36
|
+
obs_val = adata.obs[obs_key].unique().tolist()
|
|
37
|
+
obs = adata.obs[obs_key].to_numpy()
|
|
38
|
+
|
|
39
|
+
var_val = adata.var_names.tolist()
|
|
40
|
+
var = adata.var_names.to_numpy()
|
|
41
|
+
if var_key is not None:
|
|
42
|
+
var_val = adata.var[var_key].unique().tolist()
|
|
43
|
+
var = adata.var[var_key].to_numpy()
|
|
44
|
+
|
|
45
|
+
mat = np.ndarray(shape = (len(obs_val), len(var_val)), dtype = np.float32)
|
|
46
|
+
meth = None
|
|
47
|
+
|
|
48
|
+
methods = {
|
|
49
|
+
'mean': np.mean
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
for i in range(len(obs_val)):
|
|
53
|
+
for j in range(len(var_val)):
|
|
54
|
+
|
|
55
|
+
mat[i, j] = methods[method](
|
|
56
|
+
source[obs == obs_val[i], var == var_val[j]],
|
|
57
|
+
**method_args
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
annd = ad.AnnData(X = mat)
|
|
61
|
+
annd.obs_names = obs_val
|
|
62
|
+
annd.var_names = var_val
|
|
63
|
+
return annd
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def aggregate_obs(
|
|
67
|
+
adata, data = 'X', method = 'mean', method_args = {}, obs_key = 'sample'
|
|
68
|
+
):
|
|
69
|
+
|
|
70
|
+
source = choose_layer(adata, layer = data)
|
|
71
|
+
|
|
72
|
+
obs_val = adata.obs_names.tolist()
|
|
73
|
+
obs = adata.obs_names.to_numpy()
|
|
74
|
+
if obs_key is not None:
|
|
75
|
+
obs_val = adata.obs[obs_key].unique().tolist()
|
|
76
|
+
obs = adata.obs[obs_key].to_numpy()
|
|
77
|
+
|
|
78
|
+
mat = np.ndarray(shape = (len(obs_val), adata.n_vars), dtype = np.float32)
|
|
79
|
+
|
|
80
|
+
methods = {
|
|
81
|
+
'mean': np.mean
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
for i in range(len(obs_val)):
|
|
85
|
+
mat[i, :] = methods[method](
|
|
86
|
+
source[obs == obs_val[i], :],
|
|
87
|
+
axis = 0,
|
|
88
|
+
**method_args
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
annd = ad.AnnData(X = mat)
|
|
92
|
+
annd.obs_names = obs_val
|
|
93
|
+
annd.var_names = adata.var_names.tolist()
|
|
94
|
+
annd.var = adata.var.copy()
|
|
95
|
+
return annd
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def aggregate_var(
|
|
99
|
+
adata, data = 'X', method = 'mean', method_args = {}, var_key = 'module'
|
|
100
|
+
):
|
|
101
|
+
|
|
102
|
+
source = choose_layer(adata, layer = data)
|
|
103
|
+
|
|
104
|
+
var_val = adata.var_names.tolist()
|
|
105
|
+
var = adata.var_names.to_numpy()
|
|
106
|
+
if var_key is not None:
|
|
107
|
+
var_val = adata.var[var_key].unique().tolist()
|
|
108
|
+
var = adata.var[var_key].to_numpy()
|
|
109
|
+
|
|
110
|
+
mat = np.ndarray(shape = (adata.n_obs, len(var_val)), dtype = np.float32)
|
|
111
|
+
|
|
112
|
+
methods = {
|
|
113
|
+
'mean': np.mean
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
for i in range(len(var_val)):
|
|
117
|
+
mat[:, i] = methods[method](
|
|
118
|
+
source[:, var == var_val[i]],
|
|
119
|
+
axis = 1, # row sums
|
|
120
|
+
**method_args
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
annd = ad.AnnData(X = mat)
|
|
124
|
+
annd.obs_names = adata.obs_names.tolist()
|
|
125
|
+
annd.obs = adata.obs.copy()
|
|
126
|
+
annd.var_names = var_val
|
|
127
|
+
return annd
|
|
@@ -22,8 +22,12 @@ from exprmat.utils import choose_layer
|
|
|
22
22
|
|
|
23
23
|
def summarize(
|
|
24
24
|
adata, data = 'X', method = 'n', method_args = {},
|
|
25
|
-
|
|
25
|
+
|
|
26
|
+
orient = 'obs',
|
|
27
|
+
on = 'sample',
|
|
28
|
+
across = None,
|
|
26
29
|
split = None,
|
|
30
|
+
|
|
27
31
|
attached_metadata_on = None, attached_metadata_across = None,
|
|
28
32
|
attach_method_on = 'first', attach_method_across = 'first'
|
|
29
33
|
):
|
|
@@ -79,7 +79,7 @@ def invert_scores(score):
|
|
|
79
79
|
|
|
80
80
|
def filter_by(liana_res, filter_fun):
|
|
81
81
|
if filter_fun is not None:
|
|
82
|
-
msk = liana_res
|
|
82
|
+
msk = filter_fun(liana_res).astype(bool)
|
|
83
83
|
relevant_interactions = np.unique(liana_res[msk].interaction)
|
|
84
84
|
liana_res = liana_res[np.isin(liana_res['interaction'], relevant_interactions)]
|
|
85
85
|
|
|
@@ -428,14 +428,20 @@ def lr_dotplot(
|
|
|
428
428
|
# ax.set_facecolor('lightgrey')
|
|
429
429
|
# plt.grid(True, zorder = -1)
|
|
430
430
|
|
|
431
|
-
ax.scatter(
|
|
431
|
+
p = ax.scatter(
|
|
432
432
|
x = 'x', y = 'y', s = 's',
|
|
433
|
-
edgecolors = "
|
|
433
|
+
edgecolors = "lightgrey", c = 'c', cmap = cmap,
|
|
434
434
|
data = pd.DataFrame(df), marker = 'o'
|
|
435
435
|
)
|
|
436
436
|
|
|
437
|
-
|
|
437
|
+
cbar = plt.colorbar(
|
|
438
|
+
p, shrink = 0.3, aspect = 10,
|
|
439
|
+
anchor = (0.2, 0), location = "right"
|
|
440
|
+
)
|
|
438
441
|
|
|
442
|
+
cbar.ax.set_title(colour, loc = "left", fontsize = 10, pad = 15)
|
|
443
|
+
|
|
444
|
+
for label in ax.get_xticklabels(): label.set_rotation(90)
|
|
439
445
|
return fig
|
|
440
446
|
|
|
441
447
|
|
|
@@ -822,7 +822,7 @@ class experiment:
|
|
|
822
822
|
attached_metadata_on = None, attached_metadata_across = None,
|
|
823
823
|
attach_method_on = 'first', attach_method_across = 'first'
|
|
824
824
|
):
|
|
825
|
-
from exprmat.
|
|
825
|
+
from exprmat.descriptive.summary import summarize
|
|
826
826
|
return summarize(
|
|
827
827
|
adata, data = data, method = method, method_args = method_args,
|
|
828
828
|
orient = orient, on = on, across = across, split = split,
|
|
@@ -831,6 +831,18 @@ class experiment:
|
|
|
831
831
|
attach_method_on = attach_method_on,
|
|
832
832
|
attach_method_across = attach_method_across
|
|
833
833
|
)
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
@staticmethod
|
|
837
|
+
def rna_aggregate(
|
|
838
|
+
adata, sample_name, data = 'X', method = 'mean', method_args = {},
|
|
839
|
+
obs_key = 'sample', var_key = None
|
|
840
|
+
):
|
|
841
|
+
from exprmat.descriptive.aggregate import aggregate
|
|
842
|
+
return aggregate(
|
|
843
|
+
adata, data = data, method = method, method_args = method_args,
|
|
844
|
+
obs_key = obs_key, var_key = var_key
|
|
845
|
+
)
|
|
834
846
|
|
|
835
847
|
|
|
836
848
|
@staticmethod
|
|
@@ -1615,6 +1627,9 @@ class experiment:
|
|
|
1615
1627
|
def run_rna_summary(self, run_on_samples = False, **kwargs):
|
|
1616
1628
|
return self.do_for_rna(run_on_samples, experiment.rna_summary, **kwargs)
|
|
1617
1629
|
|
|
1630
|
+
def run_rna_aggregate(self, run_on_samples = False, **kwargs):
|
|
1631
|
+
return self.do_for_rna(run_on_samples, experiment.rna_aggregate, **kwargs)
|
|
1632
|
+
|
|
1618
1633
|
def run_rna_attach_tcr(self, run_on_samples = False):
|
|
1619
1634
|
return self.do_for_rna(
|
|
1620
1635
|
run_on_samples,
|
|
@@ -13,7 +13,6 @@ exprmat/clustering/__init__.py
|
|
|
13
13
|
exprmat/clustering/leiden.py
|
|
14
14
|
exprmat/clustering/rogue.py
|
|
15
15
|
exprmat/clustering/spectral.py
|
|
16
|
-
exprmat/clustering/summary.py
|
|
17
16
|
exprmat/clustering/utils.py
|
|
18
17
|
exprmat/cnv/__init__.py
|
|
19
18
|
exprmat/cnv/cnvscore.py
|
|
@@ -109,9 +108,11 @@ exprmat/data/mmu/genesets/transcript-factors.gmt
|
|
|
109
108
|
exprmat/data/mmu/genesets/wikipathway.gmt
|
|
110
109
|
exprmat/data/mmu/lr/consensus
|
|
111
110
|
exprmat/descriptive/__init__.py
|
|
111
|
+
exprmat/descriptive/aggregate.py
|
|
112
112
|
exprmat/descriptive/de.py
|
|
113
113
|
exprmat/descriptive/gse.py
|
|
114
114
|
exprmat/descriptive/kde.py
|
|
115
|
+
exprmat/descriptive/summary.py
|
|
115
116
|
exprmat/lr/__init__.py
|
|
116
117
|
exprmat/lr/aggregate.py
|
|
117
118
|
exprmat/lr/method.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|