ncem.tl.spline_differential_ncem
- ncem.tl.spline_differential_ncem(adata: anndata._core.anndata.AnnData, df: int, key_1d_coord: str, key_differential: str, key_graph: str, key_type: str, formula: str = '~0', spline_family: str = 'cr', type_specific_confounders: List[str] = [])[source]
Fit a differential 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. 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, niche, or the
differential term 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_differential: Key of condition annotation in .obs. This will be used for testing. key_graph: Key of spatial neighborhood graph in .obsp. key_type: Key of type annotation in .obs. 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. Global confounders can be added in the formula.
Returns: