This skill drives programmatic untargeted LC-MS feature extraction in R with the modern xcms 4.x API: raw centroided mzML in, a features-by-samples intensity table out, via CentWave peak detection, retention-time alignment, peak-density correspondence, gap-filling, CAMERA redundancy collapse, and built-in QC feature filtering. It guards against the traps that make untargeted tables untrustworthy: parameters that silently delete real peaks, gap-filling that fabricates intensities for absent compounds, alignment that looks perfect in QCs while mis-registering rare features, and the one-compound-many-features redundancy that inflates apparent dimensionality.
if (!require('BiocManager')) install.packages('BiocManager')
BiocManager::install(c('xcms', 'MsExperiment', 'Spectra', 'CAMERA'))
Conceptual prerequisites: data must be centroided (centroid in software with a documented algorithm, e.g. ProteoWizard msconvert vendor peakPicking, rather than relying on irreversible on-instrument centroiding); the instrument class and chromatography must be known to set ppm and peakwidth; the sample design (biological groups, pooled QCs, blanks, injection order) must be recorded as a per-file table before processing; and the analyst should understand that the resulting feature table is a parameterized result that must be reported with its full processing specification.
Tell your AI agent what you want to do: - "Process my centroided mzML files with xcms into a feature table" - "Detect peaks with CentWave using parameters appropriate for my Orbitrap UHPLC data" - "Align retention times with obiwarp and group peaks across samples" - "Gap-fill, then report the fraction of filled values per feature" - "Collapse adduct and isotope redundancy with CAMERA before annotation" - "Filter features by QC CV and D-ratio with xcms filterFeatures"
"Set up CentWaveParam for qTOF UHPLC data and explain why ppm should not be the spec mass accuracy." "My trace metabolites are missing from the table - which of prefilter, noise, and snthresh should I lower first?"
"Align retention times to a pooled QC reference rather than the first file, then regroup." "Choose between obiwarp and peakGroups for a heterogeneous case/control cohort with few shared peaks." "Set the grouping bw relative to my residual post-alignment RT scatter on UHPLC."
"Gap-fill with ChromPeakAreaParam but flag the filled values and report per-feature filled fraction." "Filter features with RsdFilter and DratioFilter using my QC and study sample indices."
"Run CAMERA in the correct order to collapse adducts and isotopes before annotation." "Export the feature table with mz, rt, and intensities for downstream statistics."
MsExperiment via readMsExperiment with a per-file sample table.findChromPeaks with a CentWaveParam (or MatchedFilterParam for low-res/profile data) tuned to the instrument and chromatography.ObiwarpParam or PeakGroupsParam, then regroup.PeakDensityParam.ChromPeakAreaParam, tracking is_filled.filterFeatures.peakwidth from real EIC base-widths; the default c(20,50) silently drops sharp UHPLC peaks.ppm from empirical across-scan centroid scatter (~2-3x), not the datasheet - too tight fragments mass traces and deletes features.is_filled, report filled fractions, and prefer MNAR-aware imputation for inferential statistics.