comparison mz_images.xml @ 7:5e6f8fb2df07 draft

"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/cardinal commit f986c51abe33c7f622d429a3c4a79ee24b33c1f3"
author galaxyp
date Thu, 23 Apr 2020 08:08:28 -0400
parents 773a24b240e1
children 08ebd8da780c
comparison
equal deleted inserted replaced
6:25b83cbd596a 7:5e6f8fb2df07
1 <tool id="cardinal_mz_images" name="MSI mz images" version="@VERSION@.2"> 1 <tool id="cardinal_mz_images" name="MSI mz images" version="@VERSION@.0">
2 <description> 2 <description>
3 mass spectrometry imaging m/z heatmaps 3 mass spectrometry imaging m/z heatmaps
4 </description> 4 </description>
5 <macros> 5 <macros>
6 <import>macros.xml</import> 6 <import>macros.xml</import>
7 </macros> 7 </macros>
8 <expand macro="requirements"> 8 <expand macro="requirements">
9 <requirement type="package" version="2.3">r-gridextra</requirement> 9 <requirement type="package" version="2.3">r-gridextra</requirement>
10 <requirement type="package" version="0.20_35">r-lattice</requirement>
11 </expand> 10 </expand>
12 <command detect_errors="aggressive"> 11 <command detect_errors="aggressive">
13 <![CDATA[ 12 <![CDATA[
14 @INPUT_LINKING@ 13 @INPUT_LINKING@
15 cat '${MSI_heatmaps}' && 14 cat '${MSI_heatmaps}' &&
21 20
22 ################################# load libraries and read file ################# 21 ################################# load libraries and read file #################
23 22
24 library(Cardinal) 23 library(Cardinal)
25 library(gridExtra) 24 library(gridExtra)
26 library(lattice) 25 ##library(lattice)
27 26
28 @READING_MSIDATA@ 27 @READING_MSIDATA_FULLY_COMPATIBLE@
29 28
30 @DATA_PROPERTIES@ 29 @DATA_PROPERTIES@
31 30
32 ##################################### read and filter input m/z ############## 31 ##################################### read and filter input m/z ##############
33 32
57 grid.table(property_df, rows= NULL) 56 grid.table(property_df, rows= NULL)
58 57
59 ############################# II) images #################################### 58 ############################# II) images ####################################
60 59
61 ### only plot images when file has features and pixels: 60 ### only plot images when file has features and pixels:
62 61 par(mar=c(0,0,0,0), oma=c(0,0,0,1))## margin for image legend
63 if (ncol(msidata)>0 & nrow(msidata) >0){ 62 if (ncol(msidata)>0 & nrow(msidata) >0){
64 if (length(inputmz) != 0){ 63 if (length(inputmz) != 0){
65 for (mass in 1:length(inputmz)){ 64 for (mass in 1:length(inputmz)){
66 65
67 ###standard image 66 print(image(msidata, mz=inputmz[mass],plusminus = $plusminus_dalton, normalize.image="$normalize_image", contrast.enhance = "$image_contrast",
68 67 smooth.image = "$image_smoothing", strip=$strip, colorkey=$colorkey, colorscale=$colorscale, ylim= c(maximumy,minimumy)))}
69 #if str($image_type) == "standard_image": 68
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.2*maximumy,minimumy-1),
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.2*maximumy,minimumy-1),
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 69
100 ## optional svg output with original coordinates 70 ## optional svg output with original coordinates
101 #if $svg_pixelimage: 71 #if $svg_pixelimage:
102 print("svg pixel image") 72 print("svg pixel image")
103 ## reverse y axis for svg output = correct order and nice svg image 73 ## reverse y axis for svg output = correct order and nice svg image
104 coord(msidata)\$y <- max(coord(msidata)\$y) - coord(msidata)\$y + 1 74 coord(msidata)\$y <- max(coord(msidata)\$y) - coord(msidata)\$y + 1
75 ## works only with MSImageSet as expected
76 msidata = as(msidata, "MSImageSet")
77
105 svg(file="svg_pixel_output.svg", width=maximumx, height=maximumy) 78 svg(file="svg_pixel_output.svg", width=maximumx, height=maximumy)
106 par(mar=c(0,0,0,0)) 79 par(mar=c(0,0,0,0), oma=c(0,0,0,0))## no margin for svg
107 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") 80 print(image(msidata, mz = inputmz[1],strip=FALSE, plusminus = $plusminus_dalton, colorscale=$colorscale, colorkey = FALSE,axes=FALSE, xlab=NA, ylab=NA,contrast.enhance = "$image_contrast", smooth.image = "$image_smoothing", normalize.image="$normalize_image"))
108 dev.off() 81 dev.off()
109 #end if 82 #end if
110 83
111 ## optional overlay all input m/z in one image 84 ## optional overlay all input m/z in one image
112 #if str($overlay_cond.overlay_selection) == "yes_overlay": 85 #if str($overlay_cond.overlay_selection) == "yes_overlay":
113 86
114 #set $color_string = ','.join(['"%s"' % $color.feature_color for $color in $overlay_cond.colours]) 87 #set $color_string = ','.join(['"%s"' % $color.feature_color for $color in $overlay_cond.colours])
115 colourvector = c($color_string) 88 colourvector = c($color_string)
116 89 par(mar=c(0,0,0,0), oma=c(0,0,0,1))## margin for image legend
117 image(msidata, mz=inputmz, 90 print(image(msidata, mz=inputmz,
118 plusminus = $plusminus_dalton, 91 plusminus = $plusminus_dalton,
119 col=colourvector, 92 col=colourvector,
120 contrast.enhance = "$image_contrast", 93 contrast.enhance = "$image_contrast",
121 normalize.image="linear", 94 normalize.image="$normalize_image",
122 smooth.image = "$image_smoothing", 95 smooth.image = "$image_smoothing",
123 superpose=TRUE, main="overlay of all m/z", 96 superpose=TRUE, main="overlay of all m/z",
124 ylim= c(maximumy+0.2*maximumy,minimumy-1)) 97 key=FALSE,
125 98 ylim= c(maximumy,minimumy)))
126 legend("topright", 99
100 legend("$overlay_cond.legend_position",
127 fill=colourvector, 101 fill=colourvector,
128 legend=as.numeric(sort(as.character(inputmz)))) 102 legend=as.numeric(sort(as.character(inputmz))))
129 #end if 103 #end if
130 104
131 } else {print("The input m/z were invalid")} 105 } else {print("The input m/z were invalid")}
132 dev.off() 106 dev.off()
133 }else{ 107 }else{
141 <inputs> 115 <inputs>
142 <expand macro="reading_msidata"/> 116 <expand macro="reading_msidata"/>
143 <expand macro="pdf_filename"/> 117 <expand macro="pdf_filename"/>
144 <expand macro="reading_2_column_mz_tabular"/> 118 <expand macro="reading_2_column_mz_tabular"/>
145 119
146 120 <param name="plusminus_dalton" value="0.25" type="float" label="m/z range" help="average of the m/z window will be computed"/>
147 <param name="image_contrast" type="select" label="Contrast enhancement" help="The 'histogram' equalization method flatterns the distribution of intensities. The hotspot 'suppression' method uses thresholding to reduce the intensities of hotspots"> 121 <param name="image_contrast" type="select" label="Contrast enhancement" help="The 'histogram' equalization method flatterns the distribution of intensities. The hotspot 'suppression' method uses thresholding to reduce the intensities of hotspots">
148 <option value="none" selected="True">none</option> 122 <option value="none" selected="True">none</option>
149 <option value="suppression">suppression</option> 123 <option value="suppression">suppression</option>
150 <option value="histogram">histogram</option> 124 <option value="histogram">histogram</option>
151 </param> 125 </param>
152 <param name="image_smoothing" type="select" label="Image smoothing" help="The 'gaussian' smoothing method smooths images with a simple gaussian kernel. The 'adaptive' method uses bilateral filtering to preserve edges"> 126 <param name="image_smoothing" type="select" label="Image smoothing" help="The 'gaussian' smoothing method smooths images with a simple gaussian kernel. The 'adaptive' method uses bilateral filtering to preserve edges">
153 <option value="none" selected="True">none</option> 127 <option value="none" selected="True">none</option>
154 <option value="gaussian">gaussian</option> 128 <option value="gaussian">gaussian</option>
155 <option value="adaptive">adaptive</option> 129 <option value="adaptive">adaptive</option>
156 </param> 130 </param>
157 <param name="plusminus_dalton" value="0.25" type="float" label="M/z range" help="plusminus m/z window"/> 131 <param name="colorscale" type="select" display="radio" label="Colorscale">
132 <option value="viridis" selected="True">viridis</option>
133 <option value="magma">magma</option>
134 <option value="plasma">plasma</option>
135 <option value="inferno">inferno</option>
136 </param>
158 <param name="strip" type="boolean" checked="True" truevalue="TRUE" falsevalue="FALSE" label="Display m/z value in plot"/> 137 <param name="strip" type="boolean" checked="True" truevalue="TRUE" falsevalue="FALSE" label="Display m/z value in plot"/>
159 <param name="colorkey" type="boolean" checked="True" truevalue="TRUE" falsevalue="FALSE" label="Display colorkey in plot"/> 138 <param name="colorkey" type="boolean" checked="True" truevalue="TRUE" falsevalue="FALSE" label="Display colorkey in plot"/>
160 <param name="image_type" type="boolean" checked="True" truevalue="standard_image" falsevalue="lattice_image" 139 <param name="normalize_image" type="boolean" truevalue="linear" falsevalue="none" label="Linear normalization of image"/>
161 label="Standard image" help="No: lattice function is used to display image"/>
162 <param name="svg_pixelimage" type="boolean" label="Export first valid m/z from tabular file as SVG"/> 140 <param name="svg_pixelimage" type="boolean" label="Export first valid m/z from tabular file as SVG"/>
163 <conditional name="overlay_cond"> 141 <conditional name="overlay_cond">
164 <param name="overlay_selection" type="select" label="Overlay image"> 142 <param name="overlay_selection" type="select" label="Overlay image">
165 <option value="no_overlay" selected="True">no</option> 143 <option value="no_overlay" selected="True">no</option>
166 <option value="yes_overlay">yes</option> 144 <option value="yes_overlay">yes</option>
174 <add value="#" /> 152 <add value="#" />
175 </valid> 153 </valid>
176 </sanitizer> 154 </sanitizer>
177 </param> 155 </param>
178 </repeat> 156 </repeat>
157 <param name="legend_position" type="select" display="radio" label="Position of legend">
158 <option value="topright" selected="True">topright</option>
159 <option value="top">top</option>
160 <option value="topleft">topleft</option>
161 <option value="left">left</option>
162 <option value="bottomleft">bottomleft</option>
163 <option value="bottom">bottom</option>
164 <option value="bottomright">bottomright</option>
165 <option value="right">right</option>
166 </param>
179 </when> 167 </when>
180 </conditional> 168 </conditional>
181 </inputs> 169 </inputs>
182 <outputs> 170 <outputs>
183 <data format="pdf" name="plots" from_work_dir="heatmaps.pdf" label="${tool.name} on ${on_string}: results"/> 171 <data format="pdf" name="plots" from_work_dir="heatmaps.pdf" label="${tool.name} on ${on_string}: results"/>
194 <param name="plusminus_dalton" value="0.25"/> 182 <param name="plusminus_dalton" value="0.25"/>
195 <param name="filename" value="Testfile_imzml"/> 183 <param name="filename" value="Testfile_imzml"/>
196 <param name="image_contrast" value="histogram"/> 184 <param name="image_contrast" value="histogram"/>
197 <param name="strip" value="True"/> 185 <param name="strip" value="True"/>
198 <param name="colorkey" value="True"/> 186 <param name="colorkey" value="True"/>
199 <param name="image_type" value="lattice_image"/>
200 <output name="plots" file="Heatmaps_imzml.pdf" ftype="pdf" compare="sim_size"/> 187 <output name="plots" file="Heatmaps_imzml.pdf" ftype="pdf" compare="sim_size"/>
201 </test> 188 </test>
202 <test> 189 <test>
203 <expand macro="infile_analyze75"/> 190 <expand macro="infile_analyze75"/>
204 <param name="calibrant_file" value="inputpeptides2.tabular" ftype="tabular"/> 191 <param name="calibrant_file" value="inputpeptides2.tabular" ftype="tabular"/>
205 <param name="mz_column" value="1"/> 192 <param name="mz_column" value="1"/>
206 <param name="name_column" value="1"/> 193 <param name="name_column" value="1"/>
207 <param name="plusminus_dalton" value="0.5"/> 194 <param name="plusminus_dalton" value="0.5"/>
208 <param name="filename" value="Testfile_analyze75"/> 195 <param name="filename" value="Testfile_analyze75"/>
196 <param name="colorscale" value="magma"/>
209 <param name="image_smoothing" value="gaussian"/> 197 <param name="image_smoothing" value="gaussian"/>
210 <param name="strip" value="False"/> 198 <param name="strip" value="False"/>
211 <param name="colorkey" value="True"/> 199 <param name="colorkey" value="True"/>
212 <param name="svg_pixelimage" value="True"/> 200 <param name="svg_pixelimage" value="True"/>
213 <output name="plots" file="Heatmaps_analyze75.pdf" ftype="pdf" compare="sim_size"/> 201 <output name="plots" file="Heatmaps_analyze75.pdf" ftype="pdf" compare="sim_size"/>
219 <param name="mz_column" value="1"/> 207 <param name="mz_column" value="1"/>
220 <param name="name_column" value="2"/> 208 <param name="name_column" value="2"/>
221 <param name="plusminus_dalton" value="0.5"/> 209 <param name="plusminus_dalton" value="0.5"/>
222 <param name="strip" value="True"/> 210 <param name="strip" value="True"/>
223 <param name="colorkey" value="True"/> 211 <param name="colorkey" value="True"/>
224 <param name="image_type" value="lattice_image"/>
225 <param name="filename" value="Testfile_rdata"/> 212 <param name="filename" value="Testfile_rdata"/>
226 <output name="plots" file="Heatmaps_rdata.pdf" ftype="pdf" compare="sim_size"/> 213 <output name="plots" file="Heatmaps_rdata.pdf" ftype="pdf" compare="sim_size"/>
227 </test> 214 </test>
228 <test> 215 <test>
229 <param name="infile" value="empty_spectra.rdata" ftype="rdata"/> 216 <param name="infile" value="empty_spectra.rdata" ftype="rdata"/>
230 <param name="calibrant_file" value="inputpeptides2.tabular" ftype="tabular"/> 217 <param name="calibrant_file" value="inputpeptides2.tabular" ftype="tabular"/>
231 <param name="mz_column" value="1"/> 218 <param name="mz_column" value="1"/>
232 <param name="name_column" value="1"/> 219 <param name="name_column" value="1"/>
233 <param name="plusminus_dalton" value="0.5"/> 220 <param name="plusminus_dalton" value="0.5"/>
221 <param name="colorscale" value="plasma"/>
234 <param name="strip" value="True"/> 222 <param name="strip" value="True"/>
235 <param name="colorkey" value="False"/> 223 <param name="colorkey" value="False"/>
236 <param name="filename" value="Testfile_rdata"/> 224 <param name="filename" value="Testfile_rdata"/>
237 <output name="plots" file="Heatmaps_LM8_file16.pdf" ftype="pdf" compare="sim_size"/> 225 <output name="plots" file="Heatmaps_LM8_file16.pdf" ftype="pdf" compare="sim_size"/>
238 </test> 226 </test>
227 <test>
228 <expand macro="processed_infile_imzml"/>
229 <conditional name="processed_cond">
230 <param name="processed_file" value="processed"/>
231 <param name="accuracy" value="100"/>
232 <param name="units" value="ppm"/>
233 </conditional>
234 <param name="calibrant_file" value="inputpeptides.tabular" ftype="tabular"/>
235 <param name="mz_column" value="1"/>
236 <param name="name_column" value="2"/>
237 <conditional name="overlay_cond">
238 <param name="overlay_selection" value="yes_overlay"/>
239 <repeat name="colours">
240 <param name="feature_color" value="#ff00ff"/>
241 </repeat>
242 <repeat name="colours">
243 <param name="feature_color" value="#1f497d"/>
244 </repeat>
245 <repeat name="colours">
246 <param name="feature_color" value="#00b050"/>
247 </repeat>
248 <param name="legend_position" value="topleft"/>
249 </conditional>
250 <output name="plots" file="Heatmaps_processed.pdf" ftype="pdf" compare="sim_size"/>
251 </test>
239 </tests> 252 </tests>
240 <help><![CDATA[ 253 <help><![CDATA[
241 254
242
243 @CARDINAL_DESCRIPTION@ 255 @CARDINAL_DESCRIPTION@
244 256
245 ----- 257 -----
246 258
247 This tool uses the Cardinal image function to plot the intensity distribution of m/z feature of mass spectrometry imaging data. 259 This tool uses the Cardinal image function to plot the intensity distribution of m/z features of mass spectrometry imaging data.
248 260
249 @MSIDATA_INPUT_DESCRIPTION@ 261 @MSIDATA_INPUT_DESCRIPTION@
250 262
251 @MZ_2COLS_TABULAR_INPUT_DESCRIPTION@ 263 @MZ_2COLS_TABULAR_INPUT_DESCRIPTION@
252 264
265
253 **Tips** 266 **Tips**
254 267
255 - 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)) 268 - 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))
256 - 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
257 - The contrast enhance and image smoothing functions require a certain number (about 2%) of m/z features with intensities > 0 across all spectra 269 - The contrast enhance and image smoothing functions require a certain number (about 2%) of m/z features with intensities > 0 across all spectra
258 - The standard image function should work for all files while the lattice function works not perfectly on every file
259 270
260 **Output** 271 **Output**
261 272
262 - Pdf with the heatmap images 273 - Single Pdf with the heatmap images
263 - optional: svg file with the heatmap of the first valid m/z in the tabular file 274 - optional: svg file with the heatmap of the first valid m/z in the tabular file
264 275
265 276
266 ]]> 277 ]]>
267 </help> 278 </help>