mantispy.pp.regress_out#
- mantispy.pp.regress_out(adata, keys=('Metadata_CellCount',), by='Metadata_Plate', key_added=None, copy=False)[source]#
Regress confounders out of every feature, within groups.
- Parameters:
adata (
AnnData) – Object to correct.keys (
Sequence[str] (default:('Metadata_CellCount',))) –obscolumns to regress out. Numeric columns enter directly; categorical ones are one-hot encoded with the first level dropped.by (
str|None(default:'Metadata_Plate')) – Fit separately within each group of this column, usually the plate, whichsc.pp.regress_outcannot do.Nonefits one model globally.key_added (
str|None(default:None)) – Write tolayers[key_added]instead of overwritingX.copy (
bool(default:False)) – Return a modified copy instead of mutating in place.
- Return type:
- Returns:
None, or the modified copy. Each feature is replaced by its residual plus the fitted value at an anchor: the mean over the whole object for a numeric covariate, and the group’s own mean for a categorical one. This keeps the units of the data.
Notes
Missing values stay missing, and a feature with gaps is fitted on the rows where it was measured. A group with no more rows than design columns is left uncorrected and logged.