首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在pheatmap中使用heatmaply树状图排序

在pheatmap中使用heatmaply树状图排序
EN

Stack Overflow用户
提问于 2020-07-15 21:27:08
回答 1查看 300关注 0票数 1

有没有一种方法可以使用heatmaply包中使用的树状图聚类方法,并将其应用于pheatmap包生成的热图?基本上与这里提出的问题相反:Clustering in pheatmap and heatmaply R packages

当我在pheatmap上使用heatmaply时,我通常会看到我的数据集群效果更好。但是,我并不总是希望使用交互式绘图。对于我来说,heatmaply::ggheatmap函数不能正常工作,因为我有col_side_colors,并且注释妨碍了树状图。它看起来就是很乱。所以我改用pheatmap

也许有人能帮我回答我的问题。谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-07-16 07:05:45

代码语言:javascript
复制
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的输出

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62915975

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档