Making Heatmaps: Difference between revisions

From Powers Wiki
(Created page with "==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'': data <- read.csv (“list.csv”) ==Name the row...")
 
No edit summary
Line 15: Line 15:
In the above command, '''n''' is the number of columns to be included in the heat map.
In the above command, '''n''' is the number of columns to be included in the heat map.


==To change the loaded data in to data matrix==
==Build a data matrix==
===Type: Data_matrix <- data.matrix (data)===
Use the following command to build a data matrix for making the heat map:
==To use gnuplot library==
 
  Note: Gnuplot package must be installed in R.
Data_matrix <- data.matrix (data)
===Type:library("gplots")===
 
==To make heat map==
==Plot the heat map==
===Type: heatmap.2 (Data_matrix, dendrogram="row", col= redgreen (75), scale="none", key = TRUE, keysize = 1.0, margins = c(4,30),  density.info="none", trace="none")===
'''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 (Data_matrix, dendrogram="row", col= redgreen (75), scale="none", key = TRUE, keysize = 1.0, margins = c(4,30),  density.info="none", trace="none")
 
[[Category:Protocols]]

Revision as of 02:48, 16 August 2012

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:

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

Name the rows

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

Row.names(data) <- data$Name

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

Type:Data <- data [,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:

Data_matrix <- data.matrix (data)

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 (Data_matrix, dendrogram="row", col= redgreen (75), scale="none", key = TRUE, keysize = 1.0, margins = c(4,30),  density.info="none", trace="none")