alphapepttools.pp.scanpy_pycombat

alphapepttools.pp.scanpy_pycombat#

alphapepttools.pp.scanpy_pycombat(adata, batch, layer=None, *, copy=False)#

Wrap scanpy’s pp.combat function with error checks and preprocessing suggestions.

Correct for the batch effect of a categorical covariate using an empirical Bayes framework as implemented in the pyComBat function of scanpy. The underlying function requires a complete data matrix without NaN values, which may require imputation prior to running batch correction.

Parameters:
  • adata (AnnData) – Annotated data matrix, where rows are cells and columns are features. The data matrix cannot contain NaN values.

  • batch (str) – Name of the batch feature in obs, the variation associated with this feature will be corrected. Missing values in this column will be replaced by one single “NA” batch.

  • layer (Optional[str] (default: None)) – Name of the layer to batch correct. If None (default), the attribute adata.X is used.

  • copy (bool (default: False)) – Whether to return a modified copy (True) of the anndata object. If False (default) modifies the object inplace

Return type:

AnnData

Returns:

-adata (AnnData) AnnData with batch correction applied to layer. If copy=False modifies the anndata object at layer inplace and returns None. If copy=True, returns a modified copy.