Skip to content

msmu.pp.correct_batch_effect

Batch correction methods for MuData object. GIS-based normalization, median centering, ComBat, and continuous batch correction (with lowess) are supported.

For 'gis', 'median_center', and 'continuous' the per-feature abundance scale is restored after correction (gis: the geometric mean of the per-batch GIS levels, i.e. classic IRS [Plubell et al. 2017]; median_center/continuous: the per-feature overall median). Restoration is decided for the modality as a whole: when the matrix has cross-batch structure (at least one feature observed in >=2 batches, as at the peptide/protein level) every observed feature is restored -- a single-batch feature to its own level, so it stays on the same abundance scale as the rest. When the matrix is fully block-diagonal (no feature spans >=2 batches, e.g. a per-plex-split PSM matrix) nothing is restored and the output stays reference-relative, ready to roll up. ComBat scales itself.

Parameters:

Name Type Description Default
mdata MuData

MuData object to batch correct.

required
method Literal['gis', 'median_center', 'combat', 'continuous']

Batch correction method to use. Options are 'gis', 'median_center', 'combat', 'continuous'.

required
category str

Category in .obs to use for batch correction.

required
modality str

Modality to batch correct.

required
layer str | None

Layer to batch correct. If None, the default layer (.X) will be used.

None
gis_samples list[str] | None

List of GIS samples.

None
drop_gis bool

If True, GIS samples will be dropped after correction. Default is True.

True
log_transformed bool

If True, data is assumed to be log-transformed. Default is True.

True

Returns:

Type Description
MuData

Batch corrected MuData object.