From jorismeys at gmail.com  Wed Nov 25 17:15:10 2009
From: jorismeys at gmail.com (jorismeys at gmail.com)
Date: Wed, 25 Nov 2009 17:15:10 +0100 (CET)
Subject: [Rd] heatmap.2 gives wrong colorkey with unequally spaced breaks
	(PR#14085)
Message-ID: <20091125161510.2EBC12831FFF@mail.pubhealth.ku.dk>

Full_Name: Joris FA Meys
Version: 2.10.0
OS: Windows XP
Submission from: (NULL) (157.193.194.73)


I use the enhanced heatmap function in gplots : heatmap.2

For the presentation of the color key, the code is not 100% adequate. More
specifically, in case you define unequally spaced breaks :

1) the keyplot ignores the minimum and maximum of these breaks.

Code changed in line 323 and 324 to :
            min.raw <- min(c(x,breaks), na.rm = TRUE)
            max.raw <- max(c(x,breaks), na.rm = TRUE)

2) the keyplot gives the histogram with the correct breaks, but the colors
remain equally spaced. This is due to the lack of a specification for x in the
call to the image() function. 

Code changed in line 327-328 to :
        image(x=breaks,z = matrix(z, ncol = 1), col = col, breaks = tmpbreaks,
            xaxt = "n", yaxt = "n")

Line numbers obtained by copy-pasting code from console into Tinn-R. The changed
code is how I adapted the function in order to get the desired result. Don't
know if it's error-proof, but it works for me.

Cheers
Joris



[Rd] heatmap.2 gives wrong colorkey with unequally spaced breaks (PR#14085)
jorismeys at gmail.com