rapids_singlecell.pp.regress_out

Contents

rapids_singlecell.pp.regress_out#

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

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

Parameters:
adata AnnData

AnnData object

keys str | list

Keys for observation annotation on which to regress on. Supports both numerical and single categorical covariates.

layer str | None (default: None)

Layer to regress instead of X. If None, X is regressed.

inplace bool (default: True)

Whether to update adata or return the corrected matrix of adata.X and adata.layers.

batchsize Union[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:

Optional[ndarray]

Returns:

Returns a corrected copy or updates adata with a corrected version of the original adata.X and adata.layers['layer'], depending on inplace.