view bamCompare.xml @ 26:e821645ef8fc draft

"planemo upload for repository https://github.com/deeptools/deepTools/tree/master/galaxy/wrapper/ commit 7c89456b6a986259c96b8d280c53e4ab155696ef"
author bgruening
date Sat, 25 Jan 2020 04:47:48 -0500
parents 5f6d123679f4
children 29451af70c52
line wrap: on
line source

<tool id="deeptools_bam_compare" name="bamCompare" version="@WRAPPER_VERSION@.0">
    <description>normalizes and compares two BAM or CRAM files to obtain the ratio, log2ratio or difference between them</description>
    <macros>
        <token name="@BINARY@">bamCompare</token>
        <import>deepTools_macros.xml</import>
    </macros>
    <expand macro="requirements" />
    <command>
<![CDATA[
        ln -s '$bamFile1' one.bam &&
        #if $bamFile1.ext == 'bam':
            ln -s '${bamFile1.metadata.bam_index}' one.bam.bai &&
        #else:
            ln -s '${bamFile1.metadata.cram_index}' one.bam.crai &&
        #end if
        ln -s '$bamFile2' two.bam &&
        #if $bamFile2.ext == 'bam':
            ln -s '${bamFile2.metadata.bam_index}' two.bam.bai &&
        #else:
            ln -s '${bamFile2.metadata.cram_index}' two.bam.crai &&
        #end if

        @BINARY@
            @THREADS@
            --bamfile1 one.bam
            --bamfile2 two.bam

            --outFileName '$outFileName'
            --outFileFormat '$outFileFormat'

            --binSize $binSize

            #if $scaling.method == 'SES':
                --scaleFactorsMethod SES
                --sampleLength $scaling.sampleLength
                --numberOfSamples $scaling.numberOfSamples
            #elif $scaling.method == 'readCount':
                --scaleFactorsMethod readCount
            #elif $scaling.method == 'own':
                --scaleFactors '$scaling.scaleFactor1:$scaling.scaleFactor2'
            #elif $scaling.method == 'None':
                --scaleFactorsMethod None
                #if $scaling.type != '':
                    --normalizeUsing $scaling.type
                #end if
            #end if

            --operation $comparison.type
            $exactScaling

            #if $comparison.type in ['ratio','log2']:
                --pseudocount $comparison.pseudocount
            #end if

            #if str($region).strip() != '':
                --region '$region'
            #end if

            #if $advancedOpt.showAdvancedOpt == "yes":
                #if $advancedOpt.smoothLength:
                    --smoothLength '$advancedOpt.smoothLength'
                #end if

                @ADVANCED_OPTS_READ_PROCESSING@
                $advancedOpt.skipNAs
                $advancedOpt.skipZeroOverZero

                #if str($advancedOpt.ignoreForNormalization).strip() != '':
                    --ignoreForNormalization '$advancedOpt.ignoreForNormalization'
                #end if

                @blacklist@
            #end if
]]>
    </command>
    <inputs>
        <param argument="--bamFile1" format="bam,cram" type="data" label="First BAM/CRAM file (e.g. treated sample)"
            help=""/>
        <param argument="--bamFile2" format="bam,cram" type="data" label="Second BAM/CRAM file (e.g. control sample)"
            help=""/>

        <param argument="--binSize" type="integer" value="50" min="1"
            label="Bin size in bases"
            help="The genome will be divided into bins of the specified size. For each bin, the overlapping number of fragments (or reads) will be reported.
                If only half a fragment overlaps then this fraction will be reported."/>

        <conditional name="scaling">
            <param name="method" type="select"
                label="Method to use for scaling the largest sample to the smallest">
                <option value="readCount" selected="true">read count</option>
                <option value="SES">signal extraction scaling (SES), check with plotFingerprint before using it!</option>
                <option value="own">enter own scaling factors</option>
                <option value="None">Don't scale reads. Samples can instead be normalized using one of the normalization methods</option>
            </param>
            <when value="SES">
                <param argument="--sampleLength" type="integer" value="1000" min="10"
                    label="Length in bases used to sample the genome and compute the size or scaling factors."
                    help="The default is fine. Only change it if you know what you are doing." />
                <param argument="--numberOfSamples" type="integer" value="100000" min="0"
                    label="Number of samplings taken from the genome to compute the scaling factors"
                    help="" />
            </when>
            <when value="readCount" />
            <when value="own">
                <expand macro="scaleFactors" />
            </when>
            <when value="None">
                <param name="type" type="select" label="Normalization method" >
                    <option value="RPKM">Normalize to fragments (reads) per kilobase per million (RPKM)</option>
                    <option value="CPM">Normalize to counts per million (CPM), same as CPM in RNA-seq</option>
                    <option value="BPM">Normalize to bins per million (BPM), same as TPM in RNA-seq</option>
                    <option value="">Do not normalize or scale</option>
                </param>
            </when>
        </conditional>

        <conditional name="comparison">
            <param name="type" type="select"
                label="How to compare the two files"
                help="The default is to output the log2ratio between the two samples.
                The reciprocal ratio returns the negative of the inverse of the ratio if
                the ratio is less than 0. The resulting values are interpreted as negative
                fold changes. To output the scaled values from the first or second BAM file,
                select 'first' or 'second'.">
                <option value="log2" selected="true">Compute log2 of the number of reads ratio</option>
                <option value="ratio">Compute the ratio of the number of reads</option>
                <option value="subtract">Compute difference (subtract input from treatment) of the number of reads</option>
                <option value="add">Compute the sum of number of reads</option>
                <option value="mean">Compute the mean of the number of reads between the two files</option>
                <option value="reciprocal_ratio">Computes the fold change. If the fold change is less than 1, the negative of the inverse is reported. E.g. A fold change of 10 to 5 would be reported not as 0.5 but as -2</option>
                <option value="first">Returns the scaled value of the first BAM file</option>
                <option value="second">Returns the scaled value of the second BAM file</option>
            </param>
            <when value="log2">
                <expand macro="pseudocount" />
            </when>
            <when value="ratio">
                <expand macro="pseudocount" />
            </when>
            <when value="add" />
            <when value="subtract" />
            <when value="mean" />
            <when value="first" />
            <when value="second" />
            <when value="reciprocal_ratio">
                <expand macro="pseudocount" />
            </when>
        </conditional>

        <expand macro="exactScaling" />
        <param name="outFileFormat" type="select" label="Coverage file format">
            <option value="bigwig" selected="true">bigwig</option>
            <option value="bedgraph">bedgraph</option>
        </param>
        <expand macro="region_limit_operation" />
        <conditional name="advancedOpt">
            <param name="showAdvancedOpt" type="select" label="Show advanced options" >
                <option value="no" selected="true">no</option>
                <option value="yes">yes</option>
            </param>
            <when value="no" />
            <when value="yes">
                <expand macro="smoothLength" />
                <expand macro="read_processing_options" />

                <expand macro="skipNAs" />
                <expand macro="skipZeroOverZero" />

                <param argument="--ignoreForNormalization" type="text" value="" size="50"
                    label="regions that should be excluded for calculating the scaling factor"
                    help="Sometimes it makes sense to exclude certain regions when calculating the scaling factor.
                        For example, if you know of copy number variations between samples then you may want to exclude these.
                        Another typical example is the difference in chromosome X copies between males and females in many species.
                        Example inputs are chrX,chrY,chr3 or chr10:12220-128932" />
                <expand macro="blacklist" />
            </when>
        </conditional>
    </inputs>
    <outputs>
        <data format="bigwig" name="outFileName">
        <change_format>
            <when input="outFileFormat" value="bigwig" format="bigwig" />
            <when input="outFileFormat" value="bedgraph" format="bedgraph" />
        </change_format>
        </data>
    </outputs>
    <tests>
        <test>
            <param name="bamFile1" value="bowtie2 test1.bam" ftype="bam" />
            <param name="bamFile2" value="bowtie2 test1.bam" ftype="bam" />
            <param name="showAdvancedOpt" value="no" />
            <param name="outFileFormat" value="bigwig" />
            <param name="outFileFormat" value="bedgraph" />
            <param name="binSize" value="5" />
            <param name="type" value="ratio" />
            <output name="outFileName" file="bamCompare_result1.bg" ftype="bedgraph" />
        </test>
        <test>
            <param name="bamFile1" value="bowtie2 test1.bam" ftype="bam" />
            <param name="bamFile2" value="bowtie2 test1.bam" ftype="bam" />
            <param name="showAdvancedOpt" value="yes" />
            <param name="outFileFormat" value="bigwig" />
            <param name="outFileFormat" value="bigwig" />
            <param name="binSize" value="10" />
            <param name="type" value="ratio" />
            <output name="outFileName" file="bamCompare_result2.bw" ftype="bigwig" />
        </test>
    </tests>
    <help>
<![CDATA[

What it does
-------------

This tool can be used to generate a bigWig or bedGraph file based on **two BAM or CRAM** files that are compared to each other while being simultaneously normalized for sequencing depth.

To compare the BAM files to each other, the genome is partitioned into bins of equal size, then the number of reads found in each BAM file is counted per bin, and finally a summary value reported.

The tool works in two steps:
1. Scaling : To properly compare samples with different sequencing depth, each bam file can be scaled either using the SES method
(proposed in Diaz et al. (2012). "Normalization, bias correction, and peak calling for ChIP-seq". Statistical applications in genetics and molecular
biology, 11(3).) or total read count. additionally scaling can be turned off and a per-sample normalization can be used (--normalizeUsing RPKM/CPM/BPM)

2. Comparison : Two bam files are compared using one of the chosen methods (e.g. add, subtract, mean, log2 ratio etc.)

By default, if reads are from a paired-end sequencing run and reads are properly paired, the fragment length reported in the BAM file is used.

**Note:** *For paired-end sequencing samples, each read mate is treated independently to avoid a bias when a mixture of concordant and discordant pairs are present. This means that _each end_ will be extended to match the fragment length.*

.. image:: $PATH_TO_IMAGES/norm_IGVsnapshot_indFiles.png
   :width: 600
   :height: 336

Output files
--------------

``bamCompare`` produces the same kind of output as ``bamCoverage``.
The difference is that you now obtain 1 coverage file that is based on 2 BAM files: a bedGraph or a bigwig file containing the bin location and the resulting comparison values.

Like BAM files, bigWig files are compressed, binary files. If you would like to see the coverage values, choose the bedGraph output. For more information on typical NGS file formats, see our `Glossary <http://deeptools.readthedocs.org/en/latest/content/help_glossary.html#file-formats>`_

.. image:: $PATH_TO_IMAGES/bamCompare_output.png
   :width: 600
   :height: 436

-----

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