view heatmap/heatmap.xml @ 0:89902ebc58b9 draft

Imported from capsule None
author devteam
date Thu, 22 Jan 2015 10:41:06 -0500
parents
children
line wrap: on
line source

<tool id="heatmap_1" name="Heatmap " version="1.0.0">
  <description>of numeric data</description>
  <command interpreter="bash">\$R_SCRIPT_PATH/r_wrapper.sh $script_file</command>

  <inputs>
    <param name="main" type="text" value="" size="30" label="Plot Title"/>
    <param name="xlab" type="text" value="" size="30" label="Label for x axis"/>
    <param name="ylab" type="text" value="" size="30" label="Label for y axis"/>
   <param name="input" type="data" format="tabular" label="Dataset"/>
    <param name="var_cols" label="Select columns containing input variables " type="data_column" data_ref="input" numerical="True" multiple="true" >
        <validator type="no_options" message="Please select at least one column."/>
    </param>
    <param name="scale" type="select" label="Center and Scale variables?">
        <option value="none" selected="true">No</option>
        <option value="column">Yes, by column</option>
        <option value="row">Yes, by row</option>
    </param>
    
    <param name="na_remove" type="select" label="Remove NA?">
        <option value="yes" selected="true">Yes</option>
        <option value="no">No</option>
    </param>
    
    <param name="header" type="select" label="Treat first line as header?">
        <option value="yes" selected="true">Yes</option>
        <option value="no">No</option>
    </param>
            
    <param name="dendrogram" type="select" label="Plot dendrogram?">
        <option value="none" selected="true">No</option>
        <option value="column">Only column dendrogram</option>
        <option value="row">Only row dendrogram</option>
        <option value="both">Both row and column dendrograms</option>
    </param>
            
    <param name="col_min" type="select" label="Color at the smallest value">
        <option value="4">Blue</option>
        <option value="1">Black</option>
        <option value="2">Red</option>
        <option value="3">Green</option>
        <option value="5">Cyan</option>
        <option value="6">Magenta</option>
        <option value="7">Yellow</option>
        <option value="8">Gray</option>
     </param>
          
      <param name="col_max" type="select" label="Color at the largest value">
        <option value="7">Yellow</option>
        <option value="1">Black</option>
        <option value="2">Red</option>
        <option value="3">Green</option>
        <option value="4">Blue</option>
        <option value="5">Cyan</option>
        <option value="6">Magenta</option>
        <option value="8">Gray</option>
     </param>
     
  </inputs>

  <configfiles>
    <configfile name="script_file">
      ## Setup R error handling to go to stderr
      options( show.error.messages=F, 
               error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) },
               warn=-1 )
      inp = read.table( "${input.file_name}" )
      x = inp[, c(${var_cols})]
      scale_value = "${scale}"
      na_rm_value = FALSE
      Colv_value = NA
      Rowv_value = NA
      
      #if str($na_remove) == "yes"
      	na_rm_value = TRUE
      #end if
      
      #if str($header) == "yes"
      	colnames(x) = rapply(x[1,], as.character)
      	x = x[2:nrow(x),]
      #end if
      x = apply(x,2,as.numeric)

      #if str($dendrogram) == "row"
      	Rowv_value = TRUE
      #elif str($dendrogram) == "column"
      	Colv_value = TRUE
      #elif str($dendrogram) == "both"
      	Rowv_value = TRUE
      	Colv_value = TRUE
      #end if
      
      ## Open output PDF file
      pdf( "${out_file1}" )
      rgb_palette = colorRampPalette(c("${col_min}", "${col_max}"), space="rgb")
      heatmap(as.matrix(x), main="${main}", xlab="${xlab}", ylab="${ylab}", scale=scale_value, Rowv=Rowv_value, Colv=Colv_value, na.rm=na_rm_value, col=rgb_palette(10))
      ## Close the PDF file
      devname = dev.off() 
    </configfile>
  </configfiles>

  <outputs>
    <data format="pdf" name="out_file1" />
  </outputs>

	<requirements>
    	<requirement type="set_environment">R_SCRIPT_PATH</requirement>
    	<requirement type="package" version="2.15.0">R</requirement>
	</requirements>

    <tests>
        <test>
            <param name="main" value="Heatmap"/>
            <param name="xlab" value="X"/>
            <param name="ylab" value="Y"/>
            <param name="input" value="heatmap_inp.tabular" ftype="tabular"/>
            <param name="var_cols" value="2,4"/>
            <param name="scale" value="column"/>
            <param name="na_remove" value="yes"/>
            <param name="header" value="yes"/>
            <param name="dendrogram" value="none"/>
            <param name="col_min" value="4"/>
            <param name="col_max" value="7"/>
            <output name="out_file1" file="heatmap_out.pdf"/>
        </test>
    </tests>
<help>

.. class:: infomark

**What it does**

This tool uses the 'heatmap' function from R statistical package to draw heatmap using numeric data values contained in columns of a dataset.

*R Development Core Team (2009). R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. ISBN 3-900051-07-0, URL http://www.R-project.org.*

-----

.. class:: warningmark

If "Remove NA" option is not set to "yes", this tool skips entire rows/columns with non-numeric data

-----

**Example**

Input file::

    chromosome GC	    telo	fRec	SNP
    1	       38.6381	51797179	1.0662	0.012289
    2	       38.8651	31413753	1.2255	0.008923
    3	       41.4730	26482501	1.6308	0.015474
    4	       44.9184	12412377	1.4997	0.022099
    5	       39.4870	34991501	1.4439	0.013091
    6	       38.3041	20816323	1.4700	0.014043

Below is a heatmap using columns 2 to 5 from the above data, with centering and scaling by column:

.. image:: ./static/operation_icons/heatmap_output.png

</help>
</tool>