Ages ago I wrote a blogpost on heatmaps in R, but that was focussing mainly on clustering and dendrograms.
This week I wanted to draw a simple heatmap and found nice tutorial here.
My input data looks something like this (in file 'mydata'):
To make a heatmap I did this:
> data <- read.csv("mydata")
> rnames <- data[,1]
> mat_data <- data.matrix(data[,2:ncol(data)])
> rownames(mat_data) <- rnames
> my_palette <- colorRampPalette(c("red", "yellow", "green"))(n = 299)
> heatmap.2(mat_data,trace="none",col=my_palette, dendrogram="none", margins=c(12,9))
This gives a nice heatmap like this: