view dada2_learnErrors.xml @ 3:10141f4eaae9 draft

planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/tree/topic/dada2/tools/dada2 commit 5b1603bbcd3f139cad5c876be83fcb39697b5613-dirty
author matthias
date Mon, 29 Apr 2019 08:56:03 -0400
parents 57eb7437f646
children 9aeea74a1fc9
line wrap: on
line source

<tool id="dada2_learnErrors" name="dada2: learnErrors" version="@DADA2_VERSION@+galaxy@WRAPPER_VERSION@">
    <description>Learn Error rates</description>
    <macros>
        <import>macros.xml</import>
    </macros>
    <expand macro="requirements"/>
    <expand macro="version_command"/>
    <command detect_errors="exit_code"><![CDATA[
    Rscript '$dada2_script' \${GALAXY_SLOTS:-1}
    ]]></command>
    <configfiles>
        <configfile name="dada2_script"><![CDATA[
library(ggplot2, quietly=T)
library(dada2, quietly=T)

args <- commandArgs(trailingOnly = TRUE)
nthreads <- as.integer(args[1])

files <- c()
#for $read in $reads:
files <- c(files, '$read')
#end for

err <- learnErrors(files, nbases = 10**$nbases,
           errorEstimationFunction = $advanced.errfoo, multithread = nthreads,
           randomize = $advanced.randomize, MAX_CONSIST = $advanced.maxconsist, OMEGA_C = $advanced.omegac)

## write.table(err\$err_out, file = '$errors', quote = F, sep = "\t", row.names = T, col.names = F)
saveRDS(err, file='$errors')

## generate error plots
plot <- plotErrors(err, obs = $plotopt.obs, err_out = $plotopt.errout, err_in = $plotopt.errin, nominalQ = $plotopt.nominalQ)
ggsave('plot.pdf', plot, width = 20,height = 15,units = c("cm"))
    ]]></configfile>
    </configfiles>
    <inputs>
        <param name="reads" type="data" multiple="true" format="fastqsanger,fastqsanger.gz" label="Short read data" help="forward or reverse reads should be processed separately"/>
        <param argument="nbases" type="integer" value="8" min="0" label="Magnitide of number of bases to use for learning"/>
        <section name="advanced" title="Advanced Option">
            <expand macro="errorEstimationFunction"/>
            <param argument="randomize" type="boolean" checked="false" truevalue="TRUE" falsevalue="FALSE" label="Randomize samples"/>
            <param name="maxconsist" argument="MAX_CONSIST" type="integer" value="10" min="0" label="Maximum number of times to step through the selfconsistency loop" help=""/>
            <param name="omegac" argument="OMEGA_C" type="integer" value="0" min="0" label="Threshold at which unique sequences inferred to contain errors are corrected" help=""/>
        </section>
        <section name="plotopt" title="Plotting Option">
            <param name="obs" type="boolean" checked="true" truevalue="TRUE" falsevalue="FALSE" label="Plot observed error rates"/>
            <param name="errout" type="boolean" checked="true" truevalue="TRUE" falsevalue="FALSE" label="Plot output error rates"/>
            <param name="errin" type="boolean" checked="false" truevalue="TRUE" falsevalue="FALSE" label="Plot input error rates"/>
            <param name="nominalQ" type="boolean" checked="true" truevalue="TRUE" falsevalue="FALSE" label="Plot expected error rates"/>
        </section>
    </inputs>
    <outputs>
        <data name="errors" format="dada2_errorrates" label="${tool.name} on ${on_string}"/>
        <data name="plot" format="pdf" from_work_dir="plot.pdf" label="${tool.name} on ${on_string}: error rates plot"/>
    </outputs>
    <tests>
        <test>
            <param name="reads" value="filterAndTrim_F3D0_R1.fq.gz" ftype="fastqsanger.gz"/>
            <output name="errors" value="learnErrors_F3D0_R1.Rdata" ftype="dada2_errorrates"/>
            <output name="plot" value="learnErrors_F3D0_R1.pdf" ftype="pdf" />
        </test>
        <!-- test for creating input for dada results for reverse, not needed for testing -->
        <test>
            <param name="reads" value="filterAndTrim_F3D0_R2.fq.gz" ftype="fastqsanger.gz"/>
            <output name="errors" value="learnErrors_F3D0_R2.Rdata" ftype="dada2_errorrates"/>
            <output name="plot" value="learnErrors_F3D0_R2.pdf" ftype="pdf" />
        </test>
        <!-- test w non-default parameters -->
        <test>
            <param name="reads" value="filterAndTrim_F3D0_R1.fq.gz" ftype="fastqsanger.gz"/>
            <param name="plotopt|obs" value="FALSE" />
            <param name="plotopt|errout" value="FALSE" />
            <param name="plotopt|errin" value="TRUE" />
            <param name="plotopt|nominalQ" value="FALSE"/>
            <output name="errors" value="learnErrors_F3D0_R1.Rdata" ftype="dada2_errorrates" />
            <output name="output" value="learnErrors_F3D0_R1.pdf" ftype="pdf" compare="sim_size" />
        </test>
        <!-- TODO test w multiple inputs -->
    </tests>
    <help><![CDATA[
Description
...........

Error rates are learned by alternating between sample inference and error rate estimation until convergence. Additionally a plot is generated that shows the observed frequency of each transition (eg. A->C) as a function of the associated quality score, the final estimated error rates (if they exist), the initial input rates, and the expected error rates under the nominal definition of quality scores.

Usage
.....

**Input** are the FASTQ dataset containing the filtered and trimmed reads of the samples.

**Output** a dataset with type *dada2_errorrates* (which is a RData file containing the output of dada2's learnErrors function) and a **plot** showing the error rates for each possible transition (A→C, A→G,...)

- Points are the observed error rates for each consensus quality score.
- The black line shows the estimated error rates after convergence of the machine-learning algorithm.
- The red line shows the error rates expected under the nominal definition of the Q-score.

The learned error rates are input the the *dada2: dada* tool.

Details
.......

The learnErrors method learns a parametric error model from the data, by alternating estimation of the error rates and inference of sample composition until they converge on a jointly consistent solution. As in many machine-learning problems, the algorithm must begin with an initial guess, for which the maximum possible error rates in this data are used (the error rates if only the most abundant sequence is correct and all the rest are errors).

It is expected that the estimated error rates (black lines in the plot) are in a good fit to the observed rates (points in the plot), and that the error rates drop with increased quality. Try to increase the **number of bases to use for learning** if this is not the case.

@HELP_OVERVIEW@
    ]]></help>
    <expand macro="citations"/>
</tool>