# HG changeset patch # User proteore # Date 1536133836 14400 # Node ID 1c98865a8508f86af08877f22b45362879dcf024 # Parent 91b9b48d07b3158aa6eb72242da20696f0304511 planemo upload commit 01102a33a5c3fc56de61cd12784691b49334054b-dirty diff -r 91b9b48d07b3 -r 1c98865a8508 GO-enrich.R --- a/GO-enrich.R Tue Aug 28 09:09:10 2018 -0400 +++ b/GO-enrich.R Wed Sep 05 03:50:36 2018 -0400 @@ -1,8 +1,6 @@ -suppressMessages(library(clusterProfiler)) +suppressMessages(library(clusterProfiler,quietly = TRUE)) -#library(org.Sc.sgd.db) -suppressMessages(library(org.Hs.eg.db)) -suppressMessages(library(org.Mm.eg.db)) +#library(org.Sc.sgd.db,quietly = TRUE) # Read file and return file content as data.frame readfile = function(filename, header) { @@ -43,24 +41,29 @@ ego<-enrichGO(gene=geneid, universe=universe, OrgDb=orgdb, - keytype="ENTREZID", ont=ontology, pAdjustMethod="BH", pvalueCutoff=pval_cutoff, qvalueCutoff=qval_cutoff, readable=TRUE) + # Plot bar & dot plots - bar_name <- paste("EGO.", ontology, ".bar.png", sep = "") - png(bar_name) - p <- barplot(ego) - print(p) - dev.off() - dot_name <- paste("EGO.", ontology, ".dot.png", sep = "") - png(dot_name) - p <- dotplot(ego, showCategory=10) - print(p) - dev.off() - return(ego) + #if there are enriched GopTerms + if (length(ego$ID)>0){ + bar_name <- paste("EGO.", ontology, ".bar.png", sep = "") + png(bar_name) + p <- barplot(ego) + print(p) + dev.off() + dot_name <- paste("EGO.", ontology, ".dot.png", sep = "") + png(dot_name) + p <- dotplot(ego, showCategory=10) + print(p) + dev.off() + return(ego) + } else { + warning(paste("No Go terms enriched (EGO) found for ",ontology,"ontology"),immediate. = TRUE,noBreaks. = TRUE,call. = FALSE) + } } check_ids <- function(vector,type) { @@ -109,15 +112,17 @@ names(args) <- argsDF$V1 #print(args) - #save(args,file="args.Rda") + #save(args,file="/home/dchristiany/proteore_project/ProteoRE/tools/cluster_profiler/args.Rda") #load("/home/dchristiany/proteore_project/ProteoRE/tools/cluster_profiler/args.Rda") + suppressMessages(library(args$species, character.only = TRUE, quietly = TRUE)) + # Extract OrgDb - if (args$species=="human") { + if (args$species=="org.Hs.eg.db") { orgdb<-org.Hs.eg.db - } else if (args$species=="mouse") { + } else if (args$species=="org.Mm.eg.db") { orgdb<-org.Mm.eg.db - } else if (args$species=="rat") { + } else if (args$species=="org.Sc.eg.db") { orgdb<-org.Rn.eg.db } @@ -149,7 +154,7 @@ any(check_ids(input,"uniprot")) idFrom<-"UNIPROT" idTo<-"ENTREZID" - gene<-bitr(input, fromType=idFrom, toType=idTo, OrgDb=orgdb) + suppressMessages(gene<-bitr(input, fromType=idFrom, toType=idTo, OrgDb=orgdb)) gene<-unique(gene$ENTREZID) } else if (id_type=="Entrez" & any(check_ids(input,"entrez"))) { gene<-unique(input) @@ -193,7 +198,7 @@ if (universe_id_type=="Uniprot" & any(check_ids(universe,"uniprot"))) { idFrom<-"UNIPROT" idTo<-"ENTREZID" - universe_gene<-bitr(universe, fromType=idFrom, toType=idTo, OrgDb=orgdb) + suppressMessages(universe_gene<-bitr(universe, fromType=idFrom, toType=idTo, OrgDb=orgdb)) universe_gene<-unique(universe_gene$ENTREZID) } else if (universe_id_type=="Entrez" & any(check_ids(universe,"entrez"))) { universe_gene<-unique(universe) diff -r 91b9b48d07b3 -r 1c98865a8508 cluster_profiler.xml --- a/cluster_profiler.xml Tue Aug 28 09:09:10 2018 -0400 +++ b/cluster_profiler.xml Wed Sep 05 03:50:36 2018 -0400 @@ -1,4 +1,4 @@ - + GO terms classification and enrichment analysis @@ -7,7 +7,7 @@ bioconductor-org.hs.eg.db bioconductor-org.mm.eg.db bioconductor-dose - bioconductor-clusterprofiler + bioconductor-clusterprofiler - - - + + +