小杜的生信笔记,自2021年11月开始做的知识分享,主要内容是R语言绘图教程、转录组上游分析、转录组下游分析等内容。凡是在社群同学,可免费获得自2021年11月份至今全部教程,教程配备示例数据和相关代码,我们会持续更新中。
# 生成柱状图
ggplot(df_long, aes(x = time, y = value, fill = group)) +
geom_bar(stat = "summary", fun = "mean", position = position_dodge(width = 0.9), width = 0.7, color = "black") +
# 添加误差条,fun.data = mean_cl_normal 指定计算均值和置信区间
geom_errorbar(stat = "summary", fun.data = mean_cl_normal, position = position_dodge(width = 0.9), width = 0.2) +
# 使用 geom_beeswarm 函数添加蜂窝散点
geom_beeswarm(dodge.width = 0.8, size = 3, color = "black") +
scale_fill_manual(values = c("#009F72","#1F78B4")) + # "#096A62"
scale_y_continuous(expand = expansion(mult = c(0,0)), ##将Y轴柱子从(0,0)开始
limits = c(0,300), # 设置Y轴的取值
##Y轴的取值距离
breaks = seq(0,300,50) ##取值0-300,间隔50
)+
labs(x = "Time", y = NULL, fill = NULL) +
theme_classic() +
# 添加 p 值
stat_pvalue_manual(p_values, x = "time", label = "label", ## label = p.adj.signif,星号
y.position = c(50, 240, 270), tip.length = 0.001, inherit.aes = FALSE) +
annotate("segment", x = 0.8, ## X轴距离
xend = 1.2, ##长度
y = 48, ## y的高度
yend = 48,
color = "black") +
annotate("segment", x = 1.8, xend = 2.2, y = 238, yend = 238, color = "black") +
annotate("segment", x = 2.8, xend = 3.2, y = 268, yend = 268, color = "black") +
theme(axis.line = element_line(size = 0.8), ## 粗细
text=element_text(#family = "sans",
colour ="black",size = 10),
axis.text.x = element_text(color = "black", size = 10),
axis.text.y = element_text(color = "black",size = 10),
axis.ticks = element_line(colour = "black"),
strip.text = element_text(color = "black",size = 10),
axis.title = element_text(color = "black",size = 12), ##坐标轴字体大小
legend.position = "none",
strip.background = element_blank()
)
若我们的教程对你有所帮助,请
点赞+收藏+转发
,这是对我们最大的支持。
1. 最全WGCNA教程(替换数据即可出全部结果与图形)
2. 精美图形绘制教程
3. 转录组分析教程
4. 转录组下游分析
小杜的生信筆記 ,主要发表或收录生物信息学教程,以及基于R分析和可视化(包括数据分析,图形绘制等);分享感兴趣的文献和学习资料!!