Package 'SOMnmR'

Title: Analysis of Soil Organic Matter using Nuclear Magnetic Resonance
Description: Integrates the 13C nuclear magnetic resonance (NMR) spectra using different integration ranges ("Smernik", "Bonanomi","Molecular Mixing Model"). Output depends on the "NMRmeth" chosen. For the Molecular Mixing Model, a measurement of the fitting quality is given by its R-factor. For more details see Colocho Hurtarte, L. C. (2023). <doi:10.5281/zenodo.10137768>
Authors: Luis Colocho [aut, cre]
Maintainer: Luis Colocho <[email protected]>
License: MIT + file LICENSE
Version: 0.3.0
Built: 2025-01-19 04:30:21 UTC
Source: https://github.com/luiscol8/somnmr

Help Index


Porting for linear combination fitting

Description

The function can be used to check which combinations of standards produce a good fit.

Usage

fit_LCF(
  all.samples,
  all.standards,
  ecosys = NULL,
  amoSTD,
  ex.smaller = NULL,
  file.output = NULL,
  best.fits = NULL,
  NMRmeth,
  FixNC
)

Arguments

all.samples

List of all samples

all.standards

List of all standards

ecosys

Standards to be used for the MMM, can be Terrestrial("Terr_Nelson" or "Terr_Baldock") or Aquatic ("Aqua_Nelson" or "Aqua_Baldock")

amoSTD

Use at most X standards

ex.smaller

Exclude portions smaller than a given value (decimal form), default to NULL

file.output

Possibility to have a file output, default to NULL

best.fits

Possibility to output more than the best fit (e.g. the first 10 best fits), default to 1

NMRmeth

Regions to be integrated, methods available include: "4region", "Bonanomi", "Smernik" and Molecular mixing model ("MMM").

FixNC

TRUE or FALSE, for fixing or not the NC ratio on the sample fitting.

Value

A dataframe containing the result of the fitting exercise for all files.


GarciaF200 sub data set from Garcia-Franco et al. (2021)

Description

Contains 3 CP MAS 13C NMR spectra.

Usage

GarciaF200

Format

A nested list with 3 sub-lists:

1 to 3

A list containing the vegetation NMR spectrum of one of the following sites.

name

"EB_Vegetation", "Fendt_Vegetation", "Graswang_Vegetation"

raw.spec

A data frame with 2 columns:

ppm

Numeric vector.

raw.intensity

Numeric vector.

Details

The spectra were taken in a NMR spectrometer with field strength of 200 MHz and MAS rate of 6.8 kHz

Source

Garcia-Franco et al. (2021) DOI: 10.1007/s00374-020-01518-0

Examples

data(GarciaF200)

Hall sub data set from Hall et al. (2020)

Description

Contains 17 CP MAS 13C NMR spectra.

Usage

Hall300

Format

A nested list with 17 sub-lists:

1 to 17

A list containing the soil NMR spectrum of one of the following sites.

name

"Calhoun", "CPER", "DCFS", "elve", "GRSM", "HARV", "icac", "JERC", "KONZ", "LENO", "MOAB", "NIWO", "ONAQ", "samt", "SCBI", "UNDE", "WOOD"

raw.spec

A data frame with 2 columns:

ppm

Numeric vector.

raw.intensity

Numeric vector.

Details

The spectra were taken in a NMR spectrometer with field strength of 300 MHz and MAS rate of 12 kHz

Source

https://portal.edirepository.org/nis/mapbrowse?packageid=edi.575.1

Examples

data(Hall300)

Integration function

Description

This function allows you to integrate the 13C-NMR spectra using diferent integration regions. The loaded Raw spectra can be integrated using the spinning side bands regions(default), the Bonanomi("Bonanomi") regions or the Molecular Mixing Model regions("MMM"). The function returns the corrected, normalized and flattened spectrum

Usage

int_nmr(raw.spec, NMRmeth = NULL, NMR_field = NULL, NMR_rotation = NULL)

Arguments

raw.spec

Raw spectrum

NMRmeth

Regions to be integrated. Default is spinning side bands, other methods available include: Bonanomi ("Bonanomi") and Molecular mixing model ("MMM" or "MMM").

NMR_field

Magnetic field of the NMR

NMR_rotation

Rotation frequency of the sample probe in the NMR

Value

A nested list containing in the first level a string (name) and a list (data) which contains two data frames one the raw spectrum and another the output of table of the integration with the spinning side bands.

Examples

data(GarciaF200)
Integralregions <- int_nmr(GarciaF200, NMRmeth = "4region", NMR_field = 200, NMR_rotation = 6800)

Create .csv file for CN data

Description

This function copies the spectra read using the read_spec function and creates a .csv file with a colum with their names and two empty columns where the user must add the C and N values. Thereafter the file is read with the function nc_data

Usage

mk_nc_data(raw.spec)

Arguments

raw.spec

The uploaded spectra read using the read_spec function

Value

A data frame with three columns, one containing the names extracted from the raw.spec, and two columns to be filled manually with the carbon and nitrogen values.

Examples

## any .txt file as output from BRUKER

All combination fitting of NMR spectra.

Description

The function wraps the Linear combination fit of the integrated regions of the molecular mixing model.

Usage

MMM_fit(sample, standards, ex.smaller = NULL, NMRmeth, FixNC)

Arguments

sample

Sample Integrals

standards

List of all standards

ex.smaller

Exclude portions smaller than a given value (decimal form), default to NULL

NMRmeth

Regions to be integrated, methods available include: "4region", "Bonanomi", "Smernik" and Molecular mixing model ("MMM").

FixNC

TRUE or FALSE, for fixing or not the NC ratio on the sample fitting.

Value

A dataframe containing the result of the fitting exercise.


Linear combination fitting solve function

Description

Quadratic programming solution function for linear combination fitting (LCF)

Usage

MMM_solve_QP(LCF.stds, LCF.samp, NMRmeth = NULL, FixNC)

Arguments

LCF.stds

Standards for LCF

LCF.samp

NMR Sample(s) for LCF

NMRmeth

Regions to be integrated, methods available include: "4region", "Bonanomi", "Smernik" and Molecular mixing model ("MMM").

FixNC

TRUE or FALSE, for fixing or not the NC ratio on the sample fitting.

Value

A dataframe containing the result of the quadratic programming exercise, constrained or not by the Nc ratio (FixNC)


N/C data merge function

Description

This function allows you import a .csv file and create a dataframe with the C and N data of the samples been processed. The created dataframe will be merged with the spectral data during the fitting.

Usage

nc_data(NCdata)

Arguments

NCdata

Raw spectrum

Value

A dataframe with the molar ratio between the nitrogen and carbon.


Hall sub data set from Hall et al. (2020)

Description

Contains 17 measurements of N and C, presented as molar N:C ratios.

Usage

ncHall300

Format

A nested list with 17 sub-lists:

1 to 17

A list containing the soil NMR spectrum of one of the following sites.

name

"Calhoun", "CPER", "DCFS", "elve", "GRSM", "HARV", "icac", "JERC", "KONZ", "LENO", "MOAB", "NIWO", "ONAQ", "samt", "SCBI", "UNDE", "WOOD"

NC

Numeric vector.

Source

https://portal.edirepository.org/nis/mapbrowse?packageid=edi.575.1

Examples

data(ncHall300)

Create a data frame of standard NMR areas

Description

The function creates a data frame with all standards of the selected ecosystem (Terrestrial or Aquatic).

Usage

NMR_table(NMRmeth = NULL)

Arguments

NMRmeth

Regions to be integrated, methods available include: "4region", "Bonanomi", "Smernik" and Molecular mixing model ("MMM").

Value

A data frame containing the starting (from) and ending (to) ppm integral ranges of the different C functional groups.

Examples

see_NMR_table <- NMR_table(NMRmeth="4region")

NMR Plotting Function

Description

This function allows you to plot the 13C-NMR spectra using marking different integration regions. The loaded Raw spectra are intensity normalized and plotted with the chosen integration regions, either spinning side bands (default), the Bonanomi("Bonanomi") regions or the Molecular Mixing Model regions("MMM"). The function returns the plots as images either tiff or png, normalized and flattened spectrum

Usage

plot_NMR(
  raw.spec,
  NMRmeth = NULL,
  use.tiff = NULL,
  set.plot.ymax = NULL,
  file.output = NULL
)

Arguments

raw.spec

loaded NMR spectra

NMRmeth

Regions to be integrated, methods available include: "4region", "Bonanomi", "Smernik" and Molecular mixing model ("MMM").

use.tiff

Logical, default to FALSE (use png)

set.plot.ymax

Set maximum of plot y axis, defaults to NULL

file.output

Logical, default to FALSE

Value

A plot of the NMR spectrum and a csv file of the data plotted.

Examples

library(ggplot2)
data("GarciaF200")
plot_NMR(GarciaF200, NMRmeth = "MMM", file.output = FALSE, use.tiff = FALSE)

Read spectra

Description

This function reads the raw file, Bruker, tab separated or coma separated extracts the spectra and returns a list with name, and the raw spectral data.

Usage

read_raw_spec(file = NULL, filetype = NULL)

Arguments

file

The raw file

filetype

The raw file type "Bruker", .csv ("tab"), csv ("coma")

Value

A list with the name of the file and the raw spectral data.

Examples

## any .txt file as output from BRUKER

Functional groups calculation

Description

This function loads, integrates and calculates the functional group distribution from the raw spectra. Produces also the molecular mixing model fitting if NC data is provided. Output is a list with the raw data, integrals and corrected spectra.

Usage

region_calc(
  batch_nmr = NULL,
  file = NULL,
  NMRmeth = NULL,
  FixNC,
  NMR_field = NULL,
  NMR_rotation = NULL,
  ecosys = NULL,
  cndata = NULL,
  mod_std = NULL
)

Arguments

batch_nmr

Vector with file names, default

file

The raw file

NMRmeth

Regions to be integrated, methods available include: "4region", "Bonanomi", "Smernik" and Molecular mixing model ("MMM").

FixNC

TRUE or FALSE, for fixing or not the NC ratio on the sample fitting.

NMR_field

Magnetic field of the NMR

NMR_rotation

Rotation frequency of the sample probe in the NMR

ecosys

Standards to be used for the MMM, can be Terrestrial("Terr_Nelson" or "Terr_Baldock") or Aquatic ("Aqua_Nelson" or "Aqua_Baldock")

cndata

The N:C data file created with mk_nc_data

mod_std

File containing a modified NMR table

Value

A data frame that contains the SSBs corrected C functional groups, or if the "MMM" method is selected, the result of the fitting of the "MMM".

Examples

data("GarciaF200")
IntegralSSBc <- region_calc(GarciaF200, NMRmeth = "4region", NMR_field = 200, NMR_rotation = 6800)

Smernik200 data set from Smernik et al. (2008)

Description

Contains 15 CP MAS 13C NMR spectra.

Usage

Smernik200

Format

A nested list with 15 sub-lists:

1 to 15

A list containing the soil NMR spectrum of one of the following sites.

name

"Control", "Burnt", "Burnt 1 year", "Control", "Control", "Control", "Control", "Burnt", "Burnt", "Burnt", "Burnt", "Burnt 1 year", "Burnt 1 year", "Burnt 1 year", "Burnt 1 year"

raw.spec

A data frame with 2 columns:

ppm

Numeric vector.

raw.intensity

Numeric vector.

Details

The spectra were taken in a NMR spectrometer with field strength of 200 MHz and MAS rate of 5 kHz

Source

Smernik et al., (2008) DOI: 10.1071/SR07128

Examples

data(Smernik200)

Smernik400 data set from Smernik et al. (2008)

Description

Contains 15 CP MAS 13C NMR spectra.

Usage

Smernik400

Format

A nested list with 15 sub-lists:

1 to 15

A list containing the soil NMR spectrum of one of the following sites.

name

"Control", "Burnt", "Burnt 1 year", "Control", "Control", "Control", "Control", "Burnt", "Burnt", "Burnt", "Burnt", "Burnt 1 year", "Burnt 1 year", "Burnt 1 year", "Burnt 1 year"

raw.spec

A data frame with 2 columns:

ppm

Numeric vector.

raw.intensity

Numeric vector.

Details

The spectra were taken in a NMR spectrometer with field strength of 400 MHz and MAS rate of 7 kHz

Source

Smernik et al., (2008) DOI: 10.1071/SR07128

Examples

data(Smernik400)

Spinnning side bands ofset calculation function This function calculates the spinning side band ofset for a given 13C NMR table. The function returns the 13C NMR integration table to be used in the int_nmr function.

Description

Spinnning side bands ofset calculation function This function calculates the spinning side band ofset for a given 13C NMR table. The function returns the 13C NMR integration table to be used in the int_nmr function.

Usage

ssb_offset(NMRmeth = NULL, NMR_field = NULL, NMR_rotation = NULL)

Arguments

NMRmeth

Regions to be integrated, methods available include: "4region", "Bonanomi", "Smernik" and Molecular mixing model ("MMM").

NMR_field

Magnetic field of the NMR

NMR_rotation

Rotation frequency of the sample probe in the NMR

Value

A dataframe containing the integral regions of the NMR spectrometer (according to the NMR spectrometer field and rotation speed) using the selected method and the predicted regions of the SSBs.

Examples

see_offset <- ssb_offset (NMRmeth='4region', NMR_field = 200, NMR_rotation = 6800)

Create a data frame of standard NMR areas

Description

The function creates a data frame with all standards of the selected ecosystem (Terrestrial or Aquatic).

Usage

std_nmr(ecosys = NULL)

Arguments

ecosys

Standards from the ecosystem to be fitted. "Terr_Nelson" or "Terr_Baldock" for terrestrial, "Aqua_Nelson" or "Aqua_Baldock" for aquatic.

Value

A data frame with all standards of the selected ecosystem ("Terr_Nelson" or "Terr_Baldock" for terrestrial, "Aqua_Nelson" or "Aqua_Baldock" for aquatic).

Examples

std_table <- std_nmr(ecosys="Terr_Nelson")