Skip to main content

Module methylation_bedgraph

Module methylation_bedgraph 

Source
Expand description

Closed-form per-CpG population-fraction bedGraph writer derived from a per-haplotype methylation bitmap; no simulated reads required. Population-fraction methylation bedGraph in MethylDackel extract format.

Derived closed-form from the per-haplotype methylation bitmap — no simulated reads. For each reference CpG, aggregates over (haplotype × strand) presence/absence and emits rate = round(100 * n_methylated / (n_methylated + n_unmethylated)) as an integer percentage (matching MethylDackel extract).

This is intentionally distinct from simulate’s --cpg-truth-bedgraph, which is coverage-weighted (depends on simulated read counts).

Functions§

write_bedgraph
Write a complete population-fraction bedGraph — header line followed by per-CpG records for every contig in per_contig.
write_bedgraph_header
Write the track header line for a MethylDackel-format population-fraction bedGraph.
write_bedgraph_records
Write per-CpG bedGraph records for a single contig, without the track header line.