view PileOMeth.xml @ 1:d1b66015effd draft

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/pileometh commit fc3727b1b39cd5654a523d03e0df2b9ac87ddcda
author bgruening
date Wed, 21 Sep 2016 13:37:19 -0400
parents 65575e70af7e
children cda51d96a9bc
line wrap: on
line source

<tool id="pileometh" name="PileOMeth" version="0.1.13">
    <description>A tool for processing bisulfite sequencing alignments</description>
    <requirements>
        <requirement type="package" version="0.1.13">pileometh</requirement>
    </requirements>
    <stdio>
        <!-- Anything other than zero is an error -->
        <exit_code range="1:" />
        <exit_code range=":-1" />
        <!-- In case the return code has not been set propery check stderr too -->
        <regex match="Error:" />
        <regex match="Exception:" />
    </stdio>
    <version_command><![CDATA[PileOMeth --version]]></version_command>
    <command><![CDATA[
        #if $reference_source.reference_source_selector == "cached":
            ln -s $reference_source.ref_file.fields.path reference.fasta &&
        #else:
            ln -s $reference_source.ref_file reference.fasta &&
        #end if

        PileOMeth
            $main_task.task

            #if $main_task.task == "extract":
                -o output
                $main_task.mergeContext
                #if str($main_task.OT).strip() != "":
                    --OT $main_task.OT
                #end if
                #if str($main_task.OB).strip() != "":
                    --OB $main_task.OB
                #end if
                #if str($main_task.CTOT).strip() != "":
                    --CTOT $main_task.CTOT
                #end if
                #if str($main_task.CTOB).strip() != "":
                    --CTOB $main_task.CTOB
                #end if
            #end if

            #if $advanced_options.options=="yes":
                #if $advanced_options.mbias_regionString:
                    -r $advanced_options.mbias_regionString
                #end if
                $advanced_options.keepDupes
                $advanced_options.keepSingleton
                -q $advanced_options.min_mapq
                -p $advanced_options.min_phred
                -D $advanced_options.max_pbdepth
                #if $main_task.task == "extract":
                    -d $advanced_options.min_pbdepth
                #end if
                $advanced_options.CHG
                $advanced_options.CHH
            #end if

            reference.fasta

            $input_sortedAlignBAM

            #if $main_task.task == "mbias":
                out_mbias &&
                touch out_mbias_OT.svg &&
                touch out_mbias_OB.svg &&
                touch out_mbias_CTOT.svg &&
                touch out_mbias_CTOB.svg
            #end if
    ]]></command>
    <inputs>
        <conditional name="reference_source">
            <param name="reference_source_selector" type="select" label="Load reference genome from">
                <option value="cached">Local cache</option>
                <option value="history">History</option>
            </param>
            <when value="cached">
                <param name="ref_file" type="select" label="Using reference genome" help="Reference sequence">
                    <options from_data_table="all_fasta"/>
                    <validator type="no_options" message="A built-in reference genome is not available for the build associated with the selected input file"/>
                </param>
            </when>
            <when value="history">
                <param name="ref_file" type="data" format="fasta" label="Use the folloing dataset as the reference sequence" help="REFERENCE_SEQUENCE; You can upload a FASTA sequence to the history and use it as reference" />
            </when>
        </conditional>

        <param name="input_sortedAlignBAM" multiple="False" type="data" format="bam" label="sorted_alignments.bam"/>
        <conditional name="main_task">
            <param name="task" type="select" label="What do you want to do?" >
                 <option value="extract">Extract methylation metrics from an alignment file in BAM/CRAM format</option>
                 <option value="mbias">Determine the position-dependent methylation bias in a dataset, producing diagnostic SVG images</option>
            </param>
            <when value="extract">
                <param name="mergeContext" type="boolean" checked="false" truevalue="--mergeContext" falsevalue=""
                label="Merge per-Cytosine metrics from CpG and CHG contexts into per-CPG or per-CHG metrics" help="(--mergeContext)" />
                <param name="OT" type="text" value="" label="Original top strand bounds (comma-separated, no spaces)"
                    help="Inclusion bounds for methylation calls from reads/pairs
                          origination from the original top strand. Suggested values can
                          be obtained from the MBias program. Each integer represents a
                          1-based position on a read. For example --OT A,B,C,D
                          translates to, 'Include calls at positions from A through B
                          on read #1 and C through D on read #2'. If a 0 is used a any
                          position then that is translated to mean start/end of the
                          alignment, as appropriate. For example, --OT 5,0,0,0 would
                          include all but the first 4 bases on read #1. Users are
                          strongly advised to consult a methylation bias plot, for
                          example by using the MBias program." />
                <param name="OB" type="text" value="" label="Original bottom strand bounds (comma-separated, no spaces)" />
                <param name="CTOT" type="text" value="" label="Complementary to the original bottom strand bounds (comma-separated, no spaces)" />
                <param name="CTOB" type="text" value="" label="Complementary to the original bottom strand bounds (comma-separated, no spaces)" />
            </when>
            <when value="mbias"/>
        </conditional>
        <conditional name="advanced_options">
            <param name="options" type="select" label="Advanced options">
                <option value="">Hide advanced options</option>
                <option value="yes">Display advanced options</option>
            </param>
            <when value="yes">
                <param name="mbias_regionString" type="text" value="" label="Region string in which to extract methylation"/>
                <param name="keepDupes" type="boolean" checked="false" truevalue="--keepDupes" falsevalue=""
                    label="By default, any alignment marked as a duplicate is ignored. This option causes them to be incorporated" />
                <param name="keepSingleton" type="boolean" checked="false" truevalue="--keepSingleton" falsevalue=""
                    label="By default, if only one read in a pair aligns (a singleton) then it's ignored." />
                <param name="min_mapq" type="integer" value="10" label="Minimum MAPQ threshold to include an alignment (default 10)"/>
                <param name="min_phred" type="integer" value="5" label="Minimum Phred threshold to include a base (default 5). This must be >0."/>
                <param name="max_pbdepth" type="integer" value="2000" label="Maximum per-base depth (default 2000)"/>
                <param name="min_pbdepth" type="integer" value="1" min="1" label="Minimum per-base depth"
                    help="Minimum per-base dpeth for reporting output. If you use --mergeContext (above), then this applies to the merged CpG/CHG (default 1). (-d)" />

                <param name="CHG" type="boolean" checked="false" truevalue="--CHG" falsevalue=""
                    label="Additional output file with CHG methylation metrics" />
                <param name="CHH" type="boolean" checked="false" truevalue="--CHH" falsevalue=""
                    label="Additional output file with CHH methylation metrics" />
            </when>
            <when value=""/>
        </conditional>
    </inputs>
    <outputs>
            <data  name="outFileExtractCpG" format="bedgraph" from_work_dir="output_CpG.bedGraph" 
                label="${tool.name} on ${on_string}">
                <filter>main_task['task']  == "extract"</filter>
            </data>
            <data  name="outFileExtractCHG" format="bedgraph" from_work_dir="output_CHG.bedGraph" 
                label="${tool.name} on ${on_string} (CHG)">
                <filter>main_task['task'] == 'extract'</filter>
                <filter>advanced_options['options'] == "yes"</filter>
                <filter>advanced_options['CHG'] == "--CHG"</filter>
            </data>
            <data  name="outFileExtractCHH" format="bedgraph" from_work_dir="output_CHH.bedGraph" 
                label="${tool.name} on ${on_string} (CHH)">
                <filter>main_task['task']  == 'extract'</filter>
                <filter>advanced_options['options'] == "yes"</filter>
                <filter>advanced_options['CHH'] == "--CHH" </filter>
            </data>
            <data  name="outFileMbiasCpGOT" format="svg" from_work_dir="out_mbias_OT.svg"
                label="${tool.name} on ${on_string} (methylation bias, original top strand)">
                <filter>main_task['task']  == 'mbias'</filter>
            </data>
            <data  name="outFileMbiasCpGOB" format="svg" from_work_dir="out_mbias_OB.svg"
                label="${tool.name} on ${on_string} (methylation bias, original bottom strand)">
                <filter>main_task['task']  == 'mbias'</filter>
            </data>
            <data  name="outFileMbiasCpGCTOT" format="svg" from_work_dir="out_mbias_CTOT.svg"
                label="${tool.name} on ${on_string} (methylation bias, complementary to the original top strand)">
                <filter>main_task['task']  == 'mbias'</filter>
            </data>
            <data  name="outFileMbiasCpGCTOB" format="svg" from_work_dir="out_mbias_CTOB.svg"
                label="${tool.name} on ${on_string} (methylation bias, complementary to the original bottom strand)">
                <filter>main_task['task']  == 'mbias'</filter>
            </data>
    </outputs>
    <tests>
        <test>
            <param name="task" value="extract" />
            <param name="min_mapq" value="2" />
            <param name="reference_source_selector" value="history" />
            <param name="ref_file" value="cg100.fa" ftype="fasta" />
            <param name="input_sortedAlignBAM" value="cg_aln.bam" ftype="bam"/>
            <param name="mergeContext" value="false"/>
            <param name="options" value="yes"/>
            <output name="outFileExtractCpG" file="test_1.bedGraph" ftype="bedgraph" compare="diff"/>
        </test>
        <test>
            <param name="task" value="mbias" />
            <param name="min_mapq" value="2" />
            <param name="options" value="yes"/>
            <param name="reference_source_selector" value="history" />
            <param name="ref_file" value="cg100.fa" ftype="fasta" />
            <param name="input_sortedAlignBAM" value="cg_aln.bam" ftype="bam"/>
            <output name="outFileMbiasCpG" file="test_2_output.svg" ftype="svg" compare="diff"/>
        </test>
    </tests>
    <help><![CDATA[
**What it does**

PileOMeth (using a PILEup to extract METHylation metrics) will process a coordinate-sorted and indexed BAM or CRAM file containing some form of BS-seq alignments and extract per-base methylation metrics from them. PileOMeth requires an indexed fasta file containing the reference genome as well.

By default, PileOMeth will only calculate metrics for Cytosines in a CpG context, but metrics for those in CHG and CHH contexts are supported as well.

**Methylation context**

PileOMeth groups all Cytosines into one of three sequence contexts: CpG, CHG, and CHH. Here, H is the IUPAC ambiguity code for any nucleotide other than G. If an N is encountered in the reference sequence, then the context will be assigned to CHG or CHH, as appropriate (e.g., CNG would be categorized as in a CHG context and CNC as in a CHH context). If a Cytosine is close enough to the end of a chromosome/contig such that its context can't be inferred, then it is categorized as CHH (e.g., a Cytosine as the last base of a chromosome is considered as being in a CHH context).


**Output information**

If no methylation can be found, the output will be empty.

Otherwise a variant of bedGraph that's similar to the "coverage" file is produced.  In short, each line consists of 6 tab separated columns:

1. The chromosome/contig/scaffold name
2. The start coordinate
3. The end coordinate
4. The methylation percentage rounded to an integer
5. The number of alignments/pairs reporting methylated bases
6. The number of alignments/pairs reporting unmethylated bases

All coordinates are 0-based half open, which conforms to the bedGraph definition. When paired-end reads are aligned, it can often occur that their alignments overlap. In such cases, PileOMeth will not count both reads of the pair in its output, as doing so would lead to incorrect downstream statistical results.

An example of the output is below::

#track type="bedGraph" description="SRR1182519.sorted CpG methylation levels"
#1   25115   25116   100 3   0
#1   29336   29337   50  1   1

Note the header line, which starts with "track". The "description" field is used as a label in programs such as IGV. Each of the subsequent lines describe single Cytosines, the 25116th and 29337th base on chromosome 1, respectively. The first position has 3 alignments (or pairs of alignments) indicating methylation and 0 indicating unmethylation (100% methylation) and the second position has 1 alignment each supporting methylation and unmethylation (50% methylation).

**Per-CpG/CHG metrics**

In many circumstances, it's desireable for metrics from individual Cytosines in a CpG to be merged, producing per-CpG metrics rather than per-Cytosine metrics. This can be accomplished with the **Merge per-Cytosine** parameter. If this is used, then this output::

#track type="bedGraph" description="SRR1182519.sorted CpG methylation levels"
#1   25114   25115   100 2   1
#1   25115   25116   100 3   0

is changed to this::

#track type="bedGraph" description="SRR1182519.sorted merged CpG methylation levels"
#1   25114   25116   100 5   1

This also works for CHG-level metrics. If bedGraph files containing per-Cytosine metrics already exist, they can be converted to instead contain per-CpG/CHG metrics with PileOMeth mergeContext.

**Methylation bias plotting and correction**

In an ideal experiment, we expect that the probability of observing a methylated C is constant across the length of any given read. In practice, however, there are often increases/decreases in observed methylation rate at the ends of reads and/or more global changes. These are termed methylation bias and including such regions in the extracted methylation metrics will result in noisier and less accurate data. For this reason, users are strongly encouraged to make a methylation bias plot.

That command will create a methylation bias (mbias for short) plot for each of the strands for which there are valid alignments.
The resulting mbias graphs are in SVG format and can be viewed in most modern web browsers:

.. image:: example.svg


If you have paired-end data, both reads in the pair will be shown separately, as is the case above. The program will suggest regions for inclusion ("--OT 2,0,0,98" above) and mark them on the plot, if applicable. The format of this output is described in PileOMeth extract -h. These suggestions should not be accepted blindly; users are strongly encouraged to have a look for themselves and tweak the actual bounds as appropriate. The lines indicate the average methylation percentage at a given position and the shaded regions the 99.9% confidence interval around it. This is useful in gauging how many methylation calls a given position has relative to its neighbors. Note the spike in methylation at the end of read #2 and the corresponding dip at the beginning of read #1. This is common and these regions can be ignored with the suggested trimming bounds. Note also that the numbers refer to the first and last base that should be included during methylation extraction, not the last and first base to ignore!.

-----

**PileOMeth** is a Free and Open Source Software, see more details on the PileOMeth_ Website.

.. _PileOMeth: https://github.com/dpryan79/PileOMeth
    ]]></help>
    <citations>
    </citations>
</tool>