ncem.tl.spline_linear_ncem_deconvoluted

ncem.tl.spline_linear_ncem_deconvoluted(adata: anndata._core.anndata.AnnData, df: int, key_1d_coord: str, key_deconvolution: str, formula: str = '~0', spline_family: str = 'cr', type_specific_confounders: List[str] = [])[source]

Fit a linear NCEM based on deconvoluted data in an adata instance and save fits in instance.

Saves fits and Wald test output into instance.

Args:

adata: AnnData instance with data and annotation. Note on placement of deconvolution output:

  • type abundances must in be in .obsm[key_deconvolution] with cell type names as columns

  • spot- and type-specific gene expression results must be layers named after types

df: Degrees of freedom of the spline model, i.e. the number of spline basis vectors. formula: Description of batch covariates as linear model. Do not include intercept, cell type, or niche as

this is automatically added.

key_1d_coord: Key of numeric 1D coordinate of each observation in .obs. This will be used to build the spline. key_deconvolution: Key of type deconvolution in .obsm. spline_family: The type of sline basis to use, refer also to:

https://patsy.readthedocs.io/en/latest/spline-regression.html

  • “bs”: B-splines

  • “cr”: natural cubic splines

  • “cc”: natural cyclic splines

type_specific_confounders: List of confounding terms in .obs to be added with an interaction term to cell

types, ie confounders that act on the cell type level. As the formula is used for each index cell, this is equivalent to adding these terms into the formula.

Returns: