knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

concentr8r

concentr8r is a collection of normalisation functions that are intended for magnetic resonance spectroscopy (MRS) spectra, more specifically that from nuclear magnetic resonance (NMR) and mass spectrometry (MS). Normalisation is a crucial yet context-dependent aspect of analysing MRS data meaning that one method may work perfectly with one study but make the spectra in another study worse so having a diverse range of techniques available is useful. This is a collection of such methods sourced from published literature.

Installation

concentr8r is currently only available on GitHub and can be sourced using the code below:

# install.packages("devtools")
devtools::install_github("kylebario/concentr8r")

Standard Pipeline

The intended use of concentr8r is to manipulate your NMR spectra so that they are as comparable as possible. This includes properly preprocessing the spectra, removing regions that are non-quantative, as well as correcting/flattening the baseline. It also includes normalising your spectra and removing the effects of dilution so that their concentrations are comparable.
Below is the code for the standard pipeline used to preprocess NMR spectra:

library(concentr8r)
read_in(path=system.file('extdata',package='concentr8r'),exp_type=list(exp=c("PROF_URINE_NOESY")), n_spec = 'multiple')
plot(ppm, X[2,], type = 'l', col = 'red', main = 'The Same NMR Spectrum (Processed vs. Non Processed)', xlab = 'Chemical Shift (ppm)', ylab = 'Intensity', xlim = c(10,-1))
preproc(X, ppm, meta, flip = TRUE, cali = TRUE, calib = 'tsp')
points(ppm, X[2,], type = 'l', col = 'blue')
legend('topleft', legend = c("Unprocessed", "Processed"), col = c('red', 'blue'), lty = 1)
plot(ppm, X[2,], type = 'l', col = 'red', main = 'Two Spectra Unnormalised', xlab = 'Chemical Shift (ppm)', ylab = 'Intensity', xlim = c(9.5,0.25))
points(ppm, X[1,], type = 'l', col = 'blue')
legend('topleft', legend = c("Spectrum 1", "Spectrum 2"), col = c('red', 'blue'), lty = 1)
pqNorm(X, noi)
plot(ppm, X_pqn[2,], type = 'l', col = 'red', main = 'Two Spectra Normalised', xlab = 'Chemical Shift (ppm)', ylab = 'Intensity', xlim = c(9.5,0.25))
points(ppm, X_pqn[1,], type = 'l', col = 'blue')
legend('topleft', legend = c("Spectrum 1", "Spectrum 2"), col = c('red', 'blue'), lty = 1)

As you can see there are multiple stages in preprocessing, that build to producing highly comparable spectra which is made all the easier by concentr8r.

Data Manipulation Functions

Data Manipulation ranges from ensuring the spectra are correctly orientated to scaling spectra based on their relationship to a reference. Here are some of the functions within concentr8r designed to do just that.

Flip

library(concentr8r)
read_in(path=system.file('extdata',package='concentr8r'),exp_type=list(exp=c("PROF_URINE_NOESY")))
Xf <- flip(X, ppm)
par(mfrow = c(1,2))
plot(ppm,X[1,],type='l',xlim=c(9.5,0.25),col='red',main="Disorientated NMR Spectrum",ylab="X")
plot(ppm,Xf[1,],type='l',xlim=c(9.5,0.25),col ='blue',main="Orientated NMR Spectrum",ylab="Xf")


kylebario/concentr8r documentation built on Nov. 9, 2022, 12:47 a.m.