ehrapy.preprocessing.maxabs_norm

ehrapy.preprocessing.maxabs_norm(adata, vars=None, group_key=None, copy=False)[source]

Apply max-abs normalization.

Functionality is provided by maxabs_scale(), see https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.maxabs_scale.html for details.

Parameters:
  • adata (AnnData) – AnnData object containing X to normalize values in. Must already be encoded using encode().

  • vars (str | Sequence[str] | None) – List of the names of the numeric variables to normalize. If None all numeric variables will be normalized. Defaults to None.

  • group_key (str | None) – Key in adata.obs that contains group information. If provided, scaling is applied per group.

  • copy (bool) – Whether to return a copy or act in place. Defaults to False.

Return type:

AnnData | None

Returns:

AnnData object with normalized X. Also stores a record of applied normalizations as a dictionary in adata.uns[“normalization”].

Examples

>>> import ehrapy as ep
>>> adata = ep.dt.mimic_2(encoded=True)
>>> adata_norm = ep.pp.maxabs_norm(adata, copy=True)