8000 GitHub - spang-lab/mdrb: Metabodecon Rust Backend for R
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

spang-lab/mdrb

Repository files navigation

R-CMD-check Test-Install R-Universe-Version

mdrb

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.

⚠️ Attention: this package is experimental and its API is subject to change. When using in scripts and/or packages make sure to check the exact version first.

Installation

To install the package from a pre-compiled binary:

  1. Install R version 4.2 or higher from CRAN
  2. 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:

  1. Install R version 4.2 or higher from CRAN.
  2. If you're on Windows install RTools from CRAN.
  3. Install the Rust toolchain from rustup.rs.
  4. Install the mdrb package by running the following commands in R:
    install.packages("mdrb", type="source", repos="https://spang-lab.r-universe.dev")

Usage

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()

Documentation

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

Contributing

See CONTRBUTING.md.

About

Metabodecon Rust Backend for R

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  
0