Combines two massSight
objects by aligning their features and
correcting for systematic differences in retention time and mass-to-charge ratios.
Usage
mass_combine(
ms1,
ms2,
optimize = TRUE,
rt_delta = 0.5,
mz_delta = 15,
minimum_intensity = 10,
iso_method = "manual",
eps = 0.1,
rt_iso_threshold = 0.01,
mz_iso_threshold = 2,
match_method = "unsupervised",
smooth_method = "gam",
weights = c(1, 1, 1),
log = NULL,
output = NULL,
n_iter = 50,
...
)
Arguments
- ms1
A
massSight
object representing the results of a preprocessed LC-MS experiment that will serve as the reference dataset.- ms2
A
massSight
object representing the results of a second preprocessed LC-MS experiment that will be aligned to ms1.- optimize
Logical: whether to optimize alignment parameters using known metabolites. Default is TRUE
- rt_delta
Numeric: the retention time window (+/-) in minutes to consider when aligning features. Default is 0.5.
- mz_delta
Numeric: the mass-to-charge ratio window (+/-) in ppm to consider when aligning features. Default is 15.
- minimum_intensity
Numeric: the minimum intensity threshold for features to be considered in the alignment. Default is 10.
- iso_method
Character: the method for isolating high-quality features before modeling drift. Options are "manual" or "dbscan". Default is "manual".
- eps
Numeric: epsilon parameter for DBSCAN clustering when iso_method = "dbscan". Default is 0.1.
- rt_iso_threshold
Numeric: the retention time similarity threshold for manual isolation. Default is 0.01.
- mz_iso_threshold
Numeric: the m/z similarity threshold for manual isolation. Default is 2.
- match_method
Character: the method for initial feature matching. Options are "unsupervised" (uses all features) or "supervised" (uses only known metabolites). Default is "unsupervised".
- smooth_method
Character: the method for smoothing systematic drift. Options are "gam", "bayesian_gam", or "gp". Default is "gam".
- weights
Numeric vector: weights for RT, m/z, and intensity in the alignment scoring. Default is c(1, 1, 1).
- log
Character: path to save the log file. Set to NULL to disable logging. Default is NULL.
- output
Character: directory to save output files. Default is NULL (current directory).
- n_iter
Integer: number of optimization iterations if optimize=TRUE. Default is 50.
- ...
Additional arguments passed to internal functions.
Value
A MergedMSObject
containing:
Original ms1 and ms2 objects
Matched features between datasets
Drift correction models
Alignment quality metrics
Examples
if (FALSE) { # \dontrun{
# Basic usage with default parameters
combined <- mass_combine(ms1_data, ms2_data)
# Use optimization with known metabolites
combined <- mass_combine(ms1_data, ms2_data,
optimize = TRUE,
n_iter = 50)
# Custom parameters for stricter matching
combined <- mass_combine(ms1_data, ms2_data,
rt_delta = 0.3,
mz_delta = 10,
minimum_intensity = 100)
} # }