changeset 0:3d068b7441be draft

planemo upload commit f36456464c692ed9d39a9cf654d09fe793113cce-dirty
author stevecassidy
date Wed, 31 Aug 2016 22:06:23 -0400
parents
children 4c17593167f0
files phonR_tool.R phonR_tool.xml
diffstat 2 files changed, 104 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/phonR_tool.R	Wed Aug 31 22:06:23 2016 -0400
@@ -0,0 +1,52 @@
+#
+# Galaxy tool that plots Vowels using the phonR package.
+# Accepts 8 inputs of the form <tsv data file> <output file name> <column1> <column2> <optPretty> <optEllipse> <optTokens> <optMeans>
+# Created by Michael Bauer
+#
+library(phonR)
+library('getopt')
+
+#create options
+option_specification = matrix(c(
+  'outdir', 'f', 1, 'character',
+  'htmlfile', 'h', 1, 'character',
+  'inputfile', 'i', 1, 'character',
+  'column1', 'y', 1, 'integer',
+  'column2', 'z', 1, 'integer',
+  'columnvowels', 'x', 1, 'integer',
+  'pretty', 'p', 1, 'logical',
+  'ellipse', 'e', 1, 'logical',
+  'tokens', 't', 1, 'logical',
+  'means', 'm', 1, 'logical',
+  'cextokens', 'c', 1, 'numeric',
+  'alphatokens', 'a', 1, 'numeric',
+  'cexmeans', 'b', 1, 'numeric'
+), byrow=TRUE, ncol=4);
+
+# Parse options
+options = getopt(option_specification);
+
+if (!is.null(options$outdir)) {
+  # Create the directory
+  dir.create(options$outdir,FALSE)
+}
+
+pngfile <- gsub("[ ]+", "", paste(options$outdir,"/pngfile.png"))
+htmlfile <- gsub("[ ]+", "", paste(options$htmlfile))
+
+data = read.table(options$inputfile,sep="\t", header=TRUE);
+
+png(pngfile);
+
+plotVowels(data[,options$column1], data[,options$column2], data[,options$columnvowels], plot.tokens = options$tokens, 
+          pch.tokens = data[,options$columnvowels], cex.tokens = options$cextokens, alpha.tokens = options$alphatokens, 
+          plot.means = options$means, pch.means = data[,options$columnvowels], cex.means = options$cexmeans, 
+          var.col.by = data[,options$columnvowels], ellipse.line = options$ellipse, pretty = options$pretty)
+dev.off();
+
+htmlfile_handle <- file(htmlfile)
+html_output = c('<html><body>',
+                '<h3>Result:</h3><img src="pngfile.png"/>',
+                '</html></body>');
+writeLines(html_output, htmlfile_handle);
+close(htmlfile_handle);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/phonR_tool.xml	Wed Aug 31 22:06:23 2016 -0400
@@ -0,0 +1,52 @@
+<tool id="vowel_plot" name="Plot Vowels" version="0.01" force_history_refresh="True">
+    <description>Using phonR to produce a Vowel Plot</description>
+
+    <requirements>
+        <requirement type="package" version="3.2.1">R</requirement>
+        <requirement type="package" version="1.0.3">phonR</requirement>
+    </requirements>
+
+    <command interpreter="Rscript">
+        $__tool_directory__/phonR_tool.R --input="${input}" --outdir="$htmlfile.files_path" --htmlfile="$htmlfile" --column1="${f1}" --column2="${f2}" --columnvowels="${vowel}" --pretty="${pretty}" --ellipse="${ellipse}" --tokens="${tokens}" --means="${means}" --cextokens="${cextokens}" --alphatokens="${alphatokens}" --cexmeans="${cexmeans}"
+    </command>
+
+    <inputs>
+        <param name="input" type="data" format="tabular" label="Segment List" help=""/>
+        <param name="f1" type="data_column" data_ref="input" label="Column for f1" force_select="true" use_header_names="true"/>
+        <param name="f2" type="data_column" data_ref="input" label="Column for f2" force_select="true" use_header_names="true"/>
+        <param name="vowel" type="data_column" data_ref="input" label="Column with Vowels" force_select="true" use_header_names="true"/>
+        <param name="pretty" type="boolean" label="Make Pretty" 
+               truevalue="TRUE" falsevalue="FALSE" checked="True"
+               help="Will apply various beautification techniques." />
+        <param name="ellipse" type="boolean" label="Add Ellipses" 
+               truevalue="TRUE" falsevalue="FALSE" checked="True"
+               help="Will add an ellipse around the location of each vowel cluster." />
+        <param name="tokens" type="boolean" label="Add Tokens" 
+               truevalue="TRUE" falsevalue="FALSE" checked="True"
+               help="Will add tokens to the plot." />
+        <param name="means" type="boolean" label="Add Means" 
+               truevalue="TRUE" falsevalue="FALSE" checked="True"
+               help="Will add means to the plot." />
+        <param name="cextokens" type="float" label="cex.tokens" value="1.2" min="0.0" max="10.0"
+               help="Size of tokens on the plot." />
+        <param name="alphatokens" type="float" label="alpha.tokens" value="0.2" min="0.0" max="1.0"
+               help="The alpha of the tokens on the plot (transparency). NOTE: Must be a value betweek 0 and 1!" />
+        <param name="cexmeans" type="float" label="cex.means" value="2" min="0.0" max="10.0"
+               help="Size of the means on the plot." />  
+    </inputs>
+
+    <outputs>
+        <data format="html" name="htmlfile" label="output.html" />
+    </outputs>
+
+
+    <tests>
+        <test>
+        </test>
+    </tests>
+
+    <help>
+        Will make a vowel plot from given data. Best used from data directly run from the "Get Formants at segment midpoint" Tool.
+    </help>
+
+</tool>