Mercurial > repos > caleb-easterly > peca
view peca.R @ 13:4dcfde657dc3 draft default tip
planemo upload for repository https://github.com/caleb-easterly/galaxytools/peca
author | caleb-easterly |
---|---|
date | Thu, 08 Mar 2018 18:35:49 -0500 |
parents | 19bb06146c2e |
children |
line wrap: on
line source
#!/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', stringsAsFactors=FALSE) # read 2nd and 3rd argument, which are path to files with group 1 and 2 column indices group1_ind_file <- as.vector(as.matrix(read.csv(args[2], header = FALSE)[1, ])) group2_ind_file <- as.vector(as.matrix(read.csv(args[3], header = FALSE)[1, ])) # test type ttype <- args[4] # paired or not pair <- args[5] == "true" # output file name out_file <- args[6] # 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(df = quant_file, samplenames1 = group1_names, samplenames2 = group2_names, test = ttype, paired = pair, 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()