bamcovは、Florian Breitwieserさん(Github)が公開されている、bamのカバレッジを計算してコンソール上で表示するユーティリティ。
インストール
macps10.14でテストした。
git clone --recurse-submodules https://github.com/fbreitwieser/bamcov
cd bamcov
make
make test
> make test
$ make test
./bamcov -H test.bam | column -ts$'\t'
NW_002479957.1 1 514 16 335 65.1751 2.05642 35 6.38
NW_002477246.1 1 2012514 3966 234753 11.6647 0.147286 34.5 43.4
./bamcov -m test.bam
NW_002479957.1 (514bp)
> 90.00% │ ██████████████████ ██████████████ │ Number of reads: 16
> 80.00% │ ██████████████████ ██████████████ │
> 70.00% │ ██████████████████ ██████████████ │ Covered bases: 335bp
> 60.00% │ ██████████████████ ██████████████ │ Percent covered: 65.18%
> 50.00% │ ███████████████████ ███████████████ │ Mean coverage: 2.06x
> 40.00% │ ███████████████████ ███████████████ │ Mean baseQ: 35
> 30.00% │ ███████████████████ ███████████████ │ Mean mapQ: 6.38
> 20.00% │ ████████████████████ ███████████████ │
> 10.00% │ ████████████████████ ███████████████ │ Histo bin width: 10bp
> 0.00% │ ████████████████████ ███████████████ │ Histo max bin: 100%
1 100 200 300 400 514
NW_002477246.1 (2.01Mbp)
> 14.45% │ ▄ █ ▄ │ Number of reads: 3966
> 12.84% │ ▄█ ▄▄ ▄ ▄▄ █ ▄ ███ ▄ ▄│ (20 filtered)
> 11.24% │▄ ███ █ ▄▄ ▄ ███▄ ██ ▄██ █ ███ ███ ▄██ ██│ Covered bases: 234.8Kbp
> 9.63% │█ ▄███ █ ██▄█ ████ ██ █ ████▄█ ████▄███ ████ ███│ Percent covered: 11.66%
> 8.03% │██ ████ █▄████ ███████▄█▄██████ ████████▄████████│ Mean coverage: 0.147x
> 6.42% │███████ ██████ ███████████████████████████████████│ Mean baseQ: 34.5
> 4.82% │██████████████ ███████████████████████████████████│ Mean mapQ: 43.4
> 3.21% │██████████████▄███████████████████████████████████│
> 1.61% │██████████████████████████████████████████████████│ Histo bin width: 40.2Kbp
> 0.00% │██████████████████████████████████████████████████│ Histo max bin: 16.055%
1 402.5K 805.0K 1.21M 1.61M 2.01M
#help
> ./bamcov -h
$ ./bamcov -h
Usage: bamcov [options] in1.bam [in2.bam [...]]
Input options:
-l, --min-read-len INT ignore reads shorter than INT bp [0]
-q, --min-MQ INT base quality threshold [0]
-Q, --min-BQ INT mapping quality threshold [0]
--rf <int|str> required flags: skip reads with mask bits unset []
--ff <int|str> filter flags: skip reads with mask bits set
[UNMAP,SECONDARY,QCFAIL,DUP]
Output options:
-m, --histogram show histogram instead of tabular output
-o, --output FILE write output to FILE [stdout]
-H, --no-header don't print a header in tabular mode
-U, --full-utf full UTF8 mode for histogram for finer resolution
-w, --n-bins INT number of bins in histogram. If 0, use terminal width [50]
-r, --region REG show specified region. Format: chr:start-end.
-h, --help help (this page)
See manpage for additional details. Tabular format columns::
rname Reference name / chromosome
startpos Start position
endpos End position (or sequence length)
numreads Number reads aligned to the region (after filtering)
covbases Number of covered bases with depth >= 1
coverage Proportion of covered bases [0..1]
meandepth Mean depth of coverage
meanbaseq Mean baseQ in covered region
meanmapq Mean mapQ of selected reads
実行方法
カバレッジをタブ区切りで表示
bamcov input.bam
-Hをつけるとヘッダー部分(コメント行)は出力しない。
bamcov -m input.bam
chromosome/plasmidごとに、 chr全体のカバレッジが出力される。
chr (4.5Mbp)
> 90.00% │██████████████████████████████████████████████████│ Number of reads: 9166
> 80.00% │██████████████████████████████████████████████████│ (43 filtered)
> 70.00% │██████████████████████████████████████████████████│ Covered bases: 4.5Mbp
> 60.00% │██████████████████████████████████████████████████│ Percent covered: 99.97%
> 50.00% │██████████████████████████████████████████████████│ Mean coverage: 21.2x
> 40.00% │██████████████████████████████████████████████████│ Mean baseQ: 255
> 30.00% │██████████████████████████████████████████████████│ Mean mapQ: 59.9
> 20.00% │██████████████████████████████████████████████████│
> 10.00% │██████████████████████████████████████████████████│ Histo bin width: 71.4Kbp
> 0.00% │██████████████████████████████████████████████████│ Histo max bin: 100%
1 714.2K 1.43M 2.14M 2.86M 3.57M
chr2の10000-20000のカバレッジだけ表示する。
bamcov -m -r chr2:10000-20000 input.bam
$ bamcov -m -r chr2:10000-20000 sorted.bam
chr1 (3.4Mbp)
> 90.00% │██████████████████████████████████████████████████│ Number of reads: 35
> 80.00% │██████████████████████████████████████████████████│
> 70.00% │██████████████████████████████████████████████████│ Covered bases: 10.0Kbp
> 60.00% │██████████████████████████████████████████████████│ Percent covered: 100%
> 50.00% │██████████████████████████████████████████████████│ Mean coverage: 13.3x
> 40.00% │██████████████████████████████████████████████████│ Mean baseQ: 255
> 30.00% │██████████████████████████████████████████████████│ Mean mapQ: 60
> 20.00% │██████████████████████████████████████████████████│
> 10.00% │██████████████████████████████████████████████████│ Histo bin width: 200bp
> 0.00% │██████████████████████████████████████████████████│ Histo max bin: 100%
10.0K 12.0K 14.0K 16.0K 18.0K 20.0K
(base)
-wで幅を調節できる。-w1で最小幅になり、"-w0"で最大の幅になる。
bamcov -mw2 input.bam
chr (4.5Mbp)
> 89.99% │██│ Number of reads: 9166
> 79.99% │██│ (43 filtered)
> 70.00% │██│ Covered bases: 4.5Mbp
> 60.00% │██│ Percent covered: 99.97%
> 50.00% │██│ Mean coverage: 21.2x
> 40.00% │██│ Mean baseQ: 255
> 30.00% │██│ Mean mapQ: 59.9
> 20.00% │██│
> 10.00% │██│ Histo bin width: 1.79Mbp
> 0.00% │██│ Histo max bin: 99.993%
1 3.57M
plasmid (43.3Kbp)
> 89.83% │█▄│ Number of reads: 242
> 79.85% │██│ (2 filtered)
> 69.87% │██│ Covered bases: 40.1Kbp
> 59.89% │██│ Percent covered: 98.28%
> 49.90% │██│ Mean coverage: 17.8x
> 39.92% │██│ Mean baseQ: 255
> 29.94% │██│ Mean mapQ: 59.9
> 19.96% │██│
> 9.98% │██│ Histo bin width: 51.7Kbp
> 0.00% │██│ Histo max bin: 99.808%
1 103.3K
引用
GitHub - fbreitwieser/bamcov: Quickly calculate and visualize sequence coverage in alignment files
関連