Eman
Eman

Reputation: 295

Change the layout of heatmap.2 figure

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 here Figure 1

enter image description here

Figure 2

Upvotes: 6

Views: 12541

Answers (2)

Keith W. Larson
Keith W. Larson

Reputation: 1573

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.

Upvotes: 3

Christopher Louden
Christopher Louden

Reputation: 7582

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.

Upvotes: 6

Related Questions