Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change the layout of heatmap.2 figure

Tags:

r

heatmap

We are using heatmap.2 to draw figures. With the default parameters we can get the following layout/outlook (see Figure 1).

  1. How to remove the right row names/row labels, for we have thousands of labels (see Figure 1) ?

  2. Can we draw the Color Key upwards to downwards (see Figure 2) ?

enter image description hereFigure 1

enter image description here

Figure 2

like image 959
Eman Avatar asked Jan 03 '14 10:01

Eman


2 Answers

Question 1: The row names can be removed by setting labRow = "".

Question 2: This is not possible without changing the function. heatmap.2 uses a 2 by 2 table for the layout and puts the key in the upper left cell if one is to be added. You would need to edit the function to have a 2 by 3 layout and put the key in the lower right cell, editing the display to show as indicated.

like image 191
Christopher Louden Avatar answered Sep 26 '22 06:09

Christopher Louden


Question 2. Ian gives an excellent explanation for the layout of the heatmap.2 components. You can change the layout (number of cells in a table where each element is "plotted", e.g. 2x2, 2x3, 3x2, 3x3) and the position of each of the elements of the heatmap (i.e. heatmap, row dendrogram, column dendrogram, and key).

For example:

# Define custom layout for heatmap
mylmat = rbind(c(0,3,0),c(2,1,0),c(0,4,0)) # creates 3x3 table with location of heatmap elements defined
mylwid = c(1.5,4,0.5)
mylhei = c(1.5,4,1)

# Plot your heatmap
heatmap.2(matrix.name, lmat=mylmat, lwid=mylwid, lhei=mylhei, ...)

Although you cannot change the key to be vertical versus horizontal (as far as I know!), you can position it anywhere around the heatmap and/or dendrograms.

like image 30
Keith W. Larson Avatar answered Sep 22 '22 06:09

Keith W. Larson