From aea26996f03067ff05ef8f074636aecf7f55bb2a Mon Sep 17 00:00:00 2001 From: Abinaya Yogasekaram <73252787+ayogasekaram@users.noreply.github.com> Date: Tue, 27 Feb 2024 09:17:25 -0500 Subject: [PATCH] reinstate ratet01 (#223) closes #221 --------- Co-authored-by: Emily de la Rua --- book/tables/efficacy/ratet01.qmd | 58 ++++++++++++++++++- package/DESCRIPTION | 4 +- .../testthat/_snaps/ratet01/markdown-snaps.md | 34 +++++++++++ 3 files changed, 93 insertions(+), 3 deletions(-) create mode 100644 package/tests/testthat/_snaps/ratet01/markdown-snaps.md diff --git a/book/tables/efficacy/ratet01.qmd b/book/tables/efficacy/ratet01.qmd index a59089735e..4e1d6fb85b 100644 --- a/book/tables/efficacy/ratet01.qmd +++ b/book/tables/efficacy/ratet01.qmd @@ -5,6 +5,8 @@ subtitle: Event Rate Summary for Recurrent Events ------------------------------------------------------------------------ +{{< include ../../test-utils/envir_hook.qmd >}} + This example will focus on data from a single visit "WEEK 1 DAY 8" and a single endpoint "FKSI-FWB". Only evaluable populations will be analyzed. @@ -29,9 +31,63 @@ anl <- df_explicit_na(anl) ## Customized Table ```{r variant1, test = list(result_v1 = "result")} -# Under development +lyt <- basic_table(show_colcounts = TRUE) %>% + split_cols_by("ARM", ref_group = "B: Placebo", split_fun = ref_group_position("first")) %>% + analyze_vars( + "AVAL_f", + var_labels = "Number of exacerbations per patient", + .stats = c("count_fraction"), + .formats = c("count_fraction" = "xx (xx.xx%)"), + .label = c("Number of exacerbations per patient") + ) %>% + summarize_glm_count( + vars = "AVAL", + variables = list(arm = "ARM", offset = "lgTMATRSK", covariates = NULL), + conf_level = 0.95, + distribution = "poisson", + rate_mean_method = "emmeans", + var_labels = "Unadjusted exacerbation rate (per year)", + table_names = "unadj", + .stats = c("rate"), + .labels = c(rate = "Rate") + ) %>% + summarize_glm_count( + vars = "AVAL", + variables = list(arm = "ARM", offset = "lgTMATRSK", covariates = c("REGION1")), + conf_level = 0.95, + distribution = "quasipoisson", + rate_mean_method = "ppmeans", + var_labels = "Adjusted (QP) exacerbation rate (per year)", + table_names = "adj-qp", + .stats = c("rate", "rate_ci", "rate_ratio", "rate_ratio_ci", "pval"), + .labels = c( + rate = "Rate", rate_ci = "Rate CI", rate_ratio = "Rate Ratio", + rate_ratio_ci = "Rate Ratio CI", pval = "p value" + ) + ) %>% + summarize_glm_count( + vars = "AVAL", + variables = list(arm = "ARM", offset = "lgTMATRSK", covariates = c("REGION1")), + conf_level = 0.95, + distribution = "negbin", + rate_mean_method = "emmeans", + var_labels = "Adjusted (NB) exacerbation rate (per year)", + table_names = "adj-nb", + .stats = c("rate", "rate_ci", "rate_ratio", "rate_ratio_ci", "pval"), + .labels = c( + rate = "Rate", rate_ci = "Rate CI", rate_ratio = "Rate Ratio", + rate_ratio_ci = "Rate Ratio CI", pval = "p value" + ) + ) +result <- build_table( + lyt = lyt, + df = anl +) +result ``` +{{< include ../../test-utils/save_results.qmd >}} + ## `teal` App ```{r teal, opts.label=c('skip_if_testing', 'app')} diff --git a/package/DESCRIPTION b/package/DESCRIPTION index b7c1fea4f1..c6f7497abf 100644 --- a/package/DESCRIPTION +++ b/package/DESCRIPTION @@ -36,10 +36,10 @@ Suggests: stringr, svglite (>= 2.1.2), teal (>= 0.14.0), - teal.modules.clinical (>= 0.8.16), + teal.modules.clinical (>= 0.9.0), teal.modules.general (>= 0.2.16), teal.transform (>= 0.5.0), - tern (>= 0.9.3), + tern (>= 0.9.3.9019), tern.mmrm (>= 0.3.0), tern.rbmi, testthat (>= 3.0.0), diff --git a/package/tests/testthat/_snaps/ratet01/markdown-snaps.md b/package/tests/testthat/_snaps/ratet01/markdown-snaps.md new file mode 100644 index 0000000000..c3293d7a9f --- /dev/null +++ b/package/tests/testthat/_snaps/ratet01/markdown-snaps.md @@ -0,0 +1,34 @@ +# result_v1 + + Code + print(data_snap[[i]]) + Output + B: Placebo A: Drug X C: Combination + (N=134) (N=134) (N=132) + ——————————————————————————————————————————————————————————————————————————————————————————————————— + Number of exacerbations per patient + 0 10 (7.46%) 6 (4.48%) 11 (8.33%) + 1 25 (18.66%) 21 (15.67%) 14 (10.61%) + 2 38 (28.36%) 41 (30.60%) 33 (25.00%) + 3 22 (16.42%) 26 (19.40%) 21 (15.91%) + 4 13 (9.70%) 18 (13.43%) 30 (22.73%) + 5 11 (8.21%) 10 (7.46%) 12 (9.09%) + 6 10 (7.46%) 7 (5.22%) 7 (5.30%) + 7 3 (2.24%) 4 (2.99%) 3 (2.27%) + 8 1 (0.75%) 1 (0.75%) 1 (0.76%) + 9 1 (0.75%) 0 (0.00%) 0 (0.00%) + Unadjusted exacerbation rate (per year) + Rate 7.2364 8.2148 9.8131 + Adjusted (QP) exacerbation rate (per year) + Rate 2.4550 2.8514 3.4304 + Rate CI (1.6194, 3.7219) (1.8974, 4.2850) (2.2946, 5.1284) + Rate Ratio 1.1615 1.3973 + Rate Ratio CI (0.6462, 2.0877) (0.7789, 2.5067) + p value 0.6169 0.2619 + Adjusted (NB) exacerbation rate (per year) + Rate 2.7374 2.8150 2.9789 + Rate CI (2.3932, 3.1311) (2.4681, 3.2106) (2.6152, 3.3932) + Rate Ratio 1.0283 1.0882 + Rate Ratio CI (0.8856, 1.1941) (0.9381, 1.2624) + p value 0.7140 0.2643 +