Compute MS1 purity matrix for xcms features
get_xcms_feature_purity_matrix.RdCalculate a feature-by-sample MS1 purity matrix by extracting, for each feature
in xcms.xcms, the closest MS1 scan (by retention time) from xcms.ms1.sp
in each sample file (matched by Spectra::dataOrigin). Purity is calculated
within an isolation window around the feature m/z.
If xcms.ms1.sp is not provided, MS1 spectra are taken via
ProtGenerics::spectra(xcms.xcms) and filtered to MS level 1.
Optimized path: closest-scan lookup via findInterval, a single
peaksData() extraction, and purity computed on peak matrices
(no per-feature Spectra subsetting).
Usage
get_xcms_feature_purity_matrix(
xcms.xcms,
xcms.ms1.sp = NULL,
ppm = 5,
isolation_half_window = 0.2
)Arguments
- xcms.xcms
XCMSnExpwith grouped features (must havefeatureDefinitions).- xcms.ms1.sp
Optional MS1
Spectracovering the same files asxcms.xcms. If missing orNULL, taken fromProtGenerics::spectra().- ppm
numeric, ppm tolerance for m/z window.
- isolation_half_window
numeric, half isolation window (m/z).