ehrapy.plot.dendrogram

ehrapy.plot.dendrogram(adata, groupby, *, dendrogram_key=None, orientation='top', remove_labels=False, show=None, save=None, ax=None)[source]

Plots a dendrogram of the categories defined in groupby.

See dendrogram().

Parameters:
  • adata (AnnData) – AnnData object object containing all observations.

  • groupby (str) – Categorical data column used to create the dendrogram.

  • dendrogram_key (str | None) – Key under with the dendrogram information was stored. By default the dendrogram information is stored under .uns[f’dendrogram_{groupby}’].

  • orientation (Literal['top', 'bottom', 'left', 'right']) – Origin of the tree. Will grow into the opposite direction.

  • remove_labels (bool) – Don’t draw labels. Used e.g. by scanpy.pl.matrixplot() to annotate matrix columns/rows.

  • show (bool | None) – Whether to display the figure or return axis.

  • save (str | bool | None) – If True or a str, save the figure. A string is appended to the default filename. Infer the filetype if ending on {‘.pdf’, ‘.png’, ‘.svg’}.

  • ax (Axes | None) – A matplotlib axes object. Only works if plotting a single component.

Returns:

matplotlib.axes.Axes

Example

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)
ep.tl.leiden(adata, resolution=0.5, key_added="leiden_0_5")
ep.pl.dendrogram(adata, groupby="leiden_0_5")
Preview:
../../_images/dendrogram.png