This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Extract Dendrogram Information From Heatmap Generated By Heatmap.2

Hi all,

I am having a hard time to extract the corresponding subgroup members in the heatmap generated by heatmap.2 in gplots. I have looked here: http://stackoverflow.com/questions/15388082/understanding-heatmap-dendogram-clustering-in-r and http://stackoverflow.com/questions/11489696/how-to-know-about-group-information-in-cluster-analysis-hierarchical and here https://stat.ethz.ch/pipermail/bioconductor/2007-December/020521.html

I have a matrix m, the heatmap can be generated by

heatmap.2(m, colv=FALSE, dendrogram= "row", trace="none")

it gave me very good looking heatmap, now I want to extract the subgroup members.

I know I can use hclust and cutree to extract the information:

hc.rows<- hclust(dist(m))

plot(hc.rows) # it gives me just the dendrogram, and it looks the same as the dendrogram appeared in the heatmap, only differ in the order. it seems to me the order is reversed.

I can cut the tree based on either the number of group (k), or the height (h)

ct<- cutree(hc.rows, h=10) # it gives me 6 groups

rect.hclust(hc.rows, h=10) # draw red rectangles to mark the subgroups

table(ct)

ct

1 2 3 4 5 6

196 248 294 119 42 4

I can get the labels of each row, and the assigned the group number by:

tableclust<- data.frame(m,ct)

my question is that how do I map the cluster number here back to the dendrogram? cluster 6 has 4 members, but it looks like to me cluster 6 appears in the most left of the dendrogram, cluster 5 has 42 members, it appears in the second most left (based on the width of the red rectangle in the dendrogram), cluster 4 has 119 members, but it appears not next to cluster 5....

enter image description here

I am confused.....

Thanks for your advice.

Tommy Tang

heatmap

1 answer

use svg(width=50) option. Increase it for bigger width. How To Get The Clear Values At The Bottom Of A Dendrogram In Clustering In R?

Log in to answer this question.