exprmat 0.1.45__tar.gz → 0.1.47__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.45 → exprmat-0.1.47}/PKG-INFO +2 -1
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/ansi.py +8 -3
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/clustering/nmf.py +2 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/clustering/seriation.py +2 -2
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/descriptive/aggregate.py +7 -12
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/descriptive/gse.py +5 -2
- exprmat-0.1.47/exprmat/metacell/__init__.py +158 -0
- exprmat-0.1.47/exprmat/metacell/engine.py +204 -0
- exprmat-0.1.47/exprmat/metacell/model.py +273 -0
- exprmat-0.1.47/exprmat/metacell/utils.py +151 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/cnmf.py +2 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/trajectory.py +72 -7
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/preprocessing/__init__.py +1 -1
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/preprocessing/filter.py +42 -37
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/preprocessing/qc.py +8 -1
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/reader/experiment.py +97 -22
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/reader/static.py +146 -10
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/reader/updater.py +13 -2
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/reduction/mde.py +10 -3
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/reduction/plot.py +25 -36
- exprmat-0.1.47/exprmat/trajectory/trace.py +367 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/transfer/atlas.py +121 -32
- {exprmat-0.1.45 → exprmat-0.1.47}/pyproject.toml +3 -2
- {exprmat-0.1.45 → exprmat-0.1.47}/Cargo.lock +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/Cargo.toml +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/__init__.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/clustering/__init__.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/clustering/cnmf.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/clustering/dbscan.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/clustering/kmeans.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/clustering/leiden.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/clustering/rogue.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/clustering/spectral.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/clustering/utils.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/cnv/__init__.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/cnv/cnvscore.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/cnv/infercnv.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/configuration.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/data/__init__.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/data/cistarget.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/data/cre.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/data/finders.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/data/geneset.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/data/io.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/data/lr.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/data/presets.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/data/signature.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/data/tf.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/descriptive/__init__.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/descriptive/atac.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/descriptive/aucell.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/descriptive/de.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/descriptive/kde.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/descriptive/recovery.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/descriptive/summary.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/descriptive/tcr.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/deseq/dataset.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/deseq/gridsearch.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/deseq/inference.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/deseq/preprocessing.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/deseq/stats.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/deseq/utils.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/dynamics/__init__.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/dynamics/generank.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/dynamics/linreg.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/dynamics/moments.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/dynamics/optimization.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/dynamics/parallel.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/dynamics/preprocess.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/dynamics/pseudotime.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/dynamics/transition.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/dynamics/utils.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/dynamics/velocity.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/grn/__init__.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/grn/infergrn.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/grn/modules.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/grn/prune.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/grn/regressors.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/grn/utils.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/image/__init__.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/image/align.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/lr/__init__.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/lr/aggregate.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/lr/method.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/lr/methods/__init__.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/lr/methods/cellchat.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/lr/methods/cellphonedb.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/lr/methods/connectome.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/lr/methods/geomean.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/lr/methods/logfc.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/lr/methods/natmi.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/lr/methods/rank_aggregate.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/lr/methods/scseqcomm.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/lr/methods/singlecellsignalr.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/lr/pipeline.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/lr/preprocess.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/lr/resources.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/lr/utils.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/peaks/__init__.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/peaks/callpeak.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/peaks/common.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/peaks/coverage.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/peaks/footprint.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/peaks/idr/__init__.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/peaks/idr/constants.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/peaks/idr/idr.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/peaks/idr/invcdf.pyx +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/peaks/idr/optimization.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/peaks/idr/utils.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/peaks/linkage.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/peaks/motif.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/peaks/sequence.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/__init__.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/atac.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/cnv.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/data/A.pk +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/data/B.pk +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/data/C.pk +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/data/D.pk +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/data/E.pk +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/data/F.pk +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/data/G.pk +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/data/H.pk +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/data/I.pk +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/data/J.pk +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/data/K.pk +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/data/L.pk +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/data/M.pk +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/data/N.pk +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/data/O.pk +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/data/P.pk +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/data/Q.pk +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/data/R.pk +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/data/S.pk +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/data/T.pk +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/data/U.pk +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/data/V.pk +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/data/W.pk +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/data/X.pk +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/data/Y.pk +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/data/Z.pk +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/de.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/expression.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/gse.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/lr.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/milestone.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/palettes.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/sankey.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/sequence.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/summary.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/track.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/utils.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/plotting/velocity.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/preprocessing/doublets/__init__.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/preprocessing/doublets/composite.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/preprocessing/doublets/scrublet.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/preprocessing/emptydrops.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/preprocessing/impute/__init__.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/preprocessing/impute/magic.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/preprocessing/integrate.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/preprocessing/linear.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/preprocessing/normal.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/preprocessing/plot.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/preprocessing/sctransform/__init__.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/preprocessing/sctransform/estimate.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/preprocessing/sctransform/ksmooth.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/preprocessing/sctransform/residual.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/preprocessing/sctransform/transform.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/preprocessing/sparse.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/preprocessing/uniform.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/reader/__init__.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/reader/conversions.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/reader/matcher.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/reader/metadata.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/reader/spatial.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/reduction/__init__.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/reduction/diffmap.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/reduction/forceatlas.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/reduction/nn.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/reduction/outliers.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/reduction/pca.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/reduction/scvi.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/reduction/spectral.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/reduction/tsne.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/reduction/umap.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/trajectory/__init__.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/trajectory/elpi.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/trajectory/pcurve.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/trajectory/pseudotime.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/trajectory/root.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/transfer/__init__.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/exprmat/utils.py +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/license +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/readme.md +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/snapatac2/Cargo.toml +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/snapatac2/license +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/snapatac2/readme +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/snapatac2/src/call_peaks.rs +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/snapatac2/src/embedding.rs +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/snapatac2/src/export.rs +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/snapatac2/src/knn.rs +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/snapatac2/src/lib.rs +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/snapatac2/src/motif.rs +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/snapatac2/src/network.rs +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/snapatac2/src/preprocessing.rs +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/snapatac2/src/utils/anndata.rs +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/snapatac2/src/utils.rs +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/snapatac2-core/Cargo.toml +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/snapatac2-core/src/embedding.rs +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/snapatac2-core/src/export.rs +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/snapatac2-core/src/feature_count/counter.rs +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/snapatac2-core/src/feature_count/data_iter.rs +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/snapatac2-core/src/feature_count/matrix.rs +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/snapatac2-core/src/feature_count/mod.rs +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/snapatac2-core/src/genome.rs +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/snapatac2-core/src/lib.rs +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/snapatac2-core/src/motif.rs +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/snapatac2-core/src/network.rs +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/snapatac2-core/src/preprocessing/bam/flagstat.rs +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/snapatac2-core/src/preprocessing/bam/header.rs +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/snapatac2-core/src/preprocessing/bam/mark_duplicates.rs +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/snapatac2-core/src/preprocessing/bam.rs +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/snapatac2-core/src/preprocessing/import.rs +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/snapatac2-core/src/preprocessing/mod.rs +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/snapatac2-core/src/preprocessing/qc.rs +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/snapatac2-core/src/utils/knn.rs +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/snapatac2-core/src/utils/mod.rs +0 -0
- {exprmat-0.1.45 → exprmat-0.1.47}/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.47
|
|
4
4
|
Classifier: Programming Language :: Rust
|
|
5
5
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
6
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
@@ -78,6 +78,7 @@ Requires-Dist: xgboost
|
|
|
78
78
|
Requires-Dist: simpleppt
|
|
79
79
|
Requires-Dist: elpigraph-python
|
|
80
80
|
Requires-Dist: dask-expr>=2.0
|
|
81
|
+
Requires-Dist: einops==0.8.1
|
|
81
82
|
Requires-Dist: sphinx ; extra == 'dev'
|
|
82
83
|
Requires-Dist: twine ; extra == 'dev'
|
|
83
84
|
Requires-Dist: ipykernel ; extra == 'dev'
|
|
@@ -83,7 +83,7 @@ def common_length(string: str, limit: int) -> str:
|
|
|
83
83
|
cn = re.findall(cn_re, string)
|
|
84
84
|
cn_length = len(cn)
|
|
85
85
|
|
|
86
|
-
if limit
|
|
86
|
+
if limit < 5:
|
|
87
87
|
x_str = string[-limit:]
|
|
88
88
|
cn = len(re.findall(cn_re, x_str))
|
|
89
89
|
while cn + len(x_str) > limit:
|
|
@@ -222,7 +222,7 @@ def wrap(array: list[str], sep = ' ', n = 100) -> list[str]:
|
|
|
222
222
|
cumulative = a
|
|
223
223
|
lencum = lenprint
|
|
224
224
|
|
|
225
|
-
if cumulative
|
|
225
|
+
if cumulative != '':
|
|
226
226
|
results += [cumulative[1:] if cumulative[0] == ' ' else cumulative]
|
|
227
227
|
|
|
228
228
|
return results
|
|
@@ -243,4 +243,9 @@ class pprog(tqdm):
|
|
|
243
243
|
|
|
244
244
|
class pproga(tqdma):
|
|
245
245
|
def __init__(self, iterable = None, **kwargs):
|
|
246
|
-
super().__init__(iterable, **progress_styles, **kwargs)
|
|
246
|
+
super().__init__(iterable, **progress_styles, **kwargs)
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
def tqinfo(x):
|
|
250
|
+
if SILENT: return
|
|
251
|
+
tqdm.write(cyan('[i] ') + x)
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
from scipy.cluster.hierarchy import cophenet, single
|
|
3
3
|
from scipy.spatial.distance import pdist, squareform
|
|
4
4
|
from sklearn.decomposition import non_negative_factorization
|
|
5
|
+
import numpy as np
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
def nmf(
|
|
@@ -12,6 +13,7 @@ def nmf(
|
|
|
12
13
|
random_state = 42, verbose = 0, shuffle = False
|
|
13
14
|
):
|
|
14
15
|
|
|
16
|
+
matrix[np.isnan(matrix)] = 0
|
|
15
17
|
w, h, n = non_negative_factorization(
|
|
16
18
|
matrix, W, H, n_components = n_comps,
|
|
17
19
|
init = init,
|
|
@@ -33,7 +33,7 @@ def seriation(Z, N, cur_index):
|
|
|
33
33
|
|
|
34
34
|
def serial_matrix(dist, method = "ward", seed = 42):
|
|
35
35
|
'''
|
|
36
|
-
|
|
36
|
+
Transforms a distance matrix into a sorted distance matrix
|
|
37
37
|
according to the order implied by the hierarchical tree (dendrogram).
|
|
38
38
|
|
|
39
39
|
Parameters
|
|
@@ -55,7 +55,7 @@ def serial_matrix(dist, method = "ward", seed = 42):
|
|
|
55
55
|
|
|
56
56
|
N = len(dist)
|
|
57
57
|
flat_dist_mat = squareform(dist)
|
|
58
|
-
res_linkage = linkage(flat_dist_mat, method = method,preserve_input = True)
|
|
58
|
+
res_linkage = linkage(flat_dist_mat, method = method, preserve_input = True)
|
|
59
59
|
res_order = seriation(res_linkage, N, N + N-2)
|
|
60
60
|
seriated_dist = np.zeros((N,N))
|
|
61
61
|
a,b = np.triu_indices(N, k = 1)
|
|
@@ -21,6 +21,13 @@ from exprmat.preprocessing.linear import get_size_factor_for_regions, normalize_
|
|
|
21
21
|
from exprmat.ansi import error, warning, info
|
|
22
22
|
|
|
23
23
|
|
|
24
|
+
methods = {
|
|
25
|
+
'mean': np.mean,
|
|
26
|
+
'sum': np.sum,
|
|
27
|
+
'median': np.median
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
24
31
|
def aggregate(
|
|
25
32
|
adata, data = 'X', method = 'mean', method_args = {},
|
|
26
33
|
obs_key = 'sample', var_key = None
|
|
@@ -56,10 +63,6 @@ def aggregate(
|
|
|
56
63
|
mat = np.ndarray(shape = (len(obs_val), len(var_val)), dtype = np.float32)
|
|
57
64
|
meth = None
|
|
58
65
|
|
|
59
|
-
methods = {
|
|
60
|
-
'mean': np.mean
|
|
61
|
-
}
|
|
62
|
-
|
|
63
66
|
for i in range(len(obs_val)):
|
|
64
67
|
for j in range(len(var_val)):
|
|
65
68
|
|
|
@@ -88,10 +91,6 @@ def aggregate_obs(
|
|
|
88
91
|
|
|
89
92
|
mat = np.ndarray(shape = (len(obs_val), adata.n_vars), dtype = np.float32)
|
|
90
93
|
|
|
91
|
-
methods = {
|
|
92
|
-
'mean': np.mean
|
|
93
|
-
}
|
|
94
|
-
|
|
95
94
|
for i in range(len(obs_val)):
|
|
96
95
|
mat[i, :] = methods[method](
|
|
97
96
|
source[obs == obs_val[i], :],
|
|
@@ -120,10 +119,6 @@ def aggregate_var(
|
|
|
120
119
|
|
|
121
120
|
mat = np.ndarray(shape = (adata.n_obs, len(var_val)), dtype = np.float32)
|
|
122
121
|
|
|
123
|
-
methods = {
|
|
124
|
-
'mean': np.mean
|
|
125
|
-
}
|
|
126
|
-
|
|
127
122
|
for i in range(len(var_val)):
|
|
128
123
|
mat[:, i] = methods[method](
|
|
129
124
|
source[:, var == var_val[i]],
|
|
@@ -218,7 +218,7 @@ def opa(
|
|
|
218
218
|
|
|
219
219
|
|
|
220
220
|
def gsva(
|
|
221
|
-
adata, taxa, identifier = '
|
|
221
|
+
adata, taxa, identifier = 'entrez', gene_sets = 'kegg', lognorm = 'X',
|
|
222
222
|
n_cores = 1, kcdf = 'Gaussian', weight = 1, min_genes = 15, max_genes = 1000
|
|
223
223
|
):
|
|
224
224
|
mat = choose_layer(adata, layer = lognorm)
|
|
@@ -238,9 +238,12 @@ def gsva(
|
|
|
238
238
|
inp = inp.loc[~ inp.index.isna(), :]
|
|
239
239
|
inp = inp.loc[~ inp.index.duplicated(), :].copy()
|
|
240
240
|
|
|
241
|
+
if isinstance(gene_sets, str):
|
|
242
|
+
gene_sets = get_genesets(taxa = taxa, name = gene_sets, identifier = identifier)
|
|
243
|
+
|
|
241
244
|
import gseapy as gp
|
|
242
245
|
gsv = gp.gsva(
|
|
243
|
-
data = inp, gene_sets =
|
|
246
|
+
data = inp, gene_sets = gene_sets,
|
|
244
247
|
kcdf = kcdf, weight = weight, min_size = min_genes, max_size = max_genes, seed = 42,
|
|
245
248
|
threads = n_cores
|
|
246
249
|
)
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
|
|
2
|
+
import os
|
|
3
|
+
import torch
|
|
4
|
+
import random
|
|
5
|
+
import argparse
|
|
6
|
+
import matplotlib
|
|
7
|
+
import numpy as np
|
|
8
|
+
import scanpy as sc
|
|
9
|
+
import seaborn as sns
|
|
10
|
+
from matplotlib import rcParams
|
|
11
|
+
|
|
12
|
+
from exprmat import warning, info, error, pprog
|
|
13
|
+
from exprmat.metacell.model import MetaQ
|
|
14
|
+
from exprmat.metacell.engine import train_one_epoch, warm_one_epoch, inference
|
|
15
|
+
from exprmat.metacell.utils import (
|
|
16
|
+
load_data, compute_metacell
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def assign_metacell(
|
|
21
|
+
scaleds,
|
|
22
|
+
size_factors,
|
|
23
|
+
counts,
|
|
24
|
+
n_metacell,
|
|
25
|
+
datatypes = ['rna'],
|
|
26
|
+
device = 'cuda',
|
|
27
|
+
random_seed = 42,
|
|
28
|
+
train_epoch = 300,
|
|
29
|
+
adam_learning_rate = 1e-3,
|
|
30
|
+
adam_weight_decay = 1e-2,
|
|
31
|
+
codebook_init = 'random',
|
|
32
|
+
converge_threshold = 10,
|
|
33
|
+
batch_size = 32,
|
|
34
|
+
):
|
|
35
|
+
|
|
36
|
+
# set random seeds
|
|
37
|
+
random.seed(random_seed)
|
|
38
|
+
np.random.seed(random_seed)
|
|
39
|
+
torch.manual_seed(random_seed)
|
|
40
|
+
torch.random.manual_seed(random_seed)
|
|
41
|
+
if device == "cuda":
|
|
42
|
+
torch.cuda.manual_seed_all(random_seed)
|
|
43
|
+
|
|
44
|
+
device = torch.device(device)
|
|
45
|
+
|
|
46
|
+
dataloader_train, dataloader_eval, input_dims = load_data(
|
|
47
|
+
scaleds, size_factors, counts,
|
|
48
|
+
n_metacells = n_metacell, batch_size = batch_size
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
omics_num = len(scaleds)
|
|
52
|
+
|
|
53
|
+
info(f"target metacell number: {n_metacell}")
|
|
54
|
+
|
|
55
|
+
net = MetaQ(
|
|
56
|
+
input_dims = input_dims,
|
|
57
|
+
data_types = datatypes,
|
|
58
|
+
entry_num = n_metacell,
|
|
59
|
+
).to(device)
|
|
60
|
+
|
|
61
|
+
optimizer = torch.optim.AdamW(
|
|
62
|
+
net.parameters(),
|
|
63
|
+
lr = adam_learning_rate,
|
|
64
|
+
weight_decay = adam_weight_decay
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
info('training metacell quantization model ...')
|
|
68
|
+
|
|
69
|
+
loss_rec_his = loss_vq_his = 1e7
|
|
70
|
+
stable_epochs = 0
|
|
71
|
+
|
|
72
|
+
if codebook_init == "random":
|
|
73
|
+
warm_epochs = 0
|
|
74
|
+
else:
|
|
75
|
+
# for Kmeans and Geometric initialization
|
|
76
|
+
warm_epochs = min(50, int(train_epoch * 0.2))
|
|
77
|
+
|
|
78
|
+
prog = pprog(range(train_epoch), desc = 'training network')
|
|
79
|
+
for epoch in prog:
|
|
80
|
+
|
|
81
|
+
if epoch < warm_epochs:
|
|
82
|
+
warm_one_epoch(
|
|
83
|
+
model = net,
|
|
84
|
+
data_types = datatypes,
|
|
85
|
+
dataloader = dataloader_train,
|
|
86
|
+
optimizer = optimizer,
|
|
87
|
+
epoch = epoch,
|
|
88
|
+
device = device,
|
|
89
|
+
prog = prog,
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
elif epoch == warm_epochs:
|
|
93
|
+
embeds, ids, _, _, _ = inference(
|
|
94
|
+
model = net,
|
|
95
|
+
data_types = datatypes,
|
|
96
|
+
data_loader = dataloader_eval,
|
|
97
|
+
device = device,
|
|
98
|
+
)
|
|
99
|
+
net.quantizer.init_codebook(embeds, method = codebook_init)
|
|
100
|
+
if omics_num == 1: net.copy_decoder_q()
|
|
101
|
+
|
|
102
|
+
else:
|
|
103
|
+
loss_rec, loss_vq = train_one_epoch(
|
|
104
|
+
model = net,
|
|
105
|
+
data_types = datatypes,
|
|
106
|
+
dataloader = dataloader_train,
|
|
107
|
+
optimizer = optimizer,
|
|
108
|
+
epoch = epoch,
|
|
109
|
+
device = device,
|
|
110
|
+
prog = prog,
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
converge = (abs(loss_vq_his - loss_vq) <= 1e-5) and (
|
|
114
|
+
abs(loss_rec_his - loss_rec) <= 1e-5)
|
|
115
|
+
|
|
116
|
+
if converge:
|
|
117
|
+
stable_epochs += 1
|
|
118
|
+
if stable_epochs >= converge_threshold:
|
|
119
|
+
info(f'early stopping the training process at epoch {epoch}')
|
|
120
|
+
break
|
|
121
|
+
|
|
122
|
+
else:
|
|
123
|
+
stable_epochs = 0
|
|
124
|
+
loss_rec_his = loss_rec
|
|
125
|
+
loss_vq_his = loss_vq
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
embeds, ids, delta_confs, rec_q_percent, loss_codebook = inference(
|
|
129
|
+
model = net,
|
|
130
|
+
data_types = datatypes,
|
|
131
|
+
data_loader = dataloader_eval,
|
|
132
|
+
device = device
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
info(f"quantized reconstruction: {rec_q_percent:.2f}")
|
|
136
|
+
info(f"delta assignment confidence: {np.mean(delta_confs):.2f}")
|
|
137
|
+
info(f"codebook loss: {loss_codebook:.2f}")
|
|
138
|
+
|
|
139
|
+
assignment = sc.AnnData(embeds.astype('float32'))
|
|
140
|
+
assignment.obs["metacell"] = ids
|
|
141
|
+
|
|
142
|
+
return assignment
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def aggregate_metacell(adata_list, assignment):
|
|
146
|
+
|
|
147
|
+
# supply a list of log normalized (X) full matrix.
|
|
148
|
+
# note that the obs order must match that of the initial input.
|
|
149
|
+
# and the previously computed assignment.
|
|
150
|
+
|
|
151
|
+
omics_num = len(adata_list)
|
|
152
|
+
metacells = []
|
|
153
|
+
for i in range(omics_num):
|
|
154
|
+
adata = adata_list[i]
|
|
155
|
+
metacell_adata = compute_metacell(adata, assignment.obs["metacell"].to_numpy())
|
|
156
|
+
metacells.append(metacell_adata)
|
|
157
|
+
|
|
158
|
+
return metacells
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
|
|
2
|
+
import torch
|
|
3
|
+
import numpy as np
|
|
4
|
+
from exprmat.metacell.model import reconstruction_loss
|
|
5
|
+
from exprmat.ansi import tqinfo
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def train_one_epoch(
|
|
9
|
+
model,
|
|
10
|
+
data_types,
|
|
11
|
+
dataloader,
|
|
12
|
+
optimizer,
|
|
13
|
+
epoch,
|
|
14
|
+
device,
|
|
15
|
+
prog
|
|
16
|
+
):
|
|
17
|
+
model.train(True)
|
|
18
|
+
optimizer.zero_grad()
|
|
19
|
+
|
|
20
|
+
omics_num = model.omics_num
|
|
21
|
+
|
|
22
|
+
loss_rec_epoch = [0 for _ in range(omics_num)]
|
|
23
|
+
loss_rec_q_epoch = [0 for _ in range(omics_num)]
|
|
24
|
+
loss_c_epoch = 0
|
|
25
|
+
|
|
26
|
+
for data in dataloader:
|
|
27
|
+
x_list = []
|
|
28
|
+
sf_list = []
|
|
29
|
+
raw_list = []
|
|
30
|
+
for i in range(omics_num):
|
|
31
|
+
x_list.append(data["x"][i].to(device, non_blocking = True))
|
|
32
|
+
sf_list.append(data["sf"][i].to(device, non_blocking = True))
|
|
33
|
+
raw_list.append(data["raw"][i].to(device, non_blocking = True))
|
|
34
|
+
|
|
35
|
+
hiddens = model(x_list)
|
|
36
|
+
hidden_q, loss_c = model.quantize(hiddens)
|
|
37
|
+
means, disps = model.decode(hiddens)
|
|
38
|
+
means_q, disps_q = model.decode_q(hidden_q)
|
|
39
|
+
|
|
40
|
+
loss_rec_all = 0
|
|
41
|
+
loss_rec_q_all = 0
|
|
42
|
+
|
|
43
|
+
for i in range(omics_num):
|
|
44
|
+
loss_rec = reconstruction_loss(
|
|
45
|
+
means[i], disps[i], sf_list[i], raw_list[i], data_types[i])
|
|
46
|
+
loss_rec_q = reconstruction_loss(
|
|
47
|
+
means_q[i], disps_q[i], sf_list[i], raw_list[i], data_types[i])
|
|
48
|
+
loss_rec_all += loss_rec
|
|
49
|
+
loss_rec_q_all += loss_rec_q
|
|
50
|
+
loss_rec_epoch[i] += loss_rec.item()
|
|
51
|
+
loss_rec_q_epoch[i] += loss_rec_q.item()
|
|
52
|
+
|
|
53
|
+
loss_c_epoch += loss_c.item()
|
|
54
|
+
loss = loss_rec_all + loss_rec_q_all + loss_c
|
|
55
|
+
|
|
56
|
+
loss.backward()
|
|
57
|
+
optimizer.step()
|
|
58
|
+
optimizer.zero_grad()
|
|
59
|
+
|
|
60
|
+
# if (epoch + 1) % 20 == 0 or epoch == 0:
|
|
61
|
+
# for i in range(omics_num):
|
|
62
|
+
# prog.write(
|
|
63
|
+
# f'(epoch {epoch + 1}) [{data_types[i]}] ' +
|
|
64
|
+
# f'loss-rec: {(loss_rec_epoch[i] / len(dataloader)):.4f}, ' +
|
|
65
|
+
# f'loss-rec-q: {(loss_rec_q_epoch[i] / len(dataloader)):.4f}'
|
|
66
|
+
# )
|
|
67
|
+
#
|
|
68
|
+
# prog.write(
|
|
69
|
+
# f'(epoch {epoch + 1}) [codebook]: ' +
|
|
70
|
+
# f'loss: {(loss_c / len(dataloader)):.4f}'
|
|
71
|
+
# )
|
|
72
|
+
|
|
73
|
+
loss_rec_q_epoch = np.array(loss_rec_q_epoch).mean() / len(dataloader)
|
|
74
|
+
loss_c_epoch = loss_c / len(dataloader)
|
|
75
|
+
|
|
76
|
+
return loss_rec_q_epoch, loss_c_epoch
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def warm_one_epoch(
|
|
80
|
+
model,
|
|
81
|
+
data_types,
|
|
82
|
+
dataloader,
|
|
83
|
+
optimizer,
|
|
84
|
+
epoch,
|
|
85
|
+
device,
|
|
86
|
+
prog
|
|
87
|
+
):
|
|
88
|
+
model.train(True)
|
|
89
|
+
optimizer.zero_grad()
|
|
90
|
+
|
|
91
|
+
omics_num = model.omics_num
|
|
92
|
+
|
|
93
|
+
loss_rec_epoch = [0 for _ in range(omics_num)]
|
|
94
|
+
|
|
95
|
+
for data in dataloader:
|
|
96
|
+
x_list = []
|
|
97
|
+
sf_list = []
|
|
98
|
+
raw_list = []
|
|
99
|
+
for i in range(omics_num):
|
|
100
|
+
x_list.append(data["x"][i].to(device, non_blocking=True))
|
|
101
|
+
sf_list.append(data["sf"][i].to(device, non_blocking=True))
|
|
102
|
+
raw_list.append(data["raw"][i].to(device, non_blocking=True))
|
|
103
|
+
|
|
104
|
+
hiddens = model(x_list)
|
|
105
|
+
means, disps = model.decode(hiddens)
|
|
106
|
+
|
|
107
|
+
loss_rec_all = 0
|
|
108
|
+
for i in range(omics_num):
|
|
109
|
+
loss_rec = reconstruction_loss(
|
|
110
|
+
means[i], disps[i], sf_list[i], raw_list[i], data_types[i]
|
|
111
|
+
)
|
|
112
|
+
loss_rec_all += loss_rec
|
|
113
|
+
loss_rec_epoch[i] += loss_rec.item()
|
|
114
|
+
|
|
115
|
+
loss = loss_rec_all
|
|
116
|
+
|
|
117
|
+
loss.backward()
|
|
118
|
+
optimizer.step()
|
|
119
|
+
optimizer.zero_grad()
|
|
120
|
+
|
|
121
|
+
# if (epoch + 1) % 20 == 0 or epoch == 0:
|
|
122
|
+
# for i in range(omics_num):
|
|
123
|
+
# prog.write(
|
|
124
|
+
# f'(epoch {epoch + 1}) [{data_types[i]}] ' +
|
|
125
|
+
# f'loss: {(loss_rec_epoch[i] / len(dataloader)):.4f}'
|
|
126
|
+
# )
|
|
127
|
+
|
|
128
|
+
loss_rec_epoch = np.array(loss_rec_epoch).mean() / len(dataloader)
|
|
129
|
+
|
|
130
|
+
return loss_rec_epoch
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
@torch.no_grad()
|
|
134
|
+
def inference(model, data_types, data_loader, device):
|
|
135
|
+
|
|
136
|
+
model.eval()
|
|
137
|
+
omics_num = model.omics_num
|
|
138
|
+
|
|
139
|
+
embeds = []
|
|
140
|
+
ids = []
|
|
141
|
+
delta_confs = []
|
|
142
|
+
loss_rec_all = 0
|
|
143
|
+
loss_rec_q_all = 0
|
|
144
|
+
loss_c_all = 0
|
|
145
|
+
|
|
146
|
+
for data in data_loader:
|
|
147
|
+
x_list = []
|
|
148
|
+
sf_list = []
|
|
149
|
+
raw_list = []
|
|
150
|
+
for i in range(omics_num):
|
|
151
|
+
x_list.append(data["x"][i].to(device, non_blocking=True))
|
|
152
|
+
sf_list.append(data["sf"][i].to(device, non_blocking=True))
|
|
153
|
+
raw_list.append(data["raw"][i].to(device, non_blocking=True))
|
|
154
|
+
|
|
155
|
+
with torch.no_grad():
|
|
156
|
+
hiddens = model(x_list)
|
|
157
|
+
|
|
158
|
+
id, delta_conf, loss_c = model.quantize(hiddens, return_assignment=True)
|
|
159
|
+
loss_c_all += loss_c
|
|
160
|
+
|
|
161
|
+
hidden_q, _ = model.quantize(hiddens)
|
|
162
|
+
means, disps = model.decode(hiddens)
|
|
163
|
+
means_q, disps_q = model.decode_q(hidden_q)
|
|
164
|
+
|
|
165
|
+
for i in range(omics_num):
|
|
166
|
+
|
|
167
|
+
loss_rec = reconstruction_loss(
|
|
168
|
+
means[i],
|
|
169
|
+
disps[i],
|
|
170
|
+
sf_list[i],
|
|
171
|
+
raw_list[i],
|
|
172
|
+
data_types[i],
|
|
173
|
+
reduction = "sum",
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
loss_rec_all += loss_rec
|
|
177
|
+
loss_rec_q = reconstruction_loss(
|
|
178
|
+
means_q[i],
|
|
179
|
+
disps_q[i],
|
|
180
|
+
sf_list[i],
|
|
181
|
+
raw_list[i],
|
|
182
|
+
data_types[i],
|
|
183
|
+
reduction = "sum",
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
loss_rec_q_all += loss_rec_q
|
|
187
|
+
|
|
188
|
+
if omics_num > 1: hidden = torch.cat(hiddens, dim=1)
|
|
189
|
+
else: hidden = hiddens[0]
|
|
190
|
+
|
|
191
|
+
embeds.append(hidden.detach().cpu().numpy())
|
|
192
|
+
ids.append(id.detach().cpu().numpy())
|
|
193
|
+
delta_confs.append(delta_conf.detach().cpu().numpy())
|
|
194
|
+
|
|
195
|
+
embeds = np.concatenate(embeds, axis=0)
|
|
196
|
+
ids = np.concatenate(ids, axis=0)
|
|
197
|
+
delta_confs = np.concatenate(delta_confs, axis=0)
|
|
198
|
+
|
|
199
|
+
rec_q_percent = (loss_rec_all / loss_rec_q_all).item()
|
|
200
|
+
loss_c_all = loss_c_all.item() / (
|
|
201
|
+
data_loader.dataset.__len__() * model.quantizer.entry_dim
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
return embeds, ids, delta_confs, rec_q_percent, loss_c_all
|