annotate goprofiles.R @ 0:6eeb2fb0c4bd draft default tip

planemo upload
author lnguyen
date Sat, 16 Sep 2017 09:17:07 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
1 # Load necessary libraries
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
2 library("org.Hs.eg.db", quietly=TRUE)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
3 library("goProfiles", quietly=TRUE)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
4
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
5 # Read file and return file content as data.frame?
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
6 readfile = function(filename, header) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
7 if (header == "true") {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
8 # Read only the first two lines of the files as data (without headers):
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
9 headers <- read.table(filename, nrows = 1, header = FALSE, sep = "\t", stringsAsFactors = FALSE, fill = TRUE)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
10 #print("header")
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
11 #print(headers)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
12 # Create the headers names with the two (or more) first rows, sappy allows to make operations over the columns (in this case paste) - read more about sapply here :
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
13 #headers_names <- sapply(headers, paste, collapse = "_")
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
14 #print(headers_names)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
15 #Read the data of the files (skipping the first 2 rows):
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
16 file <- read.table(filename, skip = 1, header = FALSE, sep = "\t", stringsAsFactors = FALSE, fill = TRUE)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
17 #print(file[1,])
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
18 #And assign the headers of step two to the data:
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
19 names(file) <- headers
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
20 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
21 else {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
22 file <- read.table(filename, header = FALSE, sep = "\t", stringsAsFactors = FALSE, fill = TRUE)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
23 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
24 return(file)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
25 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
26
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
27 #filename = "/Users/LinCun/Documents/ProteoRE/usecase1/Check/HPA.Selection.134.txt"
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
28 #test = readfile(filename)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
29 #str(test)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
30 #str(test$Gene.names)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
31 getprofile = function(ids, id_type, level) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
32
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
33 # Check if level is number
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
34 if (! as.numeric(level) %% 1 == 0) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
35 stop("Please enter an integer for level")
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
36 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
37 else {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
38 level = as.numeric(level)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
39 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
40 #genes = as.vector(file[,ncol])
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
41
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
42 # Extract Gene Entrez ID
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
43 if (id_type == "Entrez") {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
44 id = select(org.Hs.eg.db, ids, "ENTREZID", multiVals = "first")
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
45 genes_ids = id$ENTREZID[which( ! is.na(id$ENTREZID))]
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
46 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
47 else {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
48 genes_ids = c()
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
49 id = select(org.Hs.eg.db, ids, "ENTREZID", "UNIPROT", multiVals = "first")
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
50 #print(id[[1]][1])
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
51 genes_ids = id$ENTREZID[which( ! is.na(id$ENTREZID))]
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
52 # IDs that have NA ENTREZID
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
53 NAs = id$UNIPROT[which(is.na(id$ENTREZID))]
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
54 print("IDs unable to convert to ENTREZID: ")
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
55 print(NAs)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
56 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
57 #print(genes_ids)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
58 # Convert Protein IDs into entrez ids
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
59
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
60 # for (i in 1:length(id$UNIPROT)) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
61 # print(i)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
62 # if (is.na(id[[2]][i])) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
63 # print(id[[2]][i])
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
64 # }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
65 # }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
66 # a = id[which(id$ENTREZID == "NA"),]
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
67 # print(a)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
68 # print(a$UNIPROT)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
69 #print(id[[1]][which(is.na(id$ENTREZID))])
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
70 #print(genes_ids)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
71 # for (gene in genes) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
72 # #id = as.character(mget(gene, org.Hs.egALIAS2EG, ifnotfound = NA))
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
73 # id = select(org.Hs.eg.db, genes, "ENTREZID", "UNIPROT")
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
74 # print(id)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
75 # genes_ids = append(genes_ids, id$ENTREZID)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
76 # }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
77 #print(genes_ids)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
78
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
79 # Create basic profiles
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
80 profile.CC = basicProfile(genes_ids, onto='CC', level=level, orgPackage="org.Hs.eg.db", empty.cats=F, ord=T, na.rm=T)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
81 profile.BP = basicProfile(genes_ids, onto='BP', level=level, orgPackage="org.Hs.eg.db", empty.cats=F, ord=T, na.rm=T)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
82 profile.MF = basicProfile(genes_ids, onto='MF', level=level, orgPackage="org.Hs.eg.db", empty.cats=F, ord=T, na.rm=T)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
83 profile.ALL = basicProfile(genes_ids, onto='ANY', level=level, orgPackage="org.Hs.eg.db", empty.cats=F, ord=T, na.rm=T)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
84
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
85 # Print profile
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
86 # printProfiles(profile)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
87
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
88 return(c(profile.CC, profile.MF, profile.BP, profile.ALL))
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
89 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
90
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
91 # Plot profiles to PNG
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
92 plotPNG = function(profile.CC = NULL, profile.BP = NULL, profile.MF = NULL, profile.ALL = NULL, per = TRUE, title = TRUE) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
93 if (!is.null(profile.CC)) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
94 png("profile.CC.png")
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
95 plotProfiles(profile.CC, percentage=per, multiplePlots=FALSE, aTitle=title)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
96 dev.off()
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
97 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
98 if (!is.null(profile.BP)) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
99 png("profile.BP.png")
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
100 plotProfiles(profile.BP, percentage=per, multiplePlots=FALSE, aTitle=title)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
101 dev.off()
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
102 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
103 if (!is.null(profile.MF)) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
104 png("profile.MF.png")
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
105 plotProfiles(profile.MF, percentage=per, multiplePlots=FALSE, aTitle=title)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
106 dev.off()
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
107 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
108 if (!is.null(profile.ALL)) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
109 png("profile.ALL.png")
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
110 plotProfiles(profile.ALL, percentage=per, multiplePlots=T, aTitle=title)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
111 dev.off()
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
112 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
113 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
114
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
115 # Plot profiles to JPEG
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
116 plotJPEG = function(profile.CC = NULL, profile.BP = NULL, profile.MF = NULL, profile.ALL = NULL, per = TRUE, title = TRUE) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
117 if (!is.null(profile.CC)) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
118 jpeg("profile.CC.jpeg")
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
119 plotProfiles(profile.CC, percentage=per, multiplePlots=FALSE, aTitle=title)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
120 dev.off()
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
121 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
122 if (!is.null(profile.BP)) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
123 jpeg("profile.BP.jpeg")
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
124 plotProfiles(profile.BP, percentage=per, multiplePlots=FALSE, aTitle=title)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
125 dev.off()
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
126 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
127 if (!is.null(profile.MF)) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
128 jpeg("profile.MF.jpeg")
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
129 plotProfiles(profile.MF, percentage=per, multiplePlots=FALSE, aTitle=title)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
130 dev.off()
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
131 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
132 if (!is.null(profile.ALL)) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
133 jpeg("profile.ALL.jpeg")
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
134 plotProfiles(profile.ALL, percentage=per, multiplePlots=FALSE, aTitle=title)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
135 dev.off()
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
136 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
137 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
138
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
139 # Plot profiles to PDF
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
140 plotPDF = function(profile.CC = NULL, profile.BP = NULL, profile.MF = NULL, profile.ALL = NULL, per = TRUE, title = TRUE) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
141 if (!is.null(profile.CC)) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
142 pdf("profile.CC.pdf")
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
143 plotProfiles(profile.CC, percentage=per, multiplePlots=FALSE, aTitle=title)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
144 dev.off()
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
145 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
146 if (!is.null(profile.BP)) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
147 pdf("profile.BP.pdf")
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
148 plotProfiles(profile.BP, percentage=per, multiplePlots=FALSE, aTitle=title)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
149 dev.off()
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
150 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
151 if (!is.null(profile.MF)) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
152 pdf("profile.MF.pdf")
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
153 plotProfiles(profile.MF, percentage=per, multiplePlots=FALSE, aTitle=title)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
154 dev.off()
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
155 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
156 if (!is.null(profile.ALL)) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
157 #print("all")
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
158 pdf("profile.ALL.pdf")
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
159 plotProfiles(profile.ALL, percentage=per, multiplePlots=FALSE, aTitle=title)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
160 dev.off()
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
161 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
162 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
163
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
164 goprofiles = function() {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
165 args = commandArgs(trailingOnly = TRUE)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
166 #print(args)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
167 # arguments: filename.R inputfile ncol "CC,MF,BP,ALL" "PNG,JPEG,PDF" level "TRUE"(percentage) "Title"
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
168 if (length(args) != 8) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
169 stop("Not enough/Too many arguments", call. = FALSE)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
170 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
171 else {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
172 input_type = args[2]
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
173 if (input_type == "text") {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
174 input = strsplit(args[1], "\\s+")[[1]]
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
175 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
176 else if (input_type == "file") {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
177 filename = strsplit(args[1], ",")[[1]][1]
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
178 ncol = strsplit(args[1], ",")[[1]][2]
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
179 # Check ncol
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
180 if (! as.numeric(gsub("c", "", ncol)) %% 1 == 0) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
181 stop("Please enter an integer for level")
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
182 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
183 else {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
184 ncol = as.numeric(gsub("c", "", ncol))
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
185 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
186 header = strsplit(args[1], ",")[[1]][3]
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
187 # Get file content
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
188 file = readfile(filename, header)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
189 # Extract Protein IDs list
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
190 input = c()
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
191 for (row in as.character(file[,ncol])) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
192 input = c(input, strsplit(row, ";")[[1]][1])
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
193 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
194 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
195 id_type = args[3]
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
196 ontoopt = strsplit(args[4], ",")[[1]]
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
197 #print(ontoopt)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
198 #plotopt = strsplit(args[3], ",")
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
199 plotopt = args[5]
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
200 level = args[6]
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
201 per = as.logical(args[7])
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
202 title = args[8]
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
203
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
204 profiles = getprofile(input, id_type, level)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
205 profile.CC = profiles[1]
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
206 #print(profile.CC)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
207 profile.MF = profiles[2]
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
208 #print(profile.MF)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
209 profile.BP = profiles[3]
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
210 #print(profile.BP)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
211 profile.ALL = profiles[-3:-1]
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
212 #print(profile.ALL)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
213 #c(profile.ALL, profile.CC, profile.MF, profile.BP)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
214 if ("CC" %in% ontoopt) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
215 if (grepl("PNG", plotopt)) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
216 plotPNG(profile.CC=profile.CC, per=per, title=title)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
217 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
218 if (grepl("JPEG", plotopt)) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
219 plotJPEG(profile.CC = profile.CC, per=per, title=title)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
220 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
221 if (grepl("PDF", plotopt)) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
222 plotPDF(profile.CC = profile.CC, per=per, title=title)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
223 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
224 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
225 if ("MF" %in% ontoopt) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
226 if (grepl("PNG", plotopt)) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
227 plotPNG(profile.MF = profile.MF, per=per, title=title)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
228 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
229 if (grepl("JPEG", plotopt)) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
230 plotJPEG(profile.MF = profile.MF, per=per, title=title)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
231 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
232 if (grepl("PDF", plotopt)) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
233 plotPDF(profile.MF = profile.MF, per=per, title=title)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
234 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
235 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
236 if ("BP" %in% ontoopt) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
237 if (grepl("PNG", plotopt)) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
238 plotPNG(profile.BP = profile.BP, per=per, title=title)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
239 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
240 if (grepl("JPEG", plotopt)) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
241 plotJPEG(profile.BP = profile.BP, per=per, title=title)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
242 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
243 if (grepl("PDF", plotopt)) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
244 plotPDF(profile.BP = profile.BP, per=per, title=title)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
245 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
246 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
247
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
248 #if (grepl("PNG", plotopt)) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
249 # plotPNG(profile.ALL = profile.ALL, per=per, title=title)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
250 #}
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
251 #if (grepl("JPEG", plotopt)) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
252 # plotJPEG(profile.ALL = profile.ALL, per=per, title=title)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
253 #}
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
254 #if (grepl("PDF", plotopt)) {
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
255 # plotPDF(profile.ALL = profile.ALL, per=per, title=title)
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
256 #}
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
257 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
258
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
259 }
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
260
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
261 goprofiles()
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
262
6eeb2fb0c4bd planemo upload
lnguyen
parents:
diff changeset
263 #Rscript go.R ../proteinGroups_Maud.txt "1" "CC" "PDF" 2 "TRUE" "Title"