我正在使用heatmap.2来热映射我的数据。我的数据由数值介于70和100之间的矩阵组成(表示样本之间的相似性),我想定义没有渐变颜色的清除障碍。
library(gplots)
library(RColorBrewer)
#defining my colors
mypal <- brewer.pal(n = 6, name = "Spectral")
#defining the breaks as per ?heatmap.2
breaks <- c(0,75.0,78.5,82.0,86.5,94.5,100)
heatmap.2(m,
Rowv=TRUE,
Colv="Rowv",
density.info="histogram",
trace="none",
labCol=FALSE,
labRow=FALSE,
key.title=NA,
key.ylab=NA,
keysize=2,
col=mypal,
breaks=breaks,
dendrogram="row")
我用三个不同的输入矩阵做了这个,每次省略其中一个断点。我无法弄清楚为什么。这是一张图片:
http://s29.postimg.org/j3561w3uv/Keys.png
我为六个类定义了6种颜色,但忽略了一种颜色。前三次休息看似大小相同(他们不应该这样)。此外,直方图不遵循关键图表中的颜色中断,并且x轴缩放始终不同。
我在哪里失败?
谢谢!
这是一个从我的数据中获得的随机子矩阵:
structure(c(100, 96.7, 95.8, 94.8, 95.9, 94.3, 93.6, 94, 93.1,
91.9, 93.7, 91.8, 92, 91, 96.7, 100, 97.3, 95.6, 97.7, 95, 93.4,
94.2, 93.3, 92.5, 93.2, 91.3, 92.3, 91.3, 95.8, 97.3, 100, 95.2,
97, 94, 92, 92.6, 91.7, 90.8, 93, 91.2, 91.8, 91.3, 94.8, 95.6,
95.2, 100, 95.9, 95, 91.5, 92.2, 91.8, 90.9, 93.9, 92.3, 93.4,
92.7, 95.9, 97.7, 97, 95.9, 100, 95.4, 92.6, 93.7, 92.1, 92.1,
92.8, 91.1, 91.8, 91.4, 94.3, 95, 94, 95, 95.4, 100, 91.4, 92.2,
92.1, 91.3, 92.9, 91.2, 92.1, 91.5, 93.6, 93.4, 92, 91.5, 92.6,
91.4, 100, 97.1, 95.8, 94.5, 90.8, 89.3, 90.5, 90.7, 94, 94.2,
92.6, 92.2, 93.7, 92.2, 97.1, 100, 96, 94.3, 91.9, 90.6, 91.7,
92.2, 93.1, 93.3, 91.7, 91.8, 92.1, 92.1, 95.8, 96, 100, 94.8,
91.5, 91.1, 90.7, 90.9, 91.9, 92.5, 90.8, 90.9, 92.1, 91.3, 94.5,
94.3, 94.8, 100, 89.4, 88.7, 89.9, 90.3, 93.7, 93.2, 93, 93.9,
92.8, 92.9, 90.8, 91.9, 91.5, 89.4, 100, 95, 94, 93.4, 91.8,
91.3, 91.2, 92.3, 91.1, 91.2, 89.3, 90.6, 91.1, 88.7, 95, 100,
92.2, 92.6, 92, 92.3, 91.8, 93.4, 91.8, 92.1, 90.5, 91.7, 90.7,
89.9, 94, 92.2, 100, 93.2, 91, 91.3, 91.3, 92.7, 91.4, 91.5,
90.7, 92.2, 90.9, 90.3, 93.4, 92.6, 93.2, 100), .Dim = c(14L,
14L), .Dimnames = list(c("A", "B", "C", "D", "E", "F", "G", "H",
"I", "J", "K", "L", "M", "N"), (c("A", "B", "C", "D", "E", "F", "G", "H",
"I", "J", "K", "L", "M", "N")))
从这一点来看,如果相关数据高于某个丰度阈值,那么关键似乎只代表一个突破。我尝试了新的任意休息:
breaks2 <- c(0,89.0,91.5,93.0,95.5,97.5,100)
png("test.png", height=1000, width=1000, res = 300, pointsize = 8)
heatmap.2(mat_data_test,
main = "SG3",
Rowv=TRUE,
Colv="Rowv",
density.info="density",
trace="none",
labCol=FALSE,
labRow=FALSE,
key.title=NA,
key.ylab=NA,
keysize=2,
col=mypal,
breaks=breaks2,
dendrogram="row")
dev.off()
再次,忽略了几个休息时间。谢谢你的帮助!