码迷,mamicode.com
首页 > 其他好文 > 详细

使用ggbio在R中制作弦图

时间:2015-08-27 02:03:19      阅读:359      评论:0      收藏:0      [点我收藏+]

标签:

分享一个制作弦图的R包:ggbio. 效果图和代码如下。稍后解释具体用法...

 

library(GenomicRanges)

set.seed(1)
N <- 100

gr <- GRanges(seqnames = sample(c("chr1", "chr2", "chr3"), size = N, replace = TRUE),
IRanges(start = sample(1:300, size = N, replace = TRUE), width = sample(70:75,size = N, replace = TRUE)), 
strand = sample(c("+", "-", "*"),size = N,replace = TRUE), 
value = rnorm(N, 10, 3), score = rnorm(N, 100, 30),sample = sample(c("Normal", "Tumor"), 
size = N, replace = TRUE), pair = sample(letters,size = N, replace = TRUE))

library(ggbio)
seqlengths(gr) <- c(400, 500, 700)
values(gr)$to.gr <- gr[sample(1:length(gr), size = length(gr))]
idx <- sample(1:length(gr), size = 50)
gr <- gr[idx]

ggplot() 
+ layout_circle(gr, geom = "ideo", fill = "gray70", radius = 7, trackWidth = 3) 
+layout_circle(gr, geom = "bar", radius = 10, trackWidth = 4,aes(fill = score, y = score)) 
+layout_circle(gr, geom = "point", color = "red", radius = 14,trackWidth = 3, grid = TRUE, aes(y = score)) 
+layout_circle(gr, geom = "link", linked.to = "to.gr", radius = 6, trackWidth= 1)

 

技术分享

 

ggbio包还可以制作其他复杂的图表(如下),具体使用方法可参考该包的帮助文档:

技术分享

使用ggbio在R中制作弦图

标签:

原文地址:http://www.cnblogs.com/1zhk/p/4762061.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!