getwd()
setwd("F:/000/PLC_expression/boxplot/boxdata")
dat010<-read_delim("age2.txt",delim = "\t")
dat010
# 加载R包,没有安装请先安装 install.packages("包名")
library(ggplot2)
library(reshape2)
library(ggsignif)
# 读取ROC数据文件
#df = read.delim("https://www.bioladder.cn/shiny/zyp/bioladder2/demoData/BoxPlot/boxplot.txt",# 这里读取了网络上的demo数据,将此处换成你自己电脑里的文件
# header = T # 指定第一行是列名
)
# 把数据转换成ggplot常用的类型(长数据)
df = melt(dat010)
# 绘图
ggplot(df,aes(x=variable,y=value,fill=variable))+
geom_boxplot(alpha = 1, # 透明度
outlier.color = "black" # 外点颜色
)+
theme_bw()+ # 白色主题
theme(
axis.text.x = element_text(angle = 0,
vjust = 0.5
) # x轴刻度改为倾斜90度,防止名称重叠
)+
geom_signif( # 添加显著性标签
comparisons=list(c("T1st-La","T3rd-La"),c("T1st-La","T5th-La"),c("T1st-La","Adult"),c("T1st-La","Pupa"),c("T1st-La","Egg")), # 选择你想在哪2组上添加标签
step_increase = 0.1,
test="t.test", # "t 检验,比较两组(参数)" = "t.test","Wilcoxon 符号秩检验,比较两组(非参数)" = "wilcox.test"
map_signif_level= T # 标签样式F为数字,T为*号
)