Mercurial > repos > galaxyp > msi_spectra_plot
comparison msi_spectra_plots.xml @ 5:4f13aec6d8ff draft
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msi_spectra_plots commit 8087490eb4dcaf4ead0f03eae4126780d21e5503
author | galaxyp |
---|---|
date | Fri, 06 Jul 2018 14:14:41 -0400 |
parents | 9eef2792afa4 |
children | 2e0368a6bfe8 |
comparison
equal
deleted
inserted
replaced
4:9eef2792afa4 | 5:4f13aec6d8ff |
---|---|
1 <tool id="mass_spectrometry_imaging_mzplots" name="MSI plot spectra" version="1.10.0.2"> | 1 <tool id="mass_spectrometry_imaging_mzplots" name="MSI plot spectra" version="1.10.0.3"> |
2 <description> | 2 <description> |
3 mass spectrometry imaging mass spectra plots | 3 mass spectrometry imaging mass spectra plots |
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> |
32 library(Cardinal) | 32 library(Cardinal) |
33 library(gridExtra) | 33 library(gridExtra) |
34 library(ggplot2) | 34 library(ggplot2) |
35 library(scales) | 35 library(scales) |
36 | 36 |
37 | |
37 #if $infile.ext == 'imzml' | 38 #if $infile.ext == 'imzml' |
38 msidata <- readImzML('infile', mass.accuracy=$accuracy, units.accuracy = "$units") | 39 #if str($processed_cond.processed_file) == "processed": |
40 msidata <- readImzML('infile', mass.accuracy=$processed_cond.accuracy, units.accuracy = "$processed_cond.units") | |
41 #else | |
42 msidata <- readImzML('infile', attach.only=TRUE) | |
43 #end if | |
39 #elif $infile.ext == 'analyze75' | 44 #elif $infile.ext == 'analyze75' |
40 msidata = readAnalyze('infile') | 45 msidata = readAnalyze('infile', attach.only=TRUE) |
41 #else | 46 #else |
42 load('infile.RData') | 47 load('infile.RData') |
43 #end if | 48 #end if |
44 | 49 |
45 ###################################### file properties in numbers ############## | 50 ###################################### file properties in numbers ############## |
56 maximumx = max(coord(msidata)[,1]) | 61 maximumx = max(coord(msidata)[,1]) |
57 ## Range y coordinates | 62 ## Range y coordinates |
58 minimumy = min(coord(msidata)[,2]) | 63 minimumy = min(coord(msidata)[,2]) |
59 maximumy = max(coord(msidata)[,2]) | 64 maximumy = max(coord(msidata)[,2]) |
60 ## Range of intensities | 65 ## Range of intensities |
61 minint = round(min(spectra(msidata)[]), digits=2) | 66 minint = round(min(spectra(msidata)[], na.rm=TRUE), digits=2) |
62 maxint = round(max(spectra(msidata)[]), digits=2) | 67 maxint = round(max(spectra(msidata)[], na.rm=TRUE), digits=2) |
63 medint = round(median(spectra(msidata)[]), digits=2) | 68 medint = round(median(spectra(msidata)[], na.rm=TRUE), digits=2) |
64 ## Number of intensities > 0 | 69 ## Number of intensities > 0 |
65 npeaks= sum(spectra(msidata)[]>0) | 70 npeaks= sum(spectra(msidata)[]>0, na.rm=TRUE) |
66 ## Spectra multiplied with m/z (potential number of peaks) | 71 ## Spectra multiplied with m/z (potential number of peaks) |
67 numpeaks = ncol(spectra(msidata)[])*nrow(spectra(msidata)[]) | 72 numpeaks = ncol(spectra(msidata)[])*nrow(spectra(msidata)[]) |
68 ## Percentage of intensities > 0 | 73 ## Percentage of intensities > 0 |
69 percpeaks = round(npeaks/numpeaks*100, digits=2) | 74 percpeaks = round(npeaks/numpeaks*100, digits=2) |
70 ## Number of empty TICs | 75 ## Number of empty TICs |
71 TICs = colSums(spectra(msidata)[]) | 76 TICs = colSums(spectra(msidata)[], na.rm=TRUE) |
72 NumemptyTIC = sum(TICs == 0) | 77 NumemptyTIC = sum(TICs == 0) |
78 | |
73 | 79 |
74 ## Processing informations | 80 ## Processing informations |
75 processinginfo = processingData(msidata) | 81 processinginfo = processingData(msidata) |
76 centroidedinfo = processinginfo@centroided | 82 centroidedinfo = processinginfo@centroided |
77 | 83 |
174 | 180 |
175 if (pixelisvalid == "TRUE"){ | 181 if (pixelisvalid == "TRUE"){ |
176 print(pixelisvalid) | 182 print(pixelisvalid) |
177 | 183 |
178 image(msidata, mz=$chosenpixel.inputmz, ylim = c(maximumy+(0.2*maximumy),minimumy-1), | 184 image(msidata, mz=$chosenpixel.inputmz, ylim = c(maximumy+(0.2*maximumy),minimumy-1), |
179 colorkey=FALSE, plusminus = $chosenpixel.plusminusinDalton, contrast.enhance = "histogram", | 185 colorkey=FALSE, plusminus = $chosenpixel.plusminusinDalton, |
180 main= paste0("x= ",$chosenpixel.inputx, ", y= ", $chosenpixel.inputy)) | 186 main= paste0("x= ",$chosenpixel.inputx, ", y= ", $chosenpixel.inputy)) |
181 | 187 |
182 abline(v=$chosenpixel.inputx, col ="$chosenpixel.inputcolour", lty="$chosenpixel.inputtype", lwd=$chosenpixel.inputwidth) | 188 abline(v=$chosenpixel.inputx, col ="$chosenpixel.inputcolour", lty="$chosenpixel.inputtype", lwd=$chosenpixel.inputwidth) |
183 abline(h=$chosenpixel.inputy, col ="$chosenpixel.inputcolour", lty="$chosenpixel.inputtype", lwd=$chosenpixel.inputwidth) | 189 abline(h=$chosenpixel.inputy, col ="$chosenpixel.inputcolour", lty="$chosenpixel.inputtype", lwd=$chosenpixel.inputwidth) |
184 | 190 |
187 plot(msidata, coord=list(x=$chosenpixel.inputx, y=$chosenpixel.inputy)) | 193 plot(msidata, coord=list(x=$chosenpixel.inputx, y=$chosenpixel.inputy)) |
188 | 194 |
189 ##################### IV) plot zoom-in mass spectrum ############### | 195 ##################### IV) plot zoom-in mass spectrum ############### |
190 | 196 |
191 #if $chosenpixel.zoomedplot: | 197 #if $chosenpixel.zoomedplot: |
198 iData(msidata) <- iData(msidata)[] ## getting back data on disk | |
199 | |
192 #for $token in $chosenpixel.zoomedplot: | 200 #for $token in $chosenpixel.zoomedplot: |
193 | 201 |
194 minmasspixel = features(msidata, mz=$token.xlimmin) | 202 minmasspixel = features(msidata, mz=$token.xlimmin) |
195 maxmasspixel = features(msidata, mz=$token.xlimmax) | 203 maxmasspixel = features(msidata, mz=$token.xlimmax) |
196 | 204 |
202 }else{ | 210 }else{ |
203 print("The pixel coordinates did not correspond to a real pixel")} | 211 print("The pixel coordinates did not correspond to a real pixel")} |
204 #end for | 212 #end for |
205 | 213 |
206 colnames(pixeldf) = c("pixel coordinates", "coordinates were found in this file") | 214 colnames(pixeldf) = c("pixel coordinates", "coordinates were found in this file") |
207 | |
208 | 215 |
209 ############################# sample pixel ################################ | 216 ############################# sample pixel ################################ |
210 ########################################################################### | 217 ########################################################################### |
211 | 218 |
212 #elif str( $pixel_conditional.pixel_type) == 'sample_pixel': | 219 #elif str( $pixel_conditional.pixel_type) == 'sample_pixel': |
258 ## print legend only for less than 10 samples | 265 ## print legend only for less than 10 samples |
259 if (length(levels(msidata\$combined_sample)) < 10){ | 266 if (length(levels(msidata\$combined_sample)) < 10){ |
260 key_legend = TRUE | 267 key_legend = TRUE |
261 }else{key_legend = FALSE} | 268 }else{key_legend = FALSE} |
262 | 269 |
270 spectra(msidata) = is.na(spectra(msidata)[]) == 0 ## in case of NA values they will be set to zero | |
271 | |
263 plot(msidata, pixel=1:ncol(msidata), pixel.groups=msidata\$combined_sample, key=key_legend, col=hue_pal()(length(levels(msidata\$combined_sample))),superpose=TRUE) | 272 plot(msidata, pixel=1:ncol(msidata), pixel.groups=msidata\$combined_sample, key=key_legend, col=hue_pal()(length(levels(msidata\$combined_sample))),superpose=TRUE) |
264 }else{ | 273 }else{ |
274 spectra(msidata) = is.na(spectra(msidata)[]) == 0 ## in case of NA values they will be set to zero | |
265 plot(msidata, pixel=1:ncol(msidata), key=TRUE)} | 275 plot(msidata, pixel=1:ncol(msidata), key=TRUE)} |
266 | 276 |
267 ##################### II) Sample: plot zoom-in mass spectrum ########## | 277 ##################### II) Sample: plot zoom-in mass spectrum ########## |
268 | 278 |
269 #if $pixel_conditional.zoomed_sample: | 279 #if $pixel_conditional.zoomed_sample: |
280 iData(msidata) <- iData(msidata)[] ## getting back data on disk | |
270 #for $token in $pixel_conditional.zoomed_sample: | 281 #for $token in $pixel_conditional.zoomed_sample: |
271 print("zoomed sample pixels") | 282 print("zoomed sample pixels") |
272 | 283 |
273 minmasspixel = features(msidata, mz=$token.xlimmin) | 284 minmasspixel = features(msidata, mz=$token.xlimmin) |
274 maxmasspixel = features(msidata, mz=$token.xlimmax) | 285 maxmasspixel = features(msidata, mz=$token.xlimmax) |
282 }else{ | 293 }else{ |
283 plot(msidata[minmasspixel:maxmasspixel,], pixel=1:ncol(msidata), key=TRUE, xlim= c($token.xlimmin,$token.xlimmax))} | 294 plot(msidata[minmasspixel:maxmasspixel,], pixel=1:ncol(msidata), key=TRUE, xlim= c($token.xlimmin,$token.xlimmax))} |
284 | 295 |
285 #end for | 296 #end for |
286 #end if | 297 #end if |
298 | |
287 if (!is.null(levels(msidata\$combined_sample))){ | 299 if (!is.null(levels(msidata\$combined_sample))){ |
288 pixeldf = data.frame(table(msidata\$combined_sample)) | 300 pixeldf = data.frame(table(msidata\$combined_sample)) |
289 }else{ | 301 }else{ |
290 pixeldf = data.frame("$filename", ncol(msidata))} | 302 pixeldf = data.frame("$filename", ncol(msidata))} |
291 colnames(pixeldf) = c("sample name", "number of pixels") | 303 colnames(pixeldf) = c("sample name", "number of pixels") |
292 | 304 |
293 #end if | 305 #end if |
306 | |
307 | |
308 ############################# pixel table ###################################### | |
309 ############################################################################### | |
310 | |
294 | 311 |
295 ### overview table of pixels or samples: | 312 ### overview table of pixels or samples: |
296 plot(0,type='n',axes=FALSE,ann=FALSE) | 313 plot(0,type='n',axes=FALSE,ann=FALSE) |
297 title(main="Overview of chosen pixel:") | 314 title(main="Overview of chosen pixel:") |
298 | 315 |
325 ]]></configfile> | 342 ]]></configfile> |
326 </configfiles> | 343 </configfiles> |
327 <inputs> | 344 <inputs> |
328 <param name="infile" type="data" format="imzml,rdata,analyze75" label="Inputfile as imzML, Analyze7.5 or Cardinal MSImageSet saved as RData" | 345 <param name="infile" type="data" format="imzml,rdata,analyze75" label="Inputfile as imzML, Analyze7.5 or Cardinal MSImageSet saved as RData" |
329 help="Upload composite datatype imzml (ibd+imzML) or analyze75 (hdr+img+t2m) or regular upload .RData (Cardinal MSImageSet)"/> | 346 help="Upload composite datatype imzml (ibd+imzML) or analyze75 (hdr+img+t2m) or regular upload .RData (Cardinal MSImageSet)"/> |
330 <param name="accuracy" type="float" value="50" label="Only for processed imzML files: enter mass accuracy to which the m/z values will be binned" help="This should be set to the native accuracy of the mass spectrometer, if known"/> | 347 <conditional name="processed_cond"> |
331 <param name="units" display="radio" type="select" label="Only for processed imzML files: unit of the mass accuracy" help="either m/z or ppm"> | 348 <param name="processed_file" type="select" label="Is the input file a processed imzML file "> |
332 <option value="mz" >mz</option> | 349 <option value="no_processed" selected="True">not a processed imzML</option> |
333 <option value="ppm" selected="True" >ppm</option> | 350 <option value="processed">processed imzML</option> |
334 </param> | 351 </param> |
352 <when value="no_processed"/> | |
353 <when value="processed"> | |
354 <param name="accuracy" type="float" value="50" label="Mass accuracy to which the m/z values will be binned" help="This should be set to the native accuracy of the mass spectrometer, if known"/> | |
355 <param name="units" display="radio" type="select" label="Unit of the mass accuracy" help="either m/z or ppm"> | |
356 <option value="mz" >mz</option> | |
357 <option value="ppm" selected="True" >ppm</option> | |
358 </param> | |
359 </when> | |
360 </conditional> | |
335 <param name="filename" type="text" value="" label="Title" help="will appear in the pdf output. If nothing given it will take the dataset name"/> | 361 <param name="filename" type="text" value="" label="Title" help="will appear in the pdf output. If nothing given it will take the dataset name"/> |
336 <conditional name="pixel_conditional"> | 362 <conditional name="pixel_conditional"> |
337 <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"> | 363 <param name="pixel_type" type="select" label="Select if you want to plot the mass spectrum of a single pixel or the average spectrum of all pixels of a sample"> |
338 <option value="single_pixel" selected="True">Single pixel</option> | 364 <option value="single_pixel" selected="True">Single pixel</option> |
339 <option value="sample_pixel">All pixels of a sample</option> | 365 <option value="sample_pixel">Average spectrum for each sample</option> |
340 </param> | 366 </param> |
341 <when value="single_pixel"> | 367 <when value="single_pixel"> |
342 <repeat name="repeatpixel" title="Plot mass spectra for pixel of interest" min="1" max="20"> | 368 <repeat name="repeatpixel" title="Plot mass spectra for pixel of interest" min="1" max="20"> |
343 <param name="inputx" type="integer" value="" label="x-coordinate of pixel of interest" help="x-value of the pixel of interest"/> | 369 <param name="inputx" type="integer" value="" label="x-coordinate of pixel of interest" help="x-value of the pixel of interest"/> |
344 <param name="inputy" type="integer" value="" label="y-coordinate of pixel of interest" help="y-value of the pixel of interest"/> | 370 <param name="inputy" type="integer" value="" label="y-coordinate of pixel of interest" help="y-value of the pixel of interest"/> |