R/GSEA.R

Defines functions gseaAnalysisPt2 gseaAnalysisPt1 gseaAnalysis

Documented in gseaAnalysis

gseaAnalysis<-function(hitVector, whichOnto){

    hitVector<-factor(hitVector)
    l <- 0
    GOlist<-GOannotate(names(hitVector), whichOnto)
    if (class(GOlist)=="try-error"){
	    invisible(GOlist)
    }else{
      if(whichOnto == "biological_process"){
          whichOnto<-"BP"
      }
      if(whichOnto == "molecular_function"){
          whichOnto<-"MF"    
      }
      if(whichOnto == "cellular_component"){
          whichOnto<-"CC"    
      }
      try({
        GOdata<-new("topGOdata", ontology=whichOnto, allGenes=hitVector, 
        annot=geneNameAnno, gene2GO=GOlist)

        testStat<-new("weightCount", testStatistic=GOFisherTest, name="Fisher test", 
        sigRatio="ratio")
        resultWeight<-getSigGroups(GOdata, testStat)

        l <- GenTable(GOdata, resultWeight, topNodes=length(usedGO(GOdata)))
      })
    }
    return(l)
}



gseaAnalysisPt1<-function(hitVector, whichOnto){
    GOlist<-GOannotate(names(hitVector), whichOnto)
}


gseaAnalysisPt2<-function(hitVector, GOlist, whichOnto){

    hitVector<-factor(hitVector)

    if(whichOnto == "biological_process"){
        whichOnto<-"BP"
    }
    if(whichOnto == "molecular_function"){
        whichOnto<-"MF"    
    }
    if(whichOnto == "cellular_component"){
        whichOnto<-"CC"    
    }
    
    GOdata<-new("topGOdata", ontology=whichOnto, allGenes=hitVector, 
    annot=geneNameAnno, gene2GO=GOlist)

    testStat<-new("weightCount", testStatistic=GOFisherTest, name="Fisher test", 
    sigRatio="ratio")
    resultWeight<-getSigGroups(GOdata, testStat)

    l <- GenTable(GOdata, resultWeight, topNodes=length(usedGO(GOdata)))
}

Try the RNAither package in your browser

Any scripts or data that you put into this service are public.

RNAither documentation built on Nov. 8, 2020, 8:06 p.m.