annotate GO-enrich.R @ 7:4609346d8108 draft

planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
author proteore
date Tue, 18 Dec 2018 09:21:32 -0500
parents 5e16cec55146
children b29255864039
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
1 options(warn=-1) #TURN OFF WARNINGS !!!!!!
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
2 suppressMessages(library(clusterProfiler,quietly = TRUE))
0
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
3
4
710414ebb6db planemo upload commit 0a42c3d46be24406936ca0036bb436e6e2524fd2-dirty
proteore
parents: 0
diff changeset
4 # Read file and return file content as data.frame
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
5 read_file <- function(path,header){
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
6 file <- try(read.csv(path,header=header, sep="\t",stringsAsFactors = FALSE, quote="",check.names = F),silent=TRUE)
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
7 if (inherits(file,"try-error")){
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
8 stop("File not found !")
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
9 }else{
0
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
10 file <- file[!apply(is.na(file) | file == "", 1, all), , drop=FALSE]
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
11 return(file)
0
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
12 }
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
13 }
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
14
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
15 #return the number of character from the longest description found (from the 10 first)
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
16 max_str_length_10_first <- function(vector){
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
17 vector <- as.vector(vector)
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
18 nb_description = length(vector)
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
19 if (nb_description >= 10){nb_description=10}
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
20 return(max(nchar(vector[1:nb_description])))
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
21 }
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
22
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
23 str2bool <- function(x){
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
24 if (any(is.element(c("t","true"),tolower(x)))){
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
25 return (TRUE)
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
26 }else if (any(is.element(c("f","false"),tolower(x)))){
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
27 return (FALSE)
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
28 }else{
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
29 return(NULL)
0
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
30 }
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
31 }
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
32
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
33 #used before the limit was set to 50 characters
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
34 width_by_max_char <- function (nb_max_char) {
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
35 if (nb_max_char < 50 ){
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
36 width=600
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
37 } else if (nb_max_char < 75) {
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
38 width=800
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
39 } else if (nb_max_char < 100) {
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
40 width=900
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
41 } else {
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
42 width=1000
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
43 }
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
44 return (width)
0
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
45 }
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
46
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
47 repartition.GO <- function(geneid, orgdb, ontology, level=3, readable=TRUE) {
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
48 ggo<-groupGO(gene=geneid,
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
49 OrgDb = orgdb,
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
50 ont=ontology,
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
51 level=level,
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
52 readable=TRUE)
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
53
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
54 if (length(ggo@result$ID) > 0 ) {
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
55 ggo@result$Description <- sapply(as.vector(ggo@result$Description), function(x) {ifelse(nchar(x)>50, substr(x,1,50),x)},USE.NAMES = FALSE)
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
56 #nb_max_char = max_str_length_10_first(ggo$Description)
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
57 #width = width_by_max_char(nb_max_char)
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
58 name <- paste("GGO_", ontology, "_bar-plot", sep = "")
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
59 png(name,height = 720, width = 600)
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
60 p <- barplot(ggo, showCategory=10)
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
61 print(p)
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
62 dev.off()
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
63 ggo <- as.data.frame(ggo)
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
64 return(ggo)
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
65 }
0
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
66 }
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
67
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
68 # GO over-representation test
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
69 enrich.GO <- function(geneid, universe, orgdb, ontology, pval_cutoff, qval_cutoff,plot) {
0
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
70 ego<-enrichGO(gene=geneid,
6
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
71 universe=universe,
0
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
72 OrgDb=orgdb,
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
73 ont=ontology,
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
74 pAdjustMethod="BH",
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
75 pvalueCutoff=pval_cutoff,
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
76 qvalueCutoff=qval_cutoff,
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
77 readable=TRUE)
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
78
6
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
79 # Plot bar & dot plots
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
80 #if there are enriched GopTerms
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
81 if (length(ego$ID)>0){
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
82
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
83 ego@result$Description <- sapply(ego@result$Description, function(x) {ifelse(nchar(x)>50, substr(x,1,50),x)},USE.NAMES = FALSE)
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
84 #nb_max_char = max_str_length_10_first(ego$Description)
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
85 #width = width_by_max_char(nb_max_char)
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
86
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
87 if ("dotplot" %in% plot ){
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
88 dot_name <- paste("EGO_", ontology, "_dot-plot", sep = "")
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
89 png(dot_name,height = 720, width = 600)
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
90 p <- dotplot(ego, showCategory=10)
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
91 print(p)
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
92 dev.off()
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
93 }
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
94
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
95 if ("barplot" %in% plot ){
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
96 bar_name <- paste("EGO_", ontology, "_bar-plot", sep = "")
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
97 png(bar_name,height = 720, width = 600)
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
98 p <- barplot(ego, showCategory=10)
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
99 print(p)
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
100 dev.off()
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
101
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
102 }
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
103 ego <- as.data.frame(ego)
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
104 return(ego)
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
105 } else {
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
106 warning(paste("No Go terms enriched (EGO) found for ",ontology,"ontology"),immediate. = TRUE,noBreaks. = TRUE,call. = FALSE)
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
107 }
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
108 }
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
109
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
110 check_ids <- function(vector,type) {
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
111 uniprot_pattern = "^([OPQ][0-9][A-Z0-9]{3}[0-9]|[A-NR-Z][0-9]([A-Z][A-Z0-9]{2}[0-9]){1,2})$"
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
112 entrez_id = "^([0-9]+|[A-Z]{1,2}_[0-9]+|[A-Z]{1,2}_[A-Z]{1,4}[0-9]+)$"
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
113 if (type == "entrez")
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
114 return(grepl(entrez_id,vector))
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
115 else if (type == "uniprot") {
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
116 return(grepl(uniprot_pattern,vector))
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
117 }
0
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
118 }
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
119
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
120 clusterProfiler = function() {
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
121 args <- commandArgs(TRUE)
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
122 if(length(args)<1) {
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
123 args <- c("--help")
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
124 }
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
125
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
126 # Help section
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
127 if("--help" %in% args) {
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
128 cat("clusterProfiler Enrichment Analysis
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
129 Arguments:
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
130 --input_type: type of input (list of id or filename)
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
131 --input: input
6
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
132 --ncol: the column number which contains list of input IDs
0
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
133 --header: true/false if your file contains a header
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
134 --id_type: the type of input IDs (UniProt/EntrezID)
6
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
135 --universe_type: list or filename
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
136 --universe: background IDs list
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
137 --uncol: the column number which contains background IDs list
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
138 --uheader: true/false if the background IDs file contains header
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
139 --universe_id_type: the type of universe IDs (UniProt/EntrezID)
0
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
140 --species
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
141 --onto_opt: ontology options
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
142 --go_function: groupGO/enrichGO
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
143 --level: 1-3
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
144 --pval_cutoff
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
145 --qval_cutoff
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
146 --text_output: text output filename
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
147 --plot : type of visualization, dotplot or/and barplot \n")
0
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
148 q(save="no")
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
149 }
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
150 # Parse arguments
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
151 parseArgs <- function(x) strsplit(sub("^--", "", x), "=")
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
152 argsDF <- as.data.frame(do.call("rbind", parseArgs(args)))
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
153 args <- as.list(as.character(argsDF$V2))
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
154 names(args) <- argsDF$V1
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
155 plot = unlist(strsplit(args$plot,","))
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
156 go_represent=str2bool(args$go_represent)
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
157 go_enrich=str2bool(args$go_enrich)
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
158
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
159 #save(args,file="/home/dchristiany/proteore_project/ProteoRE/tools/cluster_profiler/args.Rda")
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
160 #load("/home/dchristiany/proteore_project/ProteoRE/tools/cluster_profiler/args.Rda")
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
161
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
162 suppressMessages(library(args$species, character.only = TRUE, quietly = TRUE))
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
163
6
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
164 # Extract OrgDb
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
165 if (args$species=="org.Hs.eg.db") {
6
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
166 orgdb<-org.Hs.eg.db
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
167 } else if (args$species=="org.Mm.eg.db") {
6
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
168 orgdb<-org.Mm.eg.db
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
169 } else if (args$species=="org.Rn.eg.db") {
6
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
170 orgdb<-org.Rn.eg.db
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
171 }
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
172
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
173 # Extract input IDs
0
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
174 input_type = args$input_type
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
175 id_type = args$id_type
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
176
0
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
177 if (input_type == "text") {
4
710414ebb6db planemo upload commit 0a42c3d46be24406936ca0036bb436e6e2524fd2-dirty
proteore
parents: 0
diff changeset
178 input = strsplit(args$input, "[ \t\n]+")[[1]]
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
179 } else if (input_type == "file") {
0
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
180 filename = args$input
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
181 ncol = args$ncol
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
182 # Check ncol
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
183 if (! as.numeric(gsub("c", "", ncol)) %% 1 == 0) {
6
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
184 stop("Please enter the right format for column number: c[number]")
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
185 } else {
0
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
186 ncol = as.numeric(gsub("c", "", ncol))
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
187 }
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
188 header = str2bool(args$header) # Get file content
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
189 file = read_file(filename, header) # Extract Protein IDs list
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
190 input = unlist(sapply(as.character(file[,ncol]),function(x) rapply(strsplit(x,";"),c),USE.NAMES = FALSE))
0
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
191 }
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
192
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
193
6
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
194 ## Get input gene list from input IDs
0
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
195 #ID format Conversion
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
196 #This case : from UNIPROT (protein id) to ENTREZ (gene id)
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
197 #bitr = conversion function from clusterProfiler
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
198 if (id_type=="Uniprot" & any(check_ids(input,"uniprot"))) {
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
199 any(check_ids(input,"uniprot"))
0
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
200 idFrom<-"UNIPROT"
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
201 idTo<-"ENTREZID"
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
202 suppressMessages(gene<-bitr(input, fromType=idFrom, toType=idTo, OrgDb=orgdb))
6
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
203 gene<-unique(gene$ENTREZID)
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
204 } else if (id_type=="Entrez" & any(check_ids(input,"entrez"))) {
6
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
205 gene<-unique(input)
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
206 } else {
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
207 stop(paste(id_type,"not found in your ids list, please check your IDs in input or the selected column of your input file"))
0
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
208 }
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
209
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
210 ontology <- strsplit(args$onto_opt, ",")[[1]]
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
211
6
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
212 ## Extract GGO/EGO arguments
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
213 if (go_represent) {level <- as.numeric(args$level)}
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
214 if (go_enrich) {
0
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
215 pval_cutoff <- as.numeric(args$pval_cutoff)
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
216 qval_cutoff <- as.numeric(args$qval_cutoff)
6
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
217 # Extract universe background genes (same as input file)
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
218 if (!is.null(args$universe_type)) {
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
219 universe_type = args$universe_type
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
220 if (universe_type == "text") {
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
221 universe = strsplit(args$universe, "[ \t\n]+")[[1]]
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
222 } else if (universe_type == "file") {
6
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
223 universe_filename = args$universe
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
224 universe_ncol = args$uncol
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
225 # Check ncol
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
226 if (! as.numeric(gsub("c", "", universe_ncol)) %% 1 == 0) {
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
227 stop("Please enter the right format for column number: c[number]")
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
228 } else {
6
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
229 universe_ncol = as.numeric(gsub("c", "", universe_ncol))
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
230 }
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
231 universe_header = str2bool(args$uheader)
6
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
232 # Get file content
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
233 universe_file = read_file(universe_filename, universe_header)
6
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
234 # Extract Protein IDs list
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
235 universe <- sapply(universe_file[,universe_ncol], function(x) rapply(strsplit(x,";"),c),USE.NAMES = FALSE)
6
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
236 }
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
237 universe_id_type = args$universe_id_type
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
238 ##to initialize
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
239 if (universe_id_type=="Uniprot" & any(check_ids(universe,"uniprot"))) {
6
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
240 idFrom<-"UNIPROT"
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
241 idTo<-"ENTREZID"
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
242 suppressMessages(universe_gene<-bitr(universe, fromType=idFrom, toType=idTo, OrgDb=orgdb))
6
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
243 universe_gene<-unique(universe_gene$ENTREZID)
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
244 } else if (universe_id_type=="Entrez" & any(check_ids(universe,"entrez"))) {
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
245 universe_gene<-unique(unlist(universe))
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
246 } else {
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
247 if (universe_type=="text"){
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
248 print(paste(universe_id_type,"not found in your background IDs list",sep=" "))
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
249 } else {
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
250 print(paste(universe_id_type,"not found in the column",universe_ncol,"of your background IDs file",sep=" "))
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
251 }
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
252 universe_gene = NULL
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
253 }
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
254 } else {
6
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
255 universe_gene = NULL
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
256 }
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
257 } else {
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
258 universe_gene = NULL
0
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
259 }
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
260
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
261 ##enrichGO : GO over-representation test
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
262 for (onto in ontology) {
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
263 if (go_represent) {
6
5e16cec55146 planemo upload commit 2da0aec067fd35a8ec102ce27ec4bac8f54b1c30-dirty
proteore
parents: 5
diff changeset
264 ggo<-repartition.GO(gene, orgdb, onto, level, readable=TRUE)
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
265 if (is.list(ggo)){ggo <- as.data.frame(apply(ggo, c(1,2), function(x) gsub("^$|^ $", NA, x)))} #convert "" and " " to NA
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
266 output_path = paste("cluster_profiler_GGO_",onto,".tsv",sep="")
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
267 write.table(ggo, output_path, sep="\t", row.names = FALSE, quote = FALSE )
0
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
268 }
7
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
269
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
270 if (go_enrich) {
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
271 ego<-enrich.GO(gene, universe_gene, orgdb, onto, pval_cutoff, qval_cutoff,plot)
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
272 if (is.list(ego)){ego <- as.data.frame(apply(ego, c(1,2), function(x) gsub("^$|^ $", NA, x)))} #convert "" and " " to NA
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
273 output_path = paste("cluster_profiler_EGO_",onto,".tsv",sep="")
4609346d8108 planemo upload commit 9af2cf12c26c94e7206751ccf101a3368f92d0ba
proteore
parents: 6
diff changeset
274 write.table(ego, output_path, sep="\t", row.names = FALSE, quote = FALSE )
0
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
275 }
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
276 }
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
277 }
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
278
bd052861852b planemo upload commit ffa3be72b850aecbfbd636de815967c06a8f643f-dirty
proteore
parents:
diff changeset
279 clusterProfiler()