scanpy.pp.regress_out#
- scanpy.pp.regress_out(adata, covariates=None, *, use=None, out=False, n_jobs=None, copy=False, layer=None, keys=None)[source]#
Regress out (mostly) unwanted sources of variation.
Uses simple linear regression. This is inspired by Seurat’s
regressOutfunction in R [Satija et al., 2015]. Note that this function tends to overcorrect in certain circumstances as described in #526.Array type support# Array type
supported
… experimentally in dask
Array✅
❌
❌
❌
- Parameters:
- adata
AnnData The annotated data matrix.
- covariates
AdRef|str|Sequence[AdRef|str] |None(default:None) Observation annotation(s) to regress on, e.g.
A.obs['n_counts']. Ifscanpy.settings.presetisScanpyV2Preview,strs areanndata.acc.AdAcc.resolve()d toAdRefs (e.g.'obs.is_control'), otherwise interpreted as column names. If empty, all of.obsis used.- use
LayerAcc|MultiAcc|str|None(default:None) Which matrix to regress on. Given by an accessor, e.g.
A.X,A.layers['counts']orA.obsm['pca'].strs areanndata.acc.AdAcc.resolve()d, e.g.'layers.counts'.- layer
str|None(default:None) Deprecated since version 1.13.0: Use
use/outinstead.A key of
layers, i.e.layer='k'isuse=A.layers['k'].- out
LayerAcc|MultiAcc|str|bool(default:False) Where to write the result, e.g.
A.layers['scaled'].strs areanndata.acc.AdAcc.resolve()d, e.g.'layers.scaled'. IfTrue, the result is returned instead of written. IfFalse, it is written to the placeusereads from.- n_jobs
int|None(default:None) Number of jobs for parallel computation.
Nonemeans usingscanpy.settings.n_jobs.- copy
bool(default:False) Deprecated since version 1.13.0: Copy
adatabefore calling this function instead.Whether to return a modified copy instead of modifying
adatain place.- keys
str|Sequence[str] |None(default:None) Deprecated since version 1.13.0: Use
covariatesinstead.Names of
.obscolumns, i.e.keys=['k']iscovariates=[A.obs['k']].
- adata
- Return type:
AnnData|ndarray|csr_array|csc_array|csr_matrix|csc_matrix|None- Returns:
Returns the corrected matrix if
out=True, elseNone. By default overwrites the matrixusereads from (seeoutfor others).