Monthly Archives: July 2016

An example script of creating a heatmap using the heatmap.2 function in R

 

# Just copy all below into R to test

# Notes: the styles of “double quotes” when copied may change and make the script not run normally, but you can manually change the “double quotes”.

rm(list=ls())
require(gplots)
X=matrix(rnorm(120),nrow=20)
breaks = 20 # number of colors
my_palette <- colorRampPalette(c(“green”,”red”))(n =breaks-1) # self-define and discretize color maps
heatmap.2(X,Colv = NA,col=my_palette,breaks = breaks,density.info=”none”,trace = “none”,scale=”none”)