1

When using the R heatmap.2 function from the gplots package, one can pass the argument rowsidecolors, which will then insert a column next to the dendrogram as shown here. I was wondering if it is possible to relocate the column to the opposite side of the heatmap next to the row labels?

Arun
  • 116,683
  • 26
  • 284
  • 387
2scoops
  • 11
  • 1
  • 3

2 Answers2

2

Read "help(heatmap.2)" about what happens to the 4 plot components when "RowSideColors" is used. See Moving color key in R heatmap.2 (function of gplots package) for a good explanation of how to control their locations.

Try this:

heatmap.2 ( 
    matrix(rnorm(100), 10, 10),
    lmat=rbind(c(0,5,4,0,0), c(0,3,2,1,0)), 
    lhei=c(2,5),
    lwid=c(1,1,4,0.25,1),
    col=colorpanel(20, "blue", "black", "red"),
    key = F, trace = "none", scale = "row",
    RowSideColors = rainbow(10)
)
Community
  • 1
  • 1
Ben Ernest
  • 445
  • 3
  • 14
2

This is about as close as you are going to get to default:

lmat=rbind(c(5,0,4), c(3,1,2))
lhei=c(1.5,4)
lwid=c(1.5,0.25,4)

New numbering is:

2. Heatmap,

3. Row dendrogram,

4. Column dendrogram,

5. Key,

1. Horizontal Bar

The maintainers should have kept the same numbers and just add 5. for the Horizontal bar but hey let's make it more confusing for fun :) Basically they put it in a 'queue' LIFO. Set horizontal bar to 1 and move every thing else down 1.

Brian Wiley
  • 485
  • 2
  • 11
  • 21