Skip to main content

BEDTools

bio.toolsVerified30 docs · 15.9K tokens
v2.31.1

Swiss-army knife of genome feature analysis toolset

BioContainers
75trust score
FAIR
Homepage →View on bio.toolsLicense: MIT
Topic:0622Operation:2429Operation:3194

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/biotools/bedtools

EDAM Annotations

Documentation Snippets

15,906 tokens · 30 snippets
Source
1###############
2Advanced usage
3###############
4
5
6==========================================================================
7Mask all regions in a genome except for targeted capture regions.
8==========================================================================
9
10Step 1. Add 500 bp up and downstream of each probe
11
12.. code-block:: bash
13
14 bedtools slop -i probes.bed -g hg18.genome -b 500 > probes.500bp.bed
15
16NB genome is two column chromosome size list - i.e. https://genome.ucsc.edu/goldenpath/help/hg18.chrom.sizes
17
18Step 2. Get a BED file of all regions not covered by the probes (+500 bp up/down)
19
20
21.. code-block:: bash
22
23 bedtools complement -i probes.500bp.bed -g hg18.genome > probes.500bp.complement.bed
24
25
26Step 3. Create a masked genome where all bases are masked except for the probes +500bp
27
28.. code-block:: bash
29
30 bedtools maskfasta -fi hg18.fa -bed probes.500bp.complement.bed \
31 -fo hg18.probecomplement.masked.fa
32
33
34
35==========================================================================
36Screening for novel SNPs.
37==========================================================================
38Find all SNPs that are not in dbSnp and not in the latest 1000 genomes calls
39
40.. code-block:: bash
41
42 bedtools intersect -a snp.calls.bed -b dbSnp.bed -v | \
43 bedtools intersect -a - -b 1KG.bed -v | \
44 > snp.calls.novel.bed
45
46
47==========================================================================
48Computing the coverage of features that align entirely within an interval.
49==========================================================================
50
51By default, bedtools ``coverage`` counts any feature in A that overlaps B
52by >= 1 bp. If you want to require that a feature align entirely within B for
53it to be counted, you can first use intersectBed with the "-f 1.0" option.
54
55.. code-block:: bash
56
57 bedtools intersect -a features.bed -b windows.bed -f 1.0 | \
58 bedtools coverage -a windows.bed -b - \
59 > windows.bed.coverage
60
61
62==========================================================================
63Computing the coverage of BAM alignments on exons.
64==========================================================================
65One can combine ``samtools`` with ``bedtools`` to compute coverage directly
66from the BAM data by using ``bamtobed``.
67
68.. code-block:: bash
69
70 bedtools bamtobed -i reads.bam | \
71 bedtools coverage -a exons.bed -b - \
72 > exons.bed.coverage
73
74
75Take it a step further and require that coverage be from properly-paired reads.
76
77.. code-block:: bash
78
79 samtools view -uf 0x2 reads.bam | \
80 coverageBed -abam - -b exons.bed \
81 > exons.bed.proper.coverage
82
83
84
85==========================================================================
86Computing coverage separately for each strand.
87==========================================================================
88Use grep to only look at forward strand features (i.e. those that end in "+").
89
90.. code-block:: bash
91
92 bedtools bamtobed -i reads.bam | \
93 grep \+$ | \
94 bedtools coverage -a - -b genes.bed \
95 > genes.bed.forward.coverage
96
97Use grep to only look at reverse strand features (i.e. those that end in "-").
98
99.. code-block:: bash
100
101 bedtools bamtobed -i reads.bam | \
102 grep \-$ | \
103 bedtools coverage -a - -b genes.bed \
104 > genes.bed.reverse.coverage
Source

Compiled Skill

No compiled skill yet for BEDTools.

Installation

conda
conda install -c bioconda bedtools

Container Images

quay.io
docker pull quay.io/bedtools:2.31.1--hf5e1c6e_1

Version History

  • v2.31.1