comparison NmrPreprocessing.xml @ 7:122df1bf0a8c draft default tip

planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 3d328007dd7716848ec2eeb6c2a472f27eeb2995
author workflow4metabolomics
date Fri, 11 Jul 2025 08:33:38 +0000
parents
children
comparison
equal deleted inserted replaced
6:6e837e9352a2 7:122df1bf0a8c
1 <tool id="NMR_Preprocessing" name="NMR_Preprocessing" version="@WRAPPER_VERSION@+galaxy2">
2 <description> Preprocessing of 1D NMR spectra </description>
3
4 <macros>
5 <import>macros.xml</import>
6 </macros>
7
8 <requirements>
9 <requirement type="package" version="3.4.4">r-ggplot2</requirement>
10 <requirement type="package" version="2.3">r-gridextra</requirement>
11 <requirement type="package" version="1.6_1.1">r-matrix</requirement>
12 <requirement type="package" version="1.9_16">r-ptw</requirement>
13 <requirement type="package" version="1.4.4">r-reshape2</requirement>
14 </requirements>
15
16 <required_files>
17 <include path="NmrPreprocessing_wrapper.R" />
18 <include path="NmrPreprocessing_script.R" />
19 <include path="DrawFunctions.R" />
20 </required_files>
21
22 <command detect_errors="aggressive">
23 ## Wrapper
24 Rscript $__tool_directory__/NmrPreprocessing_wrapper.R
25
26 ## Data matrix of FID spectra
27 dataMatrixFid $dataMatrixFid
28 ## Sample metadata matrix
29 sampleMetadataFid $sampleMetadataFid
30
31 ## First order phase correction
32 ## Graphical display
33 FirstOPCGraph $GDC.FirstOPCGraph
34
35 ## Water and / or solvents suppression
36 ## Smoothing parameter
37 lambda $SS.lambda
38
39 ## Graphical display
40 SSGraph $SS.SSGraph
41
42
43 ## Apodization
44 ## Graphical display
45 ApodGraph $Apod.ApodGraph
46
47 apodizationMethod $Apod.apodizationMethod.method
48 #if $Apod.apodizationMethod.method == "exp":
49 ## Line broadening for the exponential window
50 expLB $Apod.apodizationMethod.expLB
51 #end if
52 #if $Apod.apodizationMethod.method == "cos2":
53 ## Phase
54 phase $Apod.apodizationMethod.phase
55 #end if
56 #if $Apod.apodizationMethod.method == "hanning":
57 ## Phase
58 phase $Apod.apodizationMethod.phase
59 #end if
60 #if $Apod.apodizationMethod.method == "hamming":
61 ## Phase
62 phase $Apod.apodizationMethod.phase
63 #end if
64 #if $Apod.apodizationMethod.method == "blockexp":
65 ## Proportion of signal in the window
66 rectRatio $Apod.apodizationMethod.rectRatio
67 expLB $Apod.apodizationMethod.expLB
68 #end if
69 #if $Apod.apodizationMethod.method == "blockcos2":
70 ## Proportion of signal in the window
71 rectRatio $Apod.apodizationMethod.rectRatio
72 #end if
73 #if $Apod.apodizationMethod.method == "gauss":
74 ## Line broadening for the gaussian window
75 gaussLB $Apod.apodizationMethod.gaussLB
76 #end if
77
78 ## Fourier transform
79 ## Graphical display
80 FTGraph $FT.FTGraph
81
82 ## Zero order phase correction
83 ## Graphical display
84 ZeroOPCGraph $ZOPC.ZeroOPCGraph
85
86 zeroOrderPhaseMethod $ZOPC.zeroOrderPhaseMethod
87
88 excludeZoneZeroPhase.choice ${ZOPC.excludeZoneZeroPhase.choice}
89 #if str($ZOPC.excludeZoneZeroPhase.choice) == "YES":
90 #for $i in $ZOPC.excludeZoneZeroPhase.conditions:
91 excludeZoneZeroPhase_left ${i.excludeZoneZeroPhase_left}
92 excludeZoneZeroPhase_right ${i.excludeZoneZeroPhase_right}
93 #end for
94 #end if
95
96 ## Shift referencing
97 ## Graphical display
98 SRGraph $SR.SRGraph
99
100 ## Definition of the search zone
101 shiftReferencingRange $SR.shiftReferencingRange.method
102 #if $SR.shiftReferencingRange.method == "nearvalue":
103 pctNearValue $SR.shiftReferencingRange.pctNearValue
104 #end if
105 #if $SR.shiftReferencingRange.method == "window":
106 #for $i in $SR.shiftReferencingRange.conditions:
107 shiftReferencingRangeLeft ${i.shiftReferencingRangeLeft}
108 shiftReferencingRangeRight ${i.shiftReferencingRangeRight}
109 #end for
110 #end if
111 shiftHandling $SR.shiftHandling
112 ppmvalue $SR.ppmvalue
113
114 ## Baseline correction
115 ## Graphical display
116 BCGraph $BC.BCGraph
117
118 lambdaBc $BC.lambdaBc
119 pBc $BC.pBc
120 epsilon $BC.epsilon
121
122 excludeZoneBC.choice ${BC.excludeZoneBC.choice}
123 #if str($BC.excludeZoneBC.choice) == "YES":
124 #for $i in $BC.excludeZoneBC.conditions:
125 excludeZoneBC_left ${i.excludeZoneBC_left}
126 excludeZoneBC_right ${i.excludeZoneBC_right}
127 #end for
128 #end if
129
130 ## sets negative intensities to zero
131 NegativetoZero $NZ.NegativetoZero
132
133 ## final spectra
134 ## Graphical display
135 FinalGraph $FinalGraph
136
137 ## Outputs
138 dataMatrix $dataMatrix
139 variableMetadata $variableMetadata
140 graphOut $graphOut
141 logOut $logOut
142
143 </command>
144
145 <inputs>
146 <param name="dataMatrixFid" type="data" label="Data matrix of FIDs" help="" format="tabular" />
147 <param name="sampleMetadataFid" type="data" label="Sample metadata matrix" help="" format="tabular" />
148
149 <section name="GDC" title="Group Delay Correction" expanded="true">
150 <param name="FirstOPCGraph" label="Display the FIDs after 1st order phase correction?" type="select" help="Select 'YES' to display the spectra or 'NO' to not display them ">
151 <option value="NO"> NO </option>
152 <option value="YES"> YES </option>
153 </param>
154 </section>
155
156 <section name="SS" title="Solvent Suppression" expanded="true">
157 <param name="lambda" label="Solvent Suppression: Smoothing parameter" type="float" value="1000000" help="Default value is 1e6"/>
158
159 <param name="SSGraph" label="Display the FIDs after solvent suppression?" type="select" help="Select 'YES' to display the spectra or 'NO' to not display them ">
160 <option value="NO"> NO </option>
161 <option value="YES"> YES </option>
162 </param>
163 </section>
164
165
166 <section name="Apod" title="Apodization" expanded="true">
167 <conditional name="apodizationMethod" >
168 <param name="method" label="Apodization: method" type="select" help="Default method is Decreasing Exponential signal. See details below" >
169 <option value="exp">exp</option>
170 <option value="cos2">cos2</option>
171 <option value="hanning">hanning</option>
172 <option value="hamming">haming</option>
173 <option value="blockexp">blockexp</option>
174 <option value="blockcos2">blockcos2</option>
175 <option value="gauss">gauss</option>
176 </param>
177 <when value="exp">
178 <param name="expLB" type="float" label="Line broadening" value="1" help="Default value is 1" />
179 </when>
180 <when value="cos2">
181 <param name="phase" type="float" label="Phase" value="0" help="Default value is 0" />
182 </when>
183 <when value="hanning">
184 <param name="phase" type="float" label="Phase" value="0" help="Default value is 0" />
185 </when>
186 <when value="hamming">
187 <param name="phase" type="float" label="Phase" value="0" help="Default value is 0" />
188 </when>
189 <when value="blockexp">
190 <param name="rectRatio" type="float" label="Proportion of signal in the window" value="0.5" help="Default value is 0.5" />
191 <param name="expLB" type="float" label="Line broadening" value="1" help="Default value is 1" />
192 </when>
193 <when value="blockcos2">
194 <param name="rectRatio" type="float" label="Proportion of signal in the window" value="0.5" help="Default value is 0.5" />
195 </when>
196 <when value="gauss">
197 <param name="gaussLB" type="float" label="Line broadening" value="0.3" help="Default value is 0.3" />
198 </when>
199 </conditional>
200
201 <param name="ApodGraph" label="Display the FIDs after Apodization?" type="select" help="Select 'YES' to display the spectra or 'NO' to not display them ">
202 <option value="NO"> NO </option>
203 <option value="YES"> YES </option>
204 </param>
205 </section>
206
207 <section name="FT" title="Fourier Transform" expanded="true">
208 <param name="FTGraph" label="Display the Fourier transformed spectra?" type="select" help="Select 'YES' to display the spectra or 'NO' to not display them ">
209 <option value="NO"> NO </option>
210 <option value="YES"> YES </option>
211 </param>
212 </section>
213
214 <section name="ZOPC" title="Zero Order Phase Correction" expanded="true">
215 <param name="zeroOrderPhaseMethod" type="select" label="Zero Order Phase Correction: method" help="Method used to select the angles to rotate the spectra" >
216 <option value="rms" selected="yes"> rms </option>
217 <option value="max" > max </option>
218 </param>
219 <conditional name="excludeZoneZeroPhase">
220 <param name="choice" type="select" label="Zero Order Phase Correction: exclusion area(s)" help="Choose if you want to exclude particular zone(s)" >
221 <option value="YES" selected="true" > YES </option>
222 <option value="NO" > NO </option>
223 </param>
224 <when value="YES">
225 <repeat name="conditions" title="Exclusion_zone" min="1">
226 <param name="excludeZoneZeroPhase_left" label="Excusion zone: left border" type="float" value="5.1" />
227 <param name="excludeZoneZeroPhase_right" label="Excusion zone: right border" type="float" value="4.5" />
228 </repeat>
229 </when>
230 <when value="NO">
231 </when>
232 </conditional>
233
234 <param name="ZeroOPCGraph" label="Display the spectra after the Zero Order Phase Correction?" type="select" help="Select 'YES' to display the spectra or 'NO' to not display them ">
235 <option value="NO"> NO </option>
236 <option value="YES"> YES </option>
237 </param>
238 </section>
239
240 <section name="SR" title="Shift Referencing" expanded="true">
241 <conditional name="shiftReferencingRange" >
242 <param name="method" label="Shift Referencing: definition of the search zone" type="select" help="Definition of the search zone" >
243 <option value="nearvalue">nearvalue</option>
244 <option value="all">all</option>
245 <option value="window">window</option>
246 </param>
247
248 <when value="all" />
249 <when value="nearvalue">
250 <param name="pctNearValue" type="float" label="percentage of the ppm axis around the ppm value to look for the reference compound peak" value="0.02" help="Default value is 0.02" />
251 </when>
252 <when value="window">
253 <repeat name="conditions" title="Search_zone">
254 <param name="shiftReferencingRangeLeft" label="Search zone: left border" type="float" value="1" />
255 <param name="shiftReferencingRangeRight" label="Search zone: right border" type="float" value="-1" />
256 </repeat>
257 </when>
258 </conditional>
259
260 <param name="shiftHandling" type="select" label="Shift Referencing: shiftHandling" help="How to deal with shifts between spectra on their left and right sides" >
261 <option value="zerofilling" selected="yes"> zerofilling </option>
262 <option value="cut" > cut </option>
263 <option value="circular" > circular </option>
264 </param>
265
266 <param name="ppmvalue" type="float" label="Shift Referencing: the value of the reference peak in ppm" value="0" help="Default value is 0" />
267
268 <param name="SRGraph" label="Display the spectra after Shift Referencing?" type="select" help="Select 'YES' to display the spectra or 'NO' to not display them ">
269 <option value="NO"> NO </option>
270 <option value="YES"> YES </option>
271 </param>
272 </section>
273
274
275 <section name="BC" title="Baseline Correction" expanded="true">
276 <param name="lambdaBc" type="float" label="Baseline Correction: smoothing parameter" value="100000.0" help="Smoothing parameter, generally 1e5 – 1e8. Default value is 100000" />
277 <param name="pBc" type="float" label="Baseline Correction: asymmetry parameter" value="0.05" help="Asymmetry parameter. Default value is 0.05" />
278 <param name="epsilon" type="float" label="Baseline Correction: numerical precision for convergence when estimating the baseline" value="0.00000001" help="Numerical precision for convergence when estimating the baseline. Default value is 1e-8" />
279
280 <conditional name="excludeZoneBC">
281 <param name="choice" type="select" label="Baseline Correction: exclusion area(s)" help="Choose if you want to exclude particular zone(s)" >
282 <option value="YES" > YES </option>
283 <option value="NO" selected="true" > NO </option>
284 </param>
285 <when value="YES">
286 <repeat name="conditions" title="Exclusion_zone" min="1">
287 <param name="excludeZoneBC_left" label="Excusion zone: left border" type="float" value="5.1" />
288 <param name="excludeZoneBC_right" label="Excusion zone: right border" type="float" value="4.5" />
289 </repeat>
290 </when>
291 <when value="NO">
292 </when>
293 </conditional>
294
295 <param name="BCGraph" label="Display the spectra after Baseline Correction?" type="select" help="Select 'YES' to display the spectra or 'NO' to not display them ">
296 <option value="NO"> NO </option>
297 <option value="YES"> YES </option>
298 </param>
299 </section>
300
301 <section name="NZ" title="Negative intensities to Zero" expanded="true">
302 <param name="NegativetoZero" label="Set negative intensities to zero?" type="select" help="If YES, sets negative intensities to zero">
303 <option value="NO"> NO </option>
304 <option value="YES" selected="yes"> YES </option>
305 </param>
306 </section>
307
308 <param name="FinalGraph" label="Display the final spectra?" type="select" help="Select 'YES' to display the spectra or 'NO' to not display them ">
309 <option value="YES"> YES </option>
310 <option value="NO"> NO </option>
311 </param>
312
313 </inputs>
314
315 <outputs>
316 <data format="tabular" name="dataMatrix" label="${tool.name}_dataMatrix" />
317 <data format="tabular" name="variableMetadata" label="${tool.name}_variableMetadata" />
318 <data format="txt" name="logOut" label="${tool.name}_log" />
319 <data format="pdf" name="graphOut" label="${tool.name}_graph" />
320 </outputs>
321
322
323 <tests>
324 <test>
325 <param name="dataMatrixFid" location="https://nextcloud.inrae.fr/s/aMs9eM4RwRjeign/download/NMR_ReadFids_dataMatrix.tabular"/>
326 <param name="sampleMetadataFid" value="sampleMetadata.tabular"/>
327 <section name="GDC">
328 <param name="FirstOPCGraph" value="NO"/>
329 </section>
330 <section name="SS">
331 <param name="lambda" value="1000000" />
332 <param name="SSGraph" value="NO"/>
333 </section>
334 <section name="Apod">
335 <conditional name="apodizationMethod">
336 <param name="method" value="exp" />
337 <param name="expLB" value="1" />
338 </conditional>
339 <param name="ApodGraph" value="NO"/>
340 </section>
341 <section name="FT">
342 <param name="FTGraph" value="NO"/>
343 </section>
344 <section name="ZOPC">
345 <param name="zeroOrderPhaseMethod" value="rms" />
346 <conditional name="excludeZoneZeroPhase" >
347 <param name="choice" value="YES" />
348 <param name="conditions_0|excludeZoneZeroPhase_left" value="5.1" />
349 <param name="conditions_0|excludeZoneZeroPhase_right" value="4.5" />
350 </conditional>
351 <param name="ZeroOPCGraph" value="NO"/>
352 </section>
353 <section name="SR">
354 <conditional name="shiftReferencingRange">
355 <param name="method" value="nearvalue"/>
356 <param name="pctNearValue" value="0.02"/>
357 </conditional>
358 <param name="shiftHandling" value= "zerofilling"/>
359 <param name="ppmvalue" value="0" />
360 <param name="SRGraph" value="NO"/>
361 </section>
362 <section name="BC">
363 <param name="lambdaBc" value="100000.0" />
364 <param name="pBc" value="0.05" />
365 <param name="epsilon" value="0.00000001"/>
366 <param name="BCGraph" value="NO"/>
367 </section>
368 <section name="NZ">
369 <param name="NegativetoZero" value="YES" />
370 </section>
371 <param name="FinalGraph" value="YES" />
372 <output name="dataMatrix">
373 <assert_contents>
374 <has_n_lines n="32776"/>
375 <has_size size="2377097" delta="20"/>
376 <has_text text="ADG10003u_007"/>
377 </assert_contents>
378 </output>
379 </test>
380 </tests>
381
382 <help>
383
384 @HELP_AUTHORS@
385
386
387 =====================
388 Spectra preprocessing
389 =====================
390
391 -----------
392 Description
393 -----------
394
395 These steps correspond to the following steps in the PEPS-NMR R library (https://github.com/ManonMartin/PEPSNMR):
396
397 * Group Delay suppression (First order phase correction)
398 * Removal of solvent residuals signal from the FID
399 * Apodization to increase the Signal-to-Noise ratio of the FID
400 * Fourier transformation
401 * Zero order phase correction
402 * Shift referencing to calibrate the spectra with internal compound referencing
403 * Baseline correction
404 * Setting of negatives values to 0
405
406
407 -----------------
408 Workflow position
409 -----------------
410
411 **Upstream tools**
412
413 +---------------------------+-------------------------+--------+
414 | Name | Output file | Format |
415 +===========================+=========================+========+
416 |NMR_Read | NMR_Read_dataMatrix | Tabular|
417 +---------------------------+-------------------------+--------+
418 |NMR_Read | NMR_Read_sampleMetadata | Tabular|
419 +---------------------------+-------------------------+--------+
420
421
422
423 **Downstream tools**
424
425 +---------------------------+----------------------+--------+
426 | Name | Output file | Format |
427 +===========================+======================+========+
428 |NMR_Alignement | dataMatrix | Tabular|
429 +---------------------------+----------------------+--------+
430 |NMR_Bucketing | dataMatrix | Tabular|
431 +---------------------------+----------------------+--------+
432 |Normalization | dataMatrix | Tabular|
433 +---------------------------+----------------------+--------+
434 |Univariate | variableMetadata | Tabular|
435 +---------------------------+----------------------+--------+
436 |Multivariate | sampleMetadata | Tabular|
437 +---------------------------+----------------------+--------+
438 | | variableMetadata | Tabular|
439 +---------------------------+----------------------+--------+
440
441
442 -----------
443 Input files
444 -----------
445
446 +--------------------------------+-----------------+
447 | File | Format |
448 +================================+=================+
449 |1 : dataMatrix | tabular |
450 +--------------------------------+-----------------+
451 |2 : sampleMetadata | tabular |
452 +--------------------------------+-----------------+
453
454 **dataMatrix file**
455
456 sample x variable matrix with tabular separations and "." as decimal; the table must not contain metadata apart from row and column names; the row names must be identical to the rownames of the sample metadata.
457
458
459 **sampleMetadata file**
460
461 sample x metadata matrix with tabular separations and "." as decimal for numeric metadata and NA for missing values.
462
463
464 ----------------------
465 Steps parameters
466 ----------------------
467
468 **Solvent Suppression**
469 -----------------------------------
470
471 **Smoothing parameter** lambda: The higher lambda is, the smoother the estimated solvent signal will be
472
473
474 **Apodization**
475 ----------------------
476
477 The **types of apodization** are:
478
479 * exp: The signal is multiplied by a decreasing exponential exp(-t/LineBroadening).
480
481 * cos2: The signal is multiplied by the value of a cosinus squared from 0 (where its value is 1) until pi/2 (where its value is 0).
482
483 * blockexp: The first part of the signal (described by the proportion of signal in the window) is left unchanged and the second is multiplied by exp(-t/LineBroadening) starting at value 1.
484
485 * blockcos2: The first part is left unchanged as with blockexp and the second part is multiplied by a cosinus squared where its value starts at 1 at the end of the block and ends at 0 at the end of the signal.
486
487 * gauss: The signal is multiplied by a gaussian window centered at the beginning of the FID and with sigma=1/LineBroadening.
488
489 * hanning: The signal is multiplied by a hanning window : 0.5 + 0.5 cos.
490
491 * hamming: The signal is multiplied by a hamming window : 0.54 + 0.46 cos.
492
493
494
495
496 **Zero Order Phase Correction**
497 -----------------------------------
498
499 **Zero Order Phase correction method**:
500
501 * rms: A positiveness criterion is applied on the spectrum with a quantile probability parameter to trim the values.
502
503 * max: Optimization of the maximal spectral intensity.
504
505
506 **Exclusion area(s) for the Zero Order Phase Correction**: enables to optimize the criterion with excluded spectral window(s), by default the water region is excluded.
507
508
509 **Shift Referencing**
510 ----------------------
511
512 The **searching window** can be adapted:
513
514 * nearvalue: the search concentrates around the value of the reference peak in ppm.
515
516 * all: search accross the whole ppm axis.
517
518 * window: the search is operated in the windows defined by the Search_zone bounds.
519
520
521 **shiftHandling**: spectra can be shifted differently, we can handle misalignment of the left and right of the spectrum by different ways:
522
523 * zerofilling: The extremities at which a spectrum is not defined are replaced by 0. It makes sense since in practice the spectrum is close to zero at the extremities.
524
525 * NAfilling: The extremities at which a spectrum is not defined are replaced by NA.
526
527 * circular: The spectra are shifted circularly which means that the end of a spectrum is reproduced at the beginning.
528
529 * cut: The ppm values for which some spectra are not defined are removed.
530
531
532 **value of the reference peak**: the value in ppm of the reference peak. By default the value is 0 ppm.
533
534
535
536 **Baseline Correction**
537 ----------------------------
538
539 **Smoothing parameter**: the larger it is, the smoother the estimated baseline will be.
540
541 **Asymmetry parameter**: the smaller it is, the less the estimated baseline will try to follow peaks when it is under the spectrum and the more it will try to be under the spectrum.
542
543 **numerical precision**: numerical precision for convergence when estimating the baseline.
544
545 **Exclusion area(s) for the Baseline Correction**: enables to optimize the criterion with excluded spectral window(s), by default the water region is excluded.
546
547
548
549 **Negative intensities to Zero**
550 ------------------------------------
551
552 **Set negative intensities to zero**: the set of negative intensities to zero is optional.
553
554
555 ------------
556 Output files
557 ------------
558
559 NMR_Preprocessing_dataMatrix
560 | tabular output
561 | Data matrix with n rows (descriptors) and p columns (samples) containing the preprocessed spectra.
562 |
563
564 NMR_Preprocessing_variableMetadata
565 | tabular output
566 | Data matrix with 1 row (ppm value) and p columns (descriptors).
567 |
568
569 NMR_Preprocessing_log
570 | text output
571 | Contains warnings and the input parameters
572 |
573
574 NMR_Preprocessing_graph.pdf
575 | pdf output
576 | line plots of preprocessed spectra
577 |
578
579
580 @HELP_CHANGELOG@
581
582 </help>
583
584 <expand macro="citation" />
585
586 </tool>