Module 5: Untargeted Metabolomics Processing: Peak Picking, Alignment & MSI Spectral Identification
Tested Stacks:
GATK 4.6.1
Samtools 1.21
Nextflow 24.10
Seurat v5.1
Python 3.12
Prerequisites: Basic Linux CLI & Sequencing Formats
📚 Chapter 5 of 12
0% Course Completed
1. Raw Feature Detection & Retention Time Alignment
Unlike peptides whose fragmentation yields predictable $b/y$ ion ladders matching an amino acid sequence, metabolites are structurally diverse small molecules ($< 1,500\text{ Da}$) comprising carbohydrates, lipids, amino acids, organic acids, and xenobiotics. Untargeted processing tracks three-dimensional features $(m/z, \text{RT}, \text{Intensity})$:
- Centroiding & Peak Picking: Raw profile mass spectra undergo continuous wavelet transform (CentWave algorithm) to identify chromatographic peaks with signal-to-noise ratio $\text{S/N} \ge 10$ and minimum peak width ($5 - 30\text{ seconds}$).
- Retention Time Alignment: Unavoidable column aging, mobile phase heating, and matrix pressure shifts cause retention time drift across large patient runs. Algorithms like Obiwarp utilize dynamic time warping across total ion chromatograms to align homologous peaks within $\pm 0.1\text{ min}$.
- Isotope & Adduct Deconvolution (CAMERA): In electrospray ionization, a single metabolite generates multiple ion species: protonated $[M+H]^+$, sodium adducts $[M+Na]^+$, potassium adducts $[M+K]^+$, loss of water $[M+H-H_2O]^+$, and natural $^{13}\text{C}$ isotopes ($M+1, M+2$). Deconvolution groups co-eluting peaks with correlated intensity profiles into single compound clusters.
| MSI Level | Confidence Standard | Required Experimental Evidence |
|---|---|---|
| Level 1: Confirmed | Definitive identification | Matches authentic chemical reference standard analyzed on the exact same instrument under identical LC-MS conditions ($\Delta\text{RT} < 0.1\text{ min}$, accurate mass $\Delta m/z < 5\text{ ppm}$, matching MS2 fragmentation spectrum). |
| Level 2: Putative Identification | High-confidence match | Accurate mass and diagnostic MS2 fragmentation match against public spectral libraries (HMDB, METLIN, MassBank, GNPS) without authentic reference standard. |
| Level 3: Putative Compound Class | Compound family assignment | Diagnostic neutral losses or characteristic fragment ions matching a chemical class (e.g., phosphatidylcholine headgroup at $m/z\ 184.0739$). |
| Level 4: Unknown Feature | Uncharacterized molecular signal | Reproducible reproducible feature defined solely by accurate $m/z$ and retention time without chemical identity. |
2. Feature Table Extraction in R with XCMS
# Complete XCMS 3 Feature Extraction Workflow in R
library(xcms)
library(MSnbase)
# Ingest mzML files from brain tumor cohort
raw_files <- list.files("./mzml_metabolomics/", pattern="*.mzML", full.names=TRUE)
pheno <- data.frame(sample_name = sub(".mzML", "", basename(raw_files)),
cohort = ifelse(grepl("GBM", raw_files), "Glioblastoma", "Control"))
raw_data <- readMSData(files = raw_files, pdata = new("NAnnotatedDataFrame", pheno), mode = "onDisk")
# 1. Peak Picking with centWave
cwp <- CentWaveParam(ppm = 5, peakwidth = c(5, 25), snthresh = 10, prefilter = c(3, 1000))
xdata <- findChromPeaks(raw_data, param = cwp)
# 2. Alignment with Obiwarp
xdata <- adjustRtime(xdata, param = ObiwarpParam(binSize = 0.6))
# 3. Peak Grouping across samples
pdp <- PeakDensityParam(sampleGroups = pheno$cohort, minFraction = 0.5, bw = 3)
xdata <- groupChromPeaks(xdata, param = pdp)
# 4. Fill missing peaks (Gap Filling)
xdata <- fillChromPeaks(xdata)
feature_matrix <- featureValues(xdata, value = "into")
cat("Extracted", nrow(feature_matrix), "aligned metabolic features across", ncol(feature_matrix), "patients.\n")
⚠️
Common Pitfalls & Troubleshooting Checklist
- Java Heap Exhaustion (GATK / Picard): If processes terminate with
java.lang.OutOfMemoryError, set your environment variable explicitly:export _JAVA_OPTIONS="-Xmx16g -Djava.io.tmpdir=/tmp". - Index Timestamp Mismatch: If tools complain that a BAM index is missing or out of date, regenerate with
samtools index -@ 4 sample.bam. - Conda Channel Conflicts: Avoid ABI incompatibilities between bioconda and conda-forge by setting strict priority:
conda config --set channel_priority strict. - Chromosome Naming Contamination: Always verify whether reference FASTA headers use
chr1or1; divergent naming causes silent alignment drops.
Was this guide helpful to your research?
Help us maintain 100% accurate, peer-reviewed bioinformatics standards.