【问题标题】:R heatmap.2 (gplots) access dendogram dataR heatmap.2 (gplots) 访问树状图数据
【发布时间】:2014-01-29 05:22:47
【问题描述】:

在 R 中,我使用 heatmap.2(来自 gplots 包)对一些数据进行聚类和可视化。

我想访问列树状图(集群)以进一步处理我的数据。

例如:

x = matrix(runif(250), nrow= 50) h = heatmap.2(x)

h$colDendrogram 
'dendrogram' with 2 branches and 5 members total, at height 3.033438

有没有办法知道属于第一个分支的列的索引 以及属于第二个的那些(以自动的方式;当然以这种简单的方式 情况下我可能只看 x 轴上的标签)。

进一步如何访问其他子分支?

【问题讨论】:

    标签: r heatmap dendrogram inspection


    【解决方案1】:

    可以使用 as.hclust() 函数并将生成的对象视为 R hclust 对象。

    对于问题中提出的具体情况,这是访问列树状图的方式:

    colhclust = as.hclust(h$colDendrogram)
    groups = cutree(cl,2)
    

    groups 是包含每一列的组的向量;

    id_g1 = which(groups == 1)
    

    包含属于第一个分支的项目的索引。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-09
      • 1970-01-01
      • 2014-09-15
      • 1970-01-01
      • 2013-11-19
      • 1970-01-01
      相关资源
      最近更新 更多