Re: [R] heatmap color specification

2007-02-12 Thread Xiaohui
Jim Lemon wrote:
 Xiaohui wrote:
 ... Then, I did a heatmap for 'test' matrix. But for now, I want to 
 specify each of the cell in the heatmap according to the values of 
 the corresponding matrix elements of test.

 Let's say: col-c(red,yellow,green)

 for test[1,1], the color on the map should be red.

 I have tried par('usr') and par('mar') with rect function. But this 
 does not work because the rect shift from the original map. Could any 
 one tell me how to fill the cells on the map with corresponding 
 values? Or can we get the actual coordinates of the image excluding 
 the dendregram.
 Hi Xiaohui,
 You may be looking for something like color2D.matplot in the plotrix 
 package or image in the graphics package.

 Jim

Thanks, Jim. I found this problem can be solve with the 'scale' 
parameter specified to FALSE. If it is TRUE, then the positive integer 
is scale to a real number which will cause the problem earlier.

Xiaohui

__
R-help@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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] heatmap color specification

2007-02-10 Thread Jim Lemon
Xiaohui wrote:
... 
 Then, I did a heatmap for 'test' matrix. But for now, I want to specify 
 each of the cell in the heatmap according to the values of the 
 corresponding matrix elements of test.
 
 Let's say: col-c(red,yellow,green)
 
 for test[1,1], the color on the map should be red.
 
 I have tried par('usr') and par('mar') with rect function. But this does 
 not work because the rect shift from the original map. Could any one 
 tell me how to fill the cells on the map with corresponding values? Or 
 can we get the actual coordinates of the image excluding the dendregram. 

Hi Xiaohui,
You may be looking for something like color2D.matplot in the plotrix 
package or image in the graphics package.

Jim

__
R-help@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
and provide commented, minimal, self-contained, reproducible code.


[R] heatmap color specification

2007-02-09 Thread Xiaohui
hi,

I have a positive integer matrix like:

test-matrix(c(1,2,2,2,2,1,1,2,3),3)

and based on the distant function I made like this:

generateDistMat-function (target)
{
n - nrow(target)
rn - rownames(target)
distM - matrix(NA, n, n)
diag(distM) - 0
for (i in 1:(n - 1)) for (j in (i + 1):n) {
distM[i, j] - length(which(target[i, ] != target[j,
]))
distM[j, i] - distM[i, j]
}
colnames(distM) - rownames(distM) - rn
distM
}

dist.fun - function(M) return(as.dist(generateDistMat(M)))

Then, I did a heatmap for 'test' matrix. But for now, I want to specify 
each of the cell in the heatmap according to the values of the 
corresponding matrix elements of test.

Let's say: col-c(red,yellow,green)

for test[1,1], the color on the map should be red.

I have tried par('usr') and par('mar') with rect function. But this does 
not work because the rect shift from the original map. Could any one 
tell me how to fill the cells on the map with corresponding values? Or 
can we get the actual coordinates of the image excluding the dendregram. 
Any help would be appreciated. Thanks in advance!

Xiaohui

__
R-help@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
and provide commented, minimal, self-contained, reproducible code.


[R] Heatmap color specification

2007-02-09 Thread Xiaohui
hi,

I have a positive integer matrix like:

test-matrix(c(1,2,2,2,2,1,1,2,3),3)

and based on the distant function I made like this:

generateDistMat-function (target)
{
   n - nrow(target)
   rn - rownames(target)
   distM - matrix(NA, n, n)
   diag(distM) - 0
   for (i in 1:(n - 1)) for (j in (i + 1):n) {
   distM[i, j] - length(which(target[i, ] != target[j,
   ]))
   distM[j, i] - distM[i, j]
   }
   colnames(distM) - rownames(distM) - rn
   distM
}

dist.fun - function(M) return(as.dist(generateDistMat(M)))

Then, I did a heatmap for 'test' matrix. But for now, I want to specify 
each of the cell in the heatmap according to the values of the 
corresponding matrix elements of test.

Let's say: col-c(red,yellow,green)

for test[1,1], the color on the map should be red.

I have tried par('usr') and par('mar') with rect function. But this does 
not work because the rect shift from the original map. Could any one 
tell me how to fill the cells on the map with corresponding values? Or 
can we get the actual coordinates of the image excluding the dendregram. 
Any help would be appreciated. Thanks in advance!

Xiaohui

__
R-help@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
and provide commented, minimal, self-contained, reproducible code.