rapids_singlecell.pp.regress_out#

rapids_singlecell.pp.regress_out(adata, covariates=None, *, use=None, out=False, batchsize=None, verbose=False, layer=None, inplace=True, copy=False, keys=None)[source]#

Use linear regression to adjust for the effects of unwanted noise and variation.

Parameters:
adata AnnData

AnnData object

covariates AdRef | str | Sequence[AdRef | str] | None (default: None)

Observation annotation(s) to regress on, e.g. A.obs['n_counts']. Strings name .obs columns (resolved by anndata.acc.AdAcc.resolve() with the scanpy-v2-preview preset). Supports both numerical and single categorical covariates.

use LayerAcc | MultiAcc | str | None (default: None)

Which matrix to regress, e.g. A.X or A.layers['counts']. Strings are resolved by anndata.acc.AdAcc.resolve(), e.g. 'layers.counts'.

out LayerAcc | MultiAcc | str | bool (default: False)

Where to write the result, e.g. A.layers['k'] (or 'layers.k'). If True, the result is returned instead of written. If False, it is written to the place use reads from.

batchsize int | Literal['all'] | None (default: None)

Number of genes that should be processed together. If 'all' all genes will be processed together if .n_obs <100000. If None each gene will be analysed separately. Only used for continuous covariates.

verbose bool (default: False)

Print debugging information

Return type:

AnnData | ndarray | None

Returns:

The corrected matrix if out=True, else None.