Question: Limma un moderated t-test
gravatar for chris86
2.7 years ago by
UCL, United Kingdom
chris86380 wrote:


The limma t test function is very fast compared with using the R function with a for loop for large data sets. I want to use this t test function on other data types we have that are not high throughput. So I want it to do a t test that is not moderated for these data. Does anyone know how to do this?



ADD COMMENTlink modified 2.7 years ago by Axel Klenk920 • written 2.7 years ago by chris86380
gravatar for Aaron Lun
2.7 years ago by
Aaron Lun21k
Cambridge, United Kingdom
Aaron Lun21k wrote:

If your other data sets are not high-throughput, what's the harm in running the t.test function over a couple of loops? It probably wouldn't take too long for a small number of features. Besides, empirical Bayes is more versatile than you might think. Even though it's used in limma to share information across genes, it can also be used generally, e.g., across genomic windows, TF binding sites or baseball players. So, you might consider whether you could just use the moderated t-test for your data, even if that data is lower-throughput.

With all that said, if you want to compute unmoderated t-statistics, I guess you'd do something like this:

# where 'fit' is the output from lmFit() or
unmod.t <- fit$coefficients/fit$stdev.unscaled/fit$sigma
pval <- 2*pt(-abs(unmod.t), fit$df.residual)

However, you better have a large sample size, otherwise your power to reject the null hypothesis will be low.

ADD COMMENTlink modified 2.7 years ago • written 2.7 years ago by Aaron Lun21k

Thanks, that's useful. I think the power is fine because each group has sizes 40 - 70.

ADD REPLYlink written 2.7 years ago by chris86380

Oops, forgot to multiply by 2 to make it two-sided. Also note that pval is a matrix, so you'll need to subset it by column to get the test for your coefficient of interest. For two-group setups, this should be equivalent to t.test with var.equal=TRUE.

ADD REPLYlink modified 2.7 years ago • written 2.7 years ago by Aaron Lun21k
gravatar for Axel Klenk
2.7 years ago by
Axel Klenk920
Axel Klenk920 wrote:

 Or try functions rowttests() / fastT() from package genefilter.


 - axel


ADD COMMENTlink written 2.7 years ago by Axel Klenk920

very useful, this.

I am surprised that R did not already have a 'vectorized' t.test.


ADD REPLYlink written 12 months ago by map208510
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.2.0
Traffic: 165 users visited in the last hour