R热图.2(gplots)访问密度图数据

R热图.2(gplots)访问密度图数据,r,heatmap,dendrogram,inspection,R,Heatmap,Dendrogram,Inspection,在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 有没有办法知道属于第一个分支的列的索引 那些属于第二个的(以自动的方式;当然是以这种

在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轴上的标签)

此外,如何访问其他分支?

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

对于问题中提出的具体案例,这是如何访问柱状树状图的:

colhclust = as.hclust(h$colDendrogram)
groups = cutree(cl,2)
groups是包含每列的组的向量

id_g1 = which(groups == 1)
包含属于第一个分支的项的索引