p-value and Boneferroni adjusted p-value the same in R
1
0
Entering edit mode
28 days ago

I'm analysing nearly 20k genes using r (code below) with Fisher's exact test but the adjusted p-value using Bonferroni correction is the same as the one that came out of the exact test, please can someone tell me where it has gone wrong?

I have saved p-values, odds ratio and adjusted p-values so that they can be presented as separate columns as well.

for (i in 1:nrow(RVAS_counts)) {
ctbl <- matrix(c(RVAS_counts[i, "cases"], RVAS_counts[i, "ctrls"], 
               ncases - RVAS_counts[i, "cases"], 
               nctrls - RVAS_counts[i, "ctrls"]),
               nrow = 2, byrow = FALSE)

ctable <- matrix(unlist(ctbl), 2)

fisher_result <- fisher.test(ctable, alternative="greater")

p_values[i] <- fisher_result$p.value
odds_ratios[i] <- fisher_result$estimate
adjusted_p_values[i] <- p.adjust(p_values[i], method = "bonferroni", n = leng(p_values[i]))
}

Any help is much appreciated.

Bonferroni R Statistics p-value Fisher • 324 views
ADD COMMENT
3
Entering edit mode
28 days ago

You need to adjust pvalues outside of the loop, for all genes at once. Otherwise it will adjust as if there were only 1 test (meaning no adjustment at all). Also there is usually no need to specify the n argument when using p.adjust(). So do something like this instead:

for (i in 1:nrow(RVAS_counts)) {
    ...
}

adjusted_p_values <- p.adjust(p_values, method = "bonferroni"))
ADD COMMENT
0
Entering edit mode

Works now! Thanks

ADD REPLY

Login before adding your answer.

Traffic: 1963 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6