scanpy.pp.combat#
- scanpy.pp.combat(adata, batch=A.obs['batch'], *, covariates=None, use=None, out=False, inplace=True, key=None)[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].
Array type support# Array type
supported
… experimentally in dask
Array✅
❌
❌
❌
- Parameters:
- adata
AnnData Annotated data matrix
- batch
AdRef|str|Default(default:A.obs['batch']) A categorical annotation that will be used for batch effect removal, e.g.
A.obs['batch']. Ifscanpy.settings.presetisScanpyV2Preview,strs areanndata.acc.AdAcc.resolve()d toAdRefs (e.g.'obs.is_control'), otherwise interpreted as column names.- covariates
Collection[AdRef|str] |None(default:None) Additional covariates besides the batch variable such as adjustment variables or biological condition (references or names like
batch). This parameter refers to the design matrixXin Equation 2.1 in Johnson et al. [2006] and to themodargument 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.- use
LayerAcc|MultiAcc|str|None(default:None) Which matrix to correct. Given by an accessor, e.g.
A.X,A.layers['counts']orA.obsm['pca'].strs areanndata.acc.AdAcc.resolve()d, e.g.'layers.counts'.- 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.- inplace
bool(default:True) Deprecated since version 1.13.0: Use
out=Trueinstead ofinplace=False.Whether to replace adata.X or to return the corrected data
- key
str|None(default:None) Deprecated since version 1.13.0: Use
batchinstead.The name of a
.obscolumn, i.e.key='b'isbatch=A.obs['b'].
- adata
- Return type:
- Returns:
Returns the corrected matrix (a
numpy.ndarray) ifout=True, elseNone.