论文
Somatic variations led to the selection of acidic and acidless orange cultivars
https://www.nature.com/articles/s41477-021-00941-x
柑橘体细胞变异2021NP.pdf
论文中提供了作图用到的原始数据,我们可以试着复现一下,今天的推文复现一下论文中的Figure1c柱形图
论文中提供的数据格式如下
image.png
读取和整理数据的代码
代码语言:javascript复制library(tidyverse)
library(readxl)
dat<-read_excel("data/20231031/41477_2021_941_MOESM4_ESM.xlsx",
skip = 1,
sheet = "citric acid raw data",
na="N.A.") %>%
filter(!is.na(Index))
dat
dat %>% dim()
dat %>% colnames()
dat %>%
select(1,3:8) %>%
pivot_longer(!Index) %>%
group_by(Index) %>%
summarise(std_error=plotrix::std.error(value),
mean_value=mean(value,na.rm=TRUE)) %>%
ungroup() -> new.dat1
dat %>%
select(1,3:8) %>%
pivot_longer(!Index) -> new.dat2
作图代码
代码语言:javascript复制ggplot()
geom_col(data=dat,aes(x=Index,y=average),
fill=NA,color="black",
width=0.6)
geom_errorbar(data=new.dat1,
aes(ymin=mean_value-std_error,
ymax=mean_value std_error,
x=Index),
width=0.4)
geom_jitter(data=new.dat2,aes(x=Index,y=value),
width = 0.2,
size=3,color="#fda63a")
theme_bw(base_size = 20)
scale_y_continuous(expand = expansion(mult = c(0,0)),
limits = c(0,30))
scale_x_continuous(breaks = 1:26)
labs(x="Varieties of sweet orange",
y="Citric acid (mg/mL)")
theme(panel.border = element_blank(),
panel.grid = element_blank(),
axis.line = element_line())
geom_segment(data=data.frame(x=c(3.5,14.5,19.5,24.5),
y=30),
aes(x=x,xend=x,y=0,yend=y),
lty="dashed")
geom_text(data=data.frame(x=c(2,9,17,22,25.5),
y=c(28,20,20,15,10),
label=c("Extremelynhigh acid",
"High acid",
"Moderate acid",
"Low acid",
"Acidless")),
aes(x=x,y=y,label=label),
size=5)
image.png
小明的数据分析笔记本
小明的数据分析笔记本 公众号 主要分享:1、R语言和python做数据分析和数据可视化的简单小例子;2、园艺植物相关转录组学、基因组学、群体遗传学文献阅读笔记;3、生物信息学入门学习资料及自己的学习笔记!