This function identifies potential adduct pairs in mass spectrometry data based on mass differences and retention times.
Usage
detect_adducts(
data,
ppm_tolerance = 5,
rt_tolerance = 0.1,
ion_mode = "pos",
adducts = NULL
)
Arguments
- data
A data frame containing at least the columns
RT
(retention time in minutes) andMZ
(mass-to-charge ratio).- ppm_tolerance
Mass accuracy tolerance in parts per million (ppm) for matching mass differences. Default is 5 ppm.
- rt_tolerance
Retention time tolerance in minutes for considering peaks as potential adducts. Default is 0.1 minutes.
- ion_mode
Ionization mode, either
"pos"
for positive or"neg"
for negative. Default is"pos"
.- adducts
Optional data frame of adduct definitions. If not provided, a default list of common adducts is used based on
ion_mode
.
Examples
# Sample data
data <- data.frame(
RT = c(1.0, 1.0, 1.0, 1.0),
MZ = c(100.0000, 101.0073, 122.9892, 138.9632)
)
# Detect adducts in positive mode
results <- detect_adducts(data, ion_mode = "pos")
print(results)
#> mz1 rt1 mz2 rt2 observed_diff adduct theoretical_diff ppm_error
#> 1 100 1 122.9892 1 22.9892 [M+Na]+ 22.98922 0.7829757
#> 2 100 1 138.9632 1 38.9632 [M+K]+ 38.96316 1.0779414