ehrapy.plot.rank_features_groups_stacked_violin(adata, groups=None, n_features=None, groupby=None, feature_symbols=None, *, var_names=None, min_logfoldchange=None, key=None, show=None, save=None, return_fig=False, **kwds)[source]#

Plot ranking of genes using stacked_violin plot.

  • adata (AnnData) – Annotated data matrix.

  • groups (str | Sequence[str]) – List of group names.

  • n_features (int | None) – Number of features to show. Is ignored if feature_names is passed.

  • groupby (str | None) – Which key to group the features by.

  • feature_symbols (str | None) – Key for field in .var that stores feature symbols if you do not want to use .var_names displayed in the plot.

  • var_names (Sequence[str] | Mapping[str, Sequence[str]] | None) – Feature names.

  • min_logfoldchange (float | None) – Minimum log fold change to consider.

  • key (str | None) – The key of the calculated feature group rankings (default: ‘rank_features_groups’).

  • show (bool | None) – Whether to show the plot.

  • save (bool | None) – Where to save the plot.

  • return_fig (bool | None) – Returns StackedViolin object. Useful for fine-tuning the plot. Takes precedence over show=False.


If return_fig is True, returns a StackedViolin object, else if show is false, return axes dict


>>> import ehrapy as ep
>>> adata = ep.dt.mimic_2(encoded=True)
>>> ep.pp.knn_impute(adata)
>>> ep.pp.log_norm(adata, offset=1)
>>> ep.pp.neighbors(adata)
>>>, resolution=0.15, key_added="leiden_0_5")
>>>, groupby="leiden_0_5")
>>>, key="rank_features_groups", n_features=5)