sccoda.model.scCODA_model.CompositionalModel¶
-
class
sccoda.model.scCODA_model.CompositionalModel(covariate_matrix, data_matrix, cell_types, covariate_names, formula, *args, **kwargs)¶ Dynamical framework for formulation and inference of Bayesian models for compositional data analysis. This framework is used to implement scCODA’s model as a subclass of this class. Tensorflow probability then allows to run a multitude of inference algorithms on these models without the need to specify them every time.
A
CompositionalModelconsists of the following parameters:covariate_matrix: Numpy array that specifies the independent variables (X). Generated equivalently to the covariate matrix of a linear regression.data_matrix: Dependent variable (Y). Includes the raw cell type counts for every sample.cell_types, covariate_names: Names of cell types and covariatesformula: String that represents which covariates to include and how to transform them. Used analogously to the formula in R’s lm function
A specific compositional model is then implemented as a child class, with the following additional parameters specified in the constructor:
target_log_prob_fn: Log-probability function of the model. For more specific information, please refer to (tensorflow probability’s API)[https://www.tensorflow.org/probability/api_docs/python/tfp]param_names: Names of prior and intermediate parameters that are included in the model output. The order has to be the same as in the states_burnin output ofself.get_y_hatinit_params: Initial values for the inference method
Methods implemented by this class:
sampling: General MCMC sampling that uses a transition kernelget_chains_after_burnin: Application of burn-in to MCMC sampling resultsMCMC sampling methods (
sample_hmc,sample_hmc_da,sample_nuts)
Methods implemented by a child class:
get_y_hat: Calculation of intermediate parameters for all MCMC chain states and posterior mode of the cell count matrix
Methods
get_chains_after_burnin(samples, …[, is_nuts])Application of burn-in after MCMC sampling.
make_result(states_burnin, sample_stats, …)Result object generating function.
sample_hmc([num_results, num_burnin, …])Hamiltonian Monte Carlo (HMC) sampling in tensorflow 2.
sample_hmc_da([num_results, num_burnin, …])HMC sampling with dual-averaging step size adaptation (Nesterov, 2009)
sample_nuts([num_results, num_burnin, …])HMC with No-U-turn (NUTS) sampling.
sampling(num_results, num_burnin, kernel, …)MCMC sampling process (tensorflow 2)