diff preprocessing.xml @ 3:f172efe92629 draft

planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/cardinal commit 2c4a1a862900b4efbc30824cbcb798f835b168b2
author galaxyp
date Thu, 28 Feb 2019 09:27:06 -0500
parents 1b875f0b8024
children 141a9288be9c
line wrap: on
line diff
--- a/preprocessing.xml	Fri Feb 15 10:22:14 2019 -0500
+++ b/preprocessing.xml	Thu Feb 28 09:27:06 2019 -0500
@@ -60,7 +60,13 @@
     maxmz = round(max(mz(msidata)), digits=2)
     QC_numbers= data.frame(inputdata = c(minmz, maxmz,maxfeatures, pixelcount))
     vectorofactions = "inputdata"
-    plot(msidata, pixel = 1:pixelcount, main="Average spectrum of input file")
+    ## Choose random spectra for QC plots
+    random_spectra = sample(pixels(msidata), 4, replace=FALSE)
+    par(mfrow = c(2, 2), oma=c(0,0,2,0))
+    for (random_sample in 1:length(random_spectra)){
+        plot(msidata, pixel=random_spectra[random_sample], main=paste0("spectrum ", names(random_spectra)[random_sample]))}
+    title("Input spectra", outer=TRUE, line=0)
+
 
     ############################### Preprocessing steps ###########################
     ###############################################################################
@@ -84,7 +90,10 @@
             normalized = c(minmz, maxmz,maxfeatures, pixelcount)
             QC_numbers= cbind(QC_numbers, normalized)
             vectorofactions = append(vectorofactions, "normalized")
-            plot(msidata, pixel = 1:pixelcount, main="Average spectrum after normalization")
+            par(mfrow = c(2, 2), oma=c(0,0,2,0))
+            for (random_sample in 1:length(random_spectra)){
+                plot(msidata, pixel=random_spectra[random_sample], main=paste0("spectrum ", names(random_spectra)[random_sample]))}
+            title("Spectra after normalization", outer=TRUE, line=0)
 
     ############################### Baseline reduction ###########################
 
@@ -103,7 +112,9 @@
             baseline = c(minmz, maxmz,maxfeatures, pixelcount)
             QC_numbers= cbind(QC_numbers, baseline)
             vectorofactions = append(vectorofactions, "baseline red.")
-            plot(msidata, pixel = 1:pixelcount, main="Average spectrum after baseline reduction")
+            for (random_sample in 1:length(random_spectra)){
+                plot(msidata, pixel=random_spectra[random_sample], main=paste0("spectrum ", names(random_spectra)[random_sample]))}
+            title("Spectra after baseline reduction", outer=TRUE, line=0)
 
     ############################### Smoothing ###########################
 
@@ -136,7 +147,9 @@
             smoothed = c(minmz, maxmz,maxfeatures, pixelcount)
             QC_numbers= cbind(QC_numbers, smoothed)
             vectorofactions = append(vectorofactions, "smoothed")
-            plot(msidata, pixel = 1:pixelcount, main="Average spectrum after smoothing")
+            for (random_sample in 1:length(random_spectra)){
+                plot(msidata, pixel=random_spectra[random_sample], main=paste0("spectrum ", names(random_spectra)[random_sample]))}
+            title("Spectra after smoothing", outer=TRUE, line=0)
 
     ############################### Peak picking ###########################
 
@@ -170,7 +183,9 @@
             picked = c(minmz, maxmz,maxfeatures, pixelcount)
             QC_numbers= cbind(QC_numbers, picked)
             vectorofactions = append(vectorofactions, "picked")
-            plot(msidata, pixel = 1:pixelcount, main="Average spectrum after peak picking")
+            for (random_sample in 1:length(random_spectra)){
+                plot(msidata, pixel=random_spectra[random_sample], main=paste0("spectrum ", names(random_spectra)[random_sample]))}
+            title("Spectra after peak picking", outer=TRUE, line=0)
 
     ############################### Peak alignment ###########################
 
@@ -184,8 +199,8 @@
 
             #elif str( $method.methods_conditional.align_ref_type.align_reference_datatype) == 'align_table':
 
-                align_reference_table = read.delim("$method.methods_conditional.align_ref_type.mz_tabular", header = $method.methods_conditional.align_ref_type.align_mass_header, stringsAsFactors = FALSE)
-                align_reference_column = align_reference_table[,$method.methods_conditional.align_ref_type.align_mass_column]
+                align_reference_table = read.delim("$method.methods_conditional.align_ref_type.mz_tabular", header = $method.methods_conditional.align_ref_type.feature_header, stringsAsFactors = FALSE)
+                align_reference_column = align_reference_table[,$method.methods_conditional.align_ref_type.feature_column]
                 align_peak_reference = align_reference_column[align_reference_column>=min(mz(msidata)) & align_reference_column<=max(mz(msidata))]
                 if (length(align_peak_reference) == 0)
                     {align_peak_reference = 0}
@@ -217,7 +232,9 @@
             aligned = c(minmz, maxmz,maxfeatures, pixelcount)
             QC_numbers= cbind(QC_numbers, aligned)
             vectorofactions = append(vectorofactions, "aligned")
-            plot(msidata, pixel = 1:pixelcount, main="Average spectrum after alignment")
+            for (random_sample in 1:length(random_spectra)){
+                plot(msidata, pixel=random_spectra[random_sample], main=paste0("spectrum ", names(random_spectra)[random_sample]))}
+            title("Spectra after alignment", outer=TRUE, line=0)
 
     ############################### Peak filtering ###########################
 
@@ -235,7 +252,9 @@
             filtered = c(minmz, maxmz,maxfeatures, pixelcount)
             QC_numbers= cbind(QC_numbers, filtered)
             vectorofactions = append(vectorofactions, "filtered")
-            plot(msidata, pixel = 1:pixelcount, main="Average spectrum after filtering")
+            for (random_sample in 1:length(random_spectra)){
+                plot(msidata, pixel=random_spectra[random_sample], main=paste0("spectrum ", names(random_spectra)[random_sample]))}
+            title("Spectra after filtering", outer=TRUE, line=0)
 
     ############################### Data reduction ###########################
 
@@ -266,8 +285,8 @@
 
                 #if str( $method.methods_conditional.methods_for_reduction.ref_type.reference_datatype) == 'table':
 
-                    reference_table = read.delim("$method.methods_conditional.methods_for_reduction.ref_type.mz_tabular", header = $method.methods_conditional.methods_for_reduction.ref_type.mass_header, stringsAsFactors = FALSE)
-                    reference_column = reference_table[,$method.methods_conditional.methods_for_reduction.ref_type.mass_column]
+                    reference_table = read.delim("$method.methods_conditional.methods_for_reduction.ref_type.mz_tabular", header = $method.methods_conditional.methods_for_reduction.ref_type.feature_header, stringsAsFactors = FALSE)
+                    reference_column = reference_table[,$method.methods_conditional.methods_for_reduction.ref_type.feature_column]
                     peak_reference = reference_column[reference_column>min(mz(msidata)) & reference_column<max(mz(msidata))]
 
                 #elif str( $method.methods_conditional.methods_for_reduction.ref_type.reference_datatype) == 'msidata_ref':
@@ -287,7 +306,9 @@
             reduced = c(minmz, maxmz,maxfeatures, pixelcount)
             QC_numbers= cbind(QC_numbers, reduced)
             vectorofactions = append(vectorofactions, "reduced")
-            plot(msidata, pixel = 1:pixelcount, main="Average spectrum after data reduction")
+            for (random_sample in 1:length(random_spectra)){
+                plot(msidata, pixel=random_spectra[random_sample], main=paste0("spectrum ", names(random_spectra)[random_sample]))}
+            title("Spectra after data reduction", outer=TRUE, line=0)
 
         ############################### Transformation ###########################
 
@@ -328,7 +349,9 @@
             transformed = c(minmz, maxmz,maxfeatures, pixelcount)
             QC_numbers= cbind(QC_numbers, transformed)
             vectorofactions = append(vectorofactions, "transformed")
-            plot(msidata, pixel = 1:pixelcount, main="Average spectrum after transformation")
+            for (random_sample in 1:length(random_spectra)){
+                plot(msidata, pixel=random_spectra[random_sample], main=paste0("spectrum ", names(random_spectra)[random_sample]))}
+            title("Spectra after transformation", outer=TRUE, line=0)
 
             #end if
     #end for
@@ -340,6 +363,9 @@
 
     #if str($imzml_output) == "imzml_format":
         if (nrow(msidata) > 0){
+            ## make sure that coordinates are integers
+            coord(msidata)\$y = as.integer(coord(msidata)\$y)
+            coord(msidata)\$x = as.integer(coord(msidata)\$x)
             writeImzML(msidata, "out")}
     #elif str($imzml_output) == "rdata_format":
         ## save as (.RData)
@@ -443,7 +469,7 @@
                                    label="diff.max" help="Peaks that differ less than this value will be aligned together"/>
                             <param name="units_diffalignment" type="select" display="radio" optional="False" label="units">
                                     <option value="ppm" selected="True">ppm</option>
-                                    <option value="Da">m/z</option>
+                                    <option value="mz">m/z</option>
                             </param>
                         </when>
                         <when value="DP">