circos 学习手册(二十七)

技巧(二)

6. 复杂直方图

6.1 直方图填充

可以使用如下规则,基于直方图的 bin 值更改其填充色

# remap the histogram value from the range [-0.6,0.6] onto the index [0,5], then
# use the index to select the color from the list
# dorange orange lorange lblue blue dblue
# 
# Perl syntax for referencing an element of a list is qw(a b c d)[index]
# where index starts at 0.
<rule>
condition  = 1
fill_color = eval(qw(dorange orange lorange lblue blue dblue)[remap_int(var(value),-0.6,0.6,0,5)])
</rule>
6.2 分层背景色和宏

在这个例子中,我们为具有六个颜色层的直方图创建一个背景:蓝色代表正值,橙色代表负值。

背景中的每个颜色层都由其自己的 <background> 块定义

<plot>
...
# define background color cutoffs
bgy1 = 0.2    # first cutoff
bgy2 = 0.5    # second cutoff
bgc1 = orange # bg color for negative values
bgc2 = blue   # bg color for positive values
...

<backgrounds>
# use the parameters above using conf(.,param)
<background>
color = lconf(.,bgc2)
y0    = conf(.,bgy2)
</background>
<background>
color = vlconf(.,bgc2)
y1    = conf(.,bgy2)
y0    = conf(.,bgy1)
</background>
<background>
color = vvlconf(.,bgc2)
y1    = conf(.,bgy1)
y0    = 0
</background>
<background>
color = vvlconf(.,bgc1)
y1    = 0
y0    = -conf(.,bgy1)
</background>
<background>
color = vlconf(.,bgc1)
y1    = -conf(.,bgy1)
y0    = -conf(.,bgy2)
</background>
<background>
color = lconf(.,bgc1)
y1    = -conf(.,bgy2)
</background>
</backgrounds>

</plot>
6.3 y 轴网格和宏

轴网格也可以引用直方图的 cutoff

<axes>

# every 25% with low transparency
<axis>
color     = grey_a1
thickness = 2
spacing   = 0.25r

# every 5% with higher transparency
<axis>
color     = grey_a3
thickness = 1
spacing   = 0.05r
</axis>

# thick line at y=0
<axis>
color     = grey_a1
thickness = 5
position  = 0
</axis>

# at each background cutoff, a thick white line
<axis>
color     = white
thickness = 5
position  = -conf(.,bgy2),-conf(.,bgy1),conf(.,bgy1),conf(.,bgy2)
</axis>

</axes>

7. link 终端可变半径

使用数据文件或者规则,可以独立地操纵 link 的每一端的径向位置。可以应用在将 link 的端点移动到另一个数据轨迹。

这是通过设置 radius1radius2 的值来实现的,分别代表 link 的第一个数据点和第二个数据点的径向位置

第一种方法是将半径值与一端或两端关联

hs1 486 76975 hs15 100263879 100338121 radius1=0.5r
hs1 342608 393885 hs15 100218755 100268630 radius2=0.5r
hs1 576306 626811 hs15 100218755 100268630 radius=0.75r

未定义半径的 link 的端点,将使用 <links><link> 块中的 radius 参数值

第二种方法,使用 rule 并设置 radius1radius2 变量

<rules>

# if a rule is triggered, continue testing with other rules
flow       = continue

# remap the color of the link to the first chromosome
<rule>
condition  = 1
color      = eval(sprintf("%s_a4",var(chr1)))
</rule>

# Alter radial position of one or both ends of a link, depending
# on its position. The function on(RX) tests whether a link
# is on a chromosome matching the regular expression RX.

# to/from hs1
<rule>
# the trailing $ (end of string anchor) is required so that 
# chromosome names like hs10, hs11, hs12, etc don't match
condition  = on(hs1$)
radius     = 0.85r
</rule>

# to hs10, hs11 or hs12
<rule>
condition  = to(hs1[012])
radius2    = 0.75r
</rule>

# from hs10, hs11, hs12
<rule>
condition  = from(hs1[012])
radius1    = 0.75r
</rule>

# from hs14 and has start beyond 100mb
<rule>
condition  = from(hs14) && var(start1) > 100mb
radius1    = 1r+50p
z          = 5
thickness  = 3
color      = blue
</rule>

# to hs5 and has end within 50mb of position 100mb
<rule>
condition  = to(hs5) && abs(var(start2) - 100mb) < 50mb
radius2    = 1r+50p
z          = 5
thickness  = 3
color      = red
</rule>

</rules>

8. 堆积直方图

8.1 堆积数据集

堆积直方图是直方图轨迹的扩展,要绘制堆积直方图,只需要在数据文件中每个直方图设置一系列的值

...
hs7 65000000 69999999 0.388090,0.070074,0.547485,0.842239,0.525658
hs7 70000000 74999999 0.886542,0.321023,0.145677,0.897684,0.264217
hs7 75000000 79999999 0.854199,0.567889,0.574767,0.656331,0.418385
hs7 80000000 84999999 0.286509,0.201049,0.552485,0.876529,0.999801
hs7 85000000 89999999 0.154836,0.515471,0.389453,0.440168,0.475127
...

第一个值绘制在底部,然后是第二个值,以此类推。

8.2 格式化堆积数据集

可以通过制定一个逗号分隔的列表为每个数据集制定单独的格式参数(color, thickness fill_color, pattern)

例如,为每个数据集填充不同的颜色,可以设置 fill_color 提供 5 个不同的值

fill_color = red,orange,yellow,green,blue

如果提供的值较少,则会循环使用

指定颜色和厚度

color      = white
fill_color = red,orange,yellow,green,blue
fill_under = yes
thickness  = 1,2,3,4,5
8.3 颜色和模式

你可以独立循环 bin 的颜色和模式

fill_color = red,grey,black
pattern    = checker,solid

将会创建以下 bins

color  pattern
  red    checker
  grey   solid
  black  checker
  red    solid
  grey   checker
  black  solid
  ...    ...
8.4 调整堆叠次序

默认情况下,堆叠顺序是按照数据值在文件中出现的顺序,因此,对于颜色列表

fill_color = red,orange,yellow,green,blue

以及数据行

hs1 0 4999999 0.237788,0.291066,0.845814,0.152208,0.585537

将按照如下顺序堆叠

  • 0.237788 (red)
  • 0.291066 (orange)
  • 0.845814 (yellow)
  • 0.152208 (green)
  • 0.585537 (blue)

当设置

sort_bin_values = yes

将会按照降序值堆叠

  • 0.845814 (yellow)
  • 0.585537 (blue)
  • 0.291066 (orange)
  • 0.237788 (red)
  • 0.152208 (green)

9. 透明 link

下面我们将介绍如何使用颜色透明度改善 link 的布局。

9.1 使用 z-depth

如果你有许多重叠的 link,可以使用 z-depth 值将重要的 link 绘制在前面

<rules>
<rule>
condition  = 1
z          = eval( scalar min(var(size1),var(size2) ) )
</rule>
</rules>

但是 link 遮挡的问题依然存在

9.2 定义透明颜色

定义透明颜色,可以在 rgb 颜色值后面添加一个透明度值,该值介于 0(不透明)-127(完全透明) 之间。

<<include colors_fonts_patterns.conf>>
<colors>
blackweak = 0,0,0,100
</colors>

透明度为 100/127,当在白色上绘制是,blackwisergb 值为 200,200,200,当为 link 指定这个颜色之后

<link>
ribbon = yes
color  = blackweak
...
</link>

色带将是透明的。透明度 79%

9.3 自动定义颜色透明度

默认情况下,circos 为每种颜色定义了 5 个透明度级别。

每种颜色(如纯红色 pred=255,0,0),将产生 5 种新的颜色定义 pred_a1, pred_a2, pred_a3, pred_a4, 和 pred_a5,每种 _aN 颜色具有透明度 N/(5+1)。即

  • pred_a1 - 17%
  • pred_a2 - 33%
  • pred_a3 - 50%
  • pred_a4 - 67%
  • pred_a5 - 83%

注意:没有定义 pred_a0,因为 pred 已经存在其定义。pred_a5 不是 100% 透明。

<link>
ribbon = yes
color  = black_a5 # black with 83% transparency
...
</link>

你可以使用 auto_alpha_steps 更改图像的透明度变化步数

<image>
<<include etc/image.conf>>
# overwrite auto_alpha_steps from default value included in etc/image.conf
auto_alpha_steps* = 10
</image>
9.4 用 rule 添加透明度

通过使用规则,可以很容易的更改颜色透明度

对于随机生成的数据

e.g.
hs7 127586339 141410899 hsY 30737607 31414129

使用如下规则为每个 link 定义一个由三个组件派生的颜色:亮度前缀、染色体名称和透明度后缀

<rule>
condition = 1
# derive the color name from the chromosome name
# lum80 + chr_name + _a2
#
# lum70*, lum80* and lum90* colors are normalized
# to a given luminance and are predefined at etc/colors.ucsc.conf
#
# _a2 adds transparency (2/6 = 33%) where the denominator
# is derived from auto_alpha_steps+1=6
color     = eval(lc sprintf("%s%s_a%d",'conf(luminance)',var(chr1),4))
</rule>

使用这一规则,所有 link 颜色名称都会被修改。

使用 conf() 函数获取 luminance 参数的值,这一参数可以在配置文件开头定义,也可以通过命令行 -param 修改它的值

> circos -param luminance=lum70
9.5 染色体颜色

从染色体的名称及 luminance 前缀设置染色体的颜色

# change the color of each chromosome to lum80 + chr_name
# where the lum80 prefix references a predefined color
# with normalized luminance
chromosomes_color = /./=conf(luminance)var(chr)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

名本无名

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值