I'm looking to figure out how to use the pheatmap package and to make a continuous color coded heatmap.
I would like to use three colors, red, white and blue to for my map, where white = 0, blue is for negative numbers, and red for positive. I want it such that it would be continuous, rather than anything being 0 = white, and positive being red, but more of a transition from a solid red to lighter fades until white.
I couldnt find it in the documentation, so perhaps it is my lack of understanding on how to get it to work.
Here is my code currently.
pheatmap(heatmap_matrix,
cluster_rows = T,
cluster_cols = T,
color = c("blue", "white", "red"),
angle_col = 90)
Thank you!
CodePudding user response:
You could just supply a long vector of transitioning colours using colorRampPalette
:
set.seed(1)
heatmap_matrix <- matrix(rnorm(400), nrow = 20)
pheatmap(heatmap_matrix,
cluster_rows = T,
cluster_cols = T,
color = colorRampPalette(c("blue", "white", "red"))(100),
angle_col = 90)