ehrapy.tools.filter_rank_features_groups

ehrapy.tools.filter_rank_features_groups(adata, key='rank_features_groups', groupby=None, key_added='rank_features_groups_filtered', min_in_group_fraction=0.25, min_fold_change=1, max_out_group_fraction=0.5)[source]

Filters out features based on fold change and fraction of features containing the feature within and outside the groupby categories.

See rank_features_groups().

Results are stored in adata.uns[key_added] (default: ‘rank_genes_groups_filtered’).

To preserve the original structure of adata.uns[‘rank_genes_groups’], filtered genes are set to NaN.

Parameters:
  • adata (AnnData) – Annotated data matrix.

  • key – Key previously added by rank_features_groups()

  • groupby – The key of the observations grouping to consider.

  • key_added – The key in adata.uns information is saved to.

  • min_in_group_fraction – Minimum in group fraction (default: 0.25).

  • min_fold_change – Miniumum fold change (default: 1).

  • max_out_group_fraction – Maximum out group fraction (default: 0.5).

Return type:

None

Returns:

Same output as ehrapy.tl.rank_features_groups() but with filtered feature names set to nan

Examples

>>> import ehrapy as ep
>>> adata = ep.dt.mimic_2(encoded=True)
>>> ep.tl.rank_features_groups(adata, "service_unit")
>>> ep.pl.rank_features_groups(adata)