分享

Circos手把手极简入门(Windows环境)

 微笑如酒 2018-08-04

Circos安装及测试


首先,下载Circos安装包官网


安装包

标黄的为最新版本的circos。


最下面也还有一个简单的tutorials,为Linux版本的tutorial,包含了很多种类型的数据配置示例,共有十个示例,有兴趣的不妨了解一波。

Windows下移动到某个自定义文件夹下解压压缩文件即可,接下来就可以通过PowerShell进行测试,验证是否可以作图。

  1. # 进入对应的解压文件夹下

  2. PS D:\Software\circos\circos-0.69-6> cd .\example\

  3. PS D:\Software\circos\circos-0.69-6\example> ls

  4.  目录: D:\Software\circos\circos-0.69-6\example

  5. Mode LastWriteTime Length Name

  6. ---- ------------- ------ ----

  7. d----- 2018/6/20 13:32 data

  8. d----- 2018/6/20 13:32 etc

  9. -a---- 2017/6/17 7:36 3693061 circos.png

  10. -a---- 2017/6/17 7:37 258048 circos.svg

  11. -a---- 2017/6/4 9:05 1476 README

  12. -a---- 2017/6/4 9:05 202 run

  13. -a---- 2017/6/4 9:05 37130 run.out

  14. # 测试作图

  15. PS D:\Software\circos\circos-0.69-6\example> ..\bin\circos -conf .\etc\circos.conf

  16. # 会出现一大串状态信息,这里显示最后一行信息

  17. debuggroup summary,timer 34.17s image took more than 30 s to generate. Component timings are shown above. To always show them, use -debug_group timer. To adjust the time cutoff, change debug_auto_timer_report in etc/housekeeping.conf.


Example plot


Perl模块的安装


这里我看了教程[1]选择使用Strawberry Perl


日常安装

随后打开perl command line进行模块安装


Perl command line


  1. # 在命令行下输入以下代码

  2. cpan Carp Clone Config::General Cwd Data::Dumper Digest::MD5 File::Basename File::Spec::Functions File::Temp FindBin Font::TTF::Font GD GD::Image Getopt::Long IO::File List::MoreUtils List::Util Math::Round Math::Trig Math::VecStat Memoize Params::Validate Pod::Usage POSIX Readonly Regexp::Common Statistics::Basic Storable Sys::Hostname Text::Balanced Text::Format Time::HiRes

静静的等待安装结束, 随后使用PS(以下都使用此代替power shell)检查所需模块是否都已经安装成功。

  1. PS D:\Software\circos\circos-0.69-6\bin> ./circos -module

  2. ok 1.23 Carp

  3. ok 0.31 Clone

  4. ok 2.60 Config::General

  5. ok 3.36 Cwd

  6. ok 2.131 Data::Dumper

  7. ok 2.51 Digest::MD5

  8. ok 2.82 File::Basename

  9. ok 3.33 File::Spec::Functions

  10. ok 0.22 File::Temp

  11. ok 1.50 FindBin

  12. ok 0.39 Font::TTF::Font

  13. ok 2.46 GD

  14. ok 0.2 GD::Polyline

  15. ok 2.38 Getopt::Long

  16. ok 1.15 IO::File

  17. ok 0.33 List::MoreUtils

  18. ok 1.23 List::Util

  19. ok 0.01 Math::Bezier

  20. ok 1.997 Math::BigFloat

  21. ok 0.06 Math::Round

  22. ok 0.08 Math::VecStat

  23. ok 1.02 Memoize

  24. ok 1.24 POSIX

  25. ok 1.05 Params::Validate

  26. ok 1.36 Pod::Usage

  27. ok 1.03 Readonly

  28. ok 2013031301 Regexp::Common

  29. ok 2.50 SVG

  30. ok 1.19 Set::IntSpan

  31. ok 1.6611 Statistics::Basic

  32. ok 2.30 Storable

  33. ok 1.16 Sys::Hostname

  34. ok 2.02 Text::Balanced

  35. ok 0.59 Text::Format

  36. ok 1.9724 Time::HiRes

  37. PS D:\Software\circos\circos-0.69-6\bin>

此步操作没有问题,接下来就是愉快的作图时光!


Linux下安装Circos


老规矩还是anaconda

  1. conda install -c bioconda circos

[1]: 最美不过遇见你_8090


最低配上手教程


安装好Circos后我们看到作者推荐从quick start系列教程开始学起,首先我们对circos的作图模式有一个了解,只有掌握作图逻辑才可以真正理解circos。

本节学习使用最少的配置文件,先把图片画出来。随后再对需要的参数进行详细的研究。

本最低配图片将展示人类上色后的24条染色体,当然随后我们也可以加入一些额外参数使图片更好看些。


1

MINIMUM CONFIGURATIO


  1. # circos.conf

  2. karyotype = data/karyotype/karyotype.human.txt

  3. default = 0.005r

  4. radius = 0.9r

  5. thickness = 20bp

  6. fill = yes

  7. # 后面的内容都是标准且必须的。每个circos作图都会至少需要这些参数,在需要的时候可以被修改,具体内容请查看 etc/文件夹

  8. # 在circos文件夹下

  9. >

  10. # 颜色定义

  11. >

  12. # 调试参数

  13. >

2

KARYOTYPE


karyotype文件一般来说都是需要的,它定义了染色体的名称,大小,颜色。但是circos可以展示很多其它的数据,所以该文件的参数也并不限定针对染色体。

在安装好的circos/data/karyotype/文件夹下已经自带了数个常见生物的序列信息:人类,小鼠,大鼠,果蝇。

当参数karyotype指定了一个文件的位置的时候,文件路径可以是绝对路径或者是相对路径,相对路径的意思就是如果在运行目录没有找到指定文件,就会在circos文件夹下寻找,这也是为什么此处我们只需要指定data/karyotype的原因。

3

IDEOGRAMS


一旦circos有了染色体信息可以用来作图的时候,核型模式图信息就会被需要来告诉circos在哪里进行标记。

ideogram区块的参数可以指定,例如 radius, thickness, fill,除此之外, 参数也可以指定两条染色体之间的间隔。


4

实战


将以上代码保存为circos.conf,powershell进入该文件所在位置,调用circos即可作图;

  1. PS D:\Software\circos\circos-0.69-6\my_circos> ..\bin\circos -conf .\circos.conf

  2. debuggroup summary 0.16s welcome to circos v0.69-6 31 July 2017 on Perl 5.014002

  3. debuggroup summary 0.16s current working directory D:/Software/circos/circos-0.69-6/my_circos

  4. debuggroup summary 0.16s command D:\Software\circos\circos-0.69-6\bin\circos.exe -conf .\circos.conf

  5. debuggroup summary 0.16s loading configuration from file .\circos.conf

  6. debuggroup summary 0.16s found conf file .\circos.conf

  7. debuggroup summary 0.49s debug will appear for these features: output,summary

  8. debuggroup summary 0.49s bitmap output image ./.\circos.png

  9. debuggroup summary 0.49s SVG output image ./.\circos.svg

  10. debuggroup summary 0.49s parsing karyotype and organizing ideograms

  11. debuggroup summary 0.58s karyotype has 24 chromosomes of total size 3,095,677,436

  12. debuggroup summary 0.58s applying global and local scaling

  13. debuggroup summary 0.59s allocating image, colors and brushes

  14. debuggroup summary 6.69s drawing 24 ideograms of total size 3,095,677,436

  15. debuggroup summary 6.69s drawing highlights and ideograms

  16. debuggroup output 6.73s generating output

  17. debuggroup output 7.10s created PNG image ./.\circos.png (84 kb)

  18. debuggroup output 7.12s created SVG image ./.\circos.svg (6 kb)

  19. PS D:\Software\circos\circos-0.69-6\my_circos>

结果如下:


结果

简单进阶:添加坐标和标签


在此章,我们学习将在原有图形基础上添加标签和刻度。为了达到这个目的,我们需要在 ideogram分区添加label参数,并增添 ticks分区。

1

DEOGRAM LABELS


label参数格式有很多,这里展示最少的需要的变量:

  1. default = 0.005r

  2. # ideogram的位置设定,颜色填充设定的,轮廓设定

  3. radius = 0.90r

  4. thichness = 20bp

  5. fill = yes

  6. stroke_color = dgrey

  7. strock_thickness = 2p

  8. # 标签最少参数设定示例

  9. show_label = yes

  10. # 支持字体可以在etc/fonts.conf文件中查看

  11. label_font = default

  12. label_radius = 1R + 75p

  13. label_size = 30

  14. label_parallel = yes

其中label_radius参数可以自己设定为相对位置或者是绝对位置:

  1. # 以半径为单位

  2. label_radius = 1.1r

  3. label_radius = 0.8r

  4. # 绝对位置

  5. label_radius = 500p

  6. # 相对加上绝对位置

  7. label_radius = 1r + 100p

  8. # 使用图像大小来界定

  9. label_radius = dims(image,radius) - 50p

  10. # 使用核型模式图来界定

  11. label_radius = dims(ideogram,radius_outer) + 50p

  12. label_radius = dims(ideogram,radius_inner) - 50p

2

TICK MARKS AND LABELS


刻度一般都是成组出现的,你可以指定它们的相对位置和绝对位置,最低配的参数如下:

  1. show_ticks = yes

  2. show_tick_labels = yes

  3. radius = 1r

  4. color = black

  5. thickness = 2p

  6. # 刻度标签

  7. multiplier = 1e-6

  8. # %d = 整数

  9. # %f = 浮点数

  10. # %.1f = 指定小数点后保留一位

  11. # %.2f = 指定小数点后保留两位

  12. format = %d

  13. spacing = 5u

  14. size = 10bp

  15. spacing = 25u

  16. size = 15p

  17. show_label = yes

  18. label_size = 20p

  19. label_offset = 10p

  20. format = %d

我们可以看到这里指定了两个 ,是因为会根据ideogram的情况自动选择最优的展现方式。


3

实战


随后我们将这两段代码分别保存成 ideogram.conf和 ticks.conf文件,修改之前的circos.conf,将ideogram作为单独模块隔离出来同时指定其它模块的作图单位 chromsomes_units参数,那么circos.conf会变成:

  1. karyotype = data/karyotype/karyotype.human.txt

  2. chromosomes_units = 1000000

  3. >

  4. >

  5. >

  6. >

  7. >

OK,一切搞定后再次调用powershell来作图:

  1. PS D:\Software\circos\circos-0.69-6\my_circos> ..\bin\circos -conf .\circos.conf

  2. debuggroup summary 0.15s welcome to circos v0.69-6 31 July 2017 on Perl 5.014002

  3. debuggroup summary 0.15s current working directory D:/Software/circos/circos-0.69-6/my_circos

  4. debuggroup summary 0.15s command D:\Software\circos\circos-0.69-6\bin\circos.exe -conf .\circos.conf

  5. debuggroup summary 0.15s loading configuration from file .\circos.conf

  6. debuggroup summary 0.16s found conf file .\circos.conf

  7. debuggroup summary 0.32s debug will appear for these features: output,summary

  8. debuggroup summary 0.32s bitmap output image ./.\circos.png

  9. debuggroup summary 0.32s SVG output image ./.\circos.svg

  10. debuggroup summary 0.32s parsing karyotype and organizing ideograms

  11. debuggroup summary 0.40s karyotype has 24 chromosomes of total size 3,095,677,436

  12. debuggroup summary 0.41s applying global and local scaling

  13. debuggroup summary 0.42s allocating image, colors and brushes

  14. debuggroup summary 2.07s drawing 24 ideograms of total size 3,095,677,436

  15. debuggroup summary 2.07s drawing highlights and ideograms

  16. debuggroup output 2.53s generating output

  17. debuggroup output 2.94s created PNG image ./.\circos.png (271 kb)

  18. debuggroup output 2.94s created SVG image ./.\circos.svg (123 kb)

  19. PS D:\Software\circos\circos-0.69-6\my_circos>

现在我们就有标记好的图片了:



染色体选择,缩放,颜色以及方向


本章节讨论如何对已经展示出来的元素进行调整。


1

IDEOGRAM SECTION


默认是展示所有的染色体,顺序是按照文件里面的顺序。但是可以通过 chromsomes_display_default参数来设定展示哪部分染色体:

  1. chromosomes_display_default = no

  2. chromosomes = hs1;hs2;hs3;h4

  3. # 正则也是支持的哦

  4. chromosomes = /hs[1-4]$/

  5. # 也可以结合使用

  6. chromosomes = /hs[1-4]$/;hs10;hs11

  7. # “-”号代表着不显示某个染色体

  8. chromosomes = /hs[1-4]$/;-hs3

  9. # 注意是使用;分号来作为分隔符的

2

IDEOGRAM SCALE


设定染色体的大小有相对指定和绝对指定两种模式。

首先来看绝对指定:

  1. # hs1 0.25x zoom

  2. # hs2 2.00x zoom

  3. chromosomes_scale = hs1=0.25,hs2=2.0

相对指定就是以相对半径为单位了

  1. # hs1 25% of figure

  2. # hs2 50% of figure

  3. chromosomes_scale = hs1=0.25r,hs2=0.50r

也可以指定多少个染色体分享多少比例的图片

  1. # hs1,hs2 distributed evenly within 50% of figure (each is 25%)

  2. chromosomes_scale = /hs[12]/=0.5rn

或者指定大家一块均分

  1. # 所有的的ideogram均分整张图片的比例

  2. chromosomes_scale = /./=1rn

3

SCALE PROGRESSION


默认染色体的排列顺序呢,是按照顺时针方向的,但是可以通过在 模块里面的 angle_orientation参数来设置:

  1. angle_orientation* = counterclockwise

  2. # * 号的意义在于覆盖一个参数

  3. >

也可以指定特定的染色体的排列顺序,使用 chromosomes-reverse参数

  1. chromosomes-reverse = /hs[234]/

这里没有加入原字符$是没有关系,因为这里只指定了画1234染色体,当然严谨起见最好还是习惯性的加上

4

IDEOGRAM COLOR


默认的颜色设定来自于karyotype文件,可以通过 charomsomes_color参数设定

  1. chromosomes_color = hs1=red,hs2=orange,hs3=green,hs4=blue

5

IDEPGRAM RADIAL POSITION


默认的参数是将所有的染色体以一样的径向位置排列的,但是在 模块里面的 radial参数可以改变所有染色体的径向位置,或者通过 chromosomes_radius参数改变单个或者多个染色体的径向位置

  1. chromosomes_radius = hs4:0.9r

6

实战


老规矩,把所有代码保存为conf文件,调用powershell作图:

  1. # circos.conf

  2. karyotype = data/karyotype/karyotype.human.txt

  3. chromosomes_units = 1000000

  4. # 设定作图染色体防微

  5. chromosomes_display_default = no

  6. chromosomes = /hs[1-4]$/

  7. # 设定缩放比例

  8. chromosomes_scale = hs1=0.5r,/hs[234]/=0.5rn

  9. # 设置排列顺序

  10. chromosomes_reverse = /hs[234]/

  11. # 设置填充颜色

  12. chromosomes_color = hs1=red,hs2=orange,hs3=green,hs4=blue

  13. # 设置径向位置

  14. chromosomes_radius = hs4:0.9r

  15. # 调用默认文件补齐其余参数

  16. >

  17. >

  18. >

  19. >

  20. >

  1. # ideogram.conf

  2. default = 0.005r

  3. radius = 0.90r

  4. thickness = 20p

  5. fill = yes

  6. stroke_color = dgrey

  7. stroke_thickness = 2p

  8. show_label = yes

  9. # see etc/fonts.conf for list of font names

  10. label_font = default

  11. label_radius = 1.075r

  12. # 假如想要标签尽可能靠近图像,使用下一行代码

  13. # label_radius = dims(image,radius) - 60p

  14. label_size = 30

  15. label_parallel = yes

  1. # ticks.conf

  2. show_ticks = yes

  3. show_tick_labels = yes

  4. radius = 1r

  5. color = black

  6. thickness = 2p

  7. multiplier = 1e-6

  8. format = %d

  9. spacing = 5u

  10. size = 10p

  11. spacing = 25u

  12. size = 15p

  13. show_label = yes

  14. label_size = 20p

  15. label_offset = 10p

  16. format = %d

  1. PS D:\Software\circos\circos-0.69-6\my_circos> ..\bin\circos -conf .\circos.conf

  2. debuggroup summary 0.31s welcome to circos v0.69-6 31 July 2017 on Perl 5.014002

  3. debuggroup summary 0.31s current working directory D:/Software/circos/circos-0.69-6/my_circos

  4. debuggroup summary 0.32s command D:\Software\circos\circos-0.69-6\bin\circos.exe -conf .\circos.conf

  5. debuggroup summary 0.32s loading configuration from file .\circos.conf

  6. debuggroup summary 0.32s found conf file .\circos.conf

  7. debuggroup summary 0.50s debug will appear for these features: output,summary

  8. debuggroup summary 0.50s bitmap output image ./.\circos.png

  9. debuggroup summary 0.50s SVG output image ./.\circos.svg

  10. debuggroup summary 0.50s parsing karyotype and organizing ideograms

  11. debuggroup summary 0.60s karyotype has 24 chromosomes of total size 3,095,677,436

  12. debuggroup summary 0.60s applying global and local scaling

  13. debuggroup summary 0.63s allocating image, colors and brushes

  14. debuggroup summary 2.68s drawing 4 ideograms of total size 881,626,704

  15. debuggroup summary 2.68s drawing highlights and ideograms

  16. debuggroup output 2.83s generating output

  17. debuggroup output 3.19s created PNG image ./.\circos.png (132 kb)

  18. debuggroup output 3.20s created SVG image ./.\circos.svg (34 kb)

  19. PS D:\Software\circos\circos-0.69-6\my_circos>



到此,入门就算告一段落,后面就是根据自己需求往上面添加各种tracks以及选择各种炫酷的效果啦。

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多