Mercurial > repos > proteore > proteore_retrieve_from_hpa
comparison Build_tissue-specific_expression_dataset.R @ 1:cfcc7a780991 draft default tip
planemo upload commit c599cfc156c77626df2b674bdfbd437b9f664ab9
| author | proteore |
|---|---|
| date | Thu, 13 Dec 2018 03:59:41 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 0:6fc8d303bcf1 | 1:cfcc7a780991 |
|---|---|
| 1 | |
| 2 | |
| 3 select_HPAimmunohisto<-function(hpa_ref, tissue, level, reliability) { | |
| 4 HPA.normal = read.table(hpa_ref,header=TRUE,sep="\t",stringsAsFactors = FALSE) | |
| 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 HPA.rnaTissue = read.table(hpa_ref,header=TRUE,sep="\t",stringsAsFactors = FALSE) | |
| 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 normal_tissue.tsv/rna_tissue.tsv) | |
| 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() |
