This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Extracting ids of a cluster in heatmap

Hi everyone,

Sorry for a quite basic question regarding RNAseq analysis.

For the log-transformed FPKM values which made from Cuffdiff output, I have created a gene expression heatmap by pheatmap package in R. Those genes in rows are hierarchical clustered by pheatmap (clustering_distance_rows = "euclidean") to form a dendrogram structure. I wonder that how could I get hundreds of gene ids belonged to an interested branch (that is too many to be possibly read from row names) ? Does pheatmap offer this feature or should I use another R package to get those ids? Please give me suggestion and detail explanation if possible.

Thank you very much.

pheatmap heatmap rnaseq

2 answers

You can extract the genes in the clustered order if you save the pheatmap object.

map = pheatmap(x, ... )
x[map$tree_row$order,]

thanks a lot, however if I cluster with kmean, does it still work?

map <- pheatmap(x, kmean-k= 50, ... )

You can create your own dendrograms, using the hclust function, give this output to pheatmap to make heatmap (cluster_rows option ) . Then cut the clusters of your dendrogram using the cutree function in R to get a vector that tells you which entry belongs to which cluster.

thank you for your suggestion!

Log in to answer this question.