Circos作图
写在前面
当矩形图无法满足要求的时候,我们就要掰弯它。
circos图是出现在各大期刊上的概率大大提高了,这不仅仅因为它好看,其次Circos还能同时展示出不能类型的数据。
一、Circos的安装
- 1、conda安装
通过conda search circos,我们可以看到有很多个circos版本,因此我们无论安装哪个版本都是可以的。conda软件的安装在前面的文章中已经具体讲解。
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-iGohKlon-44)(https://imgkr2.cn-bj.ufileos.com/13041b23-4872-46bb-b8f7-bc28e7dc4ae1.png?UCloudPublicKey=TOKEN_8d8b72be-579a-4e83-bfd0-5f6ce1546f13&Signature=b%252FXbhaBf2coOueKmrxMalh%252BvNJw%253D&Expires=)]
conda create -n circos
conda activate circos
conda install -y circos
- 2、源码安装
wget http://circos.ca/distribution/circos-0.69-8.tgz
tar -zxvf circos-0.69-8.tgz
安装完成后添加到环境变量中就可以了。
由于源码安装需要自己去安装Circos软件所需要的perl模块,因此在使用软件前需要检查所需的模块的是否安装成功。
circos -modules
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-uKxThtBS-46)(https://imgkr2.cn-bj.ufileos.com/6435dacf-4720-485d-b35e-2831cb0b1c9d.png?UCloudPublicKey=TOKEN_8d8b72be-579a-4e83-bfd0-5f6ce1546f13&Signature=UvMtGKbVim4xTsn7BjrEAtllCc4%253D&Expires=)]
二、Circos画图
- 1、准备配置文件
(1)最外圈染色体文件
#chr - 染色体名字 circos染色体名字 染色体开始位置 染色体终止位置 颜色 chr - Supercontig_1 1 0 chr1 chr - Supercontig_2 2 0 chr2 chr - Supercontig_3 3 0 chr3 chr - Supercontig_4 4 0 chr4 chr - Supercontig_5 5 0 chr5
(2)内圈配置文件
绘制直方图
<plot> # 设定为直方图 type = histogram # 用于画直方图的数据文件路径。该文件需要编写程序生成。 # 数据文件为4列: # chromosome start end data # Supercontig_1 0 9999 0.489 file = gc.histogram.txt # 设置直方图的位置,r1 要比 r0 大。直方图的方向默认为向外。 r1 = 0.95r r0 = 0.80r # 直方图的填充颜色 #fill_color = vlgrey color = red # 默认下直方图轮廓厚度为 1px,若不需要轮廓,则设置其厚度为0,或在 etc/tracks/histogram.conf 中修改。 thickness = 6p # 直方图是由 bins (条行框)所构成的。若 bins 在坐标上不相连,最好设置不要将其bins连接到一起。例如: # hs1 10 20 0.5 # hs1 30 40 0.25 # 上述数据设置值为 yes 和 no 时,图形是不一样的。 extend_bin = no # 设置坐标轴的最大值和最小值 max = 1 min = 0 # 设定直方图的背景颜色 <backgrounds> show = data <background> color = vvlgrey </background> </backgrounds> </plot>
绘制 热图
<plot> # 绘制 heat map type = heatmap # 指定热图的数据文件路径。该文件需要编写程序生成。 # 数据文件为5列: # chrID start end data class # Supercontig_1 1151 2878 32.62 id=Nc000 # Supercontig_1 1151 2878 63.02 id=Nc015 # Supercontig_1 1151 2878 165.36 id=Nc060 # Supercontig_1 1151 2878 125.84 id=Nc120 # Supercontig_1 1151 2878 34.58 id=Nc240 file = gene_expression.heatmap.txt # 设定图形所处位置 r1 = 0.75r r0 = 0.69r # 设定数据显示的规则。以下规则表示,FPKM值在 0, 10, 100等区间使用4种不同的颜色表示。 <rules> # 以下可以设置多个 rules <rule> # 条件判断,每个 rule 都有一个condition参数;如果该condition为真,则不对数据进行展示。 condition = var(id) ne "Nc000" show = no # 若flow参数值为continue,则继续往下执行。 flow = continue </rule> <rule> condition = var(value) <= 0 color = black </rule> <rule> condition = var(value) < 10 color = green </rule> <rule> condition = var(value) < 100 color = yellow </rule> <rule> condition = var(value) >= 100 color = red </rule> </rules> </plot> <plot> type = heatmap file = gene_expression.heatmap.txt r1 = 0.68r r0 = 0.62r <rules> <rule> condition = var(id) ne "Nc015" show = no flow = continue </rule> <rule> condition = var(value) <= 0 color = black </rule> <rule> condition = var(value) < 10 color = green </rule> <rule> condition = var(value) < 100 color = yellow </rule> <rule> condition = var(value) >= 100 color = red </rule> </rules> </plot> <plot> type = heatmap file = gene_expression.heatmap.txt r1 = 0.61r r0 = 0.55r <rules> <rule> condition = var(id) ne "Nc060" show = no flow = continue </rule> <rule> condition = var(value) <= 0 color = black </rule> <rule> condition = var(value) < 10 color = green </rule> <rule> condition = var(value) < 100 color = yellow </rule> <rule> condition = var(value) >= 100 color = red </rule> </rules> </plot> <plot> type = heatmap file = gene_expression.heatmap.txt r1 = 0.54r r0 = 0.48r <rules> <rule> condition = var(id) ne "Nc120" show = no flow = continue </rule> <rule> condition = var(value) <= 0 color = black </rule> <rule> condition = var(value) < 10 color = green </rule> <rule> condition = var(value) < 100 color = yellow </rule> <rule> condition = var(value) >= 100 color = red </rule> </rules> </plot> <plot> type = heatmap file = gene_expression.heatmap.txt r1 = 0.47r r0 = 0.41r <rules> <rule> condition = var(id) ne "Nc240" show = no flow = continue </rule> <rule> condition = var(value) <= 0 color = black </rule> <rule> condition = var(value) < 10 color = green </rule> <rule> condition = var(value) < 100 color = yellow </rule> <rule> condition = var(value) >= 100 color = red </rule> </rules> </plot>
绘制线性关系
<links> <link> # 指定 link 文件的路径 file = similarity_1000.links.txt # chr1 start1 end1 chr2 start2 end2 #Supercontig_1 Supercontig_1 #Supercontig_1 Supercontig_1 #Supercontig_1 Supercontig_1 #Supercontig_1 Supercontig_1 #Supercontig_1 Supercontig_7 49410 50742 #Supercontig_2 Supercontig_6 #Supercontig_2 Supercontig_7 radius = 0.36r # 设置贝塞尔曲线半径,该值设大后曲线扁平,使图像不太好看。 bezier_radius = 0r # 设置 link 曲线的颜色 color = black_a4 # 设置 link 曲线的厚度 thickness = 6 </link> <link> file = similarity_3000.links.txt radius = 0.36r bezier_radius = 0r color = orange thickness = 18 </link> </links>
(3)软件的配置文件(字体、刻度线、内圈展示的图形类型等)
ideogram.conf
<ideogram> <spacing> # 设置圈图中染色体之间的空隙大小,以下设置为每个空隙大小为周长的 0.5% default = 0.002r # default = 20u # 也可以设置指定两条染色体之间的空隙 <pairwise Supercontig_1;Supercontig_7> # 以下设定为两条染色体之间的空隙约为圆的 20 度角。 spacing = 10r </pairwise> </spacing> # 设定 ideograms # 设定 ideograms 的位置,以下设定 ideograms 在图离圆心的 90% 处 radius = 0.80r # 设定 ideograms 的厚度,可以使用 r(比例关系) 或 p(像素)作为单位 thickness = 80p # 设定 ideograms 是否填充颜色。填充的颜色取决于 karyotype 指定的文件的最后一列。 fill = yes # 设定 ideograms 轮廓的颜色及其厚度。如果没有该参数或设定其厚度为0,则表示没有轮廓。 stroke_color = dgrey stroke_thickness = 2p 设定 label 的显示 # 设定是否显示 label 。 label 对应着 karyotype 文件的第 4 列。如果其值为 yes,则必须要有 label_radius 参数来设定 label 的位置,否则会报错并不能生成结 show_label = yes # 设定 label 的字体 label_font = default # 设定 label 的位置 label_radius = 1r+160p # 设定 label 的字体大小 label_size = 100 # 设定 label 的字体方向,yes 是易于浏览的方向。 label_parallel = no # 显示 bands 信息 show_bands = yes # 对 bands 部分进行颜色填充 fill_bands = yes # 设定 bands 廓的厚度、颜色和透明度 band_stroke_thickness = 0 band_stroke_color = black band_transparency = 1 </ideogram>
ticks.conf
# 是否显示 ticks show_ticks = yes # 是否显示 ticks 的 lables show_tick_labels = yes 设定 ticks <ticks> # ticks 的设置 # 设定 ticks 的位置 radius = 1r # 设定 ticks 的颜色 color = black # 设定 ticks 的厚度 thickness = 2p # 设定 ticks label 的值的计算。将该刻度对应位置的值 * multiplier 得到能展示到圈图上的 label 值。 multiplier = 1e-6 # label 值的格式化方法。%d 表示结果为整数;%f 结果为浮点数; %.1f 结果为小数点后保留1位; %.2f 结果为小数点后保留2位。 format = %d # 以下设置了 2 个 ticks,前者是小刻度,后者是大刻度。 <tick> # 设置每个刻度代表的长度。若其单位为 u,则必须要设置 chromosomes_units 参数。比如设置 chromosomes_units = ,则如下 5u 表示每个刻度代表 5M 长度的基因组序列。 spacing = 5u # 设置 tick 的长度 size = 20p </tick> <tick> spacing = 20u size = 50p # 由于设置的是大刻度,以下用于设置展示 ticks label。 show_label = yes # 设置 ticks label 的字体大小 label_size = 50p # 设置 ticks label 离 ticks 的距离 label_offset = 10p format = %d </tick> </ticks>
circos.conf
# 指定染色体组型的文件,该文件为 karyotype = karyotype.txt # 设置长度单位,以下设置表示 1M 长度的序列代表为 1u。 chromosomes_units = # 默认设置下是将 karyotype 文件中所有的染色体都展示出来。当然,也可能根据需要仅展示指定的 chromosomes, 使用如下的参数进行设置。 #chromosomes_display_default = no chromosomes_display_default = no # 以下参数设置指定的 chromosomes 用于展示到圈图中。// 中是一个正则表达式,匹配的 chromosomes 用于展示到圈图中。其匹配的对象是 karyotype 文件中的第 3 列。也可以直接列出需要展示的 chromosomes, 例如:hs1;hs2;hs3;hs4 。 #chromosomes = LE01Scaffold0001;LE01Scaffold0002;LE01Scaffold0003 #chromosomes = /hs[1-4]$/ # chromosomes = hs1;hs2;hs3;hs4 chromosomes = /Supercontig_[1-7]$/ # 以下设置各个 ideograms 的大小。其总长度为 1 ,hs1 的长度为 0.5, hs2,hs3 和 hs4 这 3 个 chromosomes 的总长度为 0.5,并且这 3 个 chromosomes 的长度是分布均匀的。注意前者的单位是 r, 后者使用了正则表达式对应多个 chromosomes, 其单位是为 rn 。 #chromosomes_scale = hs1=0.5r,/hs[234]/=0.5rn # 使 hs2, hs3 和 hs4 在圈图上的展示方向是反向的。 #chromosomes_reverse = /hs[234]/ # 设置各个 ideograms 的颜色 #chromosomes_color = hs1=red,hs2=orange,hs3=green,hs4=blue # 默认下在 ideogram block 中统一设置了 ideogram 的位置,可以使用此参数调整指定 ideogram 的位置。 #chromosomes_radius = hs4:0.9r # chromosomes_radius = hs2:0.9r;hs3:0.8r;hs4:0.7r # karyotype 文件最后一列指定了各个 chromosomes 的颜色,而使用 chromosomes_color 参数也能修改颜色。当然,使用如下方式进行颜色的修改,则更加直观。 #以下方式是对颜色重新进行定义。chr1,chr2,chr3 和 chr4 对应着 karyotype 文件最后一列的值,代表着颜色的类型。此处使用 color block 来对其进行重新定义。注意重新定义的时候需要加符号 * #
chr23* = chrx #chr1* = red #chr2* = orange #chr3* = green #chr4* = blue # 绘制 plot 图 <plots> <<include plots_histogram.conf>> <<include plots_heatmap.conf>> #<
>
</plots> <<include ideogram.conf>> <<include ticks.conf>> <<include links.conf>> # # 插入必须的并不常修改的标准参数 <image> <<include etc/image.conf>> </image> <<include etc/colors_fonts_patterns.conf>> <<include etc/housekeeping.conf>>
- 2、软件的运行
cricos -noparanoid -conf circos.conf -outputfile out.png
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-tlNHHgnJ-47)(https://imgkr2.cn-bj.ufileos.com/4e12be9f-0567-4dd3-92ba-ed65d5e81d6e.png?UCloudPublicKey=TOKEN_8d8b72be-579a-4e83-bfd0-5f6ce1546f13&Signature=%252ByIUiWYxsYMq8OjzxQSIh1MyAYk%253D&Expires=)]
End
除此之外还可以添加散点图、染色体内的线性关系图,更多的语法规则可以登录官网查看或在后期小编会继续更新。
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/207226.html原文链接:https://javaforall.net
