ggplot画gene structure和alternative splicing | ggbio | GenomicFeatures
见上篇:genome browser | ggplot | 基因组可视化 | R | transcript | isoform
新需求(画出Fig 4D上面的辅图, Science, 2021):
山寨版,分析解构:
- 首先去method里找,完全没写是什么工具画的,那就猜吧;
- 其次看配色和对齐方式,基本肯定是ggplot画的,但仍然查不到是什么工具;
- 最后,能猜到这是卡通图,并不是真实的数据(exon的长度过于平均);
- 优点:辅图一目了然的AS event可视化,这种barplot的可视化(颜色对应,PSI和为1)更加易读,可以看出作者在AS可视化上的功底;
- 细节也很到位:箭头和UTR
做一个API,自动读取AS event格式,添加箭头和UTR,以后可以常用。
不难
举个栗子:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | # prepare kartoon data # SE, Cassettes AS_1 <- data.frame (EXONSTART= c (0,2,4), EXONEND= c (1,3,5), EXONSTRAND= "+" ) seg_1 <- data.frame (x= c (0, 1.5, 3.5), xend= c (1.5, 3.5, 4.5), y=0, yend=0) AS_2 <- data.frame (EXONSTART= c (0,4), EXONEND= c (1,5), EXONSTRAND= "+" ) seg_2 <- data.frame (x= c (0, 1.5, 2.5, 3.5), xend= c (1.5, 2.5, 3.5, 4.5), y=0, yend=0) options (repr.plot.width=2.5, repr.plot.height=1) p1 <- ggplot () + # add line and arrow # geom_hline(yintercept=0)+ # geom_segment(x = 0, xend = 5.5, y = 0, yend = 0) + geom_segment (data=seg_1, aes (x=x,y=y,xend=xend,yend=yend), arrow= arrow (length= unit (0.3, "cm" )), size=1) + # add exons geom_rect (data=AS_1, aes (xmin=EXONSTART, xmax=EXONEND,ymin= -0.1,ymax=0.1),fill= "#4DAF4A" )+ # add UTR # geom_rect(data=UTR, aes(xmin=EXONSTART, xmax=EXONEND,ymin= -0.05,ymax=0.05),fill="#282a73")+ # details labs (title = NULL ,subtitle = NULL )+ theme_void () + theme (legend.position = "none" ) + scale_x_continuous (expand = c (0.1, 0.1), limits = c (0, 5)) + scale_y_continuous (expand = c (0.02, 0.02), limits = c (-0.1, 0.1)) p1 options (repr.plot.width=2.5, repr.plot.height=1) p2 <- ggplot () + # add line and arrow # geom_hline(yintercept=0)+ # geom_segment(x = 0, xend = 5.5, y = 0, yend = 0) + geom_segment (data=seg_2, aes (x=x,y=y,xend=xend,yend=yend), arrow= arrow (length= unit (0.3, "cm" )), size=1) + # add exons geom_rect (data=AS_2, aes (xmin=EXONSTART, xmax=EXONEND,ymin= -0.1,ymax=0.1),fill= "#984EA3" )+ # add UTR # geom_rect(data=UTR, aes(xmin=EXONSTART, xmax=EXONEND,ymin= -0.05,ymax=0.05),fill="#282a73")+ # details labs (title = NULL ,subtitle = NULL )+ theme_void () + theme (legend.position = "none" ) + scale_x_continuous (expand = c (0.1, 0.1), limits = c (0, 5))+ scale_y_continuous (expand = c (0.02, 0.02), limits = c (-0.1, 0.1)) p2 options (repr.plot.width=2.5, repr.plot.height=2) AS1 <- cowplot:: plot_grid (p1,p2,ncol = 1) AS1 options (repr.plot.width=9, repr.plot.height=1) cowplot:: plot_grid (AS2, AS2, AS3, AS1,ncol = 4) |
最终的模仿图,颜值还行:
分析案例:project/scPipeline/AS/suppa_AS_stat.ipynb
参考:
- "ggplot2 exercise" drawing gene structure diagram
- ggbio: visualization toolkits for genomic data
- ggscaleRanges
- Introduction to ‘gggenes’
- Example Needed: Using arrow() with ggplot2
- ggplot2 画个基因结构示意图
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
2020-07-21 孟德尔随机化 | Mendelian randomization
2020-07-21 探索性因子分析法 | exploratory factor analysis | EFA | Genomic Structural Equation Modelling | SEM
2017-07-21 UMI-tools | Cellranger手动分析流程 | 超短reads(primer、barcode、UMI、index等)比对方法 | gRNA | 单细胞 | Perturb-seq
2016-07-21 常用链接