changeset 0:2a8acb4c0afc draft default tip

planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 450b58f2de19b05cd05c27ae77376fb1b71f5646
author bebatut
date Thu, 21 Apr 2016 04:21:13 -0400
parents
children
files compute_wilcoxon_test.R compute_wilcoxon_test.xml test-data/input_file.txt test-data/two_sided_two_columns_test_output.txt tool_dependencies.xml
diffstat 5 files changed, 209 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/compute_wilcoxon_test.R	Thu Apr 21 04:21:13 2016 -0400
@@ -0,0 +1,55 @@
+library('getopt')
+
+option_specification = matrix(c(
+  'input_file', 'a', 2, 'character',
+  'output_file', 'b', 2, 'character',
+  'column1_id', 'c', 2, 'integer',
+  'column2_id', 'd', 2, 'integer',
+  'alternative','e',2,'character',
+  'paired','f',2,'logical',
+  'exact','g',2,'logical',
+  'correct','h',2, 'logical',
+  'mu','i',2,'integer',
+  'header','y',2,'logical'
+), byrow=TRUE, ncol=4);
+
+options = getopt(option_specification);
+
+header = TRUE
+if(!is.null(options$header)) header = options$header
+
+data = read.table(options$input_file, sep = '\t', h = header)
+
+column1_id = 1
+if(!is.null(options$column1_id)) column1_id = options$column1_id
+x = data[,column1_id]
+y = NULL
+if(!is.null(options$column2_id)) y = data[,options$column2_id]
+
+alternative = 'two.sided'
+if(!is.null(options$alternative)) alternative = options$alternative
+
+mu = 0
+if(!is.null(options$mu)) mu = options$mu
+
+paired = FALSE
+if(!is.null(options$paired)) paired = options$paired
+
+exact = NULL
+if(!is.null(options$exact)) exact = options$exact
+
+correct = TRUE
+if(!is.null(options$correct)) correct = options$correct
+
+test = wilcox.test(x = x, y = y, alternative = alternative, mu = mu, 
+    paired = paired, exact = exact, correct = correct)
+
+m = matrix(ncol = 2, nrow = 6)
+m[1,] = c('statistic',test$statistic)
+m[2,] = c('parameter',test$parameter)
+m[3,] = c('p.value',test$p.value)
+m[4,] = c('null.value',test$null.value)
+m[5,] = c('alternative',test$alternative)
+m[6,] = c('method',test$method)
+write.table(m, file = options$output_file, sep = "\t", quote = FALSE, 
+    row.names = FALSE, col.names = FALSE)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/compute_wilcoxon_test.xml	Thu Apr 21 04:21:13 2016 -0400
@@ -0,0 +1,94 @@
+<tool id="compute_wilcoxon_test" name="Compute Wilcoxon test" version="0.1.0">
+    <description>with R</description>
+
+    <requirements>
+        <requirement type="package" version="3.2.1">R</requirement>
+        <requirement type="package" version="1.20.0">r-getopt</requirement>
+    </requirements>
+
+    <stdio>
+        <exit_code range="1:" />
+        <exit_code range=":-1" />
+    </stdio>
+
+    <version_command></version_command>
+
+    <command><![CDATA[
+        Rscript $__tool_directory__/compute_wilcoxon_test.R
+            --input_file $input_file
+	    --header $header
+            --output_file $output_file
+            --column1_id $column1_id
+
+            #if $add_column.add_column_test == "true":
+                --column2_id $add_column.column2_id
+                --paired $add_column.paired
+            #end if
+
+            --alternative "$alternative"
+            --mu $mu
+            
+            --exact $exact
+            --correct $correct
+            
+    ]]></command>
+
+    <inputs>
+        <param name="input_file" type="data" format="tabular,tsv,csv" label="Input file" help="File in tabular format with tab-separated columns and header in first line (--input_file)"/>
+
+        <param name="header" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="false" label="Header in first line?" help="(--header)"/>
+  
+        <param name="column1_id" type="data_column" data_ref="input_file" label="Column containing data" multiple="false" numerical="true" help="(--column1_id)"/>
+
+        <conditional name="add_column">
+            <param name="add_column_test" label="Add a new column?" type="select" help="(--alternative)">
+                <option value="true" selected="true">Yes</option>
+                <option value="false">No</option>
+            </param>
+            <when value="true">
+                <param name="column2_id" type="data_column" data_ref="input_file" label="Column containing data" multiple="false" numerical="true" help="(--column2_id)"/>
+                <param name="paired" type="boolean" truevalue="TRUE" falsevalue="FALSE" label="Paired datasets?" checked="false" help="(--paired)"/>
+            </when>
+            <when value="false" />
+        </conditional>
+
+        <param name="alternative" label="Alternative hypothesis" type="select" help="(--alternative)">
+            <option value="two.sided" selected="true">Two sided</option>
+            <option value="greater">Greater</option>
+            <option value="less">Less</option>
+        </param>
+        <param name="mu" type="integer" value="0" label="Optional parameter used to form the null hypothesis" help="(--mu)"/>
+        
+        <param name="exact" type="boolean" truevalue="TRUE" falsevalue="FALSE" label="Compute an exact p-value?" checked="false" help="(--exact)"/>
+        <param name="correct" type="boolean" truevalue="TRUE" falsevalue="FALSE" label="Apply a continuity correction in the normal approximation for the p-value?" checked="true" help="(--correct)"/>
+    </inputs>
+
+    <outputs>
+        <data name="output_file" format="txt"  label="${tool.name} on ${on_string}: Wilcox test result" />
+    </outputs>
+
+    <tests>
+        <test>
+            <param name="input_file" ftype="tabular" value="input_file.txt"/>
+            <param name="header" value="TRUE"/>
+            <param name="column1_id" value="3"/>
+            <param name="add_column_test" value="true"/>
+            <param name="column2_id" value="5"/>
+            <param name="paired" value="FALSE"/>
+            <param name="alternative" value="two.sided"/>
+            <param name="mu" value="0"/>
+            <param name="exact" value="FALSE"/>
+            <param name="correct" value="TRUE"/>
+            <output name="output_file" file="two_sided_two_columns_test_output.txt"/>
+        </test>
+    </tests>
+
+    <help><![CDATA[
+**What it does**
+
+This tool compute a Wilcoxon test with R's wilcox.test function.
+    ]]></help>
+
+    <citations>
+    </citations>
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/input_file.txt	Thu Apr 21 04:21:13 2016 -0400
@@ -0,0 +1,45 @@
+GO:0000160	phosphorelay signal transduction system	2.24188560912	0.728693934232	2.27727933683	0.749521959908
+GO:0000746	conjugation	0.0994837099605	0.041803266954	0.0153440543392	0.0123485894543
+GO:0000902	cell morphogenesis	8.11126977702e-06	0.0501066555955	4.12343924065e-05	0.0426587635694
+GO:0002376	immune system process	0.085489980287	0.0	0.0275218309404	0.00149679872174
+GO:0005975	carbohydrate metabolic process	3.93695964707	3.53466664758	3.82956086917	4.33023870198
+GO:0006091	generation of precursor metabolites and energy	1.07156623777	1.0906071495	1.17950701314	1.06085609403
+GO:0006259	DNA metabolic process	7.83088558928	5.06907560378	7.58396051319	4.27934754543
+GO:0006412	translation	4.20183364466	2.74183619419	5.03906963774	3.04486279969
+GO:0006520	cellular amino acid metabolic process	6.18101744575	3.82270833632	6.27139841544	3.78690076599
+GO:0006629	lipid metabolic process	2.22295409952	0.98294942091	2.54389716799	1.18920658442
+GO:0006790	sulfur compound metabolic process	1.45678041362	0.428626648151	1.37494525671	0.342766907277
+GO:0006807	nitrogen compound metabolic process	6.29928644413	17.1144292852	6.08311422603	15.9266867986
+GO:0006810	transport	4.61323317367	8.81648079483	3.18084754012	8.87713901893
+GO:0006811	ion transport	2.84530948465	1.81185666634	2.90259750702	1.89008258587
+GO:0006935	chemotaxis	0.00293746066557	0.132567894519	0.0120376618448	0.0841949280975
+GO:0006950	response to stress	1.94565920911	1.44736653735	2.0733055949	1.4305653783
+GO:0007154	cell communication	0.721015903582	1.15674793488	0.709743568009	1.18696138634
+GO:0007165	signal transduction	0.118779041384	1.12181643785	0.0745544227737	1.16488360519
+GO:0009056	catabolic process	2.8187943392	1.45624257348	2.98058889328	1.56752246133
+GO:0009058	biosynthetic process	19.0004196424	14.2414568152	19.1704185155	13.7907550227
+GO:0009117	nucleotide metabolic process	3.44391451912	1.42846917009	3.70529753166	1.38640981601
+GO:0009306	protein secretion	0.0636027918464	0.176375427696	0.0756710986973	0.150802471215
+GO:0009404	toxin metabolic process	0.03091092162	0.014316187313	0.0362106070805	0.0130969888151
+GO:0009405	pathogenesis	1.43460861083	0.541438204177	0.368367078771	0.122737495182
+GO:0015979	photosynthesis	0.232009822868	0.0798843252065	0.167653248687	0.0703495399215
+GO:0016032	viral process	0.00123963164065	0.0128845685817	0.00242960292976	0.0134711884956
+GO:0016043	cellular component organization	2.24641451781	0.697770969635	2.38025522473	0.654101041398
+GO:0016049	cell growth	0.000155245877721	0.0	0.0420673650671	0.0
+GO:0016070	RNA metabolic process	2.37121554921	5.80206439421	2.38215565603	5.74546189338
+GO:0016310	phosphorylation	2.50223255226	0.848090936421	1.9906050825	0.866646459884
+GO:0019538	protein metabolic process	2.25811799055	5.09713533092	1.9377105334	5.82741162339
+GO:0022900	electron transport chain	0.3062712212	0.360767920287	0.237876158003	0.278030362562
+GO:0030031	cell projection assembly	0.0642099836606	0.0355041445362	0.0413581109156	0.0142195878565
+GO:0032196	transposition	0.722175839172	0.299208314842	2.633467426	0.919782814506
+GO:0042592	homeostatic process	0.991966070514	0.362485862765	0.715433785162	0.325553721977
+GO:0043934	sporulation	0.0768001451434	0.0160341297906	0.0916709924953	0.00673559424781
+GO:0044281	small molecule metabolic process	6.91812462508	7.90797554796	7.74857313252	8.04978352548
+GO:0045333	cellular respiration	0.338287752671	0.686031696039	0.175606167551	0.522008554205
+GO:0046034	ATP metabolic process	1.36885696133	0.377661021316	1.37948961282	0.321811725173
+GO:0048870	cell motility	0.322410195844	0.136003779473	0.153352240024	0.0722205383237
+GO:0051186	cofactor metabolic process	4.61150014233	1.60312665531	4.55766657384	1.41821678885
+GO:0051301	cell division	1.32835952519	0.120828620922	1.26384039624	0.0942983194692
+GO:0055114	oxidation-reduction process	0.131832728405	7.08823066241	0.300772862677	7.94837541209
+GO:0071554	cell wall organization or biogenesis	0.00369855395882	0.456400051538	0.0153325835178	0.403387255508
+GO:0071941	nitrogen cycle metabolic process	0.5367849148	0.0612732816996	0.267403669367	0.0160905862586
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/two_sided_two_columns_test_output.txt	Thu Apr 21 04:21:13 2016 -0400
@@ -0,0 +1,6 @@
+statistic	981
+parameter	parameter
+p.value	0.916918193979449
+null.value	0
+alternative	two.sided
+method	Wilcoxon rank sum test with continuity correction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool_dependencies.xml	Thu Apr 21 04:21:13 2016 -0400
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<tool_dependency>
+    <package name="R" version="3.2.1">
+        <repository changeset_revision="d0bf97420fb5" name="package_r_3_2_1" owner="iuc" toolshed="https://toolshed.g2.bx.psu.edu" />
+    </package>
+    <package name="r-getopt" version="1.20.0">
+        <repository changeset_revision="712cb82311a8" name="package_r_3_2_1_getopt_1_20_0" owner="bebatut" toolshed="https://toolshed.g2.bx.psu.edu" />
+    </package>
+</tool_dependency>