generate.pvalues {DiscreteFDR} | R Documentation |
Generation of P-Values and Their Supports After Data Transformations
Description
Simple wrapper for generating p-values of discrete tests and their supports after pre-processing the input data. The user only has to provide 1.) a function that generates p-values and supports and 2.) an optional function that pre-processes (i.e. transforms) the input data (if necessary) before it can be used for p-value calculations. The respective arguments are provided by named lists.
Usage
generate.pvalues(
dat,
test.fun,
test.args = NULL,
preprocess.fun = NULL,
preprocess.args = NULL
)
Arguments
dat |
input data; must be suitable for the first parameter of the provided |
test.fun |
function from package |
test.args |
optional named list with arguments for |
preprocess.fun |
optional function for pre-processing the input |
preprocess.args |
optional named list with arguments for |
Value
A DiscreteTestResults R6 class object.
Examples
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 pre-processing
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 pre-processing
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
)