Genomic intervals · Software
bedtools
A command-line suite for intersecting, merging, and analysing genomic intervals across standard bioinformatics formats.
What bedtools is
bedtools is a software suite designed for genomic arithmetic, providing tools that execute set-theory operations directly on genomic features. Developed by the Quinlan laboratory, it allows researchers to intersect, merge, count, complement, and shuffle intervals derived from high-throughput sequencing experiments.
Genomic studies frequently generate large datasets defining physical coordinates, including mapped reads, variant calls, and gene annotations. bedtools addresses the need to integrate these diverse data types by offering modular command-line utilities that each carry out a specific comparison or transformation, which can be piped together in the UNIX environment for complex workflows.
The software supports standard genomics file formats, including BED, GFF/GTF, VCF, BAM, and CRAM, making it a foundational tool for tasks such as calculating sequence coverage, comparing peak calls across assays, and identifying nearest genomic features.
How it works
bedtools implements algorithms for interval manipulation that operate on coordinate-based files. For unsorted data, it relies on an R-Tree index algorithm to detect overlaps and spatial relationships. For pre-sorted data ordered by chromosome and start position, bedtools utilises an optimised sweep-line algorithm engaged via the -sorted option, which reduces memory consumption and increases processing speed to handle large datasets efficiently.
Input files other than BAM format are expected to be tab-delimited text with UNIX line endings. For CRAM format support, bedtools interfaces with htslib and retrieves the reference sequence location specified in the CRAM_REFERENCE environment variable.
Key facts
- Lead developers
- Aaron Quinlan, Hao Hou, Brent Pedersen, Neil Kindlon
- Latest version
- 2.31.1
- Initial release year
- 2009
- Supported input formats
- BED, GFF/GTF, VCF, BAM, CRAM
- Primary dependency for CRAM
- htslib
- Default chromosome size limit
- 512 Mb (without -sorted option)
What you can use it for
- Targeted capture and coverage analysis
- Quantify read depth across target regions and detect under-covered areas in targeted sequencing experiments.
- ChIP-seq peak concordance
- Identify reproducible peaks between experimental replicates using reciprocal overlap criteria and locate the nearest non-overlapping genes.
- Genomic sequence characterisation
- Extract specific sequence elements such as promoter regions or calculate the GC content across defined structures like CCDS exons.
- Epigenomic track integration
- Compare and consolidate chromatin state intervals across multiple cell types into composite reference tables.
Run it here
bedtools is preinstalled on the machine behind every research conversation. Ask the agent in plain language, or give it the exact command — it runs it, reads the output and explains it.
Strengths and limits
Good at
- Highly scalable speed and low memory usage when operating on pre-sorted genomic interval datasets.
- Direct compatibility with primary sequencing and annotation formats, including BAM, CRAM, VCF, GFF, and BED.
- Modular architecture facilitating complex analysis pipelines through UNIX stream piping.
Watch out for
- Cannot handle chromosomes exceeding 512 Mb in size unless the -sorted mode is enabled.
- The R-Tree algorithm for unsorted files fails to complete on massive datasets, such as 100 million alignments, due to excessive memory consumption.
- Requires identical chromosome naming schemes across files, failing if conventions differ (such as 'chr1' versus '1').
- Requires a separate genome file defining chromosome ordering when using -sorted on files that are not lexicographically ordered.
Questions
Can I run bedtools online without installing it?
bedtools is preinstalled on the machine behind every research conversation. Ask the agent in plain language, or give it the exact command — it runs it, reads the output and explains it.
What licence is bedtools under?
bedtools is published under its authors' own licence; the project page at https://bedtools.readthedocs.io/ states it.
How do I process CRAM files with bedtools?
bedtools reads CRAM files using htslib. You must define the associated reference genome file using the CRAM_REFERENCE environment variable before running operations that access sequence data.
Why does bedtools report an error when comparing chromosomes named 'chr1' and '1'?
bedtools requires chromosome naming conventions to match exactly between compared files. You must standardise the chromosome identifiers across all input files beforehand.
When should I use the -sorted option?
The -sorted option should be used when inputs are ordered by chromosome and start position. It drastically decreases memory usage and execution time, enabling the tool to process tens of millions of alignments without memory exhaustion.
What formatting constraints apply to text inputs?
All non-BAM inputs must be tab-delimited and use UNIX-style line endings.
How to cite it
Quinlan AR and Hall IM, 2010. BEDTools: a flexible suite of utilities for comparing genomic features. Bioinformatics. 26, 6, pp. 841–842.
Written from bedtools's own README and project page. Statements citing a figure that does not appear there are removed before publication. Licence and running details come from our registry.