Mercurial > repos > caleb-easterly > peca
changeset 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 | 34c1ae5e99ac |
children | 784c107c5861 |
files | build_peca.R peca.xml |
diffstat | 2 files changed, 48 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/build_peca.R Thu Feb 22 11:28:22 2018 -0500 @@ -0,0 +1,46 @@ +#!/usr/bin/env Rscript + +library(PECA) + +# Set up R error handling to go to stderr +options(show.error.messages=F, error=function(){cat(geterrmessage(),file=stderr());q("no",1,F)}) + +# Avoid crashing Galaxy with an UTF8 error on German LC settings +loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8") + +main <- function() { + args <- commandArgs(trailingOnly = TRUE) + + # read first argument, which is quant file (proteins in rows, samples in columns) + quant_file <- read.delim(args[1], + na.strings = c("0", "NA"), + sep = '\t') + + # read 2nd and 3rd argument, which are path to files with group 1 and 2 column indices + group1_ind_file <- read.csv(args[2], header = FALSE)[1, ] + group2_ind_file <- read.csv(args[3], header = FALSE)[1, ] + + # read 4th argument, which is output file name + out_file <- args[4] + + # get vectors of column names + df_names <- colnames(quant_file) + group1_names <- df_names[group1_ind_file] + group2_names <- df_names[group2_ind_file] + + # run PECA_df + # id column is first column (hard-coded) + results <- PECA_df(quant_file, group1_names, group2_names, id = df_names[1]) + + # put add protein names column + results$prot <- row.names(results) + results <- results[, c("prot", "slr", "t", "score", "n", "p", "p.fdr")] + + # write to output + write.table(results, file=out_file, + quote=FALSE, + sep ='\t', + row.names = FALSE) +} + +main()
--- a/peca.xml Wed Feb 21 16:57:49 2018 -0500 +++ b/peca.xml Thu Feb 22 11:28:22 2018 -0500 @@ -4,11 +4,10 @@ <requirement type="package" version="0.7">r-dbi</requirement> </requirements> <command detect_errors="exit_code"><![CDATA[ - ## write group 1 to file + ## write groups to file echo '$group1' > group1.txt && echo '$group2' > group2.txt && - cat group1.txt && - Rscript --vanilla '$__tool_directory__/peca.R' '$input' '$group1' '$group2' '$output' + Rscript --vanilla '$__tool_directory__/peca.R' '$input' group1.txt group2.txt '$output' ]]></command> <inputs> <param name="input" type="data" format="tabular"/>