scanpy.pp.combat

Contents

scanpy.pp.combat#

scanpy.pp.combat(adata, key='batch', *, covariates=None, inplace=True)[source]#

ComBat function for batch effect correction [Johnson et al., 2006, Leek et al., 2017, Pedersen, 2012].

Corrects for batch effects by fitting linear models, gains statistical power via an EB framework where information is borrowed across genes. This uses the implementation combat.py [Pedersen, 2012].

Parameters:
adata AnnData

Annotated data matrix

key str (default: 'batch')

Key to a categorical annotation from obs that will be used for batch effect removal.

covariates Collection[str] | None (default: None)

Additional covariates besides the batch variable such as adjustment variables or biological condition. This parameter refers to the design matrix X in Equation 2.1 in Johnson et al. [2006] and to the mod argument in the original combat function in the sva R package. Note that not including covariates may introduce bias or lead to the removal of biological signal in unbalanced designs.

inplace bool (default: True)

Whether to replace adata.X or to return the corrected data

Return type:

ndarray | None

Returns:

Returns numpy.ndarray if inplace=True, else returns None and sets the following field in the adata object:

adata.Xnumpy.ndarray (dtype float)

Corrected data matrix.