BED Tool

Genome arithmetic with bedtools

BED Tools

Genome arithmetic with bedtools

Loading WebAssembly runtime...

About the BED Tools page

This page runs bedtools 2.29.2 compiled to WebAssembly, so interval arithmetic works in your browser with no install and no upload. BED is the lingua franca of genome annotation: peaks, exons, promoters, enhancers, genes and repeats are all distributed as intervals on named contigs.

Almost every question in genomics that sounds simple turns out to be an interval question. Which peaks from condition A overlap those in condition B? Which enhancers fall within a gene body? How much of the genome is covered by my repeat annotation? bedtools answers these in a single command each.

Because the file never leaves your machine, you can work on annotation sets that describe unpublished work, clinical targets or embargoed projects.

What this tool does

Sort intervals

Sort a BED file by chromosome and start position. Almost every bedtools subcommand assumes sorted input, so this is the first step in any fresh workflow.

Merge overlapping intervals

Collapse overlapping and book-ended intervals into a minimal non-overlapping set, which turns raw peak calls into a clean region list.

Intersect intervals

Find the overlap between two interval files, the standard way to relate peaks, genes, enhancers or capture targets across experiments.

Interval arithmetic

Subtract, subtract with any overlap, complement and union, which covers most of what you need to derive one annotation set from another.

Example commands

bedtools --version

Confirm the bedtools build is ready. Run it first if anything later behaves unexpectedly.

bedtools sort

Sort intervals by contig then start position. Required input for nearly every other bedtools command.

bedtools merge

Collapse overlapping intervals into a minimal non-overlapping union of regions.

bedtools intersect

Report intervals from the query file that overlap intervals in the reference file.

Frequently asked questions

Are my BED files uploaded to a server?

No. bedtools runs as WebAssembly inside your browser, so interval data is read into browser memory and processed locally without transmission.

Does BED use 0-based or 1-based coordinates?

BED is 0-based, half-open: the start position is included and the end position is not. This differs from SAM, GFF and VCF, which use 1-based inclusive coordinates. Mixing the two conventions is the single most common source of off-by-one errors.

Why does bedtools return nothing?

Usually one of four reasons: the files are not sorted, the chromosome naming differs between files (chr1 versus 1), the assemblies differ, or you are asking for any-overlap where there is genuinely no overlap. Check chromosome names first; it is the most common.

What is the difference between intersect and intersect -wa -u?

Plain intersect reports the overlapping portion of the query intervals. Intersect with -wa -u reports the full query intervals that overlap anything, which is usually what you want when counting regions rather than measuring overlap length.

How do I find the inverse, that is regions not covered by my peaks?

Use bedtools complement against a file of all genomic intervals, or subtract your peaks from a gene or mappable-genome file. Complement is the right choice when you want unmapped or uncovered space.

Can I use gzipped BED files?

Yes. The file picker accepts .bed and .bed.gz, so compressed interval files work without a separate decompression step.

Related tools

All processing happens locally in your browser. Nothing you upload is transmitted or stored, as described in the privacy policy.