From 10060b5a8959241e68c16168d110af3feb3eece2 Mon Sep 17 00:00:00 2001 From: Danila Date: Wed, 16 Oct 2024 16:18:59 -0700 Subject: [PATCH] Fix missing filter_var() --- muon/_core/preproc.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/muon/_core/preproc.py b/muon/_core/preproc.py index b108797..04c0735 100644 --- a/muon/_core/preproc.py +++ b/muon/_core/preproc.py @@ -841,6 +841,31 @@ def filter_obs( return +def filter_var( + data: Union[AnnData, MuData], var: Union[str, Sequence[str]], func: Optional[Callable] = None +): + """ + Filter variables (features, e.g. genes) in-place + using any column in .var or row in .X. + + Parameters + ---------- + data: AnnData or MuData + AnnData or MuData object + var: str or Sequence[str] + Column name in .var or row name in .X to be used for filtering. + Alternatively, var_names can be provided directly. + func + Function to apply to the variable used for filtering. + If the variable is of type boolean and func is an identity function, + the func argument can be omitted. + """ + + _filter_attr(data, "var", var, func) + + return + + # Subsampling observations