I would like to create a heatmap via the heatmap.2() command with a color key that is centered on 0 (i.e. white color -> 0, red -> greater than 0, blue -> less than 0) while kee
The solution seem to be just adding symbreaks
to your heatmap.2
. Here is a fully reproducible example with your data:
library(gplots)
#read your example data
heatmapInputActual <- read.table(textConnection(
"8.408458 5.661144 0.00000000
4.620846 4.932283 -0.46570468
-4.638912 -3.471838 -0.12146109
-4.822829 -3.946024 0.06403327
3.948832 4.520447 -0.31945941
"),as.is=TRUE)
#convert sample data to matrix
heatmapInputActual <- as.matrix(heatmapInputActual)
#just add symbreaks to the end of your code
heatmap.2(heatmapInputActual, dendrogram="none", Rowv=FALSE, Colv=FALSE,
col = bluered(256), scale="none", key=TRUE, density.info="none",
trace="none", cexRow=0.125, cexCol=0.125, symm=F,symkey=T,symbreaks=T)