MatrixPlot.add_dendrogram(show=True, dendrogram_key=None, size=0.8)

Show dendrogram based on the hierarchical clustering between the groupby categories. Categories are reordered to match the dendrogram order.

The dendrogram information is computed using If has not been called previously the function is called with default parameters.

The dendrogram is by default shown on the right side of the plot or on top if the axes are swapped.

var_names are reordered to produce a more pleasing output if:
  • The data contains var_groups

  • the var_groups match the categories.

The previous conditions happen by default when using Plot to show the results from rank_genes_groups() (aka gene markers), by calling

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

Boolean to turn on (True) or off (False) ‘add_dendrogram’

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

Needed if saved the dendrogram using a key different than the default name.

size : float | NoneOptional[float] (default: 0.8)

size of the dendrogram. Corresponds to width when dendrogram shown on the right of the plot, or height when shown on top. The unit is the same as in matplotlib (inches).




>>> adata = sc.datasets.pbmc68k_reduced()
>>> markers = {{'T-cell': 'CD3D', 'B-cell': 'CD79A', 'myeloid': 'CST3'}}
>>>, markers, groupby='bulk_labels').add_dendrogram().show()