Mercurial > repos > galaxyp > cardinal_preprocessing
comparison preprocessing.xml @ 3:f172efe92629 draft
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/cardinal commit 2c4a1a862900b4efbc30824cbcb798f835b168b2
author | galaxyp |
---|---|
date | Thu, 28 Feb 2019 09:27:06 -0500 |
parents | 1b875f0b8024 |
children | 141a9288be9c |
comparison
equal
deleted
inserted
replaced
2:1b875f0b8024 | 3:f172efe92629 |
---|---|
58 pixelcount = ncol(msidata) | 58 pixelcount = ncol(msidata) |
59 minmz = round(min(mz(msidata)), digits=2) | 59 minmz = round(min(mz(msidata)), digits=2) |
60 maxmz = round(max(mz(msidata)), digits=2) | 60 maxmz = round(max(mz(msidata)), digits=2) |
61 QC_numbers= data.frame(inputdata = c(minmz, maxmz,maxfeatures, pixelcount)) | 61 QC_numbers= data.frame(inputdata = c(minmz, maxmz,maxfeatures, pixelcount)) |
62 vectorofactions = "inputdata" | 62 vectorofactions = "inputdata" |
63 plot(msidata, pixel = 1:pixelcount, main="Average spectrum of input file") | 63 ## Choose random spectra for QC plots |
64 random_spectra = sample(pixels(msidata), 4, replace=FALSE) | |
65 par(mfrow = c(2, 2), oma=c(0,0,2,0)) | |
66 for (random_sample in 1:length(random_spectra)){ | |
67 plot(msidata, pixel=random_spectra[random_sample], main=paste0("spectrum ", names(random_spectra)[random_sample]))} | |
68 title("Input spectra", outer=TRUE, line=0) | |
69 | |
64 | 70 |
65 ############################### Preprocessing steps ########################### | 71 ############################### Preprocessing steps ########################### |
66 ############################################################################### | 72 ############################################################################### |
67 | 73 |
68 #for $method in $methods: | 74 #for $method in $methods: |
82 minmz = round(min(mz(msidata)), digits=2) | 88 minmz = round(min(mz(msidata)), digits=2) |
83 maxmz = round(max(mz(msidata)), digits=2) | 89 maxmz = round(max(mz(msidata)), digits=2) |
84 normalized = c(minmz, maxmz,maxfeatures, pixelcount) | 90 normalized = c(minmz, maxmz,maxfeatures, pixelcount) |
85 QC_numbers= cbind(QC_numbers, normalized) | 91 QC_numbers= cbind(QC_numbers, normalized) |
86 vectorofactions = append(vectorofactions, "normalized") | 92 vectorofactions = append(vectorofactions, "normalized") |
87 plot(msidata, pixel = 1:pixelcount, main="Average spectrum after normalization") | 93 par(mfrow = c(2, 2), oma=c(0,0,2,0)) |
94 for (random_sample in 1:length(random_spectra)){ | |
95 plot(msidata, pixel=random_spectra[random_sample], main=paste0("spectrum ", names(random_spectra)[random_sample]))} | |
96 title("Spectra after normalization", outer=TRUE, line=0) | |
88 | 97 |
89 ############################### Baseline reduction ########################### | 98 ############################### Baseline reduction ########################### |
90 | 99 |
91 #elif str( $method.methods_conditional.preprocessing_method ) == 'Baseline_reduction': | 100 #elif str( $method.methods_conditional.preprocessing_method ) == 'Baseline_reduction': |
92 print('Baseline_reduction') | 101 print('Baseline_reduction') |
101 minmz = round(min(mz(msidata)), digits=2) | 110 minmz = round(min(mz(msidata)), digits=2) |
102 maxmz = round(max(mz(msidata)), digits=2) | 111 maxmz = round(max(mz(msidata)), digits=2) |
103 baseline = c(minmz, maxmz,maxfeatures, pixelcount) | 112 baseline = c(minmz, maxmz,maxfeatures, pixelcount) |
104 QC_numbers= cbind(QC_numbers, baseline) | 113 QC_numbers= cbind(QC_numbers, baseline) |
105 vectorofactions = append(vectorofactions, "baseline red.") | 114 vectorofactions = append(vectorofactions, "baseline red.") |
106 plot(msidata, pixel = 1:pixelcount, main="Average spectrum after baseline reduction") | 115 for (random_sample in 1:length(random_spectra)){ |
116 plot(msidata, pixel=random_spectra[random_sample], main=paste0("spectrum ", names(random_spectra)[random_sample]))} | |
117 title("Spectra after baseline reduction", outer=TRUE, line=0) | |
107 | 118 |
108 ############################### Smoothing ########################### | 119 ############################### Smoothing ########################### |
109 | 120 |
110 #elif str( $method.methods_conditional.preprocessing_method ) == 'Smoothing': | 121 #elif str( $method.methods_conditional.preprocessing_method ) == 'Smoothing': |
111 print('Smoothing') | 122 print('Smoothing') |
134 minmz = round(min(mz(msidata)), digits=2) | 145 minmz = round(min(mz(msidata)), digits=2) |
135 maxmz = round(max(mz(msidata)), digits=2) | 146 maxmz = round(max(mz(msidata)), digits=2) |
136 smoothed = c(minmz, maxmz,maxfeatures, pixelcount) | 147 smoothed = c(minmz, maxmz,maxfeatures, pixelcount) |
137 QC_numbers= cbind(QC_numbers, smoothed) | 148 QC_numbers= cbind(QC_numbers, smoothed) |
138 vectorofactions = append(vectorofactions, "smoothed") | 149 vectorofactions = append(vectorofactions, "smoothed") |
139 plot(msidata, pixel = 1:pixelcount, main="Average spectrum after smoothing") | 150 for (random_sample in 1:length(random_spectra)){ |
151 plot(msidata, pixel=random_spectra[random_sample], main=paste0("spectrum ", names(random_spectra)[random_sample]))} | |
152 title("Spectra after smoothing", outer=TRUE, line=0) | |
140 | 153 |
141 ############################### Peak picking ########################### | 154 ############################### Peak picking ########################### |
142 | 155 |
143 #elif str( $method.methods_conditional.preprocessing_method) == 'Peak_picking': | 156 #elif str( $method.methods_conditional.preprocessing_method) == 'Peak_picking': |
144 print('Peak_picking') | 157 print('Peak_picking') |
168 minmz = round(min(mz(msidata)), digits=2) | 181 minmz = round(min(mz(msidata)), digits=2) |
169 maxmz = round(max(mz(msidata)), digits=2) | 182 maxmz = round(max(mz(msidata)), digits=2) |
170 picked = c(minmz, maxmz,maxfeatures, pixelcount) | 183 picked = c(minmz, maxmz,maxfeatures, pixelcount) |
171 QC_numbers= cbind(QC_numbers, picked) | 184 QC_numbers= cbind(QC_numbers, picked) |
172 vectorofactions = append(vectorofactions, "picked") | 185 vectorofactions = append(vectorofactions, "picked") |
173 plot(msidata, pixel = 1:pixelcount, main="Average spectrum after peak picking") | 186 for (random_sample in 1:length(random_spectra)){ |
187 plot(msidata, pixel=random_spectra[random_sample], main=paste0("spectrum ", names(random_spectra)[random_sample]))} | |
188 title("Spectra after peak picking", outer=TRUE, line=0) | |
174 | 189 |
175 ############################### Peak alignment ########################### | 190 ############################### Peak alignment ########################### |
176 | 191 |
177 #elif str( $method.methods_conditional.preprocessing_method ) == 'Peak_alignment': | 192 #elif str( $method.methods_conditional.preprocessing_method ) == 'Peak_alignment': |
178 print('Peak_alignment') | 193 print('Peak_alignment') |
182 | 197 |
183 align_peak_reference = msidata | 198 align_peak_reference = msidata |
184 | 199 |
185 #elif str( $method.methods_conditional.align_ref_type.align_reference_datatype) == 'align_table': | 200 #elif str( $method.methods_conditional.align_ref_type.align_reference_datatype) == 'align_table': |
186 | 201 |
187 align_reference_table = read.delim("$method.methods_conditional.align_ref_type.mz_tabular", header = $method.methods_conditional.align_ref_type.align_mass_header, stringsAsFactors = FALSE) | 202 align_reference_table = read.delim("$method.methods_conditional.align_ref_type.mz_tabular", header = $method.methods_conditional.align_ref_type.feature_header, stringsAsFactors = FALSE) |
188 align_reference_column = align_reference_table[,$method.methods_conditional.align_ref_type.align_mass_column] | 203 align_reference_column = align_reference_table[,$method.methods_conditional.align_ref_type.feature_column] |
189 align_peak_reference = align_reference_column[align_reference_column>=min(mz(msidata)) & align_reference_column<=max(mz(msidata))] | 204 align_peak_reference = align_reference_column[align_reference_column>=min(mz(msidata)) & align_reference_column<=max(mz(msidata))] |
190 if (length(align_peak_reference) == 0) | 205 if (length(align_peak_reference) == 0) |
191 {align_peak_reference = 0} | 206 {align_peak_reference = 0} |
192 | 207 |
193 #elif str( $method.methods_conditional.align_ref_type.align_reference_datatype) == 'align_msidata_ref': | 208 #elif str( $method.methods_conditional.align_ref_type.align_reference_datatype) == 'align_msidata_ref': |
215 minmz = round(min(mz(msidata)), digits=2) | 230 minmz = round(min(mz(msidata)), digits=2) |
216 maxmz = round(max(mz(msidata)), digits=2) | 231 maxmz = round(max(mz(msidata)), digits=2) |
217 aligned = c(minmz, maxmz,maxfeatures, pixelcount) | 232 aligned = c(minmz, maxmz,maxfeatures, pixelcount) |
218 QC_numbers= cbind(QC_numbers, aligned) | 233 QC_numbers= cbind(QC_numbers, aligned) |
219 vectorofactions = append(vectorofactions, "aligned") | 234 vectorofactions = append(vectorofactions, "aligned") |
220 plot(msidata, pixel = 1:pixelcount, main="Average spectrum after alignment") | 235 for (random_sample in 1:length(random_spectra)){ |
236 plot(msidata, pixel=random_spectra[random_sample], main=paste0("spectrum ", names(random_spectra)[random_sample]))} | |
237 title("Spectra after alignment", outer=TRUE, line=0) | |
221 | 238 |
222 ############################### Peak filtering ########################### | 239 ############################### Peak filtering ########################### |
223 | 240 |
224 #elif str( $method.methods_conditional.preprocessing_method) == 'Peak_filtering': | 241 #elif str( $method.methods_conditional.preprocessing_method) == 'Peak_filtering': |
225 print('Peak_filtering') | 242 print('Peak_filtering') |
233 minmz = round(min(mz(msidata)), digits=2) | 250 minmz = round(min(mz(msidata)), digits=2) |
234 maxmz = round(max(mz(msidata)), digits=2) | 251 maxmz = round(max(mz(msidata)), digits=2) |
235 filtered = c(minmz, maxmz,maxfeatures, pixelcount) | 252 filtered = c(minmz, maxmz,maxfeatures, pixelcount) |
236 QC_numbers= cbind(QC_numbers, filtered) | 253 QC_numbers= cbind(QC_numbers, filtered) |
237 vectorofactions = append(vectorofactions, "filtered") | 254 vectorofactions = append(vectorofactions, "filtered") |
238 plot(msidata, pixel = 1:pixelcount, main="Average spectrum after filtering") | 255 for (random_sample in 1:length(random_spectra)){ |
256 plot(msidata, pixel=random_spectra[random_sample], main=paste0("spectrum ", names(random_spectra)[random_sample]))} | |
257 title("Spectra after filtering", outer=TRUE, line=0) | |
239 | 258 |
240 ############################### Data reduction ########################### | 259 ############################### Data reduction ########################### |
241 | 260 |
242 #elif str( $method.methods_conditional.preprocessing_method) == 'Data_reduction': | 261 #elif str( $method.methods_conditional.preprocessing_method) == 'Data_reduction': |
243 print('Data_reduction') | 262 print('Data_reduction') |
264 #elif str( $method.methods_conditional.methods_for_reduction.reduction_method) == 'peaks': | 283 #elif str( $method.methods_conditional.methods_for_reduction.reduction_method) == 'peaks': |
265 print('peaks reduction') | 284 print('peaks reduction') |
266 | 285 |
267 #if str( $method.methods_conditional.methods_for_reduction.ref_type.reference_datatype) == 'table': | 286 #if str( $method.methods_conditional.methods_for_reduction.ref_type.reference_datatype) == 'table': |
268 | 287 |
269 reference_table = read.delim("$method.methods_conditional.methods_for_reduction.ref_type.mz_tabular", header = $method.methods_conditional.methods_for_reduction.ref_type.mass_header, stringsAsFactors = FALSE) | 288 reference_table = read.delim("$method.methods_conditional.methods_for_reduction.ref_type.mz_tabular", header = $method.methods_conditional.methods_for_reduction.ref_type.feature_header, stringsAsFactors = FALSE) |
270 reference_column = reference_table[,$method.methods_conditional.methods_for_reduction.ref_type.mass_column] | 289 reference_column = reference_table[,$method.methods_conditional.methods_for_reduction.ref_type.feature_column] |
271 peak_reference = reference_column[reference_column>min(mz(msidata)) & reference_column<max(mz(msidata))] | 290 peak_reference = reference_column[reference_column>min(mz(msidata)) & reference_column<max(mz(msidata))] |
272 | 291 |
273 #elif str( $method.methods_conditional.methods_for_reduction.ref_type.reference_datatype) == 'msidata_ref': | 292 #elif str( $method.methods_conditional.methods_for_reduction.ref_type.reference_datatype) == 'msidata_ref': |
274 | 293 |
275 peak_reference = loadRData('$method.methods_conditional.methods_for_reduction.ref_type.peaks_msidata') | 294 peak_reference = loadRData('$method.methods_conditional.methods_for_reduction.ref_type.peaks_msidata') |
285 minmz = round(min(mz(msidata)), digits=2) | 304 minmz = round(min(mz(msidata)), digits=2) |
286 maxmz = round(max(mz(msidata)), digits=2) | 305 maxmz = round(max(mz(msidata)), digits=2) |
287 reduced = c(minmz, maxmz,maxfeatures, pixelcount) | 306 reduced = c(minmz, maxmz,maxfeatures, pixelcount) |
288 QC_numbers= cbind(QC_numbers, reduced) | 307 QC_numbers= cbind(QC_numbers, reduced) |
289 vectorofactions = append(vectorofactions, "reduced") | 308 vectorofactions = append(vectorofactions, "reduced") |
290 plot(msidata, pixel = 1:pixelcount, main="Average spectrum after data reduction") | 309 for (random_sample in 1:length(random_spectra)){ |
310 plot(msidata, pixel=random_spectra[random_sample], main=paste0("spectrum ", names(random_spectra)[random_sample]))} | |
311 title("Spectra after data reduction", outer=TRUE, line=0) | |
291 | 312 |
292 ############################### Transformation ########################### | 313 ############################### Transformation ########################### |
293 | 314 |
294 #elif str( $method.methods_conditional.preprocessing_method) == 'Transformation': | 315 #elif str( $method.methods_conditional.preprocessing_method) == 'Transformation': |
295 print('Transformation') | 316 print('Transformation') |
326 minmz = round(min(mz(msidata)), digits=2) | 347 minmz = round(min(mz(msidata)), digits=2) |
327 maxmz = round(max(mz(msidata)), digits=2) | 348 maxmz = round(max(mz(msidata)), digits=2) |
328 transformed = c(minmz, maxmz,maxfeatures, pixelcount) | 349 transformed = c(minmz, maxmz,maxfeatures, pixelcount) |
329 QC_numbers= cbind(QC_numbers, transformed) | 350 QC_numbers= cbind(QC_numbers, transformed) |
330 vectorofactions = append(vectorofactions, "transformed") | 351 vectorofactions = append(vectorofactions, "transformed") |
331 plot(msidata, pixel = 1:pixelcount, main="Average spectrum after transformation") | 352 for (random_sample in 1:length(random_spectra)){ |
353 plot(msidata, pixel=random_spectra[random_sample], main=paste0("spectrum ", names(random_spectra)[random_sample]))} | |
354 title("Spectra after transformation", outer=TRUE, line=0) | |
332 | 355 |
333 #end if | 356 #end if |
334 #end for | 357 #end for |
335 | 358 |
336 ############# Outputs: RData, imzml and QC report ############# | 359 ############# Outputs: RData, imzml and QC report ############# |
338 | 361 |
339 ## save msidata as imzML file, will only work if there is at least 1 m/z left | 362 ## save msidata as imzML file, will only work if there is at least 1 m/z left |
340 | 363 |
341 #if str($imzml_output) == "imzml_format": | 364 #if str($imzml_output) == "imzml_format": |
342 if (nrow(msidata) > 0){ | 365 if (nrow(msidata) > 0){ |
366 ## make sure that coordinates are integers | |
367 coord(msidata)\$y = as.integer(coord(msidata)\$y) | |
368 coord(msidata)\$x = as.integer(coord(msidata)\$x) | |
343 writeImzML(msidata, "out")} | 369 writeImzML(msidata, "out")} |
344 #elif str($imzml_output) == "rdata_format": | 370 #elif str($imzml_output) == "rdata_format": |
345 ## save as (.RData) | 371 ## save as (.RData) |
346 iData(msidata) = iData(msidata)[] | 372 iData(msidata) = iData(msidata)[] |
347 save(msidata, file="$outfile_rdata") | 373 save(msidata, file="$outfile_rdata") |
441 <when value="diff"> | 467 <when value="diff"> |
442 <param name="value_diffalignment" type="float" value="200" | 468 <param name="value_diffalignment" type="float" value="200" |
443 label="diff.max" help="Peaks that differ less than this value will be aligned together"/> | 469 label="diff.max" help="Peaks that differ less than this value will be aligned together"/> |
444 <param name="units_diffalignment" type="select" display="radio" optional="False" label="units"> | 470 <param name="units_diffalignment" type="select" display="radio" optional="False" label="units"> |
445 <option value="ppm" selected="True">ppm</option> | 471 <option value="ppm" selected="True">ppm</option> |
446 <option value="Da">m/z</option> | 472 <option value="mz">m/z</option> |
447 </param> | 473 </param> |
448 </when> | 474 </when> |
449 <when value="DP"> | 475 <when value="DP"> |
450 <param name="gap_DPalignment" type="float" value="0" | 476 <param name="gap_DPalignment" type="float" value="0" |
451 label="Gap" help="The gap penalty for the dynamic programming sequence alignment"/> | 477 label="Gap" help="The gap penalty for the dynamic programming sequence alignment"/> |