将Bonferroni应用于表中的每个p值

bvhaajcl  于 2023-02-17  发布在  其他
关注(0)|答案(1)|浏览(361)

我有一个小问题与调整Bonferroni对我的数据。这里是一个例子,我的数据:

structure(list(p_values = c(0.00551261839474566, 0.00909340979590469, 
+                                  0.42610555368556, 0.711610700326496, 0.00439218856215691, 0.859681237958105)), class = "data.frame", row.names = c("a","b","c","d","e","f"))

我通过Wilcoxon检验获得了这些p值,我想通过Bonferroni和Benjamin Hochberg调整对其进行调整。
我试过这个:但值永远不会改变:(

rf0->d. #base dataset from which I extracted the values, 1020 subjects and 156 features to test with one.
out <- lapply(3:158, function(x) pairwise.wilcox.test(d[[x]], d$LesionResponse,p.adjust.method="bonferroni")). #Applying the wilcoxon test to the 3->158 features with the "LesionResponse"
names(out) <- names(d)[3:158]
pvalue<-sapply(out, function(x) {
    p <- x$p.value
    n <- outer(rownames(p), colnames(p), paste, sep='v')
    p <- as.vector(p)
    names(p) <- n
    p
})
pvalue<-as.data.frame(pvalue)```

I must so adjust because It realized 1020 tests for each comparison...Unfortunately it changes nothing in comparison of the unadjusted values...
hgc7kmma

hgc7kmma1#

library(dplyr)
df |> 
  mutate(bonferroni = p.adjust(p_values, method="bonferroni"),
         hochberg = p.adjust(p_values, method="hochberg"))

输出:

p_values bonferroni   hochberg
a 0.005512618 0.03307571 0.02756309
b 0.009093410 0.05456046 0.03637364
c 0.426105554 1.00000000 0.85968124
d 0.711610700 1.00000000 0.85968124
e 0.004392189 0.02635313 0.02635313
f 0.859681238 1.00000000 0.85968124

相关问题