R 将p值或星号添加到ggplot
我想要的是成对比较,例如配对威尔科克斯检验。分组:R 将p值或星号添加到ggplot,r,ggplot2,ggpubr,R,Ggplot2,Ggpubr,我想要的是成对比较,例如配对威尔科克斯检验。分组:列表(c(“0.5”、“1”)、c(“1”、“2”)、c(“2”、“3”))。非常简单,一开始没有alpha校正等等 代码: 一种简单的方法是手动添加符号: p + annotate("text", x = 0.5, y = 23, label = "ns") + annotate("text", x = 1.5, y = 30, label = "**") + annotate("text", x = 2.5, y = 48, la
列表(c(“0.5”、“1”)、c(“1”、“2”)、c(“2”、“3”))
。非常简单,一开始没有alpha校正等等
代码:
一种简单的方法是手动添加符号:
p + annotate("text", x = 0.5, y = 23, label = "ns") +
annotate("text", x = 1.5, y = 30, label = "**") +
annotate("text", x = 2.5, y = 48, label = "***")
根据github回购问题,这是软件包的问题。作者建议手动计算p值,并按如下方式使用:
geom_signif(annotations = c(formatC(annot_1, digits=3),formatC(annot_2, digits=3)), y_position = c(150, 180), xmin=c(1.2, 0.8), xmax=c(2.2, 1.8))
其中
annot_1
和annot_2
是预先计算的p值 运行此代码会出现错误,因为找不到df_orig
。抱歉,我已修复此问题,我将标记此问题。我想我可以用这个来构造一个通用的解决方案。
p + annotate("text", x = 0.5, y = 23, label = "ns") +
annotate("text", x = 1.5, y = 30, label = "**") +
annotate("text", x = 2.5, y = 48, label = "***")
geom_signif(annotations = c(formatC(annot_1, digits=3),formatC(annot_2, digits=3)), y_position = c(150, 180), xmin=c(1.2, 0.8), xmax=c(2.2, 1.8))