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 objectvars (
str
|list
[str
] |set
[str
]) – Columns in var with features to clipobs_cols (
str
|list
[str
] |set
[str
]) – Columns in obs with features to cliplimits (
list
[float
]) – Interval, values outside of which are clipped to the interval edgescopy (
bool
) – Whether to return a copy of AnnData or not
- Return type:
- Returns:
A copy of original AnnData object with clipped features.
Examples
>>> import ehrapy as ep >>> adata = ep.dt.mimic_2(encoded=True) >>> ep.pp.clip_quantile(adata, ["bmi"])