scanpy.pl.dendrogram

scanpy.pl.dendrogram(adata, groupby, *, dendrogram_key=None, orientation='top', remove_labels=False, show=None, save=None, ax=None)

Plots a dendrogram of the categories defined in groupby.

See dendrogram().

Parameters
adata : AnnDataAnnData

Annotated data matrix.

groupby : strstr

Categorical data column used to create the dendrogram

dendrogram_key : str | NoneOptional[str] (default: None)

Key under with the dendrogram information was stored. By default the dendrogram information is stored under .uns[f'dendrogram_{groupby}'].

orientation : {‘top’, ‘bottom’, ‘left’, ‘right’}Literal[‘top’, ‘bottom’, ‘left’, ‘right’] (default: 'top')

Origin of the tree. Will grow into the opposite direction.

remove_labels : boolbool (default: False)

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

show : bool | NoneOptional[bool] (default: None)

Show the plot, do not return axis.

save : str | bool | NoneUnion[str, bool, None] (default: 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 | NoneOptional[Axes] (default: None)

A matplotlib axes object. Only works if plotting a single component.

Returns

matplotlib.axes.Axes

Examples

import scanpy as sc
adata = sc.datasets.pbmc68k_reduced()
sc.tl.dendrogram(adata, 'bulk_labels')
sc.pl.dendrogram(adata, 'bulk_labels')
../_images/scanpy-pl-dendrogram-1.png