This function takes as input a matrix of pvalues for example obtained from a GSEA on multiple phenotypes, with a row for each gene set and a column for each phenotype and aggregates the pvalues by row (i.e. one aggregated pvalue for each gene set) according to Fisher or Stouffer's methods.
1 2  aggregatePvals(pvalMatrix, method="fishers", pAdjustMethod="BH",
order=TRUE)

pvalMatrix 
a numeric matrix of pvalues, with rows named according to the gene set (rows correspond to gene sets, and columns to multiple pvalues to be aggregated for that gene set) 
method 
a single character value of "stouffers" or "fishers" 
pAdjustMethod 
a single character value specifying the pvalue adjustment method to be used (see 'p.adjust' for details) 
order 
a single logical value: TRUE or FALSE. If it is TRUE, the results table will be ordered according to the aggregated pvalues. 
The Fisher method combines the pvalues into an aggregated chisquared statistic equal to 2*sum(log(Pk)) were we have k=1,..,K pvalues independently distributed as uniform on the unit interval under the null hypothesis. The resulting pvalues are calculated by comparing this chisquared statistic to a chisquared distribution with 2K degrees of freedom. The Stouffer method computes a zstatistics assuming that the sum of the quantiles (from a standard normal distribution) corresponding to the pvalues are distributed as N(0,K).
a matrix with a row for each gene set and two columns: "Aggregated.p.value" and "Adjusted.aggregated.p.value"
Jack Rose and Camille Terfve
1 2 3 4 5 6 7 
Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
All documentation is copyright its authors; we didn't write any of that.