Debian Codegraph @

docs/index.rst

raw
1 ================================================================
2 **bedtools**: *a powerful toolset for genome arithmetic*
3 ================================================================
4
5 Collectively, the **bedtools** utilities are a swiss-army knife of tools
6 for a wide-range of genomics analysis tasks. The most widely-used
7 tools enable *genome arithmetic*: that is, set theory on the genome. For
8 example, **bedtools** allows one to *intersect*, *merge*, *count*, *complement*,
9 and *shuffle* genomic intervals from multiple files in widely-used
10 genomic file formats such as BAM, BED, GFF/GTF, VCF. While each individual tool is designed to do a relatively simple task (e.g.,
11 *intersect* two interval files), quite sophisticated analyses can be conducted
12 by combining multiple bedtools operations on the UNIX command line.
13
14 **bedtools** is developed in the `Quinlan laboratory <http://quinlanlab.org>`_ at the `University of Utah <http://www.utah.edu/>`_ and benefits from fantastic contributions made by scientists worldwide.
15
16 ==========================
17 Tutorial
18 ==========================
19 - We have developed a fairly comprehensive `tutorial <http://quinlanlab.org/tutorials/bedtools/bedtools.html>`_ that demonstrates both the basics, as well as some more advanced examples of how bedtools can help you in your research. Please have a look.
20 - Robert Aboukhalil has developed `sandbox.bio <https://sandbox.bio/>`_ an excellent, web-based playground for the bedtools tutorial and other widely-used genomics tools.
21
22
23 ==========================
24 Important notes
25 ==========================
26 - As of version 2.28.0, bedtools now supports the CRAM format via the use of `htslib <https://github.com/samtools/htslib>`_. Specify the reference genome associated with your CRAM file via the CRAM_REFERENCE environment variable. Bedtools will look for this environment variable when it needs to access sequence data from the CRAM file (e.g., `bamtofastq`).
27 - With the exception of BAM files, `bedtools` assumes all input files are TAB delimited.
28 - `bedtools` also assumes that all input files use UNIX line endings.
29 - Unless you use the `-sorted` option, `bedtools` currently does not support chromosomes larger than 512Mb
30 - When using the -sorted option with files whose chromosomes are not lexicographically sorted (e.g., sort -k1,1 -k2,2n for BED files), one must provide a genome file (`-g`) defining the expected chromosome order.
31 - `bedtools` requires that chromosome naming schemes are identical in files that you are comparing (e.g., 'chr1' in one file and '1' in another won't work).
32 - .fai files may be used as genome (`-g`) files.
33
34 ==========================
35 Interesting Usage Examples
36 ==========================
37
38 In addition, here are a few examples of how bedtools has been used for genome research. If you have interesting examples, please send them our way and we will add them to the list.
39
40
41 - `Coverage analysis for targeted DNA capture <http://gettinggeneticsdone.blogspot.com/2014/03/visualize-coverage-exome-targeted-ngs-bedtools.html>`_. Thanks to `Stephen Turner <https://twitter.com/genetics_blog>`_.
42 - `Measuring similarity of DNase hypersensitivity among many cell types <https://github.com/arq5x/bedtools-protocols/blob/master/bedtools.md#bp6--measuring-dataset-similarity>`_
43 - `Extracting promoter sequences from a genome <http://www.biostars.org/p/17162/>`_
44 - `Comparing intersections among many genome interval files <http://www.biostars.org/p/13516/>`_
45 - `RNA-seq coverage analysis <http://www.cureffi.org/2013/11/18/an-mrna-seq-pipeline-using-gsnap-samtools-cufflinks-and-bedtools/>`_. Thanks to `Erik Minikel <https://twitter.com/cureffi>`_.
46 - `Identifying targeted regions that lack coverage <https://twitter.com/aaronquinlan/status/421786507511205888>`_. Thanks to `Brent Pedersen <https://twitter.com/brent_p>`_.
47 - `Calculating GC content for CCDS exons <http://www.biostars.org/p/47047/>`_.
48 - `Making a master table of ChromHMM tracks for multiple cell types <https://gist.github.com/arq5x/3138599>`_.
49
50
51 =================
52 Table of contents
53 =================
54 .. toctree::
55 :maxdepth: 1
56
57 content/overview
58 content/installation
59 content/quick-start
60 content/general-usage
61 content/history
62 content/bedtools-suite
63 content/example-usage
64 content/advanced-usage
65 content/tips-and-tricks
66 content/faq
67 content/related-tools
68
69
70 =================
71 Performance
72 =================
73 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
74 by chromosome and start position. As you can see in the plots below, the speed and memory consumption scale nicely
75 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.
76 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``.
77
78 Note: bedtools could not complete when using 100 million alignments and the R-Tree algorithm used for unsorted data owing to a lack of memory.
79
80 .. image:: content/images/speed-comparo.png
81 :width: 300pt
82 .. image:: content/images/memory-comparo.png
83 :width: 300pt
84
85 Commands used:
86
87 .. code-block:: bash
88
89 # bedtools sorted
90 $ bedtools intersect \
91 -a ccds.exons.bed -b aln.bam.bed \
92 -c \
93 -sorted
94
95 # bedtools unsorted
96 $ bedtools intersect \
97 -a ccds.exons.bed -b aln.bam.bed \
98 -c
99
100 # bedmap (without error checking)
101 $ bedmap --echo --count --bp-ovr 1 \
102 ccds.exons.bed aln.bam.bed
103
104 # bedmap (no error checking)
105 $ bedmap --ec --echo --count --bp-ovr 1 \
106 ccds.exons.bed aln.bam.bed
107
108
109
110 =================
111 Brief example
112 =================
113 Let's imagine you have a BED file of ChiP-seq peaks from two different
114 experiments. You want to identify peaks that were observed in *both* experiments
115 (requiring 50% reciprocal overlap) and for those peaks, you want to find to
116 find the closest, non-overlapping gene. Such an analysis could be conducted
117 with two, relatively simple bedtools commands.
118
119 .. code-block:: bash
120
121 # intersect the peaks from both experiments.
122 # -f 0.50 combined with -r requires 50% reciprocal overlap between the
123 # peaks from each experiment.
124 $ bedtools intersect -a exp1.bed -b exp2.bed -f 0.50 -r > both.bed
125
126 # find the closest, non-overlapping gene for each interval where
127 # both experiments had a peak
128 # -io ignores overlapping intervals and returns only the closest,
129 # non-overlapping interval (in this case, genes)
130 $ bedtools closest -a both.bed -b genes.bed -io > both.nearest.genes.txt
131
132 ==========
133 License
134 ==========
135 bedtools is freely available under a GNU Public License (Version 2).
136
137 =====================================
138 Acknowledgments
139 =====================================
140
141 To do.
142
143
144 =================
145 Mailing list
146 =================
147 If you have questions, requests, or bugs to report, please email the
148 `bedtools mailing list <https://groups.google.com/forum/?fromgroups#!forum/bedtools-discuss>`_
149