首页 > 解决方案 > 将调整后的 p 值添加到 ggplot 箱线图中

问题描述

我知道以前有人问过这个问题,并且我已经查看了解决方案,但它们不适用于我的情况。我有一个小数据集(BCAAparams),其中包含在不同浓度的抑制剂存在下酶的 Km 和 Vmax 值(变量是 Km、Vmax 和 Conc(抑制剂)),每个 n=6。

Km  Vmax    Conc
0.32761 0.66823 0
0.31735 0.61598 0
0.462   0.722   0
0.31537 0.75304 0
0.28596 0.69695 0
0.25033 0.6482  0
0.24417 0.56245 2
0.25671 0.55012 2
0.24481 0.5027  2
0.2128  0.627   2
0.25104 0.64405 2
0.27557 0.65705 2
0.15244 0.46027 10
0.15438 0.41831 10
0.1457  0.37902 10
0.15884 0.52568 10
0.16006 0.5068  10
0.14318 0.47678 10
0.0879  0.34372 20
0.09132 0.32773 20
0.07899 0.28851 20
0.09257 0.38427 20
0.09333 0.37988 20
0.09315 0.36979 20

我正在寻找分析抑制剂对每个酶参数的影响,例如,

ggplot(BCAAparams, aes(group=Conc, x=Conc, y=Km)) +
geom_boxplot(notch=FALSE) + labs(x="BCAA conc (mM)", y="Km (mM)")

在此处输入图像描述

我正在使用 ggpubr,我可以成功比较不同组的平均值(抑制剂的浓度)

compare_means(Km ~ Conc, data = BCAAparams, method = "t.test") 

# A tibble: 6 x 8
.y.   group1 group2            p       p.adj p.format p.signif method
<chr> <chr>  <chr>         <dbl>       <dbl> <chr>    <chr>    <chr> 
1 Km    0      2      0.0432       0.043       0.04317  *        T-test
2 Km    0      10     0.00190      0.0038      0.00190  **       T-test
3 Km    0      20     0.000461     0.0014      0.00046  ***      T-test
4 Km    2      10     0.0000342    0.000140    3.4e-05  ****     T-test
5 Km    2      20     0.00000276   0.000014    2.8e-06  ****     T-test
6 Km    10     20     0.0000000135 0.000000081 1.3e-08  ****     T-test

问题是我找不到添加 stat_compare_means 命令的方法,该命令会将括号和相关的调整后的 p 值放到我的箱线图中,例如;

my_comparisons <- list(c("0", "2"), c("0", "10"), c("0", "20"), 
c("2","10"), c("2", "20"), c("10", "20"))

ggplot(BCAAparams, aes(group=Conc, x=Conc, y=Km)) +
geom_boxplot(notch=FALSE) + stat_compare_means(aes(label = "p.adj"), 
comparisons = my_comparisons, method = "t.test") + labs(x="BCAA conc 
(mM)", y="Km(mM)")

我收到错误消息“提供给连续刻度的离散值”。我已经尝试将 stat_compare_means 命令移动到代码中的其他“位置”,并且我还尝试了我在其他帖子中看到的回答类似问题的内容,将箱线图设置为对象,然后将 stat_compare_means 添加到它但沿着这些路线没有任何效果。有没有人知道我做错了什么?

标签: p-valueggpubr

解决方案


推荐阅读