简体   繁体   中英

Using a Pre-Made Dendrogram to Order Samples in Heatmap3 in R

I'm trying to use heatmap3 to visualize my bacterial community data. I have already clustered my samples, and have a dendrogram from hclust that I want to use to order my samples in the heatmap, while showing the dendrogram as well. However, the data file that I am putting into heatmap3 has been collapsed to the genera level, so the structure that I had before isn't immediately apparent to heatmap3, and I therefore don't want heatmap3 to try to do its own clustering.

I've tried using my hclust object as a dendrogram and passing it to Colv, but the order of the samples in my heatmap, for whatever reason, becomes literally random while the dendrogram looks correct. When I extract the order of samples in my dendrogram and re-order my input matrix according to this order (without a dendrogram), I get visible clustering. Essentially what I want is to give heatmap my dendrogram that I made from an hclust function, and have it order the samples in that order WITH the dendrogram above, and then plot the relative abundances in the heatmap. What am I missing?

Unfortunately I don't have data that I'm able to provide, or an illustrative example. If this question is impossible to answer without data and R code, I will do my best to put something together.

您可以尝试使用pheatmap包,其中的参数cluster_rowscluster_cols接受hclust对象。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM