Mercurial > repos > proteore > proteore_clusterprofiler
changeset 37:7269aea2cb95 draft
planemo upload commit 3ff0fa577362e757a1e7692a0a397bdda3d4dfc8-dirty
| author | proteore |
|---|---|
| date | Thu, 27 Jun 2019 09:44:07 -0400 |
| parents | 51d79e4496cc |
| children | 0d954174e0e9 |
| files | GO-enrich.R cluster_profiler.xml |
| diffstat | 2 files changed, 37 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/GO-enrich.R Thu Jun 27 04:06:45 2019 -0400 +++ b/GO-enrich.R Thu Jun 27 09:44:07 2019 -0400 @@ -44,7 +44,7 @@ return (width) } -repartition.GO <- function(geneid, orgdb, ontology, level=3, readable=TRUE) { +repartition_GO <- function(geneid, orgdb, ontology, level=3, readable=TRUE, plot) { ggo<-groupGO(gene=geneid, OrgDb = orgdb, ont=ontology, @@ -55,18 +55,30 @@ ggo@result$Description <- sapply(as.vector(ggo@result$Description), function(x) {ifelse(nchar(x)>50, substr(x,1,50),x)},USE.NAMES = FALSE) #nb_max_char = max_str_length_10_first(ggo$Description) #width = width_by_max_char(nb_max_char) - name <- paste("GGO_", ontology, "_bar-plot", sep = "") - png(name,height = 720, width = 600) - p <- barplot(ggo, showCategory=10) - print(p) - dev.off() + + if ("dotplot" %in% plot ){ + dot_name <- paste("GGO_", ontology, "_dot-plot", sep = "") + png(dot_name,height = 720, width = 600) + p <- dotplot(ggo, showCategory=10) + print(p) + dev.off() + } + + if ("barplot" %in% plot ){ + bar_name <- paste("GGO_", ontology, "_bar-plot", sep = "") + png(bar_name,height = 720, width = 600) + p <- barplot(ggo, showCategory=10) + print(p) + dev.off() + } + ggo <- as.data.frame(ggo) return(ggo) } } # GO over-representation test -enrich.GO <- function(geneid, universe, orgdb, ontology, pval_cutoff, qval_cutoff,plot) { +enrich_GO <- function(geneid, universe, orgdb, ontology, pval_cutoff, qval_cutoff,plot) { ego<-enrichGO(gene=geneid, universe=universe, OrgDb=orgdb, @@ -126,7 +138,7 @@ } } -clusterProfiler = function() { +get_args <- function(){ args <- commandArgs(TRUE) if(length(args)<1) { args <- c("--help") @@ -162,10 +174,18 @@ args <- as.list(as.character(argsDF$V2)) names(args) <- argsDF$V1 + return(args) +} + + +main <- function() { + + #get args from command + args <- get_args() + #save(args,file="/home/dchristiany/proteore_project/ProteoRE/tools/cluster_profiler/args.Rda") #load("/home/dchristiany/proteore_project/ProteoRE/tools/cluster_profiler/args.Rda") - go_represent=str2bool(args$go_represent) go_enrich=str2bool(args$go_enrich) if (go_enrich){ @@ -272,17 +292,19 @@ universe_gene = NULL } + print(plot) + ##enrichGO : GO over-representation test for (onto in ontology) { if (go_represent) { - ggo<-repartition.GO(gene, orgdb, onto, level, readable=TRUE) + ggo<-repartition_GO(gene, orgdb, onto, level, readable=TRUE,plot) if (is.list(ggo)){ggo <- as.data.frame(apply(ggo, c(1,2), function(x) gsub("^$|^ $", NA, x)))} #convert "" and " " to NA output_path = paste("cluster_profiler_GGO_",onto,".tsv",sep="") write.table(ggo, output_path, sep="\t", row.names = FALSE, quote = FALSE ) } if (go_enrich) { - ego<-enrich.GO(gene, universe_gene, orgdb, onto, pval_cutoff, qval_cutoff,plot) + ego<-enrich_GO(gene, universe_gene, orgdb, onto, pval_cutoff, qval_cutoff,plot) if (is.list(ego)){ego <- as.data.frame(apply(ego, c(1,2), function(x) gsub("^$|^ $", NA, x)))} #convert "" and " " to NA output_path = paste("cluster_profiler_EGO_",onto,".tsv",sep="") write.table(ego, output_path, sep="\t", row.names = FALSE, quote = FALSE ) @@ -290,4 +312,6 @@ } } -clusterProfiler() +if(!interactive()) { + main() +}
--- a/cluster_profiler.xml Thu Jun 27 04:06:45 2019 -0400 +++ b/cluster_profiler.xml Thu Jun 27 09:44:07 2019 -0400 @@ -1,4 +1,4 @@ -<tool id="cluter_profiler" name="GO terms classification and enrichment analysis" version="2019.06.27"> +<tool id="cluter_profiler" name="GO terms classification and enrichment analysis" version="2019.06.27.1"> <description>(Human, Mouse, Rat)[clusterProfiler]</description> <requirements> <requirement type="package" version="3.4.1">R</requirement>
