R语言ggplot2复现CELL论文中的基因共线性图
## 论文> Reciprocal conversion between annual and polycarpic perennial flowering behavior in the Brassicaceae
[https://www.sciencedirect.com/science/article/pii/S0092867424004732](https://www.sciencedirect.com/science/article/pii/S0092867424004732)
今天的推文复现一下论文中的 FigureS3b
!(data/attachment/forum/plugin_zhanmishu_markdown/202406/08d83fea15bbdbfcdf1bfa653c89698c_1718785013_3901.jpg)
前提是已经通过分析确定了哪些基因存在共线性,现在想用ggplot2来作图
构造数据(基因长度和基因间区的长度并没有按照真实比例来,论文中是否是按照真实比例来画的暂时没有看明白)
用来画基因的数据
!(data/attachment/forum/plugin_zhanmishu_markdown/202406/2f29386a18f606bfbe43eda2ff915bff_1718785013_1088.jpg)
从前向后
基因的起始位置
纵坐标
基因名
物种名
基因方向
基因类别
用来画共线性的数据
!(data/attachment/forum/plugin_zhanmishu_markdown/202406/440fc35485617271fc02f1afe1ae6c50_1718785013_5345.jpg)
这个是手动整理的,如何用代码根据第一个数据得到这个数据暂时还没有想明白
## 作图代码
```
library(tidyverse)
library(readxl)
library(gggenes)
library(ggforce)
dat01<-read_excel("2024.data/20240618/dat01.xlsx")
dat01 %>%
mutate(X1=case_when(
X5 == "species01" ~ X1,
X5 == "species02" ~ X1 -5,
X5 == "species03" ~ X1 + 10,
X5 == "species04" ~ X1 + 5,
X5 == "species05" ~ X1 + 13,
),
X2=case_when(
X5 == "species01" ~ X2,
X5 == "species02" ~ X2 -5,
X5 == "species03" ~ X2 + 10,
X5 == "species04" ~ X2 + 5,
X5 == "species05" ~ X2 + 13,
)) -> dat01
dat01 %>%
group_by(X5) %>%
summarise(min=min(X1),
max=min(X2))
dat01 %>%
group_by(X5) %>%
summarise(min=max(X1),
max=max(X2))
dat02<-read_excel("2024.data/20240618/dat02.xlsx")
dat01 %>%
group_by(X5) %>%
summarise(min=min(X1),
max=max(X2),
X7=min(X3)) %>%
ungroup() -> segment.df
ggplot()+
geom_segment(data=segment.df,
aes(x=min-3,xend=max+3,y=X7,yend=X7),
color="grey")+
geom_diagonal_wide(data = dat02,
aes(x=x,y=y,group=group),
fill="grey",
strength = 0.5,
radius=unit(0,'mm'),
orientation = "y")+
geom_gene_arrow(data=dat01,
aes(xmin = X1,
xmax = X2,
y = X3,
fill = X7,
forward=X6),
arrowhead_height = unit(3, "mm"),
arrowhead_width = unit(1.5, "mm"),
alpha=1)+
theme_bw()+
theme(panel.grid = element_blank(),
panel.border = element_blank(),
axis.ticks = element_blank(),
axis.text.x = element_blank(),
axis.title = element_blank(),
legend.position = "none",
axis.text.y = element_text(face="italic"))+
scale_y_continuous(breaks = 1:5,
label=c("A","B","C","D","E"))+
scale_fill_manual(values = c("#e59f01","#56b4e8",
"#009f73","#0072b1"))+
geom_text(data=dat01,aes(x=X1,y=X3,label=X4),
hjust=0,vjust=2,
fontface="italic")
```
!(data/attachment/forum/plugin_zhanmishu_markdown/202406/06c0ce00bc6dd928ab673dd1d105c463_1718785013_4662.jpg)
**欢迎大家关注我的公众号**
**小明的数据分析笔记本**
> 小明的数据分析笔记本 公众号 主要分享:1、R语言和python做数据分析和数据可视化的简单小例子;2、园艺植物相关转录组学、基因组学、群体遗传学文献阅读笔记;3、生物信息学入门学习资料及自己的学习笔记!
>
页:
[1]