~ubuntu-branches/ubuntu/raring/bedtools/raring

« back to all changes in this revision

Viewing changes to docs/content/coverageBed.rst

  • Committer: Package Import Robot
  • Author(s): Charles Plessy
  • Date: 2012-11-04 17:59:41 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20121104175941-hahqzy1w8uy650z0
Tags: 2.17.0-1
bb9012e Imported Upstream version 2.16.2.
9006b23 Imported Upstream version 2.17.0.
9112569 Documented BEDTools license as a whole.
325689c Removed Pre-Depends: dpkg (>= 1.15.6).
a781b14 Conforms with Policy 3.9.4.
84b1167 Use Debhelper 9. 
0bf572d Distribute the test suite.
422cd34 Bash completion for BEDTools.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
###############
 
2
5.9 coverageBed
 
3
###############
 
4
**coverageBed** computes both the *depth* and *breadth* of coverage of features in file A across the features
 
5
in file B. For example, **coverageBed** can compute the coverage of sequence alignments (file A) across 1
 
6
kilobase (arbitrary) windows (file B) tiling a genome of interest. One advantage that **coverageBed**
 
7
offers is that it not only *counts* the number of features that overlap an interval in file B, it also
 
8
computes the fraction of bases in B interval that were overlapped by one or more features. Thus,
 
9
**coverageBed** also computes the *breadth* of coverage for each interval in B.
 
10
 
 
11
==========================================================================
 
12
5.9.1 Usage and option summary
 
13
==========================================================================
 
14
Usage:
 
15
::
 
16
  coverageBed [OPTIONS] -a <BED/GFF/VCF> -b <BED/GFF/VCF>
 
17
  
 
18
===========================      ===============================================================================================================================================================================================================
 
19
Option                           Description
 
20
===========================      ===============================================================================================================================================================================================================
 
21
**-abam**                                        BAM file A. Each BAM alignment in A is compared to B in search of overlaps. Use "stdin" if passing A with a UNIX pipe: For example:
 
22
 
 
23
                                 | samtools view -b <BAM> | intersectBed -abam stdin -b genes.bed
 
24
                                                                 
 
25
**-s**                                           Force strandedness. That is, only features in A are only counted towards coverage in B if they are the same strand. *By default, this is disabled and coverage is counted without respect to strand*.
 
26
**-hist**                        Report a histogram of coverage for each feature in B as well as a summary histogram for _all_ features in B.
 
27
 
 
28
                                 | Output (tab delimited) after each feature in B:
 
29
                                                                 
 
30
                                                                 | 1) depth
 
31
                                                                 | 2) # bases at depth
 
32
                                                                 | 3) size of B
 
33
                                                                 | 4) % of B at depth
 
34
**-d**                           Report the depth at each position in each B feature. Positions reported are one based. Each position and depth follow the complete B feature.
 
35
**-split**                       Treat "split" BAM or BED12 entries as distinct BED intervals when computing coverage. For BAM files, this uses the CIGAR "N" and "D" operations to infer the blocks for computing coverage. For BED12 files, this uses the BlockCount, BlockStarts, and BlockEnds fields (i.e., columns 10,11,12).
 
36
===========================      ===============================================================================================================================================================================================================
 
37
 
 
38
 
 
39
 
 
40
 
 
41
 
 
42
 
 
43
==========================================================================
 
44
5.9.2 Default behavior
 
45
==========================================================================
 
46
After each interval in B, **coverageBed** will report:
 
47
 
 
48
1) The number of features in A that overlapped (by at least one base pair) the B interval.
 
49
2) The number of bases in B that had non-zero coverage from features in A.
 
50
3) The length of the entry in B.
 
51
4) The fraction of bases in B that had non-zero coverage from features in A.
 
52
 
 
53
Below are the number of features in A (N=...) overlapping B and fraction of bases in B with coverage.
 
54
::
 
55
  Chromosome  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
56
  
 
57
  BED FILE B  ***************     ***************     ******    **************   
 
58
  
 
59
  BED File A  ^^^^ ^^^^              ^^             ^^^^^^^^^    ^^^ ^^ ^^^^
 
60
                ^^^^^^^^                                      ^^^^^ ^^^^^ ^^
 
61
  
 
62
  Result      [  N=3, 10/15 ]     [  N=1, 2/16 ]     [N=1,6/6]   [N=5, 11/12 ]
 
63
 
 
64
 
 
65
For example:
 
66
::
 
67
  cat A.bed
 
68
  chr1  10  20
 
69
  chr1  20  30
 
70
  chr1  30  40
 
71
  chr1  100 200
 
72
 
 
73
  cat B.bed
 
74
  chr1  0   100
 
75
  chr1  100 200
 
76
  chr2  0   100
 
77
 
 
78
  coverageBed -a A.bed -b B.bed
 
79
  chr1  0   100  3  30  100 0.3000000
 
80
  chr1  100 200  1  100 100 1.0000000
 
81
  chr2  0   100  0  0   100 0.0000000
 
82
 
 
83
  
 
84
  
 
85
==========================================================================
 
86
5.9.4 (-s)Calculating coverage by strand 
 
87
==========================================================================
 
88
Use the "**-s**" option if one wants to only count coverage if features in A are on the same strand as the
 
89
feature / window in B. This is especially useful for RNA-seq experiments.
 
90
 
 
91
For example (note the difference in coverage with and without **-s**:
 
92
::
 
93
  cat A.bed
 
94
  chr1  10  20  a1  1  -
 
95
  chr1  20  30  a2  1  -
 
96
  chr1  30  40  a3  1  -
 
97
  chr1  100 200 a4  1  +
 
98
 
 
99
  cat B.bed
 
100
  chr1  0   100 b1  1  +
 
101
  chr1  100 200 b2  1  -
 
102
  chr2  0   100 b3  1  +
 
103
 
 
104
  coverageBed -a A.bed -b B.bed
 
105
  chr1  0   100 b1  1  +  3  30  100  0.3000000
 
106
  chr1  100 200 b2  1  -  1  100 100  1.0000000
 
107
  chr2  0   100 b3  1  +  0  0   100  0.0000000
 
108
 
 
109
  coverageBed -a A.bed -b B.bed -s
 
110
  chr1  0   100 b1  1  +  0  0   100  0.0000000
 
111
  chr1  100 200 b2  1  -  0  0   100  0.0000000
 
112
  chr2  0   100 b3  1  +  0  0   100  0.0000000
 
113
 
 
114
==========================================================================
 
115
5.9.5 (-hist)Creating a histogram of coverage for each feature in the B file 
 
116
==========================================================================
 
117
One should use the "**-hist**" option to create, for each interval in B, a histogram of coverage of the
 
118
features in A across B.
 
119
 
 
120
In this case, each entire feature in B will be reported, followed by the depth of coverage, the number of
 
121
bases at that depth, the size of the feature, and the fraction covered. After all of the features in B have
 
122
been reported, a histogram summarizing the coverage among all features in B will be reported.
 
123
::
 
124
  cat A.bed
 
125
  chr1  10  20  a1  1  -
 
126
  chr1  20  30  a2  1  -
 
127
  chr1  30  40  a3  1  -
 
128
  chr1  100 200 a4  1  +
 
129
 
 
130
  cat B.bed
 
131
  chr1  0   100 b1  1  +
 
132
  chr1  100 200 b2  1  -
 
133
  chr2  0   100 b3  1  +
 
134
 
 
135
  coverageBed -a A.bed -b B.bed -hist
 
136
  chr1  0   100 b1  1  +  0  70  100  0.7000000
 
137
  chr1  0   100 b1  1  +  1  30  100  0.3000000
 
138
  chr1  100 200 b2  1  -  1  100 100  1.0000000
 
139
  chr2  0   100 b3  1  +  0  100 100  1.0000000
 
140
  all   0   170 300 0.5666667
 
141
  all   1   130 300 0.4333333
 
142
 
 
143
 
 
144
 
 
145
==========================================================================
 
146
5.9.6 (-hist)Reporting the per-base of coverage for each feature in the B file 
 
147
==========================================================================
 
148
One should use the "**-d**" option to create, for each interval in B, a detailed list of coverage at each of the
 
149
positions across each B interval.
 
150
 
 
151
The output will consist of a line for each one-based position in each B feature, followed by the coverage
 
152
detected at that position.
 
153
::
 
154
  cat A.bed
 
155
  chr1  0  5
 
156
  chr1  3  8
 
157
  chr1  4  8
 
158
  chr1  5  9
 
159
 
 
160
  cat B.bed
 
161
  chr1  0  10
 
162
 
 
163
  coverageBed -a A.bed -b B.bed -d
 
164
  chr1  0  10  B  1  1
 
165
  chr1  0  10  B  2  1
 
166
  chr1  0  10  B  3  1
 
167
  chr1  0  10  B  4  2
 
168
  chr1  0  10  B  5  3
 
169
  chr1  0  10  B  6  3
 
170
  chr1  0  10  B  7  3
 
171
  chr1  0  10  B  8  3
 
172
  chr1  0  10  B  9  1
 
173
  chr1  0  10  B  10 0
 
174
 
 
175
  
 
176
  
 
177
==========================================================================
 
178
5.9.7 (-split)Reporting coverage with spliced alignments or blocked BED features 
 
179
==========================================================================
 
180
As described in section 1.3.19, coverageBed will, by default, screen for overlaps against the entire span
 
181
of a spliced/split BAM alignment or blocked BED12 feature. When dealing with RNA-seq reads, for
 
182
example, one typically wants to only tabulate coverage for the portions of the reads that come from
 
183
exons (and ignore the interstitial intron sequence). The **-split** command allows for such coverage to be
 
184
performed.