view hicPlotMatrix.xml @ 19:7babd8a46fe0 draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hicexplorer commit 2a0943e78bdc8ebb13f181399206a9eea37ed78f"
author iuc
date Tue, 16 Mar 2021 15:24:48 +0000
parents b553d14a7845
children 9939786dd9c9
line wrap: on
line source

<tool id="hicexplorer_hicplotmatrix" name="@BINARY@" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@">
    <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':
                #if $pca_conditional.vMinBigwig:
                    --vMinBigwig $pca_conditional.vMinBigwig
                #end if
                #if $pca_conditional.vMaxBigwig:
                    --vMaxBigwig $pca_conditional.vMaxBigwig
                #end if
                $pca_conditional.flipBigwigSign

                #if $pca_conditional.scaleFactorBigwig:
                    --scaleFactorBigwig $pca_conditional.scaleFactorBigwig
                #end if
                $pca_conditional.bigwigAdditionalVerticalAxis
            #end if
            $pca
            #if $dpi:
                --dpi $dpi
            #end if

            #if $fontSize:
                --fontSize $fontSize
            #end if

            #if $rotationX:
                --rotationX $rotationX
            #end if

            #if $rotationY:
                --rotationY $rotationY
            #end if

            #if $increaseFigureWidth:
                --increaseFigureWidth $increaseFigureWidth
            #end if

            #if $increaseFigureHeight:
                --increaseFigureHeight $increaseFigureHeight
            #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">
            <validator type="expression" message="Only alphanumeric characters and a space are allowed.">value.isalnum()</validator>
        </param>
        <param argument="--scoreName" type="text" optional="true" label="Score name" help="The label for the heatmap legend.">
            <validator type="expression" message="Only alphanumeric characters and a space are allowed.">value.isalnum()</validator>
        </param>
        <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">
            <validator type="expression" message="Only alphanumeric characters, the colon or a dash are allowed.">value.replace(':', '').replace('-', '').isalnum()</validator>
        </param>
        <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">
            <validator type="expression" message="Only alphanumeric characters, the colon or a dash are allowed.">value.replace(':', '').replace('-', '').isalnum()</validator>
        </param>
        <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))" />
        <param argument="--fontSize" type="integer" optional="true" label="Font size" help="Fontsize in the plot for x and y axis." />
        <param argument="--rotationX" type="integer" optional="true" label="Rotate x-labels by degree" help="Rotation in degrees for the labels of x-axis." />
        <param argument="--rotationY" type="integer" optional="true" label="Rotate y-labels by degree" help="Rotation in degrees for the labels of y-axis." />
        <param argument="--increaseFigureWidth" type="float" value='0.5' optional="true" label="Increase figure width size" help="Plotting additional bigwig tracks can cause compression in x or y direction of the heatmap. Set this factor to a value unequal to 0 to correct this." />
        <param argument="--increaseFigureHeight" type="float" value='0.5' optional="true" label="Increase figure height size" help="Plotting additional bigwig tracks can cause compression in x or y direction of the heatmap. Set this factor to a value unequal to 0 to correct this." />
        <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>
        <expand macro="dpi" />
    </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" />
        </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>