changeset 0:89902ebc58b9 draft

Imported from capsule None
author devteam
date Thu, 22 Jan 2015 10:41:06 -0500
parents
children d423342874f7
files heatmap/heatmap.xml heatmap/r_wrapper.sh heatmap/test-data/heatmap_inp.tabular heatmap/test-data/heatmap_out.pdf heatmap/tool_dependencies.xml
diffstat 5 files changed, 212 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/heatmap/heatmap.xml	Thu Jan 22 10:41:06 2015 -0500
@@ -0,0 +1,161 @@
+<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>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/heatmap/r_wrapper.sh	Thu Jan 22 10:41:06 2015 -0500
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+### Run R providing the R script in $1 as standard input and passing 
+### the remaining arguments on the command line
+
+# Function that writes a message to stderr and exits
+function fail
+{
+    echo "$@" >&2
+    exit 1
+}
+
+# Ensure R executable is found
+which R > /dev/null || fail "'R' is required by this tool but was not found on path" 
+
+# Extract first argument
+infile=$1; shift
+
+# Ensure the file exists
+test -f $infile || fail "R input file '$infile' does not exist"
+
+# Invoke R passing file named by first argument to stdin
+R --vanilla --slave $* < $infile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/heatmap/test-data/heatmap_inp.tabular	Thu Jan 22 10:41:06 2015 -0500
@@ -0,0 +1,7 @@
+state	GC	telo	fRec	SNP
+1	38.6381	51797179	1.066205	0.012289
+2	38.8651	31413753	1.22548	0.008923
+3	41.473	26482501	1.63077	0.015474
+4	44.9184	12412376.5	1.499715	0.022099
+5	39.487	34991500.5	1.44399	0.013091
+6	38.3041	20816323	1.47006	0.014043
Binary file heatmap/test-data/heatmap_out.pdf has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/heatmap/tool_dependencies.xml	Thu Jan 22 10:41:06 2015 -0500
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<tool_dependency>
+    <set_environment version="1.0">
+        <environment_variable name="R_SCRIPT_PATH" action="set_to">$REPOSITORY_INSTALL_DIR</environment_variable>
+    </set_environment>
+    <package name="R" version="2.15.0">
+        <install version="1.0">
+            <actions>
+                <action type="download_by_url">http://CRAN.R-project.org/src/base/R-2/R-2.15.0.tar.gz</action>
+                <action type="shell_command">./configure --prefix=$INSTALL_DIR</action>
+                <action type="shell_command">make</action>
+                <action type="set_environment">
+                    <environment_variable name="PATH" action="prepend_to">$INSTALL_DIR/bin</environment_variable>
+                </action>
+            </actions>
+        </install>
+        <readme>
+You need a FORTRAN compiler or perhaps f2c in addition to a C compiler to build R.
+        </readme>
+    </package>
+</tool_dependency>