Mercurial > repos > bebatut > plot_barplot
changeset 0:de039abf9641 draft
planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/plot_barplot commit ec57288980629acd7768b28d1fbc94fc12f23561-dirty
author | bebatut |
---|---|
date | Tue, 23 Feb 2016 05:17:12 -0500 |
parents | |
children | 7c1274bf54c6 |
files | plot_barplot.R plot_barplot.xml tool_dependencies.xml |
diffstat | 3 files changed, 154 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plot_barplot.R Tue Feb 23 05:17:12 2016 -0500 @@ -0,0 +1,57 @@ +library('getopt') + +option_specification = matrix(c( + 'input_file', 'i', 2, 'character', + 'output_pdf_file', 'p', 2, 'character', + 'output_png_file', 'o', 2, 'character', + 'output_svg_file', 's', 2, 'character', + 'data_column', 'd', 2, 'integer', + 'names_column', 'n', 2, 'integer', + 'xlab', 'x', 2, 'character', + 'col', 'c', 2, 'character', + 'bottom_margin', 'b', 2, 'integer', + 'left_margin', 'l', 2, 'integer', + 'top_margin', 't', 2, 'integer', + 'right_margin', 'r', 2, 'integer' +), byrow=TRUE, ncol=4); + +options = getopt(option_specification); + +data = read.table(options$input_file, sep = '\t', h = T) + +data_column = 2 +if(!is.null(options$data_column)) data_column = options$data_column +names_column = 1 +if(!is.null(options$names_column)) names_column = options$names_column + +margin = c(5,19,1,1) +if(!is.null(options$bottom_margin)) margin[1] = options$bottom_margin +if(!is.null(options$left_margin)) margin[2] = options$left_margin +if(!is.null(options$top_margin)) margin[3] = options$top_margin +if(!is.null(options$right_margin)) margin[4] = options$right_margin + +xlab = "" +if(!is.null(options$xlab)) xlab = options$xlab + +col = "grey" +if(!is.null(options$col)) col = options$col + +plot_barplot <- function(){ + par(las=2) + par(mar=margin) + barplot(data[, data_column], horiz = T, xlab = xlab, + names.arg = data[, names_column], col = col, cex.names=0.7, + cex.axis = 0.8) +} + +if(!is.null(options$output_pdf_file)){ + pdf(options$output_pdf_file) + plot_barplot() + dev.off() +} + +if(!is.null(options$output_svg_file)){ + svg(options$output_svg_file) + plot_barplot() + dev.off() +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plot_barplot.xml Tue Feb 23 05:17:12 2016 -0500 @@ -0,0 +1,88 @@ +<tool id="plot_barplot" name="Plot barplot" 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">getopt</requirement> + </requirements> + + <stdio> + <exit_code range="1:" /> + <exit_code range=":-1" /> + </stdio> + + <version_command></version_command> + + <command><![CDATA[ + Rscript $__tool_directory__/plot_barplot.R + --input_file $input_file + + #if str($output_format)=="pdf" + --output_pdf_file $output_pdf_file + #else + --output_svg_file $output_svg_file + #end if + + + --data_column $column_with_data + --names_column $names_column + --xlab $xlab + --col $col + --bottom_margin $bottom_margin + --left_margin $left_margin + --top_margin $top_margin + --right_margin $right_margin + ]]></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="output_format" label="Format for output image" type="select" help=""> + <option value="pdf" selected="True">PDF</option> + <option value="svg">SVG</option> + </param> + + <param name="column_with_data" type="data_column" data_ref="input_file" multiple="false" numerical="true" label="Column containing data?" help="(--data_column)" /> + + <param name="names_column" type="data_column" data_ref="input_file" multiple="false" numerical="false" label="Column containing data names?" help="(--names_column)" /> + + <param name="xlab" type="text" value="" label="Label for x axis" help="(--xlab)"/> + + <param name="col" label="Bar color" type="text" value= "blue" help="R color (--col)"/> + + <param name="bottom_margin" type="integer" value="5" label="Bottom margin" help="(--bottom_margin)"/> + <param name="left_margin" type="integer" value="19" label="Left margin" help="(--left_margin)"/> + <param name="top_margin" type="integer" value="1" label="Top margin" help="(--top_margin)"/> + <param name="right_margin" type="integer" value="1" label="Right margin" help="(--right_margin)"/> + </inputs> + + <outputs> + <data name="output_pdf_file" format="pdf" + label="${tool.name} on ${on_string}: PDF barplot"> + <filter>output_format=="pdf"</filter> + </data> + <data name="output_png_file" format="png" + label="${tool.name} on ${on_string}: PNG barplot"> + <filter>output_format=="png"</filter> + </data> + <data name="output_svg_file" format="svg" + label="${tool.name} on ${on_string}: SVG barplot"> + <filter>output_format=="svg"</filter> + </data> + </outputs> + + <tests> + </tests> + + <help><![CDATA[ + **What it does** + + This tool plot a barplot from a tabular file into different format files given different customizable parameters. + + This tool relies on R's barplot function. + + ]]></help> + + <citations> + </citations> +</tool> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool_dependencies.xml Tue Feb 23 05:17:12 2016 -0500 @@ -0,0 +1,9 @@ +<?xml version="1.0"?> +<tool_dependency> + <package name="R" version="3.2.1"> + <repository changeset_revision="9f31a291b305" name="package_r_3_2_1" owner="iuc" toolshed="https://testtoolshed.g2.bx.psu.edu" /> + </package> + <package name="getopt" version="1.20.0"> + <repository changeset_revision="a0851e07e3ac" name="package_r_3_2_1_getopt_1_20_0" owner="bebatut" toolshed="https://testtoolshed.g2.bx.psu.edu" /> + </package> +</tool_dependency>