diff --git a/book/tables/ADA/adat01.qmd b/book/tables/ADA/adat01.qmd index 87e31a723f..aac96b31c5 100644 --- a/book/tables/ADA/adat01.qmd +++ b/book/tables/ADA/adat01.qmd @@ -20,12 +20,32 @@ library(tibble) adsl <- random.cdisc.data::cadsl adab <- random.cdisc.data::cadab -combodf <- tribble( - ~valname, ~label, ~levelcombo, ~exargs, - "all_X", "All Drug X", c("A: Drug X", "C: Combination"), list(), - "all_pt", "All Patients", c("A: Drug X", "B: Placebo", "C: Combination"), list() +# Order needed for the columns is c(1, 3, 4, 2, 5) +reorder_facets <- function(splret, spl, fulldf, ...) { + ord <- c(1, 3, 4, 2, 5) + make_split_result( + splret$values[ord], + splret$datasplit[ord], + splret$labels[ord] + ) +} + +# Create a custom split function for adding the new columns (facets) and sorting them +custom_column_split_fun <- make_split_fun( + post = list( + add_combo_facet("all_X", + label = "All Drug X", + levels = c("A: Drug X", "C: Combination") + ), + add_combo_facet("all_pt", + label = "All Patients", + levels = c("A: Drug X", "B: Placebo", "C: Combination") + ), + reorder_facets + ) ) + # Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels. adsl <- df_explicit_na(adsl) adab <- adab %>% @@ -133,12 +153,13 @@ adab_pb <- df_explicit_na(adab) %>% ## {{< fa regular file-lines sm fw >}} Preview + ```{r variant1, test = list(result_v1 = "result"), opts.label = ifelse(packageVersion("rtables") < "0.6.6.9011", "skip_test_strict", "")} # Layout for Baseline Prevalence of NAbs lyt_bl <- basic_table(show_colcounts = TRUE) %>% split_cols_by( "ACTARM", - split_fun = add_combo_levels(combodf) + split_fun = custom_column_split_fun ) %>% count_patients_with_flags( "USUBJID", @@ -169,7 +190,7 @@ lyt_bl <- basic_table(show_colcounts = TRUE) %>% lyt_pb <- basic_table(show_colcounts = TRUE) %>% split_cols_by( "ACTARM", - split_fun = add_combo_levels(combodf) + split_fun = custom_column_split_fun ) %>% count_patients_with_flags( "USUBJID", @@ -217,12 +238,6 @@ result_2 <- build_table(lyt_pb, df = adab_pb, alt_counts_df = adsl) result_1@col_info <- result_2@col_info result <- rbind(result_1, result_2) -# Change the column order. -result <- cbind_rtables(result[, 1], result[, 3]) %>% - cbind_rtables(result[, 4]) %>% - cbind_rtables(result[, 2]) %>% - cbind_rtables(result[, 5]) - main_title(result) <- paste( "Baseline Prevalence and Incidence of Treatment Emergent ADA" ) diff --git a/book/tables/ADA/adat04a.qmd b/book/tables/ADA/adat04a.qmd index 66e5168837..ea8f44ea9f 100644 --- a/book/tables/ADA/adat04a.qmd +++ b/book/tables/ADA/adat04a.qmd @@ -20,10 +20,30 @@ library(tibble) adsl <- random.cdisc.data::cadsl adab <- random.cdisc.data::cadab -combodf <- tribble( - ~valname, ~label, ~levelcombo, ~exargs, - "all_X", "All Drug X", c("A: Drug X", "C: Combination"), list(), - "all_pt", "All Patients", c("A: Drug X", "B: Placebo", "C: Combination"), list() + +# Order needed for the columns is c(1, 3, 4, 2, 5) +reorder_facets <- function(splret, spl, fulldf, ...) { + ord <- c(1, 3, 4, 2, 5) + make_split_result( + splret$values[ord], + splret$datasplit[ord], + splret$labels[ord] + ) +} + +# Create a custom split function for adding the new columns (facets) and sorting them +custom_column_split_fun <- make_split_fun( + post = list( + add_combo_facet("all_X", + label = "All Drug X", + levels = c("A: Drug X", "C: Combination") + ), + add_combo_facet("all_pt", + label = "All Patients", + levels = c("A: Drug X", "B: Placebo", "C: Combination") + ), + reorder_facets + ) ) # Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels. @@ -160,12 +180,13 @@ adab_pb <- df_explicit_na(adab) %>% ## {{< fa regular file-lines sm fw >}} Preview + ```{r variant1, test = list(result_v1 = "result"), opts.label = ifelse(packageVersion("rtables") < "0.6.6.9011", "skip_test_strict", "")} # Layout for Baseline Prevalence of NAbs lyt_bl <- basic_table(show_colcounts = TRUE) %>% split_cols_by( "ACTARM", - split_fun = add_combo_levels(combodf) + split_fun = custom_column_split_fun ) %>% count_patients_with_flags( "USUBJID", @@ -194,7 +215,7 @@ lyt_bl <- basic_table(show_colcounts = TRUE) %>% lyt_pb <- basic_table(show_colcounts = TRUE) %>% split_cols_by( "ACTARM", - split_fun = add_combo_levels(combodf) + split_fun = custom_column_split_fun ) %>% count_patients_with_flags( "USUBJID", @@ -241,12 +262,6 @@ result_2 <- build_table(lyt_pb, df = adab_pb, alt_counts_df = adsl) # Combine tables result <- rbind(result_1, result_2) -# Change the column order -result <- cbind_rtables(result[, 1], result[, 3]) %>% - cbind_rtables(result[, 4]) %>% - cbind_rtables(result[, 2]) %>% - cbind_rtables(result[, 5]) - main_title(result) <- paste( "Baseline Prevalence and Incidence of Treatment Emergent NAbs" ) diff --git a/book/tables/ADA/adat04b.qmd b/book/tables/ADA/adat04b.qmd index 7ac19e32ec..d8974f4bcc 100644 --- a/book/tables/ADA/adat04b.qmd +++ b/book/tables/ADA/adat04b.qmd @@ -20,10 +20,29 @@ library(tibble) adsl <- random.cdisc.data::cadsl adab <- random.cdisc.data::cadab -combodf <- tribble( - ~valname, ~label, ~levelcombo, ~exargs, - "all_X", "All Drug X", c("A: Drug X", "C: Combination"), list(), - "all_pt", "All Patients", c("A: Drug X", "B: Placebo", "C: Combination"), list() +# Order needed for the columns is c(1, 3, 4, 2, 5) +reorder_facets <- function(splret, spl, fulldf, ...) { + ord <- c(1, 3, 4, 2, 5) + make_split_result( + splret$values[ord], + splret$datasplit[ord], + splret$labels[ord] + ) +} + +# Create a custom split function for adding the new columns (facets) and sorting them +custom_column_split_fun <- make_split_fun( + post = list( + add_combo_facet("all_X", + label = "All Drug X", + levels = c("A: Drug X", "C: Combination") + ), + add_combo_facet("all_pt", + label = "All Patients", + levels = c("A: Drug X", "B: Placebo", "C: Combination") + ), + reorder_facets + ) ) # Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels. @@ -140,12 +159,13 @@ adab_pb <- left_join(adab_pb_ada, adab_pb_adap, by = mergecol) %>% ## {{< fa regular file-lines sm fw >}} Preview + ```{r variant1, test = list(result_v1 = "result"), opts.label = ifelse(packageVersion("rtables") < "0.6.6.9011", "skip_test_strict", "")} # Layout for Baseline Prevalence of NAbs lyt_bl <- basic_table(show_colcounts = TRUE) %>% split_cols_by( "ACTARM", - split_fun = add_combo_levels(combodf) + split_fun = custom_column_split_fun ) %>% count_patients_with_flags( "USUBJID", @@ -175,7 +195,7 @@ lyt_bl <- basic_table(show_colcounts = TRUE) %>% lyt_pb <- basic_table(show_colcounts = TRUE) %>% split_cols_by( "ACTARM", - split_fun = add_combo_levels(combodf) + split_fun = custom_column_split_fun ) %>% count_patients_with_flags( "USUBJID", @@ -207,12 +227,6 @@ result_2 <- build_table(lyt_pb, df = adab_pb, alt_counts_df = adsl) # Combine tables. result <- rbind(result_1, result_2) -# Change the column order. -result <- cbind_rtables(result[, 1], result[, 3]) %>% - cbind_rtables(result[, 4]) %>% - cbind_rtables(result[, 2]) %>% - cbind_rtables(result[, 5]) - main_title(result) <- paste( "Baseline Prevalence and Incidence of Neutralizing Antibodies (NAbs)" ) diff --git a/book/tables/efficacy/rbmit01.qmd b/book/tables/efficacy/rbmit01.qmd index 10de92de4b..c605d0de26 100644 --- a/book/tables/efficacy/rbmit01.qmd +++ b/book/tables/efficacy/rbmit01.qmd @@ -117,10 +117,11 @@ draws_vars$subjid <- "TMP_ID" Define which imputation method to use, then create samples for the imputation parameters by running the `draws()` function. + ```{r, warning = FALSE, opts.label = "skip_test_strict"} #| code-fold: show -draws_method <- method_bayes() +draws_method <- method_bayes(seed = 123) draws_obj <- rbmi::draws( data = data_full, @@ -154,6 +155,7 @@ The next step is to run the analysis model on each imputed dataset. This is done by defining an analysis function and then calling `rbmi::analyse()` to apply this function to each imputed dataset. + ```{r, opts.label = "skip_test_strict"} #| code-fold: show #| opts_label: "skip_test_strict" # @@ -183,6 +185,7 @@ The `rbmi::pool()` function can be used to summarize the analysis results across Using the `broom::tidy()` function the `rbmi` final results are reshaped. + ```{r, opts.label = "skip_test_strict"} #| code-fold: show @@ -215,5 +218,5 @@ result {{< include ../../_utils/save_results.qmd >}} {{< include ../../repro.qmd >}} - :::: + diff --git a/package/tests/testthat/_create_test_files.R b/package/tests/testthat/_create_test_files.R index 71b749dbe4..6aaa9e0cd3 100644 --- a/package/tests/testthat/_create_test_files.R +++ b/package/tests/testthat/_create_test_files.R @@ -1,7 +1,7 @@ # Script to create test files for all articles in the test book. # It would not remove existing test files so in case article location or name is changed, the old test file should be removed manually. # run with `source()`, e.g.: -# source("./tests//testthat/_create_test_files.R") +# source("./tests/testthat/_create_test_files.R") article_files <- list.files( test_book_path, @@ -12,6 +12,14 @@ article_files <- list.files( ) |> grep("tables/|listings/|graphs/", x = _, value = TRUE) +excluded_articles <- c( + # Stan is not reproducible on different platforms + # https://mc-stan.org/docs/2_27/reference-manual/reproducibility-chapter.html + "tables/efficacy/rbmit01.qmd" +) + +article_files <- setdiff(article_files, excluded_articles) + test_files <- article_files |> vapply( X = _, diff --git a/package/tests/testthat/_snaps/development/tables-ADA-adat01.md b/package/tests/testthat/_snaps/development/tables-ADA-adat01.md index 018f83d50d..55baa454a9 100644 --- a/package/tests/testthat/_snaps/development/tables-ADA-adat01.md +++ b/package/tests/testthat/_snaps/development/tables-ADA-adat01.md @@ -5,22 +5,22 @@ Output Baseline Prevalence and Incidence of Treatment Emergent ADA - ————————————————————————————————————————————————————————————————————————————————————————————————————————————————— - A: Drug X C: Combination B: Placebo All Drug X - (N=134) (N=132) (N=0) (N=134) (N=266) - ————————————————————————————————————————————————————————————————————————————————————————————————————————————————— - Baseline Prevalence of ADAs - Baseline evaluable patients 134 132 0 0 266 - Patient with a positive sample at baseline 63 (47.0%) 64 (48.5%) 0 0 127 (47.7%) - Patient with no positive samples at baseline 71 68 0 0 139 - Incidence of Treatment Emergent ADAs - Post-baseline evaluable patients 134 132 0 0 266 - Patient positive for Treatment Emergent ADA 0 0 0 0 0 - Treatment-induced ADA 0 0 0 0 0 - Treatment-enhanced ADA 0 0 0 0 0 - Patient negative for Treatment Emergent ADA 0 0 0 0 0 - Treatment unaffected 0 0 0 0 0 - ————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + A: Drug X C: Combination B: Placebo All Drug X + (N=134) (N=132) (N=0) (N=134) (N=266) + ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Baseline Prevalence of ADAs + Baseline evaluable patients 134 132 0 0 266 + Patient with a positive sample at baseline 63 (47.0%) 64 (48.5%) 0 0 127 (47.7%) + Patient with no positive samples at baseline 71 68 0 0 139 + Incidence of Treatment Emergent ADAs + Post-baseline evaluable patients 134 132 0 0 266 + Patient positive for Treatment Emergent ADA 0 0 0 0 0 + Treatment-induced ADA 0 0 0 0 0 + Treatment-enhanced ADA 0 0 0 0 0 + Patient negative for Treatment Emergent ADA 0 0 0 0 0 + Treatment unaffected 0 0 0 0 0 + ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————— ADA = Anti-Drug Antibodies (is also referred to as ATA, or Anti-Therapeutic Antibodies) Baseline evaluable patient = a patient with an ADA assay result from a baseline sample(s) Post-baseline evaluable patient = a patient with an ADA assay result from at least one post-baseline sample Number of patients positive for Treatment Emergent diff --git a/package/tests/testthat/_snaps/development/tables-ADA-adat04a.md b/package/tests/testthat/_snaps/development/tables-ADA-adat04a.md index 1745ab8c39..fe457863ff 100644 --- a/package/tests/testthat/_snaps/development/tables-ADA-adat04a.md +++ b/package/tests/testthat/_snaps/development/tables-ADA-adat04a.md @@ -6,24 +6,24 @@ Baseline Prevalence and Incidence of Treatment Emergent NAbs Protocol: A: Drug X Antibody - ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————— - A: Drug X C: Combination B: Placebo All Drug X - (N=134) (N=132) (N=0) (N=134) (N=266) - ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————— - Baseline Prevalence of NAbs - Baseline evaluable patients for ADA 134 132 0 0 266 - Patients with a positive ADA sample at baseline 63 64 0 0 127 - Patients with a positive NAb sample at baseline 0 0 0 0 0 - Patient with no positive NAb samples at baseline 0 0 0 0 0 - Incidence of Treatment Emergent NAbs - Post-baseline evaluable patients for ADA 134 132 0 0 266 - Patients positive for ADA 66 59 0 0 125 - Patients positive for Treatment Emergent NAb 0 0 0 0 0 - Treatment-induced NAb 0 0 0 0 0 - Treatment-enhanced NAb 0 0 0 0 0 - Patients negative for NAb 0 0 0 0 0 - Treatment unaffected 0 0 0 0 0 - ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + A: Drug X C: Combination B: Placebo All Drug X + (N=134) (N=132) (N=0) (N=134) (N=266) + ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Baseline Prevalence of NAbs + Baseline evaluable patients for ADA 134 132 0 0 266 + Patients with a positive ADA sample at baseline 63 64 0 0 127 + Patients with a positive NAb sample at baseline 0 0 0 0 0 + Patient with no positive NAb samples at baseline 0 0 0 0 0 + Incidence of Treatment Emergent NAbs + Post-baseline evaluable patients for ADA 134 132 0 0 266 + Patients positive for ADA 66 59 0 0 125 + Patients positive for Treatment Emergent NAb 0 0 0 0 0 + Treatment-induced NAb 0 0 0 0 0 + Treatment-enhanced NAb 0 0 0 0 0 + Patients negative for NAb 0 0 0 0 0 + Treatment unaffected 0 0 0 0 0 + ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— NAb = Neutralizing Antibodies ADA = Anti-Drug Antibodies (is also referred to as ATA, or Anti-Therapeutic Antibodies) Baseline evaluable patient for ADA = a patient with an ADA assay result from a baseline sample(s) Baseline evaluable patient for NAb = a patient with a NAb assay result from a baseline sample(s) diff --git a/package/tests/testthat/_snaps/development/tables-ADA-adat04b.md b/package/tests/testthat/_snaps/development/tables-ADA-adat04b.md index b7e015b532..c73b06a076 100644 --- a/package/tests/testthat/_snaps/development/tables-ADA-adat04b.md +++ b/package/tests/testthat/_snaps/development/tables-ADA-adat04b.md @@ -6,21 +6,21 @@ Baseline Prevalence and Incidence of Neutralizing Antibodies (NAbs) Protocol: A: Drug X Antibody - ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————— - A: Drug X C: Combination B: Placebo All Drug X - (N=134) (N=132) (N=0) (N=134) (N=266) - ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————— - Baseline Prevalence of NAbs - Baseline evaluable patients for ADA 134 132 0 0 266 - Patients with a positive ADA sample at baseline 63 64 0 0 127 - Patients with a positive NAb sample at baseline 0 0 0 0 0 - Patients with no positive NAb sample at baseline 0 0 0 0 0 - Incidence of NAbs - Post-baseline evaluable patients for ADA 134 132 0 0 266 - Patients positive for ADA 66 59 0 0 125 - Patients positive for NAb 0 0 0 0 0 - Patients negative for NAb 134 132 0 0 266 - ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + A: Drug X C: Combination B: Placebo All Drug X + (N=134) (N=132) (N=0) (N=134) (N=266) + ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Baseline Prevalence of NAbs + Baseline evaluable patients for ADA 134 132 0 0 266 + Patients with a positive ADA sample at baseline 63 64 0 0 127 + Patients with a positive NAb sample at baseline 0 0 0 0 0 + Patients with no positive NAb sample at baseline 0 0 0 0 0 + Incidence of NAbs + Post-baseline evaluable patients for ADA 134 132 0 0 266 + Patients positive for ADA 66 59 0 0 125 + Patients positive for NAb 0 0 0 0 0 + Patients negative for NAb 134 132 0 0 266 + ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— NAb = Neutralizing Antibodies ADA = Anti-Drug Antibodies (is also referred to as ATA, or Anti-Therapeutic Antibodies) Baseline evaluable patient for ADA = a patient with an ADA assay result from a baseline sample(s) Baseline evaluable patient for NAb = a patient with a NAb assay result from a baseline sample(s) Post-baseline evaluable patient for ADA = a patient with an ADA assay result from at least one post-baseline sample Post-baseline evaluable patient for NAb = a patient with a NAb assay result from at least one post-baseline sample Number of patients positive for ADA = the number of post-baseline evaluable patients for ADA determined to have Treatment Emergent ADA during the study period. Number of patients positive for NAb = the number (and percentage) of post-baseline evaluable patients for ADA determined to have at least one positive post-baseline NAb result during the study period. Number of patients negative for NAb = number of post-baseline evaluable patients with all negative post-baseline NAb results. diff --git a/package/tests/testthat/_snaps/development/tables-efficacy-ratet01.md b/package/tests/testthat/_snaps/development/tables-efficacy-ratet01.md index 5bda2ac2a5..230789b4eb 100644 --- a/package/tests/testthat/_snaps/development/tables-efficacy-ratet01.md +++ b/package/tests/testthat/_snaps/development/tables-efficacy-ratet01.md @@ -21,14 +21,14 @@ 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 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 + 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 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 + Rate Ratio CI (0.8856, 1.1941) (0.9381, 1.2624) + p value 0.7140 0.2643 diff --git a/package/tests/testthat/_snaps/development/tables-efficacy-rbmit01.md b/package/tests/testthat/_snaps/development/tables-efficacy-rbmit01.md deleted file mode 100644 index 22d838ab26..0000000000 --- a/package/tests/testthat/_snaps/development/tables-efficacy-rbmit01.md +++ /dev/null @@ -1,36 +0,0 @@ -# tables/efficacy/rbmit01.qmd result_v1 development - - Code - print(data_snap[[i]]) - Output - Visit ref alt - ————————————————————————————————————————————————————————————————————————— - 4 - Adjusted Mean (SE) -1.616 (0.486) -1.708 (0.475) - 95% CI (-2.576, -0.656) (-2.645, -0.770) - Difference in Adjusted Means (SE) -0.092 (0.683) - 95% CI (-1.439, 1.256) - Relative Reduction (%) 5.7% - p-value (RBMI) 0.8932 - 5 - Adjusted Mean (SE) -4.251 (0.647) -2.805 (0.644) - 95% CI (-5.528, -2.974) (-4.077, -1.533) - Difference in Adjusted Means (SE) 1.446 (0.914) - 95% CI (-0.358, 3.250) - Relative Reduction (%) -34.0% - p-value (RBMI) 0.1155 - 6 - Adjusted Mean (SE) -6.366 (0.721) -4.095 (0.696) - 95% CI (-7.793, -4.939) (-5.471, -2.720) - Difference in Adjusted Means (SE) 2.270 (0.996) - 95% CI (0.301, 4.239) - Relative Reduction (%) -35.7% - p-value (RBMI) 0.0241 - 7 - Adjusted Mean (SE) -7.689 (0.797) -4.776 (0.752) - 95% CI (-9.266, -6.112) (-6.261, -3.290) - Difference in Adjusted Means (SE) 2.913 (1.073) - 95% CI (0.792, 5.035) - Relative Reduction (%) -37.9% - p-value (RBMI) 0.0074 - diff --git a/package/tests/testthat/_snaps/stable/tables-ADA-adat01.md b/package/tests/testthat/_snaps/stable/tables-ADA-adat01.md index c50eb7af61..4bde192615 100644 --- a/package/tests/testthat/_snaps/stable/tables-ADA-adat01.md +++ b/package/tests/testthat/_snaps/stable/tables-ADA-adat01.md @@ -5,22 +5,22 @@ Output Baseline Prevalence and Incidence of Treatment Emergent ADA - ————————————————————————————————————————————————————————————————————————————————————————————————————————————————— - A: Drug X C: Combination B: Placebo All Drug X - (N=134) (N=132) (N=0) (N=134) (N=266) - ————————————————————————————————————————————————————————————————————————————————————————————————————————————————— - Baseline Prevalence of ADAs - Baseline evaluable patients 134 132 0 0 266 - Patient with a positive sample at baseline 63 (47.0%) 64 (48.5%) 0 0 127 (47.7%) - Patient with no positive samples at baseline 71 68 0 0 139 - Incidence of Treatment Emergent ADAs - Post-baseline evaluable patients 134 132 0 0 266 - Patient positive for Treatment Emergent ADA 0 0 0 0 0 - Treatment-induced ADA 0 0 0 0 0 - Treatment-enhanced ADA 0 0 0 0 0 - Patient negative for Treatment Emergent ADA 0 0 0 0 0 - Treatment unaffected 0 0 0 0 0 - ————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + A: Drug X C: Combination B: Placebo All Drug X + (N=134) (N=132) (N=0) (N=134) (N=266) + ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Baseline Prevalence of ADAs + Baseline evaluable patients 134 132 0 0 266 + Patient with a positive sample at baseline 63 (47.0%) 64 (48.5%) 0 0 127 (47.7%) + Patient with no positive samples at baseline 71 68 0 0 139 + Incidence of Treatment Emergent ADAs + Post-baseline evaluable patients 134 132 0 0 266 + Patient positive for Treatment Emergent ADA 0 0 0 0 0 + Treatment-induced ADA 0 0 0 0 0 + Treatment-enhanced ADA 0 0 0 0 0 + Patient negative for Treatment Emergent ADA 0 0 0 0 0 + Treatment unaffected 0 0 0 0 0 + ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————— ADA = Anti-Drug Antibodies (is also referred to as ATA, or Anti-Therapeutic Antibodies) Baseline evaluable patient = a patient with an ADA assay result from a baseline sample(s) Post-baseline evaluable patient = a patient with an ADA assay result from at least one post-baseline sample Number of patients positive for Treatment Emergent diff --git a/package/tests/testthat/_snaps/stable/tables-ADA-adat04a.md b/package/tests/testthat/_snaps/stable/tables-ADA-adat04a.md index ea03febaae..bf1b2ad936 100644 --- a/package/tests/testthat/_snaps/stable/tables-ADA-adat04a.md +++ b/package/tests/testthat/_snaps/stable/tables-ADA-adat04a.md @@ -6,24 +6,24 @@ Baseline Prevalence and Incidence of Treatment Emergent NAbs Protocol: A: Drug X Antibody - ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————— - A: Drug X C: Combination B: Placebo All Drug X - (N=134) (N=132) (N=0) (N=134) (N=266) - ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————— - Baseline Prevalence of NAbs - Baseline evaluable patients for ADA 134 132 0 0 266 - Patients with a positive ADA sample at baseline 63 64 0 0 127 - Patients with a positive NAb sample at baseline 0 0 0 0 0 - Patient with no positive NAb samples at baseline 0 0 0 0 0 - Incidence of Treatment Emergent NAbs - Post-baseline evaluable patients for ADA 134 132 0 0 266 - Patients positive for ADA 66 59 0 0 125 - Patients positive for Treatment Emergent NAb 0 0 0 0 0 - Treatment-induced NAb 0 0 0 0 0 - Treatment-enhanced NAb 0 0 0 0 0 - Patients negative for NAb 0 0 0 0 0 - Treatment unaffected 0 0 0 0 0 - ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + A: Drug X C: Combination B: Placebo All Drug X + (N=134) (N=132) (N=0) (N=134) (N=266) + ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Baseline Prevalence of NAbs + Baseline evaluable patients for ADA 134 132 0 0 266 + Patients with a positive ADA sample at baseline 63 64 0 0 127 + Patients with a positive NAb sample at baseline 0 0 0 0 0 + Patient with no positive NAb samples at baseline 0 0 0 0 0 + Incidence of Treatment Emergent NAbs + Post-baseline evaluable patients for ADA 134 132 0 0 266 + Patients positive for ADA 66 59 0 0 125 + Patients positive for Treatment Emergent NAb 0 0 0 0 0 + Treatment-induced NAb 0 0 0 0 0 + Treatment-enhanced NAb 0 0 0 0 0 + Patients negative for NAb 0 0 0 0 0 + Treatment unaffected 0 0 0 0 0 + ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— NAb = Neutralizing Antibodies ADA = Anti-Drug Antibodies (is also referred to as ATA, or Anti-Therapeutic Antibodies) Baseline evaluable patient for ADA = a patient with an ADA assay result from a baseline sample(s) Baseline evaluable patient for NAb = a patient with a NAb assay result from a baseline sample(s) diff --git a/package/tests/testthat/_snaps/stable/tables-ADA-adat04b.md b/package/tests/testthat/_snaps/stable/tables-ADA-adat04b.md index f04fd33c41..9f33160c46 100644 --- a/package/tests/testthat/_snaps/stable/tables-ADA-adat04b.md +++ b/package/tests/testthat/_snaps/stable/tables-ADA-adat04b.md @@ -6,21 +6,21 @@ Baseline Prevalence and Incidence of Neutralizing Antibodies (NAbs) Protocol: A: Drug X Antibody - ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————— - A: Drug X C: Combination B: Placebo All Drug X - (N=134) (N=132) (N=0) (N=134) (N=266) - ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————— - Baseline Prevalence of NAbs - Baseline evaluable patients for ADA 134 132 0 0 266 - Patients with a positive ADA sample at baseline 63 64 0 0 127 - Patients with a positive NAb sample at baseline 0 0 0 0 0 - Patients with no positive NAb sample at baseline 0 0 0 0 0 - Incidence of NAbs - Post-baseline evaluable patients for ADA 134 132 0 0 266 - Patients positive for ADA 66 59 0 0 125 - Patients positive for NAb 0 0 0 0 0 - Patients negative for NAb 134 132 0 0 266 - ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + A: Drug X C: Combination B: Placebo All Drug X + (N=134) (N=132) (N=0) (N=134) (N=266) + ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Baseline Prevalence of NAbs + Baseline evaluable patients for ADA 134 132 0 0 266 + Patients with a positive ADA sample at baseline 63 64 0 0 127 + Patients with a positive NAb sample at baseline 0 0 0 0 0 + Patients with no positive NAb sample at baseline 0 0 0 0 0 + Incidence of NAbs + Post-baseline evaluable patients for ADA 134 132 0 0 266 + Patients positive for ADA 66 59 0 0 125 + Patients positive for NAb 0 0 0 0 0 + Patients negative for NAb 134 132 0 0 266 + ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— NAb = Neutralizing Antibodies ADA = Anti-Drug Antibodies (is also referred to as ATA, or Anti-Therapeutic Antibodies) Baseline evaluable patient for ADA = a patient with an ADA assay result from a baseline sample(s) Baseline evaluable patient for NAb = a patient with a NAb assay result from a baseline sample(s) Post-baseline evaluable patient for ADA = a patient with an ADA assay result from at least one post-baseline sample Post-baseline evaluable patient for NAb = a patient with a NAb assay result from at least one post-baseline sample Number of patients positive for ADA = the number of post-baseline evaluable patients for ADA determined to have Treatment Emergent ADA during the study period. Number of patients positive for NAb = the number (and percentage) of post-baseline evaluable patients for ADA determined to have at least one positive post-baseline NAb result during the study period. Number of patients negative for NAb = number of post-baseline evaluable patients with all negative post-baseline NAb results. diff --git a/package/tests/testthat/_snaps/stable/tables-efficacy-rbmit01.md b/package/tests/testthat/_snaps/stable/tables-efficacy-rbmit01.md deleted file mode 100644 index d51404e2af..0000000000 --- a/package/tests/testthat/_snaps/stable/tables-efficacy-rbmit01.md +++ /dev/null @@ -1,36 +0,0 @@ -# tables/efficacy/rbmit01.qmd result_v1 stable - - Code - print(data_snap[[i]]) - Output - Visit ref alt - ————————————————————————————————————————————————————————————————————————— - 4 - Adjusted Mean (SE) -1.616 (0.486) -1.708 (0.475) - 95% CI (-2.576, -0.656) (-2.645, -0.770) - Difference in Adjusted Means (SE) -0.092 (0.683) - 95% CI (-1.439, 1.256) - Relative Reduction (%) 5.7% - p-value (RBMI) 0.8932 - 5 - Adjusted Mean (SE) -4.251 (0.647) -2.805 (0.644) - 95% CI (-5.528, -2.974) (-4.077, -1.533) - Difference in Adjusted Means (SE) 1.446 (0.914) - 95% CI (-0.358, 3.250) - Relative Reduction (%) -34.0% - p-value (RBMI) 0.1155 - 6 - Adjusted Mean (SE) -6.366 (0.721) -4.095 (0.696) - 95% CI (-7.793, -4.939) (-5.471, -2.720) - Difference in Adjusted Means (SE) 2.270 (0.996) - 95% CI (0.301, 4.239) - Relative Reduction (%) -35.7% - p-value (RBMI) 0.0241 - 7 - Adjusted Mean (SE) -7.689 (0.797) -4.776 (0.752) - 95% CI (-9.266, -6.112) (-6.261, -3.290) - Difference in Adjusted Means (SE) 2.913 (1.073) - 95% CI (0.792, 5.035) - Relative Reduction (%) -37.9% - p-value (RBMI) 0.0074 - diff --git a/package/tests/testthat/helper.R b/package/tests/testthat/helper.R index e7e15768a5..3afbb520be 100644 --- a/package/tests/testthat/helper.R +++ b/package/tests/testthat/helper.R @@ -25,7 +25,7 @@ test_article <- function(article_path) { print(data_snap[[i]]), variant = test_profile ) - } else if (ggplot2::is.ggplot(data_snap[[i]]) || grid::is.grob(data_snap[[i]])) { + } else if (isTRUE(if_test_plots) && (ggplot2::is.ggplot(data_snap[[i]]) || grid::is.grob(data_snap[[i]]))) { testthat::skip_if_not_installed("svglite") testthat::skip_on_ci() @@ -44,7 +44,10 @@ test_article <- function(article_path) { withr::with_seed( 123, suppressMessages( - ggplot2::ggsave(plot_file, data_snap[[i]], width = plot_dims[["width"]], height = plot_dims[["height"]]) + ggplot2::ggsave(plot_file, data_snap[[i]], + width = plot_dims[["width"]], height = plot_dims[["height"]], + create.dir = TRUE + ) ) ) diff --git a/package/tests/testthat/setup.R b/package/tests/testthat/setup.R index 31eff472b2..1248826f75 100644 --- a/package/tests/testthat/setup.R +++ b/package/tests/testthat/setup.R @@ -3,15 +3,24 @@ test_book_path <- testthat::test_path("_book") test_data_path <- testthat::test_path("_data") Sys.setenv("QUARTO_TESTTHAT_DATA_PATH" = normalizePath(test_data_path)) -# flags for developers +# Flags for developers # use it if you want to disable render of book or render individual articles instead # for the latter: # (i) set if_render_book to FALSE # (ii) set if_render_article to TRUE # (iii) assure proper value of `test_profile` ("development" or "stable") -# (iv) run `devtools::test(filter = "test-")` -if_render_book <- TRUE -if_render_articles <- FALSE +# (iv) run `devtools::test(filter = "")` +if_render_book <- TRUE # Remember to change this to FALSE if you want to render articles (otherwise loop) +if_render_articles <- !if_render_book +if_test_plots <- FALSE # Additional option for optional skip of local plot tests +# Example for render articles (NOTE: KEEP THESE COMMENTED WHEN RUNNING!!): +# setwd("package") +# Sys.setenv("QUARTO_PROFILE" = "development") +# devtools::test(filter = "tables-efficacy-rbmit01") +# devtools::test(filter = "tables-ADA-adat01") +# if the snapshot changed only an error will be printed and you need to update the snapshot +# testthat::snapshot_accept('development/tables-efficacy-rbmit01') + if (isTRUE(if_render_book) && isTRUE(if_render_articles)) { stop("Render both book and articles at the same time is not efficient! Please set one of them to FALSE.") diff --git a/package/tests/testthat/test-tables-efficacy-rbmit01.R b/package/tests/testthat/test-tables-efficacy-rbmit01.R deleted file mode 100644 index 787454977d..0000000000 --- a/package/tests/testthat/test-tables-efficacy-rbmit01.R +++ /dev/null @@ -1 +0,0 @@ -test_article("tables/efficacy/rbmit01.qmd")