Is there a way to change the color key scale so that values are binned by quantity? For example I have 15 values going from 0-1, and only a few values going from 1 to less than 8. But because my range is 0-8 the scale is so off and a huge chunk of my colours are stuck on the left end of the scale whereas most of it remains red. See image.
Here is my dataset used to generate the heatmap below. It is saved to a CSV file.
GeneID Habitat1 Habitat2 Habitat3 Control
Gene1 0.135 0.248 0.143 0.272
Gene2 0.16 0.455 0.233 0.602
Gene3 0.152 0.08 0.15 0.62
Gene4 4.86 2.93 6.035 3.56
Gene5 0 2.993 4.464 0.356
Gene6 0.071 3.805 6.82 0.587
Gene7 0.46 2.828 3.097 6.45
Gene8 0.92 3.901 3.042 5.58
Here is my R code:
x <- read.csv("heatmapvals_generated.csv", header=TRUE, row.names="GeneID") #snippet from a much larger dataset to create the mini heatmap image, but the number ranges are about the same. Mostly from 0-1 and then a few >1.
y <- data.matrix(x)
colors = c(seq(0,0.018,length=5),
seq(0.019,0.98,length=50),
seq(0.99,1.098,length=5),
seq(1.099,3,length=20),
seq(3.099,8,length=20))
my_palette <- colorRampPalette(c("navy","blue","grey","red","darkred"))(n=99)
hm2 <- heatmap.2(y, col=my_palette, trace="none", breaks=colors, margins=c(10,15),
scale="none", dendrogram = "none",
Colv=F, Rowv=F, cexRow = 1, cexCol=1.2, density.info="none")
I am not sure where I can change the color key scale so that it reads 0-1 and 1-8 equally, and the white (which is value 1) is centered. The actual heatmap is fine.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…