Mercurial > repos > galaxyp > cardinal_preprocessing
comparison preprocessing.xml @ 1:c8ab1b6f3834 draft
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/cardinal commit d2f311f7fff24e54c565127c40414de708e31b3c
| author | galaxyp |
|---|---|
| date | Thu, 25 Oct 2018 07:20:43 -0400 |
| parents | 01d12e7e48d3 |
| children | f29109d0d353 |
comparison
equal
deleted
inserted
replaced
| 0:01d12e7e48d3 | 1:c8ab1b6f3834 |
|---|---|
| 1 <tool id="cardinal_preprocessing" name="MSI preprocessing" version="@VERSION@.0"> | 1 <tool id="cardinal_preprocessing" name="MSI preprocessing" version="@VERSION@.1"> |
| 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.2.1">r-gridextra</requirement> | 9 <requirement type="package" version="2.3">r-gridextra</requirement> |
| 10 <requirement type="package" version="0.20-35">r-lattice</requirement> | 10 <requirement type="package" version="3.0">r-ggplot2</requirement> |
| 11 <requirement type="package" version="2.2.1">r-ggplot2</requirement> | 11 <requirement type="package" version="0.20_35">r-lattice</requirement> |
| 12 </expand> | 12 </expand> |
| 13 <command detect_errors="exit_code"> | 13 <command detect_errors="exit_code"> |
| 14 <![CDATA[ | 14 <![CDATA[ |
| 15 | 15 |
| 16 @INPUT_LINKING@ | 16 @INPUT_LINKING@ |
| 17 cat '${cardinal_preprocessing}' && | 17 cat '${cardinal_preprocessing}' && |
| 18 Rscript '${cardinal_preprocessing}' | 18 Rscript '${cardinal_preprocessing}' && |
| 19 | |
| 20 #if $imzml_output: | |
| 21 mkdir $outfile_imzml.files_path && | |
| 22 ls -l && | |
| 23 mv ./out.imzML "${os.path.join($outfile_imzml.files_path, 'imzml')}" | true && | |
| 24 mv ./out.ibd "${os.path.join($outfile_imzml.files_path, 'ibd')}" | true && | |
| 25 #end if | |
| 26 echo "imzML file:" > $outfile_imzml && | |
| 27 ls -l "$outfile_imzml.files_path" >> $outfile_imzml | |
| 28 | |
| 19 | 29 |
| 20 ]]> | 30 ]]> |
| 21 </command> | 31 </command> |
| 22 <configfiles> | 32 <configfiles> |
| 23 <configfile name="cardinal_preprocessing"><![CDATA[ | 33 <configfile name="cardinal_preprocessing"><![CDATA[ |
| 28 library(gridExtra) | 38 library(gridExtra) |
| 29 library(lattice) | 39 library(lattice) |
| 30 library(ggplot2) | 40 library(ggplot2) |
| 31 | 41 |
| 32 @READING_MSIDATA@ | 42 @READING_MSIDATA@ |
| 43 | |
| 44 | |
| 45 ## remove duplicated coordinates, otherwise peak picking and log2 transformation will fail | |
| 46 print(paste0(sum(duplicated(coord(msidata))), " duplicated coordinates were removed")) | |
| 47 msidata <- msidata[,!duplicated(coord(msidata))] | |
| 33 | 48 |
| 34 print(paste0("Number of NA in input file: ",sum(is.na(spectra(msidata)[])))) | 49 print(paste0("Number of NA in input file: ",sum(is.na(spectra(msidata)[])))) |
| 35 | 50 |
| 36 | 51 |
| 37 if (sum(spectra(msidata)[]>0, na.rm=TRUE)> 0){ | 52 if (sum(spectra(msidata)[]>0, na.rm=TRUE)> 0){ |
| 125 | 140 |
| 126 #elif str( $method.methods_conditional.preprocessing_method) == 'Peak_picking': | 141 #elif str( $method.methods_conditional.preprocessing_method) == 'Peak_picking': |
| 127 print('Peak_picking') | 142 print('Peak_picking') |
| 128 ## Peakpicking | 143 ## Peakpicking |
| 129 | 144 |
| 130 ## remove duplicated coordinates, otherwise peak picking will fail | |
| 131 print(paste0(sum(duplicated(coord(msidata))), " duplicated coordinates were removed")) | |
| 132 msidata <- msidata[,!duplicated(coord(msidata))] | |
| 133 | |
| 134 #if str( $method.methods_conditional.methods_for_picking.picking_method) == 'adaptive': | 145 #if str( $method.methods_conditional.methods_for_picking.picking_method) == 'adaptive': |
| 135 print('adaptive peakpicking') | 146 print('adaptive peakpicking') |
| 136 | 147 |
| 137 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) | 148 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) |
| 138 | 149 |
| 232 #if str( $method.methods_conditional.methods_for_reduction.reduction_method) == 'bin': | 243 #if str( $method.methods_conditional.methods_for_reduction.reduction_method) == 'bin': |
| 233 print('bin reduction') | 244 print('bin reduction') |
| 234 | 245 |
| 235 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) | 246 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) |
| 236 | 247 |
| 248 ## optional: replace NA with 0 | |
| 249 #if $method.methods_conditional.methods_for_reduction.replace_NA_bin: | |
| 250 print(paste0("Number of NA that were set to zero after binning:",sum(is.na(spectra(msidata)[])))) | |
| 251 spectra(msidata)[][is.na(spectra(msidata)[])] = 0 | |
| 252 #end if | |
| 253 | |
| 237 #elif str( $method.methods_conditional.methods_for_reduction.reduction_method) == 'resample': | 254 #elif str( $method.methods_conditional.methods_for_reduction.reduction_method) == 'resample': |
| 238 print('resample reduction') | 255 print('resample reduction') |
| 239 | 256 |
| 240 msidata = reduceDimension(msidata, method="resample", step=$method.methods_conditional.methods_for_reduction.resample_step) | 257 msidata = reduceDimension(msidata, method="resample", step=$method.methods_conditional.methods_for_reduction.resample_step) |
| 241 | 258 |
| 273 print('Transformation') | 290 print('Transformation') |
| 274 | 291 |
| 275 #if str( $method.methods_conditional.transf_conditional.trans_type) == 'log2': | 292 #if str( $method.methods_conditional.transf_conditional.trans_type) == 'log2': |
| 276 print('log2 transformation') | 293 print('log2 transformation') |
| 277 | 294 |
| 278 spectra(msidata)[][spectra(msidata)[] ==0] = NA | 295 ## replace 0 with NA |
| 279 print(paste0("Number of 0 which were converted into NA:",sum(is.na(spectra(msidata)[])))) | 296 spectra_df = spectra(msidata)[] |
| 280 spectra(msidata)[] = log2(spectra(msidata)[]) | 297 spectra_df[spectra_df ==0] = NA |
| 298 print(paste0("Number of 0 which were converted into NA:",sum(is.na(spectra_df)))) | |
| 299 spectra(msidata) = spectra_df | |
| 300 ## log transformation | |
| 301 spectra(msidata) = log2(spectra(msidata)) | |
| 302 ## optional: replace NA with 0 | |
| 303 #if $method.methods_conditional.transf_conditional.replace_NA_trans: | |
| 304 spectra(msidata)[][is.na(spectra(msidata)[])] = 0 | |
| 305 #end if | |
| 281 | 306 |
| 282 #elif str( $method.methods_conditional.transf_conditional.trans_type) == 'sqrt': | 307 #elif str( $method.methods_conditional.transf_conditional.trans_type) == 'sqrt': |
| 283 print('squareroot transformation') | 308 print('squareroot transformation') |
| 284 | 309 |
| 285 spectra(msidata)[] = sqrt(spectra(msidata)[]) | 310 spectra(msidata)[] = sqrt(spectra(msidata)[]) |
| 298 vectorofactions = append(vectorofactions, "transformed") | 323 vectorofactions = append(vectorofactions, "transformed") |
| 299 | 324 |
| 300 #end if | 325 #end if |
| 301 #end for | 326 #end for |
| 302 | 327 |
| 303 ############# Outputs: RData and QC report ############# | 328 ############# Outputs: RData, imzml and QC report ############# |
| 304 ################################################################################ | 329 ################################################################################ |
| 305 | 330 |
| 306 print(paste0("Number of NA in output file: ",sum(is.na(spectra(msidata)[])))) | 331 print(paste0("Number of NA in output file: ",sum(is.na(spectra(msidata)[])))) |
| 307 | 332 |
| 308 ## save as (.RData) | 333 ## save as (.RData) |
| 309 save(msidata, file="$msidata_preprocessed") | 334 save(msidata, file="$msidata_preprocessed") |
| 335 | |
| 336 ## save msidata as imzML file, will only work if there is at least 1 m/z left | |
| 337 #if $imzml_output: | |
| 338 if (nrow(msidata) > 0){ | |
| 339 print("write outputfile") | |
| 340 writeImzML(msidata, "out")} | |
| 341 #end if | |
| 310 | 342 |
| 311 ## save QC report | 343 ## save QC report |
| 312 | 344 |
| 313 pdf("Preprocessing.pdf", fonts = "Times", pointsize = 12) | 345 pdf("Preprocessing.pdf", fonts = "Times", pointsize = 12) |
| 314 plot(0,type='n',axes=FALSE,ann=FALSE) | 346 plot(0,type='n',axes=FALSE,ann=FALSE) |
| 453 <param name="bin_fun" type="select" display="radio" | 485 <param name="bin_fun" type="select" display="radio" |
| 454 label="Calculate sum or mean intensity for ions of the same bin"> | 486 label="Calculate sum or mean intensity for ions of the same bin"> |
| 455 <option value="mean" selected="True">mean</option> | 487 <option value="mean" selected="True">mean</option> |
| 456 <option value="sum">sum</option> | 488 <option value="sum">sum</option> |
| 457 </param> | 489 </param> |
| 490 <param name="replace_NA_bin" type="boolean" label="Replace NA with 0" truevalue="TRUE" falsevalue="FALSE" help="Binning can introduce NAs, should they be replaced with 0"/> | |
| 458 </when> | 491 </when> |
| 459 <when value="resample"> | 492 <when value="resample"> |
| 460 <param name="resample_step" type="float" value="1" | 493 <param name="resample_step" type="float" value="1" |
| 461 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"/> | 494 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"/> |
| 462 </when> | 495 </when> |
| 485 <conditional name="transf_conditional"> | 518 <conditional name="transf_conditional"> |
| 486 <param name="trans_type" type="select" label="Intensity transformations" help="logarithm base 2 (log2) or squareroot (sqrt)"> | 519 <param name="trans_type" type="select" label="Intensity transformations" help="logarithm base 2 (log2) or squareroot (sqrt)"> |
| 487 <option value="log2" selected="True">log2</option> | 520 <option value="log2" selected="True">log2</option> |
| 488 <option value="sqrt">sqrt</option> | 521 <option value="sqrt">sqrt</option> |
| 489 </param> | 522 </param> |
| 490 <when value="log2"/> | 523 <when value="log2"> |
| 524 <param name="replace_NA_trans" type="boolean" label="Replace NA with 0" truevalue="TRUE" falsevalue="FALSE" help="0 values are set to NA before log2 transformation, after transformation they can be set back to 0"/> | |
| 525 </when> | |
| 491 <when value="sqrt"/> | 526 <when value="sqrt"/> |
| 492 </conditional> | 527 </conditional> |
| 493 </when> | 528 </when> |
| 494 </conditional> | 529 </conditional> |
| 495 </repeat> | 530 </repeat> |
| 531 <param name="imzml_output" type="boolean" label="Output of imzML file" truevalue="TRUE" falsevalue="FALSE"/> | |
| 496 </inputs> | 532 </inputs> |
| 497 <outputs> | 533 <outputs> |
| 498 <data format="rdata" name="msidata_preprocessed" label="${tool.name} on ${on_string}"/> | 534 <data format="rdata" name="msidata_preprocessed" label="${tool.name} on ${on_string}"/> |
| 499 <data format="pdf" name="QC_overview" from_work_dir="Preprocessing.pdf" label = "${tool.name} on ${on_string}: QC"/> | 535 <data format="pdf" name="QC_overview" from_work_dir="Preprocessing.pdf" label = "${tool.name} on ${on_string}: QC"/> |
| 536 <data format="imzml" name="outfile_imzml" label="${tool.name} on ${on_string}: imzML"> | |
| 537 <filter>imzml_output</filter> | |
| 538 </data> | |
| 500 </outputs> | 539 </outputs> |
| 501 <tests> | 540 <tests> |
| 502 <test> | 541 <test> |
| 503 <expand macro="infile_imzml"/> | 542 <expand macro="infile_imzml"/> |
| 504 <repeat name="methods"> | 543 <repeat name="methods"> |
| 648 ----- | 687 ----- |
| 649 | 688 |
| 650 This tool provides multiple Cardinal functions to preprocess mass spectrometry imaging data. | 689 This tool provides multiple Cardinal functions to preprocess mass spectrometry imaging data. |
| 651 | 690 |
| 652 @MSIDATA_INPUT_DESCRIPTION@ | 691 @MSIDATA_INPUT_DESCRIPTION@ |
| 653 - Coordinates stored as decimals rather than integers will be rounded to obtain a regular pixel grid. This might lead to duplicated coordinates which will be automatically removed before peak picking. | 692 - Coordinates stored as decimals rather than integers will be rounded to obtain a regular pixel grid. This might lead to duplicated coordinates which will be automatically removed after the data is read by the tool. |
| 654 @MZ_TABULAR_INPUT_DESCRIPTION@ | 693 @MZ_TABULAR_INPUT_DESCRIPTION@ |
| 655 | 694 |
| 656 **Options** | 695 **Options** |
| 657 | 696 |
| 658 - Normalization: Normalization of intensities to total ion current (TIC) | 697 - Normalization: Normalization of intensities to total ion current (TIC) |
| 669 - Peak alignment works only after peak picking | 708 - Peak alignment works only after peak picking |
| 670 - Peak filtering works only on centroided data (peak picking and alignment or Data reduction peaks | 709 - Peak filtering works only on centroided data (peak picking and alignment or Data reduction peaks |
| 671 | 710 |
| 672 **Output** | 711 **Output** |
| 673 | 712 |
| 674 - imzML file, preprocessed | 713 - MSI data as .RData output (can be read with the Cardinal package in R) |
| 714 - optional: MSI data as imzML file | |
| 675 - pdf with key values after each processing step | 715 - pdf with key values after each processing step |
| 676 | 716 |
| 677 ]]> | 717 ]]> |
| 678 </help> | 718 </help> |
| 679 <expand macro="citations"/> | 719 <expand macro="citations"/> |
