comparison msi_ion_images.xml @ 5:2b9fa240e261 draft

planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msi_ion_images commit a7be47698f53eb4f00961192327d93e8989276a7
author galaxyp
date Mon, 11 Jun 2018 17:33:52 -0400
parents 9746576123c9
children 5a5b5a8fa8a0
comparison
equal deleted inserted replaced
4:9746576123c9 5:2b9fa240e261
1 <tool id="mass_spectrometry_imaging_ion_images" name="MSI ion images" version="1.10.0.0"> 1 <tool id="mass_spectrometry_imaging_ion_images" name="MSI ion images" version="1.10.0.1">
2 <description> 2 <description>
3 mass spectrometry imaging heatmaps 3 mass spectrometry imaging m/z heatmaps
4 </description> 4 </description>
5 <requirements> 5 <requirements>
6 <requirement type="package" version="1.10.0">bioconductor-cardinal</requirement> 6 <requirement type="package" version="1.10.0">bioconductor-cardinal</requirement>
7 <requirement type="package" version="2.2.1">r-gridextra</requirement> 7 <requirement type="package" version="2.2.1">r-gridextra</requirement>
8 <requirement type="package" version="0.20-35">r-lattice</requirement> 8 <requirement type="package" version="0.20-35">r-lattice</requirement>
43 #end if 43 #end if
44 44
45 45
46 ###################################### file properties in numbers ############## 46 ###################################### file properties in numbers ##############
47 47
48 ## Number of features (mz) 48 ## Number of features (m/z)
49 maxfeatures = length(features(msidata)) 49 maxfeatures = length(features(msidata))
50 ## Range mz 50 ## Range m/z
51 minmz = round(min(mz(msidata)), digits=2) 51 minmz = round(min(mz(msidata)), digits=2)
52 maxmz = round(max(mz(msidata)), digits=2) 52 maxmz = round(max(mz(msidata)), digits=2)
53 ## Number of spectra (pixels) 53 ## Number of spectra (pixels)
54 pixelcount = length(pixels(msidata)) 54 pixelcount = length(pixels(msidata))
55 ## Range x coordinates 55 ## Range x coordinates
62 minint = round(min(spectra(msidata)[]), digits=2) 62 minint = round(min(spectra(msidata)[]), digits=2)
63 maxint = round(max(spectra(msidata)[]), digits=2) 63 maxint = round(max(spectra(msidata)[]), digits=2)
64 medint = round(median(spectra(msidata)[]), digits=2) 64 medint = round(median(spectra(msidata)[]), digits=2)
65 ## Number of intensities > 0 65 ## Number of intensities > 0
66 npeaks= sum(spectra(msidata)[]>0) 66 npeaks= sum(spectra(msidata)[]>0)
67 ## Spectra multiplied with mz (potential number of peaks) 67 ## Spectra multiplied with m/z (potential number of peaks)
68 numpeaks = ncol(spectra(msidata)[])*nrow(spectra(msidata)[]) 68 numpeaks = ncol(spectra(msidata)[])*nrow(spectra(msidata)[])
69 ## Percentage of intensities > 0 69 ## Percentage of intensities > 0
70 percpeaks = round(npeaks/numpeaks*100, digits=2) 70 percpeaks = round(npeaks/numpeaks*100, digits=2)
71 ## Number of empty TICs 71 ## Number of empty TICs
72 TICs = colSums(spectra(msidata)[]) 72 TICs = colSums(spectra(msidata)[])
101 peakpickinginfo='FALSE' 101 peakpickinginfo='FALSE'
102 } else { 102 } else {
103 peakpickinginfo=processinginfo@peakPicking 103 peakpickinginfo=processinginfo@peakPicking
104 } 104 }
105 105
106 ##################################### read and filter input masses ############## 106 ##################################### read and filter input m/z ##############
107 107
108 input_list = read.delim("$massfile", header = FALSE, stringsAsFactors = FALSE) 108 input_list = read.delim("$massfile", header = FALSE, stringsAsFactors = FALSE)
109 109
110 ### in case input file had only one column with mz values but not names, duplicate mz values and use as names: 110 ### in case input file had only one column with m/z values but not names, duplicate m/z values and use as names:
111 111 if (ncol(input_list) == 1){
112 if (ncol(input_list) == 1) 112 input_list = cbind(input_list, input_list)}
113 { 113
114 input_list = cbind(input_list, input_list) 114 ### calculate how many input m/z are valid:
115 }
116
117 ### calculate how many input masses are valid:
118 inputmasses = input_list[input_list[,1]>minmz & input_list[,1]<maxmz,] 115 inputmasses = input_list[input_list[,1]>minmz & input_list[,1]<maxmz,]
119 116 inputmz = as.numeric(inputmasses[,1])
120 inputmz = inputmasses[,1] 117 inputnames = as.character(inputmasses[,2])
121 inputnames = inputmasses[,2] 118
122 119
123 if (length(inputmz) == 1) 120 ############################## PDF #############################################
124 { 121 ################################################################################
125 countpixels = sum(spectra(msidata)[features(msidata, mz = inputmz), ] >0) 122
126 percentpixels = round(countpixels/pixelcount*100, digits=1) 123 pdf("heatmaps.pdf", fonts = "Times", pointsize = 12)
127 valuesdataframe = cbind(inputmz, cbind(countpixels, percentpixels)) 124 plot(0,type='n',axes=FALSE,ann=FALSE)
128 write.table(valuesdataframe, file="$pixel_count", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t") 125 #if not $filename:
129 }else if (length(inputmz) >1) { 126 #set $filename = $infile.display_name
130 countpixels = rowSums(spectra(msidata)[features(msidata, mz=inputmz),] >0) 127 #end if
131 percentpixels = round(countpixels/pixelcount*100, digits=1) 128 title(main=paste("\nHeatmap images\n\n", "Filename:\n", "$filename"))
132 valuesdataframe = cbind(inputmz, cbind(countpixels, percentpixels)) 129
133 write.table(valuesdataframe, file="$pixel_count", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t") 130 ############################# I) numbers ####################################
134 }else{ 131
135 valuesdataframe = data.frame(0,0) 132 properties = c("Number of m/z features",
136 write.table(valuesdataframe, file="$pixel_count", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t") 133 "Range of m/z values [Da]",
137 }
138
139 ############################ summarize file properties in numbers ##############
140
141 properties = c("Number of mz features",
142 "Range of mz values [Da]",
143 "Number of pixels", 134 "Number of pixels",
144 "Range of x coordinates", 135 "Range of x coordinates",
145 "Range of y coordinates", 136 "Range of y coordinates",
146 "Range of intensities", 137 "Range of intensities",
147 "Median of intensities", 138 "Median of intensities",
151 "Normalization", 142 "Normalization",
152 "Smoothing", 143 "Smoothing",
153 "Baseline reduction", 144 "Baseline reduction",
154 "Peak picking", 145 "Peak picking",
155 "Centroided", 146 "Centroided",
156 paste0("# valid masses in \n", "$massfile.display_name")) 147 paste0("# valid m/z in \n", "$massfile.display_name"))
157 148
158 values = c(paste0(maxfeatures), 149 values = c(paste0(maxfeatures),
159 paste0(minmz, " - ", maxmz), 150 paste0(minmz, " - ", maxmz),
160 paste0(pixelcount), 151 paste0(pixelcount),
161 paste0(minimumx, " - ", maximumx), 152 paste0(minimumx, " - ", maximumx),
172 paste0(centroidedinfo), 163 paste0(centroidedinfo),
173 paste0(length(inputmz), "/", length(input_list[,1]))) 164 paste0(length(inputmz), "/", length(input_list[,1])))
174 165
175 property_df = data.frame(properties, values) 166 property_df = data.frame(properties, values)
176 167
177
178 ############################## PDF #############################################
179
180 pdf("heatmaps.pdf", fonts = "Times", pointsize = 12)
181 plot(0,type='n',axes=FALSE,ann=FALSE)
182 #if not $filename:
183 #set $filename = $infile.display_name
184 #end if
185 title(main=paste("\nHeatmap images\n\n", "Filename:\n", "$filename"))
186
187 ############################# I) numbers ####################################
188
189 grid.table(property_df, rows= NULL) 168 grid.table(property_df, rows= NULL)
190 169
191 ############################# II) images #################################### 170 ############################# II) images ####################################
192 171
193 ### only plot images when file has peaks and valid input mz: 172 ### only plot images when file has peaks and valid input m/z:
194 173
195 if (npeaks > 0) 174 if (npeaks > 0){
196 { 175 if (length(inputmz) != 0){
197 if (length(inputmz) != 0) 176 for (mass in 1:length(inputmz)){
198 { 177
199 for (mass in 1:length(inputmz)) 178 ###standard image
200 { 179
201 print(image(msidata, mz=inputmz[mass], strip = strip.custom(bg="lightgrey", par.strip.text=list(col="black", cex=.9)), 180 #if str($image_cond.image_type) == "standard_image":
202 lattice=TRUE, plusminus = $plusminus_dalton, contrast.enhance = "$image_contrast", smooth.image = "$image_smoothing", 181 print("standard image")
203 main= paste0(mass, ") ", inputnames[mass], " (", round(inputmz[mass], digits = 2)," ± ", $plusminus_dalton, " Da)"))) 182
204 } 183 print(image(msidata, mz=inputmz[mass],plusminus = $plusminus_dalton, contrast.enhance = "$image_contrast",
205 } else {print("The input masses were invalid")} 184 smooth.image = "$image_smoothing", strip=$strip, colorkey=$colorkey,
185 main= paste0(inputnames[mass], " (", round(inputmz[mass], digits = 2)," ± ", $plusminus_dalton, " Da)")))}
186
187
188 ###lattice image
189
190 #elif str($image_cond.image_type) == "lattice_image":
191 print("lattice image")
192
193 #if str($strip) =="TRUE":
194
195 print(image(msidata, mz=inputmz[mass], strip = strip.custom(bg="lightgrey", par.strip.text=list(col="black", cex=.9)),
196 lattice=TRUE, plusminus = $plusminus_dalton, contrast.enhance = "$image_contrast", smooth.image = "$image_smoothing",
197 colorkey=$colorkey,
198 main= paste0(inputnames[mass], " (", round(inputmz[mass], digits = 2)," ± ", $plusminus_dalton, " Da)")))}
199
200 #elif str($strip) =="FALSE":
201
202 print(image(msidata, mz=inputmz[mass], strip = $strip,
203 lattice=TRUE, plusminus = $plusminus_dalton, contrast.enhance = "$image_contrast", smooth.image = "$image_smoothing",
204 colorkey=$colorkey,
205 main= paste0(inputnames[mass], " (", round(inputmz[mass], digits = 2)," ± ", $plusminus_dalton, " Da)")))}
206
207 #end if
208
209 #end if
210
211 } else {print("The input m/z were invalid")}
206 dev.off() 212 dev.off()
207 }else{ 213 }else{
208 print("inputfile has no intensities > 0") 214 print("inputfile has no intensities > 0")
209 dev.off() 215 dev.off()
210 } 216 }
211 ]]></configfile> 217 ]]></configfile>
212 </configfiles> 218 </configfiles>
213 <inputs> 219 <inputs>
214 <param name="infile" type="data" format="imzml,rdata,analyze75" label="Inputfile as imzML, Analyze7.5 or Cardinal MSImageSet saved as RData" 220 <param name="infile" type="data" format="imzml,rdata,analyze75" label="Inputfile as imzML, Analyze7.5 or Cardinal MSImageSet saved as RData"
215 help="Upload composite datatype imzml (ibd+imzML) or analyze75 (hdr+img+t2m) or regular upload .RData (Cardinal MSImageSet)"/> 221 help="Upload composite datatype imzml (ibd+imzML) or analyze75 (hdr+img+t2m) or regular upload .RData (Cardinal MSImageSet)"/>
216 <param name="filename" type="text" value="" label="Title" help="will appear in the quality report. If nothing given it will take the dataset name"/> 222 <param name="filename" type="text" value="" label="Title" help="will appear in the pdf output. If nothing given it will take the dataset name"/>
217 <param name="massfile" type="data" format="tabular" label="Tabular file with masses and names" 223 <param name="massfile" type="data" format="tabular" label="Tabular file with m/z and names"
218 help="first column mass (m/z), second column mass name, tab separated file"/> 224 help="first column m/z, second column m/z name, tab separated file"/>
219 <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"> 225 <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">
220 <option value="none" selected="True">none</option> 226 <option value="none" selected="True">none</option>
221 <option value="suppression">suppression</option> 227 <option value="suppression">suppression</option>
222 <option value="histogram">histogram</option> 228 <option value="histogram">histogram</option>
223 </param> 229 </param>
224 <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"> 230 <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">
225 <option value="none" selected="True">none</option> 231 <option value="none" selected="True">none</option>
226 <option value="gaussian">gaussian</option> 232 <option value="gaussian">gaussian</option>
227 <option value="adaptive">adaptive</option> 233 <option value="adaptive">adaptive</option>
228 </param> 234 </param>
229 <param name="plusminus_dalton" value="0.25" type="float" label="Mass range" help="plusminus mass window in Dalton"/> 235 <param name="plusminus_dalton" value="0.25" type="float" label="M/z range" help="plusminus m/z window in Dalton"/>
236 <param name="strip" type="boolean" checked="True" display="radio" truevalue="TRUE" falsevalue="FALSE" label="Display m/z value in plot"/>
237 <param name="colorkey" type="boolean" checked="True" display="radio" truevalue="TRUE" falsevalue="FALSE" label="Display colorkey in plot"/>
238 <conditional name="image_cond">
239 <param name="image_type" type="select" label="Select the image type">
240 <option value="standard_image" selected="True">standard</option>
241 <option value="lattice_image">lattice</option>
242 </param>
243 <when value="standard_image"/>
244 <when value="lattice_image"/>
245 </conditional>
230 </inputs> 246 </inputs>
231 <outputs> 247 <outputs>
232 <data format="pdf" name="plots" from_work_dir="heatmaps.pdf" label = "${tool.name} ${on_string}"/> 248 <data format="pdf" name="plots" from_work_dir="heatmaps.pdf" label = "$infile.display_name heatmaps"/>
233 <data format="tabular" name="pixel_count" label="Number of peaks (intensity > 0) per mz"/>
234 </outputs> 249 </outputs>
235 <tests> 250 <tests>
236 <test> 251 <test>
237 <param name="infile" value="" ftype="imzml"> 252 <param name="infile" value="" ftype="imzml">
238 <composite_data value="Example_Continuous.imzML"/> 253 <composite_data value="Example_Continuous.imzML"/>
240 </param> 255 </param>
241 <param name="massfile" value="inputpeptides.tabular" ftype="tabular"/> 256 <param name="massfile" value="inputpeptides.tabular" ftype="tabular"/>
242 <param name="plusminus_dalton" value="0.25"/> 257 <param name="plusminus_dalton" value="0.25"/>
243 <param name="filename" value="Testfile_imzml"/> 258 <param name="filename" value="Testfile_imzml"/>
244 <param name="image_contrast" value="histogram"/> 259 <param name="image_contrast" value="histogram"/>
260 <param name="strip" value="True"/>
261 <param name="colorkey" value="True"/>
262 <param name="image_type" value="lattice_image"/>
245 <output name="plots" file="Heatmaps_imzml.pdf" compare="sim_size" delta="20000"/> 263 <output name="plots" file="Heatmaps_imzml.pdf" compare="sim_size" delta="20000"/>
246 <output name="pixel_count" file="tabular_imzml.tabular"/>
247 </test> 264 </test>
248 <test> 265 <test>
249 <param name="infile" value="" ftype="analyze75"> 266 <param name="infile" value="" ftype="analyze75">
250 <composite_data value="Analyze75.hdr"/> 267 <composite_data value="Analyze75.hdr"/>
251 <composite_data value="Analyze75.img"/> 268 <composite_data value="Analyze75.img"/>
253 </param> 270 </param>
254 <param name="massfile" value="inputpeptides2.tabular" ftype="tabular"/> 271 <param name="massfile" value="inputpeptides2.tabular" ftype="tabular"/>
255 <param name="plusminus_dalton" value="0.5"/> 272 <param name="plusminus_dalton" value="0.5"/>
256 <param name="filename" value="Testfile_analyze75"/> 273 <param name="filename" value="Testfile_analyze75"/>
257 <param name="image_smoothing" value="gaussian"/> 274 <param name="image_smoothing" value="gaussian"/>
275 <param name="strip" value="False"/>
276 <param name="colorkey" value="True"/>
258 <output name="plots" file="Heatmaps_analyze75.pdf" compare="sim_size" delta="20000"/> 277 <output name="plots" file="Heatmaps_analyze75.pdf" compare="sim_size" delta="20000"/>
259 <output name="pixel_count" file="tabular_analyze75.tabular"/>
260 </test> 278 </test>
261 <test> 279 <test>
262 <param name="infile" value="preprocessed.rdata" ftype="rdata"/> 280 <param name="infile" value="preprocessed.rdata" ftype="rdata"/>
263 <param name="massfile" value="inputpeptides.tabular" ftype="tabular"/> 281 <param name="massfile" value="inputpeptides.tabular" ftype="tabular"/>
264 <param name="plusminus_dalton" value="0.5"/> 282 <param name="plusminus_dalton" value="0.5"/>
283 <param name="strip" value="True"/>
284 <param name="colorkey" value="True"/>
285 <param name="image_type" value="lattice_image"/>
265 <param name="filename" value="Testfile_rdata"/> 286 <param name="filename" value="Testfile_rdata"/>
266 <output name="plots" file="Heatmaps_rdata.pdf" compare="sim_size" delta="20000"/> 287 <output name="plots" file="Heatmaps_rdata.pdf" compare="sim_size" delta="20000"/>
267 <output name="pixel_count" file="tabular_rdata.tabular"/>
268 </test> 288 </test>
269 <test> 289 <test>
270 <param name="infile" value="empty_spectra.rdata" ftype="rdata"/> 290 <param name="infile" value="empty_spectra.rdata" ftype="rdata"/>
271 <param name="massfile" value="inputpeptides2.tabular" ftype="tabular"/> 291 <param name="massfile" value="inputpeptides2.tabular" ftype="tabular"/>
272 <param name="plusminus_dalton" value="0.5"/> 292 <param name="plusminus_dalton" value="0.5"/>
293 <param name="strip" value="True"/>
294 <param name="colorkey" value="False"/>
273 <param name="filename" value="Testfile_rdata"/> 295 <param name="filename" value="Testfile_rdata"/>
274 <output name="plots" file="Heatmaps_LM8_file16.pdf" compare="sim_size" delta="20000"/> 296 <output name="plots" file="Heatmaps_LM8_file16.pdf" compare="sim_size" delta="20000"/>
275 <output name="pixel_count" file="tabular_LM8file16.tabular"/>
276 </test> 297 </test>
277 </tests> 298 </tests>
278 <help><![CDATA[ 299 <help><![CDATA[
279 300
280 301
281 Cardinal is an R package that implements statistical & computational tools for analyzing mass spectrometry imaging datasets. `More information on Cardinal <http://cardinalmsi.org//>`_ 302 Cardinal is an R package that implements statistical & computational tools for analyzing mass spectrometry imaging datasets. `More information on Cardinal <http://cardinalmsi.org//>`_
282 303
283 This tool uses the Cardinal image function to plot the intensity distribution of interesting masses of mass-spectrometry imaging data. 304 This tool uses the Cardinal image function to plot the intensity distribution of interesting m/z of mass spectrometry imaging data.
284 Input data: 305 Input data:
285 306
286 3 types of mass-spectrometry imaging data can be used: 307 3 types of mass spectrometry imaging data can be used:
287 308
288 - imzml file (upload imzml and ibd file via the "composite" function) `Introduction to the imzml format <https://ms-imaging.org/wp/imzml/>`_ 309 - imzml file (upload imzml and ibd file via the "composite" function) `Introduction to the imzml format <https://ms-imaging.org/wp/imzml/>`_
289 - Analyze7.5 (upload hdr, img and t2m file via the "composite" function) 310 - Analyze7.5 (upload hdr, img and t2m file via the "composite" function)
290 - Cardinal "MSImageSet" data (with variable name "msidata", saved as .RData) 311 - Cardinal "MSImageSet" data (with variable name "msidata", saved as .RData)
291 312
292 Tabular file with masses: 313 Tabular file with m/z:
293 314
294 - tab separated file (.tabular), 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 button with the pen (edit attributes)) 315 - tab separated file (.tabular), 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 button with the pen (edit attributes))
295 - first column must contain masses (separate point numbers by point, not comma) 316 - first column must contain m/z (separate point numbers by point, not comma)
296 - optionally a second column with names for the masses can be provided 317 - optionally a second column with names for the m/z can be provided
297 - no empty fields or letters are allowed in the first column 318 - no empty fields or letters are allowed in the first column
298 319
299 Output: 320 Output:
300 321
301 - Pdf with the heatmap images 322 - Pdf with the heatmap images
302 - Tabular with masses that were in the mass range and their occurence over all pixels (absolute and in %)
303 323
304 Troubleshooting: 324 Troubleshooting:
305 325
306 - no heatmaps are plotted when tabular file doesn't fulfill the criteria described above 326 - no heatmaps are plotted when tabular file doesn't fulfill the criteria described above
307 - no heatmaps are plotted when the input mass spectrometry imaging file has no intensities > 0 327 - no heatmaps are plotted when the input mass spectrometry imaging file has no intensities > 0
308 - out of thetabular file only masses with > 1.5-2% pixel coverage can be used with the contrast enhance and image smoothing functions, as both crash when a mass has not enough intensity values 328 - the contrast enhance and image smoothing functions require a certain number of m/z with intensities > 0 (empirical value > 2% of spectra)
329 - the standard image function should work for all files while the lattice function works not on every file (nicely)
309 330
310 ]]> 331 ]]>
311 </help> 332 </help>
312 <citations> 333 <citations>
313 <citation type="doi">10.1093/bioinformatics/btv146</citation> 334 <citation type="doi">10.1093/bioinformatics/btv146</citation>