Mercurial > repos > proteore > proteore_tissue_specific_expression_data
comparison RetrieveFromHPA.R @ 0:8ff819779f7e draft
planemo upload commit 08f1831e097df5d74bf60ff5955e7e9c8e524cc8-dirty
| author | proteore |
|---|---|
| date | Wed, 14 Mar 2018 11:36:19 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:8ff819779f7e |
|---|---|
| 1 | |
| 2 | |
| 3 select.HPAimmunohisto<-function(hpa_ref, tissue, level, reliability) { | |
| 4 load(hpa_ref) | |
| 5 if (tissue == "tissue") { | |
| 6 tissue <- unique(HPA.normal$Tissue) | |
| 7 } | |
| 8 if (level == "level") { | |
| 9 level <- unique(HPA.normal$Level) | |
| 10 } | |
| 11 if (reliability == "reliability") { | |
| 12 reliability <- unique(HPA.normal$Reliability) | |
| 13 } | |
| 14 res.imm <- subset(HPA.normal, Tissue%in%tissue & Level%in%level & Reliability%in%reliability) | |
| 15 return(res.imm) | |
| 16 } | |
| 17 | |
| 18 | |
| 19 | |
| 20 select.HPARNAseq<-function(hpa_ref, sample) { | |
| 21 load(hpa_ref) | |
| 22 res.rna <- subset(HPA.rnaTissue, Sample%in%sample, select = -c(Unit)) | |
| 23 colnames(res.rna)[which(colnames(res.rna) == 'Value')] <- 'Value (TPM unit)' | |
| 24 return(res.rna) | |
| 25 } | |
| 26 | |
| 27 main <- function() { | |
| 28 args <- commandArgs(TRUE) | |
| 29 if(length(args)<1) { | |
| 30 args <- c("--help") | |
| 31 } | |
| 32 | |
| 33 # Help section | |
| 34 if("--help" %in% args) { | |
| 35 cat("Selection and Annotation HPA | |
| 36 Arguments: | |
| 37 --data_source: immuno/rnaseq | |
| 38 --hpe_ref: path to reference file (HPA.normal.RData/HPA.rnaTissue.RData) | |
| 39 if immuno: | |
| 40 --tissue: list of tissues | |
| 41 --level: Not detected, Low, Medium, High | |
| 42 --reliability: Supported, Approved, Enhanced, Uncertain | |
| 43 if rnaseq: | |
| 44 --sample: Sample tissues | |
| 45 --output: output filename \n") | |
| 46 q(save="no") | |
| 47 } | |
| 48 | |
| 49 # Parse arguments | |
| 50 parseArgs <- function(x) strsplit(sub("^--", "", x), "=") | |
| 51 argsDF <- as.data.frame(do.call("rbind", parseArgs(args))) | |
| 52 args <- as.list(as.character(argsDF$V2)) | |
| 53 names(args) <- argsDF$V1 | |
| 54 | |
| 55 # Extract options | |
| 56 data_source = args$data_source | |
| 57 hpa_ref = args$hpa_ref | |
| 58 if (data_source == "immuno") { | |
| 59 tissue = strsplit(args$tissue, ",")[[1]] | |
| 60 level = strsplit(args$level, ",")[[1]] | |
| 61 reliability = strsplit(args$reliability, ",")[[1]] | |
| 62 # Calculation | |
| 63 res = select.HPAimmunohisto(hpa_ref, tissue, level, reliability) | |
| 64 } | |
| 65 else if (data_source == "rnaseq") { | |
| 66 sample = strsplit(args$sample, ",")[[1]] | |
| 67 # Calculation | |
| 68 res = select.HPARNAseq(hpa_ref, sample) | |
| 69 } | |
| 70 | |
| 71 # Write output | |
| 72 output = args$output | |
| 73 write.table(res, output, sep = "\t", quote = FALSE, row.names = FALSE) | |
| 74 } | |
| 75 | |
| 76 main() |
