I would like to make an heatmap in R using pheatmap with the colors green, black and red and using a range in the legend from -2 to 2, here is the code that I used:
library(pheatmap)
my_palette <- colorRampPalette(c("green", "black", "red"))(n = 201)
colors = c(seq(as.numeric(-2),-0.01,length=100), 0,
seq(0.01,as.numeric(2),length=100))
pheatmap(mFilt_annot_sort_matrix, color = my_palette, breaks = colors, scale =
"none", cluster_rows = F, cluster_cols = F, margin = c(5,5))
The problem is that I would like the values less than -2 in green an greater than 2 in red while with my solution these values are white, could you help me?