因此,我试图使用Bioconductor的ComplexHeatmap包为我的数据生成热图,但我得到的结果略有不同,这取决于我是自己制作树状图,还是让热图制作它。
包:
require(ComplexHeatmap)
require(dendextend)数据:
a=rnorm(400,1)
b=as.matrix(a)
dim(b)=c(80,5)如果我自己做树状图:
d=dist(b,method="euclidean")
d=as.dist(d)
h=hclust(d,method="ward.D")
dend=as.dendrogram(h)
Heatmap(b,
cluster_columns=FALSE,
cluster_rows = dend)与使用Heatmap进行群集相比:
Heatmap(b,
cluster_columns=FALSE,
clustering_distance_rows = "euclidean",
clustering_method_rows = "ward.D") 它们看起来非常相似,但它们会略有不同。
这对我的数据很重要。Heatmap的聚类最终以更好的方式组织我的数据,然而,我也想通过像cutree()这样的方法来提取聚类项目的列表,但我不认为我可以从Heatmap的聚类中提取它。
有人知道这是怎么回事吗?
发布于 2018-08-19 21:18:38
树状图是一样的。唯一变化的是顺序。您可以使用以下命令进行验证:
hmap1 <- Heatmap(b,
cluster_columns=FALSE,
cluster_rows = dend)
hmap2 <- Heatmap(b,
cluster_columns=FALSE,
clustering_distance_rows = "euclidean",
clustering_method_rows = "ward.D")
#Reorder both row dendrograms using the same weights:
rowdend1 <- reorder(row_dend(hmap1)[[1]], 1:80)
rowdend2 <- reorder(row_dend(hmap2)[[1]], 1:80)
#check that they are identical:
identical( rowdend1, rowdend2)
## [1] TRUEComplexHeatmap::Heatmap函数有一个参数row_dend_reorder,其默认值为TRUE,您应该检查该参数。
https://stackoverflow.com/questions/50829127
复制相似问题