Fork me on GitHub

使用ggbio在R中制作弦图

分享一个制作弦图的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包还可以制作其他复杂的图表(如下),具体使用方法可参考该包的帮助文档:

posted @ 2015-08-27 00:01  ZHK的博客  阅读(4106)  评论(0编辑  收藏  举报