annotate GO_prof_comp.R @ 0:a0ea9e00bd66 draft

planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
author proteore
date Thu, 28 Feb 2019 05:53:47 -0500
parents
children 67a4f68f1c1c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
1 options(warn=-1) #TURN OFF WARNINGS !!!!!!
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
2 suppressMessages(library(clusterProfiler,quietly = TRUE))
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
3
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
4 #return the number of character from the longest description found (from the 10 first)
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
5 max_str_length_10_first <- function(vector){
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
6 vector <- as.vector(vector)
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
7 nb_description = length(vector)
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
8 if (nb_description >= 10){nb_description=10}
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
9 return(max(nchar(vector[1:nb_description])))
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
10 }
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
11
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
12 str2bool <- function(x){
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
13 if (any(is.element(c("t","true"),tolower(x)))){
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
14 return (TRUE)
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
15 }else if (any(is.element(c("f","false"),tolower(x)))){
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
16 return (FALSE)
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
17 }else{
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
18 return(NULL)
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
19 }
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
20 }
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
21
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
22 get_args <- function(){
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
23
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
24 ## Collect arguments
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
25 args <- commandArgs(TRUE)
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
26
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
27 ## Default setting when no arguments passed
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
28 if(length(args) < 1) {
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
29 args <- c("--help")
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
30 }
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
31
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
32 ## Help section
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
33 if("--help" %in% args) {
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
34 cat("Selection and Annotation HPA
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
35 Arguments:
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
36 --inputtype1: type of input (list of id or filename)
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
37 --inputtype2: type of input (list of id or filename)
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
38 --input1: input1
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
39 --input2: input2
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
40 --column1: the column number which you would like to apply...
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
41 --column2: the column number which you would like to apply...
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
42 --header1: true/false if your file contains a header
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
43 --header2: true/false if your file contains a header
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
44 --ont: ontology to use
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
45 --lev: ontology level
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
46 --org: organism db package
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
47 --list_name1: name of the first list
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
48 --list_name2: name of the second list \n")
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
49
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
50 q(save="no")
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
51 }
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
52
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
53 parseArgs <- function(x) strsplit(sub("^--", "", x), "=")
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
54 argsDF <- as.data.frame(do.call("rbind", parseArgs(args)))
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
55 args <- as.list(as.character(argsDF$V2))
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
56 names(args) <- argsDF$V1
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
57
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
58 return(args)
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
59 }
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
60
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
61 get_ids=function(inputtype, input, ncol, header) {
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
62
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
63 if (inputtype == "text") {
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
64 ids = strsplit(input, "[ \t\n]+")[[1]]
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
65 } else if (inputtype == "file") {
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
66 header=str2bool(header)
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
67 ncol=get_cols(ncol)
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
68 csv = read.csv(input,header=header, sep="\t", as.is=T)
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
69 ids=csv[,ncol]
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
70 }
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
71
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
72 ids = unlist(strsplit(ids,";"))
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
73 ids = ids[which(!is.na(ids))]
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
74
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
75 return(ids)
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
76 }
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
77
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
78 str2bool <- function(x){
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
79 if (any(is.element(c("t","true"),tolower(x)))){
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
80 return (TRUE)
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
81 }else if (any(is.element(c("f","false"),tolower(x)))){
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
82 return (FALSE)
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
83 }else{
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
84 return(NULL)
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
85 }
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
86 }
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
87
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
88 check_ids <- function(vector,type) {
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
89 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})$"
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
90 entrez_id = "^([0-9]+|[A-Z]{1,2}_[0-9]+|[A-Z]{1,2}_[A-Z]{1,4}[0-9]+)$"
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
91 if (type == "entrez")
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
92 return(grepl(entrez_id,vector))
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
93 else if (type == "uniprot") {
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
94 return(grepl(uniprot_pattern,vector))
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
95 }
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
96 }
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
97
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
98 make_dotplot<-function(res.cmp,ontology) {
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
99
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
100 res.cmp@compareClusterResult$Description <- sapply(as.vector(res.cmp@compareClusterResult$Description), function(x) {ifelse(nchar(x)>50, substr(x,1,50),x)},USE.NAMES = FALSE)
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
101 output_path= paste("GO_profiles_comp_",ontology,".png",sep="")
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
102 png(output_path,height = 720, width = 600)
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
103 p <- dotplot(res.cmp, showCategory=30)
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
104 print(p)
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
105 dev.off()
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
106 }
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
107
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
108 get_cols <-function(input_cols) {
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
109 input_cols <- gsub("c","",gsub("C","",gsub(" ","",input_cols)))
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
110 if (grepl(":",input_cols)) {
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
111 first_col=unlist(strsplit(input_cols,":"))[1]
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
112 last_col=unlist(strsplit(input_cols,":"))[2]
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
113 cols=first_col:last_col
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
114 } else {
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
115 cols = as.integer(unlist(strsplit(input_cols,",")))
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
116 }
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
117 return(cols)
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
118 }
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
119
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
120 #to check
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
121 cmp.GO <- function(l,fun="groupGO",orgdb, ontology, level=3, readable=TRUE) {
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
122 cmpGO<-compareCluster(geneClusters = l,
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
123 fun=fun,
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
124 OrgDb = orgdb,
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
125 ont=ontology,
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
126 level=level,
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
127 readable=TRUE)
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
128
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
129 return(cmpGO)
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
130 }
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
131
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
132 check_ids <- function(vector,type) {
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
133 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})$"
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
134 entrez_id = "^([0-9]+|[A-Z]{1,2}_[0-9]+|[A-Z]{1,2}_[A-Z]{1,4}[0-9]+)$"
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
135 if (type == "entrez")
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
136 return(grepl(entrez_id,vector))
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
137 else if (type == "uniprot") {
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
138 return(grepl(uniprot_pattern,vector))
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
139 }
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
140 }
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
141
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
142 main = function() {
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
143
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
144 #to get the args of the command line
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
145 args=get_args()
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
146
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
147 #save(args,file="/home/dchristiany/proteore_project/ProteoRE/tools/GO_terms_profiles_comparison/args.rda")
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
148 #load("/home/dchristiany/proteore_project/ProteoRE/tools/GO_terms_profiles_comparison/args.rda")
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
149
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
150 ids1<-get_ids(args$inputtype1, args$input1, args$column1, args$header1)
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
151 ids2<-get_ids(args$inputtype2, args$input2, args$column2, args$header2)
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
152 ont = strsplit(args$ont, ",")[[1]]
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
153 lev=as.integer(args$lev)
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
154 org=args$org
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
155
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
156 #load annot package
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
157 suppressMessages(library(args$org, character.only = TRUE, quietly = TRUE))
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
158
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
159 # Extract OrgDb
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
160 if (args$org=="org.Hs.eg.db") {
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
161 orgdb<-org.Hs.eg.db
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
162 } else if (args$org=="org.Mm.eg.db") {
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
163 orgdb<-org.Mm.eg.db
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
164 } else if (args$org=="org.Rn.eg.db") {
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
165 orgdb<-org.Rn.eg.db
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
166 }
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
167
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
168 for(ontology in ont) {
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
169 liste = list("l1"=ids1,"l2"=ids2)
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
170 names(liste) = c(args$list_name1,args$list_name2)
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
171 res.cmp<-cmp.GO(l=liste,fun="groupGO",orgdb, ontology, level=lev, readable=TRUE)
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
172 make_dotplot(res.cmp,ontology)
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
173 output_path = paste("GO_profiles_comp_",ontology,".tsv",sep="")
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
174 write.table(res.cmp@compareClusterResult, output_path, sep="\t", row.names=F, quote=F)
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
175 }
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
176
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
177 } #end main
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
178
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
179 main()
a0ea9e00bd66 planemo upload commit e5e4a3efd1cb1498724c0e93f8ec9606d0ed3045-dirty
proteore
parents:
diff changeset
180