p=ggplot(umap)+geom_violin(aes(x=recur_T_NT,y=PHF14,fill=recur_T_NT))
p+ stat_compare_means(comparisons = list(c("NR_NT","NR_T"),c("NR_NT","R_NT"),c("NR_T","R_T"),c("R_NT","R_T")),family = "TT Times New Roman",method = "wilcox.test",label = "p.signif",#标记p值的方法
label.x = 1.5#调整p值所在位置
)
[1] FALSE
Error in `ggsignif::geom_signif()`:
! Problem while computing stat.
ℹ Error occurred in the 2nd layer.
Caused by error in `setup_params()`:
! Can only handle data with groups that are plotted on the x-axis
报错原因:发现映射关系被我写在了geom_violin()里面,因此stat_compare_means()无法读取数据,正确的写法应该如下
p=ggplot(umap,aes(x=recur_T_NT,y=PHF14,fill=recur_T_NT))+geom_violin()
p+ stat_compare_means(comparisons = list(c("NR_NT","NR_T"),c("NR_NT","R_NT"),c("NR_T","R_T"),c("R_NT","R_T")),family = "TT Times New Roman",method = "wilcox.test",label = "p.signif",#标记p值的方法
label.x = 1.5#调整p值所在位置
)
参考ggsignif报错:Can only handle data with groups that are plotted on the x-axis-CSDN博客