简体   繁体   English

R(包过热) - 向树状图添加颜色(或矩形)

[英]R (package superheat) - adding color (or rectangles) to the dendrograms

Minimal example and package documentation ( https://rlbarter.github.io/superheat/ ):最小示例和 package 文档( https://rlbarter.github.io/superheat/ ):

library(superheat)
superheat(mtcars,
          # scale the matrix columns
          scale = TRUE,
          left.label = "none",
          # add row dendrogram
          col.dendrogram = TRUE, 
          legend=F,
          )

在此处输入图像描述

I would like to achieve two things:我想实现两件事:

  • Color branches according to cluster (which necessarily I will have to determine k number of clusters) OR add rectangles on top of "chosen" clusters.根据集群颜色分支(我必须确定 k 个集群)或在“选择的”集群顶部添加矩形。
  • I would also be keen to extract and apply the same dendrogram to a different data set (with the same variables).我也很想提取相同的树状图并将其应用于不同的数据集(具有相同的变量)。

I believe the dendrogram is created used ggdendro (if that may assist).我相信树状图是使用ggdendro创建的(如果有帮助的话)。

Consequently these are example of what I wanna achieve:因此,这些是我想要实现的示例: 在此处输入图像描述

The ggdendro package does not support branch colors, and in general it is no longer supported. ggdendro package 不支持分支 colors,一般不再支持。 It was superseded by the dendextend package (which includes the ggdend object, which does support branch colors, lwd and lty).它被 dendextend package(包括 ggdend object,它支持分支 colors、lwd 和 lty)取代。 You can prepare your dendrograms using dendextend and feed them into a heatmap.2 function from gplots.您可以使用dendextend 准备您的树状图并将它们输入到热图中。来自gplots 的2 function。 Alternatively, you can look into the heatmaply package.或者,您可以查看热图 package。

Good luck.祝你好运。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM