[R] Row-wise two sample T-test on subsets of a matrix
Stefano Calza
stef at biostatistics.it
Thu Mar 1 20:21:16 CET 2007
I'd suggest to use the function mt.teststat in the package multtest or rowttests in the package genefilter. Both can be found athe the bioconductor webpage (www.bioconductor.org)
Stef
On Thu, Mar 01, 2007 at 12:48:29PM -0600, Ranjan Maitra wrote:
<Ranjan>Here's one suggestion: convert the matrix into a three-dimensional array and use apply on it.
<Ranjan>
<Ranjan>Ranjan
<Ranjan>
<Ranjan>On Thu, 1 Mar 2007 11:51:29 -0600 (CST) Nameeta Lobo <nlobo a uchicago.edu> wrote:
<Ranjan>
<Ranjan>> Hello all,
<Ranjan>>
<Ranjan>> I am trying to run a two sample t-test on a matrix which is a
<Ranjan>> 196002*22 matrix. I want to run the t-test, row-wise, with the
<Ranjan>> first 11 columns being a part of the first group and columns
<Ranjan>> 12-22 being a part of the second group.
<Ranjan>>
<Ranjan>> I tried running something like (temp.matrix being my 196002*22
<Ranjan>> matrix)
<Ranjan>>
<Ranjan>> t.test(temp.matrix[,1:11],temp.matrix[,12:22],paired=TRUE)
<Ranjan>>
<Ranjan>> or somthing like
<Ranjan>>
<Ranjan>> as.numeric(t.test(temp.matrix[,1:11],temp.matrix[,12:22],paired=TRUE)[[1]])
<Ranjan>> so as to only capture the t-value alone and
<Ranjan>>
<Ranjan>> and I get a result for the whole matrix instead of a row-wise
<Ranjan>> result.
<Ranjan>>
<Ranjan>> I want to avoid using a "for" loop to increment the number of
<Ranjan>> rows as it would take a huge amount of time.
<Ranjan>>
<Ranjan>>
<Ranjan>> Any suggestions would be really appreciated.
<Ranjan>>
<Ranjan>> thanks
<Ranjan>> nameeta
<Ranjan>>
<Ranjan>> ______________________________________________
<Ranjan>> R-help a stat.math.ethz.ch mailing list
<Ranjan>> https://stat.ethz.ch/mailman/listinfo/r-help
<Ranjan>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
<Ranjan>> and provide commented, minimal, self-contained, reproducible code.
<Ranjan>>
<Ranjan>
<Ranjan>______________________________________________
<Ranjan>R-help a stat.math.ethz.ch mailing list
<Ranjan>https://stat.ethz.ch/mailman/listinfo/r-help
<Ranjan>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
<Ranjan>and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list