[英]R - How to turn off reorder function in heatmap.2 when plot dendrogram
I was trying to use heatmap.2 to plot a double dendrogram with a heatmap. 我试图使用heatmap.2绘制带有热图的双树状图。 I have two pre-made dendrograms, which i fed them into Rowv = dend_row and Colv = dend_col. 我有两个预制的树状图,我将它们分别放入Rowv = dend_row和Colv = dend_col。 The issue is the dendrogram is also reordered. 问题是树状图也已重新排序。 I learnt from the package that in heatmap.2, if a dendrogram is fed in Rowv / Colv, then it is used "as-is", ie without any reordering. 我从软件包中了解到,在heatmap.2中,如果将树状图以Rowv / Colv的形式进行馈送,那么它将按“原样”使用,即不进行任何重新排序。 So I make sure that the objects fed into the Rowv / Colv are already dendrograms (by using as.dendrogram), the dendrogram still reordered. 因此,我确保馈入Rowv / Colv的对象已经是树状图(通过使用as.dendrogram),树状图仍会重新排序。
env.hc2 <- env %>% dist(method = 'euclidean') %>%
hclust(method = 'ward.D') %>% as.dendrogram %>% ladderize %>%
color_branches(k=4)
female.hc2 <- female %>% as.dist(female) %>% hclust(method = 'com') %>%
as.dendrogram %>% ladderize %>%
color_branches(k=4)
heatmap.2(female_env_matrix,
main = paste("test"),
trace="none",
margins =c(5, 6),
col= my_palette,
breaks=col_breaks,
dendrogram ='both',
Rowv = female.hc2,
Colv = env.hc2,
key.xlab = "GY",
cexRow = 0.6,
cexCol = 0.8,
na.rm = TRUE
)
Desire output: 需求输出:
弄清楚我需要重新采样数据框以创建树状图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.