changeset 0:095c44c46032 draft

Uploaded
author pavanvidem
date Fri, 22 May 2015 08:15:25 -0400
parents
children 1ff4ae929220
files diffbind.R diffbind.xml tool_dependencies.xml
diffstat 3 files changed, 196 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/diffbind.R	Fri May 22 08:15:25 2015 -0400
@@ -0,0 +1,49 @@
+## Setup R error handling to go to stderr
+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.
+Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
+
+library('getopt');
+options(stringAsfactors = FALSE, useFancyQuotes = FALSE)
+args <- commandArgs(trailingOnly = TRUE)
+
+#get options, using the spec as defined by the enclosed list.
+#we read the options from the default: commandArgs(TRUE).
+spec = matrix(c(
+    'verbose', 'v', 2, "integer",
+    'help' , 'h', 0, "logical",
+    'outfile' , 'o', 1, "character",
+    'plots' , 'p', 2, "character",
+    'infile' , 'i', 1, "character",
+    'format', 'f', 1, 'character'
+), byrow=TRUE, ncol=4);
+
+opt = getopt(spec);
+
+# if help was asked for print a friendly message
+# and exit with a non-zero error code
+if ( !is.null(opt$help) ) {
+    cat(getopt(spec, usage=TRUE));
+    q(status=1);
+}
+
+library('DiffBind')
+
+if ( !is.null(opt$plots) ) {
+    pdf(opt$plots)
+}
+
+
+sample = dba(sampleSheet=opt$infile, peakFormat='bed')
+sample_count = dba.count(sample)
+sample_contrast = dba.contrast(sample_count, categories=DBA_CONDITION, minMembers=2)
+sample_analyze = dba.analyze(sample_contrast)
+diff_bind = dba.report(sample_analyze)
+orvals = dba.plotHeatmap(sample_analyze, contrast=1, correlations=FALSE)
+
+resSorted <- diff_bind[order(diff_bind$FDR),]
+write.table(as.data.frame(resSorted), file = opt$outfile, sep="\t", quote = FALSE, append=TRUE, row.names = FALSE, col.names = FALSE)
+
+
+dev.off()
+sessionInfo()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/diffbind.xml	Fri May 22 08:15:25 2015 -0400
@@ -0,0 +1,105 @@
+<tool id="diffbind" name="DiffBind" version="2.0.2">
+    <description> differential binding analysis of ChIP-Seq peak data</description>
+    <requirements>
+        <requirement type="binary">Rscript</requirement>
+        <requirement type="R-module">DESeq2</requirement>
+        <requirement type="package" version="3.0.3">R</requirement>
+        <requirement type="package" version="1.2.10">deseq2</requirement>
+        <requirement type="package" version="1.8.3">diffbind</requirement>
+    </requirements>
+    <command>
+<![CDATA[
+        ## seems that diffbind also needs file extensions to work properly
+        #set $counter = 1
+        #for $sample in $samples:
+            ln -s $sample.bamreads #echo str($counter) + "_bamreads.bam"# &&
+            ln -s ${sample.bamreads.metadata.bam_index} #echo str($counter) + "_bamreads.bai"# &&
+            ln -s $sample.bamcontrol #echo str($counter) + "_bamcontrol.bam"# &&
+            ln -s ${sample.bamcontrol.metadata.bam_index} #echo str($counter) + "_bamcontrol.bai"# &&
+            #set $counter = $counter + 1
+        #end for
+
+        Rscript $__tool_directory__/diffbind.R
+            -i $infile
+            -o $outfile
+            -p $plots
+            -f $format
+]]>
+    </command>
+    <stdio>
+        <regex match="Execution halted"
+           source="both"
+           level="fatal"
+           description="Execution halted." />
+        <regex match="Input-Error 01"
+           source="both"
+           level="fatal"
+           description="Error in your input parameters: Make sure you only apply factors to selected samples." />
+        <regex match="Error in"
+           source="both"
+           level="fatal"
+           description="An undefined error occured, please check your intput carefully and contact your administrator." />
+    </stdio>
+    <inputs>
+        <repeat name="samples" title="Samples" min="2">
+            <param name="sample_id" type="text" value="Sample ID" label="Specify a sample id" help="e.g. BT474.1-" />
+            <param name="tissue" type="text" value="Tissue" label="Specify the tissue" help="e.g. BT474" />
+            <param name="factor" type="text" value="Factor Name" label="Specify a factor name" help="e.g. ER" />
+            <param name="condition" type="text" value="Condition" label="Specify the condition" help="e.g. Resistent" />
+            <param name="replicate" type="integer" value="1" label="Specify the replicate number" help="e.g. 1" />
+            <param format="bam" name="bamreads" type="data" label="Read BAM file" help="Specify the Read BAM file, used for Peak calling."/>
+            <param format="bam" name="bamcontrol" type="data" label="Control BAM file" help="Specify the Control BAM file, used for Peak calling."/>
+            <param format="bed" name="peaks" type="data" label="Peak file" help="Result of your Peak calling experiment."/>
+        </repeat>
+        <param name="pdf" type="boolean" truevalue="" falsevalue="" checked="true"
+            label="Visualising the analysis results"
+            help="output an additional PDF files" />
+        <param name="format" type="select" label="Output Format">
+            <option value="bed">BED</option>
+            <option value="gff">GFF</option>
+            <option value="wig">WIG</option>
+        </param>
+    </inputs>
+    <configfiles>
+<configfile name="infile">
+SampleID,Tissue,Factor,Condition,Replicate,bamReads,bamControl,Peaks
+#set $counter = 1
+#for $sample in $samples:
+$sample.sample_id,$sample.tissue,$sample.factor,$sample.condition,$sample.replicate,#echo str($counter) + '_bamreads.bam'#,#echo str($counter) + '_bamcontrol.bam'#,$sample.peaks
+#set $counter = $counter + 1
+#end for
+</configfile>
+    </configfiles>
+    <outputs>
+        <data format="bed" name="outfile" label="Differential binding sites on ${on_string}">
+            <change_format>
+                <when input="format" value="wig" format="wig" />
+                <when input="format" value="gff" format="gff" />
+            </change_format>
+        </data>
+        <data format="pdf" name="plots" label="Differential binding sites on ${on_string}">
+            <filter>pdf == True</filter>
+        </data>
+    </outputs>
+
+    <help>
+<![CDATA[
+
+.. class:: infomark
+
+**What it does**
+
+
+------
+
+**References**
+
+DiffBind_ Authors:  Rory Stark, Gordon Brown
+
+.. _DiffBind: http://www.bioconductor.org/packages/release/bioc/html/DiffBind.html
+
+Wrapper authors: Bjoern Gruening, Pavankumar Videm
+
+]]>
+    </help>
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool_dependencies.xml	Fri May 22 08:15:25 2015 -0400
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<tool_dependency>
+    <package name="R" version="3.1.0">
+        <repository changeset_revision="cfa09c247b6e" name="package_r_3_1_0" owner="iuc" prior_installation_required="True" toolshed="https://testtoolshed.g2.bx.psu.edu" />
+    </package>
+    <package name="deseq2" version="1.2.10">
+        <repository changeset_revision="97afd1582a0e" name="package_deseq2_1_2_10" owner="iuc" prior_installation_required="True" toolshed="https://testtoolshed.g2.bx.psu.edu" />
+    </package>
+    <package name="diffbind" version="1.14.4">
+        <install version="2.0">
+            <actions>
+                <action type="setup_r_environment">
+                    <repository changeset_revision="cfa09c247b6e" name="package_r_3_1_0" owner="iuc" toolshed="https://testtoolshed.g2.bx.psu.edu">
+                        <package name="R" version="3.1.0" />
+                    </repository>
+                        <package>http://www.bioconductor.org/packages/release/bioc/src/contrib/DiffBind_1.14.4.tar.gz</package>
+                        <package>https://github.com/bgruening/download_store/raw/master/DiffBind-1_8_3/IRanges_1.20.6.tar.gz</package>
+                        <package>https://github.com/bgruening/download_store/raw/master/DiffBind-1_8_3/XVector_0.2.0.tar.gz</package>
+                        <package>https://github.com/bgruening/download_store/raw/master/DiffBind-1_8_3/limma_3.18.9.tar.gz</package>
+                        <package>https://github.com/bgruening/download_store/raw/master/DiffBind-1_8_3/gtools_3.1.1.tar.gz</package>
+                        <package>https://github.com/bgruening/download_store/raw/master/DiffBind-1_8_3/gdata_2.13.2.tar.gz</package>
+                        <package>https://github.com/bgruening/download_store/raw/master/DiffBind-1_8_3/bitops_1.0-6.tar.gz</package>
+                        <package>https://github.com/bgruening/download_store/raw/master/DiffBind-1_8_3/caTools_1.16.tar.gz</package>
+                        <package>https://github.com/bgruening/download_store/raw/master/DiffBind-1_8_3/Biostrings_2.30.1.tar.gz</package>
+                        <package>https://github.com/bgruening/download_store/raw/master/DiffBind-1_8_3/GenomicRanges_1.14.4.tar.gz</package>
+                        <package>https://github.com/bgruening/download_store/raw/master/DiffBind-1_8_3/RColorBrewer_1.0-5.tar.gz</package>
+                        <package>https://github.com/bgruening/download_store/raw/master/DiffBind-1_8_3/amap_0.8-7.tar.gz</package>
+                        <package>https://github.com/bgruening/download_store/raw/master/DiffBind-1_8_3/edgeR_3.4.2.tar.gz</package>
+                        <package>https://github.com/bgruening/download_store/raw/master/DiffBind-1_8_3/gplots_2.12.1.tar.gz</package>
+                        <package>https://github.com/bgruening/download_store/raw/master/DiffBind-1_8_3/zlibbioc_1.8.0.tar.gz</package>
+                        <package>https://github.com/bgruening/download_store/raw/master/DiffBind-1_8_3/Rsamtools_1.14.2.tar.gz</package>
+                        <package>https://github.com/bgruening/download_store/raw/master/DiffBind-1_8_3/DiffBind_1.8.3.tar.gz</package>
+                        <package>https://github.com/bgruening/download_store/raw/master/DiffBind-1_8_3/getopt_1.20.0.tar.gz</package>
+                </action>
+            </actions>
+        </install>
+        <readme>
+        Differential Binding Analysis of ChIP-Seq peak data
+        http://www.bioconductor.org/packages/release/bioc/html/DiffBind.html
+        </readme>
+    </package>
+</tool_dependency>