mantispy.pp.normalize#
- mantispy.pp.normalize(adata, method='mad_robustize', by='Metadata_Plate', reference=None, epsilon=1e-18, keep_raw=False, layer=None, key_added=None, copy=False)#
Normalize features within groups, optionally fitting on reference rows only.
- Parameters:
adata (
AnnData) – Object to normalize.method (
str(default:'mad_robustize')) –"mad_robustize"computes(x - median) / (1.4826 * MAD + epsilon),"standardize"computes(x - mean) / sd, and"robustize"computes(x - median) / IQR.by (
str|list[str] |None(default:'Metadata_Plate')) – Column(s) defining the groups statistics are computed within, usually the plate.Nonefits one set of statistics globally.reference (
str|None(default:None)) – Rows to fit on:Nonefor all,"negcon"forMetadata_Control, or the name of a booleanobscolumn.epsilon (
float(default:1e-18)) – Added to the MAD, matching pycytominer’smad_robustize_epsilon. Unused by the other methods.keep_raw (
bool(default:False)) – Store the pre-normalization matrix inlayers["raw"]. Off by default, because the layer doubles memory and the raw table is already on disk.layer (
str|None(default:None)) – Read this layer instead ofX.key_added (
str|None(default:None)) – Write tolayers[key_added]instead of overwritingX.copy (
bool(default:False)) – Return a normalized copy instead of normalizing in place.
- Return type:
- Returns:
None, or the normalized copy whencopy=True. WritesXorlayers[key_added], andvar["degenerate_scale"], orvar["degenerate_scale_<key_added>"]when writing to a layer, which flags features that have no spread in some group or no reference values to centre on there, and comes with a warning; drop those features before computing distances.- Raises:
ValueError – If
methodis unknown, orreferenceselects no rows at all or none in some group.