diff heatmap2.xml @ 5:3b37b1b1c3a7 draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heatmap2 commit b04b237daba99e6992b27d1b65524744feb07d7d"
author iuc
date Tue, 12 Apr 2022 15:53:40 +0000
parents ca7cb0eaad62
children 566197475670
line wrap: on
line diff
--- a/heatmap2.xml	Mon Feb 11 17:32:28 2019 -0500
+++ b/heatmap2.xml	Tue Apr 12 15:53:40 2022 +0000
@@ -1,10 +1,10 @@
 <tool id="ggplot2_heatmap2" name="heatmap2" version="@VERSION@">
     <macros>
-        <token name="@VERSION@">3.0.1</token>
+        <token name="@VERSION@">3.1.1</token>
     </macros>
     <requirements>
         <requirement type="package" version="@VERSION@">r-gplots</requirement>
-        <requirement type="package" version="1.1_2">r-rcolorbrewer</requirement>
+        <requirement type="package" version="1.1_3">r-rcolorbrewer</requirement>
     </requirements>
     <command detect_errors="exit_code"><![CDATA[
 cat '$script' &&
@@ -39,63 +39,91 @@
     linput <- log10(mat_input+1)
 #end if
 
-#if $colorscheme == "whrd"
-    colorscale = colfunc <- colorRampPalette(c("white", "red"))
-#elif $colorscheme == "whblu"
-    colorscale = colfunc <- colorRampPalette(c("white", "blue"))
-#elif $colorscheme == "blwhre"
-    colorscale = colfunc <- colorRampPalette(c("blue","white", "red"))
+#if $zscore_cond.zscore == "rows":
+    linput <- t(apply(linput, 1, scale))
+    colnames(linput) <- colnames(input)
+    rownames(linput) <- input[,1]
+    scale <- "none"
+#elif $zscore_cond.zscore == "cols":
+    linput <- apply(linput, 2, scale)
+    rownames(linput) <- input[,1]
+    scale <- "none"
+#elif $zscore_cond.zscore == "none":
+    scale <- "$zscore_cond.scale"
 #end if
 
-#if $labels== "both"
-    rlabs = NULL
-    clabs = NULL
-#elif $labels== "rows"
-    rlabs = NULL
-    clabs = FALSE
-#elif $labels== "columns"
-    rlabs = FALSE
-    clabs = NULL
-#elif $labels== "none"
-    rlabs = FALSE
-    clabs = FALSE
+srtCol <- 45
+#if $labels == "both"
+    rlabs <- NULL
+    clabs <- NULL
+#elif $labels == "rows"
+    rlabs <- NULL
+    clabs <- FALSE
+    srtCol <- NULL
+#elif $labels == "columns"
+    rlabs <- FALSE
+    clabs <- NULL
+#elif $labels == "none"
+    rlabs <- FALSE
+    clabs <- FALSE
+    srtCol <- NULL
 #end if
 
-pdf(file='$output1')
-colorscale
+#if $cluster_cond.cluster == "yes":
+    dendrogramtoplot <- "$cluster_cond.cluster_cols_rows"
+    #if $cluster_cond.cluster_cols_rows == "both"
+        reorder_cols <- TRUE
+        reorder_rows <- TRUE
+    #elif $cluster_cond.cluster_cols_rows == "row"
+        reorder_cols <- FALSE
+        reorder_rows <- TRUE
+    #elif $cluster_cond.cluster_cols_rows == "column"
+        reorder_cols <- TRUE
+        reorder_rows <- FALSE
+    #end if
+    hclust_fun <- function(x) hclust(x, method='$cluster_cond.clustering')
+    #if $cluster_cond.distance == 'pearson_correlation':
+        dist_fun <- function(x) as.dist(1 - cor(t(x)))
+    #elif $cluster_cond.distance == 'spearmann_correlation':
+        dist_fun <- function(x) as.dist(1 - cor(t(x), method="spearman"))
+    #else:
+        dist_fun <- function(x) dist(x, method='$cluster_cond.distance')
+    #end if
+#else:
+    dendrogramtoplot <- "none"
+    reorder_cols <- FALSE
+    reorder_rows <- FALSE
+    hclust_fun <- hclust
+    dist_fun <- dist
+#end if
 
-#if $cluster_cond.cluster:
-    hclust_fun = function(x) hclust(x, method='$cluster_cond.clustering')
-    dist_fun = function(x) dist(x, method='$cluster_cond.distance')
-    #if $cluster_cond.cluster_cols_rows=="rows":
-        heatmap.2(linput, dendrogram="row", Colv=FALSE, Rowv=TRUE,
-            distfun=dist_fun, hclustfun=hclust_fun, scale = '$scale', labRow = rlabs, labCol = clabs,
-            col=colfunc(50), trace="none", density.info = "none", margins=c(8,8),
-            main = '$title', key.xlab='$key', keysize=1, cexCol=0.8, cexRow = 0.8, srtCol=45)
-    #elif $cluster_cond.cluster_cols_rows=="columns":
-        heatmap.2(linput, dendrogram="column", Colv=TRUE, Rowv=FALSE,
-            distfun=dist_fun, hclustfun=hclust_fun, scale = '$scale', labRow = rlabs, labCol = clabs,
-            col=colfunc(50), trace="none", density.info = "none", margins=c(8,8),
-            main = '$title', key.xlab='$key', keysize=1, cexCol=0.8, cexRow = 0.8, srtCol=45)
-    #else
-        heatmap.2(linput,
-            distfun=dist_fun, hclustfun=hclust_fun, scale = '$scale', labRow = rlabs, labCol = clabs,
-            col=colfunc(50), trace="none", density.info = "none", margins=c(8,8),
-            main = '$title', key.xlab='$key', keysize=1, cexCol=0.8, cexRow = 0.8, srtCol=45)
-    #end if
-#else
-    heatmap.2(linput,
-        dendrogram="none", Colv=FALSE, Rowv=FALSE, scale = '$scale', labRow = rlabs, labCol = clabs,
-        col=colfunc(50), trace="none", density.info = "none", margins=c(8,8),
-        main='$title', key.xlab='$key', keysize=1, cexCol=0.8, cexRow = 0.8, srtCol=45)
+ncolors <- 50
+#if $colorchoice.type == "palettes":
+    colused <- brewer.pal(ncolors, "$colorchoice.name")
+#elif $colorchoice.type == "two"
+    colused <- colorRampPalette(c("$colorchoice.color1", "$colorchoice.color2"))(ncolors)
+#elif $colorchoice.type == "three"
+    colused <- colorRampPalette(c("$colorchoice.color1", "$colorchoice.color2", "$colorchoice.color3"))(ncolors)
 #end if
 
+#if $image_file_format == "pdf":
+    pdf(file='$output1')
+#else:
+    png(file='$output1')
+#end if
+
+heatmap.2(linput, dendrogram=dendrogramtoplot, Colv=reorder_cols, Rowv=reorder_rows,
+    distfun=dist_fun, hclustfun=hclust_fun, scale = scale, labRow = rlabs, labCol = clabs,
+    col=colused, trace="none", density.info = "none", margins=c(8,8),
+    main = '$title', key.xlab='$key', keysize=1, cexCol=0.8, cexRow = 0.8, srtCol=srtCol)
+
 dev.off()
         ]]></configfile>
     </configfiles>
 
     <inputs>
-        <param name="input1" type="data" format="tabular" label="Input should have column headers - these will be the columns that are plotted"/>
+        <param name="input1" type="data" format="tabular"
+               label="Input should have column headers - these will be the columns that are plotted and row names."/>
         <param name="title" type="text" format="txt" label="Plot title"/>
         <param name="key" type="text" format="txt" label="key title"/>
         <param name="transform" type="select" label="Data transformation">
@@ -105,27 +133,55 @@
             <option value="log10">Log10(value) transform my data</option>
             <option value="log10plus1">Log10(value+1) transform my data</option>
         </param>
+        <conditional name="zscore_cond">
+            <param name="zscore" type="select" label="Compute z-scores prior to clustering">
+                <option value="none">Do not compute z-scores</option>
+                <option value="rows">Compute on rows</option>
+                <option value="cols">Compute on columns</option>
+            </param>
+            <when value="none">
+                <param name="scale" type="select" label="Scale data on the plot (after clustering)" >
+                    <option value="none" selected="true">Do not scale my data</option>
+                    <option value="row">Scale my data by row</option>
+                    <option value="column">Scale my data by column</option>
+                </param>
+            </when>
+            <when value="rows"/>
+            <when value="cols"/>
+        </conditional>
         <conditional name="cluster_cond">
             <param name="cluster" type="select" label="Enable data clustering">
-                <option value="true">Yes</option>
-                <option value="">No</option>
+                <option value="yes">Yes</option>
+                <option value="no">No</option>
             </param>
-            <when value="true">
+            <when value="yes">
                 <param name="cluster_cols_rows" type="select" label="Clustering columns and rows">
                     <option value="both" selected="true">Cluster rows and columns</option>
-                    <option value="rows">Cluster rows and not columns</option>
-                    <option value="columns">Cluster columns and not rows</option>
+                    <option value="row">Cluster rows and not columns</option>
+                    <option value="column">Cluster columns and not rows</option>
                 </param>
                 <param name="distance" type="select" label="Distance method" help="The method used to compute the distance (dissimilarity) between both rows and columns. Default: Euclidean" >
                     <option value="euclidean" selected="true">Euclidean</option>
                     <option value="maximum">Maximum</option>
+                    <option value="manhattan">Manhattan</option>
+                    <option value="canberra">Canberra</option>
+                    <option value="binary">Binary</option>
+                    <option value="minkowski">Minkowski</option>
+                    <option value="pearson_correlation">Pearson's correlation (1 - correlation coefficient)</option>
+                    <option value="spearmann_correlation">Spearmann's correlation (1 - correlation coefficient)</option>
                 </param>
                 <param name="clustering" type="select" label="Clustering method" help="The method used to compute the hierarchical clustering. Default: Complete" >
                     <option value="complete" selected="true">Complete</option>
-                    <option value="average">Average</option>
+                    <option value="average">Average (= UPGMA)</option>
+                    <option value="ward.D">ward.D</option>
+                    <option value="ward.D2">ward.D2</option>
+                    <option value="single">single</option>
+                    <option value="mcquitty">mcquitty (= WPGMA)</option>
+                    <option value="median">median (= WPGMC)</option>
+                    <option value="centroid">centroid (= UPGMC)</option>
                 </param>
             </when>
-            <when value=""/>
+            <when value="no"/>
         </conditional>
         <param name="labels" type="select" label="Labeling columns and rows" >
             <option value="both" selected="true">Label my columns and rows</option>
@@ -133,30 +189,94 @@
             <option value="columns">Label columns and not rows</option>
             <option value="none">Do not label rows or columns</option>
         </param>
-        <param name="colorscheme" type="select" label="Coloring groups" >
-            <option value="whrd" selected="true">White to red</option>
-            <option value="whblu">White to blue</option>
-            <option value="blwhre">Blue to white to red</option>
-        </param>
-        <param name="scale" type="select" label="Data scaling" >
-            <option value="none" selected="true">Do not scale my data</option>
-            <option value="row">Scale my data by row</option>
-            <option value="column">Scale my data by column</option>
+        <conditional name="colorchoice">
+            <param name="type" type="select" label="Type of colormap to use">
+                <option value="palettes">RColorBrewer palettes</option>
+                <option value="two">Gradient with 2 colors</option>
+                <option value="three">Gradient with 3 colors</option>
+            </param>
+            <when value="palettes">
+                <param name="name" type="select" label="Name of the colormap">
+                    <option value="BrBG">BrBG</option>
+                    <option value="PiYG">PiYG</option>
+                    <option value="PRGn">PRGn</option>
+                    <option value="PuOr">PuOr</option>
+                    <option value="RdBu">RdBu</option>
+                    <option value="RdGy">RdGy</option>
+                    <option value="RdYlBu">RdYlBu</option>
+                    <option value="RdYlGn">RdYlGn</option>
+                    <option value="Spectral">Spectral</option>
+                    <option value="Blues">Blues</option>
+                    <option value="BuGn">BuGn</option>
+                    <option value="BuPu">BuPu</option>
+                    <option value="GnBu">GnBu</option>
+                    <option value="Greens">Greens</option>
+                    <option value="Greys">Greys</option>
+                    <option value="Oranges">Oranges</option>
+                    <option value="OrRd">OrRd</option>
+                    <option value="PuBu">PuBu</option>
+                    <option value="PuBuGn">PuBuGn</option>
+                    <option value="PuRd">PuRd</option>
+                    <option value="Purples">Purples</option>
+                    <option value="RdPu">RdPu</option>
+                    <option value="Reds">Reds</option>
+                    <option value="YlGn">YlGn</option>
+                    <option value="YlGnBu">YlGnBu</option>
+                    <option value="YlOrBr">YlOrBr</option>
+                    <option value="YlOrRd">YlOrRd</option>
+                </param>
+            </when>
+            <when value="two">
+                <param name="color1" type="color" value="#ffffff" label="First color" />
+                <param name="color2" type="color" value="#ff0000" label="Second color" />
+            </when>
+            <when value="three">
+                <param name="color1" type="color" value="#0000ff" label="First color" />
+                <param name="color2" type="color" value="#ffffff" label="Second color" />
+                <param name="color3" type="color" value="#ff0000" label="Third color" />
+            </when>
+        </conditional>
+        <param name="image_file_format" type="select" label="Output format">
+            <option value="pdf">PDF</option>
+            <option value="png">PNG</option>
         </param>
     </inputs>
     <outputs>
-        <data name="output1" format="pdf"/>
+        <data name="output1" format="pdf">
+            <change_format>
+                <when input="image_file_format" value="png" format="png" />
+            </change_format>
+        </data>
     </outputs>
     <tests>
         <test>
             <param name="input1" value="mtcars.txt"/>
-            <param name="cluster" value="true"/>
+            <param name="cluster" value="yes"/>
+            <param name="type" value="two"/>
             <output name="output1" file="result1.pdf" compare="sim_size"/>
         </test>
         <test>
             <param name="input1" value="mtcars.txt"/>
-            <param name="cluster" value=""/>
-            <output name="output1" file="result2.pdf" compare="sim_size"/>
+            <param name="cluster" value="no"/>
+            <param name="image_file_format" value="png"/>
+            <output name="output1" file="result2.png" compare="sim_size"/>
+        </test>
+        <test>
+            <param name="input1" value="mtcars.txt"/>
+            <param name="zscore" value="cols"/>
+            <param name="cluster" value="yes"/>
+            <param name="cluster_cols_rows" value="row"/>
+            <param name="labels" value="rows"/>
+            <param name="type" value="three"/>
+            <param name="image_file_format" value="png"/>
+            <output name="output1" file="result3.png" compare="sim_size"/>
+        </test>
+        <test>
+            <param name="input1" value="mtcars.txt"/>
+            <param name="cluster" value="yes"/>
+            <param name="distance" value="pearson_correlation"/>
+            <param name="type" value="two"/>
+            <output name="output1" file="result1pearson.pdf" compare="sim_size"/>
         </test>
     </tests>
     <help><![CDATA[