Repository 'nmr_preprocessing'
hg clone https://toolshed.g2.bx.psu.edu/repos/marie-tremblay-metatoul/nmr_preprocessing

Changeset 4:a6c9f5d6fdc9 (2018-08-09)
Previous changeset 3:7d8451d9fff6 (2018-04-11) Next changeset 5:5b06800f3449 (2018-09-21)
Commit message:
Uploaded
modified:
nmr_preprocessing/NmrPreprocessing_script.R
nmr_preprocessing/NmrPreprocessing_wrapper.R
nmr_preprocessing/NmrPreprocessing_xml.xml
nmr_preprocessing/README.rst
nmr_preprocessing/ReadFids_xml.xml
nmr_preprocessing/test-data/NMR_Preprocessing_dataMatrix.tabular
b
diff -r 7d8451d9fff6 -r a6c9f5d6fdc9 nmr_preprocessing/NmrPreprocessing_script.R
--- a/nmr_preprocessing/NmrPreprocessing_script.R Wed Apr 11 05:32:23 2018 -0400
+++ b/nmr_preprocessing/NmrPreprocessing_script.R Thu Aug 09 04:08:30 2018 -0400
[
@@ -580,20 +580,21 @@
   Fid_info <- begin_info[["Signal_info"]]
   
   
-  # Check input arguments
+  ######## Check input arguments
+  
   range <- match.arg(range)
   shiftHandling <- match.arg(shiftHandling)
   method <- match.arg(method)
   plots <- NULL
   
-  
   checkArg(ppm.ir, c("bool"))
   checkArg(unlist(fromto.RC), c("num"), can.be.null = TRUE)
   checkArg(pc, c("num"))
   checkArg(ppm.value, c("num"))
   checkArg(rowindex_graph, "num", can.be.null = TRUE)
   
-  # fromto.RC
+  # fromto.RC : if range == "window", 
+  # fromto.RC defines the spectral window where to search for the peak
   if (!is.null(fromto.RC)) {
     diff <- diff(unlist(fromto.RC))[1:length(diff(unlist(fromto.RC)))%%2 !=0]
     for (i in 1:length(diff)) {
@@ -606,6 +607,9 @@
   
   
   # findTMSPpeak function ----------------------------------------------
+  # If method == "tresh", findTMSPpeak will find the position of the first 
+  # peak (from left or right) which is higher than a predefined threshold 
+  # and is computed as: c*(cumulated_mean/cumulated_sd)
   findTMSPpeak <- function(ft, c = 2, direction = "left") {
     ft <- Re(ft)  # extraction de la partie rĂ©elle
     N <- length(ft)
@@ -647,24 +651,31 @@
   }
   
   
-  # Apply the method ('thres' or 'max') on spectra
-  # ----------------------------------------------
+  # Define the search zone  ----------------------------------------
   
   n <- nrow(Spectrum_data)
   m <- ncol(Spectrum_data)
   
-  # The Sweep Width has to be the same since the column names are the same
-  SW <- Fid_info[1, "SW"]  # Sweep Width in ppm (semi frequency scale in ppm)
-  ppmInterval <- SW/(m-1)  
+  # The Sweep Width (SW) has to be the same since the column names are the same
+  SW <- Fid_info[1, "SW"]  # Sweep Width in ppm 
+  ppmInterval <- SW/(m-1)  # size of a ppm interval
   
+  # range: How the search zone is defined ("all", "nearvalue" or "window")
   if (range == "all") {
+    
     Data <- Spectrum_data
+    
   } else { # range = "nearvalue" or "window"
+    # Need to define colindex (column indexes) to apply indexInterval on it
     
     if (range == "nearvalue")  {
+      
       fromto.RC <- list(c(-(SW * pc)/2 + ppm.value, (SW * pc)/2 + ppm.value))  # automatic fromto values in ppm
       colindex <- as.numeric(colnames(Spectrum_data))
+      
     } else {
+      # range == "window"
+      # fromto.RC is already user-defined
       if (ppm.ir == TRUE)   {
         colindex <- as.numeric(colnames(Spectrum_data))
       } else   {
@@ -672,38 +683,47 @@
       }
     }
     
-    
-    Int <- vector("list", length(fromto.RC))
+    # index intervals taking into account the different elements in the list fromto.RC
+    Int <- vector("list", length(fromto.RC)) 
     for (i in 1:length(fromto.RC))  {
       Int[[i]] <- indexInterval(colindex, from = fromto.RC[[i]][1], 
                                 to = fromto.RC[[i]][2], inclusive = TRUE)
     }
     
-    vector <- rep(0, m)
-    vector[unlist(Int)] <- 1
-    if (n > 1)  {
-      Data <- sweep(Spectrum_data, MARGIN = 2, FUN = "*", vector)  # Cropped_Spectrum
-    } else  {
-      Data <- Spectrum_data * vector
-    }  # Cropped_Spectrum
+    # define Data as the cropped spectrum including the index intervals
+    # outside the research zone, the intensities are set to the minimal 
+    # intensity of the research zone
+    
+    if (n > 1){
+      Data <- apply(Re(Spectrum_data[,unlist(Int)]),1, function(x) rep(min(x), m))
+      Data <- t(Data)
+      Data[,unlist(Int)] <- Re(Spectrum_data[,unlist(Int)])
+    } else {
+      Data <- rep(min(Re(Spectrum_data)) ,m)
+      Data[unlist(Int)] <- Re(Spectrum_data[unlist(Int)])
+    }
+    
   }
   
   
+  # Apply the peak location search method ('thres' or 'max') on spectra
+  # -----------------------------------------------------------------------
+  
   if (method == "thres") {
     TMSPpeaks <- apply(Data, 1, findTMSPpeak, c = c, direction = direction)
-  } else {
-    TMSPpeaks <- apply(abs(Re(Data)), 1, which.max)
+  } else { # method == "max
+    TMSPpeaks <- apply(Re(Data), 1, which.max)
   }
   
-  # TMSPpeaks is an column index
-  maxpeak <- max(TMSPpeaks)
-  minpeak <- min(TMSPpeaks)
-  
-  
   
   # Shift spectra according to the TMSPpeaks found --------------------------------
   # Depends on the shiftHandling
   
+  # TMSPpeaks is a column index
+  maxpeak <- max(TMSPpeaks) # max accross spectra
+  minpeak <- min(TMSPpeaks) # min accross spectra
+  
+  
   if (shiftHandling %in% c("zerofilling", "NAfilling",  "cut")) {
     fill <- NA
     if (shiftHandling == "zerofilling")  {
@@ -713,6 +733,7 @@
     start <-  maxpeak - 1
     end <- minpeak - m
     
+    # ppm values of each interval for the whole spectral range of the spectral matrix
     ppmScale <- (start:end) * ppmInterval
     
     # check if ppm.value is in the ppmScale interval
@@ -722,10 +743,14 @@
       ppm.value = 0
     }
     
+    # if ppm.value != 0, ppmScale is adapted
     ppmScale <- ppmScale + ppm.value
     
+    # create the spectral matrix with realigned spectra
     Spectrum_data_calib <- matrix(fill, nrow = n, ncol =  -(end - start) + 1, 
                                   dimnames = list(rownames(Spectrum_data), ppmScale))
+    
+    # fills in Spectrum_data_calib with shifted spectra
     for (i in 1:n)  {
       shift <- (1 - TMSPpeaks[i]) + start
       Spectrum_data_calib[i, (1 + shift):(m + shift)] <- Spectrum_data[i, ]
@@ -751,10 +776,15 @@
               round(min(ppmScale),2), ",", round(max(ppmScale),2), "], and is set to its default ppm.value 0")
       ppm.value = 0
     }
+    
+    # if ppm.value != 0, ppmScale is adapted
     ppmScale <- ppmScale + ppm.value
     
+    # create the spectral matrix with realigned spectra
     Spectrum_data_calib <- matrix(nrow=n, ncol=end-start+1,
                                   dimnames=list(rownames(Spectrum_data), ppmScale))
+    
+    # fills in Spectrum_data_calib with shifted spectra
     for (i in 1:n) {
       shift <- (maxpeak-TMSPpeaks[i])
       Spectrum_data_calib[i,(1+shift):m] <- Spectrum_data[i,1:(m-shift)]
@@ -767,7 +797,7 @@
   
   
   
-  # Plot of the spectra ---------------------------------------------------
+  # Plot of the spectra (depending on rowindex_graph) ---------------------------------------------------
   
   ppm = xstart = value = xend = Legend = NULL # only for R CMD check
   
@@ -798,7 +828,7 @@
     # rectanglar bands of color for the search zone
     rects <- data.frame(xstart = sapply(fromto, function(x) x[[1]]), 
                         xend = sapply(fromto, function(x) x[[2]]), 
-                        Legend = "TMSP search zone and location")
+                        Legend = "Peak search zone and location")
     
     # vlines for TMSP peak
     addlines <- data.frame(rowname = rownames(Spectrum_data)[rowindex_graph],TMSPloc)
@@ -824,7 +854,7 @@
         ggplot2::theme(legend.position = "none") + 
         ggplot2::geom_vline(data = addlines, ggplot2::aes(xintercept = TMSPloc), 
                             color = "red", show.legend = TRUE) + 
-        ggplot2::ggtitle("TMSP peak search zone and location") + 
+        ggplot2::ggtitle("Peak search zone and location") + 
         ggplot2::theme(legend.position = "top", legend.text = ggplot2::element_text())
       
       
b
diff -r 7d8451d9fff6 -r a6c9f5d6fdc9 nmr_preprocessing/NmrPreprocessing_wrapper.R
--- a/nmr_preprocessing/NmrPreprocessing_wrapper.R Wed Apr 11 05:32:23 2018 -0400
+++ b/nmr_preprocessing/NmrPreprocessing_wrapper.R Thu Aug 09 04:08:30 2018 -0400
[
@@ -139,53 +139,6 @@
   # Inputs
 
 
-# Internal referencering ----------------------------------
-  # Inputs
-shiftTreshold = 2 # c
-ppm = TRUE
-shiftReferencingRangeList = NULL  # fromto.RC
-pctNearValue = 0.02 # pc 
-rowindex_graph = NULL
-ppm_ref = 0 # ppm.ref
-
-# 
-# shiftReferencing <- argLs[["shiftReferencing"]]
-# print(shiftReferencing)
-# 
-# if (shiftReferencing=="YES")
-# {
-#   
- # shiftReferencingMethod <- argLs[["shiftReferencingMethod"]]
- # 
- # if (shiftReferencingMethod == "thres") {
- #  shiftTreshold <- argLs[["shiftTreshold"]]
- # }
-
- shiftReferencingRange <- argLs[["shiftReferencingRange"]]
-
- if (shiftReferencingRange == "near0"){
-   pctNearValue <- argLs[["pctNearValue"]]
- }
-
- if (shiftReferencingRange == "window"){
-   shiftReferencingRangeList <- list()
-   for(i in which(names(argLs)=="shiftReferencingRangeLeft")) 
-   {
-   shiftReferencingRangeLeft <- argLs[[i]]
-   shiftReferencingRangeRight <- argLs[[i+1]]
-   shiftReferencingRangeList <- c(shiftReferencingRangeList,list(c(shiftReferencingRangeLeft,shiftReferencingRangeRight)))
-   }
- }
-
- shiftHandling <- argLs[["shiftHandling"]]
-
- ppmvalue <- argLs[["ppmvalue"]]
-
-
-
-# }
-
-
 # Zero Order Phase Correction -------------------------------
   # Inputs
 
@@ -211,6 +164,53 @@
 }
 
 
+# Internal referencering ----------------------------------
+# Inputs
+shiftTreshold = 2 # c
+ppm = TRUE
+shiftReferencingRangeList = NULL  # fromto.RC
+pctNearValue = 0.02 # pc 
+rowindex_graph = NULL
+ppm_ref = 0 # ppm.ref
+
+# 
+# shiftReferencing <- argLs[["shiftReferencing"]]
+# print(shiftReferencing)
+# 
+# if (shiftReferencing=="YES")
+# {
+#   
+# shiftReferencingMethod <- argLs[["shiftReferencingMethod"]]
+# 
+# if (shiftReferencingMethod == "thres") {
+#  shiftTreshold <- argLs[["shiftTreshold"]]
+# }
+
+shiftReferencingRange <- argLs[["shiftReferencingRange"]]
+
+if (shiftReferencingRange == "near0"){
+  pctNearValue <- argLs[["pctNearValue"]]
+}
+
+if (shiftReferencingRange == "window"){
+  shiftReferencingRangeList <- list()
+  for(i in which(names(argLs)=="shiftReferencingRangeLeft")) 
+  {
+    shiftReferencingRangeLeft <- argLs[[i]]
+    shiftReferencingRangeRight <- argLs[[i+1]]
+    shiftReferencingRangeList <- c(shiftReferencingRangeList,list(c(shiftReferencingRangeLeft,shiftReferencingRangeRight)))
+  }
+}
+
+shiftHandling <- argLs[["shiftHandling"]]
+
+ppmvalue <- argLs[["ppmvalue"]]
+
+
+
+# }
+
+
 # Baseline Correction -------------------------------
   # Inputs
 lambdaBc <- argLs[["lambdaBc"]] 
@@ -386,7 +386,7 @@
 ##======================================================
 
 # Data Matrix
-write.table(round(t(Re(Spectrum_data)),6), file=argLs$dataMatrix, quote=FALSE, row.names=TRUE, sep="\t", col.names=TRUE)
+write.table(t(Re(Spectrum_data)),file=argLs$dataMatrix, quote=FALSE, row.names=TRUE, sep="\t", col.names=TRUE)
 
 # Variable metadata
 write.table(data_variable,file=argLs$variableMetadata, quote=FALSE, row.names=TRUE, sep="\t", col.names=TRUE)
b
diff -r 7d8451d9fff6 -r a6c9f5d6fdc9 nmr_preprocessing/NmrPreprocessing_xml.xml
--- a/nmr_preprocessing/NmrPreprocessing_xml.xml Wed Apr 11 05:32:23 2018 -0400
+++ b/nmr_preprocessing/NmrPreprocessing_xml.xml Thu Aug 09 04:08:30 2018 -0400
b
b'@@ -1,376 +1,386 @@\n-<tool id="NMR_Preprocessing" name="NMR_Preprocessing" version="@WRAPPER_VERSION@">\r\n-    <description> Preprocessing of 1D NMR spectra </description>\r\n-\r\n-    <macros>\r\n-        <import>macros.xml</import>\r\n-    </macros>\r\n+<tool id="NMR_Preprocessing" name="NMR_Preprocessing" version="1.2.0">\r\n+\t<description> Preprocessing of 1D NMR spectra </description>\r\n \r\n-    <expand macro="requirements">\r\n-        <requirement type="package" version="1.9_12">r-ptw</requirement>\r\n-        <requirement type="package" version="1.2_12">r-matrix</requirement>\r\n-    </expand>\r\n-\r\n-    <expand macro="stdio"/>\r\n-\r\n-    <command>\r\n-        ## Wrapper\r\n+    <stdio>\r\n+        <exit_code range="1:" level="fatal" />\r\n+    </stdio>\r\n+\t\r\n+  \t<command>\r\n+  \t    ## Wrapper\r\n         Rscript $__tool_directory__/NmrPreprocessing_wrapper.R\r\n \r\n-        ## Data matrix of FID spectra\r\n-        dataMatrixFid $dataMatrixFid\r\n-        ## Sample metadata matrix\r\n-        sampleMetadataFid $sampleMetadataFid\r\n-\r\n-        ## First order phase correction\r\n-        ## Graphical display\r\n-        FirstOPCGraph $GDC.FirstOPCGraph\r\n-\r\n-        ## Water and / or solvents suppression\r\n-            ## Smoothing parameter\r\n+\t## Data matrix of FID spectra\r\n+\t\tdataMatrixFid $dataMatrixFid\r\n+\t\t\t## Sample metadata matrix\r\n+\t\tsampleMetadataFid $sampleMetadataFid\r\n+\t\t\r\n+\t\t\r\n+\t\t## First order phase correction\r\n+\t\t\t## Graphical display\r\n+\t\tFirstOPCGraph $GDC.FirstOPCGraph\r\n+\t\t\r\n+\t\t## Water and / or solvents suppression\r\n+\t\t    ## Smoothing parameter\r\n         lambda $SS.lambda\r\n \r\n-        ## Graphical display\r\n-        SSGraph $SS.SSGraph\r\n-\r\n-\r\n-        ## Apodization\r\n-        ## Graphical display\r\n-        ApodGraph $Apod.ApodGraph\r\n-\r\n-        apodizationMethod $Apod.apodizationMethod.method\r\n-        #if $Apod.apodizationMethod.method == "exp":\r\n-            ## Line broadening for the exponential window\r\n-            expLB $Apod.apodizationMethod.expLB\r\n-        #end if\r\n-        #if $Apod.apodizationMethod.method == "cos2":\r\n-            ## Phase\r\n-            phase $Apod.apodizationMethod.phase\r\n-        #end if\r\n-        #if $Apod.apodizationMethod.method == "hanning":\r\n-            ## Phase\r\n-            phase $Apod.apodizationMethod.phase\r\n-        #end if\r\n-        #if $Apod.apodizationMethod.method == "hamming":\r\n-            ## Phase\r\n-            phase $Apod.apodizationMethod.phase\r\n-        #end if\r\n-        #if $Apod.apodizationMethod.method == "blockexp":\r\n-            ## Proportion of signal in the window\r\n-            rectRatio $Apod.apodizationMethod.rectRatio\r\n-            expLB $Apod.apodizationMethod.expLB\r\n-        #end if\r\n-        #if $Apod.apodizationMethod.method == "blockcos2":\r\n-            ## Proportion of signal in the window\r\n-            rectRatio $Apod.apodizationMethod.rectRatio\r\n-        #end if\r\n-        #if $Apod.apodizationMethod.method == "gauss":\r\n-            ## Line broadening for the gaussian window\r\n-            gaussLB $Apod.apodizationMethod.gaussLB\r\n-        #end if\r\n-\r\n-        ## Fourier transform\r\n-        ## Graphical display\r\n-        FTGraph $FT.FTGraph\r\n-\r\n-        ## Zero order phase correction\r\n-        ## Graphical display\r\n-        ZeroOPCGraph $ZOPC.ZeroOPCGraph\r\n-\r\n-        zeroOrderPhaseMethod $ZOPC.zeroOrderPhaseMethod\r\n-\r\n-        excludeZoneZeroPhase.choice ${ZOPC.excludeZoneZeroPhase.choice}\r\n+\t\t\t## Graphical display\r\n+\t\tSSGraph $SS.SSGraph\r\n+\t\t\r\n+\t\t\r\n+\t\t## Apodization\r\n+\t\t\t\t## Graphical display\r\n+\t\tApodGraph $Apod.ApodGraph\r\n+\t\r\n+\t    apodizationMethod $Apod.apodizationMethod.method\r\n+\t\t    #if $Apod.apodizationMethod.method == "exp":\r\n+\t\t\t    ## Line broadening for the exponential window\r\n+\t\t\t    expLB $Apod.apodizationMethod.expLB \r\n+\t\t    #end if\r\n+\t\t    #if $Apod.apodizationMethod.method == "cos2":\r\n+\t\t\t    ## Phase\r\n+\t\t\t    phase $Apod.apodizationMethod.phase\r\n+\t\t    #end if\r\n+\t\t    #if $Apod.apodizationMethod.method == "hanning":\r\n+\t\t\t    ## Phase\r\n+\t\t\t    phase $Apod.apodizationMethod'..b'Franco (marie.tremblay-franco@inra.fr; Galaxy integration)\r\n+\r\n \r\n-@HELP_AUTHORS@\r\n+.. class:: infomark\r\n+\r\n+\r\n \r\n \r\n =====================\r\n@@ -432,6 +442,7 @@\n Input files\r\n -----------\r\n \r\n+\r\n +--------------------------------+-----------------+\r\n | File                           |   Format        |\r\n +================================+=================+\r\n@@ -439,19 +450,19 @@\n +--------------------------------+-----------------+\r\n |2 : sampleMetadata              |   tabular       |\r\n +--------------------------------+-----------------+\r\n-\r\n+ \r\n+| \r\n+ \r\n **dataMatrix file**\r\n-\r\n sample x variable matrix with tabular separations and "." as decimal; the table must not contain metadata apart from row and column names; the row names must be identical to the rownames of the sample metadata.\r\n \r\n \r\n **sampleMetadata file**\r\n-\r\n sample x metadata matrix with tabular separations and "." as decimal for numeric metadata and NA for missing values.\r\n \r\n \r\n ----------------------\r\n-  Steps parameters\r\n+  Steps parameters \r\n ----------------------\r\n \r\n **Solvent Suppression**\r\n@@ -511,9 +522,9 @@\n \r\n * zerofilling: The extremities at which a spectrum is not defined are replaced by 0. It makes sense since in practice the spectrum is close to zero at the extremities.\r\n \r\n-* NAfilling: The extremities at which a spectrum is not defined are replaced by NA.\r\n+* NAfilling: The extremities at which a spectrum is not defined are replaced by NA. \r\n \r\n-* circular: The spectra are shifted circularly which means that the end of a spectrum is reproduced at the beginning.\r\n+* circular: The spectra are shifted circularly which means that the end of a spectrum is reproduced at the beginning. \r\n \r\n * cut: The ppm values for which some spectra are not defined are removed.\r\n \r\n@@ -529,7 +540,7 @@\n \r\n **Asymmetry parameter**:  the smaller it is, the less the estimated baseline will try to follow peaks when it is under the spectrum and the more it will try to be under the spectrum.\r\n \r\n-**numerical precision**:  numerical precision for convergence when estimating the baseline.\r\n+**numerical precision**:  numerical precision for convergence when estimating the baseline. \r\n \r\n **Exclusion area(s) for the Baseline Correction**: enables to optimize the criterion with excluded spectral window(s), by default the water region is excluded.\r\n \r\n@@ -537,7 +548,6 @@\n \r\n **Negative intensities to Zero**\r\n ------------------------------------\r\n-\r\n **Set negative intensities to zero**: the set of negative intensities to zero is optional.\r\n \r\n \r\n@@ -546,30 +556,36 @@\n ------------\r\n \r\n NMR_Preprocessing_dataMatrix\r\n-    | tabular output\r\n-    | Data matrix with n rows (descriptors) and p columns (samples) containing the preprocessed spectra.\r\n-    |\r\n+\t| tabular output\r\n+\t| Data matrix with n rows (descriptors) and p columns (samples) containing the preprocessed spectra.\r\n+\t|\r\n \r\n NMR_Preprocessing_variableMetadata\r\n-    | tabular output\r\n-    | Data matrix with 1 row (ppm value) and p columns (descriptors).\r\n-    |\r\n-\r\n+\t| tabular output\r\n+\t| Data matrix with 1 row (ppm value) and p columns (descriptors).\r\n+\t|\r\n+\t\r\n NMR_Preprocessing_log\r\n-    | text output\r\n-    | Contains warnings and the input parameters\r\n-    |\r\n-\r\n+\t| text output\r\n+\t| Contains warnings and the input parameters\r\n+\t|\r\n+\t\r\n NMR_Preprocessing_graph.pdf\r\n-    | pdf output\r\n-    | line plots of preprocessed spectra\r\n-    |\r\n-\r\n+\t| pdf output\r\n+\t| line plots of preprocessed spectra\r\n+\t|\r\n \r\n-@HELP_CHANGELOG@\r\n-\r\n-    </help>\r\n-\r\n-    <expand macro="citation" />\r\n-\r\n+   </help>\r\n+    \r\n+   <citations>\r\n+     \r\n+     <citation type="bibtex">@PhDThesis{Rousseau2011,\r\n+      title = {Statistical contribution to the analysis of metabonomics data in $^1$H NMR spectroscopy},\r\n+      author = {Rousseau, R.},\r\n+      school = {Institut de Statistique, Biostatistique et Sciences Actuarielles, Universit{\\\'e} catholique de Louvain},\r\n+      year = {2011}}\r\n+      </citation>\r\n+      \r\n+    </citations>\r\n+ \r\n </tool>\r\n'
b
diff -r 7d8451d9fff6 -r a6c9f5d6fdc9 nmr_preprocessing/README.rst
--- a/nmr_preprocessing/README.rst Wed Apr 11 05:32:23 2018 -0400
+++ b/nmr_preprocessing/README.rst Thu Aug 09 04:08:30 2018 -0400
b
@@ -1,7 +1,7 @@
 
 Changelog/News
 --------------
-**Version 3.2.0**
+**Version 2017-11-28 - 28/11/2017**
 
 * Updated R scripts and the help section of NMR_ReadFids and NMR_preprocessing
 * Added sections
@@ -14,6 +14,10 @@
 * Switched Internal Referencing (goes second) and Zero Order Phase Correction (goes first)
 
 
-**Version 3.1.0**
+
+**Version 2017-02-13 - 13/02/2017**
+* Implementation of NMR_ReadFids and NMR_preprocessing
 
-* Implementation of NMR_ReadFids and NMR_preprocessing
+
+Test Status
+-----------
b
diff -r 7d8451d9fff6 -r a6c9f5d6fdc9 nmr_preprocessing/ReadFids_xml.xml
--- a/nmr_preprocessing/ReadFids_xml.xml Wed Apr 11 05:32:23 2018 -0400
+++ b/nmr_preprocessing/ReadFids_xml.xml Thu Aug 09 04:08:30 2018 -0400
b
@@ -1,75 +1,81 @@
-<tool id="NMR_Read" name="NMR_Read" version="@WRAPPER_VERSION@">
-    <description> Read Bruker NMR raw files</description>
-
-    <macros>
-        <import>macros.xml</import>
-    </macros>
-
-    <expand macro="requirements" />
-
-    <expand macro="stdio"/>
-
-    <command>
-        ## Wrapper
+<tool id="NMR_Read" name="NMR_Read" version="1.2.0">
+ <description> Read Bruker NMR raw files</description>
+
+    <stdio>
+        <exit_code range="1:" level="fatal" />
+    </stdio>
+
+   <command>
+       ## Wrapper
         Rscript $__tool_directory__/ReadFids_wrapper.R
 
-        ## File input
+ ## File input
         fidzipfile $fidzipfile
-
-        ## Title line
-        title_line $title_line
-
-        ## Subdirectories
-        subdirectories $subdirectories
-
-        ## Use subdirectories names as FID names?
-        dirs_names $dirs_names
+
+ ## Title line
+ title_line $title_line
+
+ ## Subdirectories
+ subdirectories $subdirectories
+
+ ## Use subdirectories names as FID names?
+ dirs_names $dirs_names
 
         ## Outputs
         dataMatrix $dataMatrix
         sampleMetadata $sampleMetadata
         logOut $logOut
         graphOut $graphOut
-
-    </command>
-
-    <inputs>
-        <param name="fidzipfile" type="data" format="no_unzip.zip" label="Bruker FID file" />
-        <param name="title_line" label="Specify the line in the title file to recover the FID names (usually in pdata/1/title)" type="integer" value="1" size="100" help="Default value is line 1"/>
+
+ </command>
+
+   <inputs>
+ <param name="fidzipfile" type="data" format="no_unzip.zip" label="Bruker FID file" />
+        
+ <param name="title_line" label="Specify the line in the title file to recover the FID names (usually in pdata/1/title)" type="integer" value="1" size="100" help="Default value is line 1"/>
 
         <param name="subdirectories" label="Presence of subdirectories?" type="select" help="Select 'FALSE' when there is no subdirectories, 'TRUE' if there are subdirectories">
             <option value="FALSE"> FALSE </option>
             <option value="TRUE"> TRUE </option>
         </param>
-
+        
         <param name="dirs_names" label="Use (sub)directories names as FID names?" type="select" help="Select 'TRUE' to use the subdirectories names as the FID names (instead of looking in the title file)">
             <option value="FALSE"> FALSE </option>
             <option value="TRUE"> TRUE </option>
         </param>
-    </inputs>
+ </inputs>
 
-    <outputs>
-        <data format="tabular" name="dataMatrix" label="${tool.name}_dataMatrix" />
-        <data format="tabular" name="sampleMetadata" label="${tool.name}_sampleMetadata" />
-        <data format="txt" name="logOut" label="${tool.name}_log" />
-        <data format="pdf" name="graphOut" label="${tool.name}_graph" />
-    </outputs>
+
+
+ <outputs>
+ <data format="tabular" name="dataMatrix" label="${tool.name}_dataMatrix" />
+ <data format="tabular" name="sampleMetadata" label="${tool.name}_sampleMetadata" />
+ <data format="txt" name="logOut" label="${tool.name}_log" />
+ <data format="pdf" name="graphOut" label="${tool.name}_graph" />
+ </outputs>
 
 
-    <tests>
+ <tests>
         <test>
           <param name="fidzipfile" value="MTBLS1.zip" ftype="zip" />
           <param name="title_line" value="1" />
           <param name="subdirectories" value="TRUE" />
           <param name="dirs_names" value="TRUE" />
-
+           
           <output name="dataMatrix" value="NMR_ReadFids_dataMatrix.tabular" />
+  
         </test>
-    </tests>
+  </tests>
+
+  
+  
+ <help>
 
-    <help>
+.. class:: infomark
 
-@HELP_AUTHORS@
+**Authors** Manon Martin (manon.martin@uclouvain.be) and Marie Tremblay-Franco (marie.tremblay-franco@inra.fr; Galaxy integration)
+
+.. class:: infomark
 
 
 =============
@@ -143,43 +149,43 @@
 ----------
 
 FID Title line
-    | Line in the acqus file to find the FID title (name)
-    |
+ | Line in the acqus file to find the FID title (name)
+ |
 
 subdirectories
-    | Organization of individual's files
-    | TRUE: will search inside subdirectories for FIDs and will merge them to have unique FID and info matrices.
-    |
-
+ | Organization of individual's files
+ | TRUE: will search inside subdirectories for FIDs and will merge them to have unique FID and info matrices.
+ |
+
 dirs_names
-    | Use the (sub)directories names as FID names?
-    |
-
-
+ | Use the (sub)directories names as FID names?
+ |
+
+
 ------------
 Output files
 ------------
 
 NMR_Read_dataMatrix
-    | tabular output
-    | Data matrix with n rows (samples) and p columns (time) containing the raw FIDs.
-    |
+ | tabular output
+ | Data matrix with n rows (samples) and p columns (time) containing the raw FIDs.
+ |
 
 NMR_Read_sampleMetadata
-    | tabular output
-    | Data matrix with n rows (samples) containing the acquisition parameters for each sample.
-    |
-
+ | tabular output
+ | Data matrix with n rows (samples) containing the acquisition parameters for each sample.
+ |
+
 NMR_Read_log
-    | Text output
-    | Contains warnings
-    |
-
+ | Text output
+ | Contains warnings
+ |
 
+
 NMR_Read_graph
-    | pdf output
-    | line plots of FID
-    |
+ | pdf output
+ | line plots of FID
+ |
 
 
 Creating the zip file
@@ -189,7 +195,8 @@
 
 Must contain at least the following files for every sample: fid, acqu and acqus
 
-.. image:: ./static/images/ReadFids.png
+.. image:: ./static/images/ReadFids.png 
+    :height: 400 
 
 
 
@@ -202,10 +209,20 @@
 (4) don't use title file and no sub-directories: subdirectories = FALSE,  dirs_names = TRUE
 
 
-@HELP_CHANGELOG@
 
-    </help>
-
-    <expand macro="citation" />
-
+   </help>
+   
+   
+   <citations>
+     
+      <citation type="bibtex">@PhDThesis{Rousseau2011,
+      title = {Statistical contribution to the analysis of metabonomics data in $^1$H NMR spectroscopy},
+      author = {Rousseau, R.},
+      school = {Institut de Statistique, Biostatistique et Sciences Actuarielles, Universit{\'e} catholique de Louvain},
+      year = {2011}}
+      </citation>
+      
+   </citations> 
+   
+   
 </tool>
b
diff -r 7d8451d9fff6 -r a6c9f5d6fdc9 nmr_preprocessing/test-data/NMR_Preprocessing_dataMatrix.tabular
--- a/nmr_preprocessing/test-data/NMR_Preprocessing_dataMatrix.tabular Wed Apr 11 05:32:23 2018 -0400
+++ b/nmr_preprocessing/test-data/NMR_Preprocessing_dataMatrix.tabular Thu Aug 09 04:08:30 2018 -0400
b
b'@@ -1,34941 +1,17493 @@\n ADG10003u_007\tADG10003u_009\tADG10003u_015\tADG10003u_017\tADG10003u_021\r\n-<<<<<<< HEAD\r\n-14.7722158796892\t0\t440513.532234769\t206138.121855941\t386826.808374734\t92280.0131501408\r\n-14.7716051547065\t0\t438297.908551098\t205525.154993051\t384756.026954071\t91945.8093173809\r\n-14.7709944297239\t0\t436082.064610661\t204912.0850611\t382685.052120003\t0\r\n-14.7703837047413\t0\t433865.561007737\t204298.706228449\t380613.498081113\t0\r\n-14.7697729797587\t30144.8119983755\t431647.740295574\t203684.710207419\t378540.787703458\t23696.6165445194\r\n-14.769162254776\t0\t429427.728094639\t203069.686560974\t0\t7754.08402369477\r\n-14.7685515297934\t5926.73644284898\t427204.434201527\t0\t0\t19590.6029616454\r\n-14.7679408048108\t36986.2255620162\t0\t0\t0\t25058.0694442252\r\n-14.7673300798282\t70143.6115586768\t0\t6942.80166939506\t0\t0\r\n-14.7667193548455\t90574.2536680185\t0\t19793.0915533878\t0\t1978.80832132518\r\n-14.7661086298629\t79089.9203496244\t0\t16683.8090673361\t12180.9955964271\t33785.5250916638\r\n-14.7654979048803\t72400.5256625149\t0\t0\t91434.6961606296\t26307.2320436728\r\n-14.7648871798977\t91724.9381991385\t35417.2496639297\t0\t15143.0247514394\t0\r\n-14.7642764549151\t7302.11448863981\t219.649400987197\t29624.9884578175\t27541.2779513435\t0\r\n-14.7636657299324\t64685.7651771302\t0\t40730.9463263804\t52275.8413168968\t20636.2884581411\r\n-14.7630550049498\t46784.0072468099\t14884.9183776884\t3004.26610640489\t44232.4911551095\t9534.57448936871\r\n-14.7624442799672\t26331.3169893605\t2675.32533106103\t32911.8233718391\t78790.1071316482\t3464.8303096389\r\n-14.7618335549846\t275.980938694731\t61671.6188975403\t18895.3136958877\t29703.2703198509\t15765.3654977631\r\n-14.7612228300019\t97562.6277645925\t71104.8400093025\t51479.0358929405\t71036.5396579774\t5281.23886798379\r\n-14.7606121050193\t0\t45125.2967255506\t13545.2412686505\t69471.6259213319\t30180.0036257685\r\n-14.7600013800367\t113484.551027679\t64100.5125279474\t37387.3369167877\t33785.4994261957\t25.064036706739\r\n-14.7593906550541\t55395.4523825558\t57851.7413212176\t35378.3770915604\t98237.9055881621\t48815.487828535\r\n-14.7587799300714\t44661.3357435991\t47590.5905180213\t26581.3819672198\t141366.450120351\t7083.52571554123\r\n-14.7581692050888\t36475.9050251448\t0\t18639.4812528994\t51477.3383035234\t0\r\n-14.7575584801062\t0\t74204.0834911913\t20895.6019714467\t33839.2365367223\t20607.3277338556\r\n-14.7569477551236\t48542.7572804512\t46841.8794917137\t47586.1981681534\t59719.6908817074\t4312.35555130724\r\n-14.7563370301409\t34111.1750789239\t59226.3786693994\t2987.47762360141\t0\t0\r\n-14.7557263051583\t50795.2724328581\t35114.8377929819\t25911.7101641376\t48887.3051690677\t7541.56272336398\r\n-14.7551155801757\t5499.11078507005\t65682.9807913334\t16747.2884535374\t97974.0261761903\t8375.14266184885\r\n-14.7545048551931\t0\t72761.21850802\t23123.0783127933\t62881.4144799234\t7946.36660989953\r\n-14.7538941302105\t95186.7387449513\t16351.254511064\t0\t60464.5949522876\t7969.71033352629\r\n-14.7532834052278\t96593.3663525092\t24177.982913017\t58782.3157580608\t65987.1287113844\t7627.4371407849\r\n-14.7526726802452\t44305.7649991353\t72813.0336050838\t36743.0537271027\t64751.6834527152\t0\r\n-14.7520619552626\t94224.5205617654\t23463.6639256763\t0\t95852.8449954447\t300.955526139966\r\n-14.75145123028\t87493.5870291964\t58796.132466105\t40234.5815756267\t74059.606363308\t23252.5277940441\r\n-14.7508405052973\t37413.6555846478\t67993.0341827511\t0\t27822.3512351813\t37292.6871961524\r\n-14.7502297803147\t95174.0237518195\t33555.1360774164\t52034.0057960021\t58092.7462412568\t10728.8797605836\r\n-14.7496190553321\t36154.1178795401\t54292.4567687972\t72012.0681579454\t64901.3681339195\t14281.5448310932\r\n-14.7490083303495\t104940.494574311\t17549.7351009792\t60210.6804534211\t47150.5235399407\t0\r\n-14.7483976053668\t29295.0495227508\t125107.449528275\t0\t54571.0864760204\t11195.161926094\r\n-14.7477868803842\t44015.2581802983\t47916.0664394849\t0\t112718.159419718\t14917.9621603628\r\n-14.7471761554016\t10687.5252592473\t48314.3441882255\t52359.2234142178\t72233.7148329129\t17025.8856819391\r\n-14.746565430419\t78175.9536668928\t76899.9866205082\t39167.5679287497\t77730.8135634694\t7014.11474969854\r\n-14.7459547054364\t'..b'233\t56091.0329124115\t13785.5437186784\t24517.525886621\t77393.3003459935\t22806.5836463638\r\n+-5.21864497651496\t95271.4804109781\t25258.2568666021\t39136.8636353963\t89487.3579235256\t6512.78534802136\r\n+-5.21925570149758\t84642.046191929\t34606.6491363958\t0\t72769.2133874604\t23439.4398121739\r\n+-5.2198664264802\t103626.41587394\t0\t15223.641733809\t23526.5900674434\t20026.596130921\r\n+-5.22047715146283\t83913.9093732063\t0\t4087.95547400204\t92897.21541942\t25649.2080348374\r\n+-5.22108787644545\t104074.626641938\t0\t32351.863999043\t36343.0606788519\t0\r\n+-5.22169860142807\t80033.6929035247\t0\t1027.61448883879\t38847.973318032\t21702.5728199682\r\n+-5.2223093264107\t81256.448630568\t16639.4148744572\t19815.6787936976\t94720.6927588634\t9946.66893267387\r\n+-5.22292005139332\t51462.8014447756\t30200.8171744159\t36681.2410237453\t92917.8866424875\t4364.35716948588\r\n+-5.22353077637594\t64003.3114838995\t3673.30583060352\t20930.9547020872\t57272.4977614591\t18322.7284537568\r\n+-5.22414150135857\t28139.2792075945\t17489.0060490482\t35127.8227999644\t64351.5329411713\t23843.5067022958\r\n+-5.22475222634119\t91764.0689140822\t0\t28297.1813715125\t90936.0383239264\t36080.0223870204\r\n+-5.22536295132381\t82694.6105746544\t26086.5508518998\t14173.4061646828\t77329.5052358563\t0\r\n+-5.22597367630644\t66404.2652549884\t21546.5868233964\t2631.75534772935\t89721.5445636178\t18115.6369546203\r\n+-5.22658440128906\t93838.2190917268\t46018.6766416407\t15898.8341737854\t49306.9081457379\t0\r\n+-5.22719512627168\t72041.2421704539\t2882.18149365438\t39936.983438689\t105374.471438442\t17275.0163921979\r\n+-5.22780585125431\t81588.6331611664\t32047.3942964197\t31328.3607000565\t78869.5419613461\t782.685754871334\r\n+-5.22841657623693\t93936.1687421534\t7340.06864209939\t21314.2882837874\t16473.0107636467\t25455.3849158172\r\n+-5.22902730121955\t64995.9422106001\t27739.0532356662\t15743.8024877714\t84782.2675069961\t12403.6603472982\r\n+-5.22963802620218\t60771.1302675189\t20091.4798984081\t17039.8900502895\t72348.0455944446\t10801.8525648924\r\n+-5.2302487511848\t96510.5728016341\t28216.1768870641\t33752.7874840866\t98852.5622043253\t28911.1565567843\r\n+-5.23085947616742\t88305.5208362822\t16104.5169451112\t9243.34518523604\t121235.062198148\t6304.73075572893\r\n+-5.23147020115004\t70250.8627642358\t31641.4115810876\t27678.802211328\t71384.787049899\t20165.422883212\r\n+-5.23208092613267\t64763.6110146298\t40002.7552748451\t27094.7501565098\t112854.864845268\t22880.3702738751\r\n+-5.23269165111529\t84945.1040077067\t4545.28966643714\t0\t111108.660013046\t12412.9797249703\r\n+-5.23330237609791\t129690.041744252\t0\t48307.8753675322\t143210.468055929\t17925.3376670017\r\n+-5.23391310108054\t114850.962036166\t38762.8505654453\t35659.4381442069\t111184.673286245\t0\r\n+-5.23452382606316\t124851.359354096\t7755.23650922778\t3420.22272110438\t110175.780730879\t20578.7013435836\r\n+-5.23513455104578\t107188.833744101\t1058.97615289368\t0\t87991.5014585232\t17874.6784868715\r\n+-5.23574527602841\t103782.149429569\t26910.2846563134\t9645.13198233415\t101644.284480318\t8381.26221414196\r\n+-5.23635600101103\t143359.946496284\t27663.2967007793\t21066.6949492662\t124953.935120636\t7151.23818329217\r\n+-5.23696672599365\t98170.517307091\t7975.50462918408\t15676.5350046159\t135895.441311671\t22355.7091703624\r\n+-5.23757745097628\t64148.1482368948\t36074.2937855784\t17507.7727904534\t119490.681324343\t13577.6723609028\r\n+-5.2381881759589\t103101.352755161\t41802.9866991295\t42552.6467230021\t97950.3706039905\t26906.5335908104\r\n+-5.23879890094152\t130747.356850558\t37938.2775539559\t28456.7996429502\t157667.466141347\t14934.5241083397\r\n+-5.23940962592415\t122302.249563884\t46359.7666440134\t22790.9274400894\t143659.330733121\t16105.1160098214\r\n+-5.24002035090677\t134032.568882135\t0\t21983.7580527431\t112282.966571831\t31920.1825255567\r\n+-5.24063107588939\t0\t0\t0\t139625.517930121\t34113.441327679\r\n+-5.24124180087202\t0\t33831.5766284231\t0\t158770.287071939\t0\r\n+-5.24185252585464\t0\t49856.9571287011\t18399.7414273817\t133535.480976215\t0\r\n+-5.24246325083726\t0\t0\t9567.52639632698\t109040.718494841\t0\r\n+-5.24307397581988\t0\t0\t4624.77826940714\t0\t0\r\n+-5.24368470080251\t0\t4769.5110939967\t59415.5822153283\t0\t0\r\n'