.filter_by_var_consistency
- proteopy.pp.filter_by_var_consistency(adata, threshold, key=None, remove_na=True, verbose=False, inplace=True)[source]
Filter variables by a per-variable consistency score.
Keeps the variables whose
adata.var[key]is at leastthreshold, e.g. the minimum batch-pair correlation computed byvar_consistency().- Parameters:
adata (AnnData) –
AnnDataobject in proteodata format.threshold (int | float) – Minimum score a variable needs to be kept (
score >= threshold).key (str | None) – Numeric column in
adata.varholding the score. If None, it is inferred as the singleadata.varcolumn ending in'_corr_min', i.e. the minimum pairwise correlation stored byvar_consistency().remove_na (bool) – Remove variables whose score is NaN (undefined). If False, they are kept.
verbose (bool) – Print how many variables are kept, removed and undefined.
inplace (bool) – If True, modify
adatain place. If False, return a filtered copy ofadata.
- Returns:
The filtered copy of
adataifinplace=False, otherwise None.- Return type:
AnnData | None
- Raises:
KeyError – If
keyis not a column ofadata.var.ValueError – If
keyis None and not exactly oneadata.varcolumn ends in'_corr_min'.TypeError – If
keyis not an integer or float column,thresholdis not an int or float, or a flag is not a bool.
Examples
>>> import proteopy as pr >>> pr.pp.var_consistency( ... adata, ... batch_key="replicate", ... group_by=["condition", "fraction"], ... ) >>> pr.pp.filter_by_var_consistency(adata, threshold=0.25)
Pass
keywhen several consistency scores are stored, or to filter on another summary:>>> pr.pp.filter_by_var_consistency( ... adata, ... threshold=0.5, ... key="replicate_corr_median", ... )