通过热图识别树状图中的簇数

问题描述

我正在使用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",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)

Example heatmap with mtcars dataset

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)