Question: Gene Set Enrichment between two dataset
0
gravatar for gracie
13 months ago by
gracie10
gracie10 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 • 843 views
ADD COMMENTlink modified 13 months ago by ewre220 • written 13 months ago by gracie10

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 13 months ago by arup1.7k
0
gravatar for ewre
13 months 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 13 months ago • written 13 months 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: 1973 users visited in the last hour