changeset 2:17f627ee8f5a draft

"planemo upload for repository https://github.com/artbio/tools-artbio/tree/master/tools/high_dim_heatmap commit ba6089071a53fbf08df00c0f94dfc8515b7c858b"
author artbio
date Tue, 26 Oct 2021 10:22:28 +0000
parents 58b36ae7baca
children cf72f579d100
files heatmap.xml test-data/complex_result1.pdf test-data/result1.pdf test-data/result2.pdf
diffstat 4 files changed, 38 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/heatmap.xml	Thu Oct 22 21:47:10 2020 +0000
+++ b/heatmap.xml	Tue Oct 26 10:22:28 2021 +0000
@@ -1,4 +1,4 @@
-<tool id="high_dim_heatmap" name="Plot heatmap" version="1.1.0">
+<tool id="high_dim_heatmap" name="Plot heatmap" version="1.2.0">
     <description>with high number of rows</description>
     <requirements>
         <requirement type="package" version="3.0.1">r-gplots</requirement>
@@ -22,29 +22,29 @@
 
 input <- read.delim('$input1', sep='\t', header=TRUE)
 
-mat_input <- data.matrix(input[,2:ncol(input)])
-rownames(mat_input) <- input[,1]
+mat_input <- data.matrix(input[, 2:ncol(input)])
+rownames(mat_input) <- input[, 1]
 
 #if $transform == "none"
     linput <- mat_input
 #elif $transform == "log2"
     linput <- log2(mat_input)
 #elif $transform == "log2plus1"
-    linput <- log2(mat_input+1)
+    linput <- log2(mat_input + 1)
 #elif $transform == "log10"
     linput <- log10(mat_input)
 #elif $transform == "log10plus1"
-    linput <- log10(mat_input+1)
+    linput <- log10(mat_input + 1)
 #end if
 
 #if $colorscheme == "whrd"
-    colorscale = colfunc <- colorRampPalette(c("white", "red"))
+    colfunc <- colorRampPalette(c("white", "red"))
 #elif $colorscheme == "whblu"
-    colorscale = colfunc <- colorRampPalette(c("white", "blue"))
+    colfunc <- colorRampPalette(c("white", "blue"))
 #elif $colorscheme == "blwhre"
-    colorscale = colfunc <- colorRampPalette(c("blue","white", "red"))
+    colfunc <- colorRampPalette(c("blue","white", "red"))
 #elif $colorscheme == "yeblu"
-    colorscale = colfunc <- colorRampPalette(c("lightyellow", "royalblue4"))
+    colfunc <- colorRampPalette(c("lightyellow", "royalblue4"))
 #end if
 
 #if $labels== "both"
@@ -61,37 +61,37 @@
     clabs = FALSE
 #end if
 
-pdf(file='$output1', paper='special', height=$height)
-colorscale
+pdf(file = '$output1', paper = 'special', height = $height)
+par(cex.main = $title_size)
 
 #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 = $rowfontsize, srtCol=45,
-            lhei=c(1, $lineheight))
-    #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 = $rowfontsize, srtCol=45,
-            lhei=c(1, $lineheight))
+    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 = $rowfontsize, srtCol = 45, lhei = c(1, $lineheight))
+    #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 = $rowfontsize, srtCol = 45, lhei = c(1, $lineheight))
     #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 = $rowfontsize, srtCol=45,
-            lhei=c(1, $lineheight))
+            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 = $rowfontsize, srtCol = 45, lhei = c(1, $lineheight))
     #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 = $rowfontsize, srtCol=45,
-        lhei=c(1, $lineheight))
+        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 = $rowfontsize, srtCol = 45, lhei = c(1, $lineheight))
 #end if
 
 dev.off()
@@ -149,6 +149,7 @@
             <option value="column">Scale my data by column</option>
         </param>
 
+        <param name="title_size" type="float" label="tweak main title size" value="1" />
         <param name="height" type="float" label="tweak plot height" value="7" />
         <param name="rowfontsize" type="float" label="tweak row label size" value="0.8" />
         <param name="lineheight" type="integer" label="tweak line height" value="4" />
@@ -159,16 +160,20 @@
     <tests>
         <test>
             <param name="input1" value="mtcars.txt"/>
+            <param name="title" value="This is a pretty long title"/>
             <param name="cluster" value="true"/>
             <output name="output1" file="result1.pdf"/>
         </test>
         <test>
             <param name="input1" value="mtcars.txt"/>
+            <param name="title" value="This is a pretty long title"/>
             <param name="cluster" value=""/>
             <output name="output1" file="result2.pdf"/>
         </test>
         <test>
             <param name="input1" value="complex_table.tsv"/>
+            <param name="title" value="This is a pretty long title for a complex plot"/>
+            <param name="title_size" value="0.7"/>
             <param name="transform" value="log2plus1"/>
             <param name="cluster" value=""/>
             <param name="colorscheme" value="blwhre"/>
Binary file test-data/complex_result1.pdf has changed
Binary file test-data/result1.pdf has changed
Binary file test-data/result2.pdf has changed