circos的安裝使用
參考資料
參考教程 http://www.reibang.com/p/741e77c94714
徐州更教程 http://www.reibang.com/u/9ea40b5f607a
circos https://www.bilibili.com/read/cv7812579/
全網(wǎng)最完整的circos中文教程
circos heatmap
circos color參考
安裝 circos
conda create -c bioconda -n circos circos
測試circos
conda activate circos
circos -V
軟件官網(wǎng)源碼和教程http://circos.ca/software/download/
顏色參考 https://colorbrewer2.org/#type=qualitative&scheme=Set3&n=12
注意:circos作圖時(shí)先紫,染色體一定要注意Chr1或Chr01格式老厌,格式前后一定要一致〉琳停基因名稱一定要一致垂攘,是'Sp01G000010.1' 還是'Sp01G000010'抖僵,后面的.1
有沒有一定要一致立倍,否則就會出錯(cuò)
制作滑動窗展示基因密度(需要安裝bedtools)
從gff3文件獲取基因的位置
grep '[[:blank:]]gene[[:blank:]]' Spohua.genome.gff3 | cut -f 1,4,5 | awk '{print $1"\t"$2"\t"$3}'|grep Chr > genes.bed
從基因組位置文件獲取滑動窗
cut -d ' ' -f 3,6 Spo.genome.txt | tr ' ' '\t' > Spo.genome
bedtools makewindows -g Spo.genome.txt -w 1000000 >Spo.windows #設(shè)置window為1M
Spo.genome.txt
是基因組染色體長度的文件
head Spo.genome.txt
Chr1 26663249
Chr2 25493351
Chr3 22916255
Chr4 22507087
Chr5 18661867
Chr6 19687438
Chr7 15147718
Chr8 14276932
Chr9 12412806
Chr10 12144945
可以使用下面的代碼來獲取沙热,
samtools faidx ${genome}
cat ${genome}.fai |cut -f 1-2| fgrep ${chr}|sort -V >${prefix}.genome.txt
獲取基因覆蓋率
bedtools coverage -a Spo.windows -b genes.bed | cut -f 1-4 > genes_num.txt
染色體配置文件
cat Spo.genome|awk '{print "chr - "$1" "$1" 0 "$2" "$1}' >karyotype.Spo.txt
獲取GC含量
bedtools nuc -fi Spo.genome.fa -bed Spo.windows |cut -f 1-3,5|sed '1d' >GC_content_num.txt
生成circos圖
circos -conf circos.conf
準(zhǔn)備可視化LTR的相關(guān)數(shù)據(jù)
###Copia類型的轉(zhuǎn)座子
cat Spohua.fa.pass.list|grep Copia |cut -f1|tr : "\t"|sed 's/\.\./\t/g' >spo.Copia.bed
###Gypsy類型的轉(zhuǎn)座子
cat Spohua.fa.pass.list|grep Gypsy |cut -f1|tr : "\t"|sed 's/\.\./\t/g' >spo.Gypsy.bed
###從gff3文件獲取基因的位置(基因密度)
grep '[[:blank:]]gene[[:blank:]]' Spohua.genome.gff3 | cut -f 1,4,5 | awk '{print $1"\t"$2"\t"$3}'|grep Chr > genes.bed
#制作滑動窗
bedtools makewindows -g Spo.genome.txt -w 1000000 >Spo.windows #設(shè)置window為1M
##獲取覆蓋率
bedtools coverage -a Spo.windows -b genes.bed |cut -f 1-4 >genes_num.txt
bedtools coverage -a Spo.windows -b spo.Copia.bed |cut -f 1-4 >Copia_num.txt
bedtools coverage -a Spo.windows -b spo.Gypsy.bed |cut -f 1-4 >Gypsy_num.txt
##準(zhǔn)備LAI的文件(windowssize為300kb)
cat Spohua.fa.out.LAI|cut -f 1,2,3,7 |sed '1,2d' >LAI_num.txt
###完整LTR的百分比(每個(gè)windowsize的完整LTR的百分比)
cat Spohua.fa.out.LAI|awk '{print $1"\t"$2"\t"$3"\t"$4*100}'|sed '1,2d' >full_LTR_num.txt
###所有LTR的百分比(每個(gè)windowsize的LTR的百分比)
cat Spohua.fa.out.LAI|awk '{print $1"\t"$2"\t"$3"\t"$5*100}'|sed '1,2d' >LTR_num.txt
##配置染色體文件
cut -d ' ' -f 3,6 Spo.genome.txt | tr ' ' '\t' > Spo.genome
cat Spo.genome|awk '{print "chr - "$1" "$1" 0 "$2" "$1}' >karyotype.Spo.txt
##準(zhǔn)備共線性文件
####需要預(yù)先準(zhǔn)備 cds,pep,bed 文件誊锭。參考[Jcvi的使用](http://www.reibang.com/p/37fed126777f)表悬。
#####一個(gè)物種內(nèi)部共線性需要準(zhǔn)備一套cds,蛋白pep,bed文件就可以了丧靡。
python -m jcvi.compara.catalog ortholog --dbtype prot --no_strip_names Spo Spo
#####從共線性的基因?qū)∧崛≌铣蒫ircos的bed格式。
cat Spo.Spo.anchors |grep -v \#| while read line;
do
gene_array=($line)
gene1_pos=`fgrep ${gene_array[0]} Spo.bed|cut -f 1-3`
gene2_pos=`fgrep ${gene_array[1]} Spo.bed|cut -f 1-3`
bed=${gene1_pos}" "${gene2_pos}
echo $bed >>Spo.coline_num.txt
done
###把染色體中的Chr0轉(zhuǎn)換成Chr.(所有的用于circos畫圖的染色體都需要改成Chr這種温治,否則饭庞,默認(rèn)的circos不會識別Chr01這種格式)
cat Spo.coline_num.txt |sed 's/Chr0/Chr/g' >coline_num.txt
circos的文件和環(huán)境配置
circos是基于perl實(shí)現(xiàn)的,只能用來畫圖熬荆,并不能處理數(shù)據(jù)舟山,所以數(shù)據(jù)需要先制作完成后,才能用circos畫。
配置文件列表
- karyotype.Spo.txt (染色體長度配置文件) *
- circos.conf (主要的conf文件累盗,畫圖時(shí)寒矿,通過此文件來調(diào)用其他配置文件)*
- ticks.conf (刻度控制文件)*
- coline_num.txt (共線性文件)
- GC_num.txt GC(含量文件)
- full_LTR_num.txt ( 完整LTR的百分比)
- Gypsy_num.txt (Gypsy的百分比)
- LTR_num.txt (所有LTR的百分比)
- Copia_num.txt(Copia的百分比)
- genes_num.txt (基因密度)
- LAI_num.txt(LAI的分布)
所有以_num.txt
結(jié)尾的都是畫圖的數(shù)據(jù)文件,可以根據(jù)實(shí)際需要靈活增刪若债。
標(biāo)*的是必須文件符相。其他是選配文件。
karyotype.Spo.txt文件內(nèi)容如下
chr - Chr1 Chr1 0 27519054 Chr1
chr - Chr2 Chr2 0 37982726 Chr2
chr - Chr3 Chr3 0 37451735 Chr3
chr - Chr4 Chr4 0 28204096 Chr4
chr - Chr5 Chr5 0 45635594 Chr5
chr - Chr6 Chr6 0 32349783 Chr6
chr - Chr7 Chr7 0 36685546 Chr7
chr - Chr8 Chr8 0 31371431 Chr8
chr - Chr9 Chr9 0 35059391 Chr9
chr - Chr10 Chr10 0 43700000 Chr10
chr - Chr11 Chr11 0 39651545 Chr11
chr - Chr12 Chr12 0 31915921 Chr12
chr - Chr13 Chr13 0 43197690 Chr13
chr - Chr14 Chr14 0 32136955 Chr14
chr - Chr15 Chr15 0 49422898 Chr15
chr - Chr16 Chr16 0 36480970 Chr16
chr - Chr17 Chr17 0 34479775 Chr17
ticks.conf文件內(nèi)容如下:
#刻度ticks配置文件
chromosomes_units = 1000000
show_ticks = yes
show_tick_labels = yes
<ticks>
radius = 1r
color = black
thickness = 2p
multiplier = 1e-6 #輸出的標(biāo)簽為實(shí)際長度與其相乘
format = %d # %d表示顯示整數(shù)
tick_separation = 3p #管理刻度和外圈之間的距離
label_separation = 10p
<tick>
spacing = 1u
size = 5p
</tick>
<tick>
spacing = 5u
size = 10p
show_label = yes
label_size = 10p
label_offset = 10p
format = %d
</tick>
</ticks>
head coline_num.txt
Chr1 2863127 2878319 Chr3 19253647 19258135
Chr1 3914355 3914748 Chr3 19905364 19905757
Chr1 3976083 3982656 Chr3 21062604 21067133
Chr1 4195280 4197605 Chr3 20801492 20805443
cat circos.conf
#首尾染色體之間有間隔,添加了共線性蠢琳,同時(shí)調(diào)整了半徑
karyotype = karyotype.Spo.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 #定義染色體的顏色,染色體名稱是karyotype.Spo.txt中第3列的名稱Chr1-17
<<include ticks.conf>> #引入自定義的刻度配置文件啊终,目錄是相對路徑
##共線性圖
<links>
<link>
file = coline_num.txt #共線性文件
radius = 0.40r #外圈半徑
color = blue_a4 #默認(rèn)顏色
thickness = 1p #定義線條的粗細(xì)
ribbon = yes
######rules指定線條的顏色,
<rules>
<rule>
condition = var(chr1) eq "Chr1" #共線性文件中傲须,左邊是Chr1的蓝牲,指定顏色。var(chr1)這個(gè)不用修改泰讽,指的是file里左側(cè)第一個(gè)例衍,后面的“Chr1”根據(jù)實(shí)際的Chr來修改。
color = rdylgn-11-div-1
</rule>
<rule>
condition = var(chr1) eq "Chr2"
color = rdylgn-11-div-2
</rule>
<rule>
condition = var(chr1) eq "Chr3"
color = rdylgn-11-div-3
</rule>
<rule>
condition = var(chr1) eq "Chr4"
color = rdylgn-11-div-4
</rule>
<rule>
condition = var(chr1) eq "Chr5"
color = rdylgn-11-div-5
</rule>
<rule>
condition = var(chr1) eq "Chr6"
color = rdylgn-11-div-6
</rule>
<rule>
condition = var(chr1) eq "Chr7"
color = rdylgn-11-div-7
</rule>
<rule>
condition = var(chr1) eq "Chr8"
color = rdylgn-11-div-8
</rule>
<rule>
condition = var(chr1) eq "Chr9"
color = rdylgn-11-div-9
</rule>
<rule>
condition = var(chr1) eq "Chr10"
color = rdylgn-11-div-10
</rule>
<rule>
condition = var(chr1) eq "Chr11"
color = rdylgn-11-div-11
</rule>
<rule>
condition = var(chr1) eq "Chr12"
color = rdylbu-9-div-1
</rule>
<rule>
condition = var(chr1) eq "Chr13"
color = rdylbu-9-div-2
</rule>
<rule>
condition = var(chr1) eq "Chr14"
color = rdylbu-9-div-3
</rule>
<rule>
condition = var(chr1) eq "Chr15"
color = rdylbu-9-div-4
</rule>
<rule>
condition = var(chr1) eq "Chr16"
color = rdylbu-9-div-5
</rule>
<rule>
condition = var(chr1) eq "Chr17"
color = rdylbu-9-div-6
</rule>
</rules>
</link>
</links>
<plots>
#完整的LTR的百分比直方圖
<plot>
type = histogram
file = full_LTR_num.txt
fill_color = 231,41,138 # 填充色
r1 = 0.50r
r0 = 0.41r
</plot>
#LTR的百分比直方圖
<plot>
type = histogram
file = LTR_num.txt
fill_color = 254,196,79 # 填充色
r1 = 0.60r
r0 = 0.51r
</plot>
#Gypsy的熱圖
<plot>
type = heatmap
file = Gypsy_num.txt
color = oranges-9-seq #填充色必須是一個(gè)list已卸,格式是 color = reds-9-seq 或者color = red,green,blue
r1 = 0.70r
r0 = 0.61r
</plot>
#Copia的熱圖
<plot>
type = heatmap
file = Copia_num.txt
color = reds-9-seq #填充色
r1 = 0.80r
r0 = 0.71r
</plot>
##LAI的散點(diǎn)圖 參考https://blog.csdn.net/weixin_43569478/article/details/83824929
<plot>
type = scatter #散點(diǎn)圖
fill_color = grey # 點(diǎn)的填充色
stroke_color = black #邊框的顏色
glyph = circle
glyph_size = 3 # 元素大小
file = LAI_num.txt
r1 = 0.90r
r0 = 0.81r
#劃分3個(gè)區(qū)間肄渗,每個(gè)區(qū)間不同的顏色。用于LAI的劃分
<backgrounds>
<background>
color = vvlgreen
y0 = 20
</background>
<background>
color = vlgrey
y1 = 20
y0 = 10
</background>
<background>
color = vvlred
y0 =10
</background>
</backgrounds>
##設(shè)置y軸刻度線
<axes>
<axis>
color = lgreen
thickness = 1p
spacing = 0.05r
y1 = 20
y0 = 10
</axis>
</axes>
</plot>
##基因密度直方圖
<plot>
type = histogram
file = genes_num.txt
fill_color = blue # 填充色
r1 = 0.99r
r0 = 0.91r
</plot>
</plots>
<ideogram>
<spacing>
default = 0.005r
#設(shè)置染色體之間空出個(gè)距離咬最,用來標(biāo)圖例a,b,c,d,e,f
<pairwise Chr17;Chr1> #染色體名稱是karyotype.Spo.txt中第3列的名稱翎嫡,根據(jù)你實(shí)際的物種第一條和最后一條來修改此處
spacing = 5r #設(shè)置第一個(gè)和最后一個(gè)染色體中間空出5*default(0.005r)的距離
</pairwise>
</spacing>
radius = 0.85r #指定畫圖的半徑(此半徑和plots里的半徑不一致,這個(gè)是總的0.85r永乌,決定了整個(gè)圈圖的最大的半徑,plots里的0.99r半徑是以這個(gè)0.85r作為100%來分配99%)
thickness = 10p #坐標(biāo)軸的染色體的厚度
fill = yes
show_bands = yes #設(shè)置染色體條帶填充惑申,如果不想用條帶填充,只用顏色翅雏,就設(shè)置為no
fill_bands = yes
stroke_color = dgrey
stroke_thickness = 2p
show_label = yes #展示label
label_font = default # 字體
label_radius = dims(ideogram,radius) + 0.075r #位置
label_size = 12 # 字體大小
label_parallel = yes # 是否平行
label_format = eval(sprintf("%s",var(chr))) # 格式
</ideogram>
<image>
# 覆蓋在 etc/image.conf 中定義的 angle_offset
angle_offset* = -82 #指定旋轉(zhuǎn)角度圈驼,用于插入圖例的位置
dir* = . #輸出文件夾
radius* = 500p #圖片半徑
svg* = yes #是否輸出svg,默認(rèn)是yes
<<include etc/image.conf>>
</image>
<<include etc/colors_fonts_patterns.conf>>
<<include etc/housekeeping.conf>>
head GC_num.txt
Chr1 0 1000000 38.8549
Chr1 1000000 2000000 38.1306
Chr1 2000000 3000000 37.9843
Chr1 3000000 4000000 37.4317
Chr1 4000000 5000000 37.967
Chr1 5000000 6000000 37.9894
circos可能會出現(xiàn)的報(bào)錯(cuò)
There was a problem with True Type font support. Circos could not render text
from the font file
/share/home/miniconda3/envs/circos/bin/../fonts/modern/cmunrm.otf
Please check that gd (system graphics library) and GD (Perl's interface to gd)
are compiled with True Type support.
這種需要重新安裝libGD和GD
wget https://github.com/libgd/libgd/releases/download/gd-2.3.1/libgd-2.3.1.tar.gz
tar zxvf libgd-2.3.1.tar.gz
cd libgd-2.3.1
./configure
curl -O http://www.ijg.org/files/jpegsrc.v8d.tar.gz
tar -xzvf jpegsrc.v8d.tar.gz
cd jpeg-8d
./configure --prefix=/path/to/jpeg-8d
make
make install
#安裝libpng
curl -O ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng16/libpng-1.6.2.tar.gz
tar -xzvf libpng-1.6.2.tar.gz
cd libpng-1.6.2.tar.gz
./configure --prefix=/path/to/jpeg-8d
make -j8
make install
#重新安裝GD(使用cpanm安裝)
cpanm -f GD
可能會提示缺少perl模塊
circos -modules
檢測是否缺少perl模塊
cpanm GD
#安裝缺少的GD模塊