ncem.tl.linear_ncem

ncem.tl.linear_ncem(adata: anndata._core.anndata.AnnData, key_type: str, key_graph: str, formula: str = '~0', type_specific_confounders: List[str] = [])[source]

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

Saves fits and Wald test output into instance.

Args:

adata: AnnData instance with data and annotation. formula: Description of batch covariates as linear model. Do not include intercept, cell type, or niche as

this is automatically added.

key_type: Key of type annotation in .obs. key_graph: Key of spatial neighborhood graph in .obsp. 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. Global confounders can be added in the formula.

Returns: