Question: Gene Set Enrichment between two dataset
0
gravatar for gracie
2.0 years ago by
gracie20
gracie20 wrote:

Dear all,

I want to perform gene set enrichment analysis between two datasets. There are packages for GO or KEGG pathway enrichment but I could not find one to calculate enrichment score between user given geneset and genelist. Is there any package for that?

Thank you

rna-seq gsea r language • 1.5k views
ADD COMMENTlink modified 2.0 years ago by ewre220 • written 2.0 years ago by gracie20

The following tools will be helpful to achieve that.

https://bioconductor.org/packages/release/bioc/html/GSEABase.html

https://bioconductor.org/packages/release/bioc/html/fgsea.html

ADD REPLYlink written 2.0 years ago by Arup Ghosh2.6k
0
gravatar for ewre
2.0 years ago by
ewre220
United States
ewre220 wrote:

Here you go if you want to use fisher's exact test.

enrich.test = function(PathGenes, interestGenes, totalGenes) {
    ################################################
    ###           | inPath | not inPath |
    ###-------------------------------------------
    ###   Predict |  a     |   b        | nPredict
    ###notPredict |  c     |   d        |
    ###-------------------------------------------
    ###           |  nPath |            | nAll
    ################################################
      ##remove genes not included in reference gene set
      PathGenes = intersect(PathGenes,totalGenes)
      interestGenes = intersect(interestGenes, totalGenes)

      nPath <- length(PathGenes)
      nPredict <- length(interestGenes)
      a <- length(intersect(PathGenes,interestGenes))
      b <- nPredict - a
      c <- nPath - a
      nAll = length(totalGenes)
      d <- nAll - (a + b + c)
      m <- matrix(c(a,b,c,d), ncol=2,byrow=T)
      colnames(m) <- c('inPath','notInPath');rownames(m) <- c('Predict','notPredict')
      p <- fisher.test(m,alternative='greater')$p.value

      ##using phyper for hypergeometric test
      p1 <- phyper(a-1,nPath, nAll-nPath,nPredict,lower.tail=F)
      p2 <-1 - phyper(a-1,nPath, nAll-nPath,nPredict)
      tmp <- c(a,b,c,d,p,p1,p2)


      res = list(mat=m,p=list('fisher.exact'=p,
                              'phyper1'=p1,
                              'phyper2'=p2),
                overlapped=intersect(PathGenes, interestGenes))
      res
    }
ADD COMMENTlink modified 2.0 years ago • written 2.0 years ago by ewre220
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1685 users visited in the last hour