Mercurial > repos > galaxyp > msi_preprocessing
comparison msi_preprocessing.xml @ 4:42580292d381 draft
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msi_preprocessing commit a7be47698f53eb4f00961192327d93e8989276a7
author | galaxyp |
---|---|
date | Mon, 11 Jun 2018 17:34:07 -0400 |
parents | b9523950e79d |
children | 2fccfd11360d |
comparison
equal
deleted
inserted
replaced
3:b9523950e79d | 4:42580292d381 |
---|---|
1 <tool id="mass_spectrometry_imaging_preprocessing" name="MSI preprocessing" version="1.10.0.0"> | 1 <tool id="mass_spectrometry_imaging_preprocessing" name="MSI preprocessing" version="1.10.0.1"> |
2 <description> | 2 <description> |
3 mass spectrometry imaging preprocessing | 3 mass spectrometry imaging preprocessing |
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> |
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="0.20-35">r-lattice</requirement> | 8 <requirement type="package" version="0.20-35">r-lattice</requirement> |
9 <requirement type="package" version="3.34.9">bioconductor-limma</requirement> | |
9 </requirements> | 10 </requirements> |
10 <command detect_errors="exit_code"> | 11 <command detect_errors="exit_code"> |
11 <![CDATA[ | 12 <![CDATA[ |
12 | 13 |
13 #if $infile.ext == 'imzml' | 14 #if $infile.ext == 'imzml' |
25 | 26 |
26 ]]> | 27 ]]> |
27 </command> | 28 </command> |
28 <configfiles> | 29 <configfiles> |
29 <configfile name="cardinal_preprocessing"><![CDATA[ | 30 <configfile name="cardinal_preprocessing"><![CDATA[ |
31 | |
32 ################################# load libraries and read file ################# | |
33 | |
30 library(Cardinal) | 34 library(Cardinal) |
31 library(gridExtra) | 35 library(gridExtra) |
32 library(lattice) | 36 library(lattice) |
37 library(limma) | |
33 | 38 |
34 #if $infile.ext == 'imzml' | 39 #if $infile.ext == 'imzml' |
35 msidata = readImzML('infile') | 40 msidata = readImzML('infile') |
36 #elif $infile.ext == 'analyze75' | 41 #elif $infile.ext == 'analyze75' |
37 msidata = readAnalyze('infile') | 42 msidata = readAnalyze('infile') |
38 #else | 43 #else |
39 load('infile.RData') | 44 load('infile.RData') |
40 #end if | 45 #end if |
41 | 46 |
42 | 47 ## function to later read RData reference files in |
43 ##################################### Preparations for QC report ############### | 48 |
49 loadRData <- function(fileName){ | |
50 #loads an RData file, and returns it | |
51 load(fileName) | |
52 get(ls()[ls() != "fileName"]) | |
53 } | |
54 | |
55 ######################### preparations for optional QC report ################# | |
44 | 56 |
45 #if $outputs.outputs_select == "quality_control": | 57 #if $outputs.outputs_select == "quality_control": |
46 | 58 |
47 ### values for QC table: | 59 ### values for QC table: |
60 | |
48 maxfeatures = length(features(msidata)) | 61 maxfeatures = length(features(msidata)) |
49 medianpeaks = median(colSums(spectra(msidata)[]>0)) | 62 medianpeaks = median(colSums(spectra(msidata)[]>0)) |
50 medint = round(median(spectra(msidata)[]), digits=2) | 63 medint = round(median(spectra(msidata)[]), digits=2) |
51 TICs = round(mean(colSums(spectra(msidata)[])), digits=1) | 64 TICs = round(mean(colSums(spectra(msidata)[])), digits=1) |
52 QC_numbers= data.frame(rawdata = c(maxfeatures, medianpeaks, medint, TICs)) | 65 QC_numbers= data.frame(rawdata = c(maxfeatures, medianpeaks, medint, TICs)) |
53 vectorofactions = "rawdata" | 66 vectorofactions = "rawdata" |
54 | 67 |
55 | 68 ### Read tabular file with calibrant m/z: |
56 ### Read tabular file with calibrant masses: | 69 |
57 calibrant_list = read.delim("$outputs.calibrant_file", header = FALSE, stringsAsFactors = FALSE) | 70 calibrant_list = read.delim("$outputs.calibrant_file", header = FALSE, stringsAsFactors = FALSE) |
58 | 71 |
59 ### calculate how many input calibrant masses are valid: | 72 ### calculate how many input calibrant m/z are valid: |
60 inputcalibrants = calibrant_list[calibrant_list[,$outputs.calibrants_column]>min(mz(msidata)) & calibrant_list[,$outputs.calibrants_column]<max(mz(msidata)),$outputs.calibrants_column] | 73 |
61 number_calibrants_in = length(calibrant_list[,$outputs.calibrants_column]) | 74 inputcalibrants = calibrant_list[calibrant_list[,$outputs.calibrants_column]>min(mz(msidata)) & calibrant_list[,$outputs.calibrants_column]<max(mz(msidata)),$outputs.calibrants_column] |
62 number_calibrants_valid = length(inputcalibrants) | 75 number_calibrants_in = length(calibrant_list[,$outputs.calibrants_column]) |
63 | 76 number_calibrants_valid = length(inputcalibrants) |
64 | |
65 | |
66 | 77 |
67 ### Quality control report | 78 ### Quality control report |
68 | |
69 | 79 |
70 pdf("Preprocessing.pdf", fonts = "Times", pointsize = 12) | 80 pdf("Preprocessing.pdf", fonts = "Times", pointsize = 12) |
71 plot(0,type='n',axes=FALSE,ann=FALSE) | 81 plot(0,type='n',axes=FALSE,ann=FALSE) |
72 title(main=paste("Quality control during preprocessing \n", "Filename:", "$infile.display_name")) | 82 title(main=paste("Quality control during preprocessing \n", "Filename:", "$infile.display_name")) |
73 title(main=paste0("\n\n\n\n Number valid masses in ", "$outputs.calibrant_file.display_name",": ", number_calibrants_valid, "/", number_calibrants_in)) | 83 title(main=paste0("\n\n\n\n Number valid m/z in ", "$outputs.calibrant_file.display_name",": ", number_calibrants_valid, "/", number_calibrants_in)) |
74 | |
75 | |
76 | 84 |
77 for (calibrant in inputcalibrants) | 85 for (calibrant in inputcalibrants) |
78 { | 86 {currentimage = image(msidata , mz=calibrant, strip = strip.custom(bg="lightgrey", |
79 | |
80 currentimage = image(msidata , mz=calibrant, strip = strip.custom(bg="lightgrey", | |
81 par.strip.text=list(col="black", cex=.9)),lattice=TRUE, | 87 par.strip.text=list(col="black", cex=.9)),lattice=TRUE, |
82 scales = list(draw = FALSE), plusminus = $outputs.plusminus_dalton, main="raw") | 88 scales = list(draw = FALSE), plusminus = $outputs.plusminus_dalton, main="raw") |
83 | 89 assign(paste("rawdata",calibrant, sep="_"), currentimage)} |
84 assign(paste("rawdata",calibrant, sep="_"), currentimage) | |
85 } | |
86 | |
87 | 90 |
88 current_plot_raw = vector(length(inputcalibrants), mode='list') | 91 current_plot_raw = vector(length(inputcalibrants), mode='list') |
89 | 92 |
90 | |
91 #end if | 93 #end if |
92 | 94 |
93 ############################### Preprocessing steps ########################### | 95 ############################### Preprocessing steps ########################### |
96 ############################################################################### | |
97 | |
94 #for $method in $methods: | 98 #for $method in $methods: |
99 | |
100 ############################### Normalization ########################### | |
95 | 101 |
96 #if str( $method.methods_conditional.preprocessing_method ) == 'Normalization': | 102 #if str( $method.methods_conditional.preprocessing_method ) == 'Normalization': |
97 print('Normalization') | 103 print('Normalization') |
98 ##normalization | 104 ##normalization |
99 | 105 |
100 msidata = normalize(msidata, method="tic") | 106 msidata = normalize(msidata, method="tic") |
101 | 107 |
108 ############################### optional QC ########################### | |
109 | |
102 #if $outputs.outputs_select == "quality_control": | 110 #if $outputs.outputs_select == "quality_control": |
111 | |
103 ### values for QC table: | 112 ### values for QC table: |
104 maxfeatures = length(features(msidata)) | 113 maxfeatures = length(features(msidata)) |
105 medianpeaks = median(colSums(spectra(msidata)[]>0)) | 114 medianpeaks = median(colSums(spectra(msidata)[]>0)) |
106 medint = round(median(spectra(msidata)[]), digits=2) | 115 medint = round(median(spectra(msidata)[]), digits=2) |
107 TICs = round(mean(colSums(spectra(msidata)[])), digits=1) | 116 TICs = round(mean(colSums(spectra(msidata)[])), digits=1) |
108 normalized = c(maxfeatures, medianpeaks, medint, TICs) | 117 normalized = c(maxfeatures, medianpeaks, medint, TICs) |
109 QC_numbers= cbind(QC_numbers, normalized) | 118 QC_numbers= cbind(QC_numbers, normalized) |
119 | |
110 ### preparation for QC plots | 120 ### preparation for QC plots |
111 vectorofactions = append(vectorofactions, "normalized") | 121 vectorofactions = append(vectorofactions, "normalized") |
112 | |
113 for (calibrant in inputcalibrants) | 122 for (calibrant in inputcalibrants) |
114 { | 123 {currentimage = image(msidata , mz=calibrant, strip = strip.custom(bg="lightgrey", |
115 currentimage = image(msidata , mz=calibrant, strip = strip.custom(bg="lightgrey", | |
116 par.strip.text=list(col="black", cex=.9)),lattice=TRUE, | 124 par.strip.text=list(col="black", cex=.9)),lattice=TRUE, |
117 scales = list(draw = FALSE), plusminus = $outputs.plusminus_dalton, main="normalized") | 125 scales = list(draw = FALSE), plusminus = $outputs.plusminus_dalton, main="normalized") |
118 | 126 assign(paste("normalized",calibrant, sep="_"), currentimage)} |
119 assign(paste("normalized",calibrant, sep="_"), currentimage) | 127 |
120 } | 128 #end if |
121 | 129 |
122 | 130 ############################### Baseline reduction ########################### |
123 #end if | |
124 | 131 |
125 #elif str( $method.methods_conditional.preprocessing_method ) == 'Baseline_reduction': | 132 #elif str( $method.methods_conditional.preprocessing_method ) == 'Baseline_reduction': |
126 print('Baseline_reduction') | 133 print('Baseline_reduction') |
127 ##baseline reduction | 134 ##baseline reduction |
135 | |
128 msidata = reduceBaseline(msidata, method="median", blocks=$method.methods_conditional.blocks_baseline) | 136 msidata = reduceBaseline(msidata, method="median", blocks=$method.methods_conditional.blocks_baseline) |
129 | 137 |
138 ############################### optional QC ########################### | |
139 | |
130 #if $outputs.outputs_select == "quality_control": | 140 #if $outputs.outputs_select == "quality_control": |
141 | |
142 ### values for QC table: | |
131 maxfeatures = length(features(msidata)) | 143 maxfeatures = length(features(msidata)) |
132 medianpeaks = median(colSums(spectra(msidata)[]>0)) | 144 medianpeaks = median(colSums(spectra(msidata)[]>0)) |
133 medint = round(median(spectra(msidata)[]), digits=2) | 145 medint = round(median(spectra(msidata)[]), digits=2) |
134 TICs = round(mean(colSums(spectra(msidata)[])), digits=1) | 146 TICs = round(mean(colSums(spectra(msidata)[])), digits=1) |
135 baseline= c(maxfeatures, medianpeaks, medint, TICs) | 147 baseline= c(maxfeatures, medianpeaks, medint, TICs) |
136 QC_numbers= cbind(QC_numbers, baseline) | 148 QC_numbers= cbind(QC_numbers, baseline) |
149 | |
137 ### preparation for QC plots | 150 ### preparation for QC plots |
138 vectorofactions = append(vectorofactions, "baseline_rem") | 151 vectorofactions = append(vectorofactions, "baseline_rem") |
139 | 152 |
140 for (calibrant in inputcalibrants) | 153 for (calibrant in inputcalibrants) |
141 { | 154 {currentimage = image(msidata , mz=calibrant, strip = strip.custom(bg="lightgrey", |
142 currentimage = image(msidata , mz=calibrant, strip = strip.custom(bg="lightgrey", | |
143 par.strip.text=list(col="black", cex=.9)),lattice=TRUE, | 155 par.strip.text=list(col="black", cex=.9)),lattice=TRUE, |
144 scales = list(draw = FALSE), plusminus = $outputs.plusminus_dalton, main="baseline removed") | 156 scales = list(draw = FALSE), plusminus = $outputs.plusminus_dalton, main="baseline removed") |
145 | 157 assign(paste("baseline_rem",calibrant, sep="_"), currentimage)} |
146 assign(paste("baseline_rem",calibrant, sep="_"), currentimage) | 158 |
147 } | 159 #end if |
148 #end if | 160 |
161 ############################### Smoothing ########################### | |
149 | 162 |
150 #elif str( $method.methods_conditional.preprocessing_method ) == 'Smoothing': | 163 #elif str( $method.methods_conditional.preprocessing_method ) == 'Smoothing': |
151 print('Smoothing') | 164 print('Smoothing') |
152 ## Smoothing | 165 ## Smoothing |
153 | 166 |
154 #if str( $method.methods_conditional.methods_for_smoothing.smoothing_method) == 'gaussian': | 167 #if str( $method.methods_conditional.methods_for_smoothing.smoothing_method) == 'gaussian': |
155 print('gaussian smoothing') | 168 print('gaussian smoothing') |
169 | |
156 msidata = smoothSignal(msidata, method="$method.methods_conditional.methods_for_smoothing.smoothing_method", window=$method.methods_conditional.window_smoothing, sd = $method.methods_conditional.methods_for_smoothing.sd_gaussian) | 170 msidata = smoothSignal(msidata, method="$method.methods_conditional.methods_for_smoothing.smoothing_method", window=$method.methods_conditional.window_smoothing, sd = $method.methods_conditional.methods_for_smoothing.sd_gaussian) |
171 | |
157 #elif str( $method.methods_conditional.methods_for_smoothing.smoothing_method) == 'sgolay': | 172 #elif str( $method.methods_conditional.methods_for_smoothing.smoothing_method) == 'sgolay': |
158 print('sgolay smoothing') | 173 print('sgolay smoothing') |
174 | |
159 msidata = smoothSignal(msidata, method="$method.methods_conditional.methods_for_smoothing.smoothing_method", window=$method.methods_conditional.window_smoothing, order = $method.methods_conditional.methods_for_smoothing.order_of_filters) | 175 msidata = smoothSignal(msidata, method="$method.methods_conditional.methods_for_smoothing.smoothing_method", window=$method.methods_conditional.window_smoothing, order = $method.methods_conditional.methods_for_smoothing.order_of_filters) |
160 #elif str($method.methods_conditional.methods_for_smoothing.smoothing_method) == 'ma': | 176 #elif str($method.methods_conditional.methods_for_smoothing.smoothing_method) == 'ma': |
161 print('sgolay smoothing') | 177 print('sgolay smoothing') |
178 | |
162 msidata = smoothSignal(msidata, method="$method.methods_conditional.methods_for_smoothing.smoothing_method", window=$method.methods_conditional.window_smoothing, coef = $method.methods_conditional.methods_for_smoothing.coefficients_ma_filter) | 179 msidata = smoothSignal(msidata, method="$method.methods_conditional.methods_for_smoothing.smoothing_method", window=$method.methods_conditional.window_smoothing, coef = $method.methods_conditional.methods_for_smoothing.coefficients_ma_filter) |
163 #end if | 180 |
181 #end if | |
182 | |
183 ############################### optional QC ########################### | |
164 | 184 |
165 #if $outputs.outputs_select == "quality_control": | 185 #if $outputs.outputs_select == "quality_control": |
186 | |
187 ### values for QC table: | |
166 maxfeatures = length(features(msidata)) | 188 maxfeatures = length(features(msidata)) |
167 medianpeaks = median(colSums(spectra(msidata)[]>0)) | 189 medianpeaks = median(colSums(spectra(msidata)[]>0)) |
168 medint = round(median(spectra(msidata)[]), digits=2) | 190 medint = round(median(spectra(msidata)[]), digits=2) |
169 TICs = round(mean(colSums(spectra(msidata)[])), digits=1) | 191 TICs = round(mean(colSums(spectra(msidata)[])), digits=1) |
170 smoothed= c(maxfeatures, medianpeaks, medint, TICs) | 192 smoothed= c(maxfeatures, medianpeaks, medint, TICs) |
171 QC_numbers= cbind(QC_numbers, smoothed) | 193 QC_numbers= cbind(QC_numbers, smoothed) |
194 | |
172 ### preparation for QC plots | 195 ### preparation for QC plots |
173 vectorofactions = append(vectorofactions, "smoothed") | 196 vectorofactions = append(vectorofactions, "smoothed") |
174 | 197 |
175 for (calibrant in inputcalibrants) | 198 for (calibrant in inputcalibrants) |
176 { | 199 {currentimage = image(msidata , mz=calibrant, strip = strip.custom(bg="lightgrey", |
177 currentimage = image(msidata , mz=calibrant, strip = strip.custom(bg="lightgrey", | |
178 par.strip.text=list(col="black", cex=.9)),lattice=TRUE, | 200 par.strip.text=list(col="black", cex=.9)),lattice=TRUE, |
179 scales = list(draw = FALSE), plusminus = $outputs.plusminus_dalton, main="smoothed") | 201 scales = list(draw = FALSE), plusminus = $outputs.plusminus_dalton, main="smoothed") |
180 | 202 assign(paste("smoothed",calibrant, sep="_"), currentimage)} |
181 assign(paste("smoothed",calibrant, sep="_"), currentimage) | 203 |
182 } | 204 #end if |
183 #end if | 205 |
206 ############################### Peak picking ########################### | |
184 | 207 |
185 #elif str( $method.methods_conditional.preprocessing_method) == 'Peak_picking': | 208 #elif str( $method.methods_conditional.preprocessing_method) == 'Peak_picking': |
186 print('Peak_picking') | 209 print('Peak_picking') |
187 ## Peakpicking | 210 ## Peakpicking |
188 | 211 |
189 #if str( $method.methods_conditional.methods_for_picking.picking_method) == 'adaptive': | 212 #if str( $method.methods_conditional.methods_for_picking.picking_method) == 'adaptive': |
190 print('adaptive peakpicking') | 213 print('adaptive peakpicking') |
214 | |
191 msidata = peakPick(msidata, window = $method.methods_conditional.window_picking, blocks = $method.methods_conditional.blocks_picking, method='$method.methods_conditional.methods_for_picking.picking_method', SNR=$method.methods_conditional.SNR_picking_method, spar=$method.methods_conditional.methods_for_picking.spar_picking) | 215 msidata = peakPick(msidata, window = $method.methods_conditional.window_picking, blocks = $method.methods_conditional.blocks_picking, method='$method.methods_conditional.methods_for_picking.picking_method', SNR=$method.methods_conditional.SNR_picking_method, spar=$method.methods_conditional.methods_for_picking.spar_picking) |
192 | 216 |
193 #elif str( $method.methods_conditional.methods_for_picking.picking_method) == 'limpic': | 217 #elif str( $method.methods_conditional.methods_for_picking.picking_method) == 'limpic': |
194 print('limpic peakpicking') | 218 print('limpic peakpicking') |
219 | |
195 msidata = peakPick(msidata, window = $method.methods_conditional.window_picking, blocks = $method.methods_conditional.blocks_picking, method='$method.methods_conditional.methods_for_picking.picking_method', SNR=$method.methods_conditional.SNR_picking_method, thresh=$method.methods_conditional.methods_for_picking.tresh_picking) | 220 msidata = peakPick(msidata, window = $method.methods_conditional.window_picking, blocks = $method.methods_conditional.blocks_picking, method='$method.methods_conditional.methods_for_picking.picking_method', SNR=$method.methods_conditional.SNR_picking_method, thresh=$method.methods_conditional.methods_for_picking.tresh_picking) |
196 | 221 |
197 #elif str( $method.methods_conditional.methods_for_picking.picking_method) == 'simple': | 222 #elif str( $method.methods_conditional.methods_for_picking.picking_method) == 'simple': |
198 print('simple peakpicking') | 223 print('simple peakpicking') |
224 | |
199 msidata = peakPick(msidata, window = $method.methods_conditional.window_picking, blocks = $method.methods_conditional.blocks_picking, method='$method.methods_conditional.methods_for_picking.picking_method', SNR=$method.methods_conditional.SNR_picking_method) | 225 msidata = peakPick(msidata, window = $method.methods_conditional.window_picking, blocks = $method.methods_conditional.blocks_picking, method='$method.methods_conditional.methods_for_picking.picking_method', SNR=$method.methods_conditional.SNR_picking_method) |
200 #end if | 226 |
227 #end if | |
228 | |
229 ############################### optional QC ########################### | |
201 | 230 |
202 #if $outputs.outputs_select == "quality_control": | 231 #if $outputs.outputs_select == "quality_control": |
232 | |
233 ### values for QC table: | |
203 maxfeatures = length(features(msidata)) | 234 maxfeatures = length(features(msidata)) |
204 medianpeaks = median(colSums(spectra(msidata)[]>0)) | 235 medianpeaks = median(colSums(spectra(msidata)[]>0)) |
205 medint = round(median(spectra(msidata)[]), digits=2) | 236 medint = round(median(spectra(msidata)[]), digits=2) |
206 TICs = round(mean(colSums(spectra(msidata)[])), digits=1) | 237 TICs = round(mean(colSums(spectra(msidata)[])), digits=1) |
207 picked= c(maxfeatures, medianpeaks, medint, TICs) | 238 picked= c(maxfeatures, medianpeaks, medint, TICs) |
208 QC_numbers= cbind(QC_numbers, picked) | 239 QC_numbers= cbind(QC_numbers, picked) |
240 | |
209 ### preparation for QC plots | 241 ### preparation for QC plots |
210 vectorofactions = append(vectorofactions, "picked") | 242 vectorofactions = append(vectorofactions, "picked") |
211 | 243 |
212 for (calibrant in inputcalibrants) | 244 for (calibrant in inputcalibrants) |
213 { | 245 {currentimage = image(msidata , mz=calibrant, strip = strip.custom(bg="lightgrey", |
214 currentimage = image(msidata , mz=calibrant, strip = strip.custom(bg="lightgrey", | |
215 par.strip.text=list(col="black", cex=.9)),lattice=TRUE, | 246 par.strip.text=list(col="black", cex=.9)),lattice=TRUE, |
216 scales = list(draw = FALSE), plusminus = $outputs.plusminus_dalton, main="picked") | 247 scales = list(draw = FALSE), plusminus = $outputs.plusminus_dalton, main="picked") |
217 | 248 assign(paste("picked",calibrant, sep="_"), currentimage)} |
218 assign(paste("picked",calibrant, sep="_"), currentimage) | 249 |
219 } | 250 #end if |
220 #end if | 251 |
252 ############################### Peak alignment ########################### | |
221 | 253 |
222 #elif str( $method.methods_conditional.preprocessing_method ) == 'Peak_alignment': | 254 #elif str( $method.methods_conditional.preprocessing_method ) == 'Peak_alignment': |
223 print('Peak_alignment') | 255 print('Peak_alignment') |
224 ## Peakalignment | 256 ## Peakalignment |
225 | 257 |
226 #if str( $method.methods_conditional.align_ref_type.align_reference_datatype) == 'align_noref': | 258 #if str( $method.methods_conditional.align_ref_type.align_reference_datatype) == 'align_noref': |
259 | |
227 align_peak_reference = msidata | 260 align_peak_reference = msidata |
228 | 261 |
229 #elif str( $method.methods_conditional.align_ref_type.align_reference_datatype) == 'align_table': | 262 #elif str( $method.methods_conditional.align_ref_type.align_reference_datatype) == 'align_table': |
263 | |
230 align_reference_table = read.delim("$method.methods_conditional.align_ref_type.align_peaks_table", header = FALSE, stringsAsFactors = FALSE) | 264 align_reference_table = read.delim("$method.methods_conditional.align_ref_type.align_peaks_table", header = FALSE, stringsAsFactors = FALSE) |
231 | |
232 align_reference_column = align_reference_table[,$method.methods_conditional.align_ref_type.align_mass_column] | 265 align_reference_column = align_reference_table[,$method.methods_conditional.align_ref_type.align_mass_column] |
233 | |
234 align_peak_reference = align_reference_column[align_reference_column>=min(mz(msidata)) & align_reference_column<=max(mz(msidata))] | 266 align_peak_reference = align_reference_column[align_reference_column>=min(mz(msidata)) & align_reference_column<=max(mz(msidata))] |
235 if (length(align_peak_reference) == 0) | 267 if (length(align_peak_reference) == 0) |
236 {align_peak_reference = 0 | 268 {align_peak_reference = 0} |
237 } | 269 |
238 | |
239 | |
240 | |
241 #### if length <0: align_peak_reference = 0 | |
242 | |
243 | |
244 #elif str( $method.methods_conditional.align_ref_type.align_reference_datatype) == 'align_msidata_ref': | 270 #elif str( $method.methods_conditional.align_ref_type.align_reference_datatype) == 'align_msidata_ref': |
245 loadRData <- function(fileName){ | 271 |
246 #loads an RData file, and returns it | |
247 load(fileName) | |
248 get(ls()[ls() != "fileName"]) | |
249 } | |
250 align_peak_reference = loadRData('$method.methods_conditional.align_ref_type.align_peaks_msidata') | 272 align_peak_reference = loadRData('$method.methods_conditional.align_ref_type.align_peaks_msidata') |
273 | |
251 #end if | 274 #end if |
252 | 275 |
253 #if str( $method.methods_conditional.methods_for_alignment.alignment_method) == 'diff': | 276 #if str( $method.methods_conditional.methods_for_alignment.alignment_method) == 'diff': |
254 print('diff peakalignment') | 277 print('diff peakalignment') |
278 | |
255 msidata = peakAlign(msidata, method='$method.methods_conditional.methods_for_alignment.alignment_method',diff.max =$method.methods_conditional.methods_for_alignment.value_diffalignment, units = "$method.methods_conditional.methods_for_alignment.units_diffalignment", ref=align_peak_reference) | 279 msidata = peakAlign(msidata, method='$method.methods_conditional.methods_for_alignment.alignment_method',diff.max =$method.methods_conditional.methods_for_alignment.value_diffalignment, units = "$method.methods_conditional.methods_for_alignment.units_diffalignment", ref=align_peak_reference) |
256 | 280 |
257 #elif str( $method.methods_conditional.methods_for_alignment.alignment_method) == 'DP': | 281 #elif str( $method.methods_conditional.methods_for_alignment.alignment_method) == 'DP': |
258 print('DPpeakalignment') | 282 print('DPpeakalignment') |
283 | |
259 msidata = peakAlign(msidata, method='$method.methods_conditional.methods_for_alignment.alignment_method',gap = $method.methods_conditional.methods_for_alignment.gap_DPalignment, ref=align_peak_reference) | 284 msidata = peakAlign(msidata, method='$method.methods_conditional.methods_for_alignment.alignment_method',gap = $method.methods_conditional.methods_for_alignment.gap_DPalignment, ref=align_peak_reference) |
285 | |
260 #end if | 286 #end if |
261 | 287 |
288 ############################### optional QC ########################### | |
262 #if $outputs.outputs_select == "quality_control": | 289 #if $outputs.outputs_select == "quality_control": |
290 | |
291 ### values for QC table: | |
263 maxfeatures = length(features(msidata)) | 292 maxfeatures = length(features(msidata)) |
264 medianpeaks = median(colSums(spectra(msidata)[]>0)) | 293 medianpeaks = median(colSums(spectra(msidata)[]>0)) |
265 medint = round(median(spectra(msidata)[]), digits=2) | 294 medint = round(median(spectra(msidata)[]), digits=2) |
266 TICs = round(mean(colSums(spectra(msidata)[])), digits=1) | 295 TICs = round(mean(colSums(spectra(msidata)[])), digits=1) |
267 aligned= c(maxfeatures, medianpeaks, medint, TICs) | 296 aligned= c(maxfeatures, medianpeaks, medint, TICs) |
268 QC_numbers= cbind(QC_numbers, aligned) | 297 QC_numbers= cbind(QC_numbers, aligned) |
298 | |
269 ### preparation for QC plots | 299 ### preparation for QC plots |
270 vectorofactions = append(vectorofactions, "aligned") | 300 vectorofactions = append(vectorofactions, "aligned") |
271 | 301 |
272 for (calibrant in inputcalibrants) | 302 for (calibrant in inputcalibrants) |
273 { | 303 {currentimage = image(msidata , mz=calibrant, strip = strip.custom(bg="lightgrey", |
274 currentimage = image(msidata , mz=calibrant, strip = strip.custom(bg="lightgrey", | |
275 par.strip.text=list(col="black", cex=.9)),lattice=TRUE, | 304 par.strip.text=list(col="black", cex=.9)),lattice=TRUE, |
276 scales = list(draw = FALSE), plusminus = $outputs.plusminus_dalton, main="aligned") | 305 scales = list(draw = FALSE), plusminus = $outputs.plusminus_dalton, main="aligned") |
277 | 306 assign(paste("aligned",calibrant, sep="_"), currentimage)} |
278 assign(paste("aligned",calibrant, sep="_"), currentimage) | 307 |
279 } | 308 #end if |
280 #end if | 309 |
310 ############################### Peak filtering ########################### | |
281 | 311 |
282 #elif str( $method.methods_conditional.preprocessing_method) == 'Peak_filtering': | 312 #elif str( $method.methods_conditional.preprocessing_method) == 'Peak_filtering': |
283 print('Peak_filtering') | 313 print('Peak_filtering') |
314 | |
284 msidata = peakFilter(msidata, method='freq', freq.min = $method.methods_conditional.frequ_filtering) | 315 msidata = peakFilter(msidata, method='freq', freq.min = $method.methods_conditional.frequ_filtering) |
285 | 316 |
317 ############################### optional QC ########################### | |
318 | |
286 #if $outputs.outputs_select == "quality_control": | 319 #if $outputs.outputs_select == "quality_control": |
320 | |
321 ### values for QC table: | |
287 maxfeatures = length(features(msidata)) | 322 maxfeatures = length(features(msidata)) |
288 medianpeaks = median(colSums(spectra(msidata)[]>0)) | 323 medianpeaks = median(colSums(spectra(msidata)[]>0)) |
289 medint = round(median(spectra(msidata)[]), digits=2) | 324 medint = round(median(spectra(msidata)[]), digits=2) |
290 TICs = round(mean(colSums(spectra(msidata)[])), digits=1) | 325 TICs = round(mean(colSums(spectra(msidata)[])), digits=1) |
291 filtered= c(maxfeatures, medianpeaks, medint, TICs) | 326 filtered= c(maxfeatures, medianpeaks, medint, TICs) |
292 QC_numbers= cbind(QC_numbers, filtered) | 327 QC_numbers= cbind(QC_numbers, filtered) |
328 | |
293 ### preparation for QC plots | 329 ### preparation for QC plots |
294 vectorofactions = append(vectorofactions, "filtered") | 330 vectorofactions = append(vectorofactions, "filtered") |
295 | 331 |
296 for (calibrant in inputcalibrants) | 332 for (calibrant in inputcalibrants) |
297 { | 333 {currentimage = image(msidata , mz=calibrant, strip = strip.custom(bg="lightgrey", |
298 currentimage = image(msidata , mz=calibrant, strip = strip.custom(bg="lightgrey", | |
299 par.strip.text=list(col="black", cex=.9)),lattice=TRUE, | 334 par.strip.text=list(col="black", cex=.9)),lattice=TRUE, |
300 scales = list(draw = FALSE), plusminus = $outputs.plusminus_dalton, main="filtered") | 335 scales = list(draw = FALSE), plusminus = $outputs.plusminus_dalton, main="filtered") |
301 | 336 assign(paste("filtered",calibrant, sep="_"), currentimage)} |
302 assign(paste("filtered",calibrant, sep="_"), currentimage) | 337 |
303 } | 338 #end if |
304 #end if | 339 |
340 ############################### Data reduction ########################### | |
305 | 341 |
306 #elif str( $method.methods_conditional.preprocessing_method) == 'Data_reduction': | 342 #elif str( $method.methods_conditional.preprocessing_method) == 'Data_reduction': |
307 print('Data_reduction') | 343 print('Data_reduction') |
308 | 344 |
309 #if str( $method.methods_conditional.methods_for_reduction.reduction_method) == 'bin': | 345 #if str( $method.methods_conditional.methods_for_reduction.reduction_method) == 'bin': |
310 print('bin reduction') | 346 print('bin reduction') |
347 | |
311 msidata = reduceDimension(msidata, method="bin", width=$method.methods_conditional.methods_for_reduction.bin_width, units="$method.methods_conditional.methods_for_reduction.bin_units", fun=$method.methods_conditional.methods_for_reduction.bin_fun) | 348 msidata = reduceDimension(msidata, method="bin", width=$method.methods_conditional.methods_for_reduction.bin_width, units="$method.methods_conditional.methods_for_reduction.bin_units", fun=$method.methods_conditional.methods_for_reduction.bin_fun) |
312 | 349 |
313 #elif str( $method.methods_conditional.methods_for_reduction.reduction_method) == 'resample': | 350 #elif str( $method.methods_conditional.methods_for_reduction.reduction_method) == 'resample': |
314 print('resample reduction') | 351 print('resample reduction') |
352 | |
315 msidata = reduceDimension(msidata, method="resample", step=$method.methods_conditional.methods_for_reduction.resample_step) | 353 msidata = reduceDimension(msidata, method="resample", step=$method.methods_conditional.methods_for_reduction.resample_step) |
316 | 354 |
317 #elif str( $method.methods_conditional.methods_for_reduction.reduction_method) == 'peaks': | 355 #elif str( $method.methods_conditional.methods_for_reduction.reduction_method) == 'peaks': |
318 print('peaks reduction') | 356 print('peaks reduction') |
319 | 357 |
320 #if str( $method.methods_conditional.methods_for_reduction.ref_type.reference_datatype) == 'table': | 358 #if str( $method.methods_conditional.methods_for_reduction.ref_type.reference_datatype) == 'table': |
359 | |
321 reference_table = read.delim("$method.methods_conditional.methods_for_reduction.ref_type.peaks_table", header = FALSE, stringsAsFactors = FALSE) | 360 reference_table = read.delim("$method.methods_conditional.methods_for_reduction.ref_type.peaks_table", header = FALSE, stringsAsFactors = FALSE) |
322 reference_column = reference_table[,$method.methods_conditional.methods_for_reduction.ref_type.mass_column] | 361 reference_column = reference_table[,$method.methods_conditional.methods_for_reduction.ref_type.mass_column] |
323 peak_reference = reference_column[reference_column>min(mz(msidata)) & reference_column<max(mz(msidata))] | 362 peak_reference = reference_column[reference_column>min(mz(msidata)) & reference_column<max(mz(msidata))] |
324 | 363 |
325 #elif str( $method.methods_conditional.methods_for_reduction.ref_type.reference_datatype) == 'msidata_ref': | 364 #elif str( $method.methods_conditional.methods_for_reduction.ref_type.reference_datatype) == 'msidata_ref': |
326 loadRData <- function(fileName){ | 365 |
327 #loads an RData file, and returns it | |
328 load(fileName) | |
329 get(ls()[ls() != "fileName"]) | |
330 } | |
331 peak_reference = loadRData('$method.methods_conditional.methods_for_reduction.ref_type.peaks_msidata') | 366 peak_reference = loadRData('$method.methods_conditional.methods_for_reduction.ref_type.peaks_msidata') |
367 | |
332 #end if | 368 #end if |
369 | |
333 msidata = reduceDimension(msidata, method="peaks", ref=peak_reference, type="$method.methods_conditional.methods_for_reduction.peaks_type") | 370 msidata = reduceDimension(msidata, method="peaks", ref=peak_reference, type="$method.methods_conditional.methods_for_reduction.peaks_type") |
334 #end if | 371 |
372 #end if | |
373 | |
374 ############################### optional QC ########################### | |
335 | 375 |
336 #if $outputs.outputs_select == "quality_control": | 376 #if $outputs.outputs_select == "quality_control": |
377 | |
378 ### values for QC table: | |
337 maxfeatures = length(features(msidata)) | 379 maxfeatures = length(features(msidata)) |
338 medianpeaks = median(colSums(spectra(msidata)[]>0)) | 380 medianpeaks = median(colSums(spectra(msidata)[]>0)) |
339 medint = round(median(spectra(msidata)[]), digits=2) | 381 medint = round(median(spectra(msidata)[]), digits=2) |
340 TICs = round(mean(colSums(spectra(msidata)[])), digits=1) | 382 TICs = round(mean(colSums(spectra(msidata)[])), digits=1) |
341 reduced= c(maxfeatures, medianpeaks, medint, TICs) | 383 reduced= c(maxfeatures, medianpeaks, medint, TICs) |
342 QC_numbers= cbind(QC_numbers, reduced) | 384 QC_numbers= cbind(QC_numbers, reduced) |
385 | |
343 ### preparation for QC plots | 386 ### preparation for QC plots |
344 vectorofactions = append(vectorofactions, "reduced") | 387 vectorofactions = append(vectorofactions, "reduced") |
345 | 388 |
346 for (calibrant in inputcalibrants) | 389 for (calibrant in inputcalibrants) |
347 { | 390 {currentimage = image(msidata , mz=calibrant, strip = strip.custom(bg="lightgrey", |
348 currentimage = image(msidata , mz=calibrant, strip = strip.custom(bg="lightgrey", | |
349 par.strip.text=list(col="black", cex=.9)),lattice=TRUE, | 391 par.strip.text=list(col="black", cex=.9)),lattice=TRUE, |
350 scales = list(draw = FALSE), plusminus = $outputs.plusminus_dalton, main="reduced") | 392 scales = list(draw = FALSE), plusminus = $outputs.plusminus_dalton, main="reduced") |
351 | 393 assign(paste("reduced",calibrant, sep="_"), currentimage)} |
352 assign(paste("reduced",calibrant, sep="_"), currentimage) | 394 |
353 } | 395 #end if |
354 #end if | 396 |
355 | 397 ############################### Transformation ########################### |
356 #elif str( $method.methods_conditional.preprocessing_method) == 'Transformation': | 398 |
357 print('Transformation') | 399 ####elif str( $method.methods_conditional.preprocessing_method) == 'Transformation': |
358 | 400 ###print('Transformation') |
359 #if str( $method.methods_conditional.transf_conditional.trans_type) == 'log2': | 401 |
360 print('log2 transformation') | 402 ####if str( $method.methods_conditional.transf_conditional.trans_type) == 'log2': |
361 spectra(msidata)[spectra(msidata) ==0] = NA | 403 ####print('log2 transformation') |
362 print(paste0("Number of 0 which were converted into NA:",sum(is.na(spectra(msidata))))) | 404 |
363 spectra(msidata) = log2(spectra(msidata)) | 405 ###spectra(msidata)[spectra(msidata) ==0] = NA |
364 | 406 ###print(paste0("Number of 0 which were converted into NA:",sum(is.na(spectra(msidata))))) |
365 #elif str( $method.methods_conditional.transf_conditional.trans_type) == 'sqrt': | 407 ###spectra(msidata) = log2(spectra(msidata)) |
366 print('squareroot transformation') | 408 |
367 spectra(msidata) = sqrt(spectra(msidata)) | 409 ####elif str( $method.methods_conditional.transf_conditional.trans_type) == 'sqrt': |
368 | 410 ###print('squareroot transformation') |
369 #end if | 411 |
412 ###spectra(msidata) = sqrt(spectra(msidata)) | |
413 | |
414 ###end if | |
415 | |
416 ############################### optional QC ########################### | |
417 | |
418 #if $outputs.outputs_select == "quality_control": | |
419 | |
420 ### values for QC table: | |
421 maxfeatures = length(features(msidata)) | |
422 medianpeaks = median(colSums(spectra(msidata)[]>0), na.rm=TRUE) | |
423 medint = round(median(spectra(msidata)[], na.rm=TRUE), digits=2) | |
424 TICs = round(mean(colSums(spectra(msidata)[]), na.rm=TRUE), digits=1) | |
425 transformed= c(maxfeatures, medianpeaks, medint, TICs) | |
426 QC_numbers= cbind(QC_numbers, transformed) | |
427 | |
428 ### preparation for QC plots | |
429 vectorofactions = append(vectorofactions, "transformed") | |
430 | |
431 for (calibrant in inputcalibrants) | |
432 {currentimage = image(msidata , mz=calibrant, strip = strip.custom(bg="lightgrey", | |
433 par.strip.text=list(col="black", cex=.9)),lattice=TRUE, | |
434 scales = list(draw = FALSE), plusminus = $outputs.plusminus_dalton, main="transformed") | |
435 assign(paste("transformed",calibrant, sep="_"), currentimage)} | |
436 | |
437 #end if | |
438 | |
439 ############################### optional QC ########################### | |
440 | |
441 #if $outputs.outputs_select == "quality_control": | |
442 | |
443 ### values for QC table: | |
444 maxfeatures = length(features(msidata)) | |
445 medianpeaks = median(colSums(spectra(msidata)[]>0)) | |
446 medint = round(median(spectra(msidata)[]), digits=2) | |
447 TICs = round(mean(colSums(spectra(msidata)[])), digits=1) | |
448 sample_norm= c(maxfeatures, medianpeaks, medint, TICs) | |
449 QC_numbers= cbind(QC_numbers, sample_norm) | |
450 | |
451 ### preparation for QC plots | |
452 vectorofactions = append(vectorofactions, "sample_norm") | |
453 | |
454 for (calibrant in inputcalibrants) | |
455 {currentimage = image(msidata , mz=calibrant, strip = strip.custom(bg="lightgrey", | |
456 par.strip.text=list(col="black", cex=.9)),lattice=TRUE, | |
457 scales = list(draw = FALSE), plusminus = $outputs.plusminus_dalton, main="sample normalized") | |
458 assign(paste("sample_norm",calibrant, sep="_"), currentimage)} | |
459 | |
460 #end if | |
461 | |
370 #end if | 462 #end if |
371 #end for | 463 #end for |
372 | 464 |
373 ###################### Outputs: RData, tabular and QC report ################### | 465 ###################### Outputs: RData, tabular and QC report ################### |
374 | 466 ############################################################################### |
375 | 467 |
376 ## save as (.RData) | 468 ## save as (.RData) |
377 save(msidata, file="$msidata_preprocessed") | 469 save(msidata, file="$msidata_preprocessed") |
378 | 470 |
379 | 471 print(paste0("Number of NAs in intensity matrix: ", sum(is.na(spectra(msidata))))) |
472 | |
473 ## save output matrix | |
380 #if $output_matrix: | 474 #if $output_matrix: |
381 | 475 |
382 | 476 |
383 if (length(features(msidata))> 0) | 477 if (length(features(msidata))> 0) |
384 { | 478 { |
385 | |
386 ## save as intensity matrix | 479 ## save as intensity matrix |
387 | |
388 spectramatrix = spectra(msidata) | 480 spectramatrix = spectra(msidata) |
389 rownames(spectramatrix) = mz(msidata) | 481 rownames(spectramatrix) = mz(msidata) |
390 newmatrix = rbind(pixels(msidata), spectramatrix) | 482 newmatrix = rbind(pixels(msidata), spectramatrix) |
391 write.table(newmatrix[2:nrow(newmatrix),], file="$matrixasoutput", quote = FALSE, row.names = TRUE, col.names=NA, sep = "\t") | 483 write.table(newmatrix[2:nrow(newmatrix),], file="$matrixasoutput", quote = FALSE, row.names = TRUE, col.names=NA, sep = "\t") |
392 | 484 |
393 }else{ | 485 }else{ |
394 print("file has no features left") | 486 print("file has no features left") |
395 write.table(matrix(rownames(coord(msidata)), ncol=ncol(msidata), nrow=1), file="$matrixasoutput", quote = FALSE, row.names = FALSE, col.names=FALSE, sep = "\t") | 487 write.table(matrix(rownames(coord(msidata)), ncol=ncol(msidata), nrow=1), file="$matrixasoutput", quote = FALSE, row.names = FALSE, col.names=FALSE, sep = "\t") |
396 } | 488 } |
397 | 489 |
398 #end if | 490 #end if |
399 | 491 |
400 | 492 ## save QC report |
401 #if $outputs.outputs_select == "quality_control": | 493 #if $outputs.outputs_select == "quality_control": |
402 | 494 |
403 rownames(QC_numbers) = c("# features", "median # peaks", "median intensity", "median TIC") | 495 rownames(QC_numbers) = c("# features", "median # peaks", "median intensity", "median TIC") |
404 grid.table(t(QC_numbers)) | 496 grid.table(t(QC_numbers)) |
405 | 497 |
406 for (calibrant in inputcalibrants) | 498 for (calibrant in inputcalibrants) |
407 { | 499 {imagelist = list() |
408 imagelist = list() | |
409 | |
410 for (numberprepro in 1:length(vectorofactions)){ | 500 for (numberprepro in 1:length(vectorofactions)){ |
411 | 501 imagelist[[numberprepro]] = get(paste(vectorofactions[numberprepro],calibrant, sep="_"))} |
412 imagelist[[numberprepro]] = get(paste(vectorofactions[numberprepro],calibrant, sep="_")) | 502 do.call(grid.arrange,imagelist)} |
413 | |
414 | |
415 } | |
416 | |
417 do.call(grid.arrange,imagelist) | |
418 } | |
419 | |
420 | 503 |
421 dev.off() | 504 dev.off() |
422 | 505 |
423 #end if | 506 #end if |
424 | 507 |
437 <option value="Smoothing">Peak smoothing</option> | 520 <option value="Smoothing">Peak smoothing</option> |
438 <option value="Peak_picking">Peak picking</option> | 521 <option value="Peak_picking">Peak picking</option> |
439 <option value="Peak_alignment">Peak alignment</option> | 522 <option value="Peak_alignment">Peak alignment</option> |
440 <option value="Peak_filtering">Peak filtering</option> | 523 <option value="Peak_filtering">Peak filtering</option> |
441 <option value="Data_reduction">Data reduction</option> | 524 <option value="Data_reduction">Data reduction</option> |
442 <option value="Transformation">Transformation</option> | 525 <!--option value="Transformation">Transformation</option--> |
526 | |
443 </param> | 527 </param> |
444 <when value="Normalization"/> | 528 <when value="Normalization"/> |
445 <when value="Baseline_reduction"> | 529 <when value="Baseline_reduction"> |
446 <param name="blocks_baseline" type="integer" value="50" | 530 <param name="blocks_baseline" type="integer" value="50" |
447 label="Blocks"/> | 531 label="Blocks"/> |
504 </param> | 588 </param> |
505 <when value="diff"> | 589 <when value="diff"> |
506 <param name="value_diffalignment" type="integer" value="200" | 590 <param name="value_diffalignment" type="integer" value="200" |
507 label="diff.max" help="Peaks that differ less than this value will be aligned together"/> | 591 label="diff.max" help="Peaks that differ less than this value will be aligned together"/> |
508 <param name="units_diffalignment" type="select" display = "radio" optional = "False" | 592 <param name="units_diffalignment" type="select" display = "radio" optional = "False" |
509 label="units" help="The coefficients for the moving average filter"> | 593 label="units"> |
510 <option value="ppm" selected="True">ppm</option> | 594 <option value="ppm" selected="True">ppm</option> |
511 <option value="Da">Da</option> | 595 <option value="Da">Da</option> |
512 </param> | 596 </param> |
513 </when> | 597 </when> |
514 <when value="DP"> | 598 <when value="DP"> |
523 <option value="align_msidata_ref">msidata file as reference</option> | 607 <option value="align_msidata_ref">msidata file as reference</option> |
524 </param> | 608 </param> |
525 <when value="align_noref"/> | 609 <when value="align_noref"/> |
526 <when value="align_table"> | 610 <when value="align_table"> |
527 <param name="align_peaks_table" type="data" format="tabular" | 611 <param name="align_peaks_table" type="data" format="tabular" |
528 label="Reference mz values to use for alignment - only these will be kept" help="One column with mz values (without empty cells or letters)"/> | 612 label="Reference m/z values to use for alignment - only these will be kept" help="One column with m/z values (without empty cells or letters)"/> |
529 <param name="align_mass_column" data_ref="align_peaks_table" label="Column with reference mz" type="data_column"/> | 613 <param name="align_mass_column" data_ref="align_peaks_table" label="Column with reference m/z" type="data_column"/> |
530 </when> | 614 </when> |
531 <when value="align_msidata_ref"> | 615 <when value="align_msidata_ref"> |
532 <param name="align_peaks_msidata" type="data" format="rdata," label="Picked and aligned Cardinal MSImageSet saved as RData"/> | 616 <param name="align_peaks_msidata" type="data" format="rdata," label="Picked and aligned Cardinal MSImageSet saved as RData"/> |
533 </when> | 617 </when> |
534 </conditional> | 618 </conditional> |
544 <option value="resample">resample</option> | 628 <option value="resample">resample</option> |
545 <option value="peaks">peaks</option> | 629 <option value="peaks">peaks</option> |
546 </param> | 630 </param> |
547 <when value="bin"> | 631 <when value="bin"> |
548 <param name="bin_width" type="float" value="1" | 632 <param name="bin_width" type="float" value="1" |
549 label="The width of a bin in mz or ppm" help="Width must be greater than range of mz values divided by number of mz features"/> | 633 label="The width of a bin in m/z or ppm" help="Width must be greater than range of m/z values divided by number of m/z features"/> |
550 <param name="bin_units" type="select" display="radio" | 634 <param name="bin_units" type="select" display="radio" |
551 label="Unit for bin"> | 635 label="Unit for bin"> |
552 <option value="mz" selected="True">mz</option> | 636 <option value="mz" selected="True">mz</option> |
553 <option value="ppm">ppm</option> | 637 <option value="ppm">ppm</option> |
554 </param> | 638 </param> |
558 <option value="sum">sum</option> | 642 <option value="sum">sum</option> |
559 </param> | 643 </param> |
560 </when> | 644 </when> |
561 <when value="resample"> | 645 <when value="resample"> |
562 <param name="resample_step" type="float" value="1" | 646 <param name="resample_step" type="float" value="1" |
563 label="The step size in mz" help="Step size must be greater than range of mz values divided by number of mz features"/> | 647 label="The step size in m/z" help="Step size must be greater than range of m/z values divided by number of m/z features"/> |
564 </when> | 648 </when> |
565 <when value="peaks"> | 649 <when value="peaks"> |
566 <param name="peaks_type" type="select" display="radio" | 650 <param name="peaks_type" type="select" display="radio" |
567 label="Should the peak height or area under the curve be taken as the intensity value?"> | 651 label="Should the peak height or area under the curve be taken as the intensity value?"> |
568 <option value="height" selected="True">height</option> | 652 <option value="height" selected="True">height</option> |
573 <option value="table" selected="True">tabular file</option> | 657 <option value="table" selected="True">tabular file</option> |
574 <option value="msidata_ref">msidata file</option> | 658 <option value="msidata_ref">msidata file</option> |
575 </param> | 659 </param> |
576 <when value="table"> | 660 <when value="table"> |
577 <param name="peaks_table" type="data" format="tabular" | 661 <param name="peaks_table" type="data" format="tabular" |
578 label="Reference mz values to use to reduce the dimension" help="One column with mz values (without empty cells or letters, mz outside mz range are not used for filtering)"/> | 662 label="Reference m/z values to use to reduce the dimension" help="One column with m/z values (without empty cells or letters, m/z outside m/z range are not used for filtering)"/> |
579 <param name="mass_column" data_ref="peaks_table" label="Column with reference mz" type="data_column"/> | 663 <param name="mass_column" data_ref="peaks_table" label="Column with reference m/z" type="data_column"/> |
580 </when> | 664 </when> |
581 <when value="msidata_ref"> | 665 <when value="msidata_ref"> |
582 <param name="peaks_msidata" type="data" format="rdata," label="Picked and aligned Cardinal MSImageSet saved as RData"/> | 666 <param name="peaks_msidata" type="data" format="rdata," label="Picked and aligned Cardinal MSImageSet saved as RData"/> |
583 </when> | 667 </when> |
584 </conditional> | 668 </conditional> |
585 </when> | 669 </when> |
586 </conditional> | 670 </conditional> |
587 </when> | 671 </when> |
588 <when value="Transformation"> | 672 <!--when value="Transformation"> |
589 <conditional name="transf_conditional"> | 673 <conditional name="transf_conditional"> |
590 <param name="trans_type" type="select" label="Choose which intensity transformation you want to apply" help="logarithm base 2 (log2) or squareroot (sqrt)"> | 674 <param name="trans_type" type="select" label="Choose which intensity transformation you want to apply" help="logarithm base 2 (log2) or squareroot (sqrt)"> |
591 <option value="log2" selected="True">log2</option> | 675 <option value="log2" selected="True">log2</option> |
592 <option value="sqrt">sqrt</option> | 676 <option value="sqrt">sqrt</option> |
593 </param> | 677 </param> |
594 <when value="log2"/> | 678 <when value="log2"/> |
595 <when value="sqrt"/> | 679 <when value="sqrt"/> |
596 </conditional> | 680 </conditional> |
597 </when> | 681 </when--> |
598 </conditional> | 682 </conditional> |
599 </repeat> | 683 </repeat> |
600 <conditional name="outputs"> | 684 <conditional name="outputs"> |
601 <param name="outputs_select" type="select" label="Quality control output"> | 685 <param name="outputs_select" type="select" label="Quality control output"> |
602 <option value="quality_control" selected="True">yes</option> | 686 <option value="quality_control" selected="True">yes</option> |
603 <option value="no_quality_control">no</option> | 687 <option value="no_quality_control">no</option> |
604 </param> | 688 </param> |
605 <when value="quality_control"> | 689 <when value="quality_control"> |
606 <param name="calibrant_file" type="data" format="tabular" | 690 <param name="calibrant_file" type="data" format="tabular" |
607 label="Provide a list of masses which will be plotted in the quality control report" | 691 label="Provide a list of m/z, which will be plotted in the quality control report" |
608 help="Use internal calibrant masses"/> | 692 help="Use internal calibrant m/z"/> |
609 <param name="calibrants_column" data_ref="calibrant_file" label="Column with masses" type="data_column"/> | 693 <param name="calibrants_column" data_ref="calibrant_file" label="Column with m/z" type="data_column"/> |
610 <param name="plusminus_dalton" value="0.25" type="text" label="Mass range" help="Plusminus mass window in Dalton"/> | 694 <param name="plusminus_dalton" value="0.25" type="text" label="M/z range" help="Plusminus m/z window in Dalton"/> |
611 </when> | 695 </when> |
612 <when value="no_quality_control"/> | 696 <when value="no_quality_control"/> |
613 </conditional> | 697 </conditional> |
614 <param name="output_matrix" type="boolean" display="radio" label="Intensity matrix output"/> | 698 <param name="output_matrix" type="boolean" display="radio" label="Intensity matrix output"/> |
615 </inputs> | 699 </inputs> |
616 <outputs> | 700 <outputs> |
617 <data format="rdata" name="msidata_preprocessed" label="Preprocessed ${on_string}"/> | 701 <data format="rdata" name="msidata_preprocessed" label="$infile.display_name preprocessed"/> |
618 <data format="pdf" name="QC_plots" from_work_dir="Preprocessing.pdf" label = "QC preprocessing report on ${on_string}"> | 702 <data format="pdf" name="QC_plots" from_work_dir="Preprocessing.pdf" label = "$infile.display_name preprocessed_QC"> |
619 <filter>outputs["outputs_select"] == "quality_control"</filter> | 703 <filter>outputs["outputs_select"] == "quality_control"</filter> |
620 </data> | 704 </data> |
621 <data format="tabular" name="matrixasoutput" label="Intensity matrix ${on_string}"> | 705 <data format="tabular" name="matrixasoutput" label="$infile.display_name preprocessed_matrix"> |
622 <filter>output_matrix</filter> | 706 <filter>output_matrix</filter> |
623 </data> | 707 </data> |
624 </outputs> | 708 </outputs> |
625 <tests> | 709 <tests> |
626 <test expect_num_outputs="2"> | 710 <test expect_num_outputs="2"> |
663 <conditional name="methods_conditional"> | 747 <conditional name="methods_conditional"> |
664 <param name="preprocessing_method" value="Peak_filtering"/> | 748 <param name="preprocessing_method" value="Peak_filtering"/> |
665 <param name="frequ_filtering" value="2"/> | 749 <param name="frequ_filtering" value="2"/> |
666 </conditional> | 750 </conditional> |
667 </repeat> | 751 </repeat> |
668 <repeat name="methods"> | 752 <!--repeat name="methods"> |
669 <conditional name="methods_conditional"> | 753 <conditional name="methods_conditional"> |
670 <param name="preprocessing_method" value="Transformation"/> | 754 <param name="preprocessing_method" value="Transformation"/> |
671 <conditional name="transf_conditional"> | 755 <conditional name="transf_conditional"> |
672 <param name="trans_type" value="sqrt"/> | 756 <param name="trans_type" value="sqrt"/> |
673 </conditional> | 757 </conditional> |
674 </conditional> | 758 </conditional> |
675 </repeat> | 759 </repeat--> |
676 <param name="outputs_select" value="no_quality_control"/> | 760 <param name="outputs_select" value="no_quality_control"/> |
677 <param name="output_matrix" value="True"/> | 761 <param name="output_matrix" value="True"/> |
678 <output name="msidata_preprocessed" file="preprocessing_results1.RData" compare="sim_size"/> | 762 <output name="msidata_preprocessed" file="preprocessing_results1.RData" compare="sim_size"/> |
679 <output name="matrixasoutput" file="preprocessing_results1.txt"/> | 763 <output name="matrixasoutput" file="preprocessing_results1.txt"/> |
680 </test> | 764 </test> |
681 <test expect_num_outputs="3"> | 765 <test expect_num_outputs="3"> |
682 <param name="infile" value="example_continous.RData" ftype="rdata"/> | 766 <param name="infile" value="preprocessed.RData" ftype="rdata"/> |
683 <repeat name="methods"> | 767 <repeat name="methods"> |
684 <conditional name="methods_conditional"> | 768 <conditional name="methods_conditional"> |
685 <param name="preprocessing_method" value="Peak_picking"/> | 769 <param name="preprocessing_method" value="Peak_picking"/> |
686 <param name="blocks_picking" value="3"/> | 770 <param name="blocks_picking" value="3"/> |
687 <param name="window_picking" value="5"/> | 771 <param name="window_picking" value="5"/> |
772 <param name="SNR_picking_method" value="2"/> | |
688 <conditional name="methods_for_picking"> | 773 <conditional name="methods_for_picking"> |
689 <param name="picking_method" value="simple"/> | 774 <param name="picking_method" value="adaptive"/> |
690 </conditional> | 775 </conditional> |
691 </conditional> | 776 </conditional> |
692 </repeat> | 777 </repeat> |
693 <repeat name="methods"> | 778 <repeat name="methods"> |
694 <conditional name="methods_conditional"> | 779 <conditional name="methods_conditional"> |
697 <param name="alignment_method" value="DP"/> | 782 <param name="alignment_method" value="DP"/> |
698 </conditional> | 783 </conditional> |
699 </conditional> | 784 </conditional> |
700 </repeat> | 785 </repeat> |
701 <param name="outputs_select" value="quality_control"/> | 786 <param name="outputs_select" value="quality_control"/> |
702 <param name="calibrant_file" ftype="tabular" value="inputcalibrantfile2.tabular"/> | 787 <param name="calibrant_file" ftype="tabular" value="inputcalibrantfile1.tabular"/> |
703 <param name="calibrants_column" value="1"/> | 788 <param name="calibrants_column" value="1"/> |
704 <param name="plusminus_dalton" value="0.25"/> | 789 <param name="plusminus_dalton" value="0.25"/> |
705 <param name="output_matrix" value="True"/> | 790 <param name="output_matrix" value="True"/> |
706 <output name="msidata_preprocessed" file="preprocessing_results2.RData" compare="sim_size"/> | 791 <output name="msidata_preprocessed" file="preprocessing_results2.RData" compare="sim_size"/> |
707 <output name="matrixasoutput" file="preprocessing_results2.txt" lines_diff="2"/> | 792 <output name="matrixasoutput" file="preprocessing_results2.txt" lines_diff="2"/> |
721 <repeat name="methods"> | 806 <repeat name="methods"> |
722 <conditional name="methods_conditional"> | 807 <conditional name="methods_conditional"> |
723 <param name="preprocessing_method" value="Peak_picking"/> | 808 <param name="preprocessing_method" value="Peak_picking"/> |
724 <param name="blocks_picking" value="100"/> | 809 <param name="blocks_picking" value="100"/> |
725 <param name="window_picking" value="5"/> | 810 <param name="window_picking" value="5"/> |
726 <conditional name="methods_for_picking"> | |
727 <param name="picking_method" value="limpic"/> | 811 <param name="picking_method" value="limpic"/> |
728 </conditional> | |
729 </conditional> | 812 </conditional> |
730 </repeat> | 813 </repeat> |
731 <repeat name="methods"> | 814 <repeat name="methods"> |
732 <conditional name="methods_conditional"> | 815 <conditional name="methods_conditional"> |
733 <param name="preprocessing_method" value="Peak_alignment"/> | 816 <param name="preprocessing_method" value="Peak_alignment"/> |
777 <param name="reduction_method" value="resample"/> | 860 <param name="reduction_method" value="resample"/> |
778 <param name="step_width" value="0.1"/> | 861 <param name="step_width" value="0.1"/> |
779 </conditional> | 862 </conditional> |
780 </conditional> | 863 </conditional> |
781 </repeat> | 864 </repeat> |
782 <repeat name="methods"> | |
783 <conditional name="methods_conditional"> | |
784 <param name="preprocessing_method" value="Transformation"/> | |
785 <conditional name="transf_conditional"> | |
786 <param name="trans_type" value="log2"/> | |
787 </conditional> | |
788 </conditional> | |
789 </repeat> | |
790 <param name="outputs_select" value="quality_control"/> | 865 <param name="outputs_select" value="quality_control"/> |
791 <param name="calibrant_file" ftype="tabular" value="inputcalibrantfile1.tabular"/> | 866 <param name="calibrant_file" ftype="tabular" value="inputcalibrantfile1.tabular"/> |
792 <param name="calibrants_column" value="1"/> | 867 <param name="calibrants_column" value="1"/> |
793 <param name="plusminus_dalton" value="0.25"/> | 868 <param name="plusminus_dalton" value="0.25"/> |
794 <param name="output_matrix" value="True"/> | 869 <param name="output_matrix" value="True"/> |
800 <help> | 875 <help> |
801 <![CDATA[ | 876 <![CDATA[ |
802 | 877 |
803 Cardinal is an R package that implements statistical & computational tools for analyzing mass spectrometry imaging datasets. `More information on Cardinal <http://cardinalmsi.org//>`_ | 878 Cardinal is an R package that implements statistical & computational tools for analyzing mass spectrometry imaging datasets. `More information on Cardinal <http://cardinalmsi.org//>`_ |
804 | 879 |
805 This tool provides provides multiple Cardinal functions to preprocess mass-spectrometry imaging data. | 880 This tool provides provides multiple Cardinal functions to preprocess mass spectrometry imaging data. |
806 | 881 |
807 Input data: 3 types of input data can be used: | 882 Input data: 3 types of input data can be used: |
808 | 883 |
809 - imzml file (upload imzml and ibd file via the "composite" function) `Introduction to the imzml format <https://ms-imaging.org/wp/imzml/>`_ | 884 - imzml file (upload imzml and ibd file via the "composite" function) `Introduction to the imzml format <https://ms-imaging.org/wp/imzml/>`_ |
810 - Analyze7.5 (upload hdr, img and t2m file via the "composite" function) | 885 - Analyze7.5 (upload hdr, img and t2m file via the "composite" function) |
812 | 887 |
813 Options: | 888 Options: |
814 | 889 |
815 - Normalization: Normalization of intensities to total ion current (TIC) | 890 - Normalization: Normalization of intensities to total ion current (TIC) |
816 - Baseline reduction: Baseline reduction removes backgroundintensity generated by chemical noise (common in MALDI datasets) | 891 - Baseline reduction: Baseline reduction removes backgroundintensity generated by chemical noise (common in MALDI datasets) |
817 - Smoothening: Smoothing of the mass peaks reduces noise and improves peak detection | 892 - Smoothening: Smoothing of the peaks reduces noise and improves peak detection |
818 - Peak picking: relevant peaks are picked while noise-peaks are removed (needs peak alignment afterwards) | 893 - Peak picking: relevant peaks are picked while noise-peaks are removed (needs peak alignment afterwards) |
819 - Peak alignment: only possible after peak picking, mz inaccuracies are removed by alignment of same peaks to a common mz value | 894 - Peak alignment: only possible after peak picking, m/z inaccuracies are removed by alignment of same peaks to a common m/z value |
820 - Peak filtering: works only on centroided data (after peak picking and alignment or data reduction with peak filtering), removes peaks that occur only in a small proportion of pixels. If not sure which cutoff to chose run qualitycontrol first and decide according to the zero value plot. | 895 - Peak filtering: works only on centroided data (after peak picking and alignment or data reduction with peak filtering), removes peaks that occur only in a small proportion of pixels. If not sure which cutoff to chose run qualitycontrol first and decide according to the zero value plot. |
821 - Data reduction: binning, resampling or peak filtering to reduce data | 896 - Data reduction: binning, resampling or peak filtering to reduce data |
822 - Transformation: log2 or squareroot transformation of all intensities | 897 |
823 | 898 |
824 Output: | 899 Output: |
825 | 900 |
826 - imzML file, preprocessed | 901 - imzML file, preprocessed |
827 - optional: pdf with heatmap of masses of interest after each preprocessing step | 902 - optional: pdf with heatmap of m/z of interest after each preprocessing step |
828 - optional: intensity matrix as tabular file (intensities for masses in rows and pixel in columns) | 903 - optional: intensity matrix as tabular file (intensities for m/z in rows and pixel in columns) |
829 | 904 |
830 Tip: | 905 Tip: |
831 | 906 |
832 - Peak alignment works only after peak picking | 907 - Peak alignment works only after peak picking |
833 - Peak filtering works only on centroided data (peak picking and alignment or Data reduction peaks) | 908 - Peak filtering works only on centroided data (peak picking and alignment or Data reduction peaks) |