我正在使用ggboxplot
中的ggpubr
创建一个箱线图。但是,compare_means
给出的p值(0.08,如下面的代码所示)与我手工计算的值(0.1)不同。我使用这个功能有什么问题吗?为什么会出现这种差异?
library(data.table)
library(ggpubr)
compare_means(ratio ~ type, data = plt2, method = 'wilcox.test')
# # A tibble: 1 x 8
# .y. group1 group2 p p.adj p.format p.signif method
# <chr> <chr> <chr> <dbl> <dbl> <chr> <chr> <chr>
# 1 ratio Mut WT 0.0808556 0.0808556 0.081 ns Wilcoxon
wilcox.test(plt2[type == 'WT', ratio], plt2[type == 'Mut', ratio])
#
# Wilcoxon rank sum test
#
# data: plt2[type == "WT", ratio] and plt2[type == "Mut", ratio]
# W = 0, p-value = 0.1
# alternative hypothesis: true location shift is not equal to 0
数据plt2
:
>dput(plt2)
structure(list(type = c("Mut", "WT", "Mut", "WT", "Mut", "WT"
), rep.bio = c("v1", "v1", "v2", "v2", "v3", "v3"), ratio = c(1.22480885484374,
1.01644732404719, 1.37027369557587, 1.16227329691363, 1.20888766223709,
1.08816776516)), row.names = c(NA, -6L), class = c("data.table",
"data.frame"), .Names = c("type", "rep.bio", "ratio"))
# type rep.bio ratio
# 1: Mut v1 1.224809
# 2: WT v1 1.016447
# 3: Mut v2 1.370274
# 4: WT v2 1.162273
# 5: Mut v3 1.208888
# 6: WT v3 1.088168
正如Jimbou所评论,ggpubr
在exact = FALSE
时设置wilcox.text
。这导致了上面报道的差异。