Mercurial > repos > proteore > proteore_expression_rnaseq_abbased
diff add_expression_HPA.R @ 12:f8d3a8a2f2e5 draft
"planemo upload commit 58e072579a4be282c00b54ebb88fbc59e189a7ed-dirty"
| author | proteore |
|---|---|
| date | Thu, 23 Jan 2020 10:44:39 +0000 |
| parents | 07858c6dbbff |
| children | 8ee4cfdc1a92 |
line wrap: on
line diff
--- a/add_expression_HPA.R Wed Jan 22 15:33:21 2020 +0000 +++ b/add_expression_HPA.R Thu Jan 23 10:44:39 2020 +0000 @@ -1,7 +1,11 @@ # Read file and return file content as data.frame read_file <- function(path,header){ - file <- read.csv(path,header=header, sep="\t",stringsAsFactors = FALSE, quote="\"", check.names = F) - return(file) + file <- try(read.csv(path,header=header, sep="\t",stringsAsFactors = FALSE, quote="\"", check.names = F),silent=TRUE) + if (inherits(file,"try-error")){ + stop("File not found !") + }else{ + return(file) + } } #convert a string to boolean @@ -142,6 +146,13 @@ } } +convert_to_previous_header <- function(options){ + header = c('Gene','description','Evidence','Antibody','RNA tissue specificity','Reliability (IH)','Reliability (IF)','Subcellular location','RNA tissue specific NX') + names(header) = c('Gene','description','Evidence','Antibody','RNA tissue category','Reliability (IH)','Reliability (IF)','Subcellular location','RNA TS TPM') + options = names(header[which(header %in% options)]) + return(options) +} + main = function() { args = get_args() @@ -176,6 +187,7 @@ # Add expression output = args$output options = strsplit(args$select, ",")[[1]] + if (tail(unlist(strsplit(args$atlas,"/")),1) == "HPA_full_atlas_23-10-2018.tsv"){ options = convert_to_previous_header(options)} res = add_expression(ids, protein_atlas, options) # Write output
