##example 1
gl <- runif(100, min=0, max=5)
gl <- gl[order(gl, decreasing=TRUE)]
names(gl) <- as.character(sample(x=seq(from=1, to=100, by=1), size=100,
replace=FALSE))
gs <- sample(names(gl), size=20, replace=FALSE)
##GSEA for input phenotype vector on a single gene set
gsea <- gseaScores(geneList=gl, geneSet=gs, mode="score", exponent=1)
##GSEA for both input phenotype vector and permutation tests on a single gene set
nPermutations <- 100
glPerm <- sapply(1:nPermutations, function(n) names(gl)[sample(1:length(gl),
length(gl), replace=FALSE)])
glPerm <- cbind(names(gl), glPerm)
gseaBatch<-gseaScoresBatch(geneList=gl, geneNames.perm=glPerm, geneSet=gs,
nPermutations=100, exponent=1)
##example 2
## Not run:
# library(KEGG.db)
# library(org.Dm.eg.db)
# library(snow)
# ##load phenotype vector (see the vignette for details about the
# ##preprocessing of this data set)
# data("KcViab_Data4Enrich")
# DM_KEGG <- KeggGeneSets(species="Dm")
# ##GSEA for input gene list on a single gene set
# test <- gseaScores(geneList=KcViab_Data4Enrich, geneSet=DM_KEGG[[1]],
# exponent=1, mode="graph")
# ##GSEA for both input gene list and permutation tests on multiple gene
# ##sets in parallel
# nPermutations <- 100
# glPerm <- sapply(1:nPermutations, function(n) names(KcViab_Data4Enrich)[
# sample(1:length(KcViab_Data4Enrich), length(KcViab_Data4Enrich),
# replace=FALSE)])
# glPerm<-cbind(names(KcViab_Data4Enrich), glPerm)
# options(cluster=makeCluster(4,"SOCK"))
# gseaBatchPar <- gseaScoresBatchParallel(geneList=KcViab_Data4Enrich,
# geneNames.perm=glPerm, collectionOfGeneSets=DM_KEGG[1:10], nPermutations=100,
# exponent=1)
# if(is(getOption("cluster"),"cluster")) {
# stopCluster(getOption("cluster"))
# options(cluster=NULL)
# }
# ## End(Not run)
Run the code above in your browser using DataLab