Mercurial > repos > caleb-easterly > peca
comparison build_peca.R @ 2:36b7a5891000 draft
planemo upload for repository https://github.com/caleb-easterly/galaxytools/peca
author | caleb-easterly |
---|---|
date | Thu, 22 Feb 2018 11:28:22 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1:34c1ae5e99ac | 2:36b7a5891000 |
---|---|
1 #!/usr/bin/env Rscript | |
2 | |
3 library(PECA) | |
4 | |
5 # Set up R error handling to go to stderr | |
6 options(show.error.messages=F, error=function(){cat(geterrmessage(),file=stderr());q("no",1,F)}) | |
7 | |
8 # Avoid crashing Galaxy with an UTF8 error on German LC settings | |
9 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8") | |
10 | |
11 main <- function() { | |
12 args <- commandArgs(trailingOnly = TRUE) | |
13 | |
14 # read first argument, which is quant file (proteins in rows, samples in columns) | |
15 quant_file <- read.delim(args[1], | |
16 na.strings = c("0", "NA"), | |
17 sep = '\t') | |
18 | |
19 # read 2nd and 3rd argument, which are path to files with group 1 and 2 column indices | |
20 group1_ind_file <- read.csv(args[2], header = FALSE)[1, ] | |
21 group2_ind_file <- read.csv(args[3], header = FALSE)[1, ] | |
22 | |
23 # read 4th argument, which is output file name | |
24 out_file <- args[4] | |
25 | |
26 # get vectors of column names | |
27 df_names <- colnames(quant_file) | |
28 group1_names <- df_names[group1_ind_file] | |
29 group2_names <- df_names[group2_ind_file] | |
30 | |
31 # run PECA_df | |
32 # id column is first column (hard-coded) | |
33 results <- PECA_df(quant_file, group1_names, group2_names, id = df_names[1]) | |
34 | |
35 # put add protein names column | |
36 results$prot <- row.names(results) | |
37 results <- results[, c("prot", "slr", "t", "score", "n", "p", "p.fdr")] | |
38 | |
39 # write to output | |
40 write.table(results, file=out_file, | |
41 quote=FALSE, | |
42 sep ='\t', | |
43 row.names = FALSE) | |
44 } | |
45 | |
46 main() |