[R] Calculate t.test for a matrix

David Winsemius dwinsemius at comcast.net
Sat Apr 14 21:44:09 CEST 2012


On Apr 14, 2012, at 11:40 AM, Junyu Lee wrote:

> Hello everyone,
>
> I have a data frame (tt), see below (I only show 2 genes, actually I  
> have a
> lot):

Shouldn't you be working with a statistician to get advice about how  
to handle the multiple comparison issues you are most certainly facing?

-- 
David.


>
>  group                    gene1       gene2  Control 28.9776 9.9355
> Control 28.9499 10.0997  Control 29.5468 14.2995  Control 29.5246  
> 13.9561
> Test1 29.1864 9.7718  Test1 29.2048 10.0388  Test1 34.9563 11.9509   
> Test1
> 34.9464 11.8909  Test2 36.9566 14.5316  Test2 37.1309 14.5188  Test2  
> 36.1017
> 29.5468  Test2 36.0883 29.5246
> I'd like to calculate p values: Test1 vs Control and  Test2 vs Control
> respectively for Gene1. Similar calculate performed for Gene2.
>
> I tried:
>
> sapply(levels(fac), function(x) t.test(tt1$gene1,
> tt$gene1[which(fac==x)])$p.value)  # I don't really understand how it
> works, I copied from genefilter.
>
> where: fac=as.factor(tt$group)
>
> It seemed to work for first column.  I don't know how to use apply()  
> to
> make it work on rest of column because I used tt$gene1 specifically.  
> Or
> whatever method that works
>
> Thank you in advance.
>
> Junyu
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org 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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list