[R] lines() in heatmap()

Paul Murrell p.murrell at auckland.ac.nz
Mon Jan 23 20:33:39 CET 2006


Hi


kaoskrew.de wrote:
> Hello!
> 
> I looked for help through google and the help-files and spend several 
> hours with trial and
> error, but didn't find a correct way.
> 
> It's all about lines in a heatmap to separate different data block from 
> each other to underline
> the significance of the found clusters!
> 
> The heatmap is build like that:
> 
> heatmap(X, Rowv=NA, Colv=NA, symm=TRUE, cexRow=0.3, cexCol=0.3)
> 
> I switched the dendrograms off, because I don't want the values sorted 
> but in the way, I
> extracted them from the data.
> 
> I tried to enter the lines that way:
> 
> lines(c(14,14),c(0,187), col="green")
> 
> That should appear as a line parallel to the x-axis, but there was no 
> line at all.
> I also tried several other ways, which didn't work at all. (The Matrix 
> contains
> 187 values and is symmetric)


Take a look at the 'add.expr' argument to heatmap.  Here's a simple example:

x  <- as.matrix(mtcars)
rc <- rainbow(nrow(x), start=0, end=.3)
cc <- rainbow(ncol(x), start=0, end=.3)
hv <- heatmap(x, col = cm.colors(256), scale="column",
               RowSideColors = rc, ColSideColors = cc, margin=c(5,10),
               xlab = "specification variables", ylab= "Car Models",
               main = "heatmap(<Mtcars data>, ..., scale = \"column\")",
               # IMPORTANT BIT HERE
               add.expr = abline(h=5, v=2))

Paul


> Also the line should start and end at the borders of the heatmap, so if 
> there is
> a parameter to enter that, I would be glad, if you add it.
> 
> Another short question:
> Does anybody have an idea, how I could switch the names of my data from 
> the heatmaps
> right side to it's left side?
> 
> 
> Thanks for help already,
> Tobias Zimmer
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul at stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/




More information about the R-help mailing list