Metabolomics Society Forum

Software => XCMS => R => XCMS - FAQ => Topic started by: hpbenton on September 04, 2011, 07:43:33 PM

Title: How do I perform multiple testing correction in xcms?
Post by: hpbenton on September 04, 2011, 07:43:33 PM
One of the great things about xcms is since it's in R this is very easy to do. Multiple testing correction gives you a corrected pvalue due to the fact that you have performed multiple univariate tests. However, you will see that while your false discovery rate decreases, you will also sacrifice a few real results. There are many papers about the problems associated with multiple testing correction and many new algorithms to make the situation better (see links below). But you asked the question, so here's the answer!
Code: [Select]
require(multtest)
library(xcms)
library(faahKO)
gxs<-group(faahko)
ret<-retcor(gxs, p="m", f="s")
gret<-group(ret)
fill<-fillPeaks(gret)
diff<-diffreport(fill, "KO", "WT")
First we need the diffreport, so I'll generate one using the default dataset. If you have already saved your datasets then you can read it back in using read.tsv
Now we'll see how the pvalue adjustment function works:
Code: [Select]
colnames(diff)
crpval<-mt.rawp2adjp(diff[,"pvalue"], proc="Bonf") ## I'll go with the default adjustment
idx<-sort(crpval$index, index.return=TRUE)
AdjPval<-crpval$adjp[idx$ix,2]
diff<-cbind(diff[,1:4], AdjustedPval=AdjPval, diff[,5:ncol(diff)])

write.csv(diff, file="NewDiffreport.csv")


Here are some links to explain why correction is needed, what it is and problems associated with it.
http://en.wikipedia.org/wiki/Bonferroni_correction (http://en.wikipedia.org/wiki/Bonferroni_correction)
http://rss.acs.unt.edu/Rdoc/library/mul ... 2adjp.html (http://rss.acs.unt.edu/Rdoc/library/multtest/html/mt.rawp2adjp.html) - This is the R page for the function we are using.
http://www.ncbi.nlm.nih.gov/pmc/articles/PMC1112991/ (http://www.ncbi.nlm.nih.gov/pmc/articles/PMC1112991/)
http://www.google.co.uk/search?client=s ... 76&bih=877 (http://www.google.co.uk/search?client=safari&rls=en&q=problems+with+bonferroni&ie=UTF-8&oe=UTF-8&redir_esc=&ei=sShkTuz4Boiy8QOAquGzCg#sclient=psy&hl=en&client=safari&rls=en&source=hp&q=problems+with+bonferroni+metabolomics&pbx=1&oq=problems+with+bonferroni+metabolomics&aq=f&aqi=&aql=&gs_sm=e&gs_upl=14793l18677l0l18905l13l12l0l0l0l0l219l1551l4.7.1l12l0&bav=on.2,or.r_gc.r_pw.&fp=75188eaea7c8ba32&biw=1276&bih=877)