ncem.tl.spline_linear_ncem
- ncem.tl.spline_linear_ncem(adata: anndata._core.anndata.AnnData, df: int, key_1d_coord: str, key_graph: str, key_type: str, formula: str = '~0', spline_family: str = 'cr', 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. 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_type: Key of type annotation in .obs. key_graph: Key of spatial neighborhood graph in .obsp. 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: