Skip to content

Downstream API

Everything in this section runs off the single sample embedding uns['X_DR_sample'] — the final sample-level DataFrame (units × PCs) written in place by compute_sample_embedding. The functions are identical across RNA, ATAC, and multi-omics, and most share a common wrapper invocation inside downstream_analysis().

Sample distance

Function Purpose
sample_distance Unified entry point for vector metrics (cosine, correlation, euclidean, ...), EMD, chi-square, Jensen–Shannon.

Dimension association

Function Purpose
run_dimension_association_analysis Per-PC variance-explained decomposition against every sample-level metadata variable, with permutation p-values — confounder / leading-covariate diagnostic.

Trajectory analysis

Function Purpose When to use
CCA_Call Supervised pseudotime via canonical correlation with a phenotype. You have a phenotype gradient in .obs.
cca_pvalue_test Permutation p-value for a CCA correlation. Want to test significance of a CCA result.
TSCAN Unsupervised pseudotime via GMM + MST. No phenotype; let structure emerge from the embedding.
run_trajectory_gam_differential_gene_analysis Per-gene GAM against pseudotime, with heatmap, volcano, and curve plots. Pseudotime (from CCA or TSCAN) in hand; find trajectory-associated genes.

Sample clustering and cluster comparisons

Function Purpose When to use
cluster K-means on the sample embedding. Want a discrete sample grouping when no phenotype is available.
proportion_test eBayes moderated test on per-sample cell-type proportions across groups. Ask whether cluster/group differences are driven by cell-type composition.
raisinfit Fit the RAISIN hierarchical GLM. Step 1 of cluster-level differential expression.
run_pairwise_tests Run every pairwise contrast on a fitted RAISIN model, emit volcanos + summary plots. Step 2 of cluster-level DE.

Visualization

Function Purpose
visualization Cell-type dendrogram, proportion PCA, expression UMAP — toggle which panels you want.
visualize_multimodal_embedding Scatter of the sample embedding with flexible coloring; multi-omics only.

For an end-to-end walkthrough that chains these functions together, see the Downstream tutorials.