changeset 0:c4bf5e913c2e draft default tip

"planemo upload commit b1883bac95e73fc6ffe2a36db3115ad5e5a1eba4"
author iuc
date Fri, 11 Oct 2019 17:31:09 -0400
parents
children
files manhattan.R manhattan_plot.xml test-data/sampledata.tsv test-data/testgraph.pdf
diffstat 4 files changed, 161 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/manhattan.R	Fri Oct 11 17:31:09 2019 -0400
@@ -0,0 +1,60 @@
+options( show.error.messages=F, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } )
+
+# we need that to not crash galaxy with an UTF8 error on German LC settings.
+loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
+
+suppressPackageStartupMessages({
+    library(GWASTools)
+    library(optparse)
+})
+option_list <- list(
+    make_option(c("-f", "--file"), type="character", help="RInput GWAS file"),
+    make_option("--pval", type="integer", help="Pvalue column"),
+    make_option("--chromosome", type="integer", help="Chromosome column"),
+    make_option("--ymin", type="double", help="Min y value"),
+    make_option("--ymax", type="double", help="Max y value"),
+    make_option("--trunc", help="Show truncation lines", action="store_true"),
+    make_option("--sig", type="double", help="Significance level for lines"),
+    make_option("--thin", type="double", help="Thinning value", action="store_true", dest="thin"),
+    make_option("--ppb", type="integer", help="Points per bin, if thinning value is specified", action="store_true"))
+args <- parse_args(OptionParser(option_list=option_list))
+file <- args$file
+data <-  read.table(args$file, header=TRUE)
+pval <-  data[,args$pval]
+chromosome <-  data[,args$chromosome]
+if(!is.null(args$ymin) & !is.null(args$ymax)){
+    ylimit <-  c(args$ymin,args$ymax)
+}else if(xor(!is.null(args$ymin), !is.null(args$ymax))){
+    print("If specifying range, both ymin and ymax must be set")
+    ylimit <- NULL
+}else{
+    ylimit <- NULL
+}
+if(is.null(args$trunc)){
+    trunc <- FALSE
+}else{
+    trunc <- TRUE
+}
+if(!is.null(args$sig)){
+    sig <-  args$sig
+}else{
+    sig <- NULL
+}
+if(!is.null(args$thin)){
+    thin = args$thin
+    if(thin == 0){
+        thin = NULL 
+    }
+}else{
+    thin <- FALSE
+}
+if(!is.null(thin) & !is.null(args$ppb)){
+    ppb = args$ppb
+}
+pdf("manhattan.pdf")
+if(isFALSE(thin)){
+    manhattanPlot(pval, chromosome, ylim=ylimit, trunc.lines=trunc, signif=sig)
+}else{
+    manhattanPlot(pval, chromosome, ylim=ylimit, trunc.lines=trunc, signif=sig, thinThreshold = thin, pointsPerBin = ppb)   
+}
+invisible(dev.off())
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/manhattan_plot.xml	Fri Oct 11 17:31:09 2019 -0400
@@ -0,0 +1,88 @@
+<tool id="gwastools_manhattan_plot" name="Manhattan plot" version="0.1.0" python_template_version="3.5">
+    <description>Generate plots for use with GWAS pipelines</description>
+    <requirements>
+        <requirement type="package" version="3.6">r-base</requirement>
+        <requirement type="package" version="1.30.0">bioconductor-gwastools</requirement>
+        <requirement type="package" version="1.6.4">r-optparse</requirement>
+    </requirements>
+    <command detect_errors="exit_code"><![CDATA[
+        Rscript '$__tool_directory__/manhattan.R'
+        --file '${file}'
+        --pval ${pvals}
+        --chromosome ${chromosome}
+        #if $ymax:
+            --ymax ${ymax}
+        #end if
+        #if $ymin:
+            --ymin ${ymin}
+        #end if
+        ${trunc}
+        #if $sig:
+            --sig ${sig}
+        #end if
+        #if $thinselect.thinning == 'Yes':
+            --thin ${thinselect.thin}
+            #if $thinselect.ppb:
+                --ppb ${thinselect.ppb}
+            #end if
+        #end if
+    ]]></command>
+    <inputs>
+        <param name="file" type="data" format="tsv,tabular" label="GWAS data file"/>
+        <param name="chromosome" type="data_column" data_ref="file" label="Chromosome column number"/>
+        <param name="pvals" type="data_column" data_ref="file" label="P-values column number"/>
+        <param name="ymax" type = "float" optional="true" label="Y max"/>
+        <param name="ymin" type = "float" optional="true" label="Y min"/>
+        <param name="trunc" type="boolean" truevalue="--trunc" falsevalue="" label="Show truncation lines?"/>
+        <param name="sig" type="float" optional="true" label="Genome-wide significance level for plotting horizontal line." help="If not specified, no line will be drawn."/>
+        <conditional name="thinselect">
+            <param name="thinning" type="select" label='Specify thinning value?'>
+                <option value="Yes"/>
+                <option value="No"/>
+            </param>
+            <when value="Yes">
+                <param name="thin" type="float" value="0" label="Threshold for thinning points" help="If not specified, value is -log10(val)"/>
+                <param name="ppb" type="integer" optional="true" label="Points per bin"/>
+            </when>
+            <when value="No"/>
+        </conditional>
+    </inputs>
+    <outputs>
+        <data name="manhattanout" format="pdf" from_work_dir="manhattan.pdf" label="Manhattan plot on ${on_string}"/>
+    </outputs>
+    <tests>
+        <test expect_num_outputs="1">
+            <param name="file" value="sampledata.tsv"/>
+            <param name="chromosome" value="2"/>
+            <param name="pvals" value="4"/>
+            <param name="ymin" value="0.2"/>
+            <param name="trunc" value="--trunc"/>
+            <param name="ymax" value="2"/>
+            <param name="sig" value="0.05"/>
+            <conditional name="thinselect">
+                <param name="thinning" value="yes"/>
+                <param name="thin" value="1"/>
+                <param name="ppb" value="1"/>
+            </conditional>
+            <output name="manhattanout" ftype="pdf" value="testgraph.pdf" compare="sim_size"/>
+        </test>
+    </tests>
+    <help><![CDATA[
+        Generates a manhattan plot for GWAS data
+
+        Input data format example:
+
+            SNP CHR  Pos  P
+            rs1   1  1 0.9148
+            rs2   1  2 0.9371
+            rs3   1  3 0.2861
+            rs4   1  4 0.8304
+            rs5   1  5 0.6417
+            rs6   1  6 0.5191
+            rs16468  22 533 0.1779
+
+    ]]></help>
+    <citations>
+        <citation type="doi">10.1093/bioinformatics/bts610</citation>
+    </citations>
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/sampledata.tsv	Fri Oct 11 17:31:09 2019 -0400
@@ -0,0 +1,13 @@
+SNP	CHR	Pos	P
+rs1	1	1	0.9148
+rs2	1	2	0.9371
+rs3	1	3	0.2861
+rs4	1	4	0.8304
+rs5	1	5	0.6417
+rs6	1	6	0.5191
+rs16465	22	530	0.5644
+rs16466	22	531	0.1383
+rs16467	22	532	0.3937
+rs16468	22	533	0.1779
+rs16469	22	534	0.2393
+rs16470	22	535	0.2630
Binary file test-data/testgraph.pdf has changed