我在使用ggbio的circle()函数方面有一个非常具体的例子。
使用基因组范围包我已经制作了一个信心数据集
gr <- GRanges(seqnames =
c("scaffold_13117","scaffold_6016","scaffold_13335"),
ranges = IRanges(
start = rep(1,3),
end = c(5790199,5827,3335858),
),
strand = rep("*",3),
n = c("red","blue","red")
)
可以使用ggbio绘制圆形图,例如
p <- ggbio() + circle(gr, geom = "ideo")
但是我想通过&#39; n&#39;元数据部分的列。具体来说,对于scaffold_13117和scaffold_13335,它应该是红色的,而对于scaffold_6016,它应该是蓝色。我想知道如何做到这一点?
答案 0 :(得分:0)
你可以试试这个(注意我也改变了“scaffold_6016”的大小,这样可以更好地看到蓝色):
gr <- GRanges(seqnames =
c("scaffold_13117","scaffold_6016","scaffold_13335"),
ranges = IRanges(
start = rep(1,3),
end = c(5790199,5000000,3335858),
),
strand = rep("*",3),
n = c("red","blue","red")
)
mycolours<-c("red","blue")
names(mycolours)<-mycolours
p<-ggbio() + circle(gr,geom="rect",aes(fill=n))+scale_fill_manual(values=mycolours,guide="none")
print(p)