X1 <- c(4, 2, 2, 14, 6, 9, 4, 0, 1)
X2 <- c(0, 0, 1, 3, 2, 1, 2, 2, 2)
N1 <- rep(148, 9)
N2 <- rep(132, 9)
Y1 <- N1 - X1
Y2 <- N2 - X2
df <- data.frame(X1, Y1, X2, Y2)
df
# Compute p-values and their supports of Fisher's exact test
test.result <- generate.pvalues(df, "fisher")
raw.pvalues <- test.result$get_pvalues()
pCDFlist <- test.result$get_pvalue_supports()
# Compute p-values and their supports of Fisher's exact test
# with preprocessing
df2 <- data.frame(X1, N1, X2, N2)
generate.pvalues(
dat = df2,
test.fun = "fisher_test_pv",
preprocess.fun = function(tab) {
for(col in c(2, 4)) tab[, col] <- tab[, col] - tab[, col - 1]
return(tab)
}
)
# Compute p-values and their supports of a binomial test with preprocessing
generate.pvalues(
dat = rbind(c(5, 2, 7), c(3, 4, 0)),
test.fun = "binom_test_pv",
test.args = list(n = c(9, 8, 11), p = 0.6, alternative = "two.sided"),
preprocess.fun = colSums
)
Run the code above in your browser using DataLab