Mercurial > repos > caleb-easterly > peca
changeset 0:f50bb34c1a37 draft
planemo upload for repository https://github.com/caleb-easterly/galaxytools/peca
author | caleb-easterly |
---|---|
date | Wed, 21 Feb 2018 16:29:34 -0500 |
parents | |
children | 34c1ae5e99ac |
files | peca.R peca.xml test-data/group1.txt test-data/group2.txt test-data/out.tab test-data/test.tab |
diffstat | 6 files changed, 117 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/peca.R Wed Feb 21 16:29:34 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()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/peca.xml Wed Feb 21 16:29:34 2018 -0500 @@ -0,0 +1,30 @@ +<tool id="peca" name="PECA: Probe-level expression change averaging" version="0.1.0"> + <requirements> + <requirement type="package" version="1.14.0">bioconductor-peca</requirement> + </requirements> + <command detect_errors="exit_code"><![CDATA[ + ## write group 1 to file + echo '$group1' > group1.txt && + echo '$group2' > group2.txt && + cat group1.txt && + Rscript --vanilla '$__tool_directory__/peca.R' '$input' '$group1' '$group2' '$output' + ]]></command> + <inputs> + <param name="input" type="data" format="tabular"/> + <param name="group1" type="data_column" data_ref="input" multiple="true"/> + <param name="group2" type="data_column" data_ref="input" multiple="true"/> + </inputs> + <outputs> + <data format="tabular" name="output"/> + </outputs> + <tests> + <test> + <param name="input" value="test.tab" ftype="tabular"/> + <param name="group1" value="2,3,4"/> + <param name="group2" value="4,5,6"/> + <output name="output" file="out.tab" ftype="tabular"/> + </test> + </tests> + <help><![CDATA[ + ]]></help> +</tool>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/group1.txt Wed Feb 21 16:29:34 2018 -0500 @@ -0,0 +1,3 @@ +2 +3 +4
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/group2.txt Wed Feb 21 16:29:34 2018 -0500 @@ -0,0 +1,3 @@ +5 +6 +7
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/out.tab Wed Feb 21 16:29:34 2018 -0500 @@ -0,0 +1,4 @@ +prot slr t score n p p.fdr +a -0.111780781397145 -0.765478419573781 0.486657928314213 10 0.465522239154437 0.471387593353045 +b -0.0722462577076137 -0.761219732287275 0.488931365477738 10 0.471387593353045 0.471387593353045 +c -0.118399562851212 -1.87027001064663 0.134789006543826 10 0.00228835744682698 0.00686507234048095
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/test.tab Wed Feb 21 16:29:34 2018 -0500 @@ -0,0 +1,31 @@ +id A1 A2 A3 B1 B2 B3 +a 54.2489063734367 49.6390576576586 55.1240726937295 49.6144780991222 50.8330349763798 53.9514564709181 +a 60.3240661014468 42.2917145283503 59.0254299559973 53.405354969144 66.559743175806 49.9652107364224 +a 56.3635394881666 39.0147151139471 54.3682844939657 53.7991057027463 54.06753635305 48.6838484867888 +a 43.4176092858866 47.1876317055487 44.8487665751097 57.6965465932599 54.7681375214397 51.8326362250669 +a 50.0551194571448 54.2119721603887 49.2509701326719 47.8977896731825 48.8221265606082 54.4935355307123 +a 49.8505658819176 40.3299420230831 48.7279482143961 55.7828322268111 54.0747354590324 54.5984495122319 +a 44.4753502143705 43.7899054516062 53.4932583201426 57.6546852980842 52.017781728326 50.3053654532735 +a 59.4620167107059 53.4648876489429 44.7651094148184 48.4178737005459 54.6258851880828 46.1245327523094 +a 49.6179461331221 45.3094403486909 50.8916567199704 59.1464413710981 60.0390757911603 50.8562740751764 +a 46.887154804165 50.9510907893787 55.0989810208619 48.2730059942602 57.6733204553657 64.1399697781665 +b 43.7343463751954 46.3207426732163 48.2222516204486 49.5643102909139 50.6434003578977 41.9768075843575 +b 59.3746925324757 45.2600349715115 46.4319107034971 43.3647332795063 58.0205082314023 52.0813651368811 +b 57.5390314413131 39.27264669353 55.2446550784507 49.4255140747867 52.949041959725 54.6454658654733 +b 45.8948784060825 46.2305745583783 52.4810269007389 49.8644917420684 49.8623114124141 49.4526454470161 +b 52.3842608595992 53.9145069152949 55.3151221876286 58.5746717923502 54.4750458440023 58.0920256016475 +b 44.9334101981099 42.4876151894126 55.0331502351991 47.3331761490083 47.9044196647419 59.334366547243 +b 57.9587874641605 56.0037071555751 57.419404123409 59.1536543270164 57.1445603630244 40.8404059053939 +b 55.2984221223832 43.1361387542313 54.4834238275705 59.6634323192618 51.7794901922063 56.5759881835152 +b 48.9423537862295 47.4638767071427 48.2194814941879 51.7775721002268 54.6930699559996 51.9582668855074 +b 54.3118247934725 39.8728288965565 52.6890807019854 49.0590745676018 62.1038198899922 53.9137630946883 +c 41.7378981728219 42.1299586143566 56.2922128023528 46.6200805390419 57.8697908417515 43.9440844795336 +c 48.2165209169497 41.86126017411 44.6506966044542 56.023500646768 53.5923002494182 55.5790515614602 +c 47.3390756225799 50.6105245971985 46.7635281876903 49.9940888411278 50.7179013415607 49.3092549972827 +c 48.3265503600379 40.912793826118 55.1625115343392 47.0734086325775 58.1109095582307 50.1587083236597 +c 44.0575082382113 43.1555584797624 46.220563477779 50.0771152407653 62.1537891209805 51.0866411965226 +c 49.6692945076024 48.3588269901328 48.1081311356118 51.5803868735586 53.5273654780519 54.9831676591611 +c 46.9501612503767 47.6985425078114 57.2693928588069 49.6957244391895 47.9997391642407 52.241811304542 +c 49.1276885847386 36.7303899690904 32.4087180261451 51.211378081021 53.5484109656343 53.5542555368538 +c 49.7627390723602 43.5336839023677 46.5137096514578 51.149647420808 48.1099599398199 45.5035113563574 +c 43.9082401716298 42.2573039778399 48.5483133832217 47.9882282287463 50.2797890577276 52.1769388638489