From 4c298eca90548a98399ba73a1fbc936dd651b1d7 Mon Sep 17 00:00:00 2001 From: CarlosEpiStats Date: Thu, 17 Sep 2026 12:33:34 +0000 Subject: [PATCH 1/2] Add two options for one-sided Fisher's test (favours verum or favours comparison) --- R/mod_calculate.R | 3 ++- R/mod_calculate_fct_data.R | 6 +++--- R/mod_calculate_fct_effect.R | 9 ++++++--- R/utils_helpers.R | 3 ++- man/calculate_results.Rd | 2 +- man/filter_minimum_aes.Rd | 4 ++-- man/find_min_event.Rd | 7 ++++++- 7 files changed, 22 insertions(+), 12 deletions(-) diff --git a/R/mod_calculate.R b/R/mod_calculate.R index 50191c5..7ce5826 100644 --- a/R/mod_calculate.R +++ b/R/mod_calculate.R @@ -313,7 +313,8 @@ mod_calculate_server <- function(id, r, calculate_mode) { } else if (input$stratified_by == "None") { choices <- list( "Two sided" = "two.sided", - "One sided" = "less" + "One sided (favours comparator)" = "greater", + "One sided (favours verum)" = "less" ) } shiny::updateSelectInput( diff --git a/R/mod_calculate_fct_data.R b/R/mod_calculate_fct_data.R index 4bfce16..1d86fbd 100644 --- a/R/mod_calculate_fct_data.R +++ b/R/mod_calculate_fct_data.R @@ -39,7 +39,7 @@ calculate_results <- function( adjustment = c("FDR", "DFDR"), order_by = c("p-value", "effect"), study_strat = "None", - alternative = c("two.sided", "less"), + alternative = c("two.sided", "less", "greater"), alpha = 0.05, filter = c("no_method", "one_percent", "min"), frequency_measure = c("proportions", "incidence rates"), @@ -232,7 +232,7 @@ filter_empty_variable <- function(data, variable) { #' @param method A character, the method of filtering: "no_method", #' "one_percent" or "min". "min" calls find_min_event() #' @param alternative A character describing the alternative hypothesis for -#' "min" method: "two.sided" or "less" (one-sided) +#' "min" method: "two.sided", "less" or "greater" (one-sided) #' @param alpha Numeric, alpha level of the test for "min" method. #' #' @returns A dataframe of filtered adverse events. @@ -241,7 +241,7 @@ filter_minimum_aes <- function( variable, big_n, method = c("no_method", "one_percent", "min"), - alternative = c("two.sided", "less"), + alternative = c("two.sided", "less", "greater"), alpha ) { filter <- match.arg(method) diff --git a/R/mod_calculate_fct_effect.R b/R/mod_calculate_fct_effect.R index eda6350..276ea4b 100644 --- a/R/mod_calculate_fct_effect.R +++ b/R/mod_calculate_fct_effect.R @@ -320,8 +320,11 @@ get_rr <- function( #' #' @returns A numeric vector with p-values get_fisher_p_value <- function(a, b, c, d, alternative) { - stats::fisher.test( - matrix(c(a, b, c, d), nrow = 2), + #TODO: remove + matrix <- matrix(c(a, b, c, d), nrow = 2) + out <- stats::fisher.test( + matrix, alternative = alternative - )$p.value + ) + out$p.value } diff --git a/R/utils_helpers.R b/R/utils_helpers.R index ca921c3..2abc412 100644 --- a/R/utils_helpers.R +++ b/R/utils_helpers.R @@ -10,10 +10,11 @@ find_min_event <- function( n1, n2, - alternative = c("two.sided", "less"), + alternative = c("two.sided", "less", "greater"), alpha = 0.05 ) { alternative <- match.arg(alternative) + alternative <- if (alternative == "greater") "less" else alternative # Create a numeric vectors of events, to try which yields significant results if (n1 < 1000) { x1 <- seq(1, round(0.1 * n1, 0), 1) diff --git a/man/calculate_results.Rd b/man/calculate_results.Rd index f0fab8c..379c164 100644 --- a/man/calculate_results.Rd +++ b/man/calculate_results.Rd @@ -12,7 +12,7 @@ calculate_results( adjustment = c("FDR", "DFDR"), order_by = c("p-value", "effect"), study_strat = "None", - alternative = c("two.sided", "less"), + alternative = c("two.sided", "less", "greater"), alpha = 0.05, filter = c("no_method", "one_percent", "min"), frequency_measure = c("proportions", "incidence rates"), diff --git a/man/filter_minimum_aes.Rd b/man/filter_minimum_aes.Rd index 794a8ca..c7c2011 100644 --- a/man/filter_minimum_aes.Rd +++ b/man/filter_minimum_aes.Rd @@ -9,7 +9,7 @@ filter_minimum_aes( variable, big_n, method = c("no_method", "one_percent", "min"), - alternative = c("two.sided", "less"), + alternative = c("two.sided", "less", "greater"), alpha ) } @@ -25,7 +25,7 @@ treatment arm.} "one_percent" or "min". "min" calls find_min_event()} \item{alternative}{A character describing the alternative hypothesis for -"min" method: "two.sided" or "less" (one-sided)} +"min" method: "two.sided", "less" or "greater" (one-sided)} \item{alpha}{Numeric, alpha level of the test for "min" method.} } diff --git a/man/find_min_event.Rd b/man/find_min_event.Rd index ec005b4..38a5fd3 100644 --- a/man/find_min_event.Rd +++ b/man/find_min_event.Rd @@ -4,7 +4,12 @@ \alias{find_min_event} \title{Calculate the minimum number of events in verum} \usage{ -find_min_event(n1, n2, alternative = c("two.sided", "less"), alpha = 0.05) +find_min_event( + n1, + n2, + alternative = c("two.sided", "less", "greater"), + alpha = 0.05 +) } \arguments{ \item{n1}{Number of patients in Verum} From 0110893a78dc796ff71a287586663ada2b006a4a Mon Sep 17 00:00:00 2001 From: CarlosEpiStats Date: Mon, 21 Sep 2026 09:10:46 +0000 Subject: [PATCH 2/2] Increment version number to 3.0.1.9007 --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 4d86b4b..59d1564 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: DetectoR Title: Stay Safe; Don't Miss Any Adverse-Event Signal -Version: 3.0.1.9006 +Version: 3.0.1.9007 Authors@R: c( person("Carlos", "Fernandez-Escobar", , "carlos.fernandez4.ext@bayer.com", role = c("aut", "cre")), person("Steffen", "Jeske", role = "aut"),