前言
最近進行基因組數(shù)據(jù)分析,繪制圈圖,想做兩個基因組的比較分析,通過查詢文獻,發(fā)現(xiàn)棉花基因組圈圖在細節(jié)方面做的較好,主要就是染色體排布中間對稱,這樣共線性連線就不會出現(xiàn)交叉現(xiàn)象,于是嘗試從頭開始利用circos繪制圈圖。通過不斷調(diào)整,成品如下:

1. 軟件安裝:
conda install -c bioconda circos
可能會出現(xiàn)報錯:GD模塊沒有安裝,可以直接下載GD模塊,手動安裝。
2. 文件準備
安裝好Circos以后,就可以進行繪圖,首先創(chuàng)建一個文件夾,在文件夾中準備相關(guān)配置文件:
1.circos.conf
2.ideogram.conf
3.ideogram.label.conf
4.ideogram.position.conf
5.bands.conf
6.ticks.conf
另外,在當前文件夾在創(chuàng)建一個文件夾data,存放自己準備的數(shù)據(jù)文件,例如我的圈圖準備畫8層:
1.karyotype
2.Genedensity
3.GC_content
4.Expression1
5.Expression2
6.Expression3
7.Copia/Gypsy
8.link
準備好以上文件(文件基本格式:chr start end value,共4列\(zhòng)t隔開),運行以下命令即可輸出圖片circos.png和circos.svg:
circos -conf circos.conf
接下來詳細介紹文件的準備
3. 配置文件:circos.conf
circos.conf是circos的主要配置文件,畫圖也是通過命令:circos -conf circos.conf來完成,但circos.conf引用了文件夾中其他配置文件,如:ideogram.conf,bands.conf等,另外還有安裝文件etc中的一些配置文件(conda安裝的位置:~/.conda/pkgs/circos-0.69.8-hdfd78af_1/etc/),如:housekeeping.conf,image.generic.conf等。
circos.conf文件格式:
show_scatter = yes
show_line = yes
show_histogram = yes
show_heatmap = yes
show_tile = yes
show_highlight = yes
use_rules = yes
<<include colors_fonts_patterns.conf>> #<<>>表示引用的其他配置文件,在當前文件和系統(tǒng)的etc文件中查找
<<include ideogram.conf>>
<<include ticks.conf>>
<<include etc/housekeeping.conf>>
<<include etc/image.conf>>
karyotype = data/1.karyotype
#1.karyotype為染色體信息文件,格式如下:
#chr - a1 a.Chr01 0 23931628 chr1
#chr - a2 a.Chr02 0 56312238 chr2
#chr - a3 a.Chr03 0 61034414 chr3
chromosomes_units = 2000000 #染色體的單位2M,如果是一個染色體可以設(shè)置為1M
#chromosomes_reverse = /b[1-18]/
chromosomes_reverse = b1,b2,b3... #設(shè)置染色體方向
chromosomes_order = a1,a2,...a18,b18,....b2,b1#設(shè)置染色體排列順序,物種a:1-18,物種b:18-1,同時物種b通過chromosomes_reverse設(shè)置為染色體反向,這樣保證了中間對稱,更美觀,
<links> #<links> 和</links>之間的部分是進行l(wèi)ink的設(shè)置,格式和html相似
z = 0
radius = 0.39r #繪圖半徑0.39r
thickness = 1p #設(shè)置連線粗細
<link>
z = 50
color = grey #總體設(shè)置連線顏色,后面<rule>可以重新設(shè)置
thichness = 4
file = data/8.link #讀取文件
#link文件格式:
#a1 6343321 6346963 b1 7987463 7991529
#a1 7081344 7082400 b1 8185204 8186260
#a1 7113128 7114630 b1 8217069 8218575
<rules>#個性化設(shè)置
<rule>
condition = var(chr1) eq "a1" #對染色體a1進行設(shè)置
color = 154,103,2 #對染色體a1顏色進行設(shè)置
</rule>
<rule>#<rule>到</rule>為一個設(shè)置單元
condition = var(chr1) eq "a2" #對染色體a1顏色進行設(shè)置
color = 102,102,0
</rule>
...
</rules>
</link>
</links>
#以上<links>到</links>是對中心link區(qū)域的設(shè)置,以下<plots>到</plots>是對其他層畫圖設(shè)置
<plots>
<plot>#<plot><plot>是對其中一層的畫圖設(shè)置,其他層類似設(shè)置
type = histogram #畫圖類型為柱狀圖
color = 190,166,46 #顏色
file = data/3.GC_content #讀取文件
#文件格式,窗口為1M
#a5 1 1000000 0.0396
#a5 1000001 2000000 0.0435
#a5 2000001 3000000 0.0288
fill_color = 190,166,46#填充顏色
r0 = 0.40r #圖層位置0.40r到 0.40r+100p之間
r1 = 0.40r+100p
orientation = out #朝向外
min = 0#顯示最大最小值設(shè)置
max = 0.1
<backgrounds>
<background>#背景色設(shè)置
color = 241,239,239
</background>
</backgrounds>
</plot>
...#其他圖層參考上面設(shè)置
<\plots>
注:以上是circos.conf文件設(shè)置,最重要,也是相對較為復(fù)雜的一個文件
4. 配置文件:ideogram.conf
以下是染色體配置文件:
<ideogram>
<spacing>
default = 0.005r#染色體之間間隔距離
<pairwise a1;b1>#設(shè)置其中兩個染色體之間距離
spacing = 6r #在圖形上面留下空白區(qū)域
</pairwise>
<pairwise a18;b18>
spacing = 6r#在圖形下面對稱留下空白區(qū)域
</pairwise>
</spacing>
<<include ideogram.position.conf>>
<<include ideogram.label.conf>>
<<include bands.conf>>
radius* = 0.825r
</ideogram>
5. 配置文件:ideogram.label.conf
染色體標簽設(shè)置:
show_label = yes
label_font = bold#設(shè)置為黑體
label_radius = 1.075r#位置
label_size = 28#字體大小
label_parallel = yes #與圓相切
label_format = eval(sprintf("%s",var(label))) #標簽格式為文本格式
6. 配置文件:ideogram.position.conf
染色體位置文件:
radius = 0.90r
thickness = 20p
fill = yes
fill_color = dgrey
stroke_thickness = 2p
troke_thickness = 0
7. 配置文件:bands.conf
show_bands = yes
fill_bands = yes
band_stroke_thickness = 2
band_stroke_color = white
band_transparency = 0
8. 配置文件:ticks.conf
對染色體刻度和刻度標簽進行設(shè)置:
show_ticks = yes
show_tick_labels = yes
<ticks>
radius = dims(ideogram,radius_outer)
orientation = out
label_multiplier = 1e-6
color = black
size = 20p
thickness = 2p
label_offset = 4p
format = %d
<tick>
spacing = 1u
show_label = no
size = 10p
</tick>
<tick>
spacing = 5u
show_label = no
label_size = 20p
size = 15p
</tick>
<tick>
spacing = 10u
show_label = yes
label_size = 24p
</tick>
</ticks>
9. 配置文件:housekeeping.conf和image.generic.conf
配置文件housekeeping.conf和image.generic.conf,位于安裝文件的etc文件中,一般不需要修改,有時候卻可以修改,如:
(1). 在畫圖的時候如果一個文件的比如基因密度或GC含量,需要畫圖的位點超過25000個的時候就會報錯,但我們可以在housekeeping.conf文件中,找到max_links,max_points_per_track的位置根據(jù)自己的情況進行修改:
max_links = 25000
max_points_per_track = 25000
(2). 在默認條件下繪制的第一個染色體的位置是從3點鐘的位置開始,如果想調(diào)整起始位置,可以調(diào)整image.generic.conf文件中的參數(shù),如angle_offset = -90 ,這時第一個染色體的位置是從12點鐘的位置開始,如果我們想在上方留出空白區(qū)域可以設(shè)置:angle_offset = -85.