View Single Post
Old 07-25-2013, 06:22 AM   #1
crazyhottommy
Senior Member
 
Location: Gainesville

Join Date: Apr 2012
Posts: 140
Default extract dendrogram information from heatmap generated by heatmap.2

I asked the same question in Biostar, try my luck here:

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/1...lustering-in-r and http://stackoverflow.com/questions/1...s-hierarchical and here https://stat.ethz.ch/pipermail/bioco...er/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....

http://i43.tinypic.com/2hhktw9.png

I am confused.....

Thanks for your advice.

Tommy Tang
crazyhottommy is offline   Reply With Quote