Hello,
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:
Replace
image(rbind(1L:nr), col = RowSideColors[rowInd], axes = FALSE)
with
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)
locale:
[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
Regards,
Pär Engström
Postdoctoral Fellow
EMBL European Bioinformatics Institute
Wellcome Trust Genome Campus
Hinxton, Cambridge, UK
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel