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 keeping scale="none" as I am interested in plotting a heatmap of the actual values. However, all of my heatmaps are not centered on zero upon using the following line:
library(gplots)
outputHeatmap <- 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=FALSE, symkey=TRUE)
I thought that using the command symkey=TRUE would work, but it does not. The variable I am trying make a heatmap of is an (n x 3) matrix of numerical values. A problematic input to the heatmap.2() command described above follows:
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
Thank you for your time. I look forward to your replies.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With