Mercurial > repos > galaxyp > msi_ion_images
comparison msi_ion_images.xml @ 4:9746576123c9 draft
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msi_ion_images commit 1c808d60243bb1eeda0cd26cb4b0a17ab05de2c0
author | galaxyp |
---|---|
date | Mon, 28 May 2018 12:37:17 -0400 |
parents | 616b98c235fb |
children | 2b9fa240e261 |
comparison
equal
deleted
inserted
replaced
3:616b98c235fb | 4:9746576123c9 |
---|---|
1 <tool id="mass_spectrometry_imaging_ion_images" name="MSI ion images" version="1.7.0.3"> | 1 <tool id="mass_spectrometry_imaging_ion_images" name="MSI ion images" version="1.10.0.0"> |
2 <description> | 2 <description> |
3 mass spectrometry imaging heatmaps | 3 mass spectrometry imaging heatmaps |
4 </description> | 4 </description> |
5 <requirements> | 5 <requirements> |
6 <requirement type="package" version="1.7.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="2.23-15">r-kernsmooth</requirement> | |
9 <requirement type="package" version="0.20-35">r-lattice</requirement> | 8 <requirement type="package" version="0.20-35">r-lattice</requirement> |
10 </requirements> | 9 </requirements> |
11 <command detect_errors="aggressive"> | 10 <command detect_errors="aggressive"> |
12 <![CDATA[ | 11 <![CDATA[ |
13 #if $infile.ext == 'imzml' | 12 #if $infile.ext == 'imzml' |
14 cp '${infile.extra_files_path}/imzml' infile.imzML && | 13 ln -s '${infile.extra_files_path}/imzml' infile.imzML && |
15 cp '${infile.extra_files_path}/ibd' infile.ibd && | 14 ln -s '${infile.extra_files_path}/ibd' infile.ibd && |
16 #elif $infile.ext == 'analyze75' | 15 #elif $infile.ext == 'analyze75' |
17 cp '${infile.extra_files_path}/hdr' infile.hdr && | 16 ln -s '${infile.extra_files_path}/hdr' infile.hdr && |
18 cp '${infile.extra_files_path}/img' infile.img && | 17 ln -s '${infile.extra_files_path}/img' infile.img && |
19 cp '${infile.extra_files_path}/t2m' infile.t2m && | 18 ln -s '${infile.extra_files_path}/t2m' infile.t2m && |
20 #else | 19 #else |
21 ln -s $infile infile.RData && | 20 ln -s $infile infile.RData && |
22 #end if | 21 #end if |
23 cat '${MSI_heatmaps}' && | 22 cat '${MSI_heatmaps}' && |
24 Rscript '${MSI_heatmaps}' | 23 Rscript '${MSI_heatmaps}' |
25 ]]> | 24 ]]> |
26 </command> | 25 </command> |
27 <configfiles> | 26 <configfiles> |
28 <configfile name="MSI_heatmaps"><![CDATA[ | 27 <configfile name="MSI_heatmaps"><![CDATA[ |
29 ################################# load libraries and read file ######################### | 28 |
29 ################################# load libraries and read file ################# | |
30 | 30 |
31 library(Cardinal) | 31 library(Cardinal) |
32 library(gridExtra) | 32 library(gridExtra) |
33 library(KernSmooth) | |
34 library(lattice) | 33 library(lattice) |
35 | 34 |
36 ## Read MALDI Imaging dataset | 35 ## Read MALDI Imaging dataset |
37 | 36 |
38 #if $infile.ext == 'imzml' | 37 #if $infile.ext == 'imzml' |
39 msidata = readMSIData('infile.imzML') | 38 msidata = readImzML('infile') |
40 #elif $infile.ext == 'analyze75' | 39 #elif $infile.ext == 'analyze75' |
41 msidata = readMSIData('infile.hdr') | 40 msidata = readAnalyze('infile') |
42 #else | 41 #else |
43 load('infile.RData') | 42 load('infile.RData') |
44 #end if | 43 #end if |
45 | 44 |
46 | 45 |
47 ###################################### file properties in numbers ###################### | 46 ###################################### file properties in numbers ############## |
48 | 47 |
49 ## Number of features (mz) | 48 ## Number of features (mz) |
50 maxfeatures = length(features(msidata)) | 49 maxfeatures = length(features(msidata)) |
51 ## Range mz | 50 ## Range mz |
52 minmz = round(min(mz(msidata)), digits=2) | 51 minmz = round(min(mz(msidata)), digits=2) |
79 | 78 |
80 ## if TRUE write processinginfo if no write FALSE | 79 ## if TRUE write processinginfo if no write FALSE |
81 | 80 |
82 ## normalization | 81 ## normalization |
83 if (length(processinginfo@normalization) == 0) { | 82 if (length(processinginfo@normalization) == 0) { |
84 normalizationinfo='FALSE' | 83 normalizationinfo='FALSE' |
85 } else { | 84 } else { |
86 normalizationinfo=processinginfo@normalization | 85 normalizationinfo=processinginfo@normalization |
87 } | 86 } |
88 ## smoothing | 87 ## smoothing |
89 if (length(processinginfo@smoothing) == 0) { | 88 if (length(processinginfo@smoothing) == 0) { |
90 smoothinginfo='FALSE' | 89 smoothinginfo='FALSE' |
91 } else { | 90 } else { |
92 smoothinginfo=processinginfo@smoothing | 91 smoothinginfo=processinginfo@smoothing |
93 } | 92 } |
94 ## baseline | 93 ## baseline |
95 if (length(processinginfo@baselineReduction) == 0) { | 94 if (length(processinginfo@baselineReduction) == 0) { |
96 baselinereductioninfo='FALSE' | 95 baselinereductioninfo='FALSE' |
97 } else { | 96 } else { |
98 baselinereductioninfo=processinginfo@baselineReduction | 97 baselinereductioninfo=processinginfo@baselineReduction |
99 } | 98 } |
100 ## peak picking | 99 ## peak picking |
101 if (length(processinginfo@peakPicking) == 0) { | 100 if (length(processinginfo@peakPicking) == 0) { |
102 peakpickinginfo='FALSE' | 101 peakpickinginfo='FALSE' |
103 } else { | 102 } else { |
104 peakpickinginfo=processinginfo@peakPicking | 103 peakpickinginfo=processinginfo@peakPicking |
105 } | 104 } |
106 | 105 |
107 | 106 ##################################### read and filter input masses ############## |
108 ### Read tabular file with peptide masses for heatmap images: | |
109 | 107 |
110 input_list = read.delim("$massfile", header = FALSE, stringsAsFactors = FALSE) | 108 input_list = read.delim("$massfile", header = FALSE, stringsAsFactors = FALSE) |
111 if (ncol(input_list) == 1) | 109 |
112 { | 110 ### in case input file had only one column with mz values but not names, duplicate mz values and use as names: |
113 input_list = cbind(input_list, input_list) | 111 |
114 } | 112 if (ncol(input_list) == 1) |
115 | 113 { |
116 ### calculate how many input masses are valid: | 114 input_list = cbind(input_list, input_list) |
117 inputmasses = input_list[input_list[,1]>minmz & input_list[,1]<maxmz,] | 115 } |
118 | 116 |
119 inputmz = inputmasses[,1] | 117 ### calculate how many input masses are valid: |
120 inputnames = inputmasses[,2] | 118 inputmasses = input_list[input_list[,1]>minmz & input_list[,1]<maxmz,] |
121 | 119 |
122 if (nrow(input_list) == 1) | 120 inputmz = inputmasses[,1] |
123 { | 121 inputnames = inputmasses[,2] |
122 | |
123 if (length(inputmz) == 1) | |
124 { | |
124 countpixels = sum(spectra(msidata)[features(msidata, mz = inputmz), ] >0) | 125 countpixels = sum(spectra(msidata)[features(msidata, mz = inputmz), ] >0) |
125 }else { | 126 percentpixels = round(countpixels/pixelcount*100, digits=1) |
127 valuesdataframe = cbind(inputmz, cbind(countpixels, percentpixels)) | |
128 write.table(valuesdataframe, file="$pixel_count", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t") | |
129 }else if (length(inputmz) >1) { | |
126 countpixels = rowSums(spectra(msidata)[features(msidata, mz=inputmz),] >0) | 130 countpixels = rowSums(spectra(msidata)[features(msidata, mz=inputmz),] >0) |
127 } | 131 percentpixels = round(countpixels/pixelcount*100, digits=1) |
128 | 132 valuesdataframe = cbind(inputmz, cbind(countpixels, percentpixels)) |
129 percentpixels = round(countpixels/pixelcount*100, digits=1) | 133 write.table(valuesdataframe, file="$pixel_count", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t") |
130 valuesdataframe = cbind(inputmz, cbind(countpixels, percentpixels)) | 134 }else{ |
131 | 135 valuesdataframe = data.frame(0,0) |
132 | 136 write.table(valuesdataframe, file="$pixel_count", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t") |
133 write.table(valuesdataframe, file="$pixel_count", quote = FALSE, row.names = TRUE, col.names=NA, sep = "\t") | 137 } |
134 | 138 |
135 colnames(input_list)[1:2] = c("mz", "name") | 139 ############################ summarize file properties in numbers ############## |
140 | |
136 properties = c("Number of mz features", | 141 properties = c("Number of mz features", |
137 "Range of mz values [Da]", | 142 "Range of mz values [Da]", |
138 "Number of pixels", | 143 "Number of pixels", |
139 "Range of x coordinates", | 144 "Range of x coordinates", |
140 "Range of y coordinates", | 145 "Range of y coordinates", |
168 paste0(length(inputmz), "/", length(input_list[,1]))) | 173 paste0(length(inputmz), "/", length(input_list[,1]))) |
169 | 174 |
170 property_df = data.frame(properties, values) | 175 property_df = data.frame(properties, values) |
171 | 176 |
172 | 177 |
173 | 178 ############################## PDF ############################################# |
174 | |
175 ######################################## PDF ############################################# | |
176 ########################################################################################## | |
177 ########################################################################################## | |
178 | |
179 | 179 |
180 pdf("heatmaps.pdf", fonts = "Times", pointsize = 12) | 180 pdf("heatmaps.pdf", fonts = "Times", pointsize = 12) |
181 plot(0,type='n',axes=FALSE,ann=FALSE) | 181 plot(0,type='n',axes=FALSE,ann=FALSE) |
182 #if not $filename: | 182 #if not $filename: |
183 #set $filename = $infile.display_name | 183 #set $filename = $infile.display_name |
184 #end if | 184 #end if |
185 title(main=paste("Quality control of MSI data\n\n", "Filename:", "$filename")) | 185 title(main=paste("\nHeatmap images\n\n", "Filename:\n", "$filename")) |
186 | 186 |
187 ############################# I) numbers #################################### | 187 ############################# I) numbers #################################### |
188 ############################################################################# | |
189 | 188 |
190 grid.table(property_df, rows= NULL) | 189 grid.table(property_df, rows= NULL) |
190 | |
191 ############################# II) images #################################### | |
192 | |
193 ### only plot images when file has peaks and valid input mz: | |
191 | 194 |
192 if (npeaks > 0) | 195 if (npeaks > 0) |
193 { | 196 { |
194 | |
195 if (length(inputmz) != 0) | 197 if (length(inputmz) != 0) |
196 { | 198 { |
197 | |
198 for (mass in 1:length(inputmz)) | 199 for (mass in 1:length(inputmz)) |
199 { | 200 { |
200 | |
201 | |
202 print(image(msidata, mz=inputmz[mass], strip = strip.custom(bg="lightgrey", par.strip.text=list(col="black", cex=.9)), | 201 print(image(msidata, mz=inputmz[mass], strip = strip.custom(bg="lightgrey", par.strip.text=list(col="black", cex=.9)), |
203 lattice=TRUE, ylim = c(maximumy+1,minimumy-1), plusminus = $plusminus_dalton, contrast.enhance = "$image_contrast", smooth.image = "$image_smoothing", | 202 lattice=TRUE, plusminus = $plusminus_dalton, contrast.enhance = "$image_contrast", smooth.image = "$image_smoothing", |
204 main= paste0(mass, ") ", inputnames[mass], " (", round(inputmz[mass], digits = 2)," ± ", $plusminus_dalton, " Da)"))) | 203 main= paste0(mass, ") ", inputnames[mass], " (", round(inputmz[mass], digits = 2)," ± ", $plusminus_dalton, " Da)"))) |
205 } | 204 } |
206 } else {print("The input masses were invalid")} | 205 } else {print("The input masses were invalid")} |
207 | |
208 dev.off() | 206 dev.off() |
209 | |
210 }else{ | 207 }else{ |
211 print("inputfile has no intensities > 0") | 208 print("inputfile has no intensities > 0") |
212 dev.off() | 209 dev.off() |
213 } | 210 } |
214 ]]></configfile> | 211 ]]></configfile> |
215 </configfiles> | 212 </configfiles> |
216 <inputs> | 213 <inputs> |
217 <param name="infile" type="data" format="imzml,rdata,analyze75" label="Inputfile as imzML, Analyze7.5 or Cardinal MSImageSet saved as RData" | 214 <param name="infile" type="data" format="imzml,rdata,analyze75" label="Inputfile as imzML, Analyze7.5 or Cardinal MSImageSet saved as RData" |
218 help="Upload composite datatype imzml (ibd+imzML) or analyze75 (hdr+img+t2m) or regular upload .RData (Cardinal MSImageSet)"/> | 215 help="Upload composite datatype imzml (ibd+imzML) or analyze75 (hdr+img+t2m) or regular upload .RData (Cardinal MSImageSet)"/> |
219 <param name="filename" type="text" value="" label="Title" help="will appear in the quality report. If nothing given it will take the dataset name"/> | 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"/> |
220 <param name="massfile" type="data" format="tabular" label="Text file with masses and names" | 217 <param name="massfile" type="data" format="tabular" label="Tabular file with masses and names" |
221 help="first column mass (m/z), second column mass name, tab separated file"/> | 218 help="first column mass (m/z), second column mass name, tab separated file"/> |
222 <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"> | 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"> |
223 <option value="none" selected="True">none</option> | 220 <option value="none" selected="True">none</option> |
224 <option value="suppression">suppression</option> | 221 <option value="suppression">suppression</option> |
225 <option value="histogram">histogram</option> | 222 <option value="histogram">histogram</option> |
260 <param name="image_smoothing" value="gaussian"/> | 257 <param name="image_smoothing" value="gaussian"/> |
261 <output name="plots" file="Heatmaps_analyze75.pdf" compare="sim_size" delta="20000"/> | 258 <output name="plots" file="Heatmaps_analyze75.pdf" compare="sim_size" delta="20000"/> |
262 <output name="pixel_count" file="tabular_analyze75.tabular"/> | 259 <output name="pixel_count" file="tabular_analyze75.tabular"/> |
263 </test> | 260 </test> |
264 <test> | 261 <test> |
265 <param name="infile" value="preprocessing_results1.RData" ftype="rdata"/> | 262 <param name="infile" value="preprocessed.rdata" ftype="rdata"/> |
266 <param name="massfile" value="inputpeptides.tabular" ftype="tabular"/> | 263 <param name="massfile" value="inputpeptides.tabular" ftype="tabular"/> |
267 <param name="plusminus_dalton" value="0.1"/> | 264 <param name="plusminus_dalton" value="0.5"/> |
268 <param name="filename" value="Testfile_rdata"/> | 265 <param name="filename" value="Testfile_rdata"/> |
269 <output name="plots" file="Heatmaps_rdata.pdf" compare="sim_size" delta="20000"/> | 266 <output name="plots" file="Heatmaps_rdata.pdf" compare="sim_size" delta="20000"/> |
270 <output name="pixel_count" file="tabular_rdata.tabular"/> | 267 <output name="pixel_count" file="tabular_rdata.tabular"/> |
271 </test> | 268 </test> |
272 <test> | 269 <test> |
273 <param name="infile" value="LM8_file16.rdata" ftype="rdata"/> | 270 <param name="infile" value="empty_spectra.rdata" ftype="rdata"/> |
274 <param name="massfile" value="inputpeptides2.tabular" ftype="tabular"/> | 271 <param name="massfile" value="inputpeptides2.tabular" ftype="tabular"/> |
275 <param name="plusminus_dalton" value="0.1"/> | 272 <param name="plusminus_dalton" value="0.5"/> |
276 <param name="filename" value="Testfile_rdata"/> | 273 <param name="filename" value="Testfile_rdata"/> |
277 <output name="plots" file="Heatmaps_LM8_file16.pdf" compare="sim_size" delta="20000"/> | 274 <output name="plots" file="Heatmaps_LM8_file16.pdf" compare="sim_size" delta="20000"/> |
278 <output name="pixel_count" file="tabular_LM8file16.tabular"/> | 275 <output name="pixel_count" file="tabular_LM8file16.tabular"/> |
279 </test> | 276 </test> |
280 </tests> | 277 </tests> |
281 <help><![CDATA[ | 278 <help><![CDATA[ |
282 | 279 |
283 Heatmaps for different masses in mass-spectrometry imaging data as pdf output. | 280 |
284 | 281 Cardinal is an R package that implements statistical & computational tools for analyzing mass spectrometry imaging datasets. `More information on Cardinal <http://cardinalmsi.org//>`_ |
282 | |
283 This tool uses the Cardinal image function to plot the intensity distribution of interesting masses of mass-spectrometry imaging data. | |
285 Input data: | 284 Input data: |
286 | 285 |
287 3 types of mass-spectrometry imaging data can be used: | 286 3 types of mass-spectrometry imaging data can be used: |
288 | 287 |
289 - imzml file (upload imzml and ibd file via the "composite" function) `Introduction to the imzml format <http://ms-imaging.org/wp/introduction/>`_ | 288 - imzml file (upload imzml and ibd file via the "composite" function) `Introduction to the imzml format <https://ms-imaging.org/wp/imzml/>`_ |
290 - Analyze7.5 (upload hdr, img and t2m file via the "composite" function) | 289 - Analyze7.5 (upload hdr, img and t2m file via the "composite" function) |
291 - Cardinal "MSImageSet" data (with variable name "msidata", saved as .RData) | 290 - Cardinal "MSImageSet" data (with variable name "msidata", saved as .RData) |
292 | 291 |
293 tabular file with masses: | 292 Tabular file with masses: |
294 - tab separated file (.tabular), datatype in Galaxy must be tabular (if Galaxy auto-detection was wrong, datatype can be changed by pressing the pen button) | 293 |
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)) | |
295 - first column must contain masses (separate point numbers by point, not comma) | 295 - first column must contain masses (separate point numbers by point, not comma) |
296 - optionally a second column with names for the masses can be provided | 296 - optionally a second column with names for the masses can be provided |
297 - no empty fields or letters are allowed (tool crashes with empty fields and a single letter prohibits generation of images) | 297 - no empty fields or letters are allowed in the first column |
298 | 298 |
299 Trouble shooting: | 299 Output: |
300 - no heatmaps are plotted when tabular file contains letters or point numbers with commas or when the input MSI file had no intensities > 0 | 300 |
301 - contrast enhance functions need masses with intensities > 0 in about 1.5% of all pixels - tool crashes when contrast enhance is used on too few intensities | 301 - Pdf with the heatmap images |
302 | 302 - Tabular with masses that were in the mass range and their occurence over all pixels (absolute and in %) |
303 | |
304 Troubleshooting: | |
305 | |
306 - 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 | |
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 | |
303 | 309 |
304 ]]> | 310 ]]> |
305 </help> | 311 </help> |
306 <citations> | 312 <citations> |
307 <citation type="doi">10.1093/bioinformatics/btv146</citation> | 313 <citation type="doi">10.1093/bioinformatics/btv146</citation> |