統(tǒng)計(jì)方法與參數(shù)
一般根據(jù)數(shù)據(jù)是否符合正態(tài)分布捞蚂,選擇合適的統(tǒng)計(jì)方法
統(tǒng)計(jì)方法 適用情況
t.test() 比較兩組(參數(shù)) 數(shù)據(jù)符合正態(tài)分布
wilcox.test() 比較兩組(非參數(shù))
aov()或anova() 比較多組(參數(shù))
kruskal.test() 比較多組(非參數(shù))
參數(shù)
ggsigni包主要函數(shù)為:geom_signif()和stat_signif() ,常用geom_signif()
參數(shù) 說明示范
comparisons list,設(shè)置需要比較的組夺饲,比如list(c("a","b"),c("a","c"))
test 統(tǒng)計(jì)方法,比如t.test()
test.args test傳入的參數(shù)
map_signif_level 布爾值瞳收,p值直接當(dāng)作注釋或者以星號(hào)替代,比如c(" " = 0.001,""=0.01,'''=0.05)
annotations 帶有可選注釋的字符向量情妖,如果沒有則被忽略
step_increase 不同組差異標(biāo)注的間隔
示例
library(ggplot2)
library(ggsignif)
dat <- data.frame(Group =c("S1","S1","S2","S2"),
Sub = c("A","B","A","B"),
Value = c(3,5,7,8))
ggplot(dat,aes(Group,Value)) + geom_bar(aes(fill = Sub),stat = "identity",position = "dodge",width = .5) +
geom_signif(y_position = c(5.3,8.3),xmin = c(0.8,1.8),xmax = c(1.2,2.2),
annotations = c("**","NS"),tip_length = 0)+
geom_signif(comparisons = list(c("S1","S2")),y_position = 9.3,tip_length = 0,vjust = 0.2)+
scale_fill_manual(values = c("grey80","grey20"))
參考
http://www.reibang.com/p/07e1bee02ee8
https://mp.weixin.qq.com/s?__biz=MzI3Mzc1MzczMA==&mid=2247484318&idx=1&sn=aeeb47d5f0cc6ce0971032f4709393ef&chksm=eb1f3073dc68b9651aa3fe1fed06db66ade6231c5f9790868ffcf680e76f67e329e04f823da3&scene=21