changeset 5:278b189248cd draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit c027cb925607cda29bb1e78fe76716af49a276ca
author iuc
date Mon, 14 Jan 2019 05:02:19 -0500
parents 251393b72616
children 9fd8b69e6e68
files dexseq.R dexseq.xml plotdexseq.R plotdexseq.xml test-data/dexseq.rds test-data/plotdexseq.pdf test-data/plotdexseq_genes.tab test-data/plotdexseq_multi.pdf
diffstat 7 files changed, 169 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/dexseq.R	Tue Dec 11 00:19:18 2018 -0500
+++ b/dexseq.R	Mon Jan 14 05:02:19 2019 -0500
@@ -21,6 +21,7 @@
     'gtf', 'a', 1, "character",
     'outfile', 'o', 1, "character",
     'reportdir', 'r', 1, "character",
+    'rds', 'd', 1, "character",
     'factors', 'f', 1, "character",
     'threads', 'p', 1, "integer",
     'fdr', 'c', 1, "double"
@@ -110,10 +111,11 @@
 write.table(export_table, file = opt$outfile, sep="\t", quote = FALSE, col.names = FALSE)
 print("Written Results")
 
+if ( !is.null(opt$rds) ) {
+    saveRDS(res, file="DEXSeqResults.rds")
+}
+
 if ( !is.null(opt$reportdir) ) {
-    save(dxd, resSorted, file = file.path(opt$reportdir,"DEXSeq_analysis.RData"))
-    save.image()
     DEXSeqHTML(res, fitExpToVar=primaryFactor, path=opt$reportdir, FDR=opt$fdr, color=c("#B7FEA0", "#FF8F43", "#637EE9", "#FF0000", "#F1E7A1", "#C3EEE7","#CEAEFF", "#EDC3C5", "#AAA8AA"))
-    unlink(file.path(opt$reportdir,"DEXSeq_analysis.RData"))
 }
 sessionInfo()
--- a/dexseq.xml	Tue Dec 11 00:19:18 2018 -0500
+++ b/dexseq.xml	Mon Jan 14 05:02:19 2019 -0500
@@ -1,4 +1,4 @@
-<tool id="dexseq" name="DEXSeq" version="@VERSION@.0">
+<tool id="dexseq" name="DEXSeq" version="@VERSION@+galaxy1">
     <description>Determines differential exon usage from count tables</description>
     <macros>
         <import>macros.xml</import>
@@ -54,6 +54,7 @@
      -f '#echo json.dumps(temp_factor_names)#'
      -a $gtf
      -c $fdr_cutoff
+     -d $rds
 
      #if $report:
          -r ./html_out
@@ -93,6 +94,8 @@
         <param name="report" type="boolean" truevalue="True" falsevalue="False" checked="true"
             label="Visualise the analysis results?"
             help="Output an additional HTML file." />
+        <param name="rds" type="boolean" truevalue="True" falsevalue="False" checked="false"
+            label="Output rds file for plotDEXSeq?" help="Can be used to generate plots for individual genes with plotDEXSeq" />
         <param name="fdr_cutoff" type="float" min="0.0" max="1.0" value="0.05" label="All the genes under this FDR threshold will be shown in the html report"/>
     </inputs>
     <outputs>
@@ -100,6 +103,9 @@
         <data name="htmlreport" format="html" label="DEXSeq report on ${on_string}">
             <filter>report is True</filter>
         </data>
+        <data name="rds_out" format="rdata" from_work_dir="DEXSeqResults.rds" label="DEXSeq rds file on ${on_string}">
+            <filter>rds is True</filter>
+        </data>
     </outputs>
     <tests>
         <!-- Ensure default output works-->
@@ -151,6 +157,22 @@
             <param name="fdr_cutoff" value="0.05"/>
             <output name="dexseq_out" file="dexseq_result_2fact.tabular" ftype="tabular" compare="sim_size"/>
         </test>
+        <!-- Ensure rds output works-->
+        <test expect_num_outputs="2">
+            <param name="gtf" value="dexseq.gtf" ftype="gtf"/>
+            <repeat name="rep_factorName">
+                <param name="factorName" value="condition"/>
+                <param name="factorLevel1" value="knockdown"/>
+                <param name="countFiles1" value="treated1fb.txt,treated2fb.txt,treated3fb.txt" ftype="tabular"/>
+                <param name="factorLevel2" value="control"/>
+                <param name="countFiles2" value="untreated1fb.txt,untreated2fb.txt,untreated3fb.txt,untreated4fb.txt" ftype="tabular"/>
+            </repeat>
+            <param name="report" value="False"/>
+            <param name="rds" value="True"/>
+            <param name="fdr_cutoff" value="0.05"/>
+            <output name="dexseq_out" ftype="tabular" file="dexseq_result.tabular" compare="sim_size"/>
+            <output name="rds_out" ftype="rdata" file="dexseq.rds" compare="sim_size"/>
+        </test>
     </tests>
     <help><![CDATA[
 .. class:: infomark
@@ -188,7 +210,7 @@
 
 **Output**
 
-DEXSeq_ generates a tabular file containing the different columns and an optional html report.
+DEXSeq_ generates a tabular file containing the different columns and an optional html report. It can also ouput the DEXSeqResults R object that can be used with the plotDEXSeq tool to visualise individual genes.
 
 ====== ==========================================================
 Column Description
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plotdexseq.R	Mon Jan 14 05:02:19 2019 -0500
@@ -0,0 +1,47 @@
+## 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")
+
+suppressPackageStartupMessages({
+    library("DEXSeq")
+    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(
+    'rdata', 'r', 1, "character",
+    'primaryfactor', 'p', 1, "character",
+    'geneid', 'g', 1, "character",
+    'genefile', 'f', 1, "character",
+    'fdr', 'c', 1, "double",
+    'transcripts', 't', 1, "logical",
+    'names', 'a', 1, "logical",
+    'normcounts', 'n', 1, "logical",
+    'splicing', 's', 1, "logical"
+), byrow=TRUE, ncol=4);
+opt = getopt(spec);
+
+res <- readRDS(opt$rdata)
+
+if (!is.null(opt$genefile)) {
+	genes <- read.delim(opt$genefile, header=FALSE)
+	genes <- genes[, 1]
+} else {
+	genes <- opt$geneid
+}
+
+pdf("plot.pdf")
+for (i in genes){
+	plotDEXSeq(res, i, FDR=opt$fdr, fitExpToVar=opt$primaryfactor,
+	    norCounts=opt$normcounts, expression=TRUE, splicing=opt$splicing,
+	    displayTranscripts=opt$transcripts, names=opt$names, legend=TRUE,
+	    color=NULL, color.samples=NULL, transcriptDb=NULL)
+}
+dev.off()
+
+sessionInfo()
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plotdexseq.xml	Mon Jan 14 05:02:19 2019 -0500
@@ -0,0 +1,90 @@
+<tool id="plotdexseq" name="plotDEXSeq" version="@VERSION@.0">
+    <description>Visualization of the per gene DEXSeq results</description>
+    <macros>
+        <import>macros.xml</import>
+    </macros>
+    <expand macro="requirements">
+        <requirement type="package" version="1.20.2">r-getopt</requirement>
+    </expand>
+    <version_command><![CDATA[
+echo $(R --version | grep version | grep -v GNU)", DEXSeq version" $(R --vanilla --slave -e "library(DEXSeq); cat(sessionInfo()\$otherPkgs\$DEXSeq\$Version)" 2> /dev/null | grep -v -i "WARNING: ")" (depends on DESeq2 "$(R --vanilla --slave -e "library(DESeq2); cat(sessionInfo()\$otherPkgs\$DESeq2\$Version)" 2> /dev/null | grep -v -i "WARNING: ")")"
+    ]]></version_command>
+    <command detect_errors="exit_code"><![CDATA[
+Rscript '$__tool_directory__/plotdexseq.R'
+    -r '$rdata'
+    -p '$primaryfactor'
+    #if $genes.genes_select == 'list':
+        -f '$genes.genefile'
+    #else:
+        -g '$genes.geneid'
+    #end if
+    -c $fdr_cutoff
+    -t $transcripts
+    -a $names
+    -n $normcounts
+    -s $splicing
+    ]]></command>
+    <inputs>
+        <param name="rdata" type="data" format="rdata" label="DEXSeqResults object" help="A DEXSeqResults object in RDS format. This can be output from the DEXSeq tool"/>
+        <param name="primaryfactor" type="text" value="FactorName" label="Specify the primary factor name in the DEXSeqResults object" help="Only letters, numbers and underscores will be retained in this field">
+            <sanitizer>
+                <valid initial="string.letters,string.digits"><add value="_" /></valid>
+            </sanitizer>
+        </param>
+        <conditional name="genes">
+            <param name="genes_select" type="select" label="Genes to plot" help="Select to input a single gene ID or a list of IDs. Default: single gene ID">
+                <option value="single" selected="True">single</option>
+                <option value="list">list</option>
+            </param>
+            <when value="single">
+                <param name="geneid" type="text" label="Gene identifier" help="Gene identifier to visualize">
+                    <sanitizer>
+                        <valid initial="string.letters,string.digits"><add value="_" /></valid>
+                    </sanitizer>
+                </param>
+            </when>
+            <when value="list">
+                <param name="genefile" type="data" format="tabular" label="List of gene IDs" help="This should be a single tabular column with one gene per row and no header." />
+            </when>
+        </conditional>
+        <param name="fdr_cutoff" type="float" min="0.0" max="1.0" value="0.1" label="False Discovery Rate"/>
+        <param name="transcripts" type="boolean" truevalue="True" falsevalue="False" checked="False" label="Display transcripts" help="If Yes, the transcripts are displayed in the plot. Default: No"/>
+        <param name="names" type="boolean" truevalue="True" falsevalue="False" checked="False" label="Display transcript names" help="If Yes, the names of the transcripts are shown. Default: No"/>
+        <param name="normcounts" type="boolean" truevalue="True" falsevalue="False" checked="False" label="Plot count values from the individual samples" help="If yes, provides a plot of the counts normalized by the size factors. Default: No"/>
+        <param name="splicing" type="boolean" truevalue="True" falsevalue="False" checked="False" label="Plot exon usage" help="If yes, the samples gene expression effects are averaged out, leaving only exon usage coefficients. Default: No" />
+    </inputs>
+
+    <outputs>
+        <data name="dexseq_plot" format="pdf" from_work_dir="plot.pdf" label="${tool.name} on ${on_string}" />
+    </outputs>
+    <tests>
+        <!-- Ensure default output works-->
+        <test expect_num_outputs="1">
+            <param name="rdata" ftype="rdata" value="dexseq.rds"/>
+            <param name="primaryfactor" value="condition"/>
+            <param name="geneid" value="FBgn0000053"/>
+            <param name="fdr_cutoff" value="1"/>
+            <output name="dexseq_plot" ftype="pdf" file="plotdexseq.pdf" compare="sim_size"/>
+        </test>
+        <!-- Ensure plotting multiple genes works-->
+        <test expect_num_outputs="1">
+            <param name="rdata" ftype="rdata" value="dexseq.rds"/>
+            <param name="primaryfactor" value="condition"/>
+            <param name="genefile" ftype="tabular" value="plotdexseq_genes.tab"/>
+            <param name="fdr_cutoff" value="1"/>
+            <output name="dexseq_plot" ftype="pdf" file="plotdexseq_multi.pdf" compare="sim_size"/>
+        </test>
+    </tests>
+    <help><![CDATA[
+.. class:: infomark
+
+**What it does**
+
+This tool enables visualization of DEXSeq results for individual genes. The input is a DEXSeqResults rds file, which can be output from the DEXSeq tool, and a single gene ID or list of IDs to plot.
+
+.. _DEXSeq: http://master.bioconductor.org/packages/release/bioc/html/DEXSeq.html
+    ]]></help>
+    <citations>
+        <citation type="doi">10.1101/gr.133744.111</citation>
+    </citations>
+</tool>
Binary file test-data/dexseq.rds has changed
Binary file test-data/plotdexseq.pdf has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/plotdexseq_genes.tab	Mon Jan 14 05:02:19 2019 -0500
@@ -0,0 +1,3 @@
+FBgn0000053
+FBgn0000064
+FBgn0000024