# HG changeset patch # User galaxyp # Date 1528752711 14400 # Node ID a851b4e8fba7459e655517c0a6d387878622b67a # Parent 729a8bf3ffa9aa10f09654a9828e50da9c6c75f7 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msi_ion_images commit a7be47698f53eb4f00961192327d93e8989276a7 diff -r 729a8bf3ffa9 -r a851b4e8fba7 msi_ion_images.xml --- a/msi_ion_images.xml Mon May 28 12:34:05 2018 -0400 +++ b/msi_ion_images.xml Mon Jun 11 17:31:51 2018 -0400 @@ -1,6 +1,6 @@ - + - mass spectrometry imaging heatmaps + mass spectrometry imaging m/z heatmaps bioconductor-cardinal @@ -45,9 +45,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) @@ -64,7 +64,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) @@ -103,43 +103,34 @@ peakpickinginfo=processinginfo@peakPicking } -##################################### read and filter input masses ############## +##################################### read and filter input m/z ############## input_list = read.delim("$massfile", header = FALSE, stringsAsFactors = FALSE) -### in case input file had only one column with mz values but not names, duplicate mz values and use as names: +### in case input file had only one column with m/z values but not names, duplicate m/z values and use as names: +if (ncol(input_list) == 1){ + input_list = cbind(input_list, input_list)} -if (ncol(input_list) == 1) -{ - input_list = cbind(input_list, input_list) -} +### calculate how many input m/z are valid: +inputmasses = input_list[input_list[,1]>minmz & input_list[,1]minmz & input_list[,1]0) - percentpixels = round(countpixels/pixelcount*100, digits=1) - valuesdataframe = cbind(inputmz, cbind(countpixels, percentpixels)) - write.table(valuesdataframe, file="$pixel_count", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t") -}else if (length(inputmz) >1) { - countpixels = rowSums(spectra(msidata)[features(msidata, mz=inputmz),] >0) - percentpixels = round(countpixels/pixelcount*100, digits=1) - valuesdataframe = cbind(inputmz, cbind(countpixels, percentpixels)) - write.table(valuesdataframe, file="$pixel_count", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t") -}else{ - valuesdataframe = data.frame(0,0) - write.table(valuesdataframe, file="$pixel_count", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t") -} +############################## PDF ############################################# +################################################################################ -############################ summarize file properties in numbers ############## +pdf("heatmaps.pdf", fonts = "Times", pointsize = 12) +plot(0,type='n',axes=FALSE,ann=FALSE) +#if not $filename: + #set $filename = $infile.display_name +#end if +title(main=paste("\nHeatmap images\n\n", "Filename:\n", "$filename")) -properties = c("Number of mz features", - "Range of mz values [Da]", +############################# I) numbers #################################### + +properties = c("Number of m/z features", + "Range of m/z values [Da]", "Number of pixels", "Range of x coordinates", "Range of y coordinates", @@ -153,7 +144,7 @@ "Baseline reduction", "Peak picking", "Centroided", - paste0("# valid masses in \n", "$massfile.display_name")) + paste0("# valid m/z in \n", "$massfile.display_name")) values = c(paste0(maxfeatures), paste0(minmz, " - ", maxmz), @@ -174,38 +165,53 @@ property_df = data.frame(properties, values) - -############################## PDF ############################################# - -pdf("heatmaps.pdf", fonts = "Times", pointsize = 12) -plot(0,type='n',axes=FALSE,ann=FALSE) -#if not $filename: - #set $filename = $infile.display_name -#end if -title(main=paste("\nHeatmap images\n\n", "Filename:\n", "$filename")) - -############################# I) numbers #################################### - grid.table(property_df, rows= NULL) ############################# II) images #################################### -### only plot images when file has peaks and valid input mz: +### only plot images when file has peaks and valid input m/z: + +if (npeaks > 0){ + if (length(inputmz) != 0){ + for (mass in 1:length(inputmz)){ + +###standard image + +#if str($image_cond.image_type) == "standard_image": + print("standard image") + + print(image(msidata, mz=inputmz[mass],plusminus = $plusminus_dalton, contrast.enhance = "$image_contrast", + smooth.image = "$image_smoothing", strip=$strip, colorkey=$colorkey, + main= paste0(inputnames[mass], " (", round(inputmz[mass], digits = 2)," ± ", $plusminus_dalton, " Da)")))} + + +###lattice image -if (npeaks > 0) -{ - if (length(inputmz) != 0) - { - for (mass in 1:length(inputmz)) - { - print(image(msidata, mz=inputmz[mass], strip = strip.custom(bg="lightgrey", par.strip.text=list(col="black", cex=.9)), - lattice=TRUE, plusminus = $plusminus_dalton, contrast.enhance = "$image_contrast", smooth.image = "$image_smoothing", - main= paste0(mass, ") ", inputnames[mass], " (", round(inputmz[mass], digits = 2)," ± ", $plusminus_dalton, " Da)"))) - } - } else {print("The input masses were invalid")} +#elif str($image_cond.image_type) == "lattice_image": + print("lattice image") + + #if str($strip) =="TRUE": + + print(image(msidata, mz=inputmz[mass], strip = strip.custom(bg="lightgrey", par.strip.text=list(col="black", cex=.9)), + lattice=TRUE, plusminus = $plusminus_dalton, contrast.enhance = "$image_contrast", smooth.image = "$image_smoothing", + colorkey=$colorkey, + main= paste0(inputnames[mass], " (", round(inputmz[mass], digits = 2)," ± ", $plusminus_dalton, " Da)")))} + + #elif str($strip) =="FALSE": + + print(image(msidata, mz=inputmz[mass], strip = $strip, + lattice=TRUE, plusminus = $plusminus_dalton, contrast.enhance = "$image_contrast", smooth.image = "$image_smoothing", + colorkey=$colorkey, + main= paste0(inputnames[mass], " (", round(inputmz[mass], digits = 2)," ± ", $plusminus_dalton, " Da)")))} + + #end if + +#end if + + } else {print("The input m/z were invalid")} dev.off() }else{ - print("inputfile has no intensities > 0") + print("inputfile has no intensities > 0") dev.off() } ]]> @@ -213,9 +219,9 @@ - - + + @@ -226,11 +232,20 @@ - + + + + + + + + + + + - - + @@ -242,8 +257,10 @@ + + + - @@ -255,24 +272,28 @@ + + - + + + - + + - `_ -This tool uses the Cardinal image function to plot the intensity distribution of interesting masses of mass-spectrometry imaging data. +This tool uses the Cardinal image function to plot the intensity distribution of interesting m/z of mass spectrometry imaging data. Input data: -3 types of mass-spectrometry imaging data can be used: +3 types of mass spectrometry imaging data can be used: - imzml file (upload imzml and ibd file via the "composite" function) `Introduction to the imzml format `_ - Analyze7.5 (upload hdr, img and t2m file via the "composite" function) - Cardinal "MSImageSet" data (with variable name "msidata", saved as .RData) -Tabular file with masses: +Tabular file with m/z: - 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)) -- first column must contain masses (separate point numbers by point, not comma) -- optionally a second column with names for the masses can be provided +- first column must contain m/z (separate point numbers by point, not comma) +- optionally a second column with names for the m/z can be provided - no empty fields or letters are allowed in the first column Output: - Pdf with the heatmap images -- Tabular with masses that were in the mass range and their occurence over all pixels (absolute and in %) Troubleshooting: - no heatmaps are plotted when tabular file doesn't fulfill the criteria described above - no heatmaps are plotted when the input mass spectrometry imaging file has no intensities > 0 -- 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 +- the contrast enhance and image smoothing functions require a certain number of m/z with intensities > 0 (empirical value > 2% of spectra) +- the standard image function should work for all files while the lattice function works not on every file (nicely) ]]> diff -r 729a8bf3ffa9 -r a851b4e8fba7 test-data/Example_Continuous.ibd Binary file test-data/Example_Continuous.ibd has changed diff -r 729a8bf3ffa9 -r a851b4e8fba7 test-data/Example_Continuous.imzML --- a/test-data/Example_Continuous.imzML Mon May 28 12:34:05 2018 -0400 +++ b/test-data/Example_Continuous.imzML Mon Jun 11 17:31:51 2018 -0400 @@ -1,373 +1,313 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 729a8bf3ffa9 -r a851b4e8fba7 test-data/Heatmaps_LM8_file16.pdf Binary file test-data/Heatmaps_LM8_file16.pdf has changed diff -r 729a8bf3ffa9 -r a851b4e8fba7 test-data/Heatmaps_analyze75.pdf Binary file test-data/Heatmaps_analyze75.pdf has changed diff -r 729a8bf3ffa9 -r a851b4e8fba7 test-data/Heatmaps_imzml.pdf Binary file test-data/Heatmaps_imzml.pdf has changed diff -r 729a8bf3ffa9 -r a851b4e8fba7 test-data/Heatmaps_rdata.pdf Binary file test-data/Heatmaps_rdata.pdf has changed