Skip to content

Genomic Data Smoothing

LOESS for methylation profiles, ChIP-seq signals, and other genomic data.

Genomic data often contains noise from sequencing depth variation, PCR artifacts, or biological heterogeneity. LOESS smoothing helps reveal underlying patterns.


DNA methylation data (from bisulfite sequencing or arrays) shows position-dependent patterns that can be obscured by measurement noise.

A small fraction = 0.1 lets LOESS follow fine-scale spatial structure without smearing the transitions between methylated and unmethylated regions. confidence_intervals = 0.95 produces uncertainty bands that naturally widen at positions with sparser CpG coverage, making low-confidence segments immediately apparent in the plot.

const { Loess } = require('fastloess-wasm');
const n = 100;
const positions = Float64Array.from({ length: n }, (_, i) => i * 100.0);
const observed = Float64Array.from(positions, p => 50 + Math.sin(p / 100) * 20 + ((p * 7 % 17) / 17 - 0.5) * 5);
// positions and observed are your methylation data (Float64Array)
const model = new Loess({
fraction: 0.1,
iterations: 3,
intervals: { confidence : 0.95 }
});
const result = model.fit(positions, observed);
console.log("CI lower[0]:", result.confidence_lower[0].toFixed(4));
CI lower[0]: 36.6609

ChIP-seq experiments produce sparse, noisy coverage data. LOESS 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.

const { Loess } = require('fastloess-wasm');
const n = 100;
const positions = Float64Array.from({ length: n }, (_, i) => i * 100.0);
const observed = Float64Array.from(positions, p => 50 + Math.sin(p / 100) * 20 + ((p * 7 % 17) / 17 - 0.5) * 5);
const model = new Loess({
fraction: 0.05,
iterations: 5
});
const result = model.fit(positions, observed);
// Find peaks
const smoothed = result.y;
const peaks = positions.filter((p, i) => smoothed[i] > 25.0);
console.log("Peak count:", peaks.length);
Peak count: 100

For whole-genome data that doesn’t fit in memory:

const { StreamingLoess } = require('fastloess-wasm');
const xChunk = Float64Array.from({ length: 1001 }, (_, i) => i * 10.0);
const yChunk = Float64Array.from(xChunk, p => 50 + Math.sin(p / 100) * 20 + 5.0);
const processor = new StreamingLoess(
{ fraction: 0.05, iterations: 3 },
{ chunk_size: 100, overlap: 10 }
);
processor.process_chunk(xChunk, yChunk);
const result = processor.finalize();
console.log("y[0]:", result.y[0].toFixed(4));
y[0]: 41.5626

ConsiderationRecommendation
Fraction0.05–0.15 (preserve local features)
Iterations3–5 (handle sequencing outliers)
Large dataUse streaming mode
Sparse regionsUse boundary_policy="extend"
Multiple chromosomesProcess separately or ensure sorted