任何人!十分钟掌握Circos图绘制
写在写在前面的前面
我不喜欢调用外部程序,如果是简单的事情。我觉得应该用最简单的方式来实现。如果你只是想画一个简单的Circos图,perl?不用的。R?不用的。网页?不用的。复杂的配置文件?一样不用的。
你只需要一个体积为 4,000KB+ 的 TBtools。

写在前面
当矩形无法满足你的时候,那么就掰弯他。
为了在一个中午的时间内写一个所有人都可以秒速掌握的Circos图绘制工具,事实上,我早已做好准备。详细可见公众号的历史消息。
前期的准备,大体包括:
- JIGplot中SubPanel的掰弯
- 文本在笛卡尔坐标系中的重叠以及在极坐标系中的重叠处理(用了很长时间,想明白一个简答的处理方式)
- 一个绘制Circos的需求
三者兼备,于是在前两天学院每周一停电的中午,我就写出了这个工具。工具是写完了,然而能让这个工具实现价值的数据,目前还在难产。我更新到社区,嗯。。。大体收获了几个图,但目前似乎并没有让我惊艳的。
索性,就写上一贴。我想试试看,
是否有可能让Circos图,正如基因家族分析一样,变得任何人都轻易掌握和完成?。
进入主题
TBtools的所有工具,面向的都是绝对的生物学背景,所以每一个输入格式的考量,都会尽可能地考虑到容易获得或者容易整理。接下来逐点说明输入文件格式,同时,给出一个所有人必然能直接重复出来的结果。
TBtools的Circos工具主界面如下

接下来逐点说明输入
1.必须骨架文件,比如染色体长度文件,格式为,注意文本文件,制表符分隔

-
可选文件,比如基因展示在染色体的圈图上,格式为,最后一列的颜色R,G,B值是可选的
3.可选文件,比如展示一些区域之间的关联关系,如共线性基因或者大片段区域,如,颜色是可选的,开始是#号的行,会被忽略
点击Add就可以增加Track,Track你是可以随意增加,任何数目,直到你开心。点击一次,出现一个Track的配置信息,
4.一个Track要对应一个文件(一个文件可以用多次,在不同的Track)
Track的类型有四种
- Line 线图
- Bar 柱形图
- Heatmap 热图
- Tile 画矩形(在极坐标系下就变成Ring),主要是做注释
前三种Track的输入数据很简单,区域带上一个值

Tile的输入数据有所不同,最后一列不是值,而是一个RGB字符串,如

-
多选框,设置Track的类型
-
主要是针对Tile以外的Track,设置无重叠滑窗之后汇总信息的模式,比如Sum,就是将一个区域的所有值加和,Mean就是取平均
-
设置滑窗的宽度,一般是10 000
其他四个摁钮,点击就是设置一些颜色
注意One Color Two Color Three Color 中
而One Color 对于除Tile外的所有Track的颜色生效
另外两个Color 只对热图生效,用于生成热阶
写的太多,不如一个示例操作
示例
下面的示例只以拟南芥的基因组展开,而我并没有说,只能是一个基因组,或者只能是基因组信息。工具如何使用,是看个人,不是看开发者。
1.打开TBtools

2. 准备一个染色体长度文件
这是一个骨架,事实上,你可以自己编一个。这里我们假设,手上只有拟南芥的基因组序列,使用TBtools的Fasta Stater

拖进来基因组序列,设置输出文件,点击开始

用Excel打开,整理得到对应的每条染色体的长度信息

3. 准备一些track文件
假设我们手上也有拟南芥的基因注释结果(.gff3)文件,那么我们可以看下拟南芥的基因密度
用TBtools的表格操作工具(或者Excel也可以)



使用Excel打开输出文件,只保留着四列

增加一列,全部标记为 1


有了以上两个信息,其实我们就可以做很多东西了,比如展示基因密度,首先是打开TBtools的Super Circos

设置输入文件

然后点击“Show My Circos Plot”,得到一个结果

这个没啥用,因为根本没显示任何东西,我们刚才是对每一个基因写了1,所以最终binning的结果,是Mean,并没有意义
修改一下

于是基因密度的线图就出来了

线图不够炫酷,我们画个柱形图
这个BInSize也放大一些


恩,柱形图也不好看,要不就画热图

看起来就像模像样的,当然颜色可以随便调

事实上,很多Track是可以组合的,比如

也可以是堆叠在一起

正负链放在一起还是比较丑的,事实上,你可以按照正负链分开,然后画成两个Track,这里就不展示了。
4. 展示一些有关联的区域
比如共线性的一些基因,你通过各种方式得到基因对

那么可以在TBtools的帮助下,获得LinkedRegion信息,
首先是获取所有基因的位置信息

设置输入的gff3文件,并设置两个输出文件


随后只保留部分的列,

整理成Chr GeneID StartPos EndPos 格式

另存为文本制表符分隔
打开TBtools一个不错的工具,将基因对信息,直接转换为LinkedRegion信息


终于,我们得到这个文件

于是可以导入TBtools作为linkedInfo

于是Linked信息就展示出来了,虽然似乎没什么用

一般你准备这些数据的过程中,有些linkedRegion是需要高亮的,比如一些基因对,那么可以在对应的lInkedInfo后面加颜色信息

保存文本文件,重新点击Show My Circos Plot就可以了

配色是一个重要的问题....
这里只展示功能就不调了,有时候,你想要展示的是一个大的region


5.展示一些文本标签上去
比如拟南芥的ARF基因家族....

然后我们保存一个文本文件,丢给TBtools就可以了

恩,都是黑色的,不太好看,所以我们在后面加一些颜色
比如我们顺便改一下ID的标签

于是颜色也修改了,。。配色看个人,不纠结

你以为这样就完了,肯定不是!
看到

点击这个弹出一些控制参数

这么多参数,你自己体会,这里就大概操作一下,搞的这张图好像还可以看一样,比如文本要移动出去


5.展示一些区域的注释
你真的以为这样就结束了吗?当然不是!
你还可以配置一个文件,对region进行注释,假设有QTL的区间对吗?我来伪装一个给你

也就是最后一列不再是数值,直接是颜色,然后...导入啊


然后你用面板的参数调整,按照参数,你应该会得到这么一张图

6.似乎完了
你不会真的以为这样就结束了?!当然不是啊。
还有JIGplot啊,不要忘了,这个图是交互的啊
我鼠标拖以下,标签就出来了

我右键一下,还可以改颜色啊


7.当然还有,但是我不想写了....
事实上,基因密度什么的,你可以换成表达量?,GC含量等等,这些需要自己折腾了。
可能有人最关心的问题是,图片导出


写在最后
很多时候,看起来简单的,或许很复杂;反之亦然。
Circos是一个Perl软件,可以画出极其复杂而炫酷的图片。这个我可能暂时不会去追求(如果真的去追求那个,那么我肯定是要发CNS了吧...)
很多时候,很多生信分析,或者说图形绘制,大多数人的需求是比较简单的。正如perl的哲学一样,可以很快速而方便地完成简单的事情,而复杂的事情,努力一下,也不是不可以。
做生物学问题的朋友,其实并不可能有足够的时间掌握各种工具,尤其是跟命令行操作相关的。即使使用Perl Circos绘制了一个图,那下次呢?复杂的配置文件逻辑,不得不说太过麻烦。
Anyway,以上都是胡扯。
我只是想说,
画一个图,可能比较简单,写一个工具会比较麻烦,打一个GUI很 痛苦,而做一个所有人都能上手用的工具,。。。。
正如Horticulture Research主编程老师所说,既然你做了,那么就发表出来。
Done!
祝你们科研顺利,这个工具的使用,暂时不会回复任何使用问题,因为我已经写得很稳健了,按照这篇推文操作,不会有问题!
如果有问题,确实需要得到回复。欢迎大额支持我们课题组成员的户外扩展活动。
详细请访问课题组网站 http://xialab.scau.edu.cn/
