ggplot2.barplot
ggpubr.barplot
library(edgeR);library(dplyr);library(ggpubr)
x <- read.csv(file = "./Desktop/excel1.sjy.csv")
x <- x[,-c(6:7,12:13)]
data <- reshape2::melt(x,id="ID")
data[,2] <- as.character(data[,2])
data[1:32,2] <- "C";data[33:64,2] <- "A"
result <- wilcox.test(as.numeric(data[1:32,3]),as.numeric(data[33:64,3] ))
anno <- paste("pvalue(wilcox.test) = ",signif(result$p.value,4))
p <- ggbarplot(data, x = "ID", y = "value", color = "variable",
palette = c("blue", "red"),
position = position_dodge(0.8),add = c("mean_se"))
p <- p+annotate(geom="text",label=anno, x=3, y=1);p
结果:
添加显著性
利用ggpubr+ggplot2做barplot和boxplot图并显示显著性
p1 <- ggbarplot(data, x = "ID", y = "value", add = "mean_se",
color = "variable", palette = c("blue", "red"),
position = position_dodge(0.8))+
stat_compare_means(aes(group = variable),
paired = F,
label.y = .9) +
stat_compare_means(aes(group = variable),
paired = F,
label = "p.signif",
label.y = .8)
结果: