简体   繁体   中英

How to change position of rowsidecolors in R heatmap.2

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?

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)
)

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM