doGse: Perform gene-set enrichment (GSE) analysis

View source: R/doGse.R

doGseR Documentation

Perform gene-set enrichment (GSE) analysis

Description

Perform gene-set enrichment (GSE) analysis

Usage

doGse(edgeResult, gmtList, doParallel = FALSE)

Arguments

edgeResult

An object of the class EdgeResult or LimmaVoomResult

gmtList

An object of the class GmtList

doParallel

Logical, whether parallel::mclapply should be used. Since at the current setting it makes a job running forever, use TRUE only if you are debugging the code.

The function performs gene-set enrichment analysis. By default,the CAMERA method is applied. In case this is not successful, for instance because of lack of biological replicates, the GAGE method (Generally Applicable Gene-set Enrichment for pathway analysis) is applied.

Value

A data.frame containing results of the gene-set enrichment analysis.

See Also

gseWithLogFCgage and gseWithCamera are wrapped by this function to perform analysis with GAGE and CAMERA, respectively. logFCgage, camera.EdgeResult, and camera.LimmaVoomResult implement the logic, and return the enrichment table.

Examples

exMat <- matrix(rpois(120, 10), nrow=20, ncol=6)
exGroups <- gl(2,3, labels=c("Group1", "Group2"))
exDesign <- model.matrix(~0+exGroups)
exContrast <- matrix(c(-1,1), ncol=1, dimnames=list(c("Group1", "Group2"), c("Group2.vs.Group1")))
exDescon <- DesignContrast(exDesign, exContrast, groups=exGroups)
exFdata <- data.frame(GeneSymbol=sprintf("Gene%d", 1:nrow(exMat)))
exPdata <- data.frame(Name=sprintf("Sample%d", 1:ncol(exMat)),
                     Group=exGroups)
exObj <- EdgeObject(exMat, exDescon, 
                     fData=exFdata, pData=exPdata)
exDgeRes <- ribiosNGS::dgeWithEdgeR(exObj)

exGeneSets <- BioQC::GmtList(list(
    list(name="Set1", desc="set 1", genes=c("Gene1", "Gene2", "Gene3"), namespace="default"),
    list(name="Set2", desc="set 2", genes=c("Gene18", "Gene6", "Gene4"), namespace="default")
))
exGse <- doGse(exDgeRes, exGeneSets)

## Not run: 
  exMat <- matrix(rpois(120000, 10), nrow=20000, ncol=12)
  exGroups <- gl(4,3, labels=c("Group1", "Group2", "Group3", "Group4"))
  exDesign <- model.matrix(~0+exGroups)
  exContrast <- matrix(c(-1,1,0,0, 0,0,-1,1),
     ncol=2, byrow=FALSE,
     dimnames=list(c("Group1", "Group2", "Group3", "Group4"), 
       c("Group2.vs.Group1", "Group4.vs.Group3")))
  exDescon <- DesignContrast(exDesign, exContrast, groups=exGroups)
  exFdata <- data.frame(GeneSymbol=sprintf("Gene%d", 1:nrow(exMat)))
  exPdata <- data.frame(Name=sprintf("Sample%d", 1:ncol(exMat)),
                       Group=exGroups)
  exObj <- EdgeObject(exMat, exDescon, 
                       fData=exFdata, pData=exPdata)
  exDgeRes <- ribiosNGS::dgeWithEdgeR(exObj)
  
  ngeneset <- 1000
  genesetSizes <- round(runif(ngeneset)*100)+1
  exGeneSets <- BioQC::GmtList(lapply(seq(1:ngeneset), function(i) {
    name <- paste0("GeneSet", i)
    desc <- paste0("GeneSet", i)
    genes <- sample(exFdata$GeneSymbol, genesetSizes[i])
    res <- list(name=name, desc=desc, genes=genes, namespace="default")
  }))
  exGse <- doGse(exDgeRes, exGeneSets)

## End(Not run)


bedapub/ribiosGSEA documentation built on March 30, 2023, 3:26 p.m.