comparison msi_ion_images.xml @ 0:385e8a4accd9 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/msi_ion_images commit 6d271de132f364b1e16b0222ad2d6e315586f0dd
author galaxyp
date Mon, 27 Nov 2017 13:49:35 -0500
parents
children 845fee459824
comparison
equal deleted inserted replaced
-1:000000000000 0:385e8a4accd9
1 <tool id="mass_spectrometry_imaging_ion_images" name="MSI ion images" version="1.7.0">
2 <description>
3 mass spectrometry imaging heatmaps
4 </description>
5 <requirements>
6 <requirement type="package" version="1.7.0">bioconductor-cardinal</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>
10 </requirements>
11 <command detect_errors="aggressive">
12 <![CDATA[
13 #if $infile.ext == 'imzml'
14 cp '${infile.extra_files_path}/imzml' infile.imzML &&
15 cp '${infile.extra_files_path}/ibd' infile.ibd &&
16 #elif $infile.ext == 'analyze75'
17 cp '${infile.extra_files_path}/hdr' infile.hdr &&
18 cp '${infile.extra_files_path}/img' infile.img &&
19 cp '${infile.extra_files_path}/t2m' infile.t2m &&
20 #else
21 ln -s $infile infile.RData &&
22 #end if
23 cat '${MSI_heatmaps}' &&
24 Rscript '${MSI_heatmaps}'
25 ]]>
26 </command>
27 <configfiles>
28 <configfile name="MSI_heatmaps"><![CDATA[
29 ################################# load libraries and read file #########################
30
31 library(Cardinal)
32 library(gridExtra)
33 library(KernSmooth)
34 library(lattice)
35
36 ## Read MALDI Imaging dataset
37
38 #if $infile.ext == 'imzml'
39 msidata <- readMSIData('infile.imzML')
40 #elif $infile.ext == 'analyze75'
41 msidata <- readMSIData('infile.hdr')
42 #else
43 load('infile.RData')
44 #end if
45
46 #if $massfile:
47 ### Read tabular file with peptide masses for plots and heatmap images:
48 input_list = read.delim("$massfile", header = FALSE, na.strings=c("","NA", "#NUM!", "#ZAHL!"), stringsAsFactors = FALSE)
49 if (ncol(input_list) == 1)
50 {
51 input_list = cbind(input_list, input_list)
52 }
53 #else
54 input_list = data.frame(0, 0)
55 #end if
56 colnames(input_list)[1:2] = c("mz", "name")
57
58 ###################################### file properties in numbers ######################
59
60 ## Number of features (mz)
61 maxfeatures = length(features(msidata))
62 ## Range mz
63 minmz = round(min(mz(msidata)), digits=2)
64 maxmz = round(max(mz(msidata)), digits=2)
65 ## Number of spectra (pixels)
66 pixelcount = length(pixels(msidata))
67 ## Range x coordinates
68 minimumx = min(coord(msidata)[,1])
69 maximumx = max(coord(msidata)[,1])
70 ## Range y coordinates
71 minimumy = min(coord(msidata)[,2])
72 maximumy = max(coord(msidata)[,2])
73 ## Range of intensities
74 minint = round(min(spectra(msidata)[]), digits=2)
75 maxint = round(max(spectra(msidata)[]), digits=2)
76 medint = round(median(spectra(msidata)[]), digits=2)
77 ## Number of intensities > 0
78 npeaks= sum(spectra(msidata)[]>0)
79 ## Spectra multiplied with mz (potential number of peaks)
80 numpeaks = ncol(spectra(msidata)[])*nrow(spectra(msidata)[])
81 ## Percentage of intensities > 0
82 percpeaks = round(npeaks/numpeaks*100, digits=2)
83 ## Number of empty TICs
84 TICs = colSums(spectra(msidata)[])
85 NumemptyTIC = sum(TICs == 0)
86
87 ## Processing informations
88 processinginfo = processingData(msidata)
89 centroidedinfo = processinginfo@centroided # TRUE or FALSE
90
91 ## if TRUE write processinginfo if no write FALSE
92
93 ## normalization
94 if (length(processinginfo@normalization) == 0) {
95 normalizationinfo='FALSE'
96 } else {
97 normalizationinfo=processinginfo@normalization
98 }
99 ## smoothing
100 if (length(processinginfo@smoothing) == 0) {
101 smoothinginfo='FALSE'
102 } else {
103 smoothinginfo=processinginfo@smoothing
104 }
105 ## baseline
106 if (length(processinginfo@baselineReduction) == 0) {
107 baselinereductioninfo='FALSE'
108 } else {
109 baselinereductioninfo=processinginfo@baselineReduction
110 }
111 ## peak picking
112 if (length(processinginfo@peakPicking) == 0) {
113 peakpickinginfo='FALSE'
114 } else {
115 peakpickinginfo=processinginfo@peakPicking
116 }
117
118 ### calculate how many input masses are valid:
119 inputmasses = input_list[input_list[,1]>minmz & input_list[,1]<maxmz,]
120
121 inputmz = inputmasses[,1]
122 inputnames = inputmasses[,2]
123
124 properties = c("Number of mz features",
125 "Range of mz values [Da]",
126 "Number of pixels",
127 "Range of x coordinates",
128 "Range of y coordinates",
129 "Range of intensities",
130 "Median of intensities",
131 "Intensities > 0",
132 "Number of zero TICs",
133 "Preprocessing",
134 "Normalization",
135 "Smoothing",
136 "Baseline reduction",
137 "Peak picking",
138 "Centroided",
139 paste0("# valid masses in ", "$filename"))
140
141 values = c(paste0(maxfeatures),
142 paste0(minmz, " - ", maxmz),
143 paste0(pixelcount),
144 paste0(minimumx, " - ", maximumx),
145 paste0(minimumy, " - ", maximumy),
146 paste0(minint, " - ", maxint),
147 paste0(medint),
148 paste0(percpeaks, " %"),
149 paste0(NumemptyTIC),
150 paste0(" "),
151 paste0(normalizationinfo),
152 paste0(smoothinginfo),
153 paste0(baselinereductioninfo),
154 paste0(peakpickinginfo),
155 paste0(centroidedinfo),
156 paste0(length(inputmz), "/", length(input_list[,1])))
157
158 property_df = data.frame(properties, values)
159
160 ######################################## PDF #############################################
161 ##########################################################################################
162 ##########################################################################################
163
164
165 pdf("heatmaps.pdf", fonts = "Times", pointsize = 12)
166 plot(0,type='n',axes=FALSE,ann=FALSE)
167 #if not $filename:
168 #set $filename = $infile.display_name
169 #end if
170 title(main=paste("Quality control of MSI data\n\n", "Filename:", "$filename"))
171
172 ############################# I) numbers ####################################
173 #############################################################################
174
175 grid.table(property_df, rows= NULL)
176
177 if (npeaks > 0)
178 {
179 if (length(inputmz) != 0)
180 {
181 for (mass in 1:length(inputmz))
182 {
183 print(image(msidata, mz=inputmz[mass], strip = strip.custom(bg="lightgrey", par.strip.text=list(col="black", cex=.9)),
184 lattice=TRUE, ylim = c(maximumy+1,minimumy-1), plusminus = $plusminusinDalton, contrast.enhance = "histogram",
185 main= paste0(mass, ") ", inputnames[mass], " (", round(inputmz[mass], digits = 2)," ± ", $plusminusinDalton, " Da)")))
186 }
187 } else {print("The input masses were outside the mass range")}
188
189 dev.off()
190
191 }else{
192 print("inputfile has no intensities > 0")
193 dev.off()
194 }
195 ]]></configfile>
196 </configfiles>
197 <inputs>
198 <param name="infile" type="data" format="imzml,rdata,analyze75" label="Inputfile as imzML, Analyze7.5 or Cardinal MSImageSet saved as RData"
199 help="Upload composite datatype imzml (ibd+imzML) or analyze75 (hdr+img+t2m) or regular upload .RData (Cardinal MSImageSet)"/>
200 <param name="filename" type="text" value="" label="Title" help="will appear in the quality report. If nothing given it will take the dataset name."/>
201 <param name="massfile" type="data" optional="true" format="tabular" label="Text file with masses and names"
202 help="first column mass (m/z), second column mass name, tab separated file"/>
203 <param name="plusminusinDalton" value="0.25" type="float" label="Mass range" help="plusminus mass window in Dalton"/>
204 </inputs>
205 <outputs>
206 <data format="pdf" name="plots" from_work_dir="heatmaps.pdf" label = "${tool.name} on $infile.display_name"/>
207 </outputs>
208 <tests>
209 <test>
210 <param name="infile" value="" ftype="imzml">
211 <composite_data value="Example_Continuous.imzML"/>
212 <composite_data value="Example_Continuous.ibd"/>
213 </param>
214 <param name="massfile" value="inputpeptides.csv" ftype="tabular"/>
215 <param name="plusminusinDalton" value="0.25"/>
216 <param name="filename" value="Testfile_imzml"/>
217 <output name="plots" file="Heatmaps_imzml.pdf" compare="sim_size" delta="20000"/>
218 </test>
219
220 <test>
221 <param name="infile" value="" ftype="analyze75">
222 <composite_data value="Analyze75.hdr"/>
223 <composite_data value="Analyze75.img"/>
224 <composite_data value="Analyze75.t2m"/>
225 </param>
226 <param name="massfile" value="inputpeptides.txt" ftype="tabular"/>
227 <param name="plusminusinDalton" value="0.5"/>
228 <param name="filename" value="Testfile_analyze75"/>
229 <output name="plots" file="Heatmaps_analyze75.pdf" compare="sim_size" delta="20000"/>
230 </test>
231 <test>
232 <param name="infile" value="preprocessing_results1.RData" ftype="rdata"/>
233 <param name="massfile" value="inputpeptides.csv" ftype="tabular"/>
234 <param name="plusminusinDalton" value="0.1"/>
235 <param name="filename" value="Testfile_rdata"/>
236 <output name="plots" file="Heatmaps_rdata.pdf" compare="sim_size" delta="20000"/>
237 </test>
238 <test>
239 <param name="infile" value="LM8_file16.rdata" ftype="rdata"/>
240 <param name="massfile" value="inputpeptides.txt" ftype="tabular"/>
241 <param name="plusminusinDalton" value="0.1"/>
242 <param name="filename" value="Testfile_rdata"/>
243 <output name="plots" file="Heatmaps_LM8_file16.pdf" compare="sim_size" delta="20000"/>
244 </test>
245 </tests>
246 <help><![CDATA[
247
248 Heatmaps for different ion masses in mass-spectrometry imaging data.
249
250 Input data: 3 types of input data can be used:
251
252 - imzml file (upload imzml and ibd file via the "composite" function) `Introduction to the imzml format <http://ms-imaging.org/wp/introduction/>`_
253 - Analyze7.5 (upload hdr, img and t2m file via the "composite" function)
254 - Cardinal "MSImageSet" data (with variable name "msidata", saved as .RData)
255
256 The output of this tool contains heatmaps for every ion mass of interest as pdf.
257
258 ]]>
259 </help>
260 <citations>
261 <citation type="doi">10.1093/bioinformatics/btv146</citation>
262 </citations>
263 </tool>