通常circos的中间部分不是空白区域,会用一条条线进行连接,表示两个染色体部分区域有关系。
对于link,circos要求输入数据至少有6列,分别是chr1 start1 end1 chr2 start2 end2 [options]
举个例子
chr1 1000000 2000000 chr5 3000000 4000000
构建输入
这次会以A. lyrata 和 A.thalina的基因组为例,利用JCVI来构建Circos的输入.
数据下载:
# Athaliana
wget ftp://ftp.ensemblgenomes.org/pub/plants/release-44/fasta/arabidopsis_thaliana/cds/Arabidopsis_thaliana.TAIR10.cds.all.fa.gz
wget ftp://ftp.ensemblgenomes.org/pub/plants/release-44/gff3/arabidopsis_thaliana/Arabidopsis_thaliana.TAIR10.44.gff3.gz
# Alyrata
wget ftp://ftp.ensemblgenomes.org/pub/plants/release-44/fasta/arabidopsis_lyrata/cds/Arabidopsis_lyrata.v.1.0.cds.all.fa.gz
wget ftp://ftp.ensemblgenomes.org/pub/plants/release-44/gff3/arabidopsis_lyrata/Arabidopsis_lyrata.v.1.0.44.gff3.gz
数据预处理
将GFF3转成BED格式
python -m jcvi.formats.gff bed --type=mRNA --key=transcript_id Arabidopsis_thaliana.TAIR10.44.gff3.gz > ath.bed
python -m jcvi.formats.gff bed --type=mRNA --key=transcript_id Arabidopsis_lyrata.v.1.0.44.gff3.gz > aly.bed
将BED去重复
python -m jcvi.formats.bed uniq ath.bed
python -m jcvi.formats.bed uniq aly.bed
提取CDS序列
seqkit grep -f <(cut -f 4 ath.bed ) Athaliana_167_TAIR10.cds.fa.gz | seqkit seq -i > ath.cds
seqkit grep -f <(cut -f 4 aly.bed ) Arabidopsis_lyrata.v.1.0.cds.all.fa.gz | seqkit seq -i > aly.cds
karyotype
从ENSEMBLE下载的GFF文件中,已经包含了每个基因组的大小, 当然也可以各种工具从基因组序列序列中获取大小。
1.aly的核型文件
chr - aly1 aly1 0 33132539 rdylbu-11-div-1
chr - aly2 aly2 0 19320864 rdylbu-11-div-2
chr - aly3 aly3 0 24464547 rdylbu-11-div-3
chr - aly4 aly4 0 23328337 rdylbu-11-div-4
chr - aly5 aly5 0 21221946 rdylbu-11-div-5
chr - aly6 aly6 0 25113588 rdylbu-11-div-6
chr - aly7 aly7 0 24649197 rdylbu-11-div-7
chr - aly8 aly8 0 22951293 rdylbu-11-div-8
2.ath的核型文件
chr - ath1 ath1 0 30427671 brbg-10-div-1
chr - ath2 ath2 0 19698289 brbg-10-div-3
chr - ath3 ath3 0 23459830 brbg-10-div-5
chr - ath4 ath4 0 18585056 brbg-10-div-7
chr - ath5 ath5 0 26975502 brbg-10-div-9
因为ENSMEBLE上Athalina和Alyrata的染色体命名都是1,2,3…,就会导致CIRCOS无法正确的区分来源,因此在原本的命名前加上了物种名缩写做为标签。
同时。我们要修改之前的bed文件
sed -e 's/^/ath/' ath.uniq.bed > ath.bed
sed -e 's/^/aly/' aly.uniq.bed > aly.bed
links
为了构建links文件,需要利用JCVI进行共线性分析
aly.bed aly.cds ath.bed ath.cds
用jcvi进行分析
python -m jcvi.compara.catalog ortholog --no_strip_names ath aly
python -m jcvi.compara.synteny screen --minspan=30 --simple ath.aly.anchors ath.aly.anchors.new
安装lastal
运行上面一步需要安装一个lastal软件
地址
cd last-1047/src
make
然后将src目录下的lastal与lastdb添加到环境中
其中ath.aly.anchors.simple是我们后续要用到的文件。
$head -n 1 ath.aly.anchors.simple
AT1G24260.1 AT1G27280.1 fgenesh1_pm.C_scaffold_1002045 fgenesh2_kg.1__2877__AT1G24260.1 225 -
我们需要将ath.aly.anchors.simple里的基因名替换成实际的位置信息,将其变成符合Circos的输入信息。
hoptop写了一个simple2links.py脚本,代码在他的GitHub上,https://github.com/xuzhougeng/myscripts。
python ~/myscripts/simple2links.py ath.aly.anchors.simple
最终会输出ath.aly.anchors.simple_link.txt
1. 配置circos
karyotype=karyotype.tair10.txt,karyotype.aly.txt
chromosomes_color = chr1=rdylbu-11-div-1,chr2=rdylbu-11-div-3,chr3=rdylbu-11-div-5,chr4=rdylbu-11-div-7,chr5=rdylbu-11-div-9
chromosomes_units = 100000
<ideogram>
<spacing>
default = 0.005r
</spacing>
radius = 0.80r
thickness = 6p
fill = yes
stroke_color = dgrey
stroke_thickness = 2p
show_label = yes
label_font = default
label_radius = dims(ideogram,radius) + 0.05r
label_size = 48
label_parallel = yes
label_fromat = eval(sprintf("%s",var(chr)))
</ideogram>
<links>
<link>
file = ath.aly.anchors.simple_link.txt
radius = 0.61r
color = red
ribbon = yes
</link>
</links>
show_ticks = yes
show_tick_labels = yes
<ticks>
radius = 1r
color = black
thickness = 2p
multiplier = 1e-6
<tick>
spacing = 5u
size = 10p
</tick>
<tick>
color = black
thickness = 4p
spacing = 5u
size = 10p
show_label = yes
label_size = 10p
label_offset = 10p
format = %d
</tick>
</ticks>
<image>
dir* = .
radius* = 500p
<<include etc/image.conf>>
</image>
<<include etc/colors_fonts_patterns.conf>>
<<include etc/housekeeping.conf>>
要是你是conda安装的,你就可以到安装这个软件的conda环境下的etc文件夹下建立一个links.conf用来配置links, 建立一个ticks.conf配置ticks
2.1links.conf
<links>
<link>
file = ath.aly.anchors.simple_link.txt
radius = 0.61r
color = red
ribbon = yes
</link>
2.2 ticks.conf
show_ticks = yes
show_tick_labels = yes
<ticks>
radius = 1r
color = black
thickness = 2p
multiplier = 1e-6
format = %d
<tick>
spacing = 1u
size = 5p
</tick>
<tick>
thickness = 4p
spacing = 5u
size = 10p
show_label = yes
label_size = 10p
label_offset = 10p
format = %d
</tick>
</ticks>
2.3 circos.conf
karyotype = karyotype.tair10.txt,karyotype.aly.txt
chromosomes_color = chr1=rdylbu-11-div-1,chr2=rdylbu-11-div-3,chr3=rdylbu-11-div-5,chr4=rdylbu-11-div-7,chr5=rdylbu-11-div-9
chromosomes_units = 1000000
<<include etc/ticks.conf>>
<ideogram>
<spacing>
default = 0.005r
</spacing>
radius = 0.90r
thickness = 20p
fill = yes
stroke_color = dgrey
stroke_thickness = 2p
show_label = yes #展示label
label_font = default # 字体
label_radius = dims(ideogram,radius) + 0.08r #位置
label_size = 16 # 字体大小
label_parallel = yes # 是否平行
label_format = eval(sprintf("%s",var(chr))) # 格式
</ideogram>
<<include etc/links.conf>>
<image>
dir* = . # 输出文件夹
radius* = 500p # 图片半径
svg* = no # 是否输出svg
<<include etc/image.conf>>
</image>
<<include etc/colors_fonts_patterns.conf>>
<<include etc/housekeeping.conf>>
运行结果
这里会发现一个问题,里面线的颜色一模一样,不容易进行区分。虽然可以在输入ath.aly.anchors.simple_link.txt里增加颜色,但是circos提供了一个动态规则,可以更加方便的直接在配置文件里修改。
建立规则(rules)
circos的配置格式为
<rules>
<rule>
...
</rule>
<rule>
...
</rule>
...
</rules>
circos的规则可以很复杂,但是最简单的情况就是下面这种。
<rule>
condition = var(chr1) eq "ath1"
color=rdylgn-5-div-1
</rule>
condition = var(chr1) eq "ath1"表示,判断link文件中左侧染色体的名字(var(chr1))是不是(eq)"ath1",如果是的话,那么颜色就是rdylgn-5-div-1
我们可以在etc/links.conf中增加五个条件,修改后的links.conf如下
<link>
file = ath.aly.anchors.simple_link.txt
radius = 0.61r
color = blue_a4
ribbon = yes
<rules>
<rule>
condition = var(chr1) eq "ath1"
color=rdylgn-5-div-1
</rule>
<rule>
condition = var(chr1) eq "ath2"
color=rdylgn-5-div-2
</rule>
<rule>
condition = var(chr1) eq "ath3"
color=rdylgn-5-div-3
</rule>
<rule>
condition = var(chr1) eq "ath4"
color=rdylgn-5-div-4
</rule>
<rule>
condition = var(chr1) eq "ath5"
color=rdylgn-5-div-5
</rule>
</rules>
</link>
</links>
运行结果
调整外圈和links的半径大小
最后就是各种美化。
比如把外面的laels往外在移一点
参考
https://www.jianshu.com/p/09565814a273
https://www.jianshu.com/p/1658e702ba17