[英]Adding Labels to Individual Genes with ggbio and ggplot2
我正在嘗試將基因標簽添加到使用 ggbio 包呈現基因組片段的繪圖中。
我正在使用autoplot()
函數並傳入一個 GenomicRanges 對象。 GRange 對象有一列元數據標簽,我希望它出現在每個圖形段頂部的生成圖上。
問題:如何從元數據列向 ggbio/ggplot2 圖中添加標簽?
我的代碼如下,沒有標簽,g 作為 GenomicRanges 對象。
autoplot(g)
正如用戶 zx8754 之前建議的那樣,我將遵循ggbio 手冊,但重點關注第2.2.5節從 GRangesList 對象制作基因模型。
基本上,關於如何從元數據列向 ggbio 圖中添加標簽的問題的答案是根據元數據列拆分 granges 對象,並使用帶有此命名 grangeslist 的 autoplot 函數。 這里的訣竅是預先向 granges 對象添加一個額外的列type="exon"
以模擬基因/轉錄模型結構。
library(ggbio)
library(GenomicRanges)
g <- GRanges(seqnames = "chr1",
ranges = c("100-150","150-200"),
strand = c("+","-"),
group = c("A","B"),
type = "exon")
autoplot(g)
grl <- split(g, g$group)
autoplot(grl)
#> Constructing graphics...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.