diff mz_images.xml @ 2:27a4c660bbca draft

planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/cardinal commit f127be2141cf22e269c85282d226eb16fe14a9c1
author galaxyp
date Fri, 15 Feb 2019 10:20:01 -0500
parents 4d5f798a7a18
children 773a24b240e1
line wrap: on
line diff
--- a/mz_images.xml	Thu Oct 25 07:27:54 2018 -0400
+++ b/mz_images.xml	Fri Feb 15 10:20:01 2019 -0500
@@ -1,4 +1,4 @@
-<tool id="cardinal_mz_images" name="MSI mz images" version="@VERSION@.1">
+<tool id="cardinal_mz_images" name="MSI mz images" version="@VERSION@.2">
     <description>
         mass spectrometry imaging m/z heatmaps
     </description>
@@ -58,9 +58,9 @@
 
 ############################# II) images ####################################
 
-### only plot images when file has peaks and valid input m/z: 
+### only plot images when file has features and pixels: 
 
-if (npeaks > 0){
+if (ncol(msidata)>0 & nrow(msidata) >0){
     if (length(inputmz) != 0){
         for (mass in 1:length(inputmz)){
 
@@ -70,7 +70,7 @@
                 print("standard image")
 
                 print(image(msidata, mz=inputmz[mass],plusminus = $plusminus_dalton, contrast.enhance = "$image_contrast", 
-                smooth.image = "$image_smoothing", strip=$strip, colorkey=$colorkey,ylim= c(maximumy+0.1*maximumy,minimumy-0.1*minimumy),
+                smooth.image = "$image_smoothing", strip=$strip, colorkey=$colorkey,ylim= c(maximumy+0.2*maximumy,minimumy-1),
                 main= paste0(inputnames[mass], " (", round(inputmz[mass], digits = 2)," ± ", $plusminus_dalton, " Da)")))}
 
 
@@ -83,7 +83,7 @@
 
                 print(image(msidata, mz=inputmz[mass], strip = strip.custom(bg="lightgrey", par.strip.text=list(col="black", cex=.9)),
                 lattice=TRUE, plusminus = $plusminus_dalton, contrast.enhance = "$image_contrast", smooth.image = "$image_smoothing", 
-                colorkey=$colorkey,ylim= c(maximumy+0.1*maximumy,minimumy-0.1*minimumy),
+                colorkey=$colorkey,ylim=c(maximumy+0.2*maximumy,minimumy-1),
                 main= paste0(inputnames[mass], " (", round(inputmz[mass], digits = 2)," ± ", $plusminus_dalton, " Da)")))}
 
                 #elif str($strip) =="FALSE": 
@@ -100,16 +100,38 @@
         ## optional svg output with original coordinates
         #if $svg_pixelimage:
             print("svg pixel image")
+            ## reverse y axis for svg output = correct order and nice svg image
+            coord(msidata)\$y <- max(coord(msidata)\$y) - coord(msidata)\$y + 1
             svg(file="svg_pixel_output.svg")
             par(mar=c(0,0,0,0))
-            image(msidata, mz = inputmz[1],strip=FALSE, ylim=c(maximumy, minimumy), plusminus = $plusminus_dalton,colorkey = FALSE,axes=FALSE, xlab=NA, ylab=NA,contrast.enhance = "$image_contrast", smooth.image = "$image_smoothing")
+            image(msidata, mz = inputmz[1],strip=FALSE, plusminus = $plusminus_dalton,colorkey = FALSE,axes=FALSE, xlab=NA, ylab=NA,contrast.enhance = "$image_contrast", smooth.image = "$image_smoothing")
             dev.off()
         #end if
 
+        ## optional overlay all input m/z in one image
+        #if str($overlay_cond.overlay_selection) == "yes_overlay":
+
+        #set $color_string = ','.join(['"%s"' % $color.feature_color for $color in $overlay_cond.colours])
+        colourvector = c($color_string)
+
+            image(msidata, mz=inputmz, 
+                  plusminus = $plusminus_dalton,
+                  col=colourvector,
+                  contrast.enhance = "$image_contrast", 
+                  normalize.image="linear",
+                  smooth.image = "$image_smoothing",
+                  superpose=TRUE, main="overlay of all m/z", 
+                  ylim= c(maximumy+0.2*maximumy,minimumy-1))
+
+                legend("topright",
+                       fill=colourvector,
+                       legend=as.numeric(sort(as.character(inputmz))))
+        #end if
+
     } else {print("The input m/z were invalid")}
     dev.off()
 }else{
-    print("inputfile has no intensities > 0")
+    print("input file has no features or pixels left")
 dev.off()
 }
 
@@ -138,9 +160,27 @@
         <param name="image_type" type="boolean" checked="True" truevalue="standard_image" falsevalue="lattice_image"
             label="Standard image" help="No: lattice function is used to display image"/>
         <param name="svg_pixelimage" type="boolean" label="Export first valid m/z from tabular file as SVG"/>
+        <conditional name="overlay_cond">
+            <param name="overlay_selection" type="select" label="Overlay image">
+                <option value="no_overlay" selected="True">no</option>
+                <option value="yes_overlay">yes</option>
+            </param>
+            <when value="no_overlay"/>
+            <when value="yes_overlay">
+            <repeat name="colours" title="Colours for the plots" min="1" max="50">
+                <param name="feature_color" type="color" label="Colours" value="#ff00ff" help="Numbers of colours should be the same as number of m/z in tabular file">
+                  <sanitizer>
+                    <valid initial="string.letters,string.digits">
+                      <add value="#" />
+                    </valid>
+                  </sanitizer>
+                </param>
+            </repeat>
+            </when>
+        </conditional>
     </inputs>
     <outputs>
-        <data format="pdf" name="plots" from_work_dir="heatmaps.pdf" label="${tool.name} on ${on_string}"/>
+        <data format="pdf" name="plots" from_work_dir="heatmaps.pdf" label="${tool.name} on ${on_string}: results"/>
         <data format="svg" name="svg_output" from_work_dir="svg_pixel_output.svg" label="${tool.name} on ${on_string}: image.svg">
             <filter>svg_pixelimage</filter>
         </data>
@@ -174,7 +214,7 @@
             <output name="svg_output" file="analyze75.svg" ftype="svg" compare="sim_size"/>
         </test>
         <test>
-            <param name="infile" value="preprocessed.rdata" ftype="rdata"/>
+            <param name="infile" value="preprocessed.RData" ftype="rdata"/>
             <param name="calibrant_file" value="inputpeptides.tabular" ftype="tabular"/>
             <param name="mz_column" value="1"/>
             <param name="name_column" value="2"/>