From 6707a09a6f2891435620069d9d08936e52e5b96f Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Mon, 22 Jan 2024 15:00:24 -0500 Subject: [PATCH 1/6] Remove g_forest tests --- tests/testthat/_snaps/table_fstg01/v1.svg | 152 --------------------- tests/testthat/_snaps/table_fstg01/v2.svg | 152 --------------------- tests/testthat/_snaps/table_fstg01/v3.svg | 106 --------------- tests/testthat/_snaps/table_fstg01/v4.svg | 152 --------------------- tests/testthat/_snaps/table_fstg01/v5.svg | 152 --------------------- tests/testthat/_snaps/table_fstg02.md | 68 ---------- tests/testthat/_snaps/table_fstg02/v1.svg | 138 ------------------- tests/testthat/_snaps/table_fstg02/v2.svg | 138 ------------------- tests/testthat/_snaps/table_fstg02/v3.svg | 106 --------------- tests/testthat/_snaps/table_fstg02/v4.svg | 138 ------------------- tests/testthat/test-table_fstg01.R | 155 ---------------------- tests/testthat/test-table_fstg02.R | 138 ------------------- 12 files changed, 1595 deletions(-) delete mode 100644 tests/testthat/_snaps/table_fstg01/v1.svg delete mode 100644 tests/testthat/_snaps/table_fstg01/v2.svg delete mode 100644 tests/testthat/_snaps/table_fstg01/v3.svg delete mode 100644 tests/testthat/_snaps/table_fstg01/v4.svg delete mode 100644 tests/testthat/_snaps/table_fstg01/v5.svg delete mode 100644 tests/testthat/_snaps/table_fstg02.md delete mode 100644 tests/testthat/_snaps/table_fstg02/v1.svg delete mode 100644 tests/testthat/_snaps/table_fstg02/v2.svg delete mode 100644 tests/testthat/_snaps/table_fstg02/v3.svg delete mode 100644 tests/testthat/_snaps/table_fstg02/v4.svg delete mode 100644 tests/testthat/test-table_fstg01.R delete mode 100644 tests/testthat/test-table_fstg02.R diff --git a/tests/testthat/_snaps/table_fstg01/v1.svg b/tests/testthat/_snaps/table_fstg01/v1.svg deleted file mode 100644 index b12e73f1..00000000 --- a/tests/testthat/_snaps/table_fstg01/v1.svg +++ /dev/null @@ -1,152 +0,0 @@ - - - - - - - - - - - - - - - - - - - - -B: Placebo - -A: Drug X - -Baseline Risk Factors -All Patients -Sex - F - M -Categorical Level Biomarker 2 - LOW - MEDIUM - HIGH -Total n -268 -161 -107 -95 -93 -80 -n -134 -82 -52 -45 -56 -33 -Responders -84 -48 -36 -30 -34 -20 -Response (%) -62.7% -58.5% -69.2% -66.7% -60.7% -60.6% -n -134 -79 -55 -50 -37 -47 -Responders -100 -61 -39 -39 -27 -34 -Response (%) -74.6% -77.2% -70.9% -78.0% -73.0% -72.3% -Odds Ratio -1.76 -2.45 -1.08 -1.77 -1.73 -1.73 -95% CI -(1.04, 2.97) -(1.23, 4.86) -(0.48, 2.46) -(0.71, 4.39) -(0.71, 4.22) -(0.67, 4.44) - - - - - - - - - - - - - - - - - - - - -B: Placebo -Better -A: Drug X -Better - - - - - - - - - - - - - - - - -0.1 -1 -10 - - diff --git a/tests/testthat/_snaps/table_fstg01/v2.svg b/tests/testthat/_snaps/table_fstg01/v2.svg deleted file mode 100644 index 01956296..00000000 --- a/tests/testthat/_snaps/table_fstg01/v2.svg +++ /dev/null @@ -1,152 +0,0 @@ - - - - - - - - - - - - - - - - - - - - -ARM B - -ARM A/ARM C - -Baseline Risk Factors -All Patients -Sex - M - F -Categorical Level Biomarker 2 - LOW - MEDIUM - HIGH -Total n -400 -169 -231 -135 -135 -130 -n -134 -52 -82 -45 -56 -33 -Responders -84 -36 -48 -30 -34 -20 -Response (%) -62.7% -69.2% -58.5% -66.7% -60.7% -60.6% -n -266 -117 -149 -90 -79 -97 -Responders -181 -78 -103 -64 -51 -66 -Response (%) -68.0% -66.7% -69.1% -71.1% -64.6% -68.0% -Odds Ratio -1.27 -0.89 -1.57 -1.21 -1.20 -1.39 -95% CI -(0.82, 1.96) -(0.44, 1.80) -(0.90, 2.75) -(0.56, 2.61) -(0.59, 2.44) -(0.61, 3.13) - - - - - - - - - - - - - - - - - - - - -ARM B -Better -ARM A/ARM C -Better - - - - - - - - - - - - - - - - -0.1 -1 -10 - - diff --git a/tests/testthat/_snaps/table_fstg01/v3.svg b/tests/testthat/_snaps/table_fstg01/v3.svg deleted file mode 100644 index e89b1e4b..00000000 --- a/tests/testthat/_snaps/table_fstg01/v3.svg +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - - - - - - - - - - - - - - - -Baseline Risk Factors -All Patients -Sex - F - M -Categorical Level Biomarker 2 - LOW - MEDIUM - HIGH -Total n -268 -161 -107 -95 -93 -80 -Odds Ratio -1.76 -2.45 -1.08 -1.77 -1.73 -1.73 -90% CI -(1.13, 2.73) -(1.38, 4.36) -(0.54, 2.15) -(0.83, 3.79) -(0.82, 3.66) -(0.78, 3.81) - - - - - - - - - - - - - - - - - - - - -B: Placebo -Better -A: Drug X -Better - - - - - - - - - - - - - - - - -0.1 -1 -10 - - diff --git a/tests/testthat/_snaps/table_fstg01/v4.svg b/tests/testthat/_snaps/table_fstg01/v4.svg deleted file mode 100644 index 5b0efc10..00000000 --- a/tests/testthat/_snaps/table_fstg01/v4.svg +++ /dev/null @@ -1,152 +0,0 @@ - - - - - - - - - - - - - - - - - - - - -B: Placebo - -A: Drug X - -Baseline Risk Factors -All Patients -Sex - F - M -Categorical Level Biomarker 2 - LOW - MEDIUM - HIGH -Total n -268 -161 -107 -95 -93 -80 -n -134 -82 -52 -45 -56 -33 -Responders -84 -48 -36 -30 -34 -20 -Response (%) -62.7% -58.5% -69.2% -66.7% -60.7% -60.6% -n -134 -79 -55 -50 -37 -47 -Responders -100 -61 -39 -39 -27 -34 -Response (%) -74.6% -77.2% -70.9% -78.0% -73.0% -72.3% -Odds Ratio -1.76 -2.45 -1.08 -1.77 -1.73 -1.73 -95% CI -(1.04, 2.97) -(1.23, 4.86) -(0.48, 2.46) -(0.71, 4.39) -(0.71, 4.22) -(0.67, 4.44) - - - - - - - - - - - - - - - - - - - - -B: Placebo -Better -A: Drug X -Better - - - - - - - - - - - - - - - - -0.1 -1 -10 - - diff --git a/tests/testthat/_snaps/table_fstg01/v5.svg b/tests/testthat/_snaps/table_fstg01/v5.svg deleted file mode 100644 index 3365a760..00000000 --- a/tests/testthat/_snaps/table_fstg01/v5.svg +++ /dev/null @@ -1,152 +0,0 @@ - - - - - - - - - - - - - - - - - - - - -B: Placebo - -A: Drug X - -Baseline Risk Factors -All Patients -Sex - F - M -Categorical Level Biomarker 2 - LOW - MEDIUM - HIGH -Total n -268 -161 -107 -95 -93 -80 -n -134 -82 -52 -45 -56 -33 -Responders -47 -25 -22 -21 -16 -10 -Response (%) -35.1% -30.5% -42.3% -46.7% -28.6% -30.3% -n -134 -79 -55 -50 -37 -47 -Responders -60 -39 -21 -27 -19 -14 -Response (%) -44.8% -49.4% -38.2% -54.0% -51.4% -29.8% -Odds Ratio -1.52 -2.32 -0.84 -1.43 -2.60 -0.99 -95% CI -(0.93, 2.48) -(1.21, 4.45) -(0.39, 1.82) -(0.63, 3.24) -(1.10, 6.16) -(0.38, 2.57) - - - - - - - - - - - - - - - - - - - - -B: Placebo -Better -A: Drug X -Better - - - - - - - - - - - - - - - - -0.1 -1 -10 - - diff --git a/tests/testthat/_snaps/table_fstg02.md b/tests/testthat/_snaps/table_fstg02.md deleted file mode 100644 index a1cb59f1..00000000 --- a/tests/testthat/_snaps/table_fstg02.md +++ /dev/null @@ -1,68 +0,0 @@ -# FSTG02 table variant 1 (Subgroup Analysis of Survival Duration) is produced correctly - - Code - res - Output - B: Placebo A: Drug X - Baseline Risk Factors Total n n Median (Months) n Median (Months) Hazard Ratio 95% Wald CI - ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— - All Patients 268 134 NA 134 NA 1.00 (0.69, 1.44) - Sex - F 161 82 NA 79 NA 0.79 (0.49, 1.28) - M 107 52 NA 55 9.6 1.39 (0.78, 2.47) - Categorical Level Biomarker 2 - LOW 95 45 NA 50 9.3 1.14 (0.64, 2.02) - MEDIUM 93 56 NA 37 NA 0.97 (0.52, 1.82) - HIGH 80 33 NA 47 NA 0.97 (0.45, 2.12) - -# FSTG02 table variant 2 (specifying class variables and options for the treatment variable) - - Code - res - Output - Placebo Drug X - Baseline Risk Factors Total n n Median (Months) n Median (Months) Hazard Ratio 95% Wald CI - ——————————————————————————————————————————————————————————————————————————————————————————————————————————————— - All Patients 268 134 NA 134 NA 1.00 (0.69, 1.44) - Sex - M 107 52 NA 55 9.6 1.39 (0.78, 2.47) - F 161 82 NA 79 NA 0.79 (0.49, 1.28) - Stratification Factor 1 - C 94 45 NA 49 NA 0.75 (0.41, 1.38) - B 92 45 NA 47 NA 1.34 (0.71, 2.54) - A 82 44 NA 38 NA 1.02 (0.53, 1.97) - -# FSTG02 table variant 3 (selecting columns and changing the alpha level) - - Code - res - Output - - Baseline Risk Factors Total n Hazard Ratio 90% Wald CI - ————————————————————————————————————————————————————————————————————— - All Patients 268 1.00 (0.74, 1.36) - Sex - F 161 0.79 (0.53, 1.19) - M 107 1.39 (0.86, 2.25) - Categorical Level Biomarker 2 - LOW 95 1.14 (0.71, 1.84) - MEDIUM 93 0.97 (0.58, 1.64) - HIGH 80 0.97 (0.51, 1.87) - -# FSTG02 table variant 4 (fixed symbol size) is produced correctly - - Code - res - Output - B: Placebo A: Drug X - Baseline Risk Factors Total n n Median (Months) n Median (Months) Hazard Ratio 95% Wald CI - ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— - All Patients 268 134 NA 134 NA 1.00 (0.69, 1.44) - Sex - F 161 82 NA 79 NA 0.79 (0.49, 1.28) - M 107 52 NA 55 9.6 1.39 (0.78, 2.47) - Categorical Level Biomarker 2 - LOW 95 45 NA 50 9.3 1.14 (0.64, 2.02) - MEDIUM 93 56 NA 37 NA 0.97 (0.52, 1.82) - HIGH 80 33 NA 47 NA 0.97 (0.45, 2.12) - diff --git a/tests/testthat/_snaps/table_fstg02/v1.svg b/tests/testthat/_snaps/table_fstg02/v1.svg deleted file mode 100644 index 6b695009..00000000 --- a/tests/testthat/_snaps/table_fstg02/v1.svg +++ /dev/null @@ -1,138 +0,0 @@ - - - - - - - - - - - - - - - - - - - - -B: Placebo - -A: Drug X - -Baseline Risk Factors -All Patients -Sex - F - M -Categorical Level Biomarker 2 - LOW - MEDIUM - HIGH -Total n -268 -161 -107 -95 -93 -80 -n -134 -82 -52 -45 -56 -33 -Median (Months) -NA -NA -NA -NA -NA -NA -n -134 -79 -55 -50 -37 -47 -Median (Months) -NA -NA -9.6 -9.3 -NA -NA -Hazard Ratio -1.00 -0.79 -1.39 -1.14 -0.97 -0.97 -95% Wald CI -(0.69, 1.44) -(0.49, 1.28) -(0.78, 2.47) -(0.64, 2.02) -(0.52, 1.82) -(0.45, 2.12) - - - - - - - - - - - - - - - - - - - - -A: Drug X -Better -B: Placebo -Better - - - - - - - - - - - - - - - - -0.1 -1 -10 - - diff --git a/tests/testthat/_snaps/table_fstg02/v2.svg b/tests/testthat/_snaps/table_fstg02/v2.svg deleted file mode 100644 index ddb92239..00000000 --- a/tests/testthat/_snaps/table_fstg02/v2.svg +++ /dev/null @@ -1,138 +0,0 @@ - - - - - - - - - - - - - - - - - - - - -Placebo - -Drug X - -Baseline Risk Factors -All Patients -Sex - M - F -Stratification Factor 1 - C - B - A -Total n -268 -107 -161 -94 -92 -82 -n -134 -52 -82 -45 -45 -44 -Median (Months) -NA -NA -NA -NA -NA -NA -n -134 -55 -79 -49 -47 -38 -Median (Months) -NA -9.6 -NA -NA -NA -NA -Hazard Ratio -1.00 -1.39 -0.79 -0.75 -1.34 -1.02 -95% Wald CI -(0.69, 1.44) -(0.78, 2.47) -(0.49, 1.28) -(0.41, 1.38) -(0.71, 2.54) -(0.53, 1.97) - - - - - - - - - - - - - - - - - - - - -Drug X -Better -Placebo -Better - - - - - - - - - - - - - - - - -0.1 -1 -10 - - diff --git a/tests/testthat/_snaps/table_fstg02/v3.svg b/tests/testthat/_snaps/table_fstg02/v3.svg deleted file mode 100644 index 216fba5f..00000000 --- a/tests/testthat/_snaps/table_fstg02/v3.svg +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - - - - - - - - - - - - - - - -Baseline Risk Factors -All Patients -Sex - F - M -Categorical Level Biomarker 2 - LOW - MEDIUM - HIGH -Total n -268 -161 -107 -95 -93 -80 -Hazard Ratio -1.00 -0.79 -1.39 -1.14 -0.97 -0.97 -90% Wald CI -(0.74, 1.36) -(0.53, 1.19) -(0.86, 2.25) -(0.71, 1.84) -(0.58, 1.64) -(0.51, 1.87) - - - - - - - - - - - - - - - - - - - - -A: Drug X -Better -B: Placebo -Better - - - - - - - - - - - - - - - - -0.1 -1 -10 - - diff --git a/tests/testthat/_snaps/table_fstg02/v4.svg b/tests/testthat/_snaps/table_fstg02/v4.svg deleted file mode 100644 index 6b695009..00000000 --- a/tests/testthat/_snaps/table_fstg02/v4.svg +++ /dev/null @@ -1,138 +0,0 @@ - - - - - - - - - - - - - - - - - - - - -B: Placebo - -A: Drug X - -Baseline Risk Factors -All Patients -Sex - F - M -Categorical Level Biomarker 2 - LOW - MEDIUM - HIGH -Total n -268 -161 -107 -95 -93 -80 -n -134 -82 -52 -45 -56 -33 -Median (Months) -NA -NA -NA -NA -NA -NA -n -134 -79 -55 -50 -37 -47 -Median (Months) -NA -NA -9.6 -9.3 -NA -NA -Hazard Ratio -1.00 -0.79 -1.39 -1.14 -0.97 -0.97 -95% Wald CI -(0.69, 1.44) -(0.49, 1.28) -(0.78, 2.47) -(0.64, 2.02) -(0.52, 1.82) -(0.45, 2.12) - - - - - - - - - - - - - - - - - - - - -A: Drug X -Better -B: Placebo -Better - - - - - - - - - - - - - - - - -0.1 -1 -10 - - diff --git a/tests/testthat/test-table_fstg01.R b/tests/testthat/test-table_fstg01.R deleted file mode 100644 index c6f0c26a..00000000 --- a/tests/testthat/test-table_fstg01.R +++ /dev/null @@ -1,155 +0,0 @@ -adsl_f <- adsl_raw %>% - select(STUDYID, USUBJID, ARMCD, ARM, SEX, BMRKR2, STRATA1, STRATA2) - -adrs_f <- adrs_raw %>% - filter(PARAMCD == "INVET") %>% - select(STUDYID, USUBJID, PARAMCD, AVISIT, AVALC) - -anl <- inner_join(adsl_f, adrs_f, by = c("STUDYID", "USUBJID")) -anl <- df_explicit_na(anl) -anl_labels <- var_labels(anl) - -anl_rsp_arms_ab <- anl %>% - mutate(is_rsp = AVALC %in% c("CR", "PR")) %>% - filter(ARMCD %in% c("ARM B", "ARM A")) %>% - mutate( - ARMCD = relevel(ARMCD, ref = "ARM B") %>% - droplevels(), - ARM = relevel(ARM, ref = "B: Placebo") %>% - droplevels() - ) %>% - droplevels() -var_labels(anl_rsp_arms_ab) <- c(anl_labels, is_rsp = "Is Responder") - -testthat::test_that("FSTG01 variant 1 is produced correctly", { - df <- extract_rsp_subgroups( - variables = list( - rsp = "is_rsp", - arm = "ARM", - subgroups = c("SEX", "BMRKR2"), - strata_var = "STRATA2" - ), - data = anl_rsp_arms_ab, - conf_level = 0.95 - ) - - result <- basic_table() %>% - tabulate_rsp_subgroups(df, vars = c("n_tot", "n", "n_rsp", "prop", "or", "ci")) - - v1 <- g_forest(tbl = result) - - expect_snapshot_ggplot("v1", v1, width = 15, height = 5) -}) - -testthat::test_that("FSTG01 variant 2 is produced correctly", { - anl_rsp_comb_arms_ac <- anl %>% - mutate(is_rsp = AVALC %in% c("CR", "PR")) %>% - filter(ARMCD %in% c("ARM B", "ARM A", "ARM C")) %>% - mutate( - ARMCD = relevel(ARMCD, ref = "ARM B") %>% - droplevels() %>% - combine_levels(levels = c("ARM A", "ARM C")), - ARM = relevel(ARM, ref = "B: Placebo") %>% - droplevels() %>% - combine_levels(levels = c("A: Drug X", "C: Combination")), - # reorder levels of SEX - SEX = forcats::fct_relevel(SEX, "M", "F"), - # reorder levels of STRATA1 by frequency - STRATA1 = forcats::fct_infreq(STRATA1) - ) %>% - droplevels() - var_labels(anl_rsp_comb_arms_ac) <- c(anl_labels, is_rsp = "Is Responder") - - df <- extract_rsp_subgroups( - variables = list( - rsp = "is_rsp", - arm = "ARMCD", - subgroups = c("SEX", "BMRKR2"), - strata_var = "STRATA2" - ), - data = anl_rsp_comb_arms_ac, - conf_level = 0.95 - ) - - result <- basic_table() %>% - tabulate_rsp_subgroups(df, vars = c("n_tot", "n", "n_rsp", "prop", "or", "ci")) - - v2 <- g_forest(tbl = result) - - expect_snapshot_ggplot("v2", v2, width = 15, height = 5) -}) - -testthat::test_that("FSTG01 variant 3 is produced correctly", { - df <- extract_rsp_subgroups( - variables = list( - rsp = "is_rsp", - arm = "ARM", - subgroups = c("SEX", "BMRKR2"), - strata_var = "STRATA2" - ), - data = anl_rsp_arms_ab, - conf_level = 0.90 - ) - - result <- basic_table() %>% - tabulate_rsp_subgroups(df, vars = c("n_tot", "or", "ci")) - - v3 <- g_forest(tbl = result) - - expect_snapshot_ggplot("v3", v3, width = 10, height = 3) -}) - -testthat::test_that("FSTG01 variant 4 is produced correctly", { - df <- extract_rsp_subgroups( - variables = list( - rsp = "is_rsp", - arm = "ARM", - subgroups = c("SEX", "BMRKR2"), - strata_var = "STRATA2" - ), - data = anl_rsp_arms_ab, - conf_level = 0.95 - ) - - result <- basic_table() %>% - tabulate_rsp_subgroups(df, vars = c("n_tot", "n", "n_rsp", "prop", "or", "ci")) - - v4 <- g_forest( - tbl = result, - col_symbol_size = NULL - ) - - expect_snapshot_ggplot("v4", v4, width = 20, height = 5) -}) - -testthat::test_that("FSTG01 variant 5 is produced correctly", { - anl_cr_arms_ab <- anl %>% - mutate(is_rsp = AVALC == "CR") %>% - filter(ARMCD %in% c("ARM B", "ARM A")) %>% - mutate( - ARMCD = relevel(ARMCD, ref = "ARM B") %>% - droplevels(), - ARM = relevel(ARM, ref = "B: Placebo") %>% - droplevels() - ) %>% - droplevels() - var_labels(anl_cr_arms_ab) <- c(anl_labels, is_rsp = "Is CR") - - df <- extract_rsp_subgroups( - variables = list( - rsp = "is_rsp", - arm = "ARM", - subgroups = c("SEX", "BMRKR2"), - strata_var = "STRATA2" - ), - data = anl_cr_arms_ab, - conf_level = 0.95 - ) - - result <- basic_table() %>% - tabulate_rsp_subgroups(df, vars = c("n_tot", "n", "n_rsp", "prop", "or", "ci")) - - v5 <- g_forest(tbl = result) - - expect_snapshot_ggplot("v5", v5, width = 20, height = 5) -}) diff --git a/tests/testthat/test-table_fstg02.R b/tests/testthat/test-table_fstg02.R deleted file mode 100644 index cfbd4c04..00000000 --- a/tests/testthat/test-table_fstg02.R +++ /dev/null @@ -1,138 +0,0 @@ -preprocess_adtte <- function(adtte) { - # Save variable labels before data processing steps. - adtte_labels <- formatters::var_labels(adtte) - - adtte_mod <- adtte %>% - dplyr::filter( - PARAMCD == "OS", - ARM %in% c("B: Placebo", "A: Drug X"), - SEX %in% c("M", "F") - ) %>% - dplyr::mutate( - # Reorder levels of ARM to display reference arm before treatment arm. - ARM = droplevels(forcats::fct_relevel(ARM, "B: Placebo")), - SEX = droplevels(SEX), - is_event = CNSR == 0, - # Convert time to MONTH - AVAL = day2month(AVAL), - AVALU = "Months" - ) - - reapply_varlabels(adtte_mod, adtte_labels, AVAL = adtte_labels["AVAL"]) -} - -adtte_local <- adtte_raw %>% - preprocess_adtte() - -testthat::test_that("FSTG02 table variant 1 (Subgroup Analysis of Survival Duration) is produced correctly", { - anl1 <- adtte_local - - df <- extract_survival_subgroups( - variables = list(tte = "AVAL", is_event = "is_event", arm = "ARM", subgroups = c("SEX", "BMRKR2")), - data = anl1 - ) - - result <- basic_table() %>% - tabulate_survival_subgroups( - df = df, - vars = c("n_tot", "n", "median", "hr", "ci"), - time_unit = anl1$AVALU[1] - ) - - res <- testthat::expect_silent(result) - testthat::expect_snapshot(res) - - # Add plot. - v1 <- g_forest(tbl = result) - - expect_snapshot_ggplot("v1", v1, width = 15, height = 5) -}) - -testthat::test_that("FSTG02 table variant 2 (specifying class variables and options for the treatment variable)", { - anl2 <- adtte_local %>% - dplyr::mutate( - # Recode levels of arm. - ARM = forcats::fct_recode( - ARM, - "Placebo" = "B: Placebo", - "Drug X" = "A: Drug X" - ), - # Reorder levels of `SEX`. - SEX = forcats::fct_relevel(SEX, "M", "F"), - # Reorder levels of `STRATA1`` by frequency. - STRATA1 = forcats::fct_infreq(STRATA1) - ) - - df <- extract_survival_subgroups( - variables = list(tte = "AVAL", is_event = "is_event", arm = "ARM", subgroups = c("SEX", "STRATA1")), - data = anl2 - ) - - result <- basic_table() %>% - tabulate_survival_subgroups( - df = df, - vars = c("n_tot", "n", "median", "hr", "ci"), - time_unit = anl2$AVALU[1] - ) - - res <- testthat::expect_silent(result) - testthat::expect_snapshot(res) - - # Add plot. - v2 <- g_forest(tbl = result) - - expect_snapshot_ggplot("v2", v2, width = 15, height = 5) -}) - -testthat::test_that("FSTG02 table variant 3 (selecting columns and changing the alpha level)", { - anl3 <- adtte_local - - df <- extract_survival_subgroups( - variables = list(tte = "AVAL", is_event = "is_event", arm = "ARM", subgroups = c("SEX", "BMRKR2")), - control = control_coxph(conf_level = 0.9), - data = anl3 - ) - - result <- basic_table() %>% - tabulate_survival_subgroups( - df = df, - vars = c("n_tot", "hr", "ci") - ) - - res <- testthat::expect_silent(result) - testthat::expect_snapshot(res) - - # Add plot. - v3 <- g_forest(tbl = result) - - expect_snapshot_ggplot("v3", v3, width = 10, height = 5) -}) - -testthat::test_that("FSTG02 table variant 4 (fixed symbol size) is produced correctly", { - anl4 <- adtte_local - - df <- extract_survival_subgroups( - variables = list( - tte = "AVAL", - is_event = "is_event", - arm = "ARM", - subgroups = c("SEX", "BMRKR2") - ), - data = anl4 - ) - - result <- basic_table() %>% - tabulate_survival_subgroups( - df = df, - vars = c("n_tot", "n", "median", "hr", "ci"), - time_unit = anl4$AVALU[1] - ) - - res <- testthat::expect_silent(result) - testthat::expect_snapshot(res) - - # Add plot. - v4 <- g_forest(tbl = result) - - expect_snapshot_ggplot("v4", v4, width = 15, height = 5) -}) From d157fbd63a87565566430513fdcebe6a2d053b33 Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Mon, 22 Jan 2024 15:00:33 -0500 Subject: [PATCH 2/6] Update tern version --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 4425968c..09a3049c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -25,7 +25,7 @@ Depends: R (>= 4.2), rlistings (>= 0.2.7), rtables (>= 0.6.6), - tern (>= 0.9.3.9002) + tern (>= 0.9.3) Imports: pharmaverseadam (>= 0.2.0), random.cdisc.data (>= 0.3.14.9002) From b9831aa7bc73c12bde1565ae348fb13720364538 Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Mon, 22 Jan 2024 15:03:22 -0500 Subject: [PATCH 3/6] Remove extra dependencies --- DESCRIPTION | 2 -- 1 file changed, 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 09a3049c..f20f9e69 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -34,11 +34,9 @@ Suggests: checkmate, dplyr, forcats, - ggplot2 (>= 3.4.0), knitr, lubridate, stringr, - svglite (>= 2.1.2), testthat (>= 3.0), tibble, tidyr From e9a07b28d2e922fa17cea46e6d7fd5953b83d7d8 Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 22 Jan 2024 20:10:12 +0000 Subject: [PATCH 4/6] [skip actions] Roxygen Man Pages Auto Update --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index f20f9e69..5aa59a63 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -49,4 +49,4 @@ Encoding: UTF-8 Language: en-US LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.0 From b699ffa4f1e33f8e225190ad4d143f808e51a5dd Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Mon, 22 Jan 2024 15:12:11 -0500 Subject: [PATCH 5/6] Empty commit From 4230506a4a2ad0223817bacdc2668f1034904488 Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Mon, 22 Jan 2024 15:53:12 -0500 Subject: [PATCH 6/6] Revert changes --- tests/testthat/setup.R | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R index 072435f3..bf6a011a 100644 --- a/tests/testthat/setup.R +++ b/tests/testthat/setup.R @@ -50,16 +50,3 @@ skip_if_too_deep <- function(depth) { # nolintr testthat::skip(paste("testing depth", testing_depth, "is below current testing specification", depth)) } } - -# expect_snapshot_ggplot - set custom plot dimensions -expect_snapshot_ggplot <- function(title, fig, width = NA, height = NA) { - skip_if_not_installed("svglite") - - name <- paste0(title, ".svg") - path <- tempdir() - suppressMessages(ggplot2::ggsave(name, fig, path = path, width = width, height = height)) - path <- file.path(path, name) - - testthat::announce_snapshot_file(name = name) - testthat::expect_snapshot_file(path, name) -}