1 Introduction

This document provides a brief summary on how to use the PepsNMR package. In this package, pre-processing functions transform raw FID signals from 1H NMR spectroscopy into a set of interpretable spectra.

2 Installation

The PepsNMR package is available on Bioconductor and can be installed via BiocManager::install:

if (!requireNamespace("BiocManager", quietly = TRUE))
  install.packages("BiocManager")

BiocManager::install("PepsNMR", 
                     dependencies = c("Depends", "Imports", "Suggests"))

Note tha installing the Suggests dependencies will install the PepsNMRData package to run the demo below.

The package needs to be loaded once installed to be used:

library(PepsNMR)

The package development version is available on Github (Master branch): https://github.com/ManonMartin/PepsNMR, although it is highly recommended to rely on the Bioconductor release version of the package to avoid any package version mismatch.

3 Data importation

The first step is meant to access the raw data files. To import Free Induction Decays (FIDs) in Bruker format, use the ReadFids function. This function will return a list with the FID data matrix (saved in Fid_data) and metadata about these FIDs (saved in Fid_info).

fidList <- ReadFids(file.path(path,dataset_name)) 

Fid_data <- fidList[["Fid_data"]]
Fid_info <- fidList[["Fid_info"]]

The possible directory structures are illustrated here:

Accepted directory structures for the raw Bruker files

Figure 1: Accepted directory structures for the raw Bruker files

And is to be linked with the possible options of the ReadFids function:

  1. If use of title file and presence of sub-directories: set the FID Title line, subdirs = TRUE, dirs.names = FALSE
  2. If use of title file and no sub-directories: set the FID Title line, subdirs = FALSE, dirs.names = FALSE
  3. If no use of title file and presence of sub-directories: subdirs = TRUE, dirs.names = TRUE
  4. If no use of title file and no sub-directories: subdirs = FALSE, dirs.names = TRUE

4 Pre-processing steps

Here is the recommended pre-processing workflow on the FIDs and the spectra once the raw data have been loaded in R:

Table 1: Pre-processing steps
They are presented in the suggested order.
Steps Description
Group Delay Correction Correct for the Bruker Group Delay.
Solvent Suppression Remove the solvent signal from the FIDs.
Apodization Increase the Signal-to-Noise ratio of the FIDs.
ZeroFilling Improve the visual representation of the spectra.
Fourier Transform Transform the FIDs into a spectrum and convert the frequency scale (Hz -> ppm).
Zero Order Phase Correction Correct for the zero order phase dephasing.
Internal Referencing Calibrate the spectra with an internal reference compound. Referencing with an internal (e.g. TMSP at 0 ppm)
Baseline Correction Remove the spectral baseline.
Negative Values Zeroing Set negatives values to 0.
Warping Warp the spectra according to a reference spectrum.
Window Selection Select the informative part of the spectrum.
Bucketing Data reduction.
Region Removal Set a desired spectral region to 0.
Zone Aggregation Aggregate a spectral region into a single peak.
Normalization Normalize the spectra.

Information on each function is provided in R, (e.g. type ?ReadFids in the R console) and methodological details are found in Martin et al. (2018).

5 Available datasets

Human serum (HS) and urine (HU) datasets are available as raw data (FIDs in Bruker format) and as (partially) pre-processed signals/spectra in the ad hoc PepsNMRData package that is automatically installed with PepsNMR (through ).

Here are examples of available datasets:

library(PepsNMRData)

str(FidData_HU)
#>  cplx [1:24, 1:29411] 0+0i 0+0i 0+0i ...
#>  - attr(*, "dimnames")=List of 2
#>   ..$ : chr [1:24] "S1-D0-E1" "S1-D0-E2" "S1-D1-E2" "S2-D0-E2" ...
#>   ..$ : chr [1:29411] "0" "5.1e-05" "0.000102" "0.000153" ...

str(FinalSpectra_HS)
#>  cplx [1:32, 1:500] 0-371030i 0-362686i 0-216899i ...
#>  - attr(*, "dimnames")=List of 2
#>   ..$ : chr [1:32] "J1-D1-1D-T1" "J3-D2-1D-T8" "J3-D3-1D-T9" "J3-D4-1D-T14" ...
#>   ..$ : chr [1:500] "9.98986984692192" "9.97027064485524" "9.95067144278856" "9.93107224072187" ...

Information for each dataset is available, (e.g. enter ?FidData_HS in the R Console).

6 Demo on the HSerum dataset

6.1 Load the data

Raw Bruker FIDs can be loaded from where PepsNMRData has been intalled:

data_path <-  system.file("extdata", package = "PepsNMRData")
dir(data_path)
#> [1] "Group_HS.csv" "HumanSerum"

6.2 Read the FID data file

To import FIDs in Bruker format, the ReadFids function is used. This function will return a list with the FID data matrix (here saved as Fid_data) and information about these FIDs (here saved as Fid_info).

# ==== read the FIDs and their metadata =================
fidList <- ReadFids(file.path(data_path, "HumanSerum"))
Fid_data0 <- fidList[["Fid_data"]]
Fid_info <- fidList[["Fid_info"]]
kable(head(Fid_info))
TD BYTORDA DIGMOD DECIM DSPFVS SW_h SW O1 DTYPA DT
J1-D1-1D-T1 65536 1 1 16 12 10245.9 20.48638 2352.222 0 4.88e-05
J3-D2-1D-T8 65536 1 1 16 12 10245.9 20.48638 2352.222 0 4.88e-05
J3-D3-1D-T9 65536 1 1 16 12 10245.9 20.48638 2352.222 0 4.88e-05
J3-D4-1D-T14 65536 1 1 16 12 10245.9 20.48638 2352.222 0 4.88e-05
J4-D1-1D-T4 65536 1 1 16 12 10245.9 20.48638 2352.222 0 4.88e-05
J4-D2-1D-T7 65536 1 1 16 12 10245.9 20.48638 2352.222 0 4.88e-05
Raw FID.

Figure 2: Raw FID

6.3 Group Delay Correction

The Bruker’s digital filter originally produces a Group Delay that is removed during this step.

# ==== GroupDelayCorrection =================
Fid_data.GDC <- GroupDelayCorrection(Fid_data0, Fid_info)