Mercurial > repos > proteore > proteore_expression_levels_by_tissue
annotate get_expression_profiles.R @ 10:48b767deb90b draft
planemo upload commit b052261cf5cd6c2413e301a19d5c95d9794f1e81-dirty
author | proteore |
---|---|
date | Wed, 13 Mar 2019 09:23:41 -0400 |
parents | 2c0bab71a436 |
children | 56c93d1fc8fd |
rev | line source |
---|---|
8
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
1 # Read file and return file content as data.frame |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
2 read_file <- function(path,header){ |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
3 file <- try(read.csv(path,header=header, sep="\t",stringsAsFactors = FALSE, quote="\"", check.names = F),silent=TRUE) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
4 if (inherits(file,"try-error")){ |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
5 stop("File not found !") |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
6 }else{ |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
7 return(file) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
8 } |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
9 } |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
10 |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
11 str2bool <- function(x){ |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
12 if (any(is.element(c("t","true"),tolower(x)))){ |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
13 return (TRUE) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
14 }else if (any(is.element(c("f","false"),tolower(x)))){ |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
15 return (FALSE) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
16 }else{ |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
17 return(NULL) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
18 } |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
19 } |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
20 |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
21 # input has to be a list of IDs in ENSG format |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
22 # tissue is one of unique(HPA.normal.tissue$Tissue) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
23 # level is one, or several, or 0 (=ALL) of "Not detected", "Medium", "High", "Low" |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
24 # reliability is one, or several, or 0 (=ALL) of "Approved", "Supported", "Uncertain" |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
25 annot.HPAnorm<-function(input, HPA_normal_tissue, tissue, level, reliability, not_mapped_option) { |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
26 dat <- subset(HPA_normal_tissue, Gene %in% input) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
27 res.Tissue<-subset(dat, Tissue %in% tissue) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
28 res.Level<-subset(res.Tissue, Level %in% level) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
29 res.Rel<-subset(res.Level, Reliability %in% reliability) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
30 |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
31 if (not_mapped_option) { |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
32 if (length(setdiff(intersect(input, unique(dat$Gene)), unique(res.Rel$Gene)))>0) { |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
33 not_match_IDs <- matrix(setdiff(intersect(input, unique(dat$Gene)), unique(res.Rel$Gene)), ncol = 1, nrow = length(setdiff(intersect(input, unique(dat$Gene)), unique(res.Rel$Gene)))) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
34 not.match <- matrix("no match", ncol = ncol(HPA_normal_tissue) - 1, nrow = length(not_match_IDs)) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
35 not.match <- cbind(not_match_IDs, unname(not.match)) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
36 colnames(not.match) <- colnames(HPA_normal_tissue) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
37 res <- rbind(res.Rel, not.match) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
38 } else { |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
39 res <- res.Rel |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
40 } |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
41 |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
42 if (length(setdiff(input, unique(dat$Gene)))>0) { |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
43 not.mapped <- matrix(ncol = ncol(HPA_normal_tissue) - 1, nrow = length(setdiff(input, unique(dat$Gene)))) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
44 not.mapped <- cbind(matrix(setdiff(input, unique(dat$Gene)), ncol = 1, nrow = length(setdiff(input, unique(dat$Gene)))), unname(not.mapped)) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
45 colnames(not.mapped) <- colnames(HPA_normal_tissue) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
46 res <- rbind(res, not.mapped) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
47 } |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
48 |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
49 } else { |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
50 res <- res.Rel |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
51 } |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
52 |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
53 return(res) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
54 |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
55 } |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
56 |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
57 annot.HPAcancer<-function(input, HPA_cancer_tissue, cancer, not_mapped_option) { |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
58 dat <- subset(HPA_cancer_tissue, Gene %in% input) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
59 res.Cancer<-subset(dat, Cancer %in% cancer) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
60 |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
61 if (not_mapped_option) { |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
62 not.mapped <- matrix(ncol=ncol(HPA_cancer_tissue)-1, nrow=length(setdiff(input, unique(dat$Gene)))) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
63 not.mapped <- cbind(matrix(setdiff(input, unique(dat$Gene)), ncol = 1, nrow = length(setdiff(input, unique(dat$Gene)))), unname(not.mapped)) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
64 colnames(not.mapped) <- colnames(HPA_cancer_tissue) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
65 res <- rbind(res.Cancer, not.mapped) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
66 } else { |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
67 res <- res.Cancer |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
68 } |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
69 return(res) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
70 } |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
71 |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
72 |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
73 main <- function() { |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
74 args <- commandArgs(TRUE) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
75 if(length(args)<1) { |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
76 args <- c("--help") |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
77 } |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
78 |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
79 # Help section |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
80 if("--help" %in% args) { |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
81 cat("Selection and Annotation HPA |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
82 Arguments: |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
83 --ref_file: HPA normal/cancer tissue file path |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
84 --input_type: type of input (list of id or filename) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
85 --input: list of IDs in ENSG format |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
86 --column_number: the column number which you would like to apply... |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
87 --header: true/false if your file contains a header |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
88 --atlas: normal/cancer |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
89 if normal: |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
90 --tissue: list of tissues |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
91 --level: Not detected, Low, Medium, High |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
92 --reliability: Supportive, Uncertain |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
93 if cancer: |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
94 --cancer: Cancer tissues |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
95 --not_mapped: true/false if your output file should contain not-mapped and not-match IDs |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
96 --output: output filename \n") |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
97 q(save="no") |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
98 } |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
99 |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
100 # Parse arguments |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
101 parseArgs <- function(x) strsplit(sub("^--", "", x), "=") |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
102 argsDF <- as.data.frame(do.call("rbind", parseArgs(args))) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
103 args <- as.list(as.character(argsDF$V2)) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
104 names(args) <- argsDF$V1 |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
105 |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
106 #save(args,file = "/home/dchristiany/proteore_project/ProteoRE/tools/Get_expression_profiles/args.rda") |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
107 #load("/home/dchristiany/proteore_project/ProteoRE/tools/Get_expression_profiles/args.rda") |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
108 |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
109 # Extract input |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
110 input_type = args$input_type |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
111 if (input_type == "list") { |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
112 list_id = strsplit(args$input, "[ \t\n]+")[[1]] |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
113 } else if (input_type == "file") { |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
114 filename = args$input |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
115 column_number = as.numeric(gsub("c", "" ,args$column_number)) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
116 header = str2bool(args$header) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
117 file = read_file(filename, header) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
118 list_id = sapply(strsplit(file[,column_number], ";"), "[", 1) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
119 } |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
120 input = list_id |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
121 |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
122 # Read reference file |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
123 reference_file = read_file(args$ref_file, TRUE) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
124 |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
125 # Extract other options |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
126 atlas = args$atlas |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
127 not_mapped_option = str2bool(args$not_mapped) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
128 if (atlas=="normal") { |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
129 tissue = strsplit(args$tissue, ",")[[1]] |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
130 level = strsplit(args$level, ",")[[1]] |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
131 reliability = strsplit(args$reliability, ",")[[1]] |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
132 # Calculation |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
133 res = annot.HPAnorm(input, reference_file, tissue, level, reliability, not_mapped_option) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
134 } else if (atlas=="cancer") { |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
135 cancer = strsplit(args$cancer, ",")[[1]] |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
136 # Calculation |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
137 res = annot.HPAcancer(input, reference_file, cancer, not_mapped_option) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
138 } |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
139 |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
140 # Write output |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
141 output = args$output |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
142 res <- apply(res, c(1,2), function(x) gsub("^$|^ $", NA, x)) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
143 write.table(res, output, sep = "\t", quote = FALSE, row.names = FALSE) |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
144 } |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
145 |
2c0bab71a436
planemo upload commit 5e13878e9679f3f5ba8e482b9108249a43f3355e-dirty
proteore
parents:
diff
changeset
|
146 main() |