comparison mz_images.xml @ 0:2ba12c97f7cc draft

planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/cardinal commit 0825a4ccd3ebf4ca8a298326d14f3e7b25ae8415
author galaxyp
date Mon, 01 Oct 2018 01:06:41 -0400
parents
children 4d5f798a7a18
comparison
equal deleted inserted replaced
-1:000000000000 0:2ba12c97f7cc
1 <tool id="cardinal_mz_images" name="MSI mz images" version="@VERSION@.0">
2 <description>
3 mass spectrometry imaging m/z heatmaps
4 </description>
5 <macros>
6 <import>macros.xml</import>
7 </macros>
8 <expand macro="requirements">
9 <requirement type="package" version="2.2.1">r-gridextra</requirement>
10 <requirement type="package" version="0.20-35">r-lattice</requirement>
11 </expand>
12 <command detect_errors="aggressive">
13 <![CDATA[
14 @INPUT_LINKING@
15 cat '${MSI_heatmaps}' &&
16 Rscript '${MSI_heatmaps}'
17 ]]>
18 </command>
19 <configfiles>
20 <configfile name="MSI_heatmaps"><![CDATA[
21
22 ################################# load libraries and read file #################
23
24 library(Cardinal)
25 library(gridExtra)
26 library(lattice)
27
28 @READING_MSIDATA@
29
30 @DATA_PROPERTIES@
31
32 ##################################### read and filter input m/z ##############
33
34 input_list = read.delim("$calibrant_file", header = $calibrant_header, stringsAsFactors = FALSE)
35 input_list = input_list[,c($mz_column, $name_column)]
36
37 ### calculate how many input m/z are valid:
38 inputmasses = input_list[input_list[,1]>minmz & input_list[,1]<maxmz,]
39 inputmz = as.numeric(inputmasses[,1])
40 inputnames = as.character(inputmasses[,2])
41
42
43 ############################## PDF #############################################
44 ################################################################################
45
46 pdf("heatmaps.pdf", fonts = "Times", pointsize = 12)
47 plot(0,type='n',axes=FALSE,ann=FALSE)
48 #if not $filename:
49 #set $filename = $infile.display_name
50 #end if
51 title(main=paste("\nHeatmap images\n\n", "Filename:\n", "$filename"))
52
53 new_row = data.frame(paste0(length(inputmz), "/", length(input_list[,1])), paste0("# valid m/z in \n", "$calibrant_file.display_name"))
54 colnames(new_row) = c("properties", "values")
55 property_df = rbind(property_df, new_row)
56
57 grid.table(property_df, rows= NULL)
58
59 ############################# II) images ####################################
60
61 ### only plot images when file has peaks and valid input m/z:
62
63 if (npeaks > 0){
64 if (length(inputmz) != 0){
65 for (mass in 1:length(inputmz)){
66
67 ###standard image
68
69 #if str($image_type) == "standard_image":
70 print("standard image")
71
72 print(image(msidata, mz=inputmz[mass],plusminus = $plusminus_dalton, contrast.enhance = "$image_contrast",
73 smooth.image = "$image_smoothing", strip=$strip, colorkey=$colorkey,ylim= c(maximumy+0.1*maximumy,minimumy-0.1*minimumy),
74 main= paste0(inputnames[mass], " (", round(inputmz[mass], digits = 2)," ± ", $plusminus_dalton, " Da)")))}
75
76
77 ###lattice image
78
79 #elif str($image_type) == "lattice_image":
80 print("lattice image")
81
82 #if str($strip) =="TRUE":
83
84 print(image(msidata, mz=inputmz[mass], strip = strip.custom(bg="lightgrey", par.strip.text=list(col="black", cex=.9)),
85 lattice=TRUE, plusminus = $plusminus_dalton, contrast.enhance = "$image_contrast", smooth.image = "$image_smoothing",
86 colorkey=$colorkey,ylim= c(maximumy+0.1*maximumy,minimumy-0.1*minimumy),
87 main= paste0(inputnames[mass], " (", round(inputmz[mass], digits = 2)," ± ", $plusminus_dalton, " Da)")))}
88
89 #elif str($strip) =="FALSE":
90
91 print(image(msidata, mz=inputmz[mass], strip = $strip,
92 lattice=TRUE, plusminus = $plusminus_dalton, contrast.enhance = "$image_contrast", smooth.image = "$image_smoothing",
93 colorkey=$colorkey,
94 main= paste0(inputnames[mass], " (", round(inputmz[mass], digits = 2)," ± ", $plusminus_dalton, " Da)")))}
95
96 #end if
97
98 #end if
99
100 ## optional svg output with original coordinates
101 #if $svg_pixelimage:
102 print("svg pixel image")
103 svg(file="svg_pixel_output.svg")
104 par(mar=c(0,0,0,0))
105 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")
106 dev.off()
107 #end if
108
109 } else {print("The input m/z were invalid")}
110 dev.off()
111 }else{
112 print("inputfile has no intensities > 0")
113 dev.off()
114 }
115
116
117 ]]></configfile>
118 </configfiles>
119 <inputs>
120 <expand macro="reading_msidata"/>
121 <expand macro="pdf_filename"/>
122 <expand macro="reading_2_column_mz_tabular"/>
123
124
125 <param name="image_contrast" type="select" label="Select a contrast enhancement function for the heatmap images" help="The 'histogram' equalization method flatterns the distribution of intensities. The hotspot 'suppression' method uses thresholding to reduce the intensities of hotspots">
126 <option value="none" selected="True">none</option>
127 <option value="suppression">suppression</option>
128 <option value="histogram">histogram</option>
129 </param>
130 <param name="image_smoothing" type="select" label="Select an image smoothing function for the heatmap images" help="The 'gaussian' smoothing method smooths images with a simple gaussian kernel. The 'adaptive' method uses bilateral filtering to preserve edges">
131 <option value="none" selected="True">none</option>
132 <option value="gaussian">gaussian</option>
133 <option value="adaptive">adaptive</option>
134 </param>
135 <param name="plusminus_dalton" value="0.25" type="float" label="M/z range" help="plusminus m/z window"/>
136 <param name="strip" type="boolean" checked="True" truevalue="TRUE" falsevalue="FALSE" label="Display m/z value in plot"/>
137 <param name="colorkey" type="boolean" checked="True" truevalue="TRUE" falsevalue="FALSE" label="Display colorkey in plot"/>
138 <param name="image_type" type="boolean" checked="True" truevalue="standard_image" falsevalue="lattice_image"
139 label="Standard image" help="No: lattice function is used to display image"/>
140 <param name="svg_pixelimage" type="boolean" label="Export first valid m/z from tabular file as SVG"/>
141 </inputs>
142 <outputs>
143 <data format="pdf" name="plots" from_work_dir="heatmaps.pdf" label="${tool.name} on ${on_string}"/>
144 <data format="svg" name="svg_output" from_work_dir="svg_pixel_output.svg" label="${tool.name} on ${on_string}: image.svg">
145 <filter>svg_pixelimage</filter>
146 </data>
147 </outputs>
148 <tests>
149 <test>
150 <expand macro="infile_imzml"/>
151 <param name="calibrant_file" value="inputpeptides.tabular" ftype="tabular"/>
152 <param name="mz_column" value="1"/>
153 <param name="name_column" value="2"/>
154 <param name="plusminus_dalton" value="0.25"/>
155 <param name="filename" value="Testfile_imzml"/>
156 <param name="image_contrast" value="histogram"/>
157 <param name="strip" value="True"/>
158 <param name="colorkey" value="True"/>
159 <param name="image_type" value="lattice_image"/>
160 <output name="plots" file="Heatmaps_imzml.pdf" ftype="pdf" compare="sim_size"/>
161 </test>
162 <test>
163 <expand macro="infile_analyze75"/>
164 <param name="calibrant_file" value="inputpeptides2.tabular" ftype="tabular"/>
165 <param name="mz_column" value="1"/>
166 <param name="name_column" value="1"/>
167 <param name="plusminus_dalton" value="0.5"/>
168 <param name="filename" value="Testfile_analyze75"/>
169 <param name="image_smoothing" value="gaussian"/>
170 <param name="strip" value="False"/>
171 <param name="colorkey" value="True"/>
172 <param name="svg_pixelimage" value="True"/>
173 <output name="plots" file="Heatmaps_analyze75.pdf" ftype="pdf" compare="sim_size"/>
174 <output name="svg_output" file="analyze75.svg" ftype="svg" compare="sim_size"/>
175 </test>
176 <test>
177 <param name="infile" value="preprocessed.rdata" ftype="rdata"/>
178 <param name="calibrant_file" value="inputpeptides.tabular" ftype="tabular"/>
179 <param name="mz_column" value="1"/>
180 <param name="name_column" value="2"/>
181 <param name="plusminus_dalton" value="0.5"/>
182 <param name="strip" value="True"/>
183 <param name="colorkey" value="True"/>
184 <param name="image_type" value="lattice_image"/>
185 <param name="filename" value="Testfile_rdata"/>
186 <output name="plots" file="Heatmaps_rdata.pdf" ftype="pdf" compare="sim_size"/>
187 </test>
188 <test>
189 <param name="infile" value="empty_spectra.rdata" ftype="rdata"/>
190 <param name="calibrant_file" value="inputpeptides2.tabular" ftype="tabular"/>
191 <param name="mz_column" value="1"/>
192 <param name="name_column" value="1"/>
193 <param name="plusminus_dalton" value="0.5"/>
194 <param name="strip" value="True"/>
195 <param name="colorkey" value="False"/>
196 <param name="filename" value="Testfile_rdata"/>
197 <output name="plots" file="Heatmaps_LM8_file16.pdf" ftype="pdf" compare="sim_size"/>
198 </test>
199 </tests>
200 <help><![CDATA[
201
202
203 @CARDINAL_DESCRIPTION@
204
205 -----
206
207 This tool uses the Cardinal image function to plot the intensity distribution of m/z feature of mass spectrometry imaging data.
208
209 @MSIDATA_INPUT_DESCRIPTION@
210
211 @MZ_2COLS_TABULAR_INPUT_DESCRIPTION@
212
213 **Tips**
214
215 - In case tabular file cannot be selected in drop-down menu: Datatype in Galaxy must be tabular otherwise file will not appear in selection window (if Galaxy auto-detection was wrong, datatype can be changed by pressing the pen button (edit attributes))
216 - No heatmaps are plotted when the input mass spectrometry imaging file has no intensities > 0 or all chosen m/z features are not present in the MSI dataset
217 - The contrast enhance and image smoothing functions require a certain number (about 2%) of m/z features with intensities > 0 across all spectra
218 - The standard image function should work for all files while the lattice function works not perfectly on every file
219
220 **Output**
221
222 - Pdf with the heatmap images
223 - optional: svg file with the heatmap of the first valid m/z in the tabular file
224
225
226 ]]>
227 </help>
228 <expand macro="citations"/>
229 </tool>