ehrapy.preprocessing.clip_quantile#

ehrapy.preprocessing.clip_quantile(adata, limits, vars=None, obs_cols=None, copy=False)[source]#

Clips (limits) features.

Given an interval, values outside the interval are clipped to the interval edges.

The implementation is based on https://numpy.org/doc/stable/reference/generated/numpy.clip.html

Parameters:
  • adata (AnnData) – The AnnData object

  • vars (Union[str, list[str], set[str], None]) – Columns in var with features to clip

  • obs_cols (Union[str, list[str], set[str], None]) – Columns in obs with features to clip

  • limits (list[float]) – Interval, values outside of which are clipped to the interval edges

  • copy (bool) – Whether to return a copy of AnnData or not

Return type:

AnnData

Returns:

A copy of original AnnData object with clipped features.

Examples

>>> import ehrapy as ep
>>> adata = ep.data.mimic_2(encoded=True)
>>> ep.pp.clip_quantile(adata, ['bmi'])