Provides a high-performance Rust backend for the metabodecon package, enabling efficient deconvolution, alignment, and post-processing of 1D NMR spectra. The package wraps optimized Rust functions to improve performance and scalability for large datasets. The recommended way to use mdrb is by installing metabodecon and setting the backend argument to "rust" when calling its functions. The Rust part of the package is based on the metabodecon-rust crate.
To install the package from a pre-compiled binary:
- Install R version 4.2 or higher from CRAN
- Enter the following commands in a running R session:
install.packages("mdrb", type="binary", repos="https://spang-lab.r-universe.dev")
To install from source:
- Install R version 4.2 or higher from CRAN.
- If you're on Windows install RTools from CRAN.
- Install the Rust toolchain from rustup.rs.
- Install the mdrb package by running the following commands in R:
install.packages("mdrb", type="source", repos="https://spang-lab.r-universe.dev")
mdrb is primarily intended to be used through the frontend functions provided by the metabodecon package. However, if you prefer to use the package directly, you can follow the example below:
spectrum_path <- metabodecon::metabodecon_file("bruker/urine/urine_1")
r_spectrum <- metabodecon::read_spectrum(spectrum_path)
rust_spectrum <- Spectrum$new(
chemical_shifts = r_spectrum$cs,
intensities = r_spectrum$si,
signal_boundaries = quantile(r_spectrum$cs, c(0.1, 0.9))
)
deconvoluter <- Deconvoluter$new()
deconvoluter$set_moving_average_smoother(iterations = 4, window_size = 3)
deconvoluter$set_noise_score_selector(6.4)
deconvoluter$set_analytical_fitter(iterations = 5)
deconvolution <- deconvoluter$deconvolute_spectrum(rust_spectrum)
lorentzians <- deconvolution$lorentzians()
superposition_vec <- deconvolution$superposition_vec()
mse <- deconvolution$mse()
Since mdrb is mostly intended as dependency of metabodecon and not for direct usage, documentation for mdrb is scarce. However, users interested in deconvolution and alignment of NMR spectra are encouraged to check out the metabodecon package, which provides a high-level interface to the Rust backend. metabodecon's documentation is available at spang-lab.github.io/metabodecon and includes pages about
See CONTRBUTING.md.