BEDTools
bio.toolsVerified30 docs · 15.9K tokensSwiss-army knife of genome feature analysis toolset
Use with Claude
Paste this MCP call into Claude to instantly fetch BEDTools documentation:
MCP call
resolve-library-id("bedtools")Or share this page: biocontext7.com/tools/bio.tools/bedtools
EDAM Annotations
Topics
Operations
Documentation Snippets
15,906 tokens · 30 snippets1###############2Advanced usage3###############456==========================================================================7Mask all regions in a genome except for targeted capture regions.8==========================================================================910Step 1. Add 500 bp up and downstream of each probe1112.. code-block:: bash1314 bedtools slop -i probes.bed -g hg18.genome -b 500 > probes.500bp.bed1516NB genome is two column chromosome size list - i.e. https://genome.ucsc.edu/goldenpath/help/hg18.chrom.sizes1718Step 2. Get a BED file of all regions not covered by the probes (+500 bp up/down)192021.. code-block:: bash2223 bedtools complement -i probes.500bp.bed -g hg18.genome > probes.500bp.complement.bed242526Step 3. Create a masked genome where all bases are masked except for the probes +500bp2728.. code-block:: bash2930 bedtools maskfasta -fi hg18.fa -bed probes.500bp.complement.bed \31 -fo hg18.probecomplement.masked.fa32333435==========================================================================36Screening for novel SNPs.37==========================================================================38Find all SNPs that are not in dbSnp and not in the latest 1000 genomes calls3940.. code-block:: bash4142 bedtools intersect -a snp.calls.bed -b dbSnp.bed -v | \43 bedtools intersect -a - -b 1KG.bed -v | \44 > snp.calls.novel.bed454647==========================================================================48Computing the coverage of features that align entirely within an interval.49==========================================================================5051By default, bedtools ``coverage`` counts any feature in A that overlaps B52by >= 1 bp. If you want to require that a feature align entirely within B for53it to be counted, you can first use intersectBed with the "-f 1.0" option.5455.. code-block:: bash5657 bedtools intersect -a features.bed -b windows.bed -f 1.0 | \58 bedtools coverage -a windows.bed -b - \59 > windows.bed.coverage606162==========================================================================63Computing the coverage of BAM alignments on exons.64==========================================================================65One can combine ``samtools`` with ``bedtools`` to compute coverage directly66from the BAM data by using ``bamtobed``.6768.. code-block:: bash6970 bedtools bamtobed -i reads.bam | \71 bedtools coverage -a exons.bed -b - \72 > exons.bed.coverage737475Take it a step further and require that coverage be from properly-paired reads.7677.. code-block:: bash7879 samtools view -uf 0x2 reads.bam | \80 coverageBed -abam - -b exons.bed \81 > exons.bed.proper.coverage82838485==========================================================================86Computing coverage separately for each strand.87==========================================================================88Use grep to only look at forward strand features (i.e. those that end in "+").8990.. code-block:: bash9192 bedtools bamtobed -i reads.bam | \93 grep \+$ | \94 bedtools coverage -a - -b genes.bed \95 > genes.bed.forward.coverage9697Use grep to only look at reverse strand features (i.e. those that end in "-").9899.. code-block:: bash100101 bedtools bamtobed -i reads.bam | \102 grep \-$ | \103 bedtools coverage -a - -b genes.bed \104 > genes.bed.reverse.coverage
1##################2The BEDTools suite3##################45`bedtools` consists of a suite of sub-commands that are invoked as follows::67 bedtools [sub-command] [options]89For example, to intersect two BED files, one would invoke the following::1011 bedtools intersect -a a.bed -b b.bed1213=========================================14The full list of `bedtools` sub-commands.15=========================================16.. toctree::17 :maxdepth: 11819 tools/annotate20 tools/bamtobed21 tools/bamtofastq22 tools/bed12tobed623 tools/bedpetobam24 tools/bedtobam25 tools/closest26 tools/cluster27 tools/complement28 tools/coverage29 tools/expand30 tools/flank31 tools/fisher32 tools/genomecov33 tools/getfasta34 tools/groupby35 tools/igv36 tools/intersect37 tools/jaccard38 tools/links39 tools/makewindows40 tools/map41 tools/maskfasta42 tools/merge43 tools/multicov44 tools/multiinter45 tools/nuc46 tools/overlap47 tools/pairtobed48 tools/pairtopair49 tools/random50 tools/reldist51 tools/shift52 tools/shuffle53 tools/slop54 tools/sort55 tools/subtract56 tools/summary57 tools/tag58 tools/unionbedg59 tools/window
bedtools - the swiss army knife for genome arithmetic
=====================================================
Cheat-sheet from Ilya Levantis
Summary
-------
Collectively, the bedtools utilities are a swiss-army knife of tools for a wide-range of genomics analysis tasks. The most widely-used tools enable genome arithmetic: that is, set theory on the genome. For example, bedtools allows one to intersect, merge, count, complement, and shuffle genomic intervals from multiple files in widely-used genomic file formats such as BAM, BED, GFF/GTF, VCF.
While each individual tool is designed to do a relatively simple task (e.g., intersect two interval files), quite sophisticated analyses can be conducted by combining multiple bedtools operations on the UNIX command line.
Performance
-----------
As of version 2.18, `bedtools` is substantially more scalable thanks to improvements we have made in the algorithm used to process datasets that are pre-sorted
by chromosome and start position. As you can see in the plots below, the speed and memory consumption scale nicely
with sorted data as compared to the poor scaling for unsorted data. The current version of bedtools intersect is as fast as (or slightly faster) than the `bedops package's bedmap` which uses a similar algorithm for sorted data. The plots below represent counting the number of intersecting alignments from exome capture BAM files against CCDS exons.
The alignments have been converted to BED to facilitate comparisons to `bedops. We compare to the bedmap --ec option because similar error checking is enforced by bedtools`.
Note: bedtools could not complete when using 100 million alignments and the R-Tree algorithm used for unsorted data.
Details
-------
First created through urgency and adrenaline by Aaron Quinlan Spring 2009.
Maintained by the Quinlan Laboratory at the University of Virginia.
- Lead developers: Aaron Quinlan, Hao Hou, Brent Pedersen, Neil Kindlon
- Significant contributions: John Marshall, Assaf Gordon, Royden Clark, Ryan Dale
- Repository: https://github.com/arq5x/bedtools2
- Stable releases: https://github.com/arq5x/bedtools2/releases
- Documentation: http://bedtools.readthedocs.org
- License: Released under MIT license
Citation
--------
Please cite the following article if you use BEDTools in your research:
- Quinlan AR and Hall IM, 2010. BEDTools: a flexible suite of utilities for comparing genomic features. Bioinformatics. 26, 6, pp. 841–842.
Also, if you use pybedtools, please cite the following.
- Dale RK, Pedersen BS, and Quinlan AR. Pybedtools: a flexible Python library for manipulating genomic datasets and annotations. Bioinformatics (2011). doi:10.1093/bioinformatics/btr539
Compiled Skill
No compiled skill yet for BEDTools.
Installation
conda install -c bioconda bedtoolsContainer Images
docker pull quay.io/bedtools:2.31.1--hf5e1c6e_1Version History
- v2.31.1