changeset 0:f0b415eb3bcf draft default tip

planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msi_classification commit 8087490eb4dcaf4ead0f03eae4126780d21e5503
author galaxyp
date Fri, 06 Jul 2018 14:12:51 -0400
parents
children
files msi_classification.xml test-data/features_test1.tabular test-data/features_test2.tabular test-data/features_test3.tabular test-data/features_test4.tabular test-data/features_test5.tabular test-data/features_test6.tabular test-data/features_test7.tabular test-data/pixel_annotation_file1.tabular test-data/pixels_test1.tabular test-data/pixels_test2.tabular test-data/pixels_test3.tabular test-data/pixels_test4.tabular test-data/pixels_test5.tabular test-data/pixels_test6.tabular test-data/pixels_test7.tabular test-data/random_factors.tabular test-data/test1.pdf test-data/test2.pdf test-data/test2.rdata test-data/test3.pdf test-data/test4.pdf test-data/test4.rdata test-data/test5.pdf test-data/test6.pdf test-data/test6.rdata test-data/test7.pdf test-data/test7.rdata test-data/testfile_squares.rdata
diffstat 23 files changed, 1537 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/msi_classification.xml	Fri Jul 06 14:12:51 2018 -0400
@@ -0,0 +1,1079 @@
+<tool id="mass_spectrometry_imaging_classification" name="MSI classification" version="1.10.0.0">
+    <description>spatial classification of mass spectrometry imaging data</description>
+    <requirements>
+        <requirement type="package" version="1.10.0">bioconductor-cardinal</requirement>
+        <requirement type="package" version="2.2.1">r-gridextra</requirement>
+        <requirement type="package" version="0.20-35">r-lattice</requirement>
+        <requirement type="package" version="2.2.1">r-ggplot2</requirement>
+    </requirements>
+    <command detect_errors="exit_code">
+    <![CDATA[
+
+        #if $infile.ext == 'imzml'
+            ln -s '${infile.extra_files_path}/imzml' infile.imzML &&
+            ln -s '${infile.extra_files_path}/ibd' infile.ibd &&
+        #elif $infile.ext == 'analyze75'
+            ln -s '${infile.extra_files_path}/hdr' infile.hdr &&
+            ln -s '${infile.extra_files_path}/img' infile.img &&
+            ln -s '${infile.extra_files_path}/t2m' infile.t2m &&
+        #else
+            ln -s $infile infile.RData &&
+        #end if
+        cat '${MSI_segmentation}' &&
+        echo ${MSI_segmentation} &&
+        Rscript '${MSI_segmentation}'
+
+    ]]>
+    </command>
+    <configfiles>
+        <configfile name="MSI_segmentation"><![CDATA[
+
+
+################################# load libraries and read file #########################
+
+library(Cardinal)
+library(gridExtra)
+library(lattice)
+library(ggplot2)
+
+
+#if $infile.ext == 'imzml'
+    #if str($processed_cond.processed_file) == "processed":
+        msidata <- readImzML('infile', mass.accuracy=$processed_cond.accuracy, units.accuracy = "$processed_cond.units")
+    #else
+        msidata <- readImzML('infile')
+    #end if
+#elif $infile.ext == 'analyze75'
+    msidata = readAnalyze('infile')
+#else
+    load('infile.RData')
+#end if
+
+## function to later read RData reference files in
+
+loadRData <- function(fileName){
+#loads an RData file, and returns it
+load(fileName)
+get(ls()[ls() != "fileName"])
+}
+
+## create full matrix to make processed imzML files compatible with classification
+iData(msidata) <- iData(msidata)[] 
+
+###################################### file properties in numbers ##############
+
+## Number of features (mz)
+maxfeatures = length(features(msidata))
+## Range mz
+minmz = round(min(mz(msidata)), digits=2)
+maxmz = round(max(mz(msidata)), digits=2)
+## Number of spectra (pixels)
+pixelcount = length(pixels(msidata))
+## Range x coordinates
+minimumx = min(coord(msidata)[,1])
+maximumx = max(coord(msidata)[,1])
+## Range y coordinates
+minimumy = min(coord(msidata)[,2])
+maximumy = max(coord(msidata)[,2])
+## Range of intensities
+minint = round(min(spectra(msidata)[]), digits=2)
+maxint = round(max(spectra(msidata)[]), digits=2)
+medint = round(median(spectra(msidata)[]), digits=2)
+## Number of intensities > 0
+npeaks= sum(spectra(msidata)[]>0)
+## Spectra multiplied with mz (potential number of peaks)
+numpeaks = ncol(spectra(msidata)[])*nrow(spectra(msidata)[])
+## Percentage of intensities > 0
+percpeaks = round(npeaks/numpeaks*100, digits=2)
+## Number of empty TICs
+TICs = colSums(spectra(msidata)[]) 
+NumemptyTIC = sum(TICs == 0)
+
+
+## Processing informations
+processinginfo = processingData(msidata)
+centroidedinfo = processinginfo@centroided # TRUE or FALSE
+
+## if TRUE write processinginfo if no write FALSE
+
+## normalization
+if (length(processinginfo@normalization) == 0) {
+  normalizationinfo='FALSE'
+} else {
+  normalizationinfo=processinginfo@normalization
+}
+## smoothing
+if (length(processinginfo@smoothing) == 0) {
+  smoothinginfo='FALSE'
+} else {
+  smoothinginfo=processinginfo@smoothing
+}
+## baseline
+if (length(processinginfo@baselineReduction) == 0) {
+  baselinereductioninfo='FALSE'
+} else {
+  baselinereductioninfo=processinginfo@baselineReduction
+}
+## peak picking
+if (length(processinginfo@peakPicking) == 0) {
+  peakpickinginfo='FALSE'
+} else {
+  peakpickinginfo=processinginfo@peakPicking
+}
+
+#############################################################################
+
+properties = c("Number of mz features",
+               "Range of mz values",
+               "Number of pixels", 
+               "Range of x coordinates", 
+               "Range of y coordinates",
+               "Range of intensities", 
+               "Median of intensities",
+               "Intensities > 0",
+               "Number of empty spectra",
+               "Preprocessing", 
+               "Normalization", 
+               "Smoothing",
+               "Baseline reduction",
+               "Peak picking",
+               "Centroided")
+
+values = c(paste0(maxfeatures), 
+           paste0(minmz, " - ", maxmz), 
+           paste0(pixelcount), 
+           paste0(minimumx, " - ", maximumx),  
+           paste0(minimumy, " - ", maximumy), 
+           paste0(minint, " - ", maxint), 
+           paste0(medint),
+           paste0(percpeaks, " %"), 
+           paste0(NumemptyTIC), 
+           paste0(" "),
+           paste0(normalizationinfo),
+           paste0(smoothinginfo),
+           paste0(baselinereductioninfo),
+           paste0(peakpickinginfo),
+           paste0(centroidedinfo))
+
+property_df = data.frame(properties, values)
+
+
+######################################## PDF ###################################
+################################################################################
+################################################################################
+
+Title = "Prediction"
+
+#if str( $type_cond.type_method) == "training":
+    #if str( $type_cond.method_cond.class_method) == "PLS":
+        Title = "PLS"
+    #elif str( $type_cond.method_cond.class_method) == "OPLS":
+        Title = "OPLS"
+    #elif str( $type_cond.method_cond.class_method) == "spatialShrunkenCentroids":
+        Title = "SSC"
+    #end if
+#end if
+
+pdf("classificationpdf.pdf", fonts = "Times", pointsize = 12)
+plot(0,type='n',axes=FALSE,ann=FALSE)
+
+
+title(main=paste0(Title," for file: \n\n", "$infile.display_name"))
+
+
+
+##################### I) numbers and control plots #############################
+###############################################################################
+
+## table with values
+grid.table(property_df, rows= NULL)
+
+if (npeaks > 0){
+
+opar <- par()
+ 
+    ######################## II) Training #############################
+    #############################################################################
+    #if str( $type_cond.type_method) == "training":
+        print("training")
+
+
+        ## load y response (will be needed in every training scenario)
+
+        #if str($type_cond.y_cond.y_vector) == "y_internal":
+            y_vector = msidata\$$type_cond.y_cond.y_name
+        #elif str($type_cond.y_cond.y_vector) == "y_external":
+            y_tabular = read.delim("$type_cond.y_cond.y_data", header = FALSE, stringsAsFactors = FALSE)
+            y_vector = as.factor(y_tabular[,$type_cond.y_cond.y_column])
+            number_pixels = length(y_vector) ## should be same as in data
+        #end if
+
+    ## plot of y vector
+
+    position_df = cbind(coord(msidata)[,1:2], y_vector)
+    y_plot = ggplot(position_df, aes(x=x, y=y, fill=y_vector))+
+           geom_tile() +
+           coord_fixed()+
+           ggtitle("Distribution of the response variable y")+
+           theme_bw()+
+           theme(text=element_text(family="ArialMT", face="bold", size=15))+
+           theme(legend.position="bottom",legend.direction="vertical")+
+           guides(fill=guide_legend(ncol=4,byrow=TRUE))
+    coord_labels = aggregate(cbind(x,y)~y_vector, data=position_df, mean, na.rm=TRUE, na.action="na.pass")
+    coord_labels\$file_number = gsub( "_.*$", "", coord_labels\$y_vector)
+    print(y_plot)
+
+
+        ######################## PLS #############################
+        #if str( $type_cond.method_cond.class_method) == "PLS":
+            print("PLS")
+
+            ######################## PLS - CV #############################
+            #if str( $type_cond.method_cond.analysis_cond.PLS_method) == "cvapply":
+                print("PLS cv")
+
+                ## folds
+                #if str($type_cond.method_cond.analysis_cond.fold_cond.fold_vector) == "fold_internal":
+
+                    fold_vector = msidata\$$type_cond.method_cond.analysis_cond.fold_cond.fold_name
+                #elif str($type_cond.method_cond.analysis_cond.fold_cond.fold_vector) == "fold_external":
+                    fold_tabular = read.delim("$type_cond.method_cond.analysis_cond.fold_cond.fold_data", header = FALSE, stringsAsFactors = FALSE)
+                    fold_vector = as.factor(fold_tabular[,$type_cond.method_cond.analysis_cond.fold_cond.fold_column])
+                    number_pixels = length(fold_vector) ## should be same as in data
+                #end if
+
+                ## plot of folds
+
+                    position_df = cbind(coord(msidata)[,1:2], fold_vector)
+                    fold_plot = ggplot(position_df, aes(x=x, y=y, fill=fold_vector))+
+                           geom_tile() +
+                           coord_fixed()+
+                           ggtitle("Distribution of the fold variable")+
+                           theme_bw()+
+                           theme(text=element_text(family="ArialMT", face="bold", size=15))+
+                           theme(legend.position="bottom",legend.direction="vertical")+
+                           guides(fill=guide_legend(ncol=4,byrow=TRUE))
+                    coord_labels = aggregate(cbind(x,y)~fold_vector, data=position_df, mean, na.rm=TRUE, na.action="na.pass")
+                    coord_labels\$file_number = gsub( "_.*$", "", coord_labels\$fold_vector)
+                    print(fold_plot)
+
+                ## number of components
+                components = c($type_cond.method_cond.analysis_cond.plscv_comp)
+
+                ## PLS-cvApply:
+                msidata.cv.pls <- cvApply(msidata, .y = y_vector, .fold = fold_vector, .fun = "PLS", ncomp = components)
+
+                ## create table with summary
+                count = 1
+                summary_plscv = list()
+                accuracy_vector = numeric()
+                for (iteration in components){
+
+                    summary_iteration = summary(msidata.cv.pls)\$accuracy[[paste0("ncomp = ", iteration)]]
+                    summary_iteration = cbind(rownames(summary_iteration), summary_iteration) ## include rownames in table
+                    accuracy_vector[count] = summary_iteration[1,2] ## vector with accuracies to find later maximum for plot
+                    empty_row = c(paste0("ncomp = ", iteration), rep( "", length(levels(y_vector)))) ## add line with ncomp for each iteration
+                    ##rownames(labeled_iteration)[1] = paste0("ncomp = ", iteration)
+                    ##labeled_iteration = cbind(rownames(labeled_iteration), labeled_iteration)
+                    labeled_iteration = rbind(empty_row, summary_iteration)
+
+                    summary_plscv[[count]] = labeled_iteration
+                    count = count+1} ## create list with summary table for each component
+                ## create dataframe from list
+                summary_plscv = do.call(rbind, summary_plscv) 
+                summary_df = as.data.frame(summary_plscv)
+                rownames(summary_df) = NULL
+
+                ## plots
+                ## plot to find ncomp with highest accuracy
+                plot(summary(msidata.cv.pls), main="Accuracy of PLS classification")
+                ncomp_max = components[which.max(accuracy_vector)] ## find ncomp with max. accuracy
+                ## one image for each sample/fold, 4 images per page
+                image(msidata.cv.pls, model = list(ncomp = ncomp_max), layout = c(2, 2))
+
+                par(opar)   
+                ## print table with summary in pdf
+                plot(0,type='n',axes=FALSE,ann=FALSE)
+                title(main="Summary for the different components\n", adj=0.5)
+                ## summary for 4 components (20 rows) fits in one page:
+                if (length(components)<5){
+                    grid.table(summary_df, rows= NULL)
+                }else{
+                    grid.table(summary_df[1:20,], rows= NULL)
+                    mincount = 21
+                    maxcount = 40
+                    for (count20 in 1:(ceiling(nrow(summary_df)/20)-1)){
+                        plot(0,type='n',axes=FALSE,ann=FALSE)
+                        if (maxcount <= nrow(summary_df)){
+                            grid.table(summary_df[mincount:maxcount,], rows= NULL)
+                            mincount = mincount+20
+                            maxcount = maxcount+20
+                        }else{### stop last page with last sample otherwise NA in table
+                            grid.table(summary_df[mincount:nrow(summary_df),], rows= NULL)} 
+                    }
+                }
+
+                ## optional output as .RData
+                #if $output_rdata:
+                save(msidata.cv.pls, file="$classification_rdata")
+                #end if
+            ######################## PLS - analysis ###########################
+            #elif str( $type_cond.method_cond.analysis_cond.PLS_method) == "PLS_analysis":
+                print("PLS analysis")
+
+                ## number of components
+                component = c($type_cond.method_cond.analysis_cond.pls_comp)
+
+                ### pls analysis
+                msidata.pls <- PLS(msidata, y = y_vector, ncomp = component, scale=$type_cond.method_cond.analysis_cond.pls_scale)
+
+                ### plot of PLS coefficients
+                plot(msidata.pls, main="PLS coefficients per m/z")
+
+                ### summary table of PLS
+                summary_table = summary(msidata.pls)\$accuracy[[paste0("ncomp = ",component)]]
+                summary_table = cbind(rownames(summary_table), data.frame(summary_table))
+                rownames(summary_table) = NULL
+print(summary_table)
+                ###plot(0,type='n',axes=FALSE,ann=FALSE)
+                ###grid.table(test, rows= TRUE)
+
+                ### image of the best m/z
+                print(image(msidata, mz = topLabels(msidata.pls)[1,1], normalize.image = "linear", contrast.enhance = "histogram",smooth.image="gaussian", main="best m/z heatmap"))
+
+                ## m/z and pixel information output
+                pls_classes = data.frame(msidata.pls\$classes[[1]])
+                rownames(pls_classes) = names(pixels(msidata))
+                colnames(pls_classes) = "predicted diagnosis"
+                pls_toplabels = topLabels(msidata.pls, n=$type_cond.method_cond.analysis_cond.pls_toplabels)
+
+                write.table(pls_toplabels, file="$mzfeatures", quote = FALSE, row.names = TRUE, col.names=NA, sep = "\t")
+                write.table(pls_classes, file="$pixeloutput", quote = FALSE, row.names = TRUE, col.names=NA, sep = "\t")
+
+                ## optional output as .RData
+                #if $output_rdata:
+                save(msidata.pls, file="$classification_rdata")
+                #end if
+
+            #end if
+
+
+        ######################## OPLS #############################
+        #elif str( $type_cond.method_cond.class_method) == "OPLS":
+            print("OPLS")
+
+            ######################## OPLS -CV #############################
+            #if str( $type_cond.method_cond.opls_analysis_cond.opls_method) == "opls_cvapply":
+                print("OPLS cv")
+
+                ## folds
+                #if str($type_cond.method_cond.opls_analysis_cond.opls_fold_cond.opls_fold_vector) == "opls_fold_internal":
+                    fold_vector = msidata\$$type_cond.method_cond.opls_analysis_cond.opls_fold_cond.opls_fold_name
+                #elif str($type_cond.method_cond.opls_analysis_cond.opls_fold_cond.opls_fold_vector) == "opls_fold_external":
+                    fold_tabular = read.delim("$type_cond.method_cond.opls_analysis_cond.opls_fold_cond.opls_fold_data", header = FALSE, stringsAsFactors = FALSE)
+                    fold_vector = as.factor(fold_tabular[,$type_cond.method_cond.opls_analysis_cond.opls_fold_cond.opls_fold_column])
+                    number_pixels = length(fold_vector) ## should be same as in data
+                #end if
+
+                ## plot of folds
+
+                position_df = cbind(coord(msidata)[,1:2], fold_vector)
+                fold_plot = ggplot(position_df, aes(x=x, y=y, fill=fold_vector))+
+                       geom_tile() +
+                       coord_fixed()+
+                       ggtitle("Distribution of the fold variable")+
+                       theme_bw()+
+                       theme(text=element_text(family="ArialMT", face="bold", size=15))+
+                       theme(legend.position="bottom",legend.direction="vertical")+
+                       guides(fill=guide_legend(ncol=4,byrow=TRUE))
+                coord_labels = aggregate(cbind(x,y)~fold_vector, data=position_df, mean, na.rm=TRUE, na.action="na.pass")
+                coord_labels\$file_number = gsub( "_.*$", "", coord_labels\$fold_vector)
+                print(fold_plot)
+
+                ## number of components
+                components = c($type_cond.method_cond.opls_analysis_cond.opls_cvcomp)
+
+                ## OPLS-cvApply:
+                msidata.cv.opls <- cvApply(msidata, .y = y_vector, .fold = fold_vector, .fun = "OPLS", ncomp = components, keep.Xnew = $type_cond.method_cond.opls_analysis_cond.xnew_cv)
+
+                ## create table with summary
+                count = 1
+                summary_oplscv = list()
+                accuracy_vector = numeric()
+                for (iteration in components){
+                    summary_iteration = summary(msidata.cv.opls)\$accuracy[[paste0("ncomp = ", iteration)]]
+                    summary_iteration = cbind(rownames(summary_iteration), summary_iteration) ## include rownames in table
+                    accuracy_vector[count] = summary_iteration[1,2] ## vector with accuracies to find later maximum for plot
+                    empty_row = c(paste0("ncomp = ", iteration), rep( "", length(levels(y_vector)))) ## add line with ncomp for each iteration
+                    ##rownames(labeled_iteration)[1] = paste0("ncomp = ", iteration)
+                    ##labeled_iteration = cbind(rownames(labeled_iteration), labeled_iteration)
+                    labeled_iteration = rbind(empty_row, summary_iteration)
+                    summary_oplscv[[count]] = labeled_iteration ## create list with summary table for each component
+                    count = count+1} 
+                ## create dataframe from list
+                summary_oplscv = do.call(rbind, summary_oplscv) 
+                summary_df = as.data.frame(summary_oplscv)
+                rownames(summary_df) = NULL
+
+                ## plots
+                ## plot to find ncomp with highest accuracy
+                plot(summary(msidata.cv.opls), main="Accuracy of OPLS classification")
+                ncomp_max = components[which.max(accuracy_vector)] ## find ncomp with max. accuracy
+                ## one image for each sample/fold, 4 images per page
+                image(msidata.cv.opls, model = list(ncomp = ncomp_max), layout = c(2, 2))
+
+                par(opar)   
+                ## print table with summary in pdf
+                plot(0,type='n',axes=FALSE,ann=FALSE)
+                title(main="Summary for the different components\n", adj=0.5)
+                ## summary for 4 components (20 rows) fits in one page:
+                if (length(components)<5){
+                    grid.table(summary_df, rows= NULL)
+                }else{
+                    grid.table(summary_df[1:20,], rows= NULL)
+                    mincount = 21
+                    maxcount = 40
+                    for (count20 in 1:(ceiling(nrow(summary_df)/20)-1)){
+                        plot(0,type='n',axes=FALSE,ann=FALSE)
+                        if (maxcount <= nrow(summary_df)){
+                            grid.table(summary_df[mincount:maxcount,], rows= NULL)
+                            mincount = mincount+20
+                            maxcount = maxcount+20
+                        }else{### stop last page with last sample otherwise NA in table
+                            grid.table(summary_df[mincount:nrow(summary_df),], rows= NULL)} 
+                    }
+                }
+
+                ## optional output as .RData
+                #if $output_rdata:
+                save(msidata.cv.opls, file="$classification_rdata")
+                #end if
+
+            ######################## OPLS -analysis ###########################
+            #elif str( $type_cond.method_cond.opls_analysis_cond.opls_method) == "opls_analysis":
+                print("OPLS analysis")
+
+                ## number of components
+                component = c($type_cond.method_cond.opls_analysis_cond.opls_comp)
+
+                ### opls analysis
+                msidata.opls <- PLS(msidata, y = y_vector, ncomp = component, scale=$type_cond.method_cond.opls_analysis_cond.opls_scale, keep.Xnew = $type_cond.method_cond.opls_analysis_cond.xnew)
+
+                ### plot of OPLS coefficients
+                plot(msidata.opls, main="OPLS coefficients per m/z")
+
+                ### summary table of OPLS
+                summary_table = summary(msidata.opls)\$accuracy[[paste0("ncomp = ",component)]]
+                summary_table = cbind(rownames(summary_table), summary_table)
+                rownames(summary_table) = NULL
+                summary_table = data.frame(summary_table)
+                print(summary_table)
+                ###plot(0,type='n',axes=FALSE,ann=FALSE)
+                ###grid.table(test, rows= TRUE)
+
+                ### image of the best m/z
+                print(image(msidata, mz = topLabels(msidata.opls)[1,1], normalize.image = "linear", contrast.enhance = "histogram",smooth.image="gaussian", main="best m/z heatmap"))
+
+                ## m/z and pixel information output
+                opls_classes = data.frame(msidata.opls\$classes[[1]])
+                rownames(opls_classes) = names(pixels(msidata))
+                colnames(opls_classes) = "predicted diagnosis"
+                opls_toplabels = topLabels(msidata.opls, n=$type_cond.method_cond.opls_analysis_cond.opls_toplabels)
+
+                write.table(opls_toplabels, file="$mzfeatures", quote = FALSE, row.names = TRUE, col.names=NA, sep = "\t")
+                write.table(opls_classes, file="$pixeloutput", quote = FALSE, row.names = TRUE, col.names=NA, sep = "\t")
+
+                ## optional output as .RData
+                #if $output_rdata:
+                save(msidata.opls, file="$classification_rdata")
+                #end if
+
+            #end if
+
+        ######################## SSC #############################
+        #elif str( $type_cond.method_cond.class_method) == "spatialShrunkenCentroids":
+            print("SSC")
+
+            ######################## SSC - CV #############################
+            #if str( $type_cond.method_cond.ssc_analysis_cond.ssc_method) == "ssc_cvapply":
+                print("SSC cv")
+
+                ## folds
+                #if str($type_cond.method_cond.ssc_analysis_cond.ssc_fold_cond.ssc_fold_vector) == "ssc_fold_internal":
+                    fold_vector = msidata\$$type_cond.method_cond.ssc_analysis_cond.ssc_fold_cond.ssc_fold_name
+
+                #elif str($type_cond.method_cond.ssc_analysis_cond.ssc_fold_cond.ssc_fold_vector) == "ssc_fold_external":
+                    fold_tabular = read.delim("$type_cond.method_cond.ssc_analysis_cond.ssc_fold_cond.ssc_fold_data", header = FALSE, stringsAsFactors = FALSE)
+                    fold_vector = as.factor(fold_tabular[,$type_cond.method_cond.ssc_analysis_cond.ssc_fold_cond.ssc_fold_column])
+                    number_pixels = length(fold_vector) ## should be same as in data
+                #end if
+
+                ## plot of folds
+                position_df = cbind(coord(msidata)[,1:2], fold_vector)
+                fold_plot = ggplot(position_df, aes(x=x, y=y, fill=fold_vector))+
+                       geom_tile() +
+                       coord_fixed()+
+                       ggtitle("Distribution of the fold variable")+
+                       theme_bw()+
+                       theme(text=element_text(family="ArialMT", face="bold", size=15))+
+                       theme(legend.position="bottom",legend.direction="vertical")+
+                       guides(fill=guide_legend(ncol=4,byrow=TRUE))
+                coord_labels = aggregate(cbind(x,y)~fold_vector, data=position_df, mean, na.rm=TRUE, na.action="na.pass")
+                coord_labels\$file_number = gsub( "_.*$", "", coord_labels\$fold_vector)
+                print(fold_plot)
+
+                ## SSC-cvApply:
+                msidata.cv.ssc <- cvApply(msidata, .y = y_vector,.fold = fold_vector,.fun = "spatialShrunkenCentroids", r = c($type_cond.method_cond.ssc_r), s = c($type_cond.method_cond.ssc_s), method = "$type_cond.method_cond.ssc_kernel_method")
+
+                ## create table with summary
+                count = 1
+                summary_ssccv = list()
+                accuracy_vector = numeric()
+
+                for (iteration in names(msidata.cv.ssc@resultData[[1]][,1])){
+                    summary_iteration = summary(msidata.cv.ssc)\$accuracy[[iteration]]
+                    summary_iteration = cbind(rownames(summary_iteration), summary_iteration) ## include rownames in table
+                    accuracy_vector[count] = summary_iteration[1,2] ## vector with accuracies to find later maximum for plot
+                    empty_row = c(iteration, rep( "", length(levels(y_vector)))) ## add line with ncomp for each iteration
+                    labeled_iteration = rbind(empty_row, summary_iteration)
+                    summary_ssccv[[count]] = labeled_iteration ## create list with summary table for each component
+                    count = count+1
+                }
+
+                ##create dataframe from list
+                summary_ssccv = do.call(rbind, summary_ssccv) 
+                summary_df = as.data.frame(summary_ssccv)
+                rownames(summary_df) = NULL
+
+                ## plot to find parameters with highest accuracy
+                plot(summary(msidata.cv.ssc), main="Accuracy of SSC classification")
+                best_params = names(msidata.cv.ssc@resultData[[1]][,1])[which.max(accuracy_vector)] ## find parameters with max. accuracy
+                r_value = as.numeric(substring(unlist(strsplit(best_params, ","))[1], 4))
+                s_value = as.numeric(substring(unlist(strsplit(best_params, ","))[3], 5)) ## remove space
+
+                image(msidata.cv.ssc, model = list( r = r_value, s = s_value ), layout=c(2,2))
+
+                par(opar)
+                ## print table with summary in pdf
+                plot(0,type='n',axes=FALSE,ann=FALSE)
+                title(main="Summary for the different parameters\n", adj=0.5)
+                ## summary for 4 parameters (20 rows) fits in one page:
+                if (length(names(msidata.cv.ssc@resultData[[1]][,1]))<5){
+                    grid.table(summary_df, rows= NULL)
+                }else{
+                    grid.table(summary_df[1:20,], rows= NULL)
+                    mincount = 21
+                    maxcount = 40
+                    for (count20 in 1:(ceiling(nrow(summary_df)/20)-1)){
+                        plot(0,type='n',axes=FALSE,ann=FALSE)
+                        if (maxcount <= nrow(summary_df)){
+                            grid.table(summary_df[mincount:maxcount,], rows= NULL)
+                            mincount = mincount+20
+                            maxcount = maxcount+20
+                        }else{### stop last page with last sample otherwise NA in table
+                            grid.table(summary_df[mincount:nrow(summary_df),], rows= NULL)} 
+                    }
+                }
+
+                ## optional output as .RData
+                #if $output_rdata:
+                save(msidata.cv.opls, file="$classification_rdata")
+                #end if
+
+            ######################## SSC -analysis ###########################
+            #elif str( $type_cond.method_cond.ssc_analysis_cond.ssc_method) == "ssc_analysis":
+                print("SSC analysis")
+
+                ## SSC analysis
+                msidata.ssc <- spatialShrunkenCentroids(msidata, y = y_vector, .fold = fold_vector, 
+r = c($type_cond.method_cond.ssc_r), s = c($type_cond.method_cond.ssc_s), method = "$type_cond.method_cond.ssc_kernel_method")
+
+                plot(msidata.ssc, mode = "tstatistics", model = list("r" = c($type_cond.method_cond.ssc_r), "s" = c($type_cond.method_cond.ssc_s)))
+
+                ### summary table SSC
+
+                ##summary(msidata.ssc)\$accuracy[[names(msidata.ssc@resultData)]]
+                summary_table = summary(msidata.ssc)
+print(summary_table)
+                ##summary_table = cbind(rownames(summary_table), summary_table)
+                ##rownames(summary_table) = NULL
+
+                ###plot(0,type='n',axes=FALSE,ann=FALSE)
+                ###grid.table(summary_table, rows= TRUE)
+
+                ### image of the best m/z
+                print(image(msidata, mz = topLabels(msidata.ssc)[1,1], normalize.image = "linear", contrast.enhance = "histogram",smooth.image="gaussian", main="best m/z heatmap"))
+
+                ## m/z and pixel information output
+                ssc_classes = data.frame(msidata.ssc\$classes[[1]])
+                rownames(ssc_classes) = names(pixels(msidata))
+                colnames(ssc_classes) = "predicted diagnosis"
+                ssc_toplabels = topLabels(msidata.ssc)
+
+                write.table(ssc_toplabels, file="$mzfeatures", quote = FALSE, row.names = TRUE, col.names=NA, sep = "\t")
+                write.table(ssc_classes, file="$pixeloutput", quote = FALSE, row.names = TRUE, col.names=NA, sep = "\t")
+
+                ## optional output as .RData
+                #if $output_rdata:
+                save(msidata.ssc, file="$classification_rdata")
+                #end if
+
+            #end if
+        #end if
+
+
+    ######################## II) Prediction #############################
+    #############################################################################
+    #elif str( $type_cond.type_method) == "prediction":
+        print("prediction")
+
+        #if str($type_cond.new_y.new_y_values) == "no_new_y": 
+            new_y_vector = FALSE
+        #elif str($type_cond.new_y.new_y_values) == "new_y_internal":
+            new_y_vector = msidata\$$type_cond.new_y.new_y_name
+        #elif str($type_cond.new_y.new_y_values) == "new_y_external":
+            
+            new_y_tabular = read.delim("$type_cond.new_y.new_y_data", header = FALSE, stringsAsFactors = FALSE)
+            new_y_vector = new_y_tabular[,$type_cond.new_y.new_y_column]
+            number_pixels = length(new_y_vector) ## should be same as in data
+        #end if
+
+        training_data = loadRData("$type_cond.training_result")
+        prediction = predict(training_data,msidata, newy = new_y_vector)
+
+        ## optional output as .RData
+        #if $output_rdata:
+        msidata = prediction
+        save(msidata, file="$classification_rdata")
+        #end if
+    #end if
+
+    dev.off()
+}else{
+    print("Inputfile has no intensities > 0")
+    dev.off()
+}
+
+    ]]></configfile>
+    </configfiles>
+    <inputs>
+        <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="processed_cond">
+            <param name="processed_file" type="select" label="Is the input file a processed imzML file ">
+                <option value="no_processed" selected="True">not a processed imzML</option>
+                <option value="processed">processed imzML</option>
+            </param>
+            <when value="no_processed"/>
+            <when value="processed">
+                <param name="accuracy" type="float" value="50" label="Mass accuracy to which the m/z values will be binned" help="This should be set to the native accuracy of the mass spectrometer, if known"/>
+                <param name="units" display="radio" type="select" label="Unit of the mass accuracy" help="either m/z or ppm">
+                    <option value="mz" >mz</option>
+                    <option value="ppm" selected="True" >ppm</option>
+                </param>
+            </when>
+        </conditional>
+
+        <conditional name="type_cond">
+            <param name="type_method" type="select" label="Analysis step to perform">
+                <option value="training" selected="True">training</option>
+                <option value="prediction">prediction</option>
+            </param>
+            <when value="training">
+
+                <conditional name="method_cond">
+                    <param name="class_method" type="select" label="Select the method for classification">
+                        <option value="PLS" selected="True">PLS</option>
+                        <option value="OPLS">OPLS</option>
+                        <option value="spatialShrunkenCentroids">spatial shrunken centroids</option>
+                    </param>
+                    <when value="PLS">
+
+                        <conditional name="analysis_cond">
+                            <param name="PLS_method" type="select" label="Crossvalidation or analysis">
+                                <option value="cvapply" selected="True">cvApply</option>
+                                <option value="PLS_analysis">PLS analysis</option>
+                            </param>
+                            <when value="cvapply">
+
+                                <param name="plscv_comp" type="text" value="1:2"
+                                       label="The number of PLS components" help="Multiple values are allowed (e.g. 1,2,3 or 2:5)"/>
+                                <conditional name="fold_cond">
+                                    <param name="fold_vector" type="select" label="Define the fold variable">
+                                        <option value="fold_internal" selected="True">dataset contains already fold</option>
+                                        <option value="fold_external">use fold from tabular file</option>
+                                    </param>
+                                    <when value="fold_internal">
+                                        <param name="fold_name" type="text" value="sample" label="Name of the pData slot where fold is stored" help="each fold must contain pixels of all categories"/>
+                                    </when>
+                                    <when value="fold_external">
+                                        <param name="fold_data" type="data" format="tabular" label="Tabular file with column for folds" help="Number of rows must be number of pixels"/>
+                                        <param name="fold_column" data_ref="fold_data" label="Column with folds" type="data_column"/>
+                                    </when>
+                                </conditional>
+                            </when>
+
+                            <when value="PLS_analysis">
+                                <param name="pls_comp" type="integer" value="5"
+                                       label="The optimal number of PLS components as indicated by cross-validations" help="Run cvApply first to optain optiaml number of PLS components"/>
+                                <param name="pls_scale" type="boolean" display="radio" label="data scaling" truevalue="TRUE" falsevalue="FALSE"/>
+                                <param name="pls_toplabels" type="integer" value="100"
+                                   label="Number of toplabels (masses) which should be written in tabular output"/>
+                            </when>
+                        </conditional>
+                    </when>
+
+                    <when value="OPLS">
+
+                        <conditional name="opls_analysis_cond">
+                            <param name="opls_method" type="select" label="Analysis step to perform">
+                                <option value="opls_cvapply" selected="True">cvApply</option>
+                                <option value="opls_analysis">OPLS analysis</option>
+                            </param>
+
+                            <when value="opls_cvapply">
+                                <param name="opls_cvcomp" type="text" value="1:2"
+                                       label="The number of OPLS components" help="Multiple values are allowed (e.g. 1,2,3 or 2:5)"/>
+                                <param name="xnew_cv" type="boolean" display="radio" truevalue="TRUE" falsevalue="FALSE" label="Keep new matrix"/>
+                                <conditional name="opls_fold_cond">
+                                    <param name="opls_fold_vector" type="select" label="Define the fold variable">
+                                        <option value="opls_fold_internal" selected="True">dataset contains already fold</option>
+                                        <option value="opls_fold_external">use fold from tabular file</option>
+                                    </param>
+                                    <when value="opls_fold_internal">
+                                        <param name="opls_fold_name" type="text" value="sample" label="Name of the pData slot where fold is stored" help="each fold must contain pixels of all categories"/>
+                                    </when>
+                                    <when value="opls_fold_external">
+                                        <param name="opls_fold_data" type="data" format="tabular" label="Tabular file with column for folds" help="Number of rows must be number of pixels"/>
+                                        <param name="opls_fold_column" data_ref="opls_fold_data" label="Column with folds" type="data_column"/>
+                                    </when>
+                                </conditional>
+                            </when>
+
+                            <when value="opls_analysis">
+                                <param name="opls_comp" type="integer" value="5"
+                                       label="The optimal number of PLS components as indicated by cross-validations" help="Run cvApply first to optain optiaml number of PLS components"/>
+                                <param name="xnew" type="boolean" display="radio" truevalue="TRUE" falsevalue="FALSE" label="Keep new matrix"/>                                
+                                <param name="opls_scale" type="select" label="data scaling" display="radio" optional="False">
+                                    <option value="TRUE">yes</option>
+                                    <option value="FALSE" selected="True">no</option>
+                               </param>
+                                <param name="opls_toplabels" type="integer" value="100"
+                                   label="Number of toplabels (features) which should be written in tabular output"/>
+                            </when>
+                        </conditional>
+                    </when>
+
+                    <when value="spatialShrunkenCentroids">
+                        <conditional name="ssc_analysis_cond">
+                            <param name="ssc_method" type="select" label="Analysis step to perform">
+                                <option value="ssc_cvapply" selected="True">cvApply</option>
+                                <option value="ssc_analysis">spatial shrunken centroids analysis</option>
+                            </param>
+                            <when value="ssc_cvapply">
+
+                                <conditional name="ssc_fold_cond">
+                                    <param name="ssc_fold_vector" type="select" label="Define the fold variable">
+                                        <option value="ssc_fold_internal" selected="True">dataset contains already fold</option>
+                                        <option value="ssc_fold_external">use fold from tabular file</option>
+                                    </param>
+                                    <when value="ssc_fold_internal">
+                                        <param name="ssc_fold_name" type="text" value="sample" label="Name of the pData slot where fold is stored" help="each fold must contain pixels of all categories"/>
+                                    </when>
+                                    <when value="ssc_fold_external">
+                                        <param name="ssc_fold_data" type="data" format="tabular" label="Tabular file with column for folds" help="Number of rows must be number of pixels"/>
+                                        <param name="ssc_fold_column" data_ref="ssc_fold_data" label="Column with folds" type="data_column"/>
+                                    </when>
+                                </conditional>
+                            </when>
+
+                            <when value="ssc_analysis">
+
+                                <param name="ssc_toplabels" type="integer" value="100"
+                                   label="Number of toplabels (features) which should be written in tabular output"/>
+                            </when>
+                        </conditional>
+                        <param name="ssc_r" type="text" value="2"
+                               label="The spatial neighborhood radius of nearby pixels to consider (r)" help="For cvapply multiple values are allowed (e.g. 1,2,3 or 2:5)"/>
+                        <param name="ssc_s" type="text" value="2"
+                               label="The sparsity thresholding parameter by which to shrink the t-statistics (s)" help="For cvapply multiple values are allowed (e.g. 1,2,3 or 2:5)"/>
+                        <param name="ssc_kernel_method" type="select" display="radio" label = "The method to use to calculate the spatial smoothing kernels for the embedding. The 'gaussian' method refers to spatially-aware (SA) weights, and 'adaptive' refers to spatially-aware structurally-adaptive (SASA) weights">
+                            <option value="gaussian">gaussian</option>
+                            <option value="adaptive" selected="True">adaptive</option>
+                        </param>
+
+                    </when>
+                </conditional>
+                <conditional name="y_cond">
+                    <param name="y_vector" type="select" label="Define the response variable y">
+                        <option value="y_internal" selected="True">dataset contains already y</option>
+                        <option value="y_external">use y from tabular file</option>
+                    </param>
+                    <when value="y_internal">
+                        <param name="y_name" type="text" value="combined_sample" label="Name of the pData slot where y is stored" help="Outputs of MSI_combine tool have 'combined_sample' as name"/>
+                    </when>
+                    <when value="y_external">
+                        <param name="y_data" type="data" format="tabular" label="Tabular file with column for y response"/>
+                        <param name="y_column" data_ref="y_data" label="Column with y response" type="data_column"/>
+                    </when>
+                </conditional>
+            </when>
+
+            <when value="prediction">
+                <param name="training_result" type="data" format="rdata" label="Result from previous classification training"/>
+                <conditional name="new_y">
+                    <param name="new_y_values" type="select" label="Define the new response y">
+                        <option value="no_new_y" >no new y response</option>
+                        <option value="new_y_internal" selected="True">dataset contains already y</option>
+                        <option value="new_y_external">use y from tabular file</option>
+                    </param>
+                    <when value="no_new_y"/>
+                    <when value="new_y_internal">
+                        <param name="new_y_name" type="text" value="combined_sample" label="Name of the pData slot where y is stored" help="data merged with MSI_combine tool has 'combined_sample' as name"/>
+                    </when>
+
+                    <when value="new_y_external">
+                        <param name="new_y_data" type="data" format="tabular" label="Tabular file with column for y response"/>
+                        <param name="new_y_column" data_ref="new_y_data" label="Column with y response" type="data_column"/>
+                    </when>
+                </conditional>
+            </when>
+        </conditional>
+        <param name="output_rdata" type="boolean" display="radio" label="Results as .RData output"/>
+    </inputs>
+    <outputs>
+        <data format="pdf" name="classification_images" from_work_dir="classificationpdf.pdf" label = "$infile.display_name classification"/>
+        <data format="tabular" name="mzfeatures" label="$infile.display_name features"/>
+        <data format="tabular" name="pixeloutput" label="$infile.display_name pixels"/>
+        <data format="rdata" name="classification_rdata" label="$infile.display_name classification">
+            <filter>output_rdata</filter>
+        </data>
+    </outputs>
+    <tests>
+        <test expect_num_outputs="3">
+            <param name="infile" value="testfile_squares.rdata" ftype="rdata"/>
+            <conditional name="type_cond">
+                <param name="type_method" value="training"/>
+                <conditional name="method_cond">
+                    <param name="class_method" value="PLS"/>
+                    <conditional name="analysis_cond">
+                        <param name="PLS_method" value="cvapply"/>
+
+                        <param name="plscv_comp" value="2:4"/>
+                        <conditional name="fold_cond">
+                            <param name="fold_vector" value="fold_external"/>
+                            <param name="fold_data" value="pixel_annotation_file1.tabular" ftype="tabular"/>
+                            <param name="fold_column" value="1"/>
+                        </conditional>
+
+                    </conditional>
+                </conditional>
+                <conditional name="y_cond">
+                    <param name="y_vector" value="y_external"/>
+                    <param name="y_data" value="pixel_annotation_file1.tabular" ftype="tabular"/>
+                    <param name="y_column" value="2"/>
+                </conditional>
+            </conditional>
+            <output name="mzfeatures" file="features_test1.tabular"/>
+            <output name="pixeloutput" file="pixels_test1.tabular"/>
+            <output name="classification_images" file="test1.pdf" compare="sim_size" delta="20000"/>
+        </test>
+
+        <test expect_num_outputs="4">
+            <param name="infile" value="testfile_squares.rdata" ftype="rdata"/>
+            <conditional name="type_cond">
+                <param name="type_method" value="training"/>
+                <conditional name="method_cond">
+                    <param name="class_method" value="PLS"/>
+                    <conditional name="analysis_cond">
+                        <param name="PLS_method" value="PLS_analysis"/>
+
+                        <param name="pls_comp" value="2"/>
+                        <param name="pls_scale" value="TRUE"/>
+                        <param name="pls_toplabels" value="100"/>
+                        <conditional name="fold_cond">
+                            <param name="fold_vector" value="fold_external"/>
+                            <param name="fold_data" value="pixel_annotation_file1.tabular" ftype="tabular"/>
+                            <param name="fold_column" value="1"/>
+                        </conditional>
+
+                    </conditional>
+                </conditional>
+                <conditional name="y_cond">
+                    <param name="y_vector" value="y_external"/>
+                    <param name="y_data" value="pixel_annotation_file1.tabular" ftype="tabular"/>
+                    <param name="y_column" value="2"/>
+                </conditional>
+            </conditional>
+            <param name="output_rdata" value="True"/>
+            <output name="mzfeatures" file="features_test2.tabular"/>
+            <output name="pixeloutput" file="pixels_test2.tabular"/>
+            <output name="classification_images" file="test2.pdf" compare="sim_size" delta="20000"/>
+            <output name="classification_rdata" file="test2.rdata" compare="sim_size" />
+        </test>
+
+        <test expect_num_outputs="3">
+            <param name="infile" value="testfile_squares.rdata" ftype="rdata"/>
+            <conditional name="type_cond">
+                <param name="type_method" value="training"/>
+                <conditional name="method_cond">
+                    <param name="class_method" value="OPLS"/>
+                    <conditional name="opls_analysis_cond">
+                        <param name="opls_method" value="opls_analysis"/>
+
+                        <param name="opls_cvcomp" value="1:2"/>
+                        <param name="xnew_cv" value="FALSE"/>
+                        <conditional name="opls_fold_cond">
+                            <param name="opls_fold_vector" value="opls_fold_external"/>
+                            <param name="opls_fold_data" ftype="tabular" value="random_factors.tabular"/>
+                            <param name="opls_fold_column" value="1"/>
+                        </conditional>
+                    </conditional>
+                </conditional>
+                <conditional name="y_cond">
+                    <param name="y_vector" value="y_external"/>
+                    <param name="y_data" value="random_factors.tabular" ftype="tabular"/>
+                    <param name="y_column" value="2"/>
+                </conditional>
+            </conditional>
+            <output name="mzfeatures" file="features_test3.tabular"/>
+            <output name="pixeloutput" file="pixels_test3.tabular"/>
+            <output name="classification_images" file="test3.pdf" compare="sim_size" delta="20000"/>
+        </test>
+
+        <test expect_num_outputs="4">
+            <param name="infile" value="testfile_squares.rdata" ftype="rdata"/>
+            <conditional name="type_cond">
+                <param name="type_method" value="training"/>
+                <conditional name="method_cond">
+                    <param name="class_method" value="OPLS"/>
+                    <conditional name="opls_analysis_cond">
+
+                        <param name="opls_method" value="opls_analysis"/>
+                        <param name="opls_comp" value="3"/>
+                        <param name="xnew" value="FALSE"/>
+                        <param name="opls_scale" value="FALSE"/>
+                        <param name="opls_toplabels" value="100"/>
+                    </conditional>
+
+                </conditional>
+                <conditional name="y_cond">
+                    <param name="y_vector" value="y_external"/>
+                    <param name="y_data" value="random_factors.tabular" ftype="tabular"/>
+                    <param name="y_column" value="2"/>
+                </conditional>
+            </conditional>
+            <param name="output_rdata" value="True"/>
+            <output name="mzfeatures" file="features_test4.tabular"/>
+            <output name="pixeloutput" file="pixels_test4.tabular"/>
+            <output name="classification_images" file="test4.pdf" compare="sim_size" delta="20000"/>
+            <output name="classification_rdata" file="test4.rdata" compare="sim_size" />
+        </test>
+
+        <test expect_num_outputs="3">
+            <param name="infile" value="testfile_squares.rdata" ftype="rdata"/>
+            <conditional name="type_cond">
+                <param name="type_method" value="training"/>
+                <conditional name="method_cond">
+                    <param name="class_method" value="spatialShrunkenCentroids"/>
+                    <conditional name="ssc_analysis_cond">
+                        <param name="ssc_method" value="ssc_cvapply"/>
+                        <conditional name="ssc_fold_cond">
+                            <param name="ssc_fold_vector" value="ssc_fold_external"/>
+                            <param name="ssc_fold_data" value="pixel_annotation_file1.tabular" ftype="tabular"/>
+                            <param name="ssc_fold_column" value="1"/>
+                        </conditional>
+                        <param name="ssc_r" value="1:2"/>
+                        <param name="ssc_s" value="2:3"/>
+                        <param name="ssc_kernel_method" value="adaptive"/>
+                    </conditional>
+                </conditional>
+                <conditional name="y_cond">
+                    <param name="y_vector" value="y_external"/>
+                    <param name="y_data" value="pixel_annotation_file1.tabular" ftype="tabular"/>
+                    <param name="y_column" value="2"/>
+                </conditional>
+            </conditional>
+            <output name="mzfeatures" file="features_test5.tabular"/>
+            <output name="pixeloutput" file="pixels_test5.tabular"/>
+            <output name="classification_images" file="test5.pdf" compare="sim_size" delta="20000"/>
+        </test>
+
+        <test expect_num_outputs="4">
+            <param name="infile" value="testfile_squares.rdata" ftype="rdata"/>
+            <conditional name="type_cond">
+                <param name="type_method" value="training"/>
+                <conditional name="method_cond">
+                    <param name="class_method" value="spatialShrunkenCentroids"/>
+                    <conditional name="ssc_analysis_cond">
+                        <param name="ssc_method" value="ssc_analysis"/>
+                        <param name="ssc_toplabels" value="100"/>
+                     </conditional>
+                    <param name="ssc_r" value="2"/>
+                    <param name="ssc_s" value="2"/>
+                    <param name="ssc_kernel_method" value="adaptive"/>
+                </conditional>
+                <conditional name="y_cond">
+                    <param name="y_vector" value="y_external"/>
+                    <param name="y_data" value="random_factors.tabular" ftype="tabular"/>
+                    <param name="y_column" value="2"/>
+                </conditional>
+            </conditional>
+            <param name="output_rdata" value="True"/>
+            <output name="mzfeatures" file="features_test6.tabular"/>
+            <output name="pixeloutput" file="pixels_test6.tabular"/>
+            <output name="classification_images" file="test6.pdf" compare="sim_size" delta="20000"/>
+            <output name="classification_rdata" file="test6.rdata" compare="sim_size" />
+        </test>
+
+        <test expect_num_outputs="4">
+            <param name="infile" value="testfile_squares.rdata" ftype="rdata"/>
+            <conditional name="type_cond">
+                <param name="type_method" value="prediction"/>
+                <param name="training_result" value="test2.rdata" ftype="rdata"/>
+                <conditional name="new_y">
+                    <param name="new_y_values" value="new_y_external"/>
+                    <param name="new_y_data" value="pixel_annotation_file1.tabular" ftype="tabular"/>
+                        <param name="new_y_column" value="2"/>
+                </conditional>
+            </conditional>
+            <param name="output_rdata" value="True"/>
+            <output name="mzfeatures" file="features_test7.tabular"/>
+            <output name="pixeloutput" file="pixels_test7.tabular"/>
+            <output name="classification_images" file="test7.pdf" compare="sim_size" delta="20000"/>
+            <output name="classification_rdata" file="test7.rdata" compare="sim_size" />
+        </test>
+
+    </tests>
+    <help>
+        <![CDATA[
+
+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 three different Cardinal functions for supervised classification of mass-spectrometry imaging data.
+
+Input data: 3 types of input data can be used:
+
+- imzml file (upload imzml and ibd file via the "composite" function) `Introduction to the imzml format <https://ms-imaging.org/wp/imzml/>`_
+- Analyze7.5 (upload hdr, img and t2m file via the "composite" function)
+- Cardinal "MSImageSet" data (with variable name "msidata", saved as .RData)
+
+Options: 
+
+- PLS(-DA): partial least square (discriminant analysis)
+- O-PLS(-DA): Orthogonal partial least squares (discriminant analysis)
+- Spatial shrunken centroids
+
+Output: 
+
+- Pdf with the heatmaps and plots for the classification
+- Tabular file with information on masses and pixels: toplabels/classes (PLS, spatial shrunken centroids)
+- optional RData output to further explore the results with Cardinal in R
+
+        ]]>
+    </help>
+    <citations>
+        <citation type="doi">10.1093/bioinformatics/btv146</citation>
+    </citations>
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/features_test2.tabular	Fri Jul 06 14:12:51 2018 -0400
@@ -0,0 +1,101 @@
+	mz	ncomp	column	coefficients	loadings	weights
+1	938.823120117188	2	1	0.00557062672565914	0.0521481794011343	0.0618954239030616
+2	938.859741210938	2	1	0.00542130109915229	0.0573197814782043	0.0556644462038001
+3	952.817016601562	2	1	0.00540658997062797	0.0541785607809472	0.0556957101293819
+4	980.9658203125	2	1	0.00530572666388636	0.0640830071706491	0.0596133867741965
+5	948.876525878906	2	1	0.00513396526933383	0.0580901569940297	0.0501389238916535
+6	926.022705078125	2	1	0.00495042111443777	0.0562851962915777	0.0443394574239625
+7	964.835876464844	2	1	0.00488062440395858	0.0565204963990886	0.0549598184884737
+8	982.013427734375	2	1	0.00485621047514792	0.048802383602383	0.0509744856714613
+9	995.19384765625	2	1	0.00481790774594767	0.0605795860610914	0.0530033855827968
+10	980.591796875	2	1	0.00471855619365328	0.0571816843146788	0.0534415807414751
+11	907.976257324219	2	1	0.00469109890013257	0.0610286466128535	0.0524345088122848
+12	907.0048828125	2	1	0.0046524995163741	0.0496389045323984	0.0487703720171644
+13	950.238220214844	2	3	0.00463861915222127	-0.0340558630529817	-0.0306112282051999
+14	995.985229492188	2	1	0.00462557611263778	0.0467967955160554	0.0558164362558804
+15	921.521667480469	2	1	0.00462412758928141	0.0492116848139342	0.0499849768568264
+16	915.04345703125	2	1	0.00454006262432388	0.0462339924711474	0.0425994231878204
+17	929.514953613281	2	1	0.00453623375772606	0.0563841702252104	0.045238258655595
+18	958.31787109375	2	1	0.00450679164876951	0.0459566089567639	0.0423653141505111
+19	962.870727539062	2	3	0.00448138616027361	-0.0581767564414316	-0.0599267135196269
+20	942.412719726562	2	1	0.00446754249696574	0.0526251413421558	0.0499585152758468
+21	922.065551757812	2	1	0.00446641275611493	0.0495906378625035	0.049953814799021
+22	918.261596679688	2	3	0.00445234724107087	-0.0158931585724287	-0.014157529428659
+23	973.64794921875	2	1	0.00445110339749622	0.0395696753622873	0.0372883597985613
+24	991.993957519531	2	1	0.00443336829341509	0.0440255653751743	0.0502927465261473
+25	976.332946777344	2	1	0.00437993281099959	0.0492604074600163	0.0448822073186939
+26	979.582275390625	2	3	0.00437918390295013	-0.0344798097888197	-0.03253979930277
+27	913.41845703125	2	3	0.00437503486499096	-0.00387925008074657	-0.00438981731141592
+28	948.619018554688	2	1	0.00426105794044819	0.0371821841057357	0.0429237139078889
+29	901.330810546875	2	1	0.00425328221665412	0.0552699147993945	0.0482509891289382
+30	960.278381347656	2	3	0.00423132265179973	-0.0433340796542259	-0.0409361343266309
+31	992.294921875	2	3	0.00418576359850056	-0.0391910598190591	-0.0342798229241432
+32	994.967834472656	2	1	0.00417817188823829	0.0383119007479891	0.0476486709797929
+33	948.471862792969	2	1	0.00417161016294321	0.0380099525316105	0.0408760564074696
+34	904.237426757812	2	1	0.00417080429266561	0.0475165460962433	0.0430960180049384
+35	942.852722167969	2	2	0.0041438458930486	-0.0468558588772594	-0.049716939342293
+36	918.442565917969	2	1	0.00413331124379944	0.0423300908408027	0.0458013372312651
+37	943.109436035156	2	2	0.00412811549109012	-0.0413767608692901	-0.0472745376109769
+38	936.5556640625	2	1	0.00411371014807382	0.0407060654246003	0.0414790745602655
+39	945.054321289062	2	1	0.00408474594381495	0.0481061599030778	0.0422885605529943
+40	992.595886230469	2	1	0.00408223122742656	0.0369204499600823	0.0410564204257673
+41	913.310180664062	2	1	0.00407879803557168	0.0498424674382356	0.040014655663535
+42	910.965698242188	2	3	0.00405962992021169	-0.0382641079076008	-0.0379558138613928
+43	950.606384277344	2	3	0.00405907592689352	-0.0503005800552258	-0.0564684538983107
+44	974.020629882812	2	1	0.00404970841392063	0.0453076176593101	0.0358031960147686
+45	903.770629882812	2	3	0.00403337646658259	-0.0308928430941287	-0.035800455446528
+46	993.197998046875	2	3	0.00402476056402085	-0.022740013818147	-0.0229211765138961
+47	955.140930175781	2	1	0.00400392811033344	0.0545303511096986	0.0430366824723547
+48	923.734497070312	2	1	0.00396875769656089	0.0489283101050371	0.0446083164881897
+49	943.292846679688	2	3	0.00396229091310485	-0.00589037926949604	-0.0081255927937416
+50	927.768005371094	2	1	0.00396212785702182	0.0446744368922679	0.0419935555431609
+51	965.540893554688	2	3	0.00395776036645286	-0.0622321071450148	-0.0629368131896196
+52	907.508483886719	2	1	0.00394876742672506	0.0338904158180818	0.0315098966370126
+53	960.019287109375	2	1	0.0039403473862032	0.050776397569013	0.03873623640836
+54	925.041748046875	2	3	0.0039362983069634	0.00547894918105684	0.00648384039698146
+55	922.863586425781	2	1	0.00393043741778826	0.0404768313565869	0.0320371152599393
+56	918.985595703125	2	3	0.00392990559936248	-0.0241976051228088	-0.0173907002587976
+57	938.054809570312	2	1	0.00392283092987214	0.0433932714795145	0.0415656785679352
+58	952.300964355469	2	1	0.00391807330597071	0.0539847824089577	0.0526900756993094
+59	938.896301269531	2	1	0.00390920544867313	0.0432075299467666	0.040884460919137
+60	918.62353515625	2	1	0.00390598520310851	0.0405436877403175	0.0394150273697351
+61	940.653686523438	2	1	0.00388205579523716	0.0325670207445315	0.0376845331490984
+62	918.587341308594	2	1	0.00386025843595639	0.0420256786308284	0.0473925689610602
+63	944.063293457031	2	3	0.00384447645727029	-0.0108918102769628	-0.00500447372654549
+64	980.479553222656	2	3	0.00383412917234354	-0.0262635632207469	-0.0305873497852977
+65	905.854248046875	2	3	0.00382809625193645	-0.0509229481136295	-0.0545129795504416
+66	942.082763671875	2	1	0.00381273797189762	0.0444743475872274	0.0435604050553623
+67	934.656066894531	2	3	0.00378297587449155	-0.0394312931297934	-0.0485932573378814
+68	906.89697265625	2	1	0.00374570932202412	0.0339271553171168	0.0282809191934174
+69	905.890197753906	2	3	0.00373151556865197	-0.024218298123225	-0.0186657492773445
+70	948.655822753906	2	3	0.00372441631900937	-0.017476081747813	-0.0110316891494553
+71	959.908325195312	2	1	0.00371442848581406	0.0342932290876843	0.0310906799107696
+72	946.192810058594	2	2	0.00369361746355479	-0.038238592789904	-0.0417491451554952
+73	933.524536132812	2	1	0.00368140176962546	0.0376205271222568	0.0348149137052689
+74	999.531311035156	2	1	0.0036708372022316	0.0419178472824249	0.0360426545514402
+75	905.602661132812	2	1	0.00366188804899887	0.0371789230194049	0.0403042300562272
+76	904.560729980469	2	1	0.00366151022492225	0.0483872255903629	0.0393416043647449
+77	967.02587890625	2	1	0.00364664009773375	0.0358270208382791	0.0367448112342897
+78	961.833374023438	2	1	0.00364124181915343	0.0500921543232852	0.0471568448381178
+79	945.71533203125	2	1	0.00362363829859195	0.038772747366622	0.038929243234765
+80	994.026245117188	2	2	0.00362302096270583	-0.0278102959641648	-0.035044986078868
+81	922.138061523438	2	1	0.0036165759251259	0.0396894571745094	0.0338599942728403
+82	921.920471191406	2	3	0.00361497501678999	-0.0109725715482311	-0.00817330765900041
+83	996.512939453125	2	3	0.00361344604654759	-0.0240208863758058	-0.0216798334099216
+84	925.586669921875	2	3	0.00360019116631399	-0.000201285421933851	-0.00370132703005591
+85	927.076965332031	2	1	0.00359739327950109	0.0402217752115896	0.0381187534803433
+86	946.266296386719	2	1	0.00359027149639919	0.0350158580852316	0.0345803953604497
+87	997.644348144531	2	3	0.00358755032912394	-0.0386413413940509	-0.0374227165960138
+88	986.959838867188	2	3	0.00356886986009821	-0.00770354721402719	-0.0073488017929185
+89	956.544067382812	2	2	0.00356755616082941	-0.0263554430477736	-0.0341563371597065
+90	981.826293945312	2	1	0.0035614851177778	0.0318618564397332	0.0359368988957353
+91	995.683715820312	2	1	0.0035606803581847	0.0326251406575274	0.0326734264590619
+92	949.575622558594	2	1	0.00354754516564472	0.0399068842159591	0.0381317579086198
+93	990.565063476562	2	3	0.00354075441437422	-0.00252469837204454	-0.00790021238532976
+94	970.222473144531	2	1	0.00353702890647679	0.033894961483528	0.0342653656238723
+95	926.277160644531	2	3	0.00352995388417487	-0.00403664201467942	-0.00483641570245392
+96	981.15283203125	2	1	0.00352226894457903	0.0343450789571067	0.0416777456263345
+97	927.222412109375	2	1	0.00350510856591621	0.0346202558912905	0.033535024774141
+98	946.450012207031	2	1	0.00349425060263787	0.0428865972028226	0.0325784624960938
+99	979.395385742188	2	3	0.00349405845239093	-0.00985834384583178	-0.00848238004662365
+100	902.083984375	2	1	0.00349155533954646	0.0283241643148307	0.0297190584575691
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/features_test3.tabular	Fri Jul 06 14:12:51 2018 -0400
@@ -0,0 +1,101 @@
+	mz	ncomp	column	coefficients	loadings	weights
+1	912.877136230469	5	B	0.00573560886985861	0.0278792843758433	0.0174625794014248
+2	928.859680175781	5	B	0.00511152861154612	0.080582202226706	0.0449791444906335
+3	928.8232421875	5	A	0.00394682983157522	-0.131114121516169	-0.120797995367842
+4	906.357543945312	5	B	0.00379761201569002	0.000218842770286919	0.0108192536553647
+5	929.806274414062	5	A	0.00329046667460749	-0.0793506800849298	-0.0567540713469838
+6	928.786865234375	5	A	0.00281536345205098	-0.137119317627185	-0.108094620314052
+7	928.350158691406	5	B	0.0027716009167843	0.0470202531672182	0.0412017517047867
+8	912.913208007812	5	B	0.00262003702349645	0.0194552925882558	-0.0195302890148169
+9	928.313781738281	5	B	0.00243736200183622	0.0805212535990385	0.0705990727896206
+10	913.887756347656	5	B	0.00221323695668804	-0.00317834456228842	-0.0111644037765951
+11	958.354858398438	5	C	0.00218611357632804	-0.0868225233010098	-0.0776158593166818
+12	900.3271484375	5	A	0.00202270233336513	0.0218864157743357	0.0249665710844463
+13	922.355712890625	5	A	0.00194994698799459	-0.00519863672214228	-0.0143720726000853
+14	906.932922363281	5	C	0.00194723366167703	-0.0312828380589129	-0.0442717730733137
+15	960.315368652344	5	A	0.00187947702290302	0.0253736974493193	0.018753441810068
+16	900.398864746094	5	A	0.00187742938790966	0.0897368447678527	0.0384134014466115
+17	908.372192382812	5	C	0.00184669840048874	-0.0869349456361487	-0.0829960247477007
+18	964.353698730469	5	A	0.00184476269063658	0.011548554180564	-0.000153032997962692
+19	907.400573730469	5	A	0.00181328146613277	-0.13964152975894	-0.111315217793746
+20	944.3935546875	5	C	0.00180114670650244	-0.112514036816282	-0.0967817030565024
+21	930.862670898438	5	B	0.00178101260222112	0.0431711794522195	0.0423828276766716
+22	917.320922851562	5	B	0.0017324863274476	-0.0018308853147361	0.0181840711680666
+23	913.923889160156	5	B	0.00169680931924337	0.00751826276561152	0.00426019175481283
+24	964.316589355469	5	A	0.00167574782378486	-0.00511819820771596	-0.0177629600432386
+25	922.391967773438	5	A	0.00165663869710544	0.0269772557383697	0.0200569702205186
+26	928.386535644531	5	C	0.00163839286482865	-0.128723542255192	-0.14365649834442
+27	917.24853515625	5	C	0.00163799346185425	-0.0686989934192134	-0.0644324391138345
+28	907.0048828125	5	C	0.00163651612048907	-0.0423460760837113	-0.042858627938677
+29	929.879089355469	5	B	0.00161854460685115	0.0107180493542772	-0.0165330274858425
+30	962.31494140625	5	A	0.0015577110978032	0.0101662280797979	0.00906297179159906
+31	928.896057128906	5	B	0.00155211020829067	-0.0227597962344375	-0.0376328151696402
+32	907.508483886719	5	A	0.00152231359874351	-0.00501023440503865	0.00411608821605429
+33	906.321594238281	5	B	0.00150232100198243	0.169628931631569	0.0833347494460195
+34	928.422912597656	5	C	0.00149862519425526	-0.0988092407586723	-0.0980124527103979
+35	915.33251953125	5	A	0.00149670046094414	0.0167810951263842	0.00799770543739007
+36	933.451599121094	5	A	0.00149559366742044	-0.0101282950093928	-0.00868888146166574
+37	938.310852050781	5	A	0.00148518024454743	-0.0190905089132087	-0.021963712310515
+38	900.398864746094	5	B	0.00144309164565263	0.0897368447678527	0.0384134014466115
+39	914.393310546875	5	A	0.00143814553766404	0.0431939959878263	0.0391694434542682
+40	923.37158203125	5	A	0.00143349164672113	0.0309748953597018	0.0265723936963444
+41	909.380310058594	5	C	0.00142631034364181	-0.0769318389091112	-0.0693117294136355
+42	922.319458007812	5	A	0.00142630323399233	0.00788744010733054	0.00410195880119904
+43	988.423706054688	5	C	0.00142458825835235	-0.0544530771113024	-0.0561690158460763
+44	945.825500488281	5	A	0.00141849722280284	-0.00410006824736187	0.00464038907760734
+45	906.968933105469	5	C	0.00141821227423597	-0.0281467969817215	-0.0346221161148836
+46	984.41015625	5	A	0.00141422568838638	0.00180288115822474	-0.00575025152945066
+47	914.429443359375	5	A	0.00140667815589665	0.00844912072512714	0.000927993780216452
+48	906.825073242188	5	C	0.00139689814365544	-0.0186626483901896	-0.0139964738169331
+49	974.356140136719	5	A	0.00139511899978669	0.00771417003944002	0.00732798200952366
+50	990.339538574219	5	A	0.00139335470274239	0.0145249159048392	0.00747421578232434
+51	906.3935546875	5	A	0.00138004860874631	-0.312550300134348	-0.247786642569732
+52	922.42822265625	5	A	0.00136676358204094	0.0165625882192442	0.0152871768674149
+53	908.300170898438	5	B	0.00135991283529091	0.0718420081273004	0.0713307284663223
+54	901.402526855469	5	A	0.00134718725931476	-0.0256078636203243	-0.0356154758922099
+55	910.352966308594	5	A	0.00134419794589414	-0.0499712979282595	-0.0256436042538601
+56	931.263549804688	5	C	0.00134117597601552	-0.0620247580251951	-0.0607020324076145
+57	985.047302246094	5	C	0.00133584639523509	-0.0384397290535222	-0.0408673780723547
+58	914.321105957031	5	A	0.00130608979486391	0.0290501975094118	0.0275420313894548
+59	945.348083496094	5	A	0.00130140516695858	0.0253060910242657	0.0119029358846208
+60	913.310180664062	5	A	0.00129896103824685	0.00742346758138673	0.0157924784190528
+61	933.70703125	5	C	0.00129763361619735	-0.0407418908691755	-0.0388860566536824
+62	921.956787109375	5	C	0.00129612551320273	-0.0483921057193139	-0.0488383464831586
+63	939.335510253906	5	A	0.00129428218404129	0.00600800789030359	0.0131879607302309
+64	987.41015625	5	A	0.00128665107590485	-0.00636134472352142	-0.00730763252053051
+65	943.549621582031	5	C	0.00128617292004578	-0.0395067636606405	-0.0475612954644227
+66	906.89697265625	5	C	0.00128388845744427	-0.0810017098053887	-0.0590661747185278
+67	943.843139648438	5	A	0.00128163928100432	0.0223636395901339	0.0171960698891111
+68	967.322998046875	5	A	0.00127943666463007	0.0314895243330321	0.0315023839724848
+69	939.079284667969	5	A	0.00126568352817391	0.00393555672515739	0.00746820029282455
+70	977.490112304688	5	C	0.00125443608196423	-0.0380384702294876	-0.0403034709131318
+71	907.32861328125	5	B	0.00125253984496166	0.110383167737652	0.0704562955022436
+72	944.283447265625	5	C	0.00124603304578717	-0.0491052600513046	-0.0727841765184862
+73	930.27978515625	5	A	0.00124326358170705	-0.00215312648559036	-0.00579722722612751
+74	949.244445800781	5	A	0.00123689874596268	0.0219656572867447	0.0137749437071788
+75	913.851684570312	5	C	0.00123370404912094	-0.108870738599701	-0.116843827740323
+76	975.362915039062	5	C	0.00123247898907694	-0.044591237647127	-0.0456858984984175
+77	900.470520019531	5	C	0.00122678197442627	-0.127593325669853	-0.123819224377232
+78	940.397277832031	5	A	0.00122354729668265	0.00648441625422437	0.00152355799263006
+79	908.876159667969	5	B	0.00121463454522318	0.061564970973976	0.0580665441987194
+80	913.346313476562	5	A	0.00120436661249893	-0.0131206347760455	-0.018390772792573
+81	916.236083984375	5	B	0.00119954624470656	0.032430870334859	0.035219768767109
+82	944.320190429688	5	C	0.00118708863739913	-0.055803354733614	-0.0761728728759915
+83	945.458251953125	5	B	0.0011857554546481	0.0368567664791091	0.0388966752148608
+84	961.388977050781	5	A	0.00118457289993589	-0.0169330554562843	-0.0263480507383981
+85	990.302001953125	5	A	0.00117366922561996	0.0268817088254416	0.02256998797909
+86	901.474243164062	5	C	0.00117008160572052	-0.0595293465828576	-0.0761088232808644
+87	964.427856445312	5	A	0.0011666327455814	0.00165239954667202	-0.00309276740861809
+88	929.442138671875	5	A	0.0011637277717203	-0.0157825629843663	-0.0212823327979183
+89	978.34912109375	5	A	0.00116221405397043	0.0177230636109089	0.013528455022467
+90	907.904296875	5	C	0.00116106463394485	-0.0368668797130259	-0.0316104275660823
+91	934.364013671875	5	A	0.00115988059659708	-0.0494769062493358	-0.042494498580377
+92	945.788757324219	5	A	0.0011595624454717	-0.0521758846817815	-0.0526870771132401
+93	902.9091796875	5	A	0.00115576472542512	0.0137482609386539	0.0127692632724736
+94	916.308349609375	5	B	0.00115492032248105	0.0430197453137873	0.0222454244793768
+95	930.899108886719	5	B	0.00115375696294478	0.0229589147612749	0.0175390324427165
+96	994.252197265625	5	A	0.00114858716830324	-0.0115164421162656	-0.0129501099310508
+97	953.517578125	5	C	0.00114667766575531	-0.0313375380866859	-0.0343808078073923
+98	927.33154296875	5	B	0.00114653967537263	0.045177958607566	0.0584684273035106
+99	909.632446289062	5	C	0.00114285552390805	-0.0421291133184035	-0.0442392582481364
+100	902.550354003906	5	A	0.00113776304703523	0.0106679460632866	0.00541877194927921
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/features_test4.tabular	Fri Jul 06 14:12:51 2018 -0400
@@ -0,0 +1,101 @@
+	mz	ncomp	column	coefficients	loadings	weights
+1	912.877136230469	3	B	0.00402511569666969	-0.246308032464734	-0.0998747661753797
+2	928.8232421875	3	A	0.00355204006388532	0.273286934815558	0.288081987978036
+3	928.859680175781	3	B	0.00304099166534859	-0.180023925015396	-0.0975882865489913
+4	929.806274414062	3	A	0.00301867966492034	0.20461792386307	0.204104875190971
+5	928.786865234375	3	A	0.00294246516676733	0.279365597419633	0.24012019090174
+6	912.913208007812	3	B	0.00221421341476842	-0.25734495461644	-0.123924205177262
+7	906.357543945312	3	B	0.0017751956946221	0.0660711931225974	-0.167734534471784
+8	913.887756347656	3	B	0.00169164545723661	-0.0797847981582402	-0.0542158398194389
+9	907.400573730469	3	A	0.00168976824209188	-0.0553409573032757	-0.0310185392575794
+10	900.3271484375	3	A	0.0016850771109767	0.0635456830152988	0.0623351620915374
+11	928.896057128906	3	B	0.00168450000766379	-0.182486440635111	-0.0950023449824687
+12	922.355712890625	3	A	0.00167096941795371	0.0529977859368994	0.0679949938623556
+13	900.398864746094	3	A	0.00166100096018687	0.0406827592981194	-0.010027514312194
+14	960.315368652344	3	A	0.00164686513200881	0.0692239228029656	0.0559857485267436
+15	964.353698730469	3	A	0.0016007991522707	0.0487859885763137	0.049315043939497
+16	906.3935546875	3	A	0.00157421991835154	-0.184824638462265	-0.161519730620847
+17	964.316589355469	3	A	0.00143180642589214	0.0309764043652652	0.0453653991628429
+18	962.31494140625	3	A	0.00141328760599612	0.0642563963154312	0.0454439922528048
+19	929.879089355469	3	B	0.00137108902531006	-0.147152863346693	-0.0787919913569194
+20	900.434692382812	3	B	0.00131488882358473	-0.20214180256976	-0.173026933354479
+21	901.402526855469	3	A	0.00131071912036092	0.0193425453272541	0.00416556425120399
+22	922.391967773438	3	A	0.00128195781418033	0.0250080230991378	0.0401690309084914
+23	915.33251953125	3	A	0.00127720082168308	0.0472700250545067	0.0476142683041524
+24	938.310852050781	3	A	0.00126979651175339	0.0258332330864995	0.0395551945184375
+25	913.923889160156	3	B	0.00125913909333928	-0.116366449217641	-0.0823808975691949
+26	907.508483886719	3	A	0.00123463128203684	0.0286834379044553	0.0416260189187914
+27	974.356140136719	3	A	0.00122974867070485	0.0426004370460666	0.0327898050985416
+28	933.451599121094	3	A	0.00122075781571264	0.0189293266454833	0.0363946273679358
+29	910.352966308594	3	A	0.00121465945239948	0.0212318588989688	0.0191774558940735
+30	990.339538574219	3	A	0.00120033930835288	0.0471035220902788	0.0441020126132822
+31	984.41015625	3	A	0.00117709585424916	0.0256612782877473	0.0364785894847815
+32	922.319458007812	3	A	0.00116343926435404	0.0350575504771194	0.049003566656031
+33	945.825500488281	3	A	0.00116281366134625	0.0358386234196617	0.039941557361758
+34	914.429443359375	3	A	0.00114751581370748	0.0214325420152595	0.0322577162355903
+35	934.364013671875	3	A	0.00111966105461266	0.0261184955739278	0.0277902861913678
+36	945.788757324219	3	A	0.0011140971316516	0.0602657244502292	0.0678490003014779
+37	930.27978515625	3	A	0.00111107830564362	0.0548573050563774	0.0541864639681832
+38	987.41015625	3	A	0.00109109627880292	0.0259022291567729	0.0348827329301489
+39	917.320922851562	3	B	0.00108811988692458	-0.0380939775497376	-0.0859734761406655
+40	961.388977050781	3	A	0.00108270610537361	0.0208991144261707	0.0235951714502884
+41	949.244445800781	3	A	0.00108094226185502	0.0553461544724562	0.0473287208302763
+42	914.393310546875	3	A	0.00107937289161071	0.0186407876697643	0.0213451871968151
+43	923.37158203125	3	A	0.00107406087109902	0.0174157121297602	0.0300927241546599
+44	967.322998046875	3	A	0.00106160501633174	0.0413827618597132	0.0291509896006055
+45	961.314880371094	3	A	0.00105652394646208	0.0429555520663857	0.0345573512639803
+46	994.252197265625	3	A	0.00105259315733988	0.0465400676246555	0.0444177569572566
+47	945.348083496094	3	A	0.00104820825219221	0.00490478080758506	0.00553720261210505
+48	913.346313476562	3	A	0.00103460925930171	0.0189564108870971	0.026732642281156
+49	914.321105957031	3	A	0.00103017762730726	0.0282931942786005	0.0284256699648362
+50	929.442138671875	3	A	0.00102404971565295	0.0229046222354404	0.0276260524235887
+51	922.42822265625	3	A	0.0010201655110503	0.00439147989742666	0.022483171550914
+52	978.386474609375	3	A	0.00101071432463861	0.0477124446667881	0.0315232247977375
+53	939.335510253906	3	A	0.00100997005380696	0.0115288494115123	0.0213424433245233
+54	929.478515625	3	A	0.00100973338976312	0.0376043223441187	0.0393591980443549
+55	939.079284667969	3	A	0.00100844892647231	0.031219827705917	0.0442017366717789
+56	943.843139648438	3	A	0.000998522723296839	0.0267299053728509	0.036566368840497
+57	929.842712402344	3	A	0.000985861500832982	0.0831947546006432	0.10803783679681
+58	940.397277832031	3	A	0.000981083898431389	0.0151431322576335	0.0277538495060947
+59	990.302001953125	3	A	0.000975080019411607	0.0394636635241222	0.0357960840702764
+60	913.310180664062	3	A	0.000968769911918236	0.0107823038071007	0.0262423379384436
+61	912.3359375	3	A	0.000967109425146236	0.0334299345844847	0.0262269905676808
+62	934.327514648438	3	A	0.000965358942233967	0.0380560763121743	0.0247830327164836
+63	978.34912109375	3	A	0.000951696141507144	0.0246378024631849	0.0263610910562008
+64	964.427856445312	3	A	0.000949632779126584	0.0206276476766682	0.0323633524966416
+65	905.135498046875	3	A	0.000938890795440174	0.0358363374682948	0.0462758721204666
+66	902.9091796875	3	A	0.000928200839226985	0.0270476983876206	0.0331256977422899
+67	970.296875	3	A	0.000917937154598045	0.0412888009110875	0.0371046212107984
+68	900.291320800781	3	A	0.000915554291393151	0.036900837325731	0.0299428712446064
+69	936.372924804688	3	A	0.00091425261278822	0.0304697260564217	0.0172307486843934
+70	902.550354003906	3	A	0.000913173677427114	0.0206873082762993	0.0314356257688807
+71	969.329895019531	3	A	0.00090861890412644	0.0381404597757337	0.0290496620448507
+72	928.350158691406	3	B	0.000900790180107579	-0.0354285882483893	-0.0781235087794192
+73	906.465454101562	3	A	0.000894886810510601	0.0278152115913203	0.00415630972695765
+74	951.195617675781	3	A	0.00088960840060638	0.0213781455200748	0.0390510024922428
+75	929.296508789062	3	A	0.00088945452659998	0.0574166486840185	0.0407909727744226
+76	910.389038085938	3	A	0.000888660624855818	0.00883285913101179	0.024080334566073
+77	900.362976074219	3	A	0.000883637632569096	0.0601212422828572	0.020862039569661
+78	938.274291992188	3	A	0.000883070665782107	0.0420871600944523	0.0280462808036272
+79	978.423828125	3	A	0.000872970230052765	0.0296257238522422	0.0297815743118744
+80	911.326171875	3	A	0.00086789849916482	0.0394187876318227	0.0290756595311376
+81	931.700927734375	3	A	0.000861266010686886	0.0280254327018276	0.0337516683459626
+82	974.393371582031	3	A	0.00086077059179462	0.0419836959861716	0.0289479495170414
+83	948.251220703125	3	A	0.000851477547904384	0.0586205266644055	0.0458040438736673
+84	930.862670898438	3	B	0.000847409031672241	-0.0301586503036759	-0.0413625782185381
+85	916.923034667969	3	A	0.000845064368244676	0.0201331942543559	0.0318311721846992
+86	949.318054199219	3	A	0.000844949051475147	0.0315506908752857	0.0279475612749433
+87	985.459655761719	3	A	0.000842609316199747	0.0291683495191316	0.0295586583634342
+88	907.4365234375	3	A	0.000842558751196136	0.0249644273710741	0.0174278577017741
+89	925.18701171875	3	A	0.000838340515097191	0.0229497739599204	0.0228814357718886
+90	929.332885742188	3	B	0.000836809726794182	-0.0293672010070615	-0.0547646716148819
+91	937.506225585938	3	A	0.000833507239635534	0.0178457519825421	0.0278222013471842
+92	987.335083007812	3	A	0.000833440336912753	0.0308912024371622	0.0275278913639686
+93	987.372619628906	3	A	0.000826015704761948	0.0386304306725754	0.0226104858957154
+94	991.392211914062	3	A	0.000822495593430933	0.0301123283528462	0.0258405716069016
+95	986.359619140625	3	A	0.00081725052418651	0.0222459076819841	0.0214131889306635
+96	995.608337402344	3	A	0.000815403977582455	0.0244745957678714	0.0372521871817605
+97	901.438415527344	3	B	0.000811802591576616	-0.14481476191689	-0.105509238222151
+98	927.295166015625	3	A	0.000809570499146196	0.0324202661433909	0.0195781537578164
+99	957.467712402344	3	A	0.000805168267772138	0.0349607008493259	0.0294205742236357
+100	982.387756347656	3	A	0.000802321450704626	0.0296134673806074	0.0240390222467118
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/features_test6.tabular	Fri Jul 06 14:12:51 2018 -0400
@@ -0,0 +1,7 @@
+	mz	r	k	s	classes	centers	tstatistics	p.values	adj.p.values
+1	928.859680175781	2	3	2	B	43.9516959905118	0.541814677313986	0.607464263577403	1
+2	912.877136230469	2	3	2	B	55.419364071664	0.437808238568372	0.676846169835776	1
+3	913.887756347656	2	3	2	B	24.9140214890445	0.393340199810185	0.70766449744142	1
+4	930.862670898438	2	3	2	B	9.28583084091344	0.29858210475084	0.775329712997245	1
+5	913.923889160156	2	3	2	B	12.1491837287613	0.0960056413112618	0.926642424678888	1
+6	900.004699707031	2	3	2	A	2.29166666666667	0	1	1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/pixel_annotation_file1.tabular	Fri Jul 06 14:12:51 2018 -0400
@@ -0,0 +1,24 @@
+Fold1	1
+Fold1	1
+Fold1	1
+Fold1	1
+Fold1	2
+Fold1	2
+Fold1	2
+Fold1	2
+Fold1	3
+Fold1	3
+Fold1	3
+Fold1	3
+Fold2	1
+Fold2	1
+Fold2	1
+Fold2	1
+Fold2	2
+Fold2	2
+Fold2	2
+Fold2	2
+Fold2	3
+Fold2	3
+Fold2	3
+Fold2	3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/pixels_test2.tabular	Fri Jul 06 14:12:51 2018 -0400
@@ -0,0 +1,25 @@
+	predicted diagnosis
+x = 1, y = 1	1
+x = 2, y = 1	1
+x = 3, y = 1	1
+x = 4, y = 1	1
+x = 1, y = 2	2
+x = 2, y = 2	2
+x = 3, y = 2	2
+x = 4, y = 2	2
+x = 1, y = 3	3
+x = 2, y = 3	3
+x = 3, y = 3	3
+x = 4, y = 3	3
+x = 10, y = 1	1
+x = 11, y = 1	1
+x = 12, y = 1	1
+x = 13, y = 1	1
+x = 10, y = 2	2
+x = 11, y = 2	2
+x = 12, y = 2	2
+x = 13, y = 2	2
+x = 10, y = 3	2
+x = 11, y = 3	3
+x = 12, y = 3	3
+x = 13, y = 3	3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/pixels_test3.tabular	Fri Jul 06 14:12:51 2018 -0400
@@ -0,0 +1,25 @@
+	predicted diagnosis
+x = 1, y = 1	A
+x = 2, y = 1	A
+x = 3, y = 1	B
+x = 4, y = 1	C
+x = 1, y = 2	C
+x = 2, y = 2	C
+x = 3, y = 2	B
+x = 4, y = 2	A
+x = 1, y = 3	A
+x = 2, y = 3	B
+x = 3, y = 3	C
+x = 4, y = 3	A
+x = 10, y = 1	A
+x = 11, y = 1	C
+x = 12, y = 1	B
+x = 13, y = 1	B
+x = 10, y = 2	B
+x = 11, y = 2	A
+x = 12, y = 2	C
+x = 13, y = 2	A
+x = 10, y = 3	C
+x = 11, y = 3	B
+x = 12, y = 3	B
+x = 13, y = 3	C
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/pixels_test4.tabular	Fri Jul 06 14:12:51 2018 -0400
@@ -0,0 +1,25 @@
+	predicted diagnosis
+x = 1, y = 1	A
+x = 2, y = 1	C
+x = 3, y = 1	B
+x = 4, y = 1	C
+x = 1, y = 2	C
+x = 2, y = 2	C
+x = 3, y = 2	B
+x = 4, y = 2	A
+x = 1, y = 3	A
+x = 2, y = 3	B
+x = 3, y = 3	C
+x = 4, y = 3	A
+x = 10, y = 1	A
+x = 11, y = 1	C
+x = 12, y = 1	C
+x = 13, y = 1	B
+x = 10, y = 2	B
+x = 11, y = 2	A
+x = 12, y = 2	C
+x = 13, y = 2	A
+x = 10, y = 3	C
+x = 11, y = 3	B
+x = 12, y = 3	B
+x = 13, y = 3	C
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/pixels_test6.tabular	Fri Jul 06 14:12:51 2018 -0400
@@ -0,0 +1,25 @@
+	predicted diagnosis
+x = 1, y = 1	A
+x = 2, y = 1	A
+x = 3, y = 1	B
+x = 4, y = 1	A
+x = 1, y = 2	A
+x = 2, y = 2	A
+x = 3, y = 2	A
+x = 4, y = 2	A
+x = 1, y = 3	A
+x = 2, y = 3	B
+x = 3, y = 3	A
+x = 4, y = 3	A
+x = 10, y = 1	A
+x = 11, y = 1	A
+x = 12, y = 1	A
+x = 13, y = 1	B
+x = 10, y = 2	B
+x = 11, y = 2	B
+x = 12, y = 2	A
+x = 13, y = 2	B
+x = 10, y = 3	A
+x = 11, y = 3	A
+x = 12, y = 3	B
+x = 13, y = 3	A
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/random_factors.tabular	Fri Jul 06 14:12:51 2018 -0400
@@ -0,0 +1,24 @@
+1	A
+1	A
+2	B
+1	C
+2	C
+2	C
+2	B
+2	A
+2	A
+1	B
+2	C
+1	A
+1	A
+2	C
+1	B
+1	B
+1	B
+1	A
+2	C
+2	A
+1	C
+2	B
+1	B
+2	C
Binary file test-data/test1.pdf has changed
Binary file test-data/test2.pdf has changed
Binary file test-data/test2.rdata has changed
Binary file test-data/test3.pdf has changed
Binary file test-data/test4.pdf has changed
Binary file test-data/test4.rdata has changed
Binary file test-data/test5.pdf has changed
Binary file test-data/test6.pdf has changed
Binary file test-data/test6.rdata has changed
Binary file test-data/test7.pdf has changed
Binary file test-data/test7.rdata has changed
Binary file test-data/testfile_squares.rdata has changed