shenwl的个人博客分享 http://blog.sciencenet.cn/u/shenwl

博文

Circos基础(4)

已有 8247 次阅读 2017-3-29 08:52 |系统分类:科研笔记

延续上一章,本章接着介绍heatmaps、scatter、histogram数据作图。

Heatmaps

热图能够直观地显示不同样本、位点之间的差异及聚类情况,是一个展示基因组不同区域不同特性的有效手段,常用于基因表达差异、表观遗传修饰差异等多种分析中。Circos通过type = heatmap的<plot>子模块来实现热图,其基本数据格式除了要求染色体名称和起始终止位置外,还应有value一栏,以示数据值的大小。我们先看一下其参数设置:

show_heatmaps= yes<plots><plot>show= conf(show_heatmaps)# 表示这是一个heatmap类型的plottype= heatmapfile= data/heatmap1.txt# 蓝色基调的9色面板color= blues-9-seq# Circos需要将数据文件中的数值进行映射进min和max区间,从而赋予不同颜色,这就需要考虑下面两个因素# 一是不同颜色区间的分配,由参数color_mapping设置# 二是线性/非线性映射,由参数scale_log_base设置,默认为线性映射,不需设置该值# 这些不同可参见下图min= 0max= .20e6# r0和r1为热图的显示半径r0= 0.765rr1= 0.785r# 每个色块边缘颜色及宽度stroke_color= whitestroke_thickness= 1p</plot><plot>show= conf(show_heatmaps)type= heatmapfile   = data/heatmap2.txtcolor= reds-9-seqmin= 0max= .20e6r0= 0.79rr1= 0.81rstroke_color= whitestroke_thickness= 1p</plot><plot>show= conf(show_heatmaps)type= heatmapfile= data/heatmap3.txtcolor= blues-9-seqmin= 0max= .10e6r0= 0.895rr1= 0.915rstroke_color= whitestroke_thickness= 1p</plot><plot>show= conf(show_heatmaps)type= heatmapfile= data/heatmap4.txtcolor= reds-9-seqmin= 0max= .10e6r0= 0.92rr1= 0.94rstroke_color= whitestroke_thickness= 1p</plot></plots>

这里可以看一下官网提供的关于颜色映射问题的示意图:circos我们先来看上面设置的heatmaps效果:circos但是会发现,上面4组heapmaps几乎用了一模一样的参数却设置了4遍,这样既麻烦又容易出错。Circos为这种情况提供了自动计数工具,下面举个例子。首先,我们新建立一个配置文件heatmap.chain.conf:

<plot># 设置变量chain,默认从0开始计数,这里的“:1”即累加1pre_increment_counter= chain:1# 用counter调用当前数值,输入不同数据文件file= data/heatmap.counter(chain).txtshow= conf(show_heatmaps)type= heatmapmin= 6000max= 50000# 同样利用counter设置颜色、位置半径等color= eval(join(",",map { sprintf("chr%d_a%d",counter(chain),$_) } (5,4,3,2,1) ))r0= eval(sprintf("%fr",0.99-counter(chain)*.025-.02))r1= eval(sprintf("%fr",0.99-counter(chain)*.025))stroke_thickness= 0<rules><rule># 前章提到Circos中是按照从前至后的顺序进行rule判断的,而importance可用来改变该判断顺序# 即importance值越高,顺序越靠前,未设置importance的则放在最后依序判断importance= 100condition= var(value) < 2000show= no</rule><rule>importance= 95condition= var(value) < 6000color= vvlgreystroke_color= blackstroke_thickness= 1</rule></rules></plot>

关于counter的详细信息可查看官网。接下来,我们在主配置文件circos.conf中进行多重include操作即可:

show_heatmaps= yes<plots># 多重操作,具体看引入的数据情况,下图一共需22个<<include heatmap.chain.conf>><<include heatmap.chain.conf>><<include heatmap.chain.conf>>... </plots>

这样设置简明清晰、易于管理,来看一下效果:circos

Scatter

散点图恐怕是工作中最常用的数据图之一了,而在Circos中我们需要重新理解其坐标轴,x轴可看作是染色体,y轴则是设置显示的径向区域,这样一来,我们就可以利用type = scatter的<plot>子模块方便地显示不同数值点。下面举个例子:

show_scatter= yes<plots># scatter1<plot>show= conf(show_scatter)# 表示这是一个scatter类型的plottype= scatterfile= data/scatter1.txt# r0和r1为散点图的显示半径r0= 1rr1= 1r+180p# 显示的数据值范围max= .5e6min= 0# 点的形状glyph= squareglyph_size= 6# 不设置color则点为空心color= undef# glyph边缘的颜色和粗细stroke_color= blues-5-seq-5stroke_thickness= 1</plot># scatter2<plot>show= conf(show_scatter)type= scatterfile= data/scatter2.txtr0= 1rr1= 1r+180pmax= .5e6min= 0glyph= triangleglyph_size= 8color= reds-5-seq-5# 表示数据展示方向,默认为out即由里向外orientation= in</plot></plots>

看一下效果:circos接下来我们考虑这样一件事,既然Circos中散点图的y轴是其显示区域的径向范围,那么令r0 = r1就可以产生不一样的显示效果,同时我们借助上面counter的用法,绘制另一种scatter图。首先新建立两个配置文件,scatter.chain.mm.conf:

<plot>show= conf(show_scatter)# 设置变量mmchainscatter,从0开始计数,累加1pre_increment_counter= mmchainscatter:1type= scatterglyph= circleglyph_size= 5min= 0max= 1e6# 可以看到,这里实际r0 = r1,且所有的配置中该值均未变r0= eval(sprintf("1r+%dp",90-0*counter(mmchainscatter)))r1= eval(sprintf("1r+%dp",90-0*counter(mmchainscatter)))file= data/scatter.mm.counter(mmchainscatter).txt# 不设置颜色使其为空心color= undef<rules><rule>condition= 1# 注意这里的id实际是数据文件第5列里自定义的变量stroke_color= eval(sprintf("%s",var(id)))stroke_thickness= 3glyph_size= eval(remap_int(var(value),0,1e5,15,180))</rule></rules></plot>

以及scatter.chain.rn.conf:

<plot>show= conf(show_scatter)pre_increment_counter= rnchainscatter:1type= scatterglyph= circleglyph_size= 15min= 0max= 1e6# 与上面不同,这里虽然r0 = r1,但该值随着rnchainscatter而变r0= eval(sprintf("1r+%dp",180-30*counter(rnchainscatter)))r1= eval(sprintf("1r+%dp",180-30*counter(rnchainscatter)))file= data/scatter.rn.counter(rnchainscatter).txtcolor= black<rules><rule>condition= 1# 注意这里的id实际是数据文件第5列里自定义的变量color= eval(sprintf("%s",var(id)))glyph_size= eval(remap_int(var(value),0,1e5,5,45))</rule></rules></plot>

然后在主配置文件circos.conf中进行多重include操作:

show_scatter= yes<plots># 多重操作,下图一共需22个<<scatter.chain.mm.conf>><<scatter.chain.mm.conf>>... # 多重操作,下图一共需5个<<scatter.chain.rn.conf>><<scatter.chain.rn.conf>>... </plots>

效果如下:circos可见对于数据可视化来说,想象力很重要。

Histogram

直方图常用来显示数据的分布、累积等差异。在某些时候,直方图与散点图存在共同之处(因为可以把点看作是直方的顶部),因而对histogram的设置来说,可以参考scatter:

show_histogram= yes<plots># histogram1<plot>show= conf(show_histogram)# 表示这是一个histogram类型的plottype= histogramfile= data/histogram1.txt# 显示的数据值范围,范围之外的不显示min= 0max= .5e6# 是否设置histogram的底色fill_under= yes# 蓝色基调的5色面板中的第4个色,aN表示透明度为N/6,这里即5/6 = 83%fill_color= blues-5-seq-4_a5# 显示区域r0= 1rr1= 1r+180p# 设置方向为由内之外orientation= out# 背景设置可用于任意plot模块,既可以与其它图形并用,也可以单独存在<backgrounds># 表示只在有数据的部分显示show= data#background1<background># 颜色设置color= vvlgrey# 注意在background中,范围设置使用y0和y1y0= 0.4ry1= 0.6r</background></backgrounds># 坐标轴的设置指y轴,径向# 可用于任意plot模块,既可以与其它图形并用,也可以单独存在<axes># 表示只在有数据的部分显示show= datathickness= 1# axis1<axis># 尺度spacing= 0.05rcolor= vlgrey# 在特定位置上不显示position_skip= 0.25r,0.35r</axis># axis2<axis>spacing= 0.1r# 注意在axis中,范围设置使用y0和y1y0= 0.3ry1= 0.7rcolor= grey</axis># axis3<axis># 在特定位置上显示,这里一个是数据值,一个是histogram图的径向范围的相对值position= .3e6,0.55rcolor= redthickness= 2</axis></axes></plot># histogram2<plot>show= conf(show_histogram)type= histogramfile= data/histogram2.txtr1= 1r+180pr0= 1rmax= .5e6min= 0fill_under= yesfill_color= reds-5-seq-4_a5orientation= in</plot></plots>

最后,我们看一下显示效果:circos经过这四章,我们大概能够应付基本的Circos作图了(plot中还有tile、line、connector等就不一一介绍了),然而唯有熟能生巧,只有不断地尝试再尝试,才能发现更多有意思的高阶用法。在这个数据为大,展示为先的时代,望Circos的使用能给我们的工作添光增色。

原文链接https://wenlongshen.github.io/2017/03/29/Circos-4/



https://blog.sciencenet.cn/blog-543513-1042286.html

上一篇:Circos基础(3)
下一篇:测序技术
收藏 IP: 219.238.129.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-6-2 19:11

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部