view loadandplot.xml @ 74:2bb6b44093ba draft

Uploaded 20170619
author fabio
date Mon, 19 Jun 2017 12:08:59 -0400
parents a3bfaf944f73
children 7dcc25a1a062
line wrap: on
line source

<tool id="iwtomics_loadandplot" name="IWTomics Load" version="@VERSION@.0">
  <description>Smooth and Plot</description>
  <macros>
    <import>macros.xml</import>
  </macros>
  <expand macro="requirements" />

  <command detect_errors="exit_code">
<![CDATA[
    Rscript '$__tool_directory__/loadandplot.R' outrdata='${outrdata}' outregions='${outregions}' outfeatures='${outfeatures}' outpdf='${outpdf}'

      #set region_paths = '|'.join( [ str( $r ) for $r in $regions ] )
      regionspaths='${region_paths}'
      #set region_galaxyids = ','.join( [ str( $r.hid ) for $r in $regions ] )
      regionsgalaxyids='c(${region_galaxyids})'
      #set region_names = '|'.join( [ str( $r.name ) for $r in $regions ] )
      regionsfilenames='${region_names}'
      #set region_header = $regionsheadersection.regionsheader
      #if $region_header != "":
        regionsheaderfile='${region_header}'
      #end if
      
      #set feature_paths = '|'.join( [ str( $f ) for $f in $features ] )
      featurespaths='${feature_paths}'
      #set feature_galaxyids = ','.join( [ str( $f.hid ) for $f in $features ] )
      featuresgalaxyids='c(${feature_galaxyids})'
      #set feature_names = '|'.join( [ str( $f.name ) for $f in $features ] )
      featuresfilenames='${feature_names}'
      #set feature_header = $featuresheadersection.featuresheader
      #if $feature_header != "":
        featuresheaderfile='${feature_header}'
      #end if

      smoothing="'${conditionaltype.smoothing}'"
      start.are.0based='${zerobased}'
      #if $conditionaltype.smoothing == 'no':
        alignment="'${conditionaltype.alignment}'"
      #elif $conditionaltype.smoothing == 'locpoly':
        alignment="'${conditionaltype.locpolyconditionalscale.alignment}'"
        #if $conditionaltype.locpolyconditionalscale.alignment == 'scale':
          scale='${conditionaltype.locpolyconditionalscale.scalegrid}'
        #end if
        bandwidth='${conditionaltype.locpolybandwidth}'
        degree='${conditionaltype.locpolydegree}'
        fill_gaps='${conditionaltype.fillgaps}'
      #elif $conditionaltype.smoothing == 'kernel':
        alignment="'${conditionaltype.kernelconditionalscale.alignment}'"
        #if $conditionaltype.kernelconditionalscale.alignment == 'scale':
          scale='${conditionaltype.kernelconditionalscale.scalegrid}'
        #end if
        bandwidth='${conditionaltype.kernelbandwidth}'
        fill_gaps='${conditionaltype.fillgaps}'
      #elif $conditionaltype.smoothing == 'splines':
        alignment="'${conditionaltype.splinesconditionalscale.alignment}'"
        #if $conditionaltype.splinesconditionalscale.alignment == 'scale':
          scale='${conditionaltype.splinesconditionalscale.scalegrid}'
        #end if
        degree='${conditionaltype.splinesdegree}'
        dist_knots='${conditionaltype.splinesdistknots}'
        fill_gaps='${conditionaltype.fillgaps}'
      #end if

      average='${plotres.average}'
      size='${plotres.size}'
      plottype="'${plotres.conditionalplottype.plottype}'"
      #if $plotres.conditionalplottype.plottype == 'boxplot':
        #set probs = ','.join( [ str( $p.prob ) for $p in $plotres.conditionalplottype.probabilitiessection.probabilities ] )
        #if $probs != "":
          probs='c(${plotres.conditionalplottype.probabilitiessection.prob0},${plotres.conditionalplottype.probabilitiessection.prob1},${plotres.conditionalplottype.probabilitiessection.prob2},${probs})'
        #else:
          probs='c(${plotres.conditionalplottype.probabilitiessection.prob0},${plotres.conditionalplottype.probabilitiessection.prob1},${plotres.conditionalplottype.probabilitiessection.prob2})'
        #end if
      #end if      
]]>
  </command>

  <inputs>
    <!-- regions -->
    <param format="tabular" name="regions" type="data" label="Select region files" multiple="true" help="" />
    <section name="regionsheadersection" title="Insert header file for regions (optional)" expanded="false" help="Tabular file. Column 1: names of the region files; Column 2: unique identifiers of the region datasets (spaces and special characters are not allowed); Column 3: name of the region datasets to be used in the output.">
      <param format="tabular" name="regionsheader" type="data" label="Select header file" optional="true" />
    </section>

    <!-- features -->
    <param format="tabular" name="features" type="data" label="Select feature files" multiple="true" help="" />
    <section name="featuresheadersection" title="Insert header file for features (optional)" expanded="false" help="Tabular file. Column 1: names of the feature files; Column 2: unique identifiers of the features (spaces and special characters are not allowed); Column 3: name of the features to be used in the output.">
      <param format="tabular" name="featuresheader" type="data" label="Select header file" optional="true" />
    </section>

    <!-- zero-base one-base -->
    <param name="zerobased" type="select" label="Start positions are:" multiple="false" help="">
      <option value="TRUE">0-based</option>
      <option value="FALSE">1-based</option>
    </param>

    <!-- conditional smoothing -->
    <conditional name="conditionaltype">
      <!-- smoothing -->
      <param name="smoothing" type="select" label="Smoothing" help="Type of smoothing to be applied to the feature curves.">
        <option value="no">No</option>
        <option value="locpoly">Local Polynomials</option>
        <option value="kernel">Gaussian Kernel</option>
        <option value="splines">B-Splines</option>
      </param>
      <!-- conditional choice: smoothing=no -->
      <when value="no">
        <param name="alignment" type="select" label="Region alignment" help="">
          <option value="center">Center - Alignment on the central position</option>
          <option value="left">Left - Alignment on the starting position</option>
          <option value="right">Right - Alignment on the ending position</option>
        </param>
      </when>
      <!-- conditional choice: smoothing=locpoly -->
      <when value="locpoly">
        <!-- conditional region alignment -->
        <conditional name="locpolyconditionalscale">
          <param name="alignment" type="select" label="Region alignment" help="">
            <option value="center">Center - Alignment on the central position</option>
            <option value="left">Left - Alignment on the starting position</option>
            <option value="right">Right - Alignment on the ending position</option>
            <option value="scale">Scale - Scaling all regions to the same length</option>
          </param>
          <when value="scale">
            <param name="scalegrid" type="integer" value="0" min="0" label="Number of grid points" help="Number of equally-spaced grid points over which the smoothed curves are evaluated." />
          </when>
        </conditional>

        <param name="locpolybandwidth" type="integer" value="5" min="2" label="Bandwidth for smoothing" help="" />
        <param name="locpolydegree" type="integer" value="3" min="0" label="Degree of local polynomial" help="" />

        <!-- fill gaps -->
        <param name="fillgaps" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="True" label="Use smoothing to fill gaps (NA measurements)" help="" />
      </when>
      <!-- conditional choice: smoothing=kernel -->
      <when value="kernel">
        <!-- conditional region alignment -->
        <conditional name="kernelconditionalscale">
          <param name="alignment" type="select" label="Region alignment" help="">
            <option value="center">Center - Alignment on the central position</option>
            <option value="left">Left - Alignment on the starting position</option>
            <option value="right">Right - Alignment on the ending position</option>
            <option value="scale">Scale - Scaling all regions to the same length</option>
          </param>
          <when value="scale">
            <param name="scalegrid" type="integer" value="0" min="0" label="Number of grid points" help="Number of equally-spaced grid points over which the smoothed curves are evaluated." />
          </when>
        </conditional>

        <param name="kernelbandwidth" type="integer" value="5" min="2" label="Bandwidth for smoothing" help="" />

        <!-- fill gaps -->
        <param name="fillgaps" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="True" label="Use smoothing to fill gaps (NA measurements)" help="" />
      </when>
      <!-- conditional choice: smoothing=splines -->
      <when value="splines">
        <!-- conditional region alignment -->
        <conditional name="splinesconditionalscale">
          <param name="alignment" type="select" label="Region alignment" help="">
            <option value="center">Center - Alignment on the central position</option>
            <option value="left">Left - Alignment on the starting position</option>
            <option value="right">Right - Alignment on the ending position</option>
            <option value="scale">Scale - Scaling all regions to the same length</option>
          </param>
          <when value="scale">
            <param name="scalegrid" type="integer" value="0" min="0" label="Number of grid points" help="Number of equally-spaced grid points over which the smoothed curves are evaluated." />
          </when>
        </conditional>

        <param name="splinesdegree" type="integer" value="3" min="0" label="Degree of B-splines" help="" />
        <param name="splinesdistknots" type="integer" value="10" min="2" label="Distance between nodes (approximate)" help="" />

        <!-- fill gaps -->
        <param name="fillgaps" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="True" label="Use smoothing to fill gaps (NA measurements)" help="" />
      </when>
    </conditional>

    <!-- plot IWTomics results -->
    <section name="plotres" title="Plot data" expanded="True">
      <!-- average -->
      <param name="average" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="True" label="Plot the mean curves" help="" />
      <!-- sample size in each position -->
      <param name="size" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="True" label="Plot sample size in each position" help="" />
      <!-- conditional plot type -->
      <conditional name="conditionalplottype">
        <!-- plot type -->
        <param name="plottype" type="select" label="Plot type" help="">
          <option value="boxplot">Pointwise quantile curves (boxplot)</option>
          <option value="curves">Curves (aligned)</option>
        </param>
        <!-- conditional choice: plottype=boxplot -->
        <when value="boxplot">
          <section name="probabilitiessection" title="Probabilities" expanded="True" help="Probabilities corresponding to the quantile curves to be drawn.">
            <param name="prob0" size="3" type="float" value="0.25" min="0.0" max="1.0" label="Probability" />
            <param name="prob1" size="3" type="float" value="0.5" min="0.0" max="1.0" label="Probability" />
            <param name="prob2" size="3" type="float" value="0.75" min="0.0" max="1.0" label="Probability" />
            <repeat name="probabilities" title="Probabilities">
              <param name="prob" size="3" type="float" value="0.5" min="0.0" max="1.0" label="Probability" />
            </repeat>
          </section>
        </when>
      </conditional>
    </section>
  </inputs>

  <outputs>
    <data format="rdata" name="outrdata" label="${tool.name} on ${on_string}: IWTomicsData Object" from_work_dir="iwtomics.loadandplot.RData" />
    <data format="tabular" name="outregions" label="${tool.name} on ${on_string}: Region Dataset IDs" from_work_dir="iwtomics.loadandplot.regions.txt" />
    <data format="tabular" name="outfeatures" label="${tool.name} on ${on_string}: Feature IDs" from_work_dir="iwtomics.loadandplot.features.txt" />
    <data format="pdf" name="outpdf" label="${tool.name} on ${on_string}: Plotted Data" from_work_dir="iwtomics.loadandplot.pdf" />
  </outputs>

  <tests>
    <test>
      <param name="regions" value="input/Controls_regions.bed,input/Elements1_regions.bed,input/Elements2_regions.bed,input/Elements3_regions.bed" ftype="bed" />
      <param name="regionsheader" value="input/regions.header.txt" ftype="tabular" />
      <param name="features" value="input/Feature1.bed,input/Feature2.bed" ftype="bed" />
      <param name="featuresheader" value="input/features.header.bed.txt" ftype="tabular" />
      <param name="zerobased" value="TRUE" />
      <param name="smoothing" value="kernel" />
      <param name="alignment" value="center" />
      <param name="kernelbandwidth" value="5" />
      <param name="fillgaps" value="TRUE" />
      <param name="average" value="TRUE" />
      <param name="size" value="TRUE" />
      <param name="plottype" value="boxplot" />
      <param name="prob0" value="0.25" />
      <param name="prob1" value="0.5" />
      <param name="prob2" value="0.75" />
      <output name="outrdata" file="output_loadandplot/iwtomics.loadandplot.RData" compare="sim_size" />
      <output name="outregions" file="output_loadandplot/iwtomics.loadandplot.regions.txt" />
      <output name="outfeatures" file="output_loadandplot/iwtomics.loadandplot.features.txt" />
      <output name="outpdf" file="output_loadandplot/iwtomics.loadandplot.pdf" compare="sim_size" />
    </test>
  </tests>

  <help><![CDATA[
This tool imports a collection of genomic region datasets, and associates to each region
multiple genomic feature measurements. It allows to align the regions in multiple ways
(center, left, right or scale alignment), to smooth the feature curves (possibly filling gaps in the
measurements) and to create a graphical representation of the feature measurements in each
region datasets (aligned curves or pointwise quantile curves).

-----

**Region datasets**

Each region dataset can be provided as a BED or Tabular file with tab delimited columns chr
start end (extra columns present in the input file are ignored). Regions can be of different
length::

    chr2  49960150  50060150
    chr2  55912445  56012445
    ...

-----

**Feature measurements**

Feature measurements corresponding to all the regions can be provided as a BED or Tabular
file with tab delimited columns chr start end value::

    chr2  49960150  49962150  0.9426
    chr2  49962150  49964150  0.7816
    ...

Each feature must be measured in windows of a fixed size inside all the regions (missing
values must be indicated as NA). Another way to import feature measurements is from a
Tabular file with the first three columns chr start end corresponding to the different genomic
regions, followed on the same row by all the measurements in fixed-size windows::

    chr2  49960150  50060150  0.9426  0.7816  0.8921  ...  ...  1.2063
    chr2  55912445  56012445  0.8719  0.9975  1.1619  ...  ...  0.9601
    ...

-----

**Output**

The tool returns:

1. RData with the IWTomicsData object, that stores the aligned genomic region datasets, and their associated feature measurements;
2. Region dataset identifiers;
3. Feature identifiers;
4. PDF file with the plotted data.

1-3 can be used as input of the tool *IWTomics Test and Plot*

-----

.. class:: infomark

**Notes**

This Galaxy tool has been developed by Fabio Cumbo (Third University of Rome, Italy - fabio.cumbo@iasi.cnr.it) and Marzia A. Cremona (The Pennsylvania State University, USA - mac78@psu.edu).

It implements a simplified version of the methods *smooth* and *plot* for *IWTomicsData* objects.
The complete version can be found in the *R/Bioconductor* package *IWTomics* (see vignette_).

.. _vignette: https://bioconductor.org/packages/release/bioc/vignettes/IWTomics/inst/doc/IWTomics.pdf

Example data can be found at:

1. Simulated_data_
2. ETn_data_

.. _Simulated_data: https://usegalaxy.org/u/fabio-cumbo/h/iwtomics-example
.. _ETn_data: https://usegalaxy.org/u/fabio-cumbo/h/iwtomics-etn-example
  ]]></help>

  <expand macro="citations" />

</tool>