by Corey
~1 min read


  • articles


  • Bioinformatics
  • R

Pheatmap is an R package, which is famous for its heatmap annotation function. Standard color key profile is well-proportioned based on the value of related data frame. If we want to set different split point or uneven color range, what should we do? Here is the code:

dat <- cbind(matrix(rnorm(120), 30, 40), matrix(sample(15, 120, T), 30))
my.breaks <- c(seq(-3, 0, by=0.1), seq(0.1, 20, by=5)) 
my.colors <- c(colorRampPalette(colors = c("blue", "white"))(length(my.breaks)/2), colorRampPalette(colors = c("white", "orange", "red", "purple"))(length(my.breaks)/2))
         color = my.colors,
         breaks = my.breaks

Plus, it should be noticed that we should avoid red-green schema when it is supposed to be shown to someone else. About 8.73% of males and 1.69% of females were found to be color blind1 and will have trouble reading red-green heatmap.

  1. Ahsana S, Hussain R, Fareed M, et al. Prevalence of red-green color vision defects among Muslim males and females of Manipur, India[J]. Iranian journal of public health, 2013, 42(1): 16.