Skip to contents

Build a hierarchical tree of clusters using average expression profiles.

Usage

VisClusterTree(
  object,
  assay = NULL,
  group.by = "seurat_clusters",
  dist.metric = "euclidean",
  linkage = "complete",
  show_heatmap = TRUE,
  palette = "C",
  tile_alpha = 0.8
)

Arguments

object

A Seurat object; required.

assay

Assay name. Default: Seurat::DefaultAssay(object).

group.by

Metadata column for cluster identity. Default: "seurat_clusters".

dist.metric

Distance metric: 'euclidean' or 'correlation'. Default: 'euclidean'.

linkage

Linkage method (e.g., 'complete', 'average', 'ward.D2'). Default: 'complete'.

show_heatmap

Append pairwise similarity heatmap under the tree. Default: TRUE.

palette

Viridis palette option for color/fill. Default: "C".

tile_alpha

Tile alpha. Default: 0.8.

Value

A ggplot dendrogram (or patchwork with heatmap).

Author

benben-miao

Examples

obj <- SeuratVisProExample(
    n_cells = 300,
    n_genes = 1000,
    n_clusters = 10,
    seed = 123,
    genes_mt = "^MT-",
    neighbor_dims = 10,
    cluster_res = 0.5,
    umap_dims = 10,
    spatial = FALSE)
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#> 
#> Number of nodes: 300
#> Number of edges: 4508
#> 
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.9485
#> Number of communities: 10
#> Elapsed time: 0 seconds

p <- VisClusterTree(
  obj,
  assay = NULL,
  group.by = "seurat_clusters",
  dist.metric = "euclidean",
  linkage = "complete",
  show_heatmap = TRUE,
  palette = "C",
  tile_alpha = 0.8)
#> As of Seurat v5, we recommend using AggregateExpression to perform pseudo-bulk analysis.
#> This message is displayed once per session.
#> First group.by variable `seurat_clusters` starts with a number, appending `g` to ensure valid variable names
#> This message is displayed once every 8 hours.
p