view hicPlotMatrix.xml @ 13:40b33e101621 draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hicexplorer commit 3b41d687ff30583540d055f6995de00530cca81d-dirty"
author bgruening
date Mon, 16 Dec 2019 15:45:27 -0500
parents 653c6fead9f9
children fe13295d0329
line wrap: on
line source

<tool id="hicexplorer_hicplotmatrix" name="@BINARY@" version="@WRAPPER_VERSION@.0">
    <description>plot a Hi-C contact matrix heatmap</description>
    <macros>
        <token name="@BINARY@">hicPlotMatrix</token>
        <import>macros.xml</import>
    </macros>
    <expand macro="requirements" />
    <command detect_errors="exit_code"><![CDATA[

        #if str($pca_conditional.pca_type) == 'bigwig':
            ln -s '$pca_conditional.pca_bigwig' pca.bw &&
            #set $pca = '--bigwig pca.bw'
        #elif str($pca_conditional.pca_type) == '':
            #set $pca = ''
        #end if
        ln -s $matrix_h5_cooler matrix.$matrix_h5_cooler.ext &&
        @BINARY@

            
            --matrix 'matrix.$matrix_h5_cooler.ext'

            #if $title and $title is not None:
                --title '$title'
            #end if

            #if $scoreName and $scoreName is not None:
                --scoreName '$scoreName'
            #end if

            --outFileName plot.$image_file_format

            $perChromosome
            $clearMaskedBins

            ## special: --chromosomeOrder is optional, but if given needs at least one argument
            #set chroms = ' '.join([ '\'' + str($var.chromosome) + '\'' for $var in $chromosomeOrder ])
            #if chroms:
                --chromosomeOrder "$chroms"
            #end if

            #if $region:
                --region '$region'
            #end if

            #if $region2:
                --region2 '$region2'
            #end if
            $log1p
            $log

            #if $colormap:
                --colorMap $colormap
            #end if

            #if $vMin:
                --vMin $vMin
            #end if

            #if $vMax:
                --vMax $vMax
            #end if
            
            #if str($pca_conditional.pca_type) == 'bigwig':
                --vMinBigwig $pca_conditional.vMinBigwig
                --vMaxBigwig $pca_conditional.vMaxBigwig
                $pca_conditional.flipBigwigSign
                --scaleFactorBigwig $pca_conditional.scaleFactorBigwig
                $pca_conditional.bigwigAdditionalVerticalAxis
            #end if 
            $pca
            #if $dpi:
                --dpi $dpi
            #end if 

            #if $loops:
                --loops '$loops'
            #end if
        && mv plot.$image_file_format plot
]]>
    </command>
    <inputs>
        <expand macro='matrix_h5_cooler_macro' />

        <param argument="--title" type="text" optional="true" label="Plot title"/>
        <param argument="--scoreName" type="text" optional="true" label="Score name" help="The label for the heatmap legend."/>
        <param argument="--perChromosome" type="boolean" truevalue="--perChromosome" falsevalue="" checked="false"
            label="Plot per chromosome"
            help="Instead of plotting the whole matrix each chromosome is plotted next to the other. This parameter is not compatible with --region" />
        <param argument="--clearMaskedBins" type="boolean" truevalue="--clearMaskedBins" falsevalue="" checked="false"
            label="Remove masked bins from the matrix"  />

        <repeat name="chromosomeOrder" min="0" title="Chromosomes to include (and order to plot in):"
            help="This option overrides --region and --region2" >
            <param name="chromosome" type="text" >
                <validator type="empty_field" />
            </param>
        </repeat>

        <param argument="--region" type="text" optional="True" label="Plot only this region"
            help="The format is chr:start-end The plotted region contains the main diagonal and is symmetric unless  --region2 is given"/>
        <param argument="--region2" type="text" optional="True" label="Region two to plot"
            help="If given then only the region defined by --region and --region2 is plotted. The format is the same as --region"/>
        <param argument="--log1p" type="boolean" truevalue="--log1p" falsevalue="" checked="false" label="Plot the log1p of the matrix values (log(Hi-C contacts+1)). This option is recommended."/>
        <param argument="--log" type="boolean" truevalue="--log" falsevalue="" checked="false" label="Plot the log of the matrix values. (log(Hi-C contacts))"/>

        <expand macro="colormap" />

        <param argument="--vMin" type="float" optional="true" label="vMin" help="Minimum value of the plotted score."/>
        <param argument="--vMax" type="float" optional="true" label="vMax" help="Maximum value of the plotted score."/>

        <conditional name="pca_conditional">
            <param name='pca_type' label='Datatype of eigenvector file' type='select'>
                <option value='' selected="true"></option>
                <option value='bigwig'>bigwig</option>
            </param>
            <when value='' />
            <when value='bigwig'>
                <param name='pca_bigwig'  type="data" format="bigwig"
                            label="Eigenvector file"/>
                <param argument="--vMinBigwig" type="float" optional="true" label="vMinBigwig" help="Minimum value of the plotted bigwig score."/>
                <param argument="--vMaxBigwig" type="float" optional="true" label="vMaxBigwig" help="Maximum value of the plotted bigwig score."/>
                <param name='flipBigwigSign' type='boolean' optional="true" truevalue='--flipBigwigSign' falsevalue='' label='Flip the sign of the bigwig values' />
                <param argument="--scaleFactorBigwig" type="float" optional="true" label="Scale factor for bigwig" help="Scale the bigwig values by a factor."/>
                <param name='bigwigAdditionalVerticalAxis' type='boolean' optional="true" truevalue='--bigwigAdditionalVerticalAxis' falsevalue='' label='Plot an additional vertical axis.' />


            </when>
        </conditional>
        <param name='loops' type="data" format="interval" optional='True' label="Add detected loops"/>
        <param name="image_file_format" type="select" label="Image output format">
            <option value="png" selected="True">png</option>
            <option value="svg">svg</option>
            <option value="pdf">pdf</option>

        </param>
        <param name='dpi' type='integer' label='DPI for image' help='Change the default resolution of the plot.' optional='true'/>
    </inputs>
    <outputs>
        <data format="png" name="outFileName" from_work_dir="plot" label="${tool.name} on ${matrix_h5_cooler.name} [${on_string}]: Plot">
            <change_format>
                <when input="image_file_format" value="svg" format="svg" />
                <when input="image_file_format" value="pdf" format="pdf" />
            </change_format>
        </data>
    </outputs>
    <tests>
        <test>
            <param name="matrix_h5_cooler" value="small_test_matrix.h5"/>
            <conditional name="pca_conditional">
                <param name="pca_type" value=''/>
            </conditional>
            <param name="region" value="chr2L:3000000-3500000"/>
            <param name="region2" value="chr2L:3100000-3600000"/>
            <param name="log1p" value="True"/>
            <param name="clearMaskedBins" value="True"/>
            <param name="image_file_format" value="png" />
            <param name="dpi" value="10" />

            <output name="outFileName" file="hicPlotMatrix/plot1.png" ftype="png" compare="sim_size"/>
        </test>
        <test>
            <param name="matrix_h5_cooler" value="small_test_matrix.cool"/>
            <param name="region" value="chr2L:3000000-3500000"/>

            <conditional name="pca_conditional">
                <param name="pca_type" value=''/>
            </conditional>
            <param name="image_file_format" value="pdf" />
            <param name="dpi" value="10" />

            <output name="outFileName" file="hicPlotMatrix/plot2.pdf" ftype="pdf" compare="sim_size"/>
        </test>
        <test>
            <param name="matrix_h5_cooler" value="small_test_matrix.cool"/>
            <conditional name="pca_conditional">
                <param name="pca_type" value='bigwig'/>
                <param name="pca_bigwig" value="hicPCA/pca1_test1.bw"/>
                <param name='vMinBigwig' value='10'/>
                <param name='vMaxBigwig' value='20'/>
                <param name='scaleFactorBigwig' value='2000'/>
                <param name='flipBigwigSign' value='True'/>
            </conditional>
            <param name='colormap' value='hot'/>
            <param name="region" value="chr2L:3000000-3500000"/>
            <param name="dpi" value="10" />

            <param name="image_file_format" value="svg" />
            <output name="outFileName" file="hicPlotMatrix/plot3_pca.svg" ftype="svg" compare="sim_size" delta="35000"/>
        </test>
        
    </tests>
    <help><![CDATA[
Contact matrix plot
=======================

**hicPlotMatrix** is a visualization tool for Hi-C contact matrices. It supports to plot genome-wide contact matrices, one or multiple chromosomes, a region or two regions against each other.
Additionally it can plot the result of a principal component analysis obtained by ``hicPCA`` to have a better understanding of A / B compartments.

_________________

Usage
-----

This tool can be used on any h5 or cool Hi-C contact matrix. It is noteworthy that for comparisons of 2 matrices or more, they must all have the same or similar number of contacts.

_________________

Output
------

**hicPlotMatrix** outputs a heatmap of a contact matrix in either png or svg format, below is an example of such a plot:

.. image:: $PATH_TO_IMAGES/hicPlotMatrix.png
   :width: 50%

Contact matrix of *Drosophila melanogaster* embryos visualized using **hicPlotMatrix**. Hi-C matrix bins were merged to a 25 kb bin size using ``hicMergeMatrixBins`` and the matrix has then been corrected using ``hicCorrectMatrix`` before plotting.

Another example is available below using Hi-C data published by `Lieberman-Aiden <https://doi.org/10.1126/science.1181369>`_ in 2009, (`GSE18199 <https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE18199>`_). A Hi-C contact matrix has been plotted with the ``--perChr`` option and the first eigenvector (pca1) computed by ``hicPCA``. For this plot a pearson correlated matrix was used, which is computed by first creating an observed / expected matrix and then a pearson correlation matrix with ``hicTransform``.

.. image:: $PATH_TO_IMAGES/SRR0279XX_perChr_eigenvector1.png
   :width: 70 %

_________________

| For more information about HiCExplorer please consider our documentation on readthedocs.io_

.. _readthedocs.io: http://hicexplorer.readthedocs.io/en/latest/index.html
.. _Colormaps: https://matplotlib.org/examples/color/colormaps_reference.html
]]></help>
    <expand macro="citations" />
</tool>