view loadandplot.xml @ 33:40542bd944eb draft

Deleted selected files
author fabio
date Wed, 31 May 2017 12:39:59 -0400
parents 565118df598a
children 7e5e94fe6b1f
line wrap: on
line source

<tool id="loadandplot" name="IWTomics Load" version="@VERSION@.0">
  <description>Smooth and Plot</description>
  <macros>
    <import>macros.xml</import>
  </macros>
  <expand macro="requirements" />
  <stdio>
    <exit_code range="255" source="both" level="fatal" description="Missing IWTomics package. Please be sure to have it installed before using this tool." />
    <exit_code range="10" source="both" level="fatal" description="An error has occurred reading the header file for regions. Please try again." />
    <exit_code range="11" source="both" level="fatal" description="Not all region files are present in the first column of header file for regions." />
    <exit_code range="20" source="both" level="fatal" description="An error has occurred reading the header file for features. Please try again." />
    <exit_code range="21" source="both" level="fatal" description="Not all feature files are present in the first column of header file for features." />
    <exit_code range="30" source="both" level="fatal" description="An error has occurred reading the data. Please try again." />
    <exit_code range="31" source="both" level="fatal" description="Not enough columns in input file." />
    <exit_code range="32" source="both" level="fatal" description="Duplicated regions in region file." />
    <exit_code range="33" source="both" level="fatal" description="Duplicated windows in feature file." />
    <exit_code range="34" source="both" level="fatal" description="Overlapping windows in feature file." />
    <exit_code range="35" source="both" level="fatal" description="Windows in feature files do not cover all regions in region files." />
    <exit_code range="36" source="both" level="fatal" description="All windows in a feature file must have the same size." />
    <exit_code range="40" source="both" level="fatal" description="An error has occurred smoothing the data. Please try again." />
    <regex match="Error" source="both" level="fatal" description="An error has occurred. Please try again." />
  </stdio>

  <command>
<![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 = '"\\|"'.join( [ str( $rh.regionsheader ) for $rh in $regionsheaderrepeat ] )
      #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 = '"\\|"'.join( [ str( $fh.featuresheader ) for $fh in $featuresheaderrepeat ] )
      #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

      >& /dev/null
]]>
    <!--
    to print the stack add the following line at the end of the command and enable the corresponding entry in output
    2> "${stackerr}"
    -->
  </command>

  <inputs>
    <!-- regions -->
    <param format="tabular" name="regions" type="data" label="Select region files" multiple="true" help="" />
    <repeat name="regionsheaderrepeat" title="Header file for regions (optional)" min="0" max="1" 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" />
    </repeat>

    <!-- features -->
    <param format="tabular" name="features" type="data" label="Select feature files" multiple="true" help="" />
    <repeat name="featuresheaderrepeat" title="Header file for features (optional)" min="0" max="1" 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" />
    </repeat>

    <!-- 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="txt" name="stackerr" label="iwtomics.loadandplot.stackerr.txt" from_work_dir="iwtomics.loadandplot.stackerr.txt" />-->
    <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>

  <help>
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) and Marzia A. Cremona (The Pennsylvania State University, USA).

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
  </help>

  <citations>
    <citation type="bibtex">
      @ARTICLE{
               iwt-functional-data,
               author = {Pini, Alessia and Vantini, Simone},
               title = {Interval-Wise Testing for functional data},
               journal = {Journal of Nonparametric Statistics},
               year = {2017},
               volume = {29},
               number = {2},
               pages = {407-424}
      }
    </citation>
    <citation type="bibtex">
      @MANUAL{
               iwtomics,
               author = {Cremona, Marzia A and Pini, Alessia and Chiaromonte, Francesca and Vantini, Simone},
               title = {IWTomics: Interval-Wise Testing for Omics Data},
               note = {R package version 0.99.12},
               year = {2017}
      }
    </citation>
  </citations>

</tool>