diff msi_spectra_plots.xml @ 3:fe28ca73548a draft

planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msi_spectra_plots commit a7be47698f53eb4f00961192327d93e8989276a7
author galaxyp
date Mon, 11 Jun 2018 17:34:44 -0400
parents ea4f1c516368
children 9eef2792afa4
line wrap: on
line diff
--- a/msi_spectra_plots.xml	Mon May 28 12:39:59 2018 -0400
+++ b/msi_spectra_plots.xml	Mon Jun 11 17:34:44 2018 -0400
@@ -1,4 +1,4 @@
-<tool id="mass_spectrometry_imaging_mzplots" name="MSI plot spectra" version="1.10.0.0">
+<tool id="mass_spectrometry_imaging_mzplots" name="MSI plot spectra" version="1.10.0.1">
     <description>
         mass spectrometry imaging mass spectra plots
     </description>
@@ -24,6 +24,7 @@
     </command>
     <configfiles>
         <configfile name="MSI_mzplots"><![CDATA[
+
 ################################# load libraries and read file #################
 
 library(Cardinal)
@@ -41,9 +42,9 @@
 
 ###################################### file properties in numbers ##############
 
-## Number of features (mz)
+## Number of features (m/z)
 maxfeatures = length(features(msidata))
-## Range mz
+## Range m/z
 minmz = round(min(mz(msidata)), digits=2)
 maxmz = round(max(mz(msidata)), digits=2)
 ## Number of spectra (pixels)
@@ -60,7 +61,7 @@
 medint = round(median(spectra(msidata)[]), digits=2)
 ## Number of intensities > 0
 npeaks= sum(spectra(msidata)[]>0)
-## Spectra multiplied with mz (potential number of peaks)
+## Spectra multiplied with m/z (potential number of peaks)
 numpeaks = ncol(spectra(msidata)[])*nrow(spectra(msidata)[])
 ## Percentage of intensities > 0
 percpeaks = round(npeaks/numpeaks*100, digits=2)
@@ -99,8 +100,8 @@
   peakpickinginfo=processinginfo@peakPicking
 }
 
-properties = c("Number of mz features",
-               "Range of mz values [Da]",
+properties = c("Number of m/z features",
+               "Range of m/z values [Da]",
                "Number of pixels", 
                "Range of x coordinates", 
                "Range of y coordinates",
@@ -133,8 +134,6 @@
 
 property_df = data.frame(properties, values)
 
-print("before pdf")
-
 ######################################## PDF ###################################
 ################################################################################
 ################################################################################
@@ -142,62 +141,50 @@
 
 pdf("mzplots.pdf", fonts = "Times", pointsize = 12)
 plot(0,type='n',axes=FALSE,ann=FALSE)
-
-title(main=paste0("Plotted mass spectra for file: \n\n", "$infile.display_name"))
+#if not $filename:
+    #set $filename = $infile.display_name
+#end if
+title(main=paste0("Plotted mass spectra for file: \n\n","$filename"))
 
 
 ############################# I) numbers ######################################
 ###############################################################################
 
-print("in pdf")
 grid.table(property_df, rows= NULL)
 
-
+if (npeaks > 0){
 
-if (npeaks > 0)
-{
     pixeldf = data.frame(matrix(ncol = 2, nrow=0))
 
+    ############################# single pixel ################################
+    ###########################################################################
 
     #if str( $pixel_conditional.pixel_type) == 'single_pixel':
-    print("single_pixel")
+        print("single_pixel")
 
         #for $chosenpixel in $pixel_conditional.repeatpixel: 
 
-
             pixelisvalid = as.character($chosenpixel.inputx %in% coord(msidata)\$x & $chosenpixel.inputy %in% coord(msidata)\$y)
             pixelname = paste0("x=", $chosenpixel.inputx,", ", "y=", $chosenpixel.inputy)
-            print(pixelname)
-            print(colnames(pixeldf))
-            print(colnames(cbind(pixelname, pixelisvalid)))
             pixeldf = rbind(pixeldf, cbind(pixelname, pixelisvalid))
-            print(colnames(pixeldf))
 
             ############################# II) control image ####################
-            ####################################################################
 
-
-                if (pixelisvalid == "TRUE")
-                {
+                if (pixelisvalid == "TRUE"){
+                    print(pixelisvalid)
 
-                print(pixelisvalid)
-
-
-                    image(msidata, mz=$chosenpixel.inputmz, 
-                          ylim = c(maximumy+(0.2*maximumy),minimumy-1),colorkey=FALSE, plusminus = $chosenpixel.plusminusinDalton, contrast.enhance = "histogram", 
-                          main= paste0("x= ",$chosenpixel.inputx, ", y= ", $chosenpixel.inputy))
+                    image(msidata, mz=$chosenpixel.inputmz, ylim = c(maximumy+(0.2*maximumy),minimumy-1),
+                    colorkey=FALSE, plusminus = $chosenpixel.plusminusinDalton, contrast.enhance = "histogram", 
+                    main= paste0("x= ",$chosenpixel.inputx, ", y= ", $chosenpixel.inputy))
 
                     abline(v=$chosenpixel.inputx, col ="$chosenpixel.inputcolour", lty="$chosenpixel.inputtype", lwd=$chosenpixel.inputwidth)
                     abline(h=$chosenpixel.inputy, col ="$chosenpixel.inputcolour", lty="$chosenpixel.inputtype", lwd=$chosenpixel.inputwidth)
 
-
             ##################### III) plot full mass spectrum #################
-            ####################################################################
 
                     plot(msidata, coord=list(x=$chosenpixel.inputx, y=$chosenpixel.inputy))
 
             ##################### IV) plot zoom-in mass spectrum ###############
-            ####################################################################
 
                     #if $chosenpixel.zoomedplot:
                         #for $token in $chosenpixel.zoomedplot:
@@ -210,33 +197,39 @@
 
                         #end for
                     #end if
-
                 }else{
                     print("The pixel coordinates did not correspond to a real pixel")}
-
         #end for
 
     colnames(pixeldf) = c("pixel coordinates", "coordinates were found in this file")
 
-    #elif str( $pixel_conditional.pixel_type) == 'sample_pixel':
-    print("sample_pixel")
+
+    ############################# sample pixel ################################
+    ###########################################################################
 
-            ##################### I) Sample: plot full mass spectrum ###########
-        plot(msidata, pixel=1:ncol(msidata), pixel.groups=pData(msidata)\$sample, key=TRUE, col=c("blue", "orange", "green", "red", "yellow", "grey"), superpose=TRUE)
+    #elif str( $pixel_conditional.pixel_type) == 'sample_pixel':
+        print("sample_pixel")
 
-            ##################### II) Sample: plot zoom-in mass spectrum #######
+        ##################### I) Sample: plot full mass spectrum ##############
+
+        plot(msidata, pixel=1:ncol(msidata), pixel.groups=msidata\$combined_sample, key=TRUE, col=c("blue", "orange", "green", "red", "yellow", "grey"), superpose=TRUE)
+
+        ##################### II) Sample: plot zoom-in mass spectrum ##########
 
         #if $pixel_conditional.zoomed_sample:
             #for $token in $pixel_conditional.zoomed_sample:
 
                 minmasspixel = features(msidata, mz=$token.xlimmin)
                 maxmasspixel = features(msidata, mz=$token.xlimmax)
-                plot(msidata[minmasspixel:maxmasspixel,], pixel=1:ncol(msidata),  xlim= c($token.xlimmin,$token.xlimmax),pixel.groups=pData(msidata)\$sample, key=TRUE,col=c("blue", "orange", "green", "red", "yellow", "grey"), superpose=TRUE)
+
+                plot(msidata[minmasspixel:maxmasspixel,], pixel=1:ncol(msidata),
+                xlim= c($token.xlimmin,$token.xlimmax),pixel.groups=msidata\$combined_sample,
+                key=TRUE,col=c("blue", "orange", "green", "red", "yellow", "grey"), superpose=TRUE)
 
             #end for
         #end if
 
-        pixeldf = data.frame(table(pData(msidata)\$sample))
+        pixeldf = data.frame(table(msidata\$combined_sample))
         colnames(pixeldf) = c("sample name", "number of pixels")
 
     #end if
@@ -247,7 +240,6 @@
 
     dev.off()
 
-
 }else{
     print("Inputfile has no intensities > 0")
     dev.off()
@@ -257,6 +249,7 @@
     <inputs>
         <param name="infile" type="data" format="imzml,rdata,analyze75" label="Inputfile as imzML, Analyze7.5 or Cardinal MSImageSet saved as RData"
             help="Upload composite datatype imzml (ibd+imzML) or analyze75 (hdr+img+t2m) or regular upload .RData (Cardinal MSImageSet)"/>
+        <param name="filename" type="text" value="" label="Title" help="will appear in the pdf output. If nothing given it will take the dataset name"/>
         <conditional name="pixel_conditional">
             <param name="pixel_type" type="select" label="Select if you want to plot the mass spectrum of a single pixel or of all pixels of a sample">
                 <option value="single_pixel" selected="True">Single pixel</option>
@@ -266,8 +259,8 @@
                 <repeat name="repeatpixel" title="Plot mass spectra for pixel of interest" min="1" max="20">
                     <param name="inputx" type="integer" value="" label="x-coordinate of pixel of interest" help="x-value of the pixel of interest"/>
                     <param name="inputy" type="integer" value="" label="y-coordinate of pixel of interest" help="y-value of the pixel of interest"/>
-                    <param name="inputmz" type="float" value="1296.7" label="Next parameters are to control heatmap image which will be plotted, here mz in Dalton" help="mz will be displayed as heatmap and the pixel of interest will be visualized by the intersection of two lines"/>
-                    <param name="plusminusinDalton" value="0.25" type="float" label="mass range for this mz value" help="plusminus mass window in Dalton"/>
+                    <param name="inputmz" type="float" value="1296.7" label="Next parameters are to control heatmap image which will be plotted, here m/z in Dalton" help="m/z will be displayed as heatmap and the pixel of interest will be visualized by the intersection of two lines"/>
+                    <param name="plusminusinDalton" value="0.25" type="float" label="m/z range for this m/z value" help="plusminus m/z window in Dalton"/>
                     <param name="inputcolour" type="select" label="select the colour for the lines at x and y position">
                         <option value="white" selected="True">white</option>
                         <option value="black">black</option>
@@ -283,22 +276,22 @@
                         <option value="longdash">longdash</option>
                     </param>
                     <param name="inputwidth" type="integer" value="2" label="select the width of the lines at x and y position"/>
-                    <repeat name="zoomedplot" title="Zoomed in plots with mz min and mz max to define the plot window" min="0" max="50">
-                        <param name="xlimmin" type="integer" value="" label="lower boundary in Dalton for plotting window" help="minimum mz for zoomed in window"/>
-                        <param name="xlimmax" type="integer" value="" label="upper boundary in Dalton for plotting window" help="maximum mz for zoomed in window"/>
+                    <repeat name="zoomedplot" title="Zoomed in plots with m/z min and m/z max to define the plot window" min="0" max="50">
+                        <param name="xlimmin" type="integer" value="" label="lower boundary in Dalton for plotting window" help="minimum m/z for zoomed in window"/>
+                        <param name="xlimmax" type="integer" value="" label="upper boundary in Dalton for plotting window" help="maximum m/z for zoomed in window"/>
                     </repeat>
                 </repeat>
             </when>
             <when value="sample_pixel">
-                <repeat name="zoomed_sample" title="Zoomed in plots with mz min and mz max to define the plot window" min="0" max="50">
-                    <param name="xlimmin" type="integer" value="" label="lower boundary in Dalton for plotting window" help="minimum mz for zoomed in window"/>
-                    <param name="xlimmax" type="integer" value="" label="upper boundary in Dalton for plotting window" help="maximum mz for zoomed in window"/>
+                <repeat name="zoomed_sample" title="Zoomed in plots with m/z min and m/z max to define the plot window" min="0" max="50">
+                    <param name="xlimmin" type="integer" value="" label="lower boundary in Dalton for plotting window" help="minimum m/z for zoomed in window"/>
+                    <param name="xlimmax" type="integer" value="" label="upper boundary in Dalton for plotting window" help="maximum m/z for zoomed in window"/>
                 </repeat>
             </when>
         </conditional>
     </inputs>
     <outputs>
-        <data format="pdf" name="plots" from_work_dir="mzplots.pdf" label = "${tool.name} ${on_string}"/>
+        <data format="pdf" name="plots" from_work_dir="mzplots.pdf" label = "$infile.display_name mass_spectra"/>
     </outputs>
     <tests>
         <test>
@@ -313,12 +306,12 @@
                         <param name="inputx" value="3"/>
                         <param name="inputy" value="3"/>
                         <repeat name="zoomedplot">
-                            <param name="xlimmin" value="550"/>
-                            <param name="xlimmax" value="555"/>
+                            <param name="xlimmin" value="310"/>
+                            <param name="xlimmax" value="320"/>
                         </repeat>
                         <repeat name="zoomedplot">
-                            <param name="xlimmin" value="750"/>
-                            <param name="xlimmax" value="800"/>
+                            <param name="xlimmin" value="350"/>
+                            <param name="xlimmax" value="400"/>
                         </repeat>
                         <repeat name="zoomedplot">
                             <param name="xlimmin" value="400"/>
@@ -364,7 +357,7 @@
             <output name="plots" file="Plot_analyze75.pdf" compare="sim_size" delta="20000"/>
         </test>
         <test>
-            <param name="infile" value="123_combined.rdata" ftype="rdata"/>
+            <param name="infile" value="123_combined.RData" ftype="rdata"/>
             <conditional name="pixel_conditional">
                 <param name="pixel_type" value="sample_pixel"/>
                     <repeat name="zoomed_sample">
@@ -395,7 +388,7 @@
 
 Cardinal is an R package that implements statistical & computational tools for analyzing mass spectrometry imaging datasets. `More information on Cardinal <http://cardinalmsi.org//>`_
 
-This tool uses the Cardinal plot function to generate (zoomed in) mass spectra plots of mass-spectrometry imaging data.
+This tool uses the Cardinal plot function to generate (zoomed in) mass spectra plots of mass spectrometry imaging data.
 
 Input data: 3 types of input data can be used:
 
@@ -405,23 +398,23 @@
 
 Options:
 
-- "single pixel": Returns a full mass-spectrum plot for one pixel, which is defined by its x- and y-coordinates
+- "single pixel": Returns a full mass spectrum plot for one pixel, which is defined by its x- and y-coordinates
 
     - Enter the x and y coordinates of your pixel of interest
-    - To have a visual control for the selected pixel, a heatmap of a mass of interest will be drawn. Two intersecting lines will show the pixel location. This procedure requires an mass of interest together with a mass range and for the lines the colour and type.
-    - Additionally zoom into mass-spectra plots is possible by providing the minimum and maximum mass value to define the limits of the plot
-- "All pixels of a sample": Returns a full average mass-spectrum plot with different colours for each subfile
+    - To have a visual control for the selected pixel, a heatmap of a m/z of interest will be drawn. Two intersecting lines will show the pixel location. This procedure requires an m/z of interest together with a m/z range and for the lines the colour and type.
+    - Additionally zoom into mass spectra plots is possible by providing the minimum and maximum m/z value to define the limits of the plot
+- "All pixels of a sample": Returns a full average mass spectrum plot with different colours for each subfile
 
     - This option only works on files that have previosly been combined in the combine tool
-    - Additionally zoom into mass-spectra plots is possible by providing the minimum and maximum mass value to define the limits of the plot
+    - Additionally zoom into mass spectra plots is possible by providing the minimum and maximum m/z value to define the limits of the plot
 
 Output:
 
-- Pdf with the selected mass-spectra plots and additional control plots
+- Pdf with the selected mass spectra plots and additional control plots
 
 Tip: 
 
-- Corresponding peaklists with masses and their intensities can be obtained with the filtering tool option "ranges for x and y"
+- Corresponding mass spectra with m/z intensity pairs as tabular output can be obtained with the filtering tool option "ranges for x and y"
 
 
 ]]>