changeset 0:3d1d965b6423 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vegan/vegan_rarefaction commit 0e04a4c237677c1f5be1950babcf8591097996a9
author iuc
date Wed, 23 Dec 2015 13:55:57 -0500
parents
children dd2705a31239
files test-data/vegan_in.tabular test-data/vegan_output_richness.tabular test-data/vegan_output_slope.tabular test-data/vegan_output_species_count.tabular test-data/vegan_output_species_frequency.tabular test-data/vegan_output_species_probabilities.tabular tool_dependencies.xml vegan_macros.xml vegan_rarefaction.xml
diffstat 9 files changed, 269 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/vegan_in.tabular	Wed Dec 23 13:55:57 2015 -0500
@@ -0,0 +1,22 @@
+  3.26	4226	74	P	976	        Bacteroidetes
+  0.01	10	2	P	1090	        Chlorobi
+  0.90	1163	19	P	1239	      Firmicutes
+  0.31	402	12	P	1224	      Proteobacteria
+  0.21	275	0	P	201174	      Actinobacteria
+  0.02	30	14	P	1117	      Cyanobacteria
+  0.01	15	0	P	57723	        Acidobacteria
+  0.01	8	1	P	65842	        Fibrobacteres
+  0.01	12	0	P	200795	      Chloroflexi
+  0.01	8	0	P	142182	      Gemmatimonadetes
+  0.01	8	0	P	200783	      Aquificae
+  0.01	7	0	P	544448	      Tenericutes
+  0.00	6	0	P	203682	      Planctomycetes
+  0.00	5	0	P	40117	      Nitrospirae
+  0.00	5	1	P	74201	        Verrucomicrobia
+  0.00	5	0	P	200918	      Thermotogae
+  0.00	2	0	P	32066	      Fusobacteria
+  0.00	1	0	P	1297	      Deinococcus-Thermus
+  0.00	1	0	P	74152	      Elusimicrobia
+  0.00	1	0	P	200930	      Deferribacteres
+  0.00	1	0	P	203691	      Spirochaetes
+  0.00	1	0	P	28890	      Euryarchaeota
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/vegan_output_richness.tabular	Wed Dec 23 13:55:57 2015 -0500
@@ -0,0 +1,2 @@
+""	"x"
+"V2"	22
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/vegan_output_slope.tabular	Wed Dec 23 13:55:57 2015 -0500
@@ -0,0 +1,2 @@
+"x"
+"V2"	0.000807519626095124
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/vegan_output_species_count.tabular	Wed Dec 23 13:55:57 2015 -0500
@@ -0,0 +1,2 @@
+""	"x"
+"V2"	22
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/vegan_output_species_frequency.tabular	Wed Dec 23 13:55:57 2015 -0500
@@ -0,0 +1,23 @@
+""	"x"
+"        Bacteroidetes"	1
+"        Chlorobi"	1
+"      Firmicutes"	1
+"      Proteobacteria"	1
+"      Actinobacteria"	1
+"      Cyanobacteria"	1
+"        Acidobacteria"	1
+"        Fibrobacteres"	1
+"      Chloroflexi"	1
+"      Gemmatimonadetes"	1
+"      Aquificae"	1
+"      Tenericutes"	1
+"      Planctomycetes"	1
+"      Nitrospirae"	1
+"        Verrucomicrobia"	1
+"      Thermotogae"	1
+"      Fusobacteria"	1
+"      Deinococcus-Thermus"	1
+"      Elusimicrobia"	1
+"      Deferribacteres"	1
+"      Spirochaetes"	1
+"      Euryarchaeota"	1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/vegan_output_species_probabilities.tabular	Wed Dec 23 13:55:57 2015 -0500
@@ -0,0 +1,23 @@
+""	"x"
+"        Bacteroidetes"	1
+"        Chlorobi"	1
+"      Firmicutes"	1
+"      Proteobacteria"	1
+"      Actinobacteria"	1
+"      Cyanobacteria"	1
+"        Acidobacteria"	1
+"        Fibrobacteres"	1
+"      Chloroflexi"	1
+"      Gemmatimonadetes"	1
+"      Aquificae"	1
+"      Tenericutes"	1
+"      Planctomycetes"	1
+"      Nitrospirae"	1
+"        Verrucomicrobia"	1
+"      Thermotogae"	1
+"      Fusobacteria"	1
+"      Deinococcus-Thermus"	0.99983850129199
+"      Elusimicrobia"	0.99983850129199
+"      Deferribacteres"	0.99983850129199
+"      Spirochaetes"	0.99983850129199
+"      Euryarchaeota"	0.99983850129199
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool_dependencies.xml	Wed Dec 23 13:55:57 2015 -0500
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<tool_dependency>
+    <package name="vegan" version="2.3-0">
+        <repository changeset_revision="1ab514ba46e7" name="package_r_vegan_2_3_0" owner="iuc" toolshed="https://toolshed.g2.bx.psu.edu" />
+    </package>
+    <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>
+</tool_dependency>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vegan_macros.xml	Wed Dec 23 13:55:57 2015 -0500
@@ -0,0 +1,49 @@
+<macros>
+    <xml name="requirements">
+        <requirements>
+            <requirement type="package" version="3.2.1">R</requirement>
+            <requirement type="package" version="2.3-0">vegan</requirement>
+            <yield />
+        </requirements>
+    </xml>
+
+    <xml name="version_command">
+        <version_command><![CDATA[Rscript -e 'library(vegan)' 2>&1 > /dev/null | grep 'This is vegan']]></version_command>
+    </xml>
+
+    <xml name="stdio">
+        <stdio>
+            <exit_code range="1:" />
+            <exit_code range=":-1" />
+        </stdio>
+    </xml>
+
+    <xml name="params_load_tabular_file">
+        <param name="input_abundance" type="data" format="tabular" label="File with abundance values for community" help="Rows are samples; columns are species/phyla/community classifier"/>
+        <param name="species_column" label="Group name column" type="data_column" data_ref="input_abundance" value="6" help="Species, phylum, etc"/>
+        <param name="sample_columns" label="Sample count columns" type="data_column" multiple="True" value="2" data_ref="input_abundance" help="Select each column that contains counts"/>
+        <param name="header" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="False" label="Input has a header line"/>
+    </xml>
+
+    <token name="@RSCRIPT_LOAD_TABULAR_FILE@"><![CDATA[
+#set $int_species_column = int( str( $species_column ) )
+#set $fixed_sample_columns = []
+#for $sample_col in map( int, str( $sample_columns ).split( "," ) ):
+#assert $sample_col != $int_species_column, "Sample label column and sample count columns must not be the same."
+#silent $fixed_sample_columns.append( str( $sample_col if $sample_col < $int_species_column else $sample_col-1 ) )
+#end for
+input_abundance <- read.delim("${input_abundance}", header=${header}, sep="\t", row.names=${ species_column })
+input_abundance <- t( input_abundance[ c( ${ ",".join( $fixed_sample_columns ) } )] )
+
+]]>
+    </token>
+
+    <token name="@RSCRIPT_PREAMBLE@"><![CDATA[
+options(bitmapType='cairo')## No X11, so we'll use cairo
+library(vegan)
+]]>
+    </token>
+
+    <token name="@VERSION@">2.3-0</token>
+
+</macros>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vegan_rarefaction.xml	Wed Dec 23 13:55:57 2015 -0500
@@ -0,0 +1,137 @@
+<tool id="vegan_rarefaction" name="Vegan Rarefaction" version="0.0.2">
+    <description>
+        curve and statistics
+    </description>
+    <macros>
+        <import>vegan_macros.xml</import>
+    </macros>
+    <expand macro="requirements" />
+    <expand macro="stdio" />
+    <expand macro="version_command" />
+    <command><![CDATA[
+        #if "output_r_script" in str( $include_outputs ).split( "," ):
+            cp "${vegan_rarefaction_script}" "${output_r_script}" &&
+        #end if
+        Rscript "${vegan_rarefaction_script}"
+    ]]>
+    </command>
+    <configfiles>
+        <configfile name="vegan_rarefaction_script"><![CDATA[
+@RSCRIPT_PREAMBLE@
+@RSCRIPT_LOAD_TABULAR_FILE@
+#set $include_files = str( $include_outputs ).split( "," )
+
+#if str( $sample_size ) == '':
+raremax <- min(rowSums(input_abundance))
+raremax_offset <- -1
+sprintf("Automatically determining subsampling size, will apply offset to slope calculation and species probabilities.")
+#else:
+raremax = $sample_size
+raremax_offset <- 0
+#end if
+sprintf("Using sample size: %i", raremax)
+Srare <- rarefy(input_abundance, sample=raremax, se=FALSE, MARGIN=1)
+#if "output_richness" in $include_files:
+write.table(Srare, "${output_richness}", col.names=NA, sep = "\t")
+#end if
+
+#if "output_slope" in $include_files:
+write.table(rareslope(input_abundance, sample=raremax+raremax_offset), "${output_slope}", sep = "\t")
+#end if
+
+S <- specnumber(input_abundance)
+#if "output_species_count" in $include_files:
+write.table(S, "${ output_species_count }", col.names=NA, sep="\t" )
+#end if
+
+#if "output_species_frequency" in $include_files:
+write.table(specnumber(input_abundance, MARGIN=2), "${ output_species_frequency }", col.names=NA, sep="\t" )
+#end if
+
+#if "output_species_probabilities" in $include_files:
+write.table(drarefy(input_abundance, sample=raremax+raremax_offset), "${ output_species_probabilities }", col.names=NA, sep="\t" )
+#end if
+
+#if "output_plot" in $include_files:
+png('${output_plot}', width=1020, height=800, units='px')
+rarecurve(input_abundance, step = ${step_size}, sample = raremax, xlab = "${xlab}", ylab = "${ylab}", label="${label}", col = "blue", cex = 0.6)
+invisible(dev.off())
+#end if
+    ]]>
+        </configfile>
+    </configfiles>
+    <inputs>
+        <expand macro="params_load_tabular_file" />
+        <param name="sample_size" type="integer" value="" min="1" optional="True" label="Subsample size for rarefying community" help="Leave empty to subsample by community size for the smallest sample."/>
+        <param name="step_size" type="integer" value="1" min="1" label="Step size for sample sizes"/>
+        <param name="xlab" type="text" value="Sample Size" label="X-axis label"/>
+        <param name="ylab" type="text" value="Species" label="Y-axis label"/>
+        <param name="label" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="True" label="Label rarefaction curves by rownames of X"/>
+        <param name="include_outputs" type="select" multiple="True" label="Datasets to create">
+            <option value="output_species_count" selected="true">Count of species</option>
+            <option value="output_species_frequency" selected="true">Species frequency</option>
+            <option value="output_richness" selected="true">Richness</option>
+            <option value="output_species_probabilities" selected="true">Species probabilities</option>
+            <option value="output_slope" selected="true">Slope of rarefaction curve</option>
+            <option value="output_r_script" selected="false">R script</option>
+            <option value="output_plot" selected="true">Rarefaction plot</option>
+        </param>
+    </inputs>
+    <outputs>
+        <data format="tabular" name="output_species_count" label="${tool.name} on ${on_string} (number of species)">
+            <filter>"output_species_count" in include_outputs</filter>
+        </data>
+        <data format="tabular" name="output_species_frequency" label="${tool.name} on ${on_string} (frequency of species)">
+            <filter>"output_species_frequency" in include_outputs</filter>
+        </data>
+        <data format="tabular" name="output_richness" label="${tool.name} on ${on_string} (estimated richness)">
+            <filter>"output_richness" in include_outputs</filter>
+        </data>
+        <data format="tabular" name="output_species_probabilities" label="${tool.name} on ${on_string} (species probabilities)">
+            <filter>"output_species_probabilities" in include_outputs</filter>
+        </data>
+        <data format="tabular" name="output_slope" label="${tool.name} on ${on_string} (slope of curve)">
+            <filter>"output_slope" in include_outputs</filter>
+        </data>
+        <data format="txt" name="output_r_script" label="${tool.name} on ${on_string} (Rscript)">
+            <filter>"output_r_script" in include_outputs</filter>
+        </data>
+        <data format="png" name="output_plot" label="${tool.name} on ${on_string} (plot)">
+            <filter>"output_plot" in include_outputs</filter>
+        </data>
+    </outputs>
+    <tests>
+        <test>
+            <param name="input_abundance" ftype="tabular" value="vegan_in.tabular"/>
+            <param name="species_column" value="6"/>
+            <param name="sample_columns" value="2"/>
+            <param name="sample_size" value=""/>
+            <param name="step_size" value="1"/>
+            <param name="xlab" value="Sample Size"/>
+            <param name="ylab" value="Species"/>
+            <param name="label" value="TRUE"/>
+            <output name="output_species_count" ftype="tabular" file="vegan_output_species_count.tabular" />
+            <output name="output_species_frequency" ftype="tabular" file="vegan_output_species_frequency.tabular" />
+            <output name="output_richness" ftype="tabular" file="vegan_output_richness.tabular" />
+            <output name="output_species_probabilities" ftype="tabular" file="vegan_output_species_probabilities.tabular" />
+            <output name="output_slope" ftype="tabular" file="vegan_output_slope.tabular" />
+        </test>
+    </tests>
+    <help>
+        <![CDATA[
+        
+        Gives the expected species richness in random subsamples of size sample from the community. The size of sample should be smaller than total community size, but the function will work for larger sample as well (with a warning) and return non-rarefied species richness (and standard error = 0). Rarefaction can be performed only with genuine counts of individuals. The function rarefy is based on Hurlbert’s (1971) formulation, and the standard errors on Heck et al. (1975).
+        
+        Returns probabilities that species occur in a rarefied community of size sample.
+        
+        Draws a rarefaction curve for each row of the input data. The rarefaction curves are evaluated using the interval of step sample sizes, always including 1 and total sample size. If sample is specified, a vertical line is drawn at sample with horizontal lines for the rarefied species richnesses.
+
+
+.. class:: warningmark
+
+When subsampling by community size, slope of the rarefaction curve and species probabilities are computed using community size-1
+        ]]>
+    </help>
+    <citations>
+    </citations>
+</tool>
\ No newline at end of file