Skip to content

Fix bug in s_ancova when arm levels include special characters #1242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
* Updated `g_lineplot` legend to follow factor levels set by users.
* Added examples and tests for `label_all` parameter to `extract_survival_biomarkers` and `extract_survival_subgroups`.

### Bug Fixes
* Fixed bug in `s_ancova` that prevented statistics from being printed when arm levels include special characters.

### Miscellaneous
* Began deprecation of the unused `label_all` parameter to `tabulate_survival_biomarkers` and `tabulate_survival_subgroups`, with redirection to the same parameter in their associated `extract_*` functions.

Expand Down
4 changes: 3 additions & 1 deletion R/summarize_ancova.R
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ s_ancova <- function(df,
adjust = "none"
)

contrast_lvls <- gsub(paste0(" - ", .ref_group[[arm]][1], ".*"), "", sum_contrasts$contrast)
contrast_lvls <- gsub(
"^\\(|\\)$", "", gsub(paste0(" - \\(*", .ref_group[[arm]][1], ".*"), "", sum_contrasts$contrast)
)
if (!is.null(interaction_item)) {
sum_contrasts_level <- sum_contrasts[grepl(sum_level, contrast_lvls, fixed = TRUE), ]
} else {
Expand Down
32 changes: 23 additions & 9 deletions tests/testthat/_snaps/summarize_ancova.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,27 @@
Code
res
Output
ARM A ARM B (x) ARM C
(N=69) (N=73) (N=58)
——————————————————————————————————————————————————————————————
Unadjusted comparison
n 552 584 464
Mean 0.01 0.01 -0.05
Difference in Means 0.06 0.06
95% CI (-0.07, 0.19) (-0.06, 0.19)
p-value 0.3442 0.3186
ARM A ARM B (x) ARM C
(N=69) (N=73) (N=58)
——————————————————————————————————————————————————————————
Unadjusted comparison
n 552 584 464
Mean 0.01 0.01 -0.05
Difference in Means 0.06
95% CI (-0.07, 0.19)
p-value 0.3442

---

Code
res
Output
10mg/kg 20mg/kg 30mg/kg
————————————————————————————————————————————————————————————————————————
ARMCD
n 69 73 58
Adjusted Mean 6.30 6.75 6.16
Difference in Adjusted Means 0.45 -0.14
95% CI (-0.70, 1.60) (-1.36, 1.08)
p-value 0.4433 0.8214

23 changes: 23 additions & 0 deletions tests/testthat/test-summarize_ancova.R
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,27 @@ testthat::test_that("summarize_ancova works with irregular arm levels", {

res <- testthat::expect_silent(result2)
testthat::expect_snapshot(res)

adsl <- adsl |>
mutate(
ARMCD = case_match(
ARMCD,
"ARM A" ~ "10mg/kg",
"ARM B" ~ "20mg/kg",
"ARM C" ~ "30mg/kg"
) |> factor(levels = paste0(1:3, "0mg/kg")),
)

result3 <- basic_table() |>
split_cols_by("ARMCD", ref_group = "10mg/kg") |>
summarize_ancova(
vars = "BMRKR1",
variables = list(arm = "ARMCD"),
conf_level = 0.95,
var_labels = "ARMCD"
) |>
build_table(adsl)

res <- testthat::expect_silent(result3)
testthat::expect_snapshot(res)
})
Loading