This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to set value range of heatmap plotted with R?

Hello,

I have fold expression change data for three species and I want to plot a heatmap in R ggplot2 package. To compare them I want to set the range fixed for all, for example -5 to 5. Here is my script to plot

heatmap.2( pos_matrix, col = greenred(70),cexRow = 1, cexCol = 1)

If you make a suggestion I will be appreciated.

heatmap r

I'd recommend checking stackoverflow.

1 answer

Check the "breaks" parameter.

Here is a detailed explanation: http://stackoverflow.com/questions/17820143/how-to-change-heatmap-2-color-range-in-r

Thank you I saw this page however did not help. The program sets the range automatically to -3 :3 because of the max values and when I use this script and change values to see the problem , I still can't set the value between -5:5. But I will write to this website too, thank you for your reply.

This why you use "breaks" to override the automatic behavior.

breaks=seq(-5, 5, length.out=101)

Log in to answer this question.