macでインフォマティクス

macでインフォマティクス

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

JavaScriptライブラリに基づいてインタラクティブなCircosプロットを生成するRパッケージ interacCircos

 

 JavaScriptベースのCircosライブラリは、ウェブアプリケーションインタラクティブなCircosプロットを生成するために広く実装されている。しかし、これらのライブラリは、ローカルにインストールする必要があり、余分なライブラリをコンパイルする必要があるか、プロットの各トラックの入力と設定を準備するために余分なデータ処理手順が必要であり、強力なRパッケージとの統合の有用性と能力が制限されている。本報告では、JavaScriptベースのライブラリを統合することで、インタラクティブなCircosプロットを作成するためのRパッケージ、interacCircosを紹介する。interacCircosは、大規模なゲノムデータをインタラクティブなCircosプロットで表現するための14のトラックプロット関数と7つの補助関数を、シンプルかつ柔軟に実装することができる。

 InteracCircos とそのマニュアルは https://github.com/mrcuizhe/interacCircos で自由に入手できる。オンラインドキュメントはGPLライセンスで、https://mrcuizhe.github.io/interacCircos_documentation/index.htmlから利用できる。

 

NG-Circos/BioCircos.js/circosJSのユーザーで、モジュールとそのデータ構造に慣れているなら、interacCircosに慣れるのにほとんど時間はかからない。

マニュアル

詳細なドキュメント(PDF)

 

Quick Start

https://mrcuizhe.github.io/interacCircos_documentation/html/quick_start.html

 

インストール

windows10のRstudioに導入した。

To install this package, start R (version "4.1") and enter:

#Install from Bioconductor
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("interacCircos")

#Install from Github (R package of htmlwidgets, RColorBrewer, plyr, jsonlite
# and grDevices are required ! )
if (!require('devtools')){install.packages('devtools')}
devtools::install_github('mrcuizhe/interacCircos')

 #Documenation

> browseVignettes("interacCircos")

 

デモラン

library(interacCircos)

 

例1、メイン関数Circos()はCircosプロットのために必要で、全てのモジュールの座標の基礎となる。

library(interacCircos)
Circos()

f:id:kazumaxneo:20210722204740p:plain

図はインタラクティブに操作可能(拡大縮小・スクロールなど)。デフォルトではヒトのKaryotypeダイアグラム(hg19)が使用される。

 

例2、サイズ指定し、結果はhtml保存する。染色体間の間隔を変えるにはchrPadを使う。

library(htmlwidgets)

plot <- Circos(width = 700,height = 550, chrPad = 0.04)
saveWidget(plot, "plot.html")
  • chrPad   Distance between each chromosome, default is 0.04
  • width, height   The width and height for svg element, could be px or percent or auto

 

例3、ゲノムを変える方法の一つにgenomeオプションがある。genomeオプションにリスト関数で染色体名と長さの値を提供する。長さの値をここでは3桁の相対値で指定しているが、染色体長(bp)の大きな値を指定しても問題ない。この例では、genomeFillColorオプションを使い、色もユーザーが指定している。色は、genomeオプションのリスト数分指定する(色を自動指定するのは例4)。

Circos(zoom = TRUE,genome=list("Example1"=100,"Example2"=200,
"Example3"=300),genomeFillColor = c("red","blue","green"),
width = 700,height = 550)
  • genome    Could be either ’hg19’, which is defaultly set to use chromosomes of hg19, or a list of chromosomes with length, for example, list("chr1"=100,"chr2"=200)  
  • genomeFillColor   Could be either a color palette from RColorBrewer, or a list of color name, for example, list("yellow","rgb(1,255,255)")

f:id:kazumaxneo:20210722215252p:plain

注釈としてリストで指定したExample1~Example3が付く。

 

例4、色の系統だけ指定して、自動で色を付ける。拡大縮小を無効にするにはzoomオプションを使う。

set.seed(1)
Circos(zoom = FALSE,genome=list("Example1"=100,"Example2"=200,
"Example3"=300),genomeFillColor = "Blues",
outerRadius = 220, width = 700,height = 550)
  • zoom   Whether or not the plot is zoomable?
  • innerRadius   Default 216, Inner radius of chromosome
  • outerRadius   Default 240, Outer radius of chromosome

f:id:kazumaxneo:20210723083645p:plain

 

例5、例4の改変で、リング外にクロモソーム毎のポジションの目盛りを100,000-bp刻みで表示する(genomeTicksDisplay = TRUE, genomeTicksScale = 100000)。chrの注釈は消す(genomeLabelDisplay = FALSE)。

Circos(zoom=FALSE,genome=list("Example1"=1000000,"Example2"=2000000,
"Example3"=3000000),genomeFillColor = "Blues",chrPad = 0,genomeTicksDisplay = TRUE,
genomeTicksScale = 100000,genomeLabelDisplay = FALSE)
  • genomeTicksDisplay   Whether display the ticks for genome track

f:id:kazumaxneo:20210723084841p:plain

他にも様々なカラーパレットが利用できます(参考にしたHP)。 

library(RColorBrewer)
display.brewer.all()

 

 

例6、内側のリングにヒストグラムを表示する。ヒストグラムを表示するにはCircosHistogramモジュールを使う。

histogramData <- histogramExample
Circos(moduleList=CircosHistogram('HISTOGRAM01', data = histogramData,
fillColor= "#ff7f0e",maxRadius = 210,minRadius = 175,
animationDisplay = TRUE),genome=list("2L"=23011544,"2R"=21146708,"3L"=24543557,"3R"= 27905053,"X"=22422827,"4"=1351857),
outerRadius = 220, width = 700,height = 550)
  • moduleList   Module list displayed in plot
  • fillColors   The filling color of the module
  • minRadius, maxRadius  The outer and inner ring range of module
  • animationDisplay   Whether display animation

animationDisplay = TRUEだと、図は動的な表示エフェクト(アニメーション)付きでレンダリングされる。

f:id:kazumaxneo:20210722221033p:plain

ヒストグラムに使っているhistogramExampleは以下のデータ

 f:id:kazumaxneo:20210723074614p:plain

染色体名、領域(開始、終了)、名前、値、を記載している。

 

例7、内側のリングにSNPsを表示するにはCircosSnpモジュールを使う。バックグラウンド(下の画像の水色背景部分)を表示するにはCircosBackgroundモジュールを使う。

snpData <- snpExample
Circos(moduleList=CircosSnp('SNP01', minRadius =150,
maxRadius = 190, data = snpExample,SNPFillColor= "#9ACD32",
circleSize= 2, SNPAxisColor= "#B8B8B8", SNPAxisWidth= 0.5,
animationDisplay=TRUE,animationTime= 2000, animationDelay= 0,
animationType= "linear") +
CircosBackground('BG01',minRadius = 145,maxRadius = 200),
width = 700,height = 550)
  • maxRadius, minRadius   Where the module should begin and end
  • animationTime, animationDelay, animationType   The time, delay and display type for animation

f:id:kazumaxneo:20210723074851p:plain

snpExample

f:id:kazumaxneo:20210723075000p:plain

染色体名、ポジション、値(例はおそらくコホートでの出現頻度)、ソースの種類を記載している。

 

例8、遺伝子、Exon、タンパク質などの関係を表示するにはCircosChordモジュールかCircosChord.pモジュールを使う。現在のバージョンでは、zoomをオンにするとリンクオブジェクトだけ拡大されずにズレてしまう。防止するため、zoom=FALSEとしている。

chordData=chord.pExample
Circos(moduleList=CircosChord.p('CHORD01', data = chordData,radius= 216,opacity=0.67,
color="black"), innerRadius = 217, outerRadius = 237,genomeLabelDisplay = TRUE,zoom=FALSE)

f:id:kazumaxneo:20210723085830p:plain

chord.pExample

f:id:kazumaxneo:20210723085146p:plain

リンク線を描くために、ソースの染色体名と領域、ターゲットの染色体名と領域を指定している。自分のデータを使う場合、例と同じように1行目は

source_chr source_start source_end target_chr target_start target_end

で始める。source_chr名とtarget_chr名はシンプルでないと認識しない可能性がある。例えば”chr”は正常に認識したが、”A.species_chr1”や”B.species_chr1”は部分的な文字列だけ認識した。

 

 

例9、CNVを示すにはCircosCnvモジュールを使う。

cnvData=cnvExample
Circos(moduleList=CircosCnv('Cnv01',maxRadius =175, minRadius =116,
data =cnvData,width=2,color = "#4876FF",animationDisplay = TRUE,
animationType = "linear",animationTime = 500)+
CircosBackground("bg01",minRadius = 116,maxRadius = 175,
fillColors = "#F2F2F2",axisShow = TRUE),CNVMouseOverDisplay = TRUE,
CNVMouseOverTooltipsSetting = "style1",CNVMouseOutDisplay = TRUE,
CNVMouseOutColor = NULL)
  • animationTime, animationDelay, animationType   The time, delay and display type for animation
  • CNVMouseOverDisplay   Default False, show/not the tooltip when mouse hover on a CNV point
  • CNVMouseOverTooltipsSetting   Default "style1"
  • CNVMouseOutDisplay   Defalut False, hide/not tooltip when mouse is not hovering a CNV point anymore
  • CNVMouseOutColor   Color when mouse moving out the element

アニメーションONだと、環に沿ってCNVの発生位置が動的に表示されていく。animationTypeにはlinear、bounceなどがある。animationDelayも追加すると、より長い時間にわたってアニメーションされる(例えばanimationDelay = 50)。

f:id:kazumaxneo:20210723090530p:plain

CNVMouseOverDisplay = ONだと、CNV上にマウスカーソルをホバーすることで注釈が表示される。CNVMouseOutDisplay = TRUEもつけておかないと、マウスカーソルがCNVから離れたあとも注釈が表示され続ける。CNVMouseOutColor = TRUEにすると、マウスカーソルがCNVから離れたあとも赤色が残る。

f:id:kazumaxneo:20210723091601p:plain

アニメーション終了後

f:id:kazumaxneo:20210723090728p:plain

 

例10、小さなゲノムのCircosプロットで、遺伝子を示すにはCircosGeneモジュールを使う。読み込む遺伝子情報はgeneExampleに書かれている。geneExampleについては下に画像を表示しているが、strand、start-end、type、nameなどが書かれている。

geneData=geneExample
Circos(moduleList=CircosGene('Gene01', outerRadius = 195, innerRadius = 180,
data=geneData,arrowGap = 10, arrowColor = "black",arrowSize = "12px",
cdsColor = "#1e77b3",cdsStrokeColor = "#1e77b3",cdsStrokeWidth= 0,
utrWidth= 0,utrColor= "#fe7f0e",utrStrokeColor= "#fe7f0e",
animationDisplay = TRUE),genome =list("EGFR"=1000),outerRadius = 220,
GENEMouseOverDisplay = TRUE,GENEMouseOverTooltipsSetting = "style1",
GENEMouseOutDisplay = TRUE,GENEMouseOutColor = NULL)

アニメーション表示される。

f:id:kazumaxneo:20210723092453p:plain

 

f:id:kazumaxneo:20210723092851p:plain

染色体名、featureの向き、スタート、エンド、遺伝子名、クリックした時のジャンプ先URL。1つの遺伝子を描画するには、1行目に遺伝子全長(上の写真では2行目、8行目、14行目)、2行目以降にUTRとCDSを記述する(上の写真では3-7行目が1つ目の遺伝子)。

 

マウスホバーすると、そのfeatureの注釈が表示される。下の写真は先頭の注釈を表示。

f:id:kazumaxneo:20210723093314p:plain

引用

interacCircos: an R package based on JavaScript libraries for the generation of interactive circos plots
Zhe Cui, Ya Cui, Tianyi Zang, Yadong Wang Author Notes
Bioinformatics, Published: 08 April 2021

 

関連論文