API¶
We advise to import scCODA in a python session via:
import sccoda
dat = sccoda.util.cell_composition_data
ana = sccoda.util.compositional_analysis
viz = sccoda.util.data_visualization
The workflow in scCODA starts with reading in cell count data (dat
) and visualizing them (viz
)
or synthetically generating cell count data (util.data_generation
).
Data acquisition¶
Integrating data sources (dat) (scanpy or pandas)
Converts a Pandas DataFrame into a compositional analysis data set. |
|
Creates a compositional analysis dataset from a single anndata object, as it is produced by e.g. |
|
Creates a compositional analysis data set from all scanpy data sets in a directory. |
|
Creates a compositional analysis data set from a list of scanpy data sets. |
|
|
Converts a single scRNA-seq data set from scanpy (anndata format) to a row of a cell count matrix. |
Synthetic data generation
Generates compositional data with binary covariates. |
|
Calculates intercepts and slopes from a starting count and an absolute change for the first cell type |
|
Calculates a count vector from a given first entry, length and sum. |
|
Generates a sparse effect matrix |
Compositional data visualization
Compositional datasets can be plotted via the methods in util.data_visualization
.
Plots a stacked barplot for all levels of a covariate or all samples (if feature_name==”samples”). |
|
Grouped boxplot visualization. |
|
Plots a stacked barplot for one (discrete) covariate Typical use (only inside stacked_barplot): plot_one_stackbar(data.X, data.var.index, “xyz”, data.obs.index) |
Model setup and inference¶
Using the scCODA model is easiest by generating an instance of ana.CompositionalAnalysis
.
By specifying the formula via the patsy syntax, many combinations and
transformations of the covariates can be performed without redefining the covariate matrix. Also, the reference cell
type needs to be specified in this step.
The scCODA model
Initializer class for scCODA models. |
|
Dynamical framework for formulation and inference of Bayesian models for compositional data analysis. |
|
Statistical model for single-cell differential composition analysis with specification of a reference cell type. |
Utility functions
calculates the estimated number of required samples for fixed MCC, absolute increase and log2-fold change using the fitted linear model from Büttner, Ostner et al., 2020 |
Result evaluation¶
Executing an inference method on a compositional model produces a sccoda.util.result_classes.CAResult
object. This
class extends the InferenceData
class of arviz and supports all its
diagnostic and plotting functionality.
Result class for scCODA, extends the arviz framework for inference data. |
Model comparison¶
sccoda.models.other_models
contains implementations of several compositional methods frm microbiome analysis and
non-compositional tests that can be used for comparison.
Simple Dirichlet-Multinomial model with normal priors. |
|
wrapper for using the scdney package for R (Cao et al., 2019) with scCODA data |
|
|
Implements the Poisson regression model from Haber et al. |
|
Implements a CLR transform and subsequent linear model on each cell type. |
|
Implements a t-test on each cell type. |
Implements a CLR transform and subsequent t-test on each cell type. |
|
Wrapper for using the ALDEx2 package for R (Fernandes et al., 2014) |
|
Implements a ALR transform and subsequent t-test on each cell type. |
|
Implements a ALR transform and subsequent Wilcoxon rank-sum test on each cell type. |
|
|
Wrapper for the ancom model for compositional differentiation analysis (Mandal et al., 2015) |
Wrapper for using the DirichReg package in R (Maier, 2014) with scCODA’s infrastructure |
|
Wrapper for using the corncob package for R (Martin et al., 2020) |
|
Wrapper for using the ANCOMBC package for R (Lin and Peddada, 2020) |