ggplot2+ggsignif绘制箱图及添加显著性
Posted xiaosagege
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ggplot2+ggsignif绘制箱图及添加显著性相关的知识,希望对你有一定的参考价值。
library(ggplot2)#加载ggplot2包
library(ggsignif)#加载显著性包
setwd(‘d:‘)#设置工作路径
da<-read.table(‘ahga.txt‘,header = TRUE,sep = ‘ ‘,stringsAsFactors = T)#读取文件,保持标题,保持因素型变量
head(da)#展示前几行数据
compire<-list(c(‘A‘,‘B‘),c(‘A‘,‘C‘),c(‘B‘,‘C‘))#添加要进行多重比较的数据列
ggplot(da,aes(x=Genotype,y=VLCFA,fill=Genotype))+stat_boxplot(geom = ‘errorbar‘,width=0.15)+geom_boxplot()+geom_signif(comparisons = compire,step_increase=0.5,map_signif_level = T,test = wilcox.test)#画箱图,并根据t检验结果,添加显著性
以上是关于ggplot2+ggsignif绘制箱图及添加显著性的主要内容,如果未能解决你的问题,请参考以下文章