gpt4 book ai didi

r - heatmap.2 颜色真的很奇怪

转载 作者:行者123 更新时间:2023-12-02 01:31:29 24 4
gpt4 key购买 nike

有谁知道为什么我的 heatmap.2 结果有奇怪的颜色——绿松石不属于我的红/黑/绿调色板?绿松石似乎是指基于样本聚类的信息(我“错误”编辑出的行树状图),而不是基于特征聚类的信息。这是怎么回事?

我正在使用 gplots、RBrewerColor 和 heatmap.2() 方法。

代码:

temp <- t(iris[,1:4])
sampleLabels.c <- as.character(iris[,5])
sampleLabels.c[sampleLabels.c=="setosa"] <- "red"
sampleLabels.c[sampleLabels.c=="versicolor"] <- "orange"
sampleLabels.c[sampleLabels.c=="virginica"] <- "green"

# Sort on max difference
t.min <-apply(temp, 1, min)
t.max <- apply(temp, 1, max)
temp <- temp[order(t.max-t.min, decreasing=TRUE),]
# cluster on correlation
hc <- hclust(as.dist(1 - cor(temp)), method="average")
png("iris.png", 1000, 1000)
par(mar=c(1,1,1,1))
heatmap.2(as.matrix(temp),
Rowv=FALSE,
Colv=as.dendrogram(hc),
dendrogram="column",
col=greenred(10),
labRow="", labCol="", key=TRUE,
ColSideColors=sampleLabels.c)
legend("left",
legend=c("Setosa", "Versicolor", "Virginica"),
col=c("red", "orange", "green"),
lty=1, lwd=2)
dev.off()

这是从代码(上面)生成的图像。

enter image description here感谢您提供任何见解!

最佳答案

?heatmap.2 中搜索“cyan”会得到:

trace=c("column","row","both","none"), tracecol="cyan" ... ...

trace: character string indicating whether a solid "trace" line should be drawn across 'row's or down 'column's, 'both' or 'none'. The distance of the line from the center of each color-cell is proportional to the size of the measurement. Defaults to 'column'.

尝试设置 trace="none" ... ?

关于r - heatmap.2 颜色真的很奇怪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34009056/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com