| msigdb.gsea | R Documentation |
These functions perform gene set enrichment analyses based on MSigDB collections.
msigdb.gsea(x, query.population=NULL, genesets=c('c2.cp', 'c5.go.bp', 'c5.go.cc', 'c5.go.mf'),
background='common', name.x='Input', name.go='MSigDB',
method=c('hypergeometric', 'GSEA', 'logitreg'), adj="BH", species=c('human', 'mouse'),
ReportOverlap=TRUE, ncores=1, gsea.alpha=1,
permutations=ifelse(method=='GSEA', 1000, 0), iseed=12345)
x |
a data.frame of query gene signatures. See |
query.population |
a population of the genes from which the query gene signatures are collected. |
genesets |
MSigDB gene set collections to be tested. |
background |
an integer or a keyword. See explanation in function |
name.x |
a character string specifing the name of the query. |
name.go |
a character string specifing the name of the function gene sets. |
method |
algorithm to performing the enrichment test. See |
adj |
approach to correct for multiple tests. See function |
species |
Specifying the species for the input gene signatures. |
ReportOverlap |
whether to output overlapping elements. |
ncores |
number of CPU cores to be used for parallel computing. |
gsea.alpha |
power to scale the weights: 0 (unweighted = Kolmogorov-Smirnov), 1 (weighted), and 2 or larger (over-weighted) |
permutations |
number of permutations for computing P value significance and controlling FDR for |
iseed |
seed for random number generation in permutations. |
For msigdb.gsea, known annotated gene sets in MSigDB will be loaded by function msigdb.genesets and the enrichment analysis is computed using function GOtest.
Other details can be found in function GOtest.
See output of function GOtest.
GOtest, plotOverlap, p.adjust, GSEA
###Example usage 2: weighted enrichment tests
#We will again make use of the MacArthur gene set and the gene universe of HGNC approved symbols,
# so make sure they have been loaded as in Example 1.
library(GOtest)
MAGenes=curated.genesets(c('MacArthur'))
universe=curated.genesets(c('HGNC_universe'))$Gene
(n=length(universe))
#In this example, we will try both the hypergeometric test and weighted enrichment tests,
#including GSEA and logistic regression, by geneating a toy dataset
#through simulation of random gene-phenotype associations.
set.seed(123)
toy=data.frame(Gene=universe, Phenotype='Simulated', Z=rnorm(n, 0, 1), stringsAsFactors=FALSE)
#Select genes with absolute Z value larger than 3 and separate them into up and down groups
#based on the sign of Z value, then run the hypergeometric test on both groups
#against the MacAuther gene sets:
toy.3 = toy[abs(toy$Z)>3,]
toy.3$Direction = ifelse(toy.3$Z > 0, 'Up', 'Down')
fit1 = msigdb.gsea(x = toy.3[, c('Gene', 'Direction')], query.population = universe,
background = 'query', name.x = 'Toy', method = 'hypergeometric')
#As expected, no significant enrichment identified:
head(fit1)
## Not run:
#Next, we are going to run weighted enrichment tests on the full test dataset
#by using GSEA or logistic regression. First, run GSEA:
fit2 = msigdb.gsea(x=toy, name.x='Toy', method='GSEA')
head(fit2)
#Run logistic regression:
fit3=GOtest(x=toy, go=MAGenes, name.x='Toy', name.go='MacArthur', method='logitreg')
head(fit3)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.