Re: [R] Wilcoxon test on data matrix

From: Christophe Pallier <christophe_at_pallier.org>
Date: Thu, 14 Jun 2007 13:32:00 +0200

   wilcox.test(data.matrix[i,] ~ data.cl)$p.value

will return the p.value for row 'i'.

With a loop:

   pv = rep(0,42)
   for (i in 1:42) { pv[i]=wilcox.test(data.matrix[i,] ~ data.cl)$p.value }

Is this what you wanted?

Christophe

On 6/14/07, Booman, M <m.booman_at_path.umcg.nl> wrote:
>
> Dear everyone,
> I am trying to do a Wilcoxon one-sided test on my gene expression data.
> These are the data i have in R:
> data.matrix (matrix, numeric) containing all gene expression data (42
> rows=genes, 42 columns=tumors), no column header or row names
> data.cl (vector, numeric) consisting of 42 0's and 1's to indicate class 0
> or class 1 for each column in data.matrix
>
> I want to do a Wilcoxon one-sided test on the data from class 0 versus the
> data from class 1, for each row (gene) of the data set.
> My first try:
>
> #to make separate matrices for both classes:
> data.matrix.0 <- data.matrix[,data.cl==0]
> data.matrix.1 <- data.matrix[,data.cl==1]
>
> # to run the wilcox.test function for each row:
> rawp <- apply(data.matrix.0, 1, wilcox.test, y=data.matrix.1,
> alternative="less")
>
>
> The result of printing rawp is:
> $`1`
>
> Wilcoxon rank sum test with continuity correction
>
> data: newX[, i] and data.matrix.1
> W = 7585, p-value = 1
> alternative hypothesis: true location shift is less than 0
>
>
> $`2`
>
> Wilcoxon rank sum test with continuity correction
>
> data: newX[, i] and data.matrix.1
> W = 6700, p-value = 0.9983
> alternative hypothesis: true location shift is less than 0
>
>
> Etcetera for each row of the data matrix.
> I can get the p value for one row (gene) using:
> rawp.1 <- rawp$'1'$p.value
>
> But how can I get these p-values in one list? I have tried:
> rawp <- NULL
> for (i in 1:42) {
> a <- paste("'", i, "'", sep="")
> rawp <- rbind(rawp, test$a$p.value)
> }
>
> but that doesn't work (no errors but rawp stays NULL)
>
> There must be an easier way to do a wilcoxon analysis on a matrix!
> I'd appreciate your help with this...
>
> Marije
>
>
> De inhoud van dit bericht is vertrouwelijk en alleen bestemd voor de
> geadresseerde(n). Anderen dan de geadresseerde mogen geen gebruik maken van
> dit bericht, het openbaar maken of op enige wijze verspreiden of
> vermenigvuldigen. Het UMCG kan niet aansprakelijk gesteld worden voor een
> incomplete aankomst of vertraging van dit verzonden bericht.
>
> The contents of this message are confidential and only intended for the
> eyes of the addressee(s). Others than the addressee(s) are not allowed to
> use this message, to make it public or to distribute or multiply this
> message in any way. The UMCG cannot be held responsible for incomplete
> reception or delay of this transferred message.
>
> ______________________________________________
> R-help_at_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
> and provide commented, minimal, self-contained, reproducible code.
>
>

-- 
Christophe Pallier (http://www.pallier.org)

	[[alternative HTML version deleted]]

______________________________________________
R-help_at_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
and provide commented, minimal, self-contained, reproducible code.
Received on Thu 14 Jun 2007 - 11:37:14 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 14 Jun 2007 - 12:31:57 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.