美文网首页
基因结构图

基因结构图

作者: 余绕 | 来源:发表于2023-01-05 21:15 被阅读0次

加载R包

library(gggenes)
library(ggplot2)

加载数据

rm(list = ls())
data("example_genes")

dat=as.data.frame(example_genes)

绘图

ggplot(data=dat,
        aes(xmin=start,
            xmax=end,
            y=molecule))+
geom_gene_arrow(aes(fill=gene,forward=orientation))+
  geom_gene_label(aes(label=gene))+
  facet_wrap(~ molecule , ncol = 1,scales = "free")+ #分图,scales = "free"自由显示坐标
  scale_fill_brewer(palette = "Set3")+theme_genes()
image.png

选择部分数据绘图

library(tidyverse)
#选择数据
dat1<- dat %>% dplyr::filter(molecule =="Genome1") %>% slice(1:3)

> dat1
  molecule gene start   end  strand orientation
1  Genome1 genA 15389 17299 reverse           1
2  Genome1 genB 17301 18161 forward          -1
3  Genome1 genC 18176 18640 reverse           1

ggplot(data=dat1,
       aes(xmin=start,
           xmax=end,
           y=molecule))+
  geom_gene_arrow(aes(fill=gene,forward=orientation),arrowhead_width = grid::unit(10,"mm"),arrow_body_height = grid::unit(10,"mm"))+
  geom_gene_label(aes(label=gene),padding.y=grid::unit(0.1,"mm"),min.size=8)+
  facet_wrap(~ molecule , ncol = 1,scales = "free")+
  scale_fill_brewer(palette = "Set3")+theme_genes()

#其中arrowhead_width = grid::unit(10,"mm"),arrow_body_height = grid::unit(10,"mm")) 用于条基因大小
#padding.y=grid::unit(0.1,"mm")用于调节字体大小
image.png

相关文章

网友评论

      本文标题:基因结构图

      本文链接:https://www.haomeiwen.com/subject/mgilcdtx.html