Genomic Data Smoothing
LOWESS for methylation profiles, ChIP-seq signals, and other genomic data.
Overview
Genomic data often contains noise from sequencing depth variation, PCR artifacts, or biological heterogeneity. LOWESS smoothing helps reveal underlying patterns.
Methylation Profile Smoothing
The Challenge
DNA methylation data (from bisulfite sequencing or arrays) shows position-dependent patterns that can be obscured by measurement noise.
Solution
A small fraction = 0.1 lets LOWESS follow fine-scale spatial structure without smearing the transitions between methylated and unmethylated regions. intervals = (confidence = 0.95,) produces uncertainty bands that naturally widen at positions with sparser CpG coverage, making low-confidence segments immediately apparent in the plot.
using FastLOWESS
positions = collect(0.0:1000.0:99000.0)
observed = 50.0 .+ sin.(positions ./ 1000.0) .* 20.0 .+ 5.0
# positions and observed are your methylation data
model = Lowess(;
fraction=0.1,
iterations=3,
intervals=(confidence=0.95,),
)
result = fit(model, positions, observed)
# Smoothed profile in result.y
# CI bounds in result.confidence_lower/upper
println("95% CI: [", result.confidence_lower[1], ", ", result.confidence_upper[1], "]")95% CI: [53.27919505033735, 67.15544006032717]ChIP-seq Signal Smoothing
Application
ChIP-seq experiments produce sparse, noisy coverage data. LOWESS can help identify binding regions.
fraction = 0.05 provides high spatial resolution — important for resolving narrow binding peaks that would otherwise be smeared into the background. The larger iterations = 5 is deliberate: Poisson-distributed read counts produce tall, isolated spikes, and extra robustness iterations progressively down-weight them so the estimated background level is not inflated by a handful of extreme counts.
using FastLOWESS
positions = collect(0.0:1000.0:99000.0)
observed = 50.0 .+ sin.(positions ./ 1000.0) .* 20.0 .+ 5.0
# positions and observed are your ChIP-seq data
model = Lowess(; fraction=0.05, iterations=5)
result = fit(model, positions, observed)
# Find peaks above threshold
peak_count = count(y -> y > 65.0, result.y)
println("y[0]: ", result.y[1])
println("Peak count: ", peak_count)y[0]: 59.937594476093395
Peak count: 26Large Genome Coverage (Streaming)
For whole-genome data that doesn't fit in memory:
using FastLOWESS
positions = collect(0.0:10.0:10000.0)
coverage = 50.0 .+ sin.(positions ./ 100.0) .* 20.0 .+ 5.0
# coverage and positions are chromosome-scale vectors
model = StreamingLowess(;
fraction=0.05,
iterations=3,
chunk_size=50,
overlap=10,
merge_strategy="weighted_average"
)
process_chunk(model, positions, coverage)
result = finalize(model)
println("y[0]: ", result.y[1])y[0]: 41.28390556612269Best Practices for Genomic Data
| Consideration | Recommendation |
|---|---|
| Fraction | 0.05–0.15 (preserve local features) |
| Iterations | 3–5 (handle sequencing outliers) |
| Large data | Use streaming mode |
| Sparse regions | Use boundary_policy="extend" |
| Multiple chromosomes | Process separately or ensure sorted |
See Also
- Concepts — How LOWESS works
- API Reference — All options
- Robustness — Outlier downweighting in depth
- Merge Strategies — Streaming chunk reconciliation
- Boundary Handling — Edge handling for sparse regions
- Real-Time Processing — For sequencing runs