How to extract the components of a cluster after pheatmap
0
0
Entering edit mode
7 months ago
Luiza • 0

Hello everyone. I'm sorry if my question looks dumb, I'm new to R.

I used this code to make a heatmap with differentialy expressed genes:

heatmap <- pheatmap(zscore,
     cluster_rows = T,
     cluster_cols = T,
     clustering_distance_rows = "euclidean",
     clustering_distance_cols = "euclidean",
     cutree_rows = 5,
     cutree_cols = 3,
     fontsize_col = 10,
     fontsize_row = 0.5,
     col = brewer.pal(10, "RdYlGn"),
     )

I did the cutree_rows in 5 because I saw 5 interesting clusters. Now, I want to grab the elements of each row cluster. Then I tried to use cutree because I saw on this forum someone using it.

heatmap_clust <- cbind(zscore, 
                  cluster = cutree(heatmap$tree_row, 
                                   k = 5))

I seem to be doing something wrong, since the output is not the same as the row names in the graph (specially, the clusters are out of order -- e.g. cluster number 4 on the spreadsheet is not the 4th cluster to appear on the image). Can someone please elucidate what is wrong and what should I do? Thank you!

Heatmap Export Cluster • 393 views
ADD COMMENT

Login before adding your answer.

Traffic: 4569 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6