comparison get_expression_profiles.R @ 12:56c93d1fc8fd draft

planemo upload commit 4ba1ebe7b3f5e3fabf78b5fed7ed0b92e2cbf9e5-dirty
author proteore
date Fri, 28 Jun 2019 05:10:08 -0400
parents 2c0bab71a436
children
comparison
equal deleted inserted replaced
11:6e85f07c20ee 12:56c93d1fc8fd
67 res <- res.Cancer 67 res <- res.Cancer
68 } 68 }
69 return(res) 69 return(res)
70 } 70 }
71 71
72 clean_ids <- function(ids){
73
74 ids = gsub(" ","",ids)
75 ids = ids[which(ids!="")]
76 ids = ids[which(ids!="NA")]
77 ids = ids[!is.na(ids)]
78
79 return(ids)
80 }
72 81
73 main <- function() { 82 main <- function() {
74 args <- commandArgs(TRUE) 83 args <- commandArgs(TRUE)
75 if(length(args)<1) { 84 if(length(args)<1) {
76 args <- c("--help") 85 args <- c("--help")
107 #load("/home/dchristiany/proteore_project/ProteoRE/tools/Get_expression_profiles/args.rda") 116 #load("/home/dchristiany/proteore_project/ProteoRE/tools/Get_expression_profiles/args.rda")
108 117
109 # Extract input 118 # Extract input
110 input_type = args$input_type 119 input_type = args$input_type
111 if (input_type == "list") { 120 if (input_type == "list") {
112 list_id = strsplit(args$input, "[ \t\n]+")[[1]] 121 ids = unlist(strsplit(strsplit(args$input, "[ \t\n]+")[[1]],";"))
113 } else if (input_type == "file") { 122 } else if (input_type == "file") {
114 filename = args$input 123 filename = args$input
115 column_number = as.numeric(gsub("c", "" ,args$column_number)) 124 column_number = as.numeric(gsub("c", "" ,args$column_number))
116 header = str2bool(args$header) 125 header = str2bool(args$header)
117 file = read_file(filename, header) 126 file = read_file(filename, header)
118 list_id = sapply(strsplit(file[,column_number], ";"), "[", 1) 127 ids = unlist(strsplit(file[,column_number], ";"))
119 } 128 }
120 input = list_id 129 #filter ids
121 130 ids = clean_ids(ids)
131
122 # Read reference file 132 # Read reference file
123 reference_file = read_file(args$ref_file, TRUE) 133 reference_file = read_file(args$ref_file, TRUE)
124 134
125 # Extract other options 135 # Extract other options
126 atlas = args$atlas 136 atlas = args$atlas
128 if (atlas=="normal") { 138 if (atlas=="normal") {
129 tissue = strsplit(args$tissue, ",")[[1]] 139 tissue = strsplit(args$tissue, ",")[[1]]
130 level = strsplit(args$level, ",")[[1]] 140 level = strsplit(args$level, ",")[[1]]
131 reliability = strsplit(args$reliability, ",")[[1]] 141 reliability = strsplit(args$reliability, ",")[[1]]
132 # Calculation 142 # Calculation
133 res = annot.HPAnorm(input, reference_file, tissue, level, reliability, not_mapped_option) 143 res = annot.HPAnorm(ids, reference_file, tissue, level, reliability, not_mapped_option)
134 } else if (atlas=="cancer") { 144 } else if (atlas=="cancer") {
135 cancer = strsplit(args$cancer, ",")[[1]] 145 cancer = strsplit(args$cancer, ",")[[1]]
136 # Calculation 146 # Calculation
137 res = annot.HPAcancer(input, reference_file, cancer, not_mapped_option) 147 res = annot.HPAcancer(ids, reference_file, cancer, not_mapped_option)
138 } 148 }
139 149
140 # Write output 150 # Write output
141 output = args$output 151 output = args$output
142 res <- apply(res, c(1,2), function(x) gsub("^$|^ $", NA, x)) 152 res <- apply(res, c(1,2), function(x) gsub("^$|^ $", NA, x))