[Rd] Unexpected behaviour for RowSideColors in function heatmap

From: Pär Engström <engstrom_at_ebi.ac.uk>
Date: Tue, 28 Feb 2012 10:04:30 +0000


I have come across some unexpected behaviour of the function heatmap in the stats package. This looks like a bug to me, but I might have misunderstood something.

When calling the function in symmetric mode, the ColSideColors are plotted correctly, but RowSideColors appear in reverse order. This code (modified from the example on the help page) demonstrates the problem:

cU <- cor(USJudgeRatings)
sideCols <- rainbow(ncol(cU))
heatmap(cU, symm = TRUE, distfun = function(c) as.dist(1 - c),

       ColSideColors=sideCols, RowSideColors=sideCols)

Reversing the RowSideColors argument does not solve the problem:

heatmap(cU, symm = TRUE, distfun = function(c) as.dist(1 - c),

       ColSideColors=sideCols, RowSideColors=rev(sideCols))

I had a look at the the function code and found that this change fixes the problem:


       image(rbind(1L:nr), col = RowSideColors[rowInd], axes = FALSE)


       image(rbind(if(revC) nr:1L else 1L:nr), col = RowSideColors[rowInd], axes = FALSE)

I am using the current version of R for Mac OS X:

> sessionInfo()

R version 2.14.1 (2011-12-22)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets methods base


Pär Engström

Postdoctoral Fellow
EMBL European Bioinformatics Institute
Wellcome Trust Genome Campus
Hinxton, Cambridge, UK

        [[alternative HTML version deleted]]

R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Tue 28 Feb 2012 - 12:35:33 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 08 Mar 2012 - 22:30:25 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive