diff topGO_enrichment.R @ 12:3d6b76f301c2 draft

planemo upload commit 4c04fd02dbe5234b3b1c524d65fb2de4c56e5a78-dirty
author proteore
date Tue, 16 Oct 2018 10:57:54 -0400
parents ddcc0347c54a
children e7ff74898133
line wrap: on
line diff
--- a/topGO_enrichment.R	Tue Oct 16 10:28:50 2018 -0400
+++ b/topGO_enrichment.R	Tue Oct 16 10:57:54 2018 -0400
@@ -261,10 +261,8 @@
   }
   
   geneList = factor(as.integer(allGenes %in% sample)) 
-  if (levels(geneList) == "1" ){
-    stop("All background genes are found in tested genes dataset, enrichment analysis can't be done")
-  } else if (levels(geneList)== "0"){
-    stop("None of the background genes are found in tested genes dataset, enrichment analysis can't be done")
+  if (length(levels(geneList)) == 1 ){
+    stop("All or none of the background genes are found in tested genes dataset, enrichment analysis can't be done")
   }
   names(geneList) <- allGenes
   
@@ -333,16 +331,15 @@
     background_tab=read_file(background_genes,background_header)
     background_sample = unique(trimws(unlist(strsplit(background_tab[,background_column],";"))))
   }
+  #check of ENS ids
+  if (! any(check_ens_ids(background_sample))){
+    print("no ensembl gene ids found in your background ids list, please check your IDs in input or the selected column of your input file")
+    stop()
+  }
 } else {
   background_sample=NULL
 }
 
-#check of ENS ids
-if (! any(check_ens_ids(background_sample))){
-  print("no ensembl gene ids found in your background ids list, please check your IDs in input or the selected column of your input file")
-  stop()
-}
-
 # Launch enrichment analysis
 allresult = suppressMessages(goEnrichment(geneuniverse,sample,background_sample,onto))
 result = allresult[1][[1]]