multivelovae.regress_out

multivelovae.regress_out(adata, keys, layer=None, n_jobs=8, copy=False, add_intercept=False)
Regress out (mostly) unwanted sources of variation and optionally add intercept back.

Adapted from scanpy, with an option to add intercept back after regression. See github.com/scverse/scanpy/pull/2731 for details.

Args:
adata (anndata.AnnData):

The annotated data matrix.

keys (Union[str, Sequence[str]]):

Keys for observation annotation on which to regress.

layer (str, optional):

If provided, which element of layers to use in regression. Defaults to None.

n_jobs (int, optional):

Number of jobs for parallel computation. Defaults to 8.

copy (bool, optional):

Determines whether a copy of adata is returned. Defaults to False.

add_intercept (bool, optional):

If True, regress_out will add intercept back to residuals in order to transform results back into gene-count space. Defaults to False.

Returns:
None:

if not copy. Directly modifies adata with corrected data matrix.

anndata.AnnData:

if copy. Returns AnnData with corrected data matrix.