I am very new to R and recently I have been playing around with the pheatmap library to generate, well, heatmaps. My problem is that I want to color my heatmap in a specific way. I'll describe below:
- Values < 1 should be a color ramp (e.g. dark blue to light blue)
- A value exactly equal to 1 should be dark grey
- Values > 1 should be a color ramp (e.g. dark red to light red)
I have played around with the breaks
parameter and the color
parameter with various palettes but I can't seem to nail a good solution. the closest I've come is something like this:
pheatmap(mtx,
color = c('#4444FF','#F4FF4F','#FF4444'),
breaks = c(0,1,2,3),
legend_breaks = c(0,1,2) )
But this doesn't allow for visualization of the ranges, i.e. 0.1 should look a different shade than 0.9 even though they should both be blue. Can anyone provide suggestions or advice? I did look at This ticket and consider changing 1 to NA, but it's a bit too complex for me. Not to mention I'd have to turn off clustering for pheatmap which is not something I wish to do. Thanks!