Making Heatmaps

From Powers Wiki
Revision as of 00:29, 22 September 2012 by Bozhang (talk | contribs)

Load the data

The data can be prepared in csv or text file to load the data in to R. For example, to load list.csv:

heatmapname <- read.csv (“list.csv”)

Name the rows

You can then name the rows of the heatmap like so:

row.names(heatmapname) <- data$Name

To exclude the first column from the heat map, use a command of similar form to the following:

heatmapname <- heatmapname [,2: n]

In the above command, n is the number of columns to be included in the heat map.

Build a data matrix

Use the following command to build a data matrix for making the heat map:

heatmapname_matrix <- data.matrix (heatmapname)

Plot the heat map

Note: Gnuplot package must be installed in R before heat maps may be displayed! Run the following command to load in the gplots library.

library("gplots")

To make heat map, run the following command:

heatmap.2 (heatmapname_matrix, dendrogram="row", col= redgreen (75), scale="none",
key = TRUE, keysize = 1.0, margins = c(4,30),
density.info="none", trace="none")

Note: To rescale the color key, add break function to the heatmap.2.

breaks=c(seq(-1,0.8,length=10),seq(0.8,1.2,length=10),seq(1.2,3,length=10),

This will define the color range:

"red=[-1,0.8]

black=[0.8,1.2]

green=[1.2,3]"