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?
Asked
Active
Viewed 5,218 times
1
2 Answers
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
-
the change to the layout is not in the help function. – Brian Wiley Sep 30 '20 at 14:19
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