macでインフォマティクス

macでインフォマティクス

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

VCFの要約統計プロットを出力する vcfstats

 

開発の動機(マニュアルより)

bcftoolsやjvarkitなどVCFファイルの統計情報をプロットするツールはいくつか存在する。しかし、いずれも 特定の指標をプロットする、プロットをカスタマイズする、特定のフィルタでバリアントにフォーカスする、を行うことができない。RのパッケージvcfRは、上記の一部を行うことができるが、しかし、VCF全体をメモリに読み込む必要があり、大きなVCFファイルには不親切である。

 

Documentation

https://pwwang.github.io/vcfstats/

 

インストール

Github

#ここではcondaの仮想環境に導入する
mamba create -n vcfstats python=3.9 -y
conda activate vcfstats
pip install -U vcfstats

#docker
docker run --rm justold/vcfstats:latest vcfstats
# or
singularity run docker://justold/vcfstats:latest vcfstats

>

$ vcfstats -h

 DESCRIPTION:

  vcfstats v0.2.0: Powerful VCF statistics.                                     

 USAGE:

  vcfstats --vcf PATH --outdir AUTO --formula LIST --title LIST [OPTIONS]

 REQUIRED OPTIONS:

  -v, --vcf <PATH>          - The VCF file.                                     

  -o, --outdir <AUTO>       - The output directory.                             

  -f, --formula <LIST>      - The formulas for plotting in format of Y ~ X,     

                              where Y and X should be either an entry or an     

                              aggregation.                                      

  --title <LIST>            - The title of each figure, will be used to name the

                              output files as well.                             

 OPTIONAL OPTIONS:

  --loglevel <STR>          - The logging level. Default: info                  

  --figtype <LIST>          - Your preferences for type of plot for each        

                              formula. Default: \                             

  --figfmt <LIST>           - Your preferences for format of figure for each    

                              formula, Any file format supported by matplotlib. 

                              Default is png. Default: \                      

  -r, --region <LIST>       - Regions in format of CHR or CHR:START-END         

                              Default: \                                      

  -R, --Region <AUTO>       - Regions in a BED file. If both --region/--Region  

                              are provided, regions will be merged together.    

                              Default: None                                     

  -p, --passed [BOOL]       - Only analyze variants that pass all filters.      

                              This does not work if FILTER entry is in the      

                              analysis.                                         

                              Default: False                                    

  -l, --list [BOOL]         - List all available macros. Default: False         

  -s, --savedata [BOOL]     - Whether save the plotting data for further        

                              exploration. Default: False                       

  --macro <PATH>            - A user-defined macro file. Default: None          

  --ggs <LIST>              - Extra ggplot2 expressions for each plot           

                              Default: \                                      

  --devpars <NS>            - The device parameters for plots. To specify       

                              devpars for each plot, use a configuration file.  

  -c, --config <AUTO>       - A configuration file defining how to plot in TOML 

                              format.                                           

                              If this is provided, CLI arguments will be        

                              overwritten if defined in this file. Default: None

  -h, --help                - Print help information for this command           

 OPTIONAL OPTIONS UNDER --devpars:

  --devpars.width <INT>     - The width of the plot Default: 2000               

  --devpars.height <INT>    - The height of the plot Default: 2000              

  --devpars.res <INT>       - The resolution of the plot Default: 300         

 

 

テストラン

vcfファイルとconfigファイル(詳細)を指定する。出力はexamples/、図のタイトルは'Number of variants on each chromosome'、Y軸 と X軸の軸ラベル はCOUNT<INT>とCONTIG。出力ディレクトリは前もって作成しておく必要がある。

git clone https://github.com/pwwang/vcfstats.git
cd vcfstats/

mkdir out
vcfstats --vcf examples/sample.vcf \
  --outdir out/ \
    --formula 'COUNT(1) ~ CONTIG' \
    --title 'Number of variants on each chromosome' \
    --config examples/config.toml
  • --vcf   The VCF file
  • --outdir   The output directory. 
  • -c    A configuration file defining how to plot in TOML format. If this is provided, CLI arguments will be overwritten if defined in this file. Default: None
  • --title    The title of each figure, will be used to name the output files as well.
  • --formula    The formulas for plotting in format of Y ~ X, where Y and X should be either an entry or an aggregation.

出力

out/number-of-variants-on-each-chromosome.col.png

f:id:kazumaxneo:20220112004532p:plain

 

Githubでは--formulaオプションを調節して特定の染色体だけプロットするようにカスタムする例や他の要約統計プロットを出力するコマンドについて説明されています。アクセスしてみて下さい。

引用

GitHub - pwwang/vcfstats: Powerful statistics for VCF files

 

関連