changeset 8:87bb011a4ee8 draft

"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/cardinal commit d008f6ea0f5c8435fb975a34cb99ea4d42c5ebd2"
author galaxyp
date Wed, 13 May 2020 14:21:48 -0400
parents 44a4b31fcbf3
children ca727a6dede6
files macros.xml preprocessing.xml test-data/QC_analyze75.pdf test-data/QC_empty_spectra.pdf test-data/QC_imzml.pdf test-data/QC_rdata.pdf test-data/preprocessing_results1.ibd test-data/preprocessing_results1.imzml test-data/preprocessing_results1.imzml.txt test-data/preprocessing_results1.pdf test-data/preprocessing_results2.ibd test-data/preprocessing_results2.imzml test-data/preprocessing_results2.imzml.txt test-data/preprocessing_results2.pdf test-data/preprocessing_results3.ibd test-data/preprocessing_results3.imzml test-data/preprocessing_results3.imzml.txt test-data/preprocessing_results3.pdf test-data/preprocessing_results4.ibd test-data/preprocessing_results4.imzml test-data/preprocessing_results4.imzml.txt test-data/preprocessing_results4.pdf test-data/preprocessing_results5.ibd test-data/preprocessing_results5.imzml test-data/preprocessing_results5.imzml.txt test-data/preprocessing_results5.pdf
diffstat 26 files changed, 104 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/macros.xml	Thu Apr 23 08:07:20 2020 -0400
+++ b/macros.xml	Wed May 13 14:21:48 2020 -0400
@@ -32,6 +32,12 @@
     <token name="@READING_MSIDATA@"><![CDATA[
         ## importing MSI data files
 
+            ## read RData files (MSI and other data) independent of filename
+            loadRData <- function(fileName){
+            load(fileName)
+            get(ls()[ls() != "fileName"])
+            }
+
         #if $infile.ext == 'imzml'
             #if str($processed_cond.processed_file) == "processed":
                 msidata <- readImzML('infile', resolution=$processed_cond.accuracy, attach.only=TRUE, units = "$processed_cond.units")
@@ -45,11 +51,6 @@
             msidata = readAnalyze('infile', attach.only=TRUE)
             centroided(msidata) = $centroids
         #else
-            ## function to read RData files independent of filename
-            loadRData <- function(fileName){
-            load(fileName)
-            get(ls()[ls() != "fileName"])
-            }
             msidata = loadRData('infile.RData')
         #end if
 
--- a/preprocessing.xml	Thu Apr 23 08:07:20 2020 -0400
+++ b/preprocessing.xml	Wed May 13 14:21:48 2020 -0400
@@ -1,4 +1,4 @@
-<tool id="cardinal_preprocessing" name="MSI preprocessing" version="@VERSION@.1">
+<tool id="cardinal_preprocessing" name="MSI preprocessing" version="@VERSION@.2">
     <description>
         mass spectrometry imaging preprocessing
     </description>
@@ -92,7 +92,7 @@
                 msidata = as(msidata, "MSContinuousImagingExperiment")
             }
 
-            msidata = normalize(msidata, method="tic")
+            msidata = normalize(msidata, method="$method.methods_conditional.methods_for_normalization.normalization_method")
             msidata <- process(msidata, BPPARAM=MulticoreParam(workers=number_cpu))
 
 
@@ -179,6 +179,42 @@
             print(plot(msidata, pixel=random_spectra))
             title("Spectra after smoothing", outer=TRUE, line=0)
 
+
+    ############################### Mz alignment ###########################
+
+        #elif str( $method.methods_conditional.preprocessing_method ) == 'mz_alignment':
+            print('M/z alignment')
+            ## M/z alignment
+
+            #if str( $method.methods_conditional.mzalign_ref_type.align_reference_datatype) == 'align_table':
+
+                reference_mz = read.delim("$method.methods_conditional.mzalign_ref_type.mz_tabular", header = $method.methods_conditional.mzalign_ref_type.feature_header, stringsAsFactors = FALSE)
+                reference_mz = reference_mz[,$method.methods_conditional.mzalign_ref_type.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)
+
+
+            #elif str( $method.methods_conditional.mzalign_ref_type.align_reference_datatype) == 'align_noref':
+
+                msidata = mzAlign(msidata,tolerance = $method.methods_conditional.alignment_tol, units = "$method.methods_conditional.alignment_units", , quantile = $method.methods_conditional.quantile, span = $method.methods_conditional.span)
+
+            #end if
+
+            msidata <- process(msidata, BPPARAM=MulticoreParam(workers=number_cpu))
+
+            ############################### QC ###########################
+
+            maxfeatures =nrow(msidata)
+            pixelcount = ncol(msidata)
+            minmz = round(min(mz(msidata)), digits=2)
+            maxmz = round(max(mz(msidata)), digits=2)
+            mz_aligned = c(minmz, maxmz,maxfeatures, pixelcount)
+            QC_numbers= cbind(QC_numbers, mz_aligned)
+            vectorofactions = append(vectorofactions, "mz aligned")
+            print(plot(msidata, pixel=random_spectra))
+            title("Spectra after m/z alignment", outer=TRUE, line=0)
+
+
     ############################### Peak picking ###########################
 
         #elif str( $method.methods_conditional.preprocessing_method) == 'Peak_picking':
@@ -438,6 +474,7 @@
                     <option value="Normalization" selected="True">Intensity Normalization</option>
                     <option value="Baseline_reduction">Baseline Reduction</option>
                     <option value="Smoothing">Peak smoothing</option>
+                    <option value="mz_alignment">m/z alignment</option>
                     <option value="Peak_picking">Peak picking</option>
                     <option value="Peak_alignment">Peak alignment</option>
                     <option value="Peak_filtering">Peak filtering</option>
@@ -487,6 +524,35 @@
                     <param name="window_smoothing" type="float" value="8"
                                 label="Window size"/>
                 </when>
+                <when value="mz_alignment">
+                    <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>
+                    <conditional name="mzalign_ref_type">
+                        <param name="align_reference_datatype" type="select" label="Choose reference">
+                            <option value="align_noref" selected="True">use mean spectrum as reference</option>
+                            <option value="align_table" >m/z values from tabular file as reference</option>
+                        </param>
+                        <when value="align_noref"/>
+                        <when value="align_table">
+                            <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."/>
+                        </when>
+                    </conditional>
+                    <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"
@@ -522,7 +588,7 @@
                     <conditional name="align_ref_type">
                         <param name="align_reference_datatype" type="select" label="Choose reference">
                             <option value="align_noref" selected="True">no reference</option>
-                            <option value="align_table" >tabular file as reference</option>
+                            <option value="align_table" >m/z values from tabular file as reference</option>
                         </param>
                         <when value="align_noref"/>
                         <when value="align_table">
@@ -537,9 +603,10 @@
                 <when value="Peak_binning">
                     <expand macro="reading_1_column_mz_tabular" label="A reference to which the peaks are binned." help="Tabular file with m/z features to extract from input file"/>
                     <param name="peakbin_tol" value="NA" type="text" label="The tolerance to be used when matching the m/z features in the dataset to the reference. If this is NA, then automatically guess a resolution from the data." >
-                        <sanitizer invalid_char="">
+                        <sanitizer>
                             <valid initial="string.digits">
-                                <add value="NA" />
+                                <add value="N" />
+                                <add value="A" />
                             </valid>
                         </sanitizer>
                     </param>
@@ -728,6 +795,11 @@
             </repeat>
             <repeat name="methods">
                 <conditional name="methods_conditional">
+                    <param name="preprocessing_method" value="mz_alignment"/>
+                </conditional>
+            </repeat>
+            <repeat name="methods">
+                <conditional name="methods_conditional">
                     <param name="preprocessing_method" value="Data_reduction"/>
                     <conditional name="methods_for_reduction">
                         <param name="reduction_method" value="bin"/>
@@ -761,7 +833,7 @@
                     <param name="preprocessing_method" value="Baseline_reduction"/>
                 </conditional>
             </repeat>
-            <output name="QC_overview" file="preprocessing_results5.pdf" compare="sim_size"/>
+            <output name="QC_overview" file="preprocessing_results5.pdf" compare="sim_size" delta="13000"/>
             <output name="outfile_imzml" ftype="imzml" file="preprocessing_results5.imzml.txt" compare="sim_size">
                 <extra_files type="file" file="preprocessing_results5.imzml" name="imzml" lines_diff="6"/>
                 <extra_files type="file" file="preprocessing_results5.ibd" name="ibd" compare="sim_size"/>
Binary file test-data/QC_analyze75.pdf has changed
Binary file test-data/QC_empty_spectra.pdf has changed
Binary file test-data/QC_imzml.pdf has changed
Binary file test-data/QC_rdata.pdf has changed
Binary file test-data/preprocessing_results1.ibd has changed
--- a/test-data/preprocessing_results1.imzml	Thu Apr 23 08:07:20 2020 -0400
+++ b/test-data/preprocessing_results1.imzml	Wed May 13 14:21:48 2020 -0400
@@ -9,8 +9,8 @@
 		<fileContent>
 			<cvParam cvRef="MS" accession="MS:1000579" name="MS1 spectrum" value="" />
 			<cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum" value="" />
-			<cvParam cvRef="IMS" accession="IMS:1000080" name="universally unique identifier" value="722d404b-4188-40b4-a3b2-3764ebbdecad" />
-			<cvParam cvRef="IMS" accession="IMS:1000091" name="ibd SHA-1" value="c5aded0bab57fd7317901ff7709f2395fc91152e" />
+			<cvParam cvRef="IMS" accession="IMS:1000080" name="universally unique identifier" value="25fb4349-d529-4b12-8523-a6aa0306ecf4" />
+			<cvParam cvRef="IMS" accession="IMS:1000091" name="ibd SHA-1" value="7f41f9f5efcb31248caefc91b7d6edce87d7f42c" />
 			<cvParam cvRef="IMS" accession="IMS:1000030" name="continuous" value="" />
 		</fileContent>
 	</fileDescription>
--- a/test-data/preprocessing_results1.imzml.txt	Thu Apr 23 08:07:20 2020 -0400
+++ b/test-data/preprocessing_results1.imzml.txt	Wed May 13 14:21:48 2020 -0400
@@ -1,4 +1,4 @@
 imzML file:
 total 24
--rw-r--r-- 1 meli meli   216 Mär 24 10:39 ibd
--rw-r--r-- 1 meli meli 18090 Mär 24 10:39 imzml
+-rw-r--r-- 1 meli meli   216 Mai 10 17:37 ibd
+-rw-r--r-- 1 meli meli 18090 Mai 10 17:37 imzml
Binary file test-data/preprocessing_results1.pdf has changed
Binary file test-data/preprocessing_results2.ibd has changed
--- a/test-data/preprocessing_results2.imzml	Thu Apr 23 08:07:20 2020 -0400
+++ b/test-data/preprocessing_results2.imzml	Wed May 13 14:21:48 2020 -0400
@@ -9,8 +9,8 @@
 		<fileContent>
 			<cvParam cvRef="MS" accession="MS:1000579" name="MS1 spectrum" value="" />
 			<cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum" value="" />
-			<cvParam cvRef="IMS" accession="IMS:1000080" name="universally unique identifier" value="e536d1e2-427b-4c5b-9743-8210ae52a564" />
-			<cvParam cvRef="IMS" accession="IMS:1000091" name="ibd SHA-1" value="7cea783e9d345946b874fc1f25d40ce90bffd2f9" />
+			<cvParam cvRef="IMS" accession="IMS:1000080" name="universally unique identifier" value="fa59b434-12e0-47fe-b338-814c92daa7d6" />
+			<cvParam cvRef="IMS" accession="IMS:1000091" name="ibd SHA-1" value="5764be27b51a23d8c23e4c93befb9d8e57161bd9" />
 			<cvParam cvRef="IMS" accession="IMS:1000030" name="continuous" value="" />
 		</fileContent>
 	</fileDescription>
--- a/test-data/preprocessing_results2.imzml.txt	Thu Apr 23 08:07:20 2020 -0400
+++ b/test-data/preprocessing_results2.imzml.txt	Wed May 13 14:21:48 2020 -0400
@@ -1,4 +1,4 @@
 imzML file:
 total 64
--rw-r--r-- 1 meli meli 37404 Mär 24 10:40 ibd
--rw-r--r-- 1 meli meli 22796 Mär 24 10:40 imzml
+-rw-r--r-- 1 meli meli 37404 Mai 10 17:38 ibd
+-rw-r--r-- 1 meli meli 22796 Mai 10 17:38 imzml
Binary file test-data/preprocessing_results2.pdf has changed
Binary file test-data/preprocessing_results3.ibd has changed
--- a/test-data/preprocessing_results3.imzml	Thu Apr 23 08:07:20 2020 -0400
+++ b/test-data/preprocessing_results3.imzml	Wed May 13 14:21:48 2020 -0400
@@ -9,8 +9,8 @@
 		<fileContent>
 			<cvParam cvRef="MS" accession="MS:1000579" name="MS1 spectrum" value="" />
 			<cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum" value="" />
-			<cvParam cvRef="IMS" accession="IMS:1000080" name="universally unique identifier" value="df9dd256-6485-4954-8338-ddb0c760d4dc" />
-			<cvParam cvRef="IMS" accession="IMS:1000091" name="ibd SHA-1" value="ea9ad44f2615ef4d24b92d3ceb38dfa8ec47a978" />
+			<cvParam cvRef="IMS" accession="IMS:1000080" name="universally unique identifier" value="d11b7693-3397-4d1f-9e67-29d952701100" />
+			<cvParam cvRef="IMS" accession="IMS:1000091" name="ibd SHA-1" value="94906879d47bbdcf97126d50c906dfd76e6681e4" />
 			<cvParam cvRef="IMS" accession="IMS:1000031" name="processed" value="" />
 		</fileContent>
 	</fileDescription>
--- a/test-data/preprocessing_results3.imzml.txt	Thu Apr 23 08:07:20 2020 -0400
+++ b/test-data/preprocessing_results3.imzml.txt	Wed May 13 14:21:48 2020 -0400
@@ -1,4 +1,4 @@
 imzML file:
 total 24
--rw-r--r-- 1 meli meli   960 Apr 22 15:36 ibd
--rw-r--r-- 1 meli meli 18112 Apr 22 15:36 imzml
+-rw-r--r-- 1 meli meli   960 Mai 10 17:39 ibd
+-rw-r--r-- 1 meli meli 18112 Mai 10 17:39 imzml
Binary file test-data/preprocessing_results3.pdf has changed
Binary file test-data/preprocessing_results4.ibd has changed
--- a/test-data/preprocessing_results4.imzml	Thu Apr 23 08:07:20 2020 -0400
+++ b/test-data/preprocessing_results4.imzml	Wed May 13 14:21:48 2020 -0400
@@ -9,8 +9,8 @@
 		<fileContent>
 			<cvParam cvRef="MS" accession="MS:1000579" name="MS1 spectrum" value="" />
 			<cvParam cvRef="MS" accession="MS:1000128" name="profile spectrum" value="" />
-			<cvParam cvRef="IMS" accession="IMS:1000080" name="universally unique identifier" value="db79298c-8368-42d7-84fc-18cad6ef1924" />
-			<cvParam cvRef="IMS" accession="IMS:1000091" name="ibd SHA-1" value="18bae3cc87b4c9aab2577cffe2fbc7425a93270b" />
+			<cvParam cvRef="IMS" accession="IMS:1000080" name="universally unique identifier" value="c6122884-ceb5-46b6-9160-5d28e8862946" />
+			<cvParam cvRef="IMS" accession="IMS:1000091" name="ibd SHA-1" value="03e4b58b8e63517605164e90b85fe93a851a9c5b" />
 			<cvParam cvRef="IMS" accession="IMS:1000030" name="continuous" value="" />
 		</fileContent>
 	</fileDescription>
--- a/test-data/preprocessing_results4.imzml.txt	Thu Apr 23 08:07:20 2020 -0400
+++ b/test-data/preprocessing_results4.imzml.txt	Wed May 13 14:21:48 2020 -0400
@@ -1,4 +1,4 @@
 imzML file:
 total 84
--rw-r--r-- 1 meli meli 63256 Mär 24 11:35 ibd
--rw-r--r-- 1 meli meli 18199 Mär 24 11:35 imzml
+-rw-r--r-- 1 meli meli 63256 Mai 10 17:40 ibd
+-rw-r--r-- 1 meli meli 18199 Mai 10 17:40 imzml
Binary file test-data/preprocessing_results4.pdf has changed
Binary file test-data/preprocessing_results5.ibd has changed
--- a/test-data/preprocessing_results5.imzml	Thu Apr 23 08:07:20 2020 -0400
+++ b/test-data/preprocessing_results5.imzml	Wed May 13 14:21:48 2020 -0400
@@ -9,8 +9,8 @@
 		<fileContent>
 			<cvParam cvRef="MS" accession="MS:1000579" name="MS1 spectrum" value="" />
 			<cvParam cvRef="MS" accession="MS:1000128" name="profile spectrum" value="" />
-			<cvParam cvRef="IMS" accession="IMS:1000080" name="universally unique identifier" value="1cb5b7df-bc82-4588-9a14-1dd58a3983a7" />
-			<cvParam cvRef="IMS" accession="IMS:1000091" name="ibd SHA-1" value="a16bf7a9d9d4064ce94821e3e7df2681725a497b" />
+			<cvParam cvRef="IMS" accession="IMS:1000080" name="universally unique identifier" value="3aff713c-00ec-422d-b63d-efd45fbdd7cc" />
+			<cvParam cvRef="IMS" accession="IMS:1000091" name="ibd SHA-1" value="9316138c1e7484662943bb206c79c2d074121530" />
 			<cvParam cvRef="IMS" accession="IMS:1000030" name="continuous" value="" />
 		</fileContent>
 	</fileDescription>
--- a/test-data/preprocessing_results5.imzml.txt	Thu Apr 23 08:07:20 2020 -0400
+++ b/test-data/preprocessing_results5.imzml.txt	Wed May 13 14:21:48 2020 -0400
@@ -1,4 +1,4 @@
 imzML file:
 total 428
--rw-r--r-- 1 meli meli 415936 Apr 19 21:07 ibd
--rw-r--r-- 1 meli meli  18569 Apr 19 21:07 imzml
+-rw-r--r-- 1 meli meli 415936 Mai 10 17:40 ibd
+-rw-r--r-- 1 meli meli  18569 Mai 10 17:40 imzml
Binary file test-data/preprocessing_results5.pdf has changed