我正在使用 R 生成热图。
我使用了该hclust
函数并得到了错误:
Colv dendrogram doesn't match size of x
。
下面是我的代码,它与方阵完美配合。现在我的输入矩阵是400x2000
. 有人可以告诉我为什么会收到此错误吗?
data <- read.table("mydata.txt",sep="\t",header=TRUE,row.names=1)
data_matrix <- data.matrix(data)
library(gplots)
library("RColorBrewer")
colors <- colorRampPalette(rev(brewer.pal(9, "Blues")) )(255)
hc_dist= dist(data_matrix)
hc_clust= hclust(hc_dist)
hr_dist= dist(t(data_matrix))
hr_clust= hclust(hr_dist)
heatmap.2(data_matrix, col=brewer.pal(11,"RdBu"), labRow=NA, density.info="none", scale="row",trace="none",Colv=as.dendrogram(hc_clust), Rowv=as.dendrogram(hr_clust))
Error in heatmap.2(data_matrix, col = brewer.pal(11, "RdBu"), labRow = NA,:Colv dendrogram doesn't match size of x