Color key in heatmap.2 function in R
1
0
Entering edit mode
10 months ago

The below image shows the type of the heatmap i want. As you can see the color key range in the heatmap is -3,3,9,15. How to achieve the same?

I have tried the break argument in the heatmap.2() function. But the color range keeps changing from what ever break i provide. I need the exact numbers in the color key as seen in the picture.

R • 1.6k views
2
Entering edit mode
10 months ago
Ram 32k

Consider switching to ComplexHeatmap. It eliminates a lot of the problems one faces with heatmap.2 or pheatmap or any of those complicated heatmap building packages.

0
Entering edit mode

Even in ComplexHeatmap package, when I use the

colorRamp2(c(-3,3,9,15), c(“red”,”yellow”,”green”,”blue”))


The color range is still getting divided in the heatmap automatically to 15,10,5,0,-5. I basically want to see only the values (-3,3,9,15) in the color range bar.

1
Entering edit mode

You may want to look at advanced parameters or limit the data range to your specific range by trimming all values that fall outside the range.