论文
Environmentally robust cis-regulatory changes underlie rapid climatic adaptation
https://www.biorxiv.org/content/10.1101/2022.08.29.505745v1
2022.08.29.505745v1.full.pdf
还没有发表,论文的数据和代码都公开
https://github.com/malballinger/BallingerMack_NYBZase_2022
今天的推文我们重复一下论文中的Figure3C
这里桑基图实现是借助R包 ggalluvial
帮助文档
或者直接通过命令查看help(package="ggalluvial")
首先是自己构造数据的一个简单例子
library(ggalluvial)
as.data.frame(Titanic)
dat01<-data.frame(first=c("A","A","C"),
second=c("B","D","E"),
third=c("F","G","F"),
n=c(15,30,20))
dat01$first<-factor(dat01$first,
levels = c("C","A"))
ggplot(data=dat01,
aes(axis1=first,axis2=second,axis3=third,
y=n))+
geom_alluvium(aes(fill=second),
#size=3,
#color="white",
width = 0.1,
aes.bind = "flows")+
geom_stratum(fill=c("red","blue","green",'yellow',
'orange',"blue","green"),
#color="white",
#size=3,
width=0.1)+
geom_label(stat = "stratum", aes(label = after_stat(stratum)))+
scale_x_continuous(breaks = c(1,2),
labels = c("first","second"),
expand = expansion(mult = c(0,0)))+
theme_void()
加载需要用到的R包
library(tidyverse)
library(readr)
library(ggplot2)
library(ggalluvial)
library(latex2exp)
论文中的数据和图
fig3c1<-read_csv("figure3c1.csv")
fig3c1
cp2 <- c("#FC7945", "#4AB08C", "#482870",
"gray", "#FC7945", "#4AB08C",
"#482870", "gray")
fig3c1$category_warm<-factor(fig3c1$category_warm,
levels = c("Amb&Conserved",
"TRANS_ONLY",
"Cis&Trans",
"CIS_ONLY"))
fig3c1$category_cold<-factor(fig3c1$category_cold,
levels = c("Amb&Conserved",
"TRANS_ONLY",
"Cis&Trans",
"CIS_ONLY"))
fig3c1 %>%
ggplot(aes(y = n, axis1 = category_warm, axis2 = category_cold)) +
geom_alluvium(aes(fill= category_warm, color = category_warm),
size = 0.7, alpha = 0.6,
curve_type = "cubic", width = 1/4,
show.legend = FALSE,
aes.bind = "flows") +
geom_stratum(
color = cp2, fill = cp2,
alpha = 0.99, width = 1/4, show.legend = FALSE) +
scale_fill_manual(breaks = c("Amb&Conserved", "Cis&Trans", "TRANS_ONLY", "CIS_ONLY"),
values = c("darkgray", "#29AF7F", "#3B0F6F", "#FC4E07"),
labels = c("Conserved", "Cis + Trans", "Trans", "Cis")) +
scale_color_manual(breaks = c("Amb&Conserved", "Cis&Trans", "TRANS_ONLY", "CIS_ONLY"),
values = c("darkgray", "#29AF7F", "#3B0F6F", "#FC4E07"),
labels = c("Conserved", "Cis + Trans", "Trans", "Cis")) +
scale_x_continuous(breaks = 1:2, labels = c("Warm", "Cold"), expand = c(0.025,0.025)) +
scale_y_continuous(limits = c(0,1400), breaks = seq(0, 1400, 400),
expand = c(0,0)) +
theme_classic() +
theme(panel.grid = element_blank(),
axis.title = element_blank(),
axis.text = element_text (size = 10,
family = "sans"),
plot.margin = unit(c(0,1.5,0,0),'cm'))+
coord_cartesian(clip="off")+
annotate(geom="text",
x=2.15,y=225,
label=TeX(r"(\textit{cis})"),
hjust=0,
color="#FC7945")+
annotate(geom="text",
x=2.15,y=621.5,
label=TeX(r"(\textit{cis & trans})"),
hjust=0,
color= "#4AB08C")+
annotate(geom="text",
x=2.15,y=892,
label=TeX(r"(\textit{trans})"),
hjust=0,
color="#482870")+
annotate(geom="text",
x=2.15,y=1186,
label="conserved\nambiguous",
hjust=0,
color="gray")
欢迎大家关注我的公众号
小明的数据分析笔记本
小明的数据分析笔记本 公众号 主要分享:1、R语言和python做数据分析和数据可视化的简单小例子;2、园艺植物相关转录组学、基因组学、群体遗传学文献阅读笔记;3、生物信息学入门学习资料及自己的学习笔记!