This function adjusts p-values using a specified method and alpha level. It successively tests each method along with each alpha value, and if the sum is zero, it continues to the next method. Otherwise, it returns the subsetted dataframe.
A subsetted dataframe where the adjusted p-values are less than or equal to the corresponding alpha levels.
The function checks that the lengths of methods
and alpha
are equivalent and that all alpha values are in the range (0, 1). It iterates over the provided methods and alpha values, adjusting the p-values using the p.adjust
function from the stats
package. If the sum of selected values is greater than zero, it returns the subsetted dataframe.
# Example dataset
set.seed(123)
resdf <- data.frame(
p = runif(100, min = 0, max = 1)
)
# Example usage of adjust_p_values
adjusted_df <- adjust_p_values(resdf,
methods = c('BY', 'BH', 'none', 'none'),
alpha = c(0.05, 0.05, 0.05, 0.2))
head(adjusted_df)
#> [1] 0.0455564994 0.0420595335 0.0246136845 0.0458311667 0.0006247733