comparison preprocessing.xml @ 4:141a9288be9c draft

planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/cardinal commit ecdc3a64aa245d80dbc5487b2bf10a85a43adc6d
author galaxyp
date Fri, 22 Mar 2019 08:12:42 -0400
parents f172efe92629
children ed9ed1e6cca2
comparison
equal deleted inserted replaced
3:f172efe92629 4:141a9288be9c
1 <tool id="cardinal_preprocessing" name="MSI preprocessing" version="@VERSION@.2"> 1 <tool id="cardinal_preprocessing" name="MSI preprocessing" version="@VERSION@.3">
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>
37 library(lattice) 37 library(lattice)
38 library(ggplot2) 38 library(ggplot2)
39 39
40 @READING_MSIDATA@ 40 @READING_MSIDATA@
41 41
42 @READING_MSIDATA_INRAM@ ###change out
43
42 ## remove duplicated coordinates, otherwise peak picking and log2 transformation will fail 44 ## remove duplicated coordinates, otherwise peak picking and log2 transformation will fail
43 print(paste0(sum(duplicated(coord(msidata)[,1:2])), " duplicated coordinates were removed"))
44 msidata <- msidata[,!duplicated(coord(msidata)[,1:2])] 45 msidata <- msidata[,!duplicated(coord(msidata)[,1:2])]
45 46
46 47
47 if (ncol(msidata)>0 & nrow(msidata) >0){ 48 if (ncol(msidata)>0 & nrow(msidata) >0){
48 49
129 130
130 #elif str( $method.methods_conditional.methods_for_smoothing.smoothing_method) == 'sgolay': 131 #elif str( $method.methods_conditional.methods_for_smoothing.smoothing_method) == 'sgolay':
131 print('sgolay smoothing') 132 print('sgolay smoothing')
132 133
133 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) 134 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)
135
136 ## if selected replace negative intensities with zero
137 #if $method.methods_conditional.methods_for_smoothing.replace_negatives:
138 spectra(msidata)[spectra(msidata)<0] = 0
139 #end if
140
134 #elif str($method.methods_conditional.methods_for_smoothing.smoothing_method) == 'ma': 141 #elif str($method.methods_conditional.methods_for_smoothing.smoothing_method) == 'ma':
135 print('moving average smoothing') 142 print('moving average smoothing')
136 143
137 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) 144 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)
138 145
266 273
267 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) 274 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)
268 275
269 ## optional: replace NA with 0 276 ## optional: replace NA with 0
270 #if $method.methods_conditional.methods_for_reduction.replace_NA_bin: 277 #if $method.methods_conditional.methods_for_reduction.replace_NA_bin:
271 ## binning seems to create normal R matrix but to be sure:
272 iData(msidata) <- iData(msidata)[]
273 ## count and replace NAs 278 ## count and replace NAs
274 print(paste0("Number of NA that were set to zero after binning:",sum(is.na(spectra(msidata)[])))) 279 print(paste0("Number of NA that were set to zero after binning:",sum(is.na(spectra(msidata)))))
275 spectra(msidata)[is.na(spectra(msidata))] = 0 280 spectra(msidata)[is.na(spectra(msidata))] = 0
276 #end if 281 #end if
277 282
278 #elif str( $method.methods_conditional.methods_for_reduction.reduction_method) == 'resample': 283 #elif str( $method.methods_conditional.methods_for_reduction.reduction_method) == 'resample':
279 print('resample reduction') 284 print('resample reduction')
314 319
315 #elif str( $method.methods_conditional.preprocessing_method) == 'Transformation': 320 #elif str( $method.methods_conditional.preprocessing_method) == 'Transformation':
316 print('Transformation') 321 print('Transformation')
317 322
318 ## convert data into R matrix what brings it automatically into memory and can take some take but next steps need R matrix 323 ## convert data into R matrix what brings it automatically into memory and can take some take but next steps need R matrix
319 iData(msidata) <- iData(msidata)[] 324 ##iData(msidata) <- iData(msidata)[]
320 325
321 #if str( $method.methods_conditional.transf_conditional.trans_type) == 'log2': 326 #if str( $method.methods_conditional.transf_conditional.trans_type) == 'log2':
322 print('log2 transformation') 327 print('log2 transformation')
323 328
324 ## replace 0 with NA to prevent Inf 329 ## replace 0 with NA to prevent Inf
325 spectra_df = spectra(msidata)[] 330 spectra_df = spectra(msidata)[] ## convert into R matrix
326 spectra_df[spectra_df ==0] = NA 331 spectra_df[spectra_df ==0] = NA
327 print(paste0("Number of 0 which were converted into NA:",sum(is.na(spectra_df)))) 332 print(paste0("Number of 0 which were converted into NA:",sum(is.na(spectra_df))))
328 spectra(msidata) = spectra_df 333 spectra(msidata) = spectra_df
329 ## log transformation 334 ## log transformation
330 spectra(msidata) = log2(spectra(msidata)) 335 spectra(msidata) = log2(spectra(msidata))
331 ## optional: replace NA with 0 336 ## optional: replace NA with 0
332 #if $method.methods_conditional.transf_conditional.replace_NA_trans: 337 #if $method.methods_conditional.transf_conditional.replace_NA_trans:
333 spectra(msidata)[][is.na(spectra(msidata)[])] = 0 338 spectra(msidata)[is.na(spectra(msidata))] = 0
334 #end if 339 #end if
335 340
336 #elif str( $method.methods_conditional.transf_conditional.trans_type) == 'sqrt': 341 #elif str( $method.methods_conditional.transf_conditional.trans_type) == 'sqrt':
337 print('squareroot transformation') 342 print('squareroot transformation')
338 343
339 spectra(msidata)[] = sqrt(spectra(msidata)[]) 344 spectra(msidata) = sqrt(spectra(msidata)[])
340 345
341 #end if 346 #end if
342 347
343 ############################### QC ########################### 348 ############################### QC ###########################
344 349
415 <option value="sgolay">Savitsky-Golay</option> 420 <option value="sgolay">Savitsky-Golay</option>
416 <option value="ma">moving average</option> 421 <option value="ma">moving average</option>
417 </param> 422 </param>
418 <when value="gaussian"> 423 <when value="gaussian">
419 <param name="sd_gaussian" type="float" value="2" 424 <param name="sd_gaussian" type="float" value="2"
420 label="The standard deviation for the Gaussian kernel (window/sd)"/> 425 label="The standard deviation for the Gaussian kernel. Default = window/4"/>
421 </when> 426 </when>
422 <when value="sgolay"> 427 <when value="sgolay">
423 <param name="order_of_filters" type="integer" value="3" 428 <param name="order_of_filters" type="integer" value="3"
424 label="The order of the smoothing filter, must be smaller than window size"/> 429 label="The order of the smoothing filter, must be smaller than window size"/>
430 <param name="replace_negatives" type="boolean" label="Replace negative intensities with 0" truevalue="TRUE" falsevalue="FALSE" checked="True" help="Savitzky golay smoothing can introduce negative intensity values it is recommended to replace them with zero"/>
425 </when> 431 </when>
426 <when value="ma"> 432 <when value="ma">
427 <param name="coefficients_ma_filter" type="float" value="1" 433 <param name="coefficients_ma_filter" type="float" value="1"
428 label="The coefficients for the moving average filter"/> 434 label="The coefficients for the moving average filter"/>
429 </when> 435 </when>
514 <param name="bin_fun" type="select" display="radio" 520 <param name="bin_fun" type="select" display="radio"
515 label="Calculate sum or mean intensity for ions of the same bin"> 521 label="Calculate sum or mean intensity for ions of the same bin">
516 <option value="mean" selected="True">mean</option> 522 <option value="mean" selected="True">mean</option>
517 <option value="sum">sum</option> 523 <option value="sum">sum</option>
518 </param> 524 </param>
519 <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"/> 525 <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"/>
520 </when> 526 </when>
521 <when value="resample"> 527 <when value="resample">
522 <param name="resample_step" type="float" value="1" 528 <param name="resample_step" type="float" value="1"
523 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"/> 529 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"/>
524 </when> 530 </when>
548 <param name="trans_type" type="select" label="Intensity transformations" help="logarithm base 2 (log2) or squareroot (sqrt)"> 554 <param name="trans_type" type="select" label="Intensity transformations" help="logarithm base 2 (log2) or squareroot (sqrt)">
549 <option value="log2" selected="True">log2</option> 555 <option value="log2" selected="True">log2</option>
550 <option value="sqrt">sqrt</option> 556 <option value="sqrt">sqrt</option>
551 </param> 557 </param>
552 <when value="log2"> 558 <when value="log2">
553 <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"/> 559 <param name="replace_NA_trans" type="boolean" label="Replace NA with 0" truevalue="TRUE" falsevalue="FALSE" checked="True" help="0 values are set to NA before log2 transformation, after transformation they can be set back to 0"/>
554 </when> 560 </when>
555 <when value="sqrt"/> 561 <when value="sqrt"/>
556 </conditional> 562 </conditional>
557 </when> 563 </when>
558 </conditional> 564 </conditional>
559 </repeat> 565 </repeat>
560 <param name="imzml_output" type="select" display = "radio" optional = "False" 566 <param name="imzml_output" type="select" display = "radio" optional = "False"
561 label="Output format" help= "Choose the output format"> 567 label="Output format" help= "Choose the output format">
562 <option value="imzml_format" selected="True">imzML</option> 568 <option value="imzml_format" >imzML</option>
563 <option value="rdata_format">RData</option> 569 <option value="rdata_format" selected="True" >RData</option>
564 </param> 570 </param>
565 </inputs> 571 </inputs>
566 <outputs> 572 <outputs>
567 <data format="imzml" name="outfile_imzml" label="${tool.name} on ${on_string}: imzML"> 573 <data format="imzml" name="outfile_imzml" label="${tool.name} on ${on_string}: imzML">
568 <filter>imzml_output=='imzml_format'</filter> 574 <filter>imzml_output=='imzml_format'</filter>
761 - Peak filtering works only on centroided data (peak picking and alignment or Data reduction peaks 767 - Peak filtering works only on centroided data (peak picking and alignment or Data reduction peaks
762 768
763 **Output** 769 **Output**
764 770
765 - MSI data as imzML file or .RData (can be read with the Cardinal package in R) 771 - MSI data as imzML file or .RData (can be read with the Cardinal package in R)
766 - pdf with key values and average mass spectra after each processing step 772 - pdf with key values and four random mass spectra after each processing step
767 773
768 ]]> 774 ]]>
769 </help> 775 </help>
770 <expand macro="citations"/> 776 <expand macro="citations"/>
771 </tool> 777 </tool>