diff preprocessing.xml @ 15:accf9fb6ea01 draft

"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/cardinal commit c8d3adac445b4e08e2724e22d7201bfc38bbf40f"
author galaxyp
date Sun, 29 Aug 2021 07:32:56 +0000
parents 6b36be80febb
children 611d80c0e29d
line wrap: on
line diff
--- a/preprocessing.xml	Wed Dec 23 22:32:19 2020 +0000
+++ b/preprocessing.xml	Sun Aug 29 07:32:56 2021 +0000
@@ -1,4 +1,4 @@
-<tool id="cardinal_preprocessing" name="MSI preprocessing" version="@VERSION@.2">
+<tool id="cardinal_preprocessing" name="MSI preprocessing" version="@VERSION@.0">
     <description>
         mass spectrometry imaging preprocessing
     </description>
@@ -7,7 +7,7 @@
     </macros>
     <expand macro="requirements">
         <requirement type="package" version="2.3">r-gridextra</requirement>
-        <requirement type="package" version="3.3.2">r-ggplot2</requirement>
+        <requirement type="package" version="3.3.5">r-ggplot2</requirement>
     </expand>
     <command detect_errors="exit_code">
     <![CDATA[
@@ -204,6 +204,35 @@
             vectorofactions = append(vectorofactions, "mz aligned")
             print(plot(msidata, pixel=random_spectra, col="black"))
             title("Spectra after m/z alignment", outer=TRUE, line=0)
+            
+          
+    ############################### Mz recalibration ###########################
+
+        #elif str( $method.methods_conditional.preprocessing_method ) == 'mz_recalibration':
+            print('m/z recalibration')
+            ## M/z recalibration
+
+            reference_mz = read.delim("$method.methods_conditional.mz_tabular", header = $method.methods_conditional.feature_header, stringsAsFactors = FALSE)
+            reference_mz = reference_mz[,$method.methods_conditional.feature_column]
+
+            msidata = mzAlign(msidata, ref=reference_mz, tolerance = $method.methods_conditional.alignment_tol, units = "$method.methods_conditional.alignment_units", quantile = $method.methods_conditional.quantile, span = $method.methods_conditional.span)
+
+            msidata <- process(msidata, BPPARAM=MulticoreParam(workers=number_cpu))
+            
+            ## remove the reference peaks data to allow proper peak alignment afterwards
+            metadata(featureData(msidata))['reference peaks'] <- NULL
+
+            ############################### QC ###########################
+
+            maxfeatures =nrow(msidata)
+            pixelcount = ncol(msidata)
+            minmz = round(min(mz(msidata)), digits=2)
+            maxmz = round(max(mz(msidata)), digits=2)
+            mz_recal = c(minmz, maxmz,maxfeatures, pixelcount)
+            QC_numbers= cbind(QC_numbers, mz_recal)
+            vectorofactions = append(vectorofactions, "mz recalibrated")
+            print(plot(msidata, pixel=random_spectra, col="black"))
+            title("Spectra after m/z recalibration", outer=TRUE, line=0)      
 
 
     ############################### Peak picking ###########################
@@ -456,6 +485,7 @@
                     <option value="Baseline_reduction">Baseline Reduction</option>
                     <option value="Smoothing">Peak smoothing</option>
                     <option value="mz_alignment">m/z alignment</option>
+                    <option value="mz_recalibration">m/z recalibration</option>
                     <option value="Peak_picking">Peak picking</option>
                     <option value="Peak_alignment">Peak alignment</option>
                     <option value="Peak_filtering">Peak filtering</option>
@@ -534,6 +564,26 @@
                     <param name="span" type="float" value="0.75"
                         label="span" help="The smoothing parameter for the local polynomial regression used to determine the warping function."/>
                 </when>
+	        <when value="mz_recalibration">
+		    <param name="alignment_tol" type="text" value="NA"
+		           label="tolerance" help="The tolerance to be used when matching the peaks in the unaligned spectra to the reference spectrum. If this is NA, then automatically guess a tolerance from the data.">
+		       <sanitizer>
+		            <valid initial="string.digits">
+		                <add value="N" />
+		                <add value="A" />
+		            </valid>
+		        </sanitizer>
+		    </param>
+		    <param name="alignment_units" type="select" display="radio" optional="False" label="The units to use for the tolerance.">
+		            <option value="ppm" selected="True">ppm</option>
+		            <option value="mz">m/z</option>
+		    </param>
+		    <expand macro="reading_1_column_mz_tabular" label="Tabular file with m/z features to use for alignment. Only the m/z values from the tabular file will be kept."/>
+		    <param name="quantile" type="float" value="0.2"
+		        label="quantile" help="The top quantile of reference points (peaks detected via local maxima) to use from the reference spectrum."/>
+		    <param name="span" type="float" value="0.75"
+		        label="span" help="The smoothing parameter for the local polynomial regression used to determine the warping function."/>
+		</when>
                 <when value="Peak_picking">
                     <param name="SNR_picking_method" type="float" value="6"
                         label="Signal to noise ratio"
@@ -773,6 +823,16 @@
             </repeat>
             <repeat name="methods">
                 <conditional name="methods_conditional">
+                    <param name="preprocessing_method" value="mz_recalibration"/>                   
+                    <param name="alignment_tol" value="2"/>
+                    <param name="alignment_units" value="ppm"/>
+                    <param name="mz_tabular" value="inputcalibrantfile2.txt" ftype="tabular"/>
+                    <param name="feature_column" value="1"/>
+                    <param name="feature_header" value="TRUE"/>
+                </conditional>
+            </repeat>
+            <repeat name="methods">
+                <conditional name="methods_conditional">
                     <param name="preprocessing_method" value="Mass_binning"/>
                         <param name="bin_width" value="0.1"/>
                         <param name="bin_units" value="mz"/>