0

I have a data frame (golubdf) with 3051 genes and 38 columns (2 class labels--27 columns one label: 0, 11 columns other label: 1). I need to write a for loop to iterate 500 times, where in each iteration, the columns of the data frame are shuffled (class labels mixed up), Wilcox test calculated on all genes and the maximum test statistic on all genes saved in a list:

t.test.all.genes <- function(x,s1,s2) {
    x1 <- x[s1]
    x2 <- x[s2]
    x1 <- as.numeric(x1)
    x2 <- as.numeric(x2)
    t.out <- wilcox.test(x1,x2, alternative="two.sided", exact=F, correct=T)
    out <- as.numeric(t.out$statistic)
    return(out)
}

prs = replicate(500, apply(golubdf[ ,sample(ncol(golubdf))], 1, 
                t.test.all.genes, s1=labels==0, s2=labels==1))
 ps.max = apply(prs, 1, max) 

I am not sure if this is right--do I need to use rows or columns? Since I need the maximum test statistic on all genes I have used rows (1). After this, I need to get the 95% value test statistic from the list of maximum test statistics, which is were I am not sure how to get it to work.

gung - Reinstate Monica
  • 11,583
  • 7
  • 60
  • 79
ser2207860
  • 65
  • 1
  • 9
  • 3
    Without example data it's very difficult to help you. Read [the FAQ](http://stackoverflow.com/q/5963269/1412059) to learn how to provide data. – Roland Aug 02 '13 at 20:32
  • the data I am using the golub data in R and the class labels are the same (All for the first 27 samples and AML for rest of the 11) – ser2207860 Aug 05 '13 at 12:16
  • the only thing I changed is the for all the 3051 records I changed the names to g1 to g3051,, row.names(golubdf)=c(paste("g",1:3051,sep="")) labels <- golub.cl # class labels ALL=0; AML=1 labelgb <- factor(c(rep("ALL",27),rep("AML",11))) – ser2207860 Aug 05 '13 at 12:17

1 Answers1

0

ps.max = apply(prs, 1, max) line will cause error. Just try ps.max = max(prs). Also as per your requirement, you have to save your out put in a list. First create an empty list as follows:

myList<-list(). Then inside the for loop keep inserting the max value to the list.

Thanks

user466663
  • 815
  • 4
  • 18
  • 40