RIdeogram:染色体数据可视化的R包

已有的工具如circos, 只能绘制弯的染色体,又如R包chromoMap,IdeoViz,karyploteR,ggbio和在线工具Idiographica,虽然能绘制直的染色体,但仅支持人,小鼠,大鼠和果蝇等几个物种,不支持自定义物种,不够自由。R包RIdeogram可以可视化染色体上的全基因组数据,并且输出SVG格式的文件,也可以将SVG格式的文件转化为pdf, png, tiff, 或jpg格式。

安装

install.packages('RIdeogram')
require(RIdeogram)

输入文件

data(human_karyotype, package="RIdeogram")
data(gene_density, package="RIdeogram")
data(Random_RNAs_500, package="RIdeogram")
head(human_karyotype)
#>   Chr Start       End  CE_start    CE_end
#> 1   1     0 248956422 122026459 124932724
#> 2   2     0 242193529  92188145  94090557
#> 3   3     0 198295559  90772458  93655574
#> 4   4     0 190214555  49712061  51743951
#> 5   5     0 181538259  46485900  50059807
#> 6   6     0 170805979  58553888  59829934

karyotype文件:可以是五列(包含中心粒位置)或三列(不含中心粒位置)
第一列:染色体号
第二列:起始
第三列:终止
第四列:中心粒起始位置
第五列:中心粒终止位置

head(gene_density)
#>   Chr   Start     End Value
#> 1   1       1 1000000    65
#> 2   1 1000001 2000000    76
#> 3   1 2000001 3000000    35
#> 4   1 3000001 4000000    30
#> 5   1 4000001 5000000    10
#> 6   1 5000001 6000000    10

基因密度文件:
第一列:染色体号
第二列:起始
第三列:终止
第四列:基因密度值

head(Random_RNAs_500)
#>    Type    Shape Chr    Start      End  color
#> 1  tRNA   circle   6 69204486 69204568 6a3d9a
#> 2  rRNA      box   3 68882967 68883091 33a02c
#> 3  rRNA      box   5 55777469 55777587 33a02c
#> 4  rRNA      box  21 25202207 25202315 33a02c
#> 5 miRNA triangle   1 86357632 86357687 ff7f00
#> 6 miRNA triangle  11 74399237 74399333 ff7f00

染色体旁的标记文件:
第一列:标记类型
第二列:标记形状
第三列:染色体号
第四列:起始
第五列:终止
第六列:颜色

也可以加载自己的数据。

karyotype <- read.table("karyotype.txt", sep = "\t", header = T, stringsAsFactors = F)
density <- read.table("data_1.txt", sep = "\t", header = T, stringsAsFactors = F)
label <- read.table("data_2.txt", sep = "\t", header = T, stringsAsFactors = F)

另外,该R包中还提供了一个GFFex函数用来从GFF文件中提取绘制染色体上热图的信息(例如基因密度)。
首先,需要准备物种的karyotype文件,格式与上述的相同,且保证第一列染色体号与GFF文件中的相同。然后,使用GFFex提取基因密度信息。

gene_density <- GFFex(input = "gencode.v32.annotation.gff3.gz", karyotype = "human_karyotype.txt", feature = "gene", window = 1000000)

其中,feature选项可以改为要绘制的特征类型,window选项可以更改统计的窗口大小。

用法

基本染色体绘制

ideogram(karyotype = human_karyotype)
convertSVG("chromosome.svg", device = "png")

基因密度热图绘制

ideogram(karyotype = human_karyotype, overlaid = gene_density)
convertSVG("chromosome.svg", device = "png")

标记类型绘制

ideogram(karyotype = human_karyotype, label = Random_RNAs_500, label_type = "marker")
convertSVG("chromosome.svg", device = "png")

染色体,基因密度和标记同时绘制

ideogram(karyotype = human_karyotype, overlaid = gene_density, label = Random_RNAs_500, label_type = "marker")
convertSVG("chromosome.svg", device = "png")

修改基因密度热图的颜色

ideogram(karyotype = human_karyotype, overlaid = gene_density, label = Random_RNAs_500, label_type = "marker", colorset1 = c("#fc8d59", "#ffffbf", "#91bfdb"))
convertSVG("chromosome.svg", device = "png")

无中心粒染色体的绘制

human_karyotype <- human_karyotype[,1:3]
ideogram(karyotype = human_karyotype, overlaid = gene_density, label = Random_RNAs_500, label_type = "marker")
convertSVG("chromosome.svg", device = "png")

修改染色体宽度值(染色体数较少时)

# default width is 170
human_karyotype <- human_karyotype[1:10,]
ideogram(karyotype = human_karyotype, overlaid = gene_density, label = Random_RNAs_500, label_type = "marker")
convertSVG("chromosome.svg", device = "png")
# change width to 100
human_karyotype <- human_karyotype[1:10,]
ideogram(karyotype = human_karyotype, overlaid = gene_density, label = Random_RNAs_500, label_type = "marker", width = 100)
convertSVG("chromosome.svg", device = "png")

移动图例位置

# change Lx and Ly to 80, 25
ideogram(karyotype = human_karyotype, overlaid = gene_density, label = Random_RNAs_500, label_type = "marker", width = 100, Lx = 80, Ly = 25)
convertSVG("chromosome.svg", device = "png")

绘制热图标签

data(human_karyotype, package="RIdeogram") #reload the karyotype data
ideogram(karyotype = human_karyotype, overlaid = gene_density, label = LTR_density, label_type = "heatmap", colorset1 = c("#f7f7f7", "#e34a33"), colorset2 = c("#f7f7f7", "#2c7fb8")) #use the arguments 'colorset1' and 'colorset2' to set the colors for gene and LTR heatmaps, separately.
convertSVG("chromosome.svg", device = "png")

绘制线形标签

# 单线形标签
data(liriodendron_karyotype, package="RIdeogram") #load the karyotype data
data(Fst_between_CE_and_CW, package="RIdeogram") #load the Fst data for overlaid heatmap
data(Pi_for_CE, package="RIdeogram") #load the Pi data for one-line label
head(Pi_for_CE) #this data has a similar format with the heatmap data with additional column of "Color" which indicate the color for the line.
#>   Chr   Start     End      Value  Color
#> 1   1       1 2000000 0.00273566 fc8d62
#> 2   1 1000001 3000000 0.00239580 fc8d62
#> 3   1 2000001 4000000 0.00319407 fc8d62
#> 4   1 3000001 5000000 0.00286900 fc8d62
#> 5   1 4000001 6000000 0.00186596 fc8d62
#> 6   1 5000001 7000000 0.00186182 fc8d62

ideogram(karyotype = liriodendron_karyotype, overlaid = Fst_between_CE_and_CW, label = Pi_for_CE, label_type = "line", colorset1 = c("#e5f5f9", "#99d8c9", "#2ca25f"))
convertSVG("chromosome.svg", device = "png")
# 双线形标签
data(liriodendron_karyotype, package="RIdeogram") #load the karyotype data
data(Fst_between_CE_and_CW, package="RIdeogram") #load the Fst data for overlaid heatmap
data(Pi_for_CE_and_CW, package="RIdeogram") #load the Pi data for two-line label
head(Pi_for_CE_and_CW) #this data has a similar format with the one for one-line label with additional two columns indicating the second feature you want to show. When you prepare your own data, please keep the exact same column names.
#>   Chr   Start     End    Value_1 Color_1    Value_2 Color_2
#> 1   1       1 2000000 0.00273566  fc8d62 0.00385702  8da0cb
#> 2   1 1000001 3000000 0.00239580  fc8d62 0.00331109  8da0cb
#> 3   1 2000001 4000000 0.00319407  fc8d62 0.00374530  8da0cb
#> 4   1 3000001 5000000 0.00286900  fc8d62 0.00339141  8da0cb
#> 5   1 4000001 6000000 0.00186596  fc8d62 0.00305246  8da0cb
#> 6   1 5000001 7000000 0.00186182  fc8d62 0.00323655  8da0cb

ideogram(karyotype = liriodendron_karyotype, overlaid = Fst_between_CE_and_CW, label = Pi_for_CE_and_CW, label_type = "line", colorset1 = c("#e5f5f9", "#99d8c9", "#2ca25f"))
convertSVG("chromosome.svg", device = "png")

绘制多边形标签

# 单多边形标签
data(liriodendron_karyotype, package="RIdeogram") #load the karyotype data
data(Fst_between_CE_and_CW, package="RIdeogram") #load the Fst data for overlaid heatmap
data(Pi_for_CE, package="RIdeogram") #load the Pi data for one-polygon label
ideogram(karyotype = liriodendron_karyotype, overlaid = Fst_between_CE_and_CW, label = Pi_for_CE, label_type = "polygon", colorset1 = c("#e5f5f9", "#99d8c9", "#2ca25f"))
convertSVG("chromosome.svg", device = "png")
# 双多边形标签
data(liriodendron_karyotype, package="RIdeogram") #load the karyotype data
data(Fst_between_CE_and_CW, package="RIdeogram") #load the Fst data for overlaid heatmap
data(Pi_for_CE_and_CW, package="RIdeogram") #load the Pi data for two-polygon label
ideogram(karyotype = liriodendron_karyotype, overlaid = Fst_between_CE_and_CW, label = Pi_for_CE_and_CW, label_type = "polygon", colorset1 = c("#e5f5f9", "#99d8c9", "#2ca25f"))
convertSVG("chromosome.svg", device = "png")

此外,还可以修改device参数来转换图片为其他格式,比如tiff, pdf, jpg等,还可以修改dpi参数来设置图片的分辨率(默认为300).

convertSVG("chromosome.svg", device = "tiff", dpi = 600)

该R包中还提供了四个快捷方式进行图片格式转换。

svg2tiff("chromosome.svg")
svg2pdf("chromosome.svg")
svg2jpg("chromosome.svg")
svg2png("chromosome.svg")

基因组共线性区域可视化

两个基因组间共线性区域的绘制,

data(karyotype_dual_comparison, package="RIdeogram")
head(karyotype_dual_comparison)
#>   Chr Start      End   fill species size  color
#> 1  I      1 23037639 969696   Grape   12 252525
#> 2  II     1 18779884 969696   Grape   12 252525
#> 3 III     1 19341862 969696   Grape   12 252525
#> 4  IV     1 23867706 969696   Grape   12 252525
#> 5   V     1 25021643 969696   Grape   12 252525
#> 6  VI     1 21508407 0ab276   Grape   12 252525
table(karyotype_dual_comparison$species)
#> 
#>   Grape Populus 
#>      19      19

data(synteny_dual_comparison, package="RIdeogram")
head(synteny_dual_comparison)
#>   Species_1  Start_1    End_1 Species_2 Start_2   End_2   fill
#> 1         1 12226377 12267836         2 5900307 5827251 cccccc
#> 2        15  5635667  5667377        17 4459512 4393226 cccccc
#> 3         9  7916366  7945659         3 8618518 8486865 cccccc
#> 4         2  8214553  8242202        18 5964233 6027199 cccccc
#> 5        13  2330522  2356593        14 6224069 6138821 cccccc
#> 6        11 10861038 10886821        10 8099058 8011502 cccccc

karyotype_dual_comparison文件格式
Chr: 染色体号
Start: 起始
End: 终止
fill: 染色体填充色
species:物种名
size: 物种名字体大小
color: 物种名字体颜色

synteny_dual_comparison文件格式
Species_1:物种1染色体号
Start_1,End_1:物种1染色体区域位置
Species_2:物种2染色体号
Start_2,End_2:物种2染色体区域位置

ideogram(karyotype = karyotype_dual_comparison, synteny = synteny_dual_comparison)
convertSVG("chromosome.svg", device = "png")

三个基因组间共线性区域的绘制,

data(karyotype_ternary_comparison, package="RIdeogram")
head(karyotype_ternary_comparison)
#>   Chr Start      End   fill   species size  color
#> 1  NA     1 15980527 fcb06b Amborella   10 fcb06b
#> 2  NA     1 11522362 fcb06b Amborella   10 fcb06b
#> 3  NA     1 11085951 fcb06b Amborella   10 fcb06b
#> 4  NA     1 10537363 fcb06b Amborella   10 fcb06b
#> 5  NA     1  9585472 fcb06b Amborella   10 fcb06b
#> 6  NA     1  9414115 fcb06b Amborella   10 fcb06b
table(karyotype_ternary_comparison$species)
#> 
#>    Amborella        Grape Liriodendron 
#>          100           19           19

data(synteny_ternary_comparison, package="RIdeogram")
head(synteny_ternary_comparison)
#>   Species_1 Start_2   End_2 Species_2  Start_1    End_1   fill type
#> 1         1 4761181 2609697         1   342802   981451 cccccc    1
#> 2         6 6344197 8074393         1 15387184 16716190 cccccc    1
#> 3        10 6457890 9052487         1 11224953 14959548 cccccc    1
#> 4        13 6318795 1295413         1 20564870 21386271 cccccc    1
#> 5        16 1398101 2884119         1 21108654 22221088 cccccc    1
#> 6        16 1482529 2093625         1 21864494 22364888 cccccc    1
tail(synteny_ternary_comparison, n = 20)
#>     Species_1  Start_2    End_2 Species_2  Start_1    End_1   fill type
#> 571        16 19278042 20828694         2 95267449 93334736 cccccc    3
#> 572        12 20546006 22461088         2 22647943 18365764 cccccc    3
#> 573         4 22259262 23453956         2 15068249 17839485 cccccc    3
#> 574        14 22377895 23821929         2 97299880 96033346 cccccc    3
#> 575         6  1538773  2808373         1 91285578 95681546 cccccc    3
#> 576        11  3381792  4954528         1 67689752 75286468 cccccc    3
#> 577         9  4814481  6975840         1 69506847 76015710 cccccc    3
#> 578        10  7091825  9742616         1 19333526 24516133 cccccc    3
#> 579        13 22063957 23402389         1 95843870 92195256 cccccc    3
#> 580         7   679765  1881756         6  7365421  7531534 e41a1c    1
#> 581         7   679765  2752867        13   501561   766473 e41a1c    1
#> 582         7   679765  3012501         8  7406703  8222490 e41a1c    1
#> 583         7  2049369  2942034        14 29350547 34369929 e41a1c    2
#> 584         7  2075095  1538540        10 28985737 30815217 e41a1c    2
#> 585        13   531939   834472        14 28866243 35278211 e41a1c    3
#> 586         8  7427221  8894821        14 28632063 34805893 e41a1c    3
#> 587         6  7567597  7690342        14 32050301 34913801 e41a1c    3
#> 588        13   501561   876423        10 30496700 27874100 e41a1c    3
#> 589         6  7171014  7815454        10 31408837 27660041 e41a1c    3
#> 590         8  5773528  9346871        10 31408837 26585934 e41a1c    3
ideogram(karyotype = karyotype_ternary_comparison, synteny = synteny_ternary_comparison)
convertSVG("chromosome.svg", device = "png")

更好的阅读体验请移步这里>>

参考

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 158,560评论 4 361
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,104评论 1 291
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 108,297评论 0 243
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,869评论 0 204
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,275评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,563评论 1 216
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,833评论 2 312
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,543评论 0 197
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,245评论 1 241
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,512评论 2 244
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,011评论 1 258
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,359评论 2 253
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,006评论 3 235
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,062评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,825评论 0 194
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,590评论 2 273
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,501评论 2 268

推荐阅读更多精彩内容