[R] Composing a matrix for 'heatmap' from original dataset and genetic data analysis.

From: Lavrentiy <goujat_at_gmail.com>
Date: Wed 22 Feb 2006 - 09:35:38 EST


Hello.

I have following data:

doze	g1	g2	g3	g4	etc...
1200	a	d
1100	b	e
1158	c	f
1500	a	e
1403	c	f

...
etc.

Doze - numeric, levels(g1)=c('a','b','c'), levels(g2)=c('d','e','f').

This is the data of genetic analysis, where the factors are genes and the numerical is some numerical value.

I want to build up a function, which will do a preliminary data visualization based on factor levels combination and mean doze for that combination.

The best way to do it, as I think, is to build a tree which divides at the "stage 1" into the levels of factor 1, then on the "stage 2" into the levels of factor two etc. And in the end it will be mean doze for this branch. What I found was only 'ctree', this can only bifurcate, I'm not sure it fits much. What's the convenient way to visualize such kind of data in R?

I think 'heatmap' for any two factors I give to it with text mean labels
(how to add them?) would be nice solution. So that's the way I wrote
(ughly):

zar <- function(g1,g2,param='doz') {

levels(g1)->lg1
levels(g2)->lg2
table(lg1,lg2)->f
#to make a matrix for 'heatmap', is it necessary? #data labels are not preserved in this expression, badly!

for (i in lg1) {

        for (j in lg2) {          

f[i,j]<-mean(subset(mydata,as.factor(g1)==i&as.factor(g2)==j)[[param]], na.rm=T)

			}
		}

heatmap(-f, Rowv=NA, Colv=NA, margins=c(10,10),main=param) }

Please, make a hint to me for how to do this task easier and more convenient,
how to add text labels to 'heatmap'
and is this way right?

-- 
Evgeniy

______________________________________________
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
Received on Wed Feb 22 09:39:17 2006

This archive was generated by hypermail 2.1.8 : Wed 22 Feb 2006 - 17:14:22 EST