comparison goprofiles.R @ 11:3ddc1f78773d draft

planemo upload commit 4ba1ebe7b3f5e3fabf78b5fed7ed0b92e2cbf9e5-dirty
author proteore
date Fri, 28 Jun 2019 05:11:15 -0400
parents 2138e0035e57
children 601027649251
comparison
equal deleted inserted replaced
10:2138e0035e57 11:3ddc1f78773d
63 #genes = as.vector(file[,ncol]) 63 #genes = as.vector(file[,ncol])
64 64
65 # Extract Gene Entrez ID 65 # Extract Gene Entrez ID
66 if (id_type == "Entrez") { 66 if (id_type == "Entrez") {
67 id = select(package, ids, "ENTREZID", multiVals = "first") 67 id = select(package, ids, "ENTREZID", multiVals = "first")
68 genes_ids = id$ENTREZID[which( ! is.na(id$ENTREZID))]
69 } else { 68 } else {
70 genes_ids = c()
71 id = select(package, ids, "ENTREZID", "UNIPROT", multiVals = "first") 69 id = select(package, ids, "ENTREZID", "UNIPROT", multiVals = "first")
72 if (duplicate == "TRUE") { 70 }
73 id = unique(id) 71 if (duplicate) { id = unique(id) }
74 } 72 genes_ids = id$ENTREZID[which( ! is.na(id$ENTREZID))]
75 print(id[[1]]) 73 NAs = id$UNIPROT[which(is.na(id$ENTREZID))] # IDs that have NA ENTREZID
76 genes_ids = id$ENTREZID[which( ! is.na(id$ENTREZID))] 74
77 # IDs that have NA ENTREZID
78 NAs = id$UNIPROT[which(is.na(id$ENTREZID))]
79 #print("IDs unable to convert to ENTREZID: ")
80 #print(NAs)
81 }
82 # Create basic profiles 75 # Create basic profiles
83 profile.CC = basicProfile(genes_ids, onto='CC', level=level, orgPackage=species, empty.cats=F, ord=T, na.rm=T) 76 profile.CC = basicProfile(genes_ids, onto='CC', level=level, orgPackage=species, empty.cats=F, ord=T, na.rm=T)
84 profile.BP = basicProfile(genes_ids, onto='BP', level=level, orgPackage=species, empty.cats=F, ord=T, na.rm=T) 77 profile.BP = basicProfile(genes_ids, onto='BP', level=level, orgPackage=species, empty.cats=F, ord=T, na.rm=T)
85 profile.MF = basicProfile(genes_ids, onto='MF', level=level, orgPackage=species, empty.cats=F, ord=T, na.rm=T) 78 profile.MF = basicProfile(genes_ids, onto='MF', level=level, orgPackage=species, empty.cats=F, ord=T, na.rm=T)
86 profile.ALL = basicProfile(genes_ids, onto='ANY', level=level, orgPackage=species, empty.cats=F, ord=T, na.rm=T) 79 profile.ALL = basicProfile(genes_ids, onto='ANY', level=level, orgPackage=species, empty.cats=F, ord=T, na.rm=T)
161 #load("/home/dchristiany/proteore_project/ProteoRE/tools/goprofiles/args.Rda") 154 #load("/home/dchristiany/proteore_project/ProteoRE/tools/goprofiles/args.Rda")
162 155
163 id_type = args$id_type 156 id_type = args$id_type
164 input_type = args$input_type 157 input_type = args$input_type
165 if (input_type == "text") { 158 if (input_type == "text") {
166 input = strsplit(args$input, "[ \t\n]+")[[1]] 159 input = unlist(strsplit(strsplit(args$input, "[ \t\n]+")[[1]],";"))
167 } else if (input_type == "file") { 160 } else if (input_type == "file") {
168 filename = args$input 161 filename = args$input
169 ncol = args$ncol 162 ncol = args$ncol
170 # Check ncol 163 # Check ncol
171 if (! as.numeric(gsub("c", "", ncol)) %% 1 == 0) { 164 if (! as.numeric(gsub("c", "", ncol)) %% 1 == 0) {
176 header = str2bool(args$header) 169 header = str2bool(args$header)
177 # Get file content 170 # Get file content
178 file = read_file(filename, header) 171 file = read_file(filename, header)
179 # Extract Protein IDs list 172 # Extract Protein IDs list
180 input = unlist(strsplit(as.character(file[,ncol]),";")) 173 input = unlist(strsplit(as.character(file[,ncol]),";"))
181 input = input [which(!is.na(input))] 174 }
182 } 175 input = input [which(!is.na(gsub("NA",NA,input)))]
183 176
184 if (! any(check_ids(input,id_type))){ 177 if (! any(check_ids(input,id_type))){
185 stop(paste(id_type,"not found in your ids list, please check your IDs in input or the selected column of your input file")) 178 stop(paste(id_type,"not found in your ids list, please check your IDs in input or the selected column of your input file"))
186 } 179 }
187 180
189 onto_pos = as.integer(gsub("BP",3,gsub("MF",2,gsub("CC",1,ontoopt)))) 182 onto_pos = as.integer(gsub("BP",3,gsub("MF",2,gsub("CC",1,ontoopt))))
190 plotopt = args$plot_opt 183 plotopt = args$plot_opt
191 level = args$level 184 level = args$level
192 per = as.logical(args$per) 185 per = as.logical(args$per)
193 title = args$title 186 title = args$title
194 duplicate = args$duplicate 187 duplicate = str2bool(args$duplicate)
195 text_output = args$text_output 188 text_output = args$text_output
196 species=args$species 189 species=args$species
197 190
198 profiles = getprofile(input, id_type, level, duplicate,species) 191 profiles = getprofile(input, id_type, level, duplicate,species)
199 192