我正在使用 heatmaply 包创建带有来自 dendextend 包的树状图的热图。有没有办法识别树状图上的簇号?这是 mtcars 数据集的示例热图。我想要树状图(或图例)上的簇编号,就像我手动放入红色的那样。这是复制的代码:
library(dendextend, datasets, heatmaply)
row_dend <- mtcars %>% dist %>% hclust %>% as.dendrogram %>%
set("branches_k_color", value = c(1:8), k = 8) %>%
set("branches_lwd", 1)
col_dend <- mtcars%>% t %>% dist %>% hclust %>% as.dendrogram %>%
set("branches_k_color", value = c(1:8), k = 8) %>%
set("branches_lwd", 1)
heatmaply_mtcars <-
heatmaply(mtcars, hclustfun = hclust, hclust_method = "ward.D2",
Rowv = row_dend,
Colv = col_dend,
xlab = "x axis",
ylab = "y axis",
showticklabels = c(TRUE, TRUE),
scale_fill_gradient_fun = ggplot2::scale_fill_gradient2(high = "#025492"),
file = "inter_heatmap.html",
column_text_angle = 30,
colorbar_thickness = 50)