macでインフォマティクス

macでインフォマティクス

HTS (NGS) 関連のインフォマティクス情報についてまとめています。

bamのカバレッジを素早くプロットする tinycov

 

Githubより

Tinycovは、BAMファイルのカバレッジを素早くプロットする、Pythonで書かれた小さなスタンドアロンコマンドラインユーティリティです。このソフトウェアは、Matt Edwards氏のゲノムカバレッジプロッター(Github)に影響を受けています。入力として必要なのはBAMファイルのアライメントのみです。Coordinate sortされていない場合、ファイル名がinput.bamであれば、tinycovはinput.sorted.bamという名前でソートされたコピーを作成します。

 

インストール

Github

#pip (pypi)
pip install tinycov

#development version
git clone https://github.com/cmdoret/tinycov.git
cd tinycov
pip install .

tinycov

$ tinycov

Usage: tinycov [OPTIONS] COMMAND [ARGS]...

 

  tinycov: visualisation of coverage from BAM files using rolling window

  averages.

 

Options:

  --version  Show the version and exit.

  --help     Show this message and exit.

 

Commands:

  covhist  Visualise the histogram of coverage in rolling windows.

  covplot  Visualise coverage in rolling windows, optionally save results

           to...

> tinycov covhist --help

$ tinycov covhist --help

Usage: tinycov covhist [OPTIONS] BAM

 

  Visualise the histogram of coverage in rolling windows.

 

Options:

  -N, --no-filter          Use all reads. By default, PCR duplicates and

                           secondary alignments are excluded

 

  -m, --max-depth INTEGER  Maximum read depth permitted. Position with higher

                           coverage will set to this value

 

  -o, --out PATH           Output file where to write the plot. If not

                           provided, the plot is shown interactively

 

  -w, --whitelist TEXT     Only include those chromosomes in the plot. List of

                           comma-separated chromosome names.

 

  -b, --blacklist TEXT     Exclude those chromosomes from the plot. List of

                           comma-separated chromosome names.

 

  -n, --name TEXT          Name of the sample (plot title). Base name of input

                           file by default

 

  -B, --bins TEXT          Tab-separated file of three columns (chromosome,

                           start, end) without header containing a custom

                           binning to use. Overrides --res and --skip,

                           optional.

 

  -s, --skip INTEGER       Stride between windows, in basepairs.  [default:

                           1000]

 

  -r, --res INTEGER        Size of windows in which to compute coverage, in

                           basepairs.  [default: 10000]

 

  --version                Show the version and exit.

  --help                   Show this message and exit.

tinycov covplot --help

$ tinycov covplot --help

Usage: tinycov covplot [OPTIONS] BAM

 

  Visualise coverage in rolling windows, optionally save results to a

  bedgraph file.

 

Options:

  -N, --no-filter          Use all reads. By default, PCR duplicates and

                           secondary alignments are excluded

 

  -m, --max-depth INTEGER  Maximum read depth permitted. Position with higher

                           coverage will set to this value

 

  -o, --out PATH           Output file where to write the plot. If not

                           provided, the plot is shown interactively

 

  -w, --whitelist TEXT     Only include those chromosomes in the plot. List of

                           comma-separated chromosome names.

 

  -b, --blacklist TEXT     Exclude those chromosomes from the plot. List of

                           comma-separated chromosome names.

 

  -n, --name TEXT          Name of the sample (plot title). Base name of input

                           file by default

 

  -B, --bins TEXT          Tab-separated file of three columns (chromosome,

                           start, end) without header containing a custom

                           binning to use. Overrides --res and --skip,

                           optional.

 

  -s, --skip INTEGER       Stride between windows, in basepairs.  [default:

                           1000]

 

  -r, --res INTEGER        Size of windows in which to compute coverage, in

                           basepairs.  [default: 10000]

 

  -t, --text PATH          Output file where to write the raw data table.

  -p, --ploidy INTEGER     Ploidy of input sample, used to estimate coverage

                           threshold for aneuploidies. Setting to 0 disables

                           estimations.

 

  --version                Show the version and exit.

  --help                   Show this message and exit.

 

 

実行方法

covhistローリングウィンドウでカバー率ヒストグラムを可視化

bamを指定する。

tinycov covhist input.bam

出力

f:id:kazumaxneo:20210420140437p:plain

左下のボタンから、拡大縮小とスクロールができる。図をPNGで保存するには、フロッピー形状のボタンをクリックする。

 

covhist:ローリングウィンドウでカバレッジを可視化

bamを指定する。

tinycov covplot input.bam

出力

f:id:kazumaxneo:20210420140944p:plain

スライダーボタンからは図のサイズを変更できる。

f:id:kazumaxneo:20210420141202p:plain

 

chr21のみ描画する。結果はファイル保存する。

tinycov covplot out.bam -w chr21 -r 1000 -o putput_name -t coverage.txt 

putput_name.pngと coverage.txtが保存される。

 

ゲノムサイズによって、プロットの間隔(-s 1000)は調整して下さい。pythonのbamを扱うAPIを探している時に見つけたツールです。簡単に紹介しました。

引用

https://github.com/cmdoret/tinycov