有没有一种方法可以使用heatmaply包中使用的树状图聚类方法,并将其应用于pheatmap包生成的热图?基本上与这里提出的问题相反:Clustering in pheatmap and heatmaply R packages
当我在pheatmap上使用heatmaply时,我通常会看到我的数据集群效果更好。但是,我并不总是希望使用交互式绘图。对于我来说,heatmaply::ggheatmap函数不能正常工作,因为我有col_side_colors,并且注释妨碍了树状图。它看起来就是很乱。所以我改用pheatmap。
也许有人能帮我回答我的问题。谢谢!
发布于 2020-07-16 07:05:45
library(pheatmap)
library(heatmaply)
library(seriation)
library(dendextend)
# A dataset
x <- scale(mtcars)
# Interactive heatmap
p <- heatmaply(x)
print(p)
# The dendrogram for rows
dst <- dist(x)
hc_row <- hclust(dst)
row_dend <- as.dendrogram(hc_row)
row_dend <- seriate_dendrogram(row_dend, dst, method="OLO")
# The dendrogram for columns
dst <- dist(t(x))
hc_row <- hclust(dst)
col_dend <- as.dendrogram(hc_row)
col_dend <- seriate_dendrogram(col_dend, dst, method="OLO")
col_dend <- rotate(col_dend, order = rev(labels(dst)[get_order(as.hclust(col_dend))]))
# The pheatmap with the same clustering of heatmaply
pheatmap(x, cluster_rows=as.hclust(row_dend), cluster_cols=as.hclust(col_dend))heatmaply的输出

和pheatmap的输出

https://stackoverflow.com/questions/62915975
复制相似问题