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.

adjust_p_values(
  resdf,
  methods = c("BY", "BH", "none", "none"),
  alpha = c(0.05, 0.05, 0.05, 0.2)
)

Arguments

resdf

A data frame containing at least a column named p with p-values.

methods

A character vector specifying the methods for p-value adjustment. Default is c('BY', 'BH', 'none', 'none').

alpha

A numeric vector specifying the alpha levels for p-value adjustment. Default is c(0.05, 0.05, 0.05, 0.2).

Value

A subsetted dataframe where the adjusted p-values are less than or equal to the corresponding alpha levels.

Details

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.

Examples

# 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