comparison preprocessing.xml @ 9:ca727a6dede6 draft

"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/cardinal commit 6e8b69ee3aff3c93f745a5de11cc9169130f2e5e"
author galaxyp
date Thu, 24 Sep 2020 11:43:31 +0000
parents 87bb011a4ee8
children 5abc3ab4792c
comparison
equal deleted inserted replaced
8:87bb011a4ee8 9:ca727a6dede6
1 <tool id="cardinal_preprocessing" name="MSI preprocessing" version="@VERSION@.2"> 1 <tool id="cardinal_preprocessing" name="MSI preprocessing" version="@VERSION@.0">
2 <description> 2 <description>
3 mass spectrometry imaging preprocessing 3 mass spectrometry imaging preprocessing
4 </description> 4 </description>
5 <macros> 5 <macros>
6 <import>macros.xml</import> 6 <import>macros.xml</import>
7 </macros> 7 </macros>
8 <expand macro="requirements"> 8 <expand macro="requirements">
9 <requirement type="package" version="2.3">r-gridextra</requirement> 9 <requirement type="package" version="2.3">r-gridextra</requirement>
10 <requirement type="package" version="3.2.1">r-ggplot2</requirement> 10 <requirement type="package" version="3.3.2">r-ggplot2</requirement>
11 </expand> 11 </expand>
12 <command detect_errors="exit_code"> 12 <command detect_errors="exit_code">
13 <![CDATA[ 13 <![CDATA[
14 14
15 @INPUT_LINKING@ 15 @INPUT_LINKING@
345 vectorofactions = append(vectorofactions, "peak binned") 345 vectorofactions = append(vectorofactions, "peak binned")
346 print(plot(msidata, pixel=random_spectra)) 346 print(plot(msidata, pixel=random_spectra))
347 title("Spectra after peak binning", outer=TRUE, line=0) 347 title("Spectra after peak binning", outer=TRUE, line=0)
348 348
349 349
350 ############################### Data reduction ########################### 350 ############################### Mass binning ###########################
351 351
352 #elif str( $method.methods_conditional.preprocessing_method) == 'Data_reduction': 352 #elif str( $method.methods_conditional.preprocessing_method) == 'Mass_binning':
353 print('Data_reduction') 353 print('mass binning')
354 354
355 ## these functions only work on MSImageSet 355 #if str( $method.methods_conditional.mz_range.features_filtering) == 'change_mz_range':
356 msidata = as(msidata, "MSImageSet") 356
357 357 #if str($processed_cond.processed_file) == "processed":
358 #if str( $method.methods_conditional.methods_for_reduction.reduction_method) == 'bin': 358
359 print('bin reduction') 359 msidata = mse_bin = mzBin(msidata,resolution=$method.methods_conditional.bin_width, from=$method.methods_conditional.mz_range.min_mz, to=$method.methods_conditional.mz_range.max_mz, units="$method.methods_conditional.bin_units", fun=$method.methods_conditional.bin_fun)
360 360
361 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) 361 #else
362 362 msidata = mse_bin = mzBin(msidata,resolution=$method.methods_conditional.bin_width, units="$method.methods_conditional.bin_units", fun=$method.methods_conditional.bin_fun)
363 #end if
364
365
366 #elif str( $method.methods_conditional.mz_range.features_filtering) == 'none':
367
368 msidata = mse_bin = mzBin(msidata,resolution=$method.methods_conditional.bin_width, units="$method.methods_conditional.bin_units", fun=$method.methods_conditional.bin_fun)
369
370 #end if
371
372 msidata <- process(msidata, BPPARAM=MulticoreParam(workers=number_cpu))
373
363 ## optional: replace NA with 0 374 ## optional: replace NA with 0
364 #if $method.methods_conditional.methods_for_reduction.replace_NA_bin: 375 #if $method.methods_conditional.replace_NA_bin:
365 ## count and replace NAs 376 ## count and replace NAs
366 print(paste0("Number of NA that were set to zero after binning:",sum(is.na(spectra(msidata))))) 377 print(paste0("Number of NA that were set to zero after binning:",sum(is.na(spectra(msidata)))))
367 spectra(msidata)[is.na(spectra(msidata))] = 0 378 spectra(msidata)[is.na(spectra(msidata))] = 0
368 #end if 379 #end if
369 380
370 #elif str( $method.methods_conditional.methods_for_reduction.reduction_method) == 'resample':
371 print('resample reduction')
372
373 msidata = reduceDimension(msidata, method="resample", step=$method.methods_conditional.methods_for_reduction.resample_step)
374 #end if
375
376 ## coercition into new format
377 msidata = as(msidata, "MSImagingExperiment")
378
379 ############################### QC ########################### 381 ############################### QC ###########################
380 382
381 maxfeatures =nrow(msidata) 383 maxfeatures =nrow(msidata)
382 pixelcount = ncol(msidata) 384 pixelcount = ncol(msidata)
383 minmz = round(min(mz(msidata)), digits=2) 385 minmz = round(min(mz(msidata)), digits=2)
384 maxmz = round(max(mz(msidata)), digits=2) 386 maxmz = round(max(mz(msidata)), digits=2)
385 reduced = c(minmz, maxmz,maxfeatures, pixelcount) 387 reduced = c(minmz, maxmz,maxfeatures, pixelcount)
386 QC_numbers= cbind(QC_numbers, reduced) 388 QC_numbers= cbind(QC_numbers, reduced)
387 vectorofactions = append(vectorofactions, "reduced") 389 vectorofactions = append(vectorofactions, "reduced")
388 print(plot(msidata, pixel=random_spectra)) 390 print(plot(msidata, pixel=random_spectra))
389 title("Spectra after data reduction", outer=TRUE, line=0) 391 title("Spectra after m/z binning", outer=TRUE, line=0)
390 392
391 ############################### Transformation ########################### 393 ############################### Transformation ###########################
392 394
393 #elif str( $method.methods_conditional.preprocessing_method) == 'Transformation': 395 #elif str( $method.methods_conditional.preprocessing_method) == 'Transformation':
394 print('Transformation') 396 print('Transformation')
477 <option value="mz_alignment">m/z alignment</option> 479 <option value="mz_alignment">m/z alignment</option>
478 <option value="Peak_picking">Peak picking</option> 480 <option value="Peak_picking">Peak picking</option>
479 <option value="Peak_alignment">Peak alignment</option> 481 <option value="Peak_alignment">Peak alignment</option>
480 <option value="Peak_filtering">Peak filtering</option> 482 <option value="Peak_filtering">Peak filtering</option>
481 <option value="Peak_binning">Peak binning to reference peaks</option> 483 <option value="Peak_binning">Peak binning to reference peaks</option>
482 <option value="Data_reduction">Data reduction</option> 484 <option value="Mass_binning">m/z binning</option>
483 <option value="Transformation">Transformation</option> 485 <option value="Transformation">Transformation</option>
484 </param> 486 </param>
485 <when value="Normalization"> 487 <when value="Normalization">
486 <conditional name="methods_for_normalization"> 488 <conditional name="methods_for_normalization">
487 <param name="normalization_method" type="select" label="Normalization method"> 489 <param name="normalization_method" type="select" label="Normalization method">
618 label="Should the peak height or area under the curve be taken as the intensity value?"> 620 label="Should the peak height or area under the curve be taken as the intensity value?">
619 <option value="height" selected="True">height</option> 621 <option value="height" selected="True">height</option>
620 <option value="area">area</option> 622 <option value="area">area</option>
621 </param> 623 </param>
622 </when> 624 </when>
623 <when value="Data_reduction"> 625 <when value="Mass_binning">
624 <conditional name="methods_for_reduction"> 626 <param name="bin_width" type="float" value="1" 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"/>
625 <param name="reduction_method" type="select" label="Reduction method"> 627 <param name="bin_units" type="select" display="radio"
626 <option value="bin" selected="True">bin</option> 628 label="Unit for bin">
627 <option value="resample">resample</option> 629 <option value="mz" selected="True">mz</option>
630 <option value="ppm">ppm</option>
631 </param>
632 <param name="bin_fun" type="select" display="radio"
633 label="Calculate sum or mean intensity for ions of the same bin">
634 <option value="mean" selected="True">mean</option>
635 <option value="sum">sum</option>
636 </param>
637 <param name="replace_NA_bin" type="boolean" label="Replace NA with 0" truevalue="TRUE" falsevalue="FALSE" checked="True" help="Binning can introduce NAs, should they be replaced with 0"/>
638 <conditional name="mz_range">
639 <param name="features_filtering" type="select" label="Select m/z feature filtering option">
640 <option value="none" selected="True">none</option>
641 <option value="change_mz_range">change m/z range</option>
628 </param> 642 </param>
629 <when value="bin"> 643 <when value="none"/>
630 <param name="bin_width" type="float" value="1" 644 <when value="change_mz_range">
631 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"/> 645 <param name="min_mz" type="float" value="1" label="Minimum value for m/z"/>
632 <param name="bin_units" type="select" display="radio" 646 <param name="max_mz" type="float" value="10000" label="Maximum value for m/z"/>
633 label="Unit for bin"> 647 </when>
634 <option value="mz" selected="True">mz</option>
635 <option value="ppm">ppm</option>
636 </param>
637 <param name="bin_fun" type="select" display="radio"
638 label="Calculate sum or mean intensity for ions of the same bin">
639 <option value="mean" selected="True">mean</option>
640 <option value="sum">sum</option>
641 </param>
642 <param name="replace_NA_bin" type="boolean" label="Replace NA with 0" truevalue="TRUE" falsevalue="FALSE" checked="True" help="Binning can introduce NAs, should they be replaced with 0"/>
643 </when>
644 <when value="resample">
645 <param name="resample_step" type="float" value="1"
646 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"/>
647 </when>
648 </conditional> 648 </conditional>
649 </when> 649 </when>
650 <when value="Transformation"> 650 <when value="Transformation">
651 <conditional name="transf_conditional"> 651 <conditional name="transf_conditional">
652 <param name="trans_type" type="select" label="Intensity transformations" help="logarithm base 2 (log2) or squareroot (sqrt)"> 652 <param name="trans_type" type="select" label="Intensity transformations" help="logarithm base 2 (log2) or squareroot (sqrt)">
798 <param name="preprocessing_method" value="mz_alignment"/> 798 <param name="preprocessing_method" value="mz_alignment"/>
799 </conditional> 799 </conditional>
800 </repeat> 800 </repeat>
801 <repeat name="methods"> 801 <repeat name="methods">
802 <conditional name="methods_conditional"> 802 <conditional name="methods_conditional">
803 <param name="preprocessing_method" value="Data_reduction"/> 803 <param name="preprocessing_method" value="Mass_binning"/>
804 <conditional name="methods_for_reduction">
805 <param name="reduction_method" value="bin"/>
806 <param name="bin_width" value="0.1"/> 804 <param name="bin_width" value="0.1"/>
807 </conditional> 805 <param name="bin_units" value="mz"/>
808 </conditional> 806 </conditional>
809 </repeat> 807 </repeat>
810 <output name="QC_overview" file="preprocessing_results4.pdf" compare="sim_size"/> 808 <output name="QC_overview" file="preprocessing_results4.pdf" compare="sim_size"/>
811 <output name="outfile_imzml" ftype="imzml" file="preprocessing_results4.imzml.txt" compare="sim_size"> 809 <output name="outfile_imzml" ftype="imzml" file="preprocessing_results4.imzml.txt" compare="sim_size">
812 <extra_files type="file" file="preprocessing_results4.imzml" name="imzml" lines_diff="6"/> 810 <extra_files type="file" file="preprocessing_results4.imzml" name="imzml" lines_diff="6"/>
815 </test> 813 </test>
816 <test> 814 <test>
817 <expand macro="processed_infile_imzml"/> 815 <expand macro="processed_infile_imzml"/>
818 <conditional name="processed_cond"> 816 <conditional name="processed_cond">
819 <param name="processed_file" value="processed"/> 817 <param name="processed_file" value="processed"/>
820 <param name="accuracy" value="100"/> 818 <param name="accuracy" value="200"/>
821 <param name="units" value="ppm"/> 819 <param name="units" value="ppm"/>
822 </conditional> 820 </conditional>
823 <repeat name="methods"> 821 <repeat name="methods">
824 <conditional name="methods_conditional"> 822 <conditional name="methods_conditional">
825 <param name="preprocessing_method" value="Transformation"/> 823 <param name="preprocessing_method" value="Transformation"/>