Import spectra

Description

This function imports mass spectra from various file formats (.mgf, .msp, .rds), harmonizes metadata field names, filters by MS level and polarity, optionally combines replicate spectra, and sanitizes peak data.

Usage

import_spectra(
  file,
  cutoff = 0,
  dalton = 0.01,
  polarity = NA,
  ppm = 10,
  sanitize = TRUE,
  combine = TRUE
)

Arguments

file Character string path to the spectrum file (.mgf, .msp, or .rds)
cutoff Numeric absolute minimal intensity threshold (default: 0)
dalton Numeric Dalton tolerance for peak matching (default: 0.01)
polarity Character string for polarity filtering: "pos", "neg", or NA to keep all (default: NA)
ppm Numeric PPM tolerance for peak matching (default: 10)
sanitize Logical flag indicating whether to sanitize spectra (default: TRUE)
combine Logical flag indicating whether to combine replicate spectra (default: TRUE)

Value

Spectra object containing the imported and processed spectra

Examples

library("tima")

get_file(
  url = get_default_paths()$urls$examples$spectra_mini,
  export = get_default_paths()$data$source$spectra
)
import_spectra(file = get_default_paths()$data$source$spectra)
import_spectra(
  file = get_default_paths()$data$source$spectra,
  sanitize = FALSE
)