scanpy.pp.regress_out

Contents

scanpy.pp.regress_out#

scanpy.pp.regress_out(adata, keys, *, layer=None, n_jobs=None, copy=False)[source]#

Regress out (mostly) unwanted sources of variation.

Uses simple linear regression. This is inspired by Seurat’s regressOut function in R [Satija et al., 2015]. Note that this function tends to overcorrect in certain circumstances as described in issue526.

Parameters:
adata AnnData

The annotated data matrix.

keys str | Sequence[str]

Keys for observation annotation on which to regress on.

layer str | None (default: None)

If provided, which element of layers to regress on.

n_jobs int | None (default: None)

Number of jobs for parallel computation. None means using scanpy._settings.ScanpyConfig.n_jobs.

copy bool (default: False)

Determines whether a copy of adata is returned.

Return type:

AnnData | None

Returns:

Returns None if copy=False, else returns an updated AnnData object. Sets the following fields:

adata.X | adata.layers[layer]numpy.ndarray | scipy.sparse._csr.csr_matrix (dtype float)

Corrected count data matrix.