macでインフォマティクス

macでインフォマティクス

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

カバレッジトラックを視覚化する SparK

2020 3/1 コマンド修正

2024/04/17 help更新

 

Integrative Genomics Viewer(IGV)やUCSCゲノムブラウザなど、NGSデータの表示に利用できる洗練されたリソースが存在するが、領域のエクスポートとpublication用の図の組み立ては依然として困難である。特に、トラックの外観のカスタマイズとtrack replicatesのオーバーレイは、手動で時間のかかるプロセスである。ここでは、RNA-seq、ChIP-seq、ATAC-seqなど、NGSベースのトラックからpublication可能な高解像度のベクターグラフィックフィギュアを自動生成するツールであるSparKを紹介する。 SparKの新しい機能には、replicatesの平均化、標準偏差トラックのプロット、大幅に変更された領域の強調表示が含まれる。 SparKはPython 3で記述されており、主要なOSプラットフォームで実行可能である。コマンドラインプロンプトを使用して図を生成すると、後で変更するのが非常に簡単になる。たとえば、プロットのゲノム領域を変更する必要がある場合、またはトラックを追加/削除する必要がある場合、すべてを手動で再エクスポートおよび再組み立てするプロセスなしで、数秒以内に図を簡単に再生成できる。 SparKでプロットした後、出力SVGベクターグラフィックファイルの変更は、テキスト、線、色など、簡単に行える。 SparKはGitHubで公開されている:https://github.com/harbourlab/SparK

 

 

インストール

macos10.14のanaconda3.7環境でテストした。

依存

  • Python 3 (in theory Python 2 should work too, but I highly reccomend using Python 3)
  • numpy
#bedgraphを作るにはdeeptoolsも必要。
conda install -c bioconda deeptools

本体 Github

git clone https://github.com/harbourlab/SparK.git
cd SparK/

python SparK.py -h

$  python SparK.py -h

usage: SparK.py [-h] [-pt PLOT_TYPE] [-ps SHOW_PLOTS] -pr REGION -cf CONTROL_FILES [CONTROL_FILES ...] [-tf TREAT_FILES [TREAT_FILES ...]] [-cg CONTROL_GROUPS [CONTROL_GROUPS ...]] [-tg TREAT_GROUPS [TREAT_GROUPS ...]] [-gl GROUP_LABELS [GROUP_LABELS ...]]

                [-l LABELS [LABELS ...]] [-gs GROUP_AUTOSCALE] [-es EXCLUDE_FROM_GROUP_AUTOSCALE [EXCLUDE_FROM_GROUP_AUTOSCALE ...]] [-eg EXCLUDE_GROUPS [EXCLUDE_GROUPS ...]] [-f FILLS [FILLS ...]] [-cs CUSTOM_Y_AXIS_SCALES [CUSTOM_Y_AXIS_SCALES ...]]

                [-dc DISPLAY_CHROM_LOCATION] [-gtf GTFFILE] [-tss DRAWTSS] [-genestart DRAW_GENESTART] [-sp SPARK] [-sc SPARK_COLOR [SPARK_COLOR ...]] [-sm SMOOTHEN] [-o OUTPUT_NAME] [-bed BED_FILES [BED_FILES ...]] [-bedcol BED_COLOR [BED_COLOR ...]]

                [-bedlab BED_LABELS [BED_LABELS ...]] [-w TRACK_WIDTH] [-dg DISPLAY_GENES [DISPLAY_GENES ...]] [-dt DISPLAY_TRANSCRIPTS [DISPLAY_TRANSCRIPTS ...]] [-wg WRITE_GENENAMES] [-scale DISPLAY_SCALEBAR]

 

SparC_args

 

optional arguments:

  -h, --help            show this help message and exit

  -pt PLOT_TYPE, --plot_type PLOT_TYPE

                        choices: standard, STD, sine

  -ps SHOW_PLOTS, --show_plots SHOW_PLOTS

                        choices: all, averages

  -pr REGION, --region REGION

                        example: chr1:1647389-272634

  -cf CONTROL_FILES [CONTROL_FILES ...], --control_files CONTROL_FILES [CONTROL_FILES ...]

                        separate by space

  -tf TREAT_FILES [TREAT_FILES ...], --treat_files TREAT_FILES [TREAT_FILES ...]

                        separate by space

  -cg CONTROL_GROUPS [CONTROL_GROUPS ...], --control_groups CONTROL_GROUPS [CONTROL_GROUPS ...]

                        group numbers separate by spacse

  -tg TREAT_GROUPS [TREAT_GROUPS ...], --treat_groups TREAT_GROUPS [TREAT_GROUPS ...]

                        group numbers separate by space

  -gl GROUP_LABELS [GROUP_LABELS ...], --group_labels GROUP_LABELS [GROUP_LABELS ...]

                        set group labels

  -l LABELS [LABELS ...], --labels LABELS [LABELS ...]

                        set labels for controls and treatment

  -gs GROUP_AUTOSCALE, --group_autoscale GROUP_AUTOSCALE

                        set to "yes" to autoscale all groups(plots), except the groups excluded in -eg

  -es EXCLUDE_FROM_GROUP_AUTOSCALE [EXCLUDE_FROM_GROUP_AUTOSCALE ...], --exclude_from_group_autoscale EXCLUDE_FROM_GROUP_AUTOSCALE [EXCLUDE_FROM_GROUP_AUTOSCALE ...]

                        group numbers of groups to be excluded from autoscale

  -eg EXCLUDE_GROUPS [EXCLUDE_GROUPS ...], --exclude_groups EXCLUDE_GROUPS [EXCLUDE_GROUPS ...]

                        Exclude groups from the analysis

  -f FILLS [FILLS ...], --fills FILLS [FILLS ...]

                        track colors. One or two colors in hex format for control and treatment tracks

  -cs CUSTOM_Y_AXIS_SCALES [CUSTOM_Y_AXIS_SCALES ...], --custom_y_axis_scales CUSTOM_Y_AXIS_SCALES [CUSTOM_Y_AXIS_SCALES ...]

                        Enter y-axis values for all groups(plots). All groups need a value. Enter "D" for each group no value should be assigned, e.g. to keep autoscaling functionality for some groups

  -dc DISPLAY_CHROM_LOCATION, --display_chrom_location DISPLAY_CHROM_LOCATION

                        set to "no" if you do not want to plot the chromosomal coordinates

  -gtf GTFFILE, --gtffile GTFFILE

                        link gtf file for drawing genes here

  -tss DRAWTSS, --drawtss DRAWTSS

                        set to "no" if TSS sites should not be indicated

  -genestart DRAW_GENESTART, --draw_genestart DRAW_GENESTART

                        set to "yes" if TSS sites should be indicated

  -sp SPARK, --spark SPARK

                        display significant change "yes"

  -sc SPARK_COLOR [SPARK_COLOR ...], --spark_color SPARK_COLOR [SPARK_COLOR ...]

                        spark color

  -sm SMOOTHEN, --smoothen SMOOTHEN

                        smoothen tracks, int

  -o OUTPUT_NAME, --output_name OUTPUT_NAME

                        output graph name, str

  -bed BED_FILES [BED_FILES ...], --bed_files BED_FILES [BED_FILES ...]

                        bed files to be plotted

  -bedcol BED_COLOR [BED_COLOR ...], --bed_color BED_COLOR [BED_COLOR ...]

                        colors of bed files in hex

  -bedlab BED_LABELS [BED_LABELS ...], --bed_labels BED_LABELS [BED_LABELS ...]

                        set labels for bed tracks

  -w TRACK_WIDTH, --track_width TRACK_WIDTH

                        width of the track, default = 150, int

  -dg DISPLAY_GENES [DISPLAY_GENES ...], --display_genes DISPLAY_GENES [DISPLAY_GENES ...]

                        genes to display from the gtf file

  -dt DISPLAY_TRANSCRIPTS [DISPLAY_TRANSCRIPTS ...], --display_transcripts DISPLAY_TRANSCRIPTS [DISPLAY_TRANSCRIPTS ...]

                        display custom transcripts. By default, all transcripts annotated in the gtf file will be merged and displayed as one gene. Alternatively all can be plotted seperatelly by setting this to "all". Further, Transcript IDs can be listed to

                        plot only certain transcripts

  -wg WRITE_GENENAMES, --write_genenames WRITE_GENENAMES

                        write genename instead of transcript ID when transcripts are plotted. Set to "yes".

  -scale DISPLAY_SCALEBAR, --display_scalebar DISPLAY_SCALEBAR

                        set to "no" to remove scalebar

(r4) kamisakakazumanoMac-Studio:SparK kamisakakazuma$ python SparK.py -pr Aggregatilineales_A4b_gen._1_1:1-10000000 -cf ../uesaka.bdg -w 300 -cd 300

usage: SparK.py [-h] [-pt PLOT_TYPE] [-ps SHOW_PLOTS] -pr REGION -cf CONTROL_FILES [CONTROL_FILES ...] [-tf TREAT_FILES [TREAT_FILES ...]] [-cg CONTROL_GROUPS [CONTROL_GROUPS ...]] [-tg TREAT_GROUPS [TREAT_GROUPS ...]] [-gl GROUP_LABELS [GROUP_LABELS ...]]

                [-l LABELS [LABELS ...]] [-gs GROUP_AUTOSCALE] [-es EXCLUDE_FROM_GROUP_AUTOSCALE [EXCLUDE_FROM_GROUP_AUTOSCALE ...]] [-eg EXCLUDE_GROUPS [EXCLUDE_GROUPS ...]] [-f FILLS [FILLS ...]] [-cs CUSTOM_Y_AXIS_SCALES [CUSTOM_Y_AXIS_SCALES ...]]

                [-dc DISPLAY_CHROM_LOCATION] [-gtf GTFFILE] [-tss DRAWTSS] [-genestart DRAW_GENESTART] [-sp SPARK] [-sc SPARK_COLOR [SPARK_COLOR ...]] [-sm SMOOTHEN] [-o OUTPUT_NAME] [-bed BED_FILES [BED_FILES ...]] [-bedcol BED_COLOR [BED_COLOR ...]]

                [-bedlab BED_LABELS [BED_LABELS ...]] [-w TRACK_WIDTH] [-dg DISPLAY_GENES [DISPLAY_GENES ...]] [-dt DISPLAY_TRANSCRIPTS [DISPLAY_TRANSCRIPTS ...]] [-wg WRITE_GENENAMES] [-scale DISPLAY_SCALEBAR]

SparK.py: error: unrecognized arguments: -cd 300

 

実行方法

1、使用にはbedgraphファイルが必要。deeptoolsのbamCoverageコマンドでつくる。 -bs 1を指定するが、chip-seqではこのコマンドは推奨されない(Githubより)。MACS2から出力する。

bamCoverage -b input.bam -o output.bdg -bs 1 -of bedgraph
  • --binSize < INT> bp, -bs     Size of the bins, in bases, for the output of the bigwig/bedgraph file. (Default: 50)
  • -of {bigwig, bedgraph}

 

2、SparKの実行。

bedgraphファイルと領域を指定して実行する。chr1:1-1000のカバレッジを視覚化する。

python SparK.py -pr chr1:1-10000 -cf control.bdg
  • -pr, --region    example: chr1:1647389-272634
  • -cf , --control_files   CONTROL_FILES

f:id:kazumaxneo:20200204231447p:plain


Githubに例があるように、複数ファイルを指定することもできる。

python SparK.py -pr chr:1-10000 -cf sample1.bdg sample2.bdg -gl sample1 sample2

-gl, --group_labels    set group labels

f:id:kazumaxneo:20200301225233p:plain

 

gtfを指定すると、図の下にgenomic featureが表示される。同時に-dgフラグも立てると指定した遺伝子のみ図の下に表示できる(表記が重なるのを防ぐ)。

python SparK.py \
-pr chr12:6520512-6640512 \
-cf HepG2_H3K27AC_1_ENCFF495QSO.bigWig.bdg HepG2_H3K27AC_2_ENCFF348RLL.bigWig.bdg HepG2_H3K4me3_1_ENCFF699DRO.bigWig.bdg HepG2_H3K4me3_2_ENCFF400FYO.bigWig.bdg \
-gff gencode.v24.primary_assembly.annotation.txt \
-gl H3K27AC H3K4me3 H3K27AC-2 H3K4me3-2 \
-dg GAPDH IFFO1 NOP2 CHD4 LPAR5
  • -dg    genes to display from the gff file
  • -gff    link gff file for drawing genes here

 

オーバーレイ表示もできる。どれとどれをオーバーレイ表示するか-tg <NUM>,  -cg <NUM>で指定する。幅を150から300に増やす。出力名はtest.svgにする。

python SparK.py -pr chr:1-10000 \
-cf sample1_cont.bdg -tf sample1_treat.bdg\
-tg 1 -cg 1 \
-gl sample1 \
-w 300 \
-o test.svg

f:id:kazumaxneo:20200301232028p:plain

カバレッジに差があるサンプルを使ってしまったので分かりにくいが、下の方の赤くなっている部分がカバレッジの少ない方のサンプル。そのほか、カバレッジ変動が激しい領域をだけ色を変えて強調表示するなどがある。

 

追記

y軸の値を指定する(新機能)。

 python SparK.py -pr chr1:1-10000 -cf sample1_cont.bdg -w 300 -cs 300
  • -cs     Enter y-axis values for all groups(plots). All groups need a value. Enter "D" for each group no value should be as

 

更新についてはGIthubを確認してください。

引用

SparK: A Publication-quality NGS Visualization Tool

Stefan Kurtenbach, J. William Harbour

bioRxiv preprint first posted online Nov. 16, 2019

 

関連