Modern, interactive visualizations for XCMS metabolomics data using ggplot2.
Overview
xcmsVis provides ggplot2 implementations of XCMS plotting functions, enabling:
- Modern, publication-ready visualizations
- Interactive plots through plotly integration
- Consistent styling across all plots
- Full compatibility with both XCMSnExp and XcmsExperiment objects
This package complements the XCMS package by reimplementing its base graphics plots using ggplot2.
Status
All 11 modern XCMS plotting functions are now implemented!
| Metric | Status |
|---|---|
| Core Functions | 11/11 complete ✅ |
| Object Support | XCMSnExp ✅ / XcmsExperiment ✅ / LamaParama ✅ |
| Vignettes | 7 comprehensive guides |
| Test Coverage | All tests passing ✅ |
Implemented Functions
Retention Time and Alignment
-
gplotAdjustedRtime()- Visualize retention time corrections -
gplot(LamaParama)- Landmark-based alignment parameters
Peak Detection and Visualization
-
gplotChromPeaks()- Detected peaks in RT-m/z space -
gplotChromPeakImage()- Peak density heatmap across samples -
gplotChromPeakDensity()- Peak density for parameter optimization -
ghighlightChromPeaks()- Peak annotation layers
Chromatograms and EICs
-
gplot(XChromatogram)- Single chromatogram with detected peaks -
gplot(XChromatograms)- Multiple chromatograms (stacked or separate) -
gplotChromatogramsOverlay()- Overlay multiple EICs
Feature Groups and MS/MS
-
gplotFeatureGroups()- Related features (isotopes, adducts, fragments) -
gplotPrecursorIons()- MS/MS precursor ion visualization
Quick Start
library(xcmsVis)
library(xcms)
library(MsExperiment)
# Load data
xdata <- readMsExperiment(files = mzml_files)
# XCMS workflow
xdata <- findChromPeaks(xdata, param = CentWaveParam())
xdata <- groupChromPeaks(xdata, param = PeakDensityParam())
xdata <- adjustRtime(xdata, param = PeakGroupsParam())
# Visualize results
p <- gplotAdjustedRtime(xdata, color_by = sample_group)
print(p)
# Make it interactive
library(plotly)
ggplotly(p, tooltip = "text")
# Customize with ggplot2
p +
theme_minimal() +
labs(title = "RT Alignment Results")Example Visualizations
Retention Time Alignment
gplotAdjustedRtime(xdata, color_by = sample_group)Chromatographic Peaks
gplotChromPeaks(xdata)Feature Groups
gplotFeatureGroups(xdata, featureGroups = c("FG.0001", "FG.0002"))Extract Ion Chromatograms
chr <- chromatogram(xdata, mz = c(305, 306), rt = c(2500, 3500))
gplot(chr)Why xcmsVis?
Interactive Plots
All plots are ggplot2 objects that seamlessly convert to interactive plotly visualizations:
p <- gplotAdjustedRtime(xdata)
ggplotly(p) # Instant interactivity with zoom, pan, hover tooltipsComposable
Use patchwork to create custom layouts:
library(patchwork)
p1 <- gplotAdjustedRtime(xdata)
p2 <- gplotChromPeaks(xdata)
p1 / p2 # Stack verticallyPublication-Ready
Full ggplot2 customization:
gplotAdjustedRtime(xdata) +
theme_minimal() +
scale_color_brewer(palette = "Set1") +
labs(title = "Retention Time Correction",
subtitle = "PeakGroups alignment method")Motivation
This package addresses the need discussed in XCMS issue #551 for ggplot2-based visualizations that can be easily made interactive using plotly.
Citation
This package reuses and adapts substantial code and algorithms from the XCMS package, translating base R graphics implementations to ggplot2 while preserving the original visualization logic and functionality.
Original XCMS authors: - Colin A. Smith (original author) - Ralf Tautenhahn (original author) - Steffen Neumann (original author) - Johannes Rainer (current maintainer) - And many contributors
When using xcmsVis, please also cite the original XCMS package.