bedGraph is a 4-column (chrom/start/end/value) 0-based half-open text format for continuous genomic signal - coverage, scores, log2 ratios. This skill covers generating signal tracks from a BAM, the normalization step that makes tracks comparable across samples (and the global-perturbation case where library-size normalization is the wrong tool), multi-sample track arithmetic, and converting the text bedGraph into a browser-ready bigWig under the strict sort/overlap/chrom.sizes contract. The central judgment is that a raw bedGraph is a library-size artifact, the wrong normalization is worse than none, and bigWig - not bedGraph - is the deliverable.
# deepTools (bamCoverage/bamCompare/bigwigCompare/multiBigwigSummary)
conda install -c bioconda deeptools
# bedtools (genomecov/unionbedg/merge/map)
conda install -c bioconda bedtools
# UCSC Kent utilities (bedGraphToBigWig/bigWigToBedGraph/fetchChromSizes)
conda install -c bioconda ucsc-bedgraphtobigwig ucsc-bigwigtobedgraph
# pyBigWig (read/extract bigWig in Python)
pip install pyBigWig
Tell your AI agent what you want to do: - "Generate a normalized coverage bigWig from my BAM file" - "Make a log2 treatment-vs-input track from two BAMs" - "Convert my bedGraph to bigWig for the genome browser" - "Check whether library-size normalization is safe for my knockdown experiment" - "Build a sample correlation heatmap from my bigWig tracks"
"Make an RPGC-normalized bigWig from chip.bam for GRCh38, 25 bp bins, extending reads to fragments and excluding chrX and chrM from the scale factor." "Generate a CPM-normalized bedGraph from my ATAC BAM so I can inspect the values, then convert it to bigWig."
"I knocked down a histone acetyltransferase and want to compare H3K27ac between control and KD. Is CPM/RPGC normalization safe here, or do I need a spike-in?" "Which normalization should I use to compare ChIP signal across samples when a few regions have very high coverage?"
"Make a log2 ratio track of treatment over input from the two BAMs, normalizing for depth first." "Stack my three replicate bedGraphs into a value matrix over a common interval partition." "Build a Spearman correlation heatmap across my six bigWig tracks to check sample relatedness."
"My bedGraphToBigWig run says the input is not case-sensitive sorted - fix the sort." "My bigWig loads in the browser but the heights look wrong - help me find what corrupted it." "I have overlapping intervals in my bedGraph; collapse them so conversion succeeds."
head, awk '$4 > 1000', sort -k4 -n) before converting - it is the last human-readable checkpoint before opaque binary.LC_COLLATE=C sort -k1,1 -k2,2n before bedGraphToBigWig; a locale-aware sort that looks fine interactively fails in the scheduler.samtools faidx + cut -f1,2), not a generic download - a mismatched assembly/patch errors or pads phantom genome.