diff msi_filtering.xml @ 3:d51c3c814d57 draft

planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msi_filtering commit a7be47698f53eb4f00961192327d93e8989276a7
author galaxyp
date Mon, 11 Jun 2018 17:33:40 -0400
parents 22db5eb94e50
children bf61fc662615
line wrap: on
line diff
--- a/msi_filtering.xml	Mon May 28 12:36:24 2018 -0400
+++ b/msi_filtering.xml	Mon Jun 11 17:33:40 2018 -0400
@@ -1,4 +1,4 @@
-<tool id="mass_spectrometry_imaging_filtering" name="MSI filtering" version="1.10.0.0">
+<tool id="mass_spectrometry_imaging_filtering" name="MSI filtering" version="1.10.0.1">
     <description>tool for filtering mass spectrometry imaging data</description>
     <requirements>
         <requirement type="package" version="1.10.0">bioconductor-cardinal</requirement>
@@ -41,12 +41,13 @@
     load('infile.RData')
 #end if
 
-##################################### QC: inputfile properties in numbers ######
+########################### optional QC numbers ########################
 
 #if $outputs.outputs_select == "quality_control":
-    ## Number of features (mz)
+
+    ## Number of features (m/z)
     maxfeatures = length(features(msidata))
-    ## Range mz
+    ## Range m/z
     minmz = round(min(mz(msidata)), digits=2)
     maxmz = round(max(mz(msidata)), digits=2)
     ## Number of spectra (pixels)
@@ -59,7 +60,7 @@
     maximumy = max(coord(msidata)[,2])
     ## Number of intensities > 0
     npeaks= sum(spectra(msidata)[]>0)
-    ## Spectra multiplied with mz (potential number of peaks)
+    ## Spectra multiplied with m/z (potential number of peaks)
     numpeaks = ncol(spectra(msidata)[])*nrow(spectra(msidata)[])
     ## Percentage of intensities > 0
     percpeaks = round(npeaks/numpeaks*100, digits=2)
@@ -70,66 +71,55 @@
     medint = round(median(TICs), digits=2)
     ## Store features for QC plot
     featuresinfile = mz(msidata)
+
 #end if
 
+###################################### Filtering of pixels #####################
+################################################################################
 
-###################################### Filtering of pixels #####################
-
-### Pixels in the one column format "x=,y="
+#################### Pixels in the one column format "x=,y=" #####################
 
 #if str($pixels_cond.pixel_filtering) == "single_column":
     print("single column")
 
-        input_list = read.delim("$pixels_cond.single_pixels", header = FALSE, stringsAsFactors = FALSE)
-        numberpixels = length(input_list[,$pixels_cond.pixel_column])
-        valid_entries = input_list[,$pixels_cond.pixel_column] %in% names(pixels(msidata))
-        validpixels = sum(valid_entries)
+    input_list = read.delim("$pixels_cond.single_pixels", header = FALSE, stringsAsFactors = FALSE)
+    numberpixels = length(input_list[,$pixels_cond.pixel_column])
+    valid_entries = input_list[,$pixels_cond.pixel_column] %in% names(pixels(msidata))
+    validpixels = sum(valid_entries)
 
-                if (validpixels != 0)
-            {
-                pixelsofinterest = pixels(msidata)[names(pixels(msidata)) %in% input_list[valid_entries,$pixels_cond.pixel_column]]
-                msidata = msidata[,pixelsofinterest]
-            }else{
-                msidata = msidata[,0]
-                validpixels=0
-            }
+    if (validpixels != 0){
+        pixelsofinterest = pixels(msidata)[names(pixels(msidata)) %in% input_list[valid_entries,$pixels_cond.pixel_column]]
+        msidata = msidata[,pixelsofinterest]
+    }else{
+        msidata = msidata[,0]
+        validpixels=0}
 
-
-### Pixels in two columns format: x and y in different columns
+############ Pixels in two columns format: x and y in different columns #############
 
 #elif str($pixels_cond.pixel_filtering) == "two_columns":
     print("two columns")
 
-        input_list = read.delim("$pixels_cond.two_columns_pixel", header = FALSE, 
-        stringsAsFactors = FALSE)
-        numberpixels = length(input_list[,$pixels_cond.pixel_column_x])
-
-        inputpixel_x = input_list[,$pixels_cond.pixel_column_x]
-        inputpixel_y = input_list[,$pixels_cond.pixel_column_y]
+    input_list = read.delim("$pixels_cond.two_columns_pixel", header = FALSE, 
+    stringsAsFactors = FALSE)
+    numberpixels = length(input_list[,$pixels_cond.pixel_column_x])
 
-        inputpixels = cbind(inputpixel_x, inputpixel_y)
-        colnames(inputpixels) = c("x", "y")
-        valid_rows = merge(inputpixels, coord(msidata)[,1:2])
-        validpixels = nrow(valid_rows)
-
-        if (validpixels != 0)
-        {
+    inputpixel_x = input_list[,$pixels_cond.pixel_column_x]
+    inputpixel_y = input_list[,$pixels_cond.pixel_column_y]
+    inputpixels = cbind(inputpixel_x, inputpixel_y)
+    colnames(inputpixels) = c("x", "y")
+    valid_rows = merge(inputpixels, coord(msidata)[,1:2])
+    validpixels = nrow(valid_rows)
 
-            pixelvector = character()
-
-            for (pixel in 1:nrow(valid_rows))
-            {
-            pixelvector[pixel] = paste0("x = ", valid_rows[pixel,1],", ", "y = ", valid_rows[pixel,2])
-            }
+    if (validpixels != 0){
+        pixelvector = character()
+        for (pixel in 1:nrow(valid_rows)){
+            pixelvector[pixel] = paste0("x = ", valid_rows[pixel,1],", ", "y = ", valid_rows[pixel,2])}
+        pixelsofinterest= pixels(msidata)[names(pixels(msidata)) %in% pixelvector]
+        msidata = msidata[,pixelsofinterest]
+    }else{
+        validpixels=0}
 
-            pixelsofinterest= pixels(msidata)[names(pixels(msidata)) %in% pixelvector]
-            msidata = msidata[,pixelsofinterest]
-        }else{
-            validpixels=0
-        }
-
-
-### Pixels wihin x and y minima and maxima are kept: 
+########### Pixels wihin x and y minima and maxima are kept ###################
 
 #elif str($pixels_cond.pixel_filtering) == "pixel_range":
     print("pixel range")
@@ -139,69 +129,60 @@
 
 ## only filter pixels if at least one pixel will be left
 
-    if (sum(coord(msidata)\$x <= $pixels_cond.max_x_range & coord(msidata)\$x >= $pixels_cond.min_x_range) > 0 & sum(coord(msidata)\$y <= $pixels_cond.max_y_range & coord(msidata)\$y >= $pixels_cond.min_y_range) > 0)
-    {
+    if (sum(coord(msidata)\$x <= $pixels_cond.max_x_range & coord(msidata)\$x >= $pixels_cond.min_x_range) > 0 & sum(coord(msidata)\$y <= $pixels_cond.max_y_range & coord(msidata)\$y >= $pixels_cond.min_y_range) > 0){
         msidata = msidata[, coord(msidata)\$x <= $pixels_cond.max_x_range & coord(msidata)\$x >= $pixels_cond.min_x_range]
         msidata = msidata[, coord(msidata)\$y <= $pixels_cond.max_y_range & coord(msidata)\$y >= $pixels_cond.min_y_range]
-    }else{ 
+    }else{
         msidata = msidata[,0]
-        print("no valid pixel found")
-    }
-
-
+        print("no valid pixel found")}
 
 #elif str($pixels_cond.pixel_filtering) == "none":
     print("no pixel filtering")
+
     numberpixels = 0
     validpixels = 0
 
 #end if
 
 
+###################################### filtering of features ######################
+##################################################################################
 
-###################################### filtering of features ######################
-
-### Tabular file contains mz either as numbers or in the format mz=800.01
+######################## Keep m/z from tabular file #########################
 
 #if str($features_cond.features_filtering) == "features_list":
     print("feature list")
 
     input_features = read.delim("$inputfeatures", header = FALSE, stringsAsFactors = FALSE)
-
     startingrow = $features_cond.feature_header+1
     extracted_features = input_features[startingrow:nrow(input_features),$features_cond.feature_column]
     numberfeatures = length(extracted_features)
 
-    if (grepl("m/z = ", input_features[startingrow,$features_cond.feature_column])==FALSE)
+    if (grepl("m/z = ", input_features[startingrow,$features_cond.feature_column])==FALSE){
 
 ### if input is in numeric format
-    {
-
-        if (class(extracted_features) == "numeric")
-        {
-            charactervector = rep("m/z = ", numberfeatures)
-            mz_added = paste0(charactervector, round(extracted_features,digits=2))
-            validfeatures = mz_added %in% names(features(msidata))
-            featuresofinterest = features(msidata)[names(features(msidata)) %in% mz_added[validfeatures]]
-            validmz = sum(validfeatures)
+        if (class(extracted_features) == "numeric"){
+            ### max digits given in the input file will be used to match m/z
+            max_digits = max(nchar(matrix(unlist(strsplit(as.character(extracted_features), "\\.")), ncol=2, byrow=TRUE)[,2]))
+            validfeatures = extracted_features %in% round(mz(msidata),max_digits)
+            featuresofinterest = features(msidata)[round(mz(msidata), digits = max_digits) %in% extracted_features[validfeatures]]
+            validmz = length(unique(featuresofinterest))
         }else{
-            validmz = 0
-            featuresofinterest = 0
-        }
+                validmz = 0
+                featuresofinterest = 0}
 
 ### if input is already in character format (m/z = 800.01)
 
-    }else{   
+    }else{
         validfeatures = extracted_features %in% names(features(msidata))
         featuresofinterest = features(msidata)[names(features(msidata)) %in% extracted_features[validfeatures]]
-        validmz = sum(validfeatures)
-    }
+        validmz = sum(validfeatures)}
 
 ### filter msidata for valid features
+
     msidata = msidata[featuresofinterest,]
 
-
-### Only features within a given minimum and maximum value are kept: 
+############### features within a given range are kept #########################
 
 #elif str($features_cond.features_filtering) == "features_range":
     print("feature range")
@@ -209,146 +190,168 @@
     numberfeatures = "range"
     validmz = "range"
 
-    if (sum(mz(msidata) >= $features_cond.min_mz & mz(msidata) <= $features_cond.max_mz)> 0)
-    {
-    msidata = msidata[mz(msidata) >= $features_cond.min_mz & mz(msidata) <= $features_cond.max_mz,]
+    if (sum(mz(msidata) >= $features_cond.min_mz & mz(msidata) <= $features_cond.max_mz)> 0){
+        msidata = msidata[mz(msidata) >= $features_cond.min_mz & mz(msidata) <= $features_cond.max_mz,]
     }else{ 
         msidata = msidata[0,]
-        print("no valid mz range")
+        print("no valid mz range")}
+
+############### Remove m/z from tabular file #########################
+
+#elif str($features_cond.features_filtering) == "remove_features":
+    print("remove features")
+
+### Tabular file contains mz either as numbers or in the format mz = 800.01
+
+    input_features = read.delim("$inputfeatures_removal", header = FALSE, stringsAsFactors = FALSE) 
+    startingrow = $features_cond.removal_header+1
+    extracted_features = input_features[startingrow:nrow(input_features),$features_cond.removal_column]
+    numberfeatures = length(extracted_features)
+
+    if (grepl("m/z = ", input_features[startingrow,$features_cond.removal_column])==TRUE){
+
+### if input is mz = 800 character format
+        print("input is in format mz = 400")
+        validfeatures = extracted_features %in% names(features(msidata))
+        validmz = sum(validfeatures)
+        filtered_features = features(msidata)[names(features(msidata)) %in% extracted_features[validfeatures]]
+        featuresofinterest = mz(msidata)[filtered_features]
+
+### if input is numeric:
+    }else{
+        if (class(extracted_features) == "numeric"){
+            print("input is numeric")
+            featuresofinterest = extracted_features
+            validmz = sum(featuresofinterest <= max(mz(msidata))& featuresofinterest >= min(mz(msidata)))
+        }else{featuresofinterest = 0
+                validmz = 0}
     }
 
+### Here starts removal of features: 
+
+    plusminus = $features_cond.removal_plusminus
+
+    mass_to_remove = numeric()
+    if (sum(featuresofinterest) > 0){
+        for (masses in featuresofinterest){
+            #if str($features_cond.units_removal) == "ppm": 
+                plusminus = masses * $features_cond.removal_plusminus/1000000
+            #end if 
+            current_mass = which(c(mz(msidata) <= masses + plusminus & mz(msidata) >= masses - plusminus))
+            mass_to_remove = append(mass_to_remove, current_mass)}
+        msidata= msidata[-mass_to_remove, ]
+    }else{print("No features were removed as they were not fitting to m/z values and/or range")}
+
 
 #elif str($features_cond.features_filtering) == "none":
 
     print("no feature filtering")
     validmz = 0
     numberfeatures = 0
+
 #end if
 
-
-
-# save msidata as Rfile
+## save msidata as Rfile
 save(msidata, file="$msidata_filtered")
 
-###################################### outputfile properties in numbers ########
+#################### optional QC numbers #######################
 
 #if $outputs.outputs_select == "quality_control":
 
-## Number of features (mz)
-maxfeatures2 = length(features(msidata))
-## Range mz
-minmz2 = round(min(mz(msidata)), digits=2)
-maxmz2 = round(max(mz(msidata)), digits=2)
-## Number of spectra (pixels)
-pixelcount2 = length(pixels(msidata))
-## Range x coordinates
-minimumx2 = min(coord(msidata)[,1])
-maximumx2 = max(coord(msidata)[,1])
-## Range y coordinates
-minimumy2 = min(coord(msidata)[,2])
-maximumy2 = max(coord(msidata)[,2])
-## Number of intensities > 0
-npeaks2= sum(spectra(msidata)[]>0)
-## Spectra multiplied with mz (potential number of peaks)
-numpeaks2 = ncol(spectra(msidata)[])*nrow(spectra(msidata)[])
-## Percentage of intensities > 0
-percpeaks2 = round(npeaks2/numpeaks2*100, digits=2)
-## Number of empty TICs
-TICs2 = colSums(spectra(msidata)[]) 
-NumemptyTIC2 = sum(TICs2 == 0)
-## median TIC
-medint2 = round(median(TICs2), digits=2)
-
+    ## Number of features (m/z)
+    maxfeatures2 = length(features(msidata))
+    ## Range m/z
+    minmz2 = round(min(mz(msidata)), digits=2)
+    maxmz2 = round(max(mz(msidata)), digits=2)
+    ## Number of spectra (pixels)
+    pixelcount2 = length(pixels(msidata))
+    ## Range x coordinates
+    minimumx2 = min(coord(msidata)[,1])
+    maximumx2 = max(coord(msidata)[,1])
+    ## Range y coordinates
+    minimumy2 = min(coord(msidata)[,2])
+    maximumy2 = max(coord(msidata)[,2])
+    ## Number of intensities > 0
+    npeaks2= sum(spectra(msidata)[]>0)
+    ## Spectra multiplied with m/z (potential number of peaks)
+    numpeaks2 = ncol(spectra(msidata)[])*nrow(spectra(msidata)[])
+    ## Percentage of intensities > 0
+    percpeaks2 = round(npeaks2/numpeaks2*100, digits=2)
+    ## Number of empty TICs
+    TICs2 = colSums(spectra(msidata)[]) 
+    NumemptyTIC2 = sum(TICs2 == 0)
+    ## median TIC
+    medint2 = round(median(TICs2), digits=2)
 
-properties = c("Number of mz features",
-               "Range of mz values [Da]",
-               "Number of pixels", 
-               "Range of x coordinates", 
-               "Range of y coordinates",
-               "Intensities > 0",
-               "Median TIC per pixel",
-               "Number of zero TICs", 
-               "pixel overview", 
-               "feature overview")
+    properties = c("Number of m/z features",
+                   "Range of m/z values [Da]",
+                   "Number of pixels", 
+                   "Range of x coordinates", 
+                   "Range of y coordinates",
+                   "Intensities > 0",
+                   "Median TIC per pixel",
+                   "Number of zero TICs", 
+                   "pixel overview", 
+                   "feature overview")
 
-before = c(paste0(maxfeatures), 
-           paste0(minmz, " - ", maxmz), 
-           paste0(pixelcount), 
-           paste0(minimumx, " - ", maximumx),  
-           paste0(minimumy, " - ", maximumy), 
-           paste0(percpeaks, " %"), 
-           paste0(medint),
-           paste0(NumemptyTIC), 
-           paste0("input pixels: ", numberpixels),
-           paste0("input mz: ", numberfeatures))
+    before = c(paste0(maxfeatures), 
+               paste0(minmz, " - ", maxmz), 
+               paste0(pixelcount), 
+               paste0(minimumx, " - ", maximumx),  
+               paste0(minimumy, " - ", maximumy), 
+               paste0(percpeaks, " %"), 
+               paste0(medint),
+               paste0(NumemptyTIC), 
+               paste0("input pixels: ", numberpixels),
+               paste0("input mz: ", numberfeatures))
 
-filtered = c(paste0(maxfeatures2), 
-           paste0(minmz2, " - ", maxmz2), 
-           paste0(pixelcount2), 
-           paste0(minimumx2, " - ", maximumx2),  
-           paste0(minimumy2, " - ", maximumy2), 
-           paste0(percpeaks2, " %"), 
-           paste0(medint2),
-           paste0(NumemptyTIC2), 
-           paste0("valid pixels: ", validpixels),
-           paste0("valid mz: ", validmz))
+    filtered = c(paste0(maxfeatures2), 
+               paste0(minmz2, " - ", maxmz2), 
+               paste0(pixelcount2), 
+               paste0(minimumx2, " - ", maximumx2),  
+               paste0(minimumy2, " - ", maximumy2), 
+               paste0(percpeaks2, " %"), 
+               paste0(medint2),
+               paste0(NumemptyTIC2), 
+               paste0("valid pixels: ", validpixels),
+               paste0("valid mz: ", validmz))
 
-
-property_df = data.frame(properties, before, filtered)
+    property_df = data.frame(properties, before, filtered)
 
-
-
-######################################## PDF QC ################################
+############################### optional PDF QC ################################
 
     pdf("filtertool_QC.pdf", fonts = "Times", pointsize = 12)
     plot(0,type='n',axes=FALSE,ann=FALSE)
-
     title(main=paste0("Qualitycontrol of filtering tool for file: \n\n", "$infile.display_name"))
-
-
-    
     grid.table(property_df, rows= NULL)
 
     ### heatmap image as visual pixel control
-
-if (length(features(msidata))> 0 & length(pixels(msidata)) > 0)
-{
-
-
-    image(msidata, mz=$outputs.inputmz, plusminus = $outputs.plusminus_dalton, contrast.enhance = "none", 
+    if (length(features(msidata))> 0 & length(pixels(msidata)) > 0){
+        image(msidata, mz=$outputs.inputmz, plusminus = $outputs.plusminus_dalton, contrast.enhance = "none", 
           main= paste0($outputs.inputmz," ± ", $outputs.plusminus_dalton, " Da"), ylim = c(maximumy2+0.2*maximumy2,minimumy2-0.2*minimumy2))
 
-    ### control features which are left
-
-    plot(featuresinfile, rep(1,length(featuresinfile)), yaxt="n", ylab=NA, xlab="m/z values", col="red", ylim=c(0.8, 1.1), main="Distribution of m/z values")
-    lines(mz(msidata),rep(0.9, length(mz(msidata))), col="green", type="p")
-    legend("top", horiz=TRUE,
-           legend = c("before", "filtered"), 
-           fill = c("red", "green"))
-
-}else{
-    print("file has no features or pixels left")
-}
+        ### control features which are left
+        plot(featuresinfile, rep(1,length(featuresinfile)), yaxt="n", ylab=NA, xlab="m/z values", col="red", ylim=c(0.8, 1.1), main="Distribution of m/z values")
+        lines(mz(msidata),rep(0.9, length(mz(msidata))), col="green", type="p")
+        legend("top", horiz=TRUE, legend = c("before", "filtered"), fill = c("red", "green"))
+    }else{
+        print("file has no features or pixels left")}
 
     dev.off()
 
 #end if
 
-######################################## intensity matrix ######################
+############################### optional intensity matrix ######################
 
 #if $output_matrix:
 
-if (length(features(msidata))> 0 & length(pixels(msidata)) > 0)
-{
-
+if (length(features(msidata))> 0 & length(pixels(msidata)) > 0){
     spectramatrix = spectra(msidata)
     rownames(spectramatrix) = mz(msidata)
     newmatrix = rbind(pixels(msidata), spectramatrix)
     write.table(newmatrix[2:nrow(newmatrix),], file="$matrixasoutput", quote = FALSE, row.names = TRUE, col.names=NA, sep = "\t")
-
 }else{
-    print("file has no features or pixels left")
-}
+    print("file has no features or pixels left")}
 
 #end if
 
@@ -356,7 +359,7 @@
     ]]></configfile>
     </configfiles>
     <inputs>
-        <param name="infile" type="data" format="imzml, rdata, analyze75"
+        <param name="infile" type="data" format="imzml,rdata,analyze75"
                label="Inputfile as imzML, Analyze7.5 or Cardinal MSImageSet saved as RData"
                 help="Upload composite datatype imzML (ibd+imzML) or analyze75 (hdr+img+t2m) or regular upload .RData (Cardinal MSImageSet)"/>
         <conditional name="pixels_cond">
@@ -388,18 +391,29 @@
         <conditional name="features_cond">
             <param name="features_filtering" type="select" label="Select feature filtering option">
                 <option value="none" selected="True">none</option>
-                <option value="features_list">tabular file with features (data type: 800.12 or m/z = 800.12)</option>
-                <option value="features_range">range of features</option>
+                <option value="features_list">keep features (tabular input)</option>
+                <option value="features_range">keep features within a range (manual input)</option>
+                <option value="remove_features">remove features (tabular input)</option>
             </param>
             <when value="none"/>
             <when value="features_list">
-                <param name="inputfeatures" type="data" format="tabular" label="Features for filtering of MSI data" help="tabular file with masses of interest either as numbers (800.05) or in the form m/z = 800.05"/>
+                <param name="inputfeatures" type="data" format="tabular" label="Features for filtering of MSI data" help="tabular file with m/z of interest either as numbers (800.05) or in the form m/z = 800.05"/>
                 <param name="feature_column" data_ref="inputfeatures" label="Column with features" type="data_column"/>
                 <param name="feature_header" label="Number of header lines to skip" value="0" type="integer"/>
             </when> 
             <when value="features_range">
-                <param name="min_mz" type="float" value="1" label="Minimum value for mz (in Dalton)"/>
-                <param name="max_mz" type="float" value="100" label="Maximum value for mz (in Dalton)"/>
+                <param name="min_mz" type="float" value="1" label="Minimum value for m/z"/>
+                <param name="max_mz" type="float" value="100" label="Maximum value for m/z"/>
+            </when> 
+            <when value="remove_features">
+                <param name="inputfeatures_removal" type="data" format="tabular" label="Features for filtering of MSI data" help="tabular file with m/z to be removed either as numbers (800.05) or in the form m/z = 800.05"/>
+                <param name="removal_column" data_ref="inputfeatures_removal" label="Column with features" type="data_column"/>
+                <param name="removal_header" label="Number of header lines to skip" value="0" type="integer"/>
+                <param name="removal_plusminus" type="float" value="20" label="Window in which m/z will be removed" help="This value will be added and substracted from the given input value"/>
+                <param name="units_removal" type="select" display = "radio" optional = "False" label="units">
+                        <option value="ppm" selected="True">ppm</option>
+                        <option value="Da">Da</option>
+                </param>
             </when> 
         </conditional>
         <conditional name="outputs">
@@ -408,19 +422,19 @@
                <option value="no_quality_control">no</option>
            </param>
            <when value="quality_control">
-              <param name="inputmz" type="float" value="1296.7" label="Mass for which a heatmap image will be drawn" help="Use a mass which is still present in all pixels to control if the pixel filtering went well"/>
-              <param name="plusminus_dalton" value="0.25" type="float" label="mass range for mz value" help="plusminus mass window in Dalton"/>
+              <param name="inputmz" type="float" value="1296.7" label="M/z for which a heatmap image will be drawn" help="Use a m/z which is still present in all pixels to control if the pixel filtering went well"/>
+              <param name="plusminus_dalton" value="0.25" type="float" label="Range for m/z value" help="plusminus m/z window"/>
            </when>
            <when value="no_quality_control"/>
          </conditional>
          <param name="output_matrix" type="boolean" display="radio" label="Intensity matrix output"/>
     </inputs>
     <outputs>
-        <data format="rdata" name="msidata_filtered" label="${tool.name} ${on_string}"/>
-        <data format="pdf" name="filtering_qc" from_work_dir="filtertool_QC.pdf" label = "QC ${tool.name} ${on_string}">
+        <data format="rdata" name="msidata_filtered" label="$infile.display_name filtered"/>
+        <data format="pdf" name="filtering_qc" from_work_dir="filtertool_QC.pdf" label = "$infile.display_name filtered_QC">
             <filter>outputs["outputs_select"] == "quality_control"</filter>
         </data>
-        <data format="tabular" name="matrixasoutput" label="Matrix ${tool.name} ${on_string}">
+        <data format="tabular" name="matrixasoutput" label="$infile.display_name filtered_matrix">
             <filter>output_matrix</filter>
         </data>
     </outputs>
@@ -470,7 +484,7 @@
             <param name="min_y_range" value="2"/>
             <param name="max_y_range" value="2"/>
             <param name="features_filtering" value="features_range"/>
-            <param name="min_mz" value="0" />
+            <param name="min_mz" value="350" />
             <param name="max_mz" value="500"/>
              <param name="outputs_select" value="quality_control"/>
                 <param name="inputmz" value="328.9"/>
@@ -509,9 +523,10 @@
             <param name="max_x_range" value="10"/>
             <param name="min_y_range" value="2"/>
             <param name="max_y_range" value="20"/>
-            <param name="features_filtering" value="features_range"/>
-            <param name="min_mz" value="500" />
-            <param name="max_mz" value="700"/>
+            <param name="features_filtering" value="features_list"/>
+            <param name="inputfeatures" ftype="tabular" value = "featuresofinterest5.tabular"/>
+            <param name="feature_column" value="1"/>
+            <param name="feature_header" value="0"/>
              <param name="outputs_select" value="quality_control"/>
                 <param name="inputmz" value="328.9"/>
                 <param name="plusminus_dalton" value="0.25"/>
@@ -569,7 +584,7 @@
 
 Cardinal is an R package that implements statistical & computational tools for analyzing mass spectrometry imaging datasets. `More information on Cardinal <http://cardinalmsi.org//>`_
 
-This tool provides provides options to filter (subset) pixels and masses of mass-spectrometry imaging data.
+This tool provides provides options to filter (subset) pixels and m/z features of mass spectrometry imaging data.
 
 Input data: 3 types of input data can be used:
 
@@ -577,20 +592,24 @@
 - Analyze7.5 (upload hdr, img and t2m file via the "composite" function)
 - Cardinal "MSImageSet" data (with variable name "msidata", saved as .RData)
 
+
 Options:
 
 - pixel filtering: can use a tabular file containing x and y coordinates or by defining a range for x and y by hand
-- mass filtering: can use a tabular file containing masses of interest or by defining a range for the mass values
+- m/z feature filtering: can use a tabular file containing m/z of interest or by defining a range for the m/z values (! numeric input will be rounded to 2 digits before matching to m/z!)
+- m/z feature removing: infering m/z such as matrix contaminants can be removed by specifying their m/z in a tabular file and optionally set a window (window in ppm or Da in which peaks should be removed)
+
 
 Output: 
 
-- imzML file filtered for pixels and/or masses
-- optional: pdf with heatmap showing the pixels that are left after filtering and plot of masses before and after filtering
-- optional: intensity matrix as tabular file (intensities for masses in rows and pixel in columns)
+- imzML file filtered for pixels and/or m/z
+- optional: pdf with heatmap showing the pixels that are left after filtering and plot of m/z before and after filtering
+- optional: intensity matrix as tabular file (intensities for m/z in rows and pixel in columns)
+
 
 Tip: 
 
-- It is recommended to use the filtering tool only for masses which have been extracted from the same dataset. If you have masses from dataset A and you want to use them to filter dataset B, first find the corresponding (closest) features in dataset B by using the tool "Join two files on column allowing a small difference". Afterwards use the corresponding feature masses from dataset A to filter dataset B. 
+- It is recommended to use the filtering tool only for m/z which have been extracted from the same dataset. If you have m/z from dataset A and you want to use them to filter dataset B, first find the corresponding (closest) features in dataset B by using the tool "Join two files on column allowing a small difference". Afterwards use the corresponding feature m/z from dataset A to filter dataset B. 
 
 
         ]]>