Repository 'plot_generic_x_y_plot'
hg clone https://toolshed.g2.bx.psu.edu/repos/bebatut/plot_generic_x_y_plot

Changeset 0:5118d839acae (2016-04-18)
Commit message:
planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/plot_generic_x_y_plot commit e4da8b5a999456b2b6dabdf6b8f3bfea1eba5504-dirty
added:
plot_generic_x_y_plot.R
plot_generic_x_y_plot.xml
static/images/output.png
test-data/input_file.txt
test-data/output_test.pdf
tool_dependencies.xml
b
diff -r 000000000000 -r 5118d839acae plot_generic_x_y_plot.R
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/plot_generic_x_y_plot.R Mon Apr 18 11:11:02 2016 -0400
[
@@ -0,0 +1,86 @@
+library('getopt')
+
+option_specification = matrix(c(
+  'input_file', 'a', 2, 'character',
+  'output_pdf_file', 'b', 2, 'character',
+  'output_png_file', 'c', 2, 'character',
+  'output_svg_file', 'd', 2, 'character',
+  'x_column_id', 'e', 2, 'integer',
+  'y_column_id', 'f', 2, 'integer',
+  'xlog', 'g', 2, 'logical',
+  'ylog', 'h', 2, 'logical',
+  'xlab', 'i', 2, 'character',
+  'ylab', 'j', 2, 'character',
+  'col', 'k', 2, 'character',
+  'pch', 'l', 2, 'integer',
+  'lim', 'm', 2, 'logical',
+  'abline', 'n', 2, 'logical',
+  'bottom_margin', 'o', 2, 'integer',
+  'left_margin', 'p', 2, 'integer',
+  'top_margin', 'q', 2, 'integer',
+  'right_margin', 'r', 2, 'integer',
+  'header','s',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)
+
+x_column_id = 2
+if(!is.null(options$x_column_id)) x_column_id = options$x_column_id
+x_axis = data[,x_column_id]
+
+y_column_id = 3
+if(!is.null(options$y_column_id)) y_column_id = options$y_column_id
+y_axis = data[,y_column_id]
+
+xlim = c(min(x_axis),max(x_axis))
+ylim = c(min(y_axis),max(y_axis))
+if(!is.null(options$lim) && options$lim){
+  xlim = c(min(xlim,ylim), max(xlim,ylim))
+  ylim = xlim
+}
+
+
+xlab = ""
+if(!is.null(options$xlab)) xlab = options$xlab
+ylab = ""
+if(!is.null(options$ylab)) ylab = options$ylab
+
+col = 'grey25'
+if(!is.null(options$col)) col = options$col
+
+pch = 21
+if(!is.null(options$pch)) pch = options$pch
+
+log = ""
+if(!is.null(options$xlog) && options$xlog) log = paste(log,"x",sep = '')
+if(!is.null(options$ylog) && options$ylog) log = paste(log,"y",sep = '')
+
+margin = c(5,5,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
+
+plot_generic_x_y_plot <- function(){
+    par(mar=margin)
+    plot(x_axis, y_axis, xlab = xlab, ylab = ylab, 
+      col = col, log = log, xlim = xlim, ylim = ylim, pch = pch)
+    if(!is.null(options$abline) && options$abline) abline(a = 0, b = 1, col = 'grey50')
+}
+
+if(!is.null(options$output_pdf_file)){
+    pdf(options$output_pdf_file)
+    plot_generic_x_y_plot()
+    dev.off()
+}
+
+if(!is.null(options$output_svg_file)){
+    svg(options$output_svg_file)
+    plot_generic_x_y_plot()
+    dev.off()
+}
\ No newline at end of file
b
diff -r 000000000000 -r 5118d839acae plot_generic_x_y_plot.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/plot_generic_x_y_plot.xml Mon Apr 18 11:11:02 2016 -0400
[
@@ -0,0 +1,125 @@
+<tool id="plot_generic_x_y_plot" name="Plot generic X-Y plot" 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__/plot_generic_x_y_plot.R
+            --input_file $input_file
+            --header $header
+
+            #if str($output_format)=="pdf"
+                --output_pdf_file $output_pdf_file
+            #else
+                --output_svg_file $output_svg_file
+            #end if
+
+            --x_column_id $x_column_id
+            --y_column_id $y_column_id
+            --xlog $xlog
+            --ylog $ylog
+            --xlab "$xlab"
+            --ylab "$ylab"
+            --col $color
+            --lim $lim
+            --abline $abline
+            --bottom_margin $bottom_margin
+            --left_margin $left_margin
+            --top_margin $top_margin
+            --right_margin $right_margin
+            --pch $pch
+    ]]></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="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="x_column_id" type="data_column" data_ref="input_file" label="Column containing data for X axis" multiple="false" numerical="true" help="--x_column_id)"/>
+        <param name="y_column_id" type="data_column" data_ref="input_file" label="Column containing data for Y axis" multiple="false" numerical="true" help="--y_column_id)"/>
+
+        <param name="xlog" type="boolean" truevalue="TRUE" falsevalue="FALSE" label="Scale with log for X axis?" help="(--xlog)"/>
+        <param name="ylog" type="boolean" truevalue="TRUE" falsevalue="FALSE" label="Scale with log for Y axis?" help="(--ylog)"/>
+
+        <param name="xlab" type="text" value="" label="Label for X axis" help="(--xlab)"/>
+        <param name="ylab" type="text" value="" label="Label for Y axis" help="(--ylab)"/>
+
+        <param name="color" label="Color for the points" type="text" value= "grey25" help="R color (--col)"/>
+        <param name="pch" type="integer" value="21" label="Point type" help="(--pch)"/>
+
+        <param name="lim" type="boolean" truevalue="TRUE" falsevalue="FALSE" label="Use same limits for both axis?" help="(--lim)"/>
+        <param name="abline" type="boolean" truevalue="TRUE" falsevalue="FALSE" label="Add a line for x = y?" help="(--abline)"/>
+
+        <param name="bottom_margin" type="integer" value="5" label="Bottom margin" help="(--bottom_margin)"/>
+        <param name="left_margin" type="integer" value="5" 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 X-Y plot">
+            <filter>output_format=="pdf"</filter>
+        </data>
+        <data name="output_png_file" format="png"
+            label="${tool.name} on ${on_string}: PNG X-Y plot">
+            <filter>output_format=="png"</filter>
+        </data>
+        <data name="output_svg_file" format="svg"
+            label="${tool.name} on ${on_string}: SVG X-Y plot">
+            <filter>output_format=="svg"</filter>
+        </data>
+    </outputs>
+
+    <tests>
+        <test>
+            <param name="input_file" value="input_file.txt" />
+            <param name="header" value="FALSE" />
+            <param name="output_format" value="pdf" />    
+            <param name="x_column_id" value="2" />
+            <param name="y_column_id" value="3" />
+            <param name="xlog" value="FALSE" />
+            <param name="ylog" value="FALSE" />
+            <param name="xlab" value="" />
+            <param name="ylab" value="" />
+            <param name="color" value= "grey25" />
+            <param name="pch" value="21" />
+            <param name="lim" value="FALSE" />
+            <param name="abline" value="FALSE" />
+            <param name="bottom_margin" value="5" />
+            <param name="left_margin" value="5" />
+            <param name="top_margin" value="1" />
+            <param name="right_margin" value="1" />
+            <output name="output_pdf_file" file="output_file.pdf" />
+        </test>
+    </tests>
+
+    <help><![CDATA[
+**What it does**
+
+This tool plot a generic X-Y plot:
+
+.. image:: $PATH_TO_IMAGES/output.png
+   :scale: 50 %
+
+This tool relies on R's plot function. The input file must be a tabular file with at least two data columns. The output image is customizable (margin, legend positions, ...) and can be export in different format. 
+    ]]></help>
+
+    <citations>
+    </citations>
+</tool>
\ No newline at end of file
b
diff -r 000000000000 -r 5118d839acae static/images/output.png
b
Binary file static/images/output.png has changed
b
diff -r 000000000000 -r 5118d839acae test-data/input_file.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/input_file.txt Mon Apr 18 11:11:02 2016 -0400
b
b'@@ -0,0 +1,44933 @@\n+Peptidoglycan glycosyltransferase\t0.000161727\t0.0118886\n+4Fe 4S ferredoxin iron sulfur binding domain containing protein\t0.000868638\t0.000531762\n+glutamine synthetase\t2.69312e-06\t5.73862e-06\n+PREDICTED\t2.60733e-06\t6.24102e-06\n+CheA2\t0.000150322\t0.000790528\n+Lipid A export ATP binding permease protein MsbA\t1.11264e-05\t1.07255e-05\n+Putrescine transport ATP binding protein PotG\t0.00246313\t0.000669647\n+UniRef50_T1T0E7\t0.000100801\t7.45857e-05\n+UniRef50_B1ES30\t4.14647e-05\t3.75108e-05\n+UniRef50_U5FV07\t6.21513e-06\t8.56822e-06\n+hypothetical protein\t4.43079e-05\t3.94018e-05\n+UniRef50_E3EZF3\t3.37315e-05\t3.03424e-05\n+MULTISPECIES\t0.000310186\t0.000273077\n+Xanthine phosphoribosyltransferase\t2.9417e-05\t4.25664e-05\n+osmotically inducible protein C\t2.85602e-05\t7.28132e-05\n+hypothetical protein\t1.23194e-05\t1.08152e-05\n+UniRef50_V6QDM9\t0.00783736\t0.000329043\n+hypothetical protein\t7.99295e-06\t2.60025e-06\n+hypothetical protein\t1.59535e-05\t1.05228e-05\n+ATP synthase subunit c\t0.00179136\t0.00191803\n+Signal transduction histidine kinase, nitrogen specific, NtrB\t0.000503327\t0.000572126\n+Ribosomal RNA large subunit methyltransferase E\t8.84364e-05\t2.10681e-05\n+hypothetical protein\t1.08525e-05\t2.65469e-06\n+Pyridoxal phosphate dependent protein\t4.65423e-06\t3.77816e-06\n+ppGpp synthetase\t7.04822e-06\t3.22676e-06\n+tRNA  methyltransferase TrmJ\t0.00189866\t0.000149062\n+Aminomethyltransferase\t2.33117e-05\t1.51446e-05\n+UniRef50_G3A3C4\t2.16795e-05\t2.79743e-05\n+Cation efflux family protein\t0.0196844\t0.0036985\n+Cysteine  tRNA ligase\t1.30529e-05\t6.16661e-06\n+GTPase Der\t0.0197074\t0.00571616\n+transcriptional regulator, partial\t7.01959e-06\t5.19979e-06\n+M18 family aminopeptidase\t0.000248146\t0.00099988\n+hypothetical protein\t1.06502e-05\t1.04434e-05\n+UniRef50_Q8CTD2\t0.00357327\t0.000428378\n+UniRef50_N6UZ26\t0.000164589\t8.81973e-05\n+UniRef50_Q8CTD8\t0.00416514\t0.000892528\n+Aspartate racemase\t0.00375174\t0.00128855\n+pH adaptation potassium efflux system a\t7.69331e-06\t4.21598e-06\n+Putative secreted protein\t6.06564e-07\t4.76785e-06\n+UniRef50_P0AFQ9\t0.00344033\t0.00044277\n+MULTISPECIES\t1.06444e-05\t9.05003e-06\n+UniRef50_Q49VL4\t0.00854163\t0.00348391\n+Exotoxin 3\t0.0119531\t0.0018639\n+UniRef50_Q49VL2\t0.0102927\t0.00297603\n+UniRef50_U4W1Q6\t1.47561e-05\t2.55106e-05\n+UniRef50_A0A023Y807\t3.98755e-06\t2.70598e-06\n+RNA 2 phosphotransferase\t0.00361245\t0.000242662\n+Metallophosphoesterase\t0.00240274\t0.000599791\n+multidrug transporter\t5.07658e-06\t1.06808e-05\n+UniRef50_B0VT73\t0.000165395\t0.00161481\n+Periplasmic sensor signal transduction histidine kinase\t0.00203538\t0.000220771\n+hypothetical protein\t4.99047e-06\t6.95463e-05\n+UniRef50_C6SR58\t0.00204608\t0.000458828\n+hypothetical protein\t3.97248e-05\t1.7195e-05\n+hypothetical protein\t1.15135e-05\t0.000280398\n+hypothetical protein\t4.71096e-05\t0.000910536\n+Thiamine biosynthesis protein ApbE, putative\t0.00439006\t0.000746352\n+quinone oxidoreductase\t5.99892e-06\t5.14167e-06\n+UniRef50_Q1IC36\t3.434e-05\t1.54274e-05\n+Methionine  tRNA ligase\t6.10882e-06\t6.27787e-06\n+hypothetical protein\t6.78396e-05\t8.38177e-05\n+UniRef50_J3K6Q4\t5.60575e-05\t2.36951e-05\n+Membrane protein\t0.000632297\t5.37312e-05\n+UniRef50_V4SQT0\t0.000106089\t0.000203256\n+hypothetical protein\t1.47649e-05\t1.25305e-05\n+UniRef50_Q3JR57\t7.38026e-05\t4.84538e-05\n+UPF0336 protein PPA1896\t0.000237006\t0.0164004\n+hypothetical protein\t0.000209179\t4.14018e-05\n+ABC transporter permease\t4.15875e-06\t2.7588e-05\n+UniRef50_P55573\t0.000276561\t0.00266001\n+Inner membrane protein YqiK\t0.00313998\t0.000344059\n+hypothetical protein\t1.1061e-05\t3.41183e-06\n+Trehalose synthase amylase TreS\t0.000159596\t0.0214083\n+Protein translocase subunit SecA\t4.0402e-05\t0.019036\n+Methionine aminotransferase\t0.00115406\t8.41412e-05\n+UniRef50_Q8CSN4\t0.0124256\t0.00204947\n+UniRef50_R7PW99\t0.00157791\t0.000141616\n+UniRef50_B0SVK0\t4.60143e-05\t4.22004e-05\n+hypothetical protein, partial\t5.51487e-05\t2.10073e-05\n+Oxidoreductase, putative\t0.00356744\t0.00339111\n+UniRef50_P76352\t0.00336489\t0.000244252\n+glycosyl hydrolase family 20\t7.73428e-07\t6.34216'..b'.46116e-06\n+Bifunctional protein PaaZ\t0.00296879\t0.017174\n+hypothetical protein\t2.06422e-05\t2.90355e-05\n+Peptidase U32\t0.000657375\t0.000633363\n+UniRef50_S1MU41\t3.16359e-06\t3.00806e-06\n+hypothetical protein\t4.0719e-05\t1.19419e-06\n+UniRef50_P57864\t0.00346975\t0.00184651\n+hypothetical protein\t1.10759e-05\t1.1749e-06\n+ribonucleotide diphosphate reductase subunit alpha, partial\t1.24665e-05\t0.00479338\n+Ribonuclease PH\t1.22353e-05\t9.89494e-06\n+Serine threonine phosphatase\t4.22523e-06\t1.61328e-05\n+hypothetical protein\t3.58485e-06\t5.04236e-06\n+Aspartate ammonia lyase\t0.000752977\t0.0025833\n+UniRef50_P9WLT0\t0.000110344\t0.00257699\n+Acyl CoA dehydrogenase\t0.000113827\t0.00398798\n+MW0677 protein\t0.00916458\t0.000789517\n+UniRef50_P76613\t0.00297844\t6.91717e-05\n+Exodeoxyribonuclease III\t0.0113436\t0.00134576\n+UniRef50_Q8DUL3\t0.00546777\t0.00294859\n+Binding protein dependent transport systems inner membrane component\t0.000788459\t0.000967536\n+Methyltransferase, putative\t0.000687874\t0.0289494\n+Malate dehydrogenase  (NADP(+))\t0.000128807\t0.0339473\n+UniRef50_Q3JPF1\t2.36254e-05\t5.92248e-05\n+hypothetical protein\t4.24475e-05\t4.25391e-05\n+Isopentenyl diphosphate Delta isomerase\t0.00055475\t0.000164441\n+Phosphopantothenate  cysteine ligase\t0.00402834\t0.000870814\n+nickel transporter permease NikB\t4.12544e-05\t4.37221e-05\n+Ribosomal RNA small subunit methyltransferase G\t6.9804e-05\t1.44396e-05\n+UniRef50_B1QWY3\t0.000468626\t0.000787847\n+Membrane protein insertase YidC 1\t0.00373089\t0.00113492\n+leucyl phenylalanyl tRNA  protein transferase\t8.98619e-06\t1.69263e-05\n+Phosphodiesterase, family\t0.000515125\t0.000376063\n+Sensor kinase CusS\t0.00221302\t0.000633498\n+Proteophosphoglycan ppg4\t1.08034e-05\t1.27052e-05\n+Fatty acid  CoA ligase\t7.93123e-05\t0.00301925\n+hypothetical protein\t5.86556e-06\t0.000148134\n+Homoserine dehydrogenase\t0.000340781\t0.00253223\n+hypothetical protein\t2.21467e-05\t3.48258e-05\n+hypothetical protein\t7.20664e-06\t1.16351e-05\n+peptidase M24\t3.47577e-06\t7.64163e-06\n+heme ABC transporter ATP binding protein\t5.18248e-05\t2.93601e-05\n+hypothetical protein\t1.43604e-05\t1.73656e-06\n+UniRef50_P0AB04\t0.00173809\t0.000684324\n+UniRef50_UPI0002A4C202\t4.9528e-05\t1.37999e-05\n+alpha L fucosidase\t1.37673e-05\t2.39567e-05\n+UniRef50_A0A017Y7E3\t2.65397e-05\t2.26091e-05\n+UniRef50_Q97FA7\t0.000265612\t0.00107913\n+Fibronectin, type III domain protein\t0.000206936\t0.000490788\n+oxidoreductase\t5.00962e-06\t8.74669e-06\n+branched chain amino acid transporter II carrier protein\t1.41705e-05\t6.39227e-06\n+UniRef50_K0S2S0\t2.55692e-05\t0.000253257\n+Porphobilinogen deaminase\t0.00702004\t0.000628213\n+Sodium proline symporter\t0.00153802\t0.00672764\n+hypothetical protein\t2.12677e-05\t8.18687e-05\n+hypothetical protein\t5.33117e-05\t2.56122e-06\n+UniRef50_K8Z2D7\t1.23149e-05\t1.2493e-05\n+Xanthine permease XanQ\t0.00338718\t0.00112417\n+UPF0246 protein YaaA \t1.20083e-05\t8.0264e-06\n+DegV domain containing protein CPE1310\t0.000404868\t0.000451044\n+taurine  pyruvate aminotransferase\t4.23357e-05\t8.41047e-06\n+malyl CoA thiolesterase\t9.025e-05\t2.26902e-05\n+UniRef50_E3D1E7\t0.000254676\t0.000640291\n+peptide ABC transporter permease\t4.82265e-06\t1.23469e-05\n+DnaK domain protein \t8.44881e-05\t3.2284e-05\n+hypothetical protein, partial\t3.30099e-05\t1.089e-05\n+PREDICTED\t1.12802e-05\t8.1275e-07\n+Phage infection protein Pip\t0.000430009\t0.000649083\n+50S ribosomal protein L22\t7.49387e-06\t1.5923e-05\n+UniRef50_A8G2K7\t0.00050524\t0.00149351\n+UniRef50_V9U122\t0.000337332\t0.000132147\n+Carbamoyl phosphate synthase small chain\t0.000300047\t0.00123932\n+UniRef50_Q64QH6\t1.57974e-06\t1.57088e-06\n+hypothetical protein\t2.77341e-06\t3.02538e-06\n+Membrane fusion protein\t7.59132e-05\t0.00309855\n+Peptidase family M48 family\t0.000542551\t0.000208802\n+MarR family transcriptional regulator, partial\t1.06452e-05\t2.16182e-05\n+hypothetical protein\t0.000133491\t1.9086e-05\n+Transcriptional regulator, RpiR family\t0.000282183\t0.000790884\n+Potassium transporting ATPase A chain\t0.00726039\t0.00621555\n+Putative pyruvate, phosphate dikinase regulatory protein\t0.0200092\t0.00205547\n'
b
diff -r 000000000000 -r 5118d839acae test-data/output_test.pdf
b
Binary file test-data/output_test.pdf has changed
b
diff -r 000000000000 -r 5118d839acae tool_dependencies.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tool_dependencies.xml Mon Apr 18 11:11:02 2016 -0400
b
@@ -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>