Hi Kevin,

thanks a lot for the advices. The first suggestion worked, overall, I have to find a way to scale the names/numbers on the interval considered. But it was the good way to look at the problem. The second suggestion didn't really work. It is not a problem of custom fitting, it is more where in the plot, zero is centered.
If I say

abline(v=0)

it produces a vertical line much more right on the x axis than the actual 0. It is a problem of where the axis of the plots are set and they don't seem to match the layout of the heatmap. Any suggestion on this?

Moreno

Quoting "Kevin J. Thompson" <[EMAIL PROTECTED]>:



    would this work for you?

cl2=c(rep('',4500))
for (i in seq(500,4500,by=500)){
+ cl2[i]=as.character(i)}

heatmap(x, labCol=cl2)

  you might have to custom fit the lines

d=seq(.2,.8,by=.1)
abline(v=d)

hope it helps,
kt

----- Original Message -----
From: Moreno Ignazio Coco <[EMAIL PROTECTED]>
Date: Wednesday, May 28, 2008 12:55 pm
Subject: [R] heatmap-changing column or row names

Dear R Community,

I am trying to create an heatmap for the following set of data:

##example of data matrix
o4
       V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16 V17 V18
green  27 28 29 29 28 28 26 25 25  23  23  22  22  21  21  22  22  22
yellow  6  8  8  7  7  7  6  6  6   7   7   7   6   6   6   6   6
5
red    15 15 15 15 15 15 14 13 12  11  12  10   9   8   7   6   8
9
pink   11 11 11 11 11 10 12 11 13  14  14  15  15  14  14  17  17  17
blue   17 15 15 16 17 17 17 17 18  18  18  19  20  20  20  21  22  21

the column names are timepoints 450 in total. When I run the
heatmap code:

x  <- as.matrix(o4)
ramp <- colorRamp(c("yellow","green","blue"))
cv<-rgb( ramp(seq(0, 1, length = 83)), max = 255)

heatmap(x, col = cv, Colv=NA, Rowv=NA,xaxt="n", yaxt="n",
scale="column", margins=c(5,10), labCol=NA,xlab = "Time", ylab=
"Colors",main = "")

I have quite few problems to change the column names. Being 450
timepoints too many to be readable on the plot, I wanted to
reduce/scale them to, let say 45. So, as you can see from the code

above, I have removed the x and y, row and column information.
Then I have tried to create a new name vector:

##create col vector to add names

Colname<-as.character(seq(0,4500,500))

##putting it as arguments of (labCol=Colname, in the heatmap function)

but this solution didn't work. It looks like as it cannot find the

exact point on the axis where to stick the label in and it
clutters
all the datapoint on the same spot without being able to unfold it.

Therefore I have tried to introduce an axis:

axis(1, at=seq(0,450,1),line=1)

and then adding some text on top

mtext(paste(seq(0,4500, 250),sep=""),side=1,
at=seq(0,450,25),line=2,cex=0.6,las=1)

also this way didn't work out. Actually, it has created a kind of
axis
but the zero of it was aligned to the middle of the plot. So, it
was
completely shifted.
That was my first problem.

Second small problem.
I am trying to mark on the heatmap some crucial timepoints. I
wanted
to do it by adding a straight abline on the heatmap plot

abline(v=80,col=green)

but also this doesn't seem to have any result
It seems that it is quite difficult to add any information to the
heatmap, but perhaps some of you might know how to do it.

Many thanks in advance

Moreno




--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-
guide.htmland provide commented, minimal, self-contained,
reproducible code.






--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

______________________________________________
[email protected] 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.

Reply via email to