Skip to content
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

try to harmonize the templates #496

Merged
merged 75 commits into from
May 17, 2023
Merged
Changes from 1 commit
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
fa8b1dc
update gitignore
Apr 24, 2023
9380c68
Merge branch 'main' into 476_harmonize_templates@main
Apr 26, 2023
bd9f0c6
attemp to unify
Apr 26, 2023
b29e359
first attempt to harmonize the template
May 5, 2023
1c2dcd5
minor update
May 5, 2023
2121783
styling
May 5, 2023
45b335d
update the preprocess to make it simpler
May 5, 2023
5f439d8
export formatters::with_label to make it simpler
May 5, 2023
faf58e8
minor update
May 5, 2023
f0ca344
update aet02 and reexport reformat
May 6, 2023
c4a297d
add more utility functions
May 6, 2023
5a83b69
update styles
May 6, 2023
a91d363
Merge branch 'main' into 476_harmonize_templates@main
May 6, 2023
59c0fe2
update all ae templates
May 8, 2023
29f75ce
update snapshot
May 8, 2023
4f77481
update snapshots
May 8, 2023
7cce311
fix formating of DCSREAS
May 8, 2023
ffce2ee
update dmt01
May 9, 2023
edc0d47
update checks in main
May 10, 2023
eca6a00
update tests and code
May 10, 2023
4d55102
update vst02 and cmt01a
May 10, 2023
3be8acd
update layout function docs
May 10, 2023
2d14293
Merge branch '476_harmonize_templates@main' of github.com:insightseng…
May 10, 2023
dc83150
correct documentation
May 10, 2023
97c14b5
update docs
May 10, 2023
97b4152
Merge branch '476_harmonize_templates@main' of github.com:insightseng…
May 10, 2023
823d963
update roxygen
May 10, 2023
6f0a0e3
update vst02 and cmt01a
May 10, 2023
7747b2e
add a bunch of assertions
May 10, 2023
43039fb
fix check issues
May 10, 2023
1380119
fix check issues
May 11, 2023
73d6d19
update aet01
May 11, 2023
b761d7b
update code styles
May 11, 2023
be67df8
fix issue
May 11, 2023
98152c1
not use adam_db
May 11, 2023
caf981a
update tests
May 11, 2023
ebb0e26
Merge branch 'main' into 476_harmonize_templates@main
May 11, 2023
b76a76d
update coxt02
May 11, 2023
99673d1
update tests
May 11, 2023
dfa67e3
style update and pkgdown
May 11, 2023
60ed5f1
update sorting of cmt01a
May 11, 2023
ae30831
update dtht01
May 12, 2023
fb2b8f6
fix check issues
May 13, 2023
d292568
update spelling
May 13, 2023
edf54b2
update pkgdown
May 13, 2023
f910d06
unify cmt01a and cmt02_pt
May 13, 2023
d361d79
fix issue
May 13, 2023
fcb3d4f
fix issue
May 13, 2023
8967b46
minor update
May 15, 2023
dad28f5
organize code
May 15, 2023
ec20069
Merge branch 'main' into 476_harmonize_templates@main
May 15, 2023
edecec1
update rspt01
May 15, 2023
fa6942f
update spelling
May 15, 2023
ca3f515
fix issue of empty string
May 15, 2023
c91a5fc
Update template@476 harmonize templates (#499)
BFalquet May 15, 2023
206e3c5
update tests and documentation
May 15, 2023
d30fbdc
clean up
May 16, 2023
7b06084
remove pdf
May 16, 2023
5c65695
move layouts to internal
May 16, 2023
85558da
update aet01_aesi snapshots
May 16, 2023
44d9195
update snapshots
May 16, 2023
38cc050
fix warnings (#501)
BFalquet May 16, 2023
f74401a
Merge branch '476_harmonize_templates@main' of github.com:insightseng…
May 16, 2023
11da514
update page size for pdf01
May 16, 2023
c5e489c
update vst01, add formatters namespace, update tests
May 16, 2023
0bfaa75
remove vdiffr
May 16, 2023
94a0659
fix documentation
May 16, 2023
ab2045c
fix failing test
May 16, 2023
63b2296
handle missing levels in lbt04
May 16, 2023
9096763
upgrade lbt04 assertion
May 16, 2023
b028906
correct assertion
May 16, 2023
c01e124
update pdt01 snapshot
May 16, 2023
463a24a
fix issue
May 16, 2023
4956406
update minor check
May 16, 2023
523fe1f
update kmg01
May 17, 2023
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
Prev Previous commit
Next Next commit
update vst01, add formatters namespace, update tests
  • Loading branch information
benoit committed May 16, 2023
commit c5e489c52101dd81809775a335a40f257fe289c4
1 change: 0 additions & 1 deletion R/lbt04.R
100755 → 100644
Original file line number Diff line number Diff line change
@@ -29,7 +29,6 @@ lbt04_main <- function(adam_db,
assert_valid_variable(adam_db$adlb, c("USUBJID"), types = list(c("character", "factor")), empty_ok = TRUE)
assert_valid_variable(adam_db$adsl, c("USUBJID"), types = list(c("character", "factor")))
assert_valid_var_pair(adam_db$adsl, adam_db$adlb, arm_var)
checkmate::assert_true(any(lvls(adam_db$adlb$ANRIND) %in% c("HIGH", "LOW", "HIGH HIGH", "LOW LOW")))
lbl_anrind <- var_labels_for(adam_db$adlb, "ANRIND")
lbl_param <- var_labels_for(adam_db$adlb, "PARAM")

73 changes: 69 additions & 4 deletions R/vst01.R
Original file line number Diff line number Diff line change
@@ -7,6 +7,10 @@
#' where no name is provided, the label attribute of the corresponding column in `advs` table of `adam_db` is used.
#' @param visitvar (`string`) typically one of `"AVISIT"` (Default) or `"ATPTN"` depending on the type of time point
#' to be displayed
#' @param precision (named `list` of `integer`) where names are values found in the `PARAMCD` column and the the values
#' indicate the number of digits that should be represented for `min`, `max` and `median`. `Mean` and `sd` are
#' represented with one more decimal of precision.
#' @param default_precision (`integer`) the default number of digits.
#'
#' @details
#' * The `Analysis Value` column, displays the number of patients, the mean, standard deviation, median and range of
@@ -28,6 +32,8 @@ vst01_main <- function(adam_db,
arm_var = "ACTARM",
summaryvars = c("AVAL", "CHG"),
visitvar = "AVISIT",
precision = list(),
default_precision = 2,
...) {
assert_all_tablenames(adam_db, c("adsl", "advs"))
checkmate::assert_string(arm_var)
@@ -38,6 +44,9 @@ vst01_main <- function(adam_db,
assert_valid_variable(adam_db$advs, "USUBJID", types = list(c("character", "factor")), empty_ok = TRUE)
assert_valid_variable(adam_db$adsl, "USUBJID", types = list(c("character", "factor")))
assert_valid_var_pair(adam_db$adsl, adam_db$adae, arm_var)
checkmate::assert_list(precision, types = "integerish", names = "unique")
vapply(precision, checkmate::assert_integerish, FUN.VALUE = numeric(1), lower = 0, len = 1)
checkmate::assert_integerish(default_precision, lower = 0, len = 1)

lbl_avisit <- var_labels_for(adam_db$advs, visitvar)
lbl_param <- var_labels_for(adam_db$advs, "PARAM")
@@ -50,7 +59,9 @@ vst01_main <- function(adam_db,
summaryvars_lbls = summaryvars_lbls,
visitvar = visitvar,
lbl_avisit = lbl_avisit,
lbl_param = lbl_param
lbl_param = lbl_param,
precision = precision,
default_precision = default_precision
)

tbl <- build_table(
@@ -65,6 +76,7 @@ vst01_main <- function(adam_db,
#' `vst01` Layout
#'
#' @inheritParams gen_args
#' @inheritParams vst01_main
#'
#' @param summaryvars (`character`) the variables to be analyzed. For this table, `AVAL` and `CHG` by default.
#' @param summaryvars_lbls (`character`) the label of the variables to be analyzed.
@@ -80,15 +92,18 @@ vst01_lyt <- function(arm_var,
summaryvars_lbls,
visitvar,
lbl_avisit,
lbl_param) {
lbl_param,
precision,
default_precision) {
# TODE solve the problem of the overall column
# remove change from baseline in BASELINE
# problem with the column count

basic_table(show_colcounts = TRUE) %>%
split_cols_by(arm_var) %>%
split_rows_by(
"PARAM",
var = "PARAMCD",
labels_var = "PARAM",
split_fun = drop_split_levels,
label_pos = "hidden",
split_label = paste(lbl_param)
@@ -104,7 +119,57 @@ vst01_lyt <- function(arm_var,
varlabels = summaryvars_lbls,
nested = TRUE
) %>%
summarize_colvars() %>%
analyze_colvars(
afun = function(x, .var, .spl_context, precision, default_precision, ...) {
param_val <- .spl_context$value[which(.spl_context$split == "PARAMCD")]

pcs <- precision[[param_val]] %||% default_precision

# Create context dependent function.
n_fun <- sum(!is.na(x), na.rm = TRUE)
if (n_fun == 0) {
mean_sd_fun <- c(NA, NA)
median_fun <- NA
min_max_fun <- c(NA, NA)
} else {
mean_sd_fun <- c(mean(x, na.rm = TRUE), sd(x, na.rm = TRUE))
median_fun <- median(x, na.rm = TRUE)
min_max_fun <- c(min(x), max(x))
}

# Identify context-
is_chg <- .var == "CHG"

is_baseline <- .spl_context$value[which(.spl_context$split == "AVISIT")] == "BASELINE"

if (is_baseline && is_chg) {
n_fun <- mean_sd_fun <- median_fun <- min_max_fun <- NULL
}

in_rows(
"n" = n_fun,
"Mean (SD)" = mean_sd_fun,
"Median" = median_fun,
"Min - Max" = min_max_fun,
.formats = list(
"n" = "xx",
"Mean (SD)" = h_format_dec(format = "%f (%f)", digits = pcs + 1),
"Median" = h_format_dec(format = "%f", digits = pcs + 1),
"Min - Max" = h_format_dec(format = "%f - %f", digits = pcs)
),
.format_na_strs = list(
"n" = "NE",
"Mean (SD)" = "NE (NE)",
"Median" = "NE",
"Min - Max" = "NE - NE"
)
)
},
extra_args = list(
precision = precision,
default_precision = default_precision
)
) %>%
append_topleft(paste(lbl_param)) %>%
append_topleft(paste(" ", lbl_avisit))
}
8 changes: 8 additions & 0 deletions man/vst01.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion man/vst01_lyt.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions tests/testthat/_snaps/ael01_nollt.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ael01_nollt works with admh dataset

Code
cat(export_as_txt(res, lpp = 100))
cat(formatters::export_as_txt(res, lpp = 100))
Output
MedDRA System Organ Class MedDRA Preferred Term Reported Term for the Medical History
—————————————————————————————————————————————————————————————————————————————————————————
@@ -19,7 +19,7 @@
# ael01_nollt works with non-default label

Code
cat(export_as_txt(res, lpp = 100))
cat(formatters::export_as_txt(res, lpp = 100))
Output
MedDRA System Organ Class MedDRA Preferred Term Reported Term for the Adverse Event
———————————————————————————————————————————————————————————————————————————————————————
@@ -37,7 +37,7 @@
# ael01_nollt can handle all missing values

Code
cat(export_as_txt(res, lpp = 100))
cat(formatters::export_as_txt(res, lpp = 100))
Output
MedDRA System Organ Class MedDRA Preferred Term Reported Term for the Adverse Event
———————————————————————————————————————————————————————————————————————————————————————
@@ -46,7 +46,7 @@
# ael01_nollt can handle some missing values

Code
cat(export_as_txt(res, lpp = 100))
cat(formatters::export_as_txt(res, lpp = 100))
Output
MedDRA System Organ Class MedDRA Preferred Term Reported Term for the Adverse Event
———————————————————————————————————————————————————————————————————————————————————————
10 changes: 5 additions & 5 deletions tests/testthat/_snaps/aet01.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# aet01 can handle all NA values

Code
cat(export_as_txt(res, lpp = 100))
cat(formatters::export_as_txt(res, lpp = 100))
Output
A: Drug X B: Placebo C: Combination
(N=134) (N=134) (N=132)
@@ -26,7 +26,7 @@
---

Code
cat(export_as_txt(res, lpp = 100))
cat(formatters::export_as_txt(res, lpp = 100))
Output
A: Drug X B: Placebo C: Combination
(N=134) (N=134) (N=132)
@@ -46,7 +46,7 @@
# aet01 can handle some NA values

Code
cat(export_as_txt(res, lpp = 100))
cat(formatters::export_as_txt(res, lpp = 100))
Output
A: Drug X B: Placebo C: Combination
(N=134) (N=134) (N=132)
@@ -71,7 +71,7 @@
# aet01 can use custom anl_vars

Code
cat(export_as_txt(res, lpp = 100))
cat(formatters::export_as_txt(res, lpp = 100))
Output
A: Drug X B: Placebo C: Combination
(N=134) (N=134) (N=132)
@@ -86,7 +86,7 @@
# aet01 can use custom medconcept_var

Code
cat(export_as_txt(res, lpp = 100))
cat(formatters::export_as_txt(res, lpp = 100))
Output
A: Drug X B: Placebo C: Combination
(N=134) (N=134) (N=132)
8 changes: 4 additions & 4 deletions tests/testthat/_snaps/aet01_aesi.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# aet01_aesi can handle all NA values

Code
cat(export_as_txt(res, lpp = 100, cpp = 200))
cat(formatters::export_as_txt(res, lpp = 100, cpp = 200))
Output
A: Drug X B: Placebo C: Combination
(N=134) (N=134) (N=132)
@@ -25,7 +25,7 @@
---

Code
cat(export_as_txt(res, lpp = 100, cpp = 200))
cat(formatters::export_as_txt(res, lpp = 100, cpp = 200))
Output
A: Drug X B: Placebo C: Combination
(N=134) (N=134) (N=132)
@@ -45,7 +45,7 @@
# aet01_aesi can handle some NA values

Code
cat(export_as_txt(res, lpp = 100, cpp = 200))
cat(formatters::export_as_txt(res, lpp = 100, cpp = 200))
Output
A: Drug X B: Placebo C: Combination
(N=134) (N=134) (N=132)
@@ -69,7 +69,7 @@
# aet01_aesi works with `ALL` argument

Code
cat(export_as_txt(res, lpp = 100, cpp = 200))
cat(formatters::export_as_txt(res, lpp = 100, cpp = 200))
Output
A: Drug X B: Placebo C: Combination
(N=134) (N=134) (N=132)
4 changes: 2 additions & 2 deletions tests/testthat/_snaps/aet02.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# aet02 can have different levels of row_split

Code
cat(export_as_txt(res1, lpp = 100))
cat(formatters::export_as_txt(res1, lpp = 100))
Output
MedDRA Preferred Term A: Drug X B: Placebo C: Combination
(N=134) (N=134) (N=132)
@@ -22,7 +22,7 @@
---

Code
cat(export_as_txt(res2, lpp = 100))
cat(formatters::export_as_txt(res2, lpp = 100))
Output
MedDRA System Organ Class
MedDRA Preferred Term A: Drug X B: Placebo
4 changes: 2 additions & 2 deletions tests/testthat/_snaps/aet03.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# aet03 can handle NA values

Code
cat(export_as_txt(res1, lpp = 100))
cat(formatters::export_as_txt(res1, lpp = 100))
Output
MedDRA System Organ Class A: Drug X B: Placebo C: Combination
MedDRA Preferred Term (N=134) (N=134) (N=132)
@@ -24,7 +24,7 @@
# aet03 can handle some NA values

Code
cat(export_as_txt(res1, lpp = 100))
cat(formatters::export_as_txt(res1, lpp = 100))
Output
MedDRA System Organ Class A: Drug X B: Placebo C: Combination
MedDRA Preferred Term (N=134) (N=134) (N=132)
13 changes: 9 additions & 4 deletions tests/testthat/_snaps/aet04.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# aet04 can handle NA values

Code
cat(export_as_txt(res1, lpp = 100))
cat(formatters::export_as_txt(res1, lpp = 100))
Output
MedDRA System Organ Class
MedDRA Preferred Term A: Drug X B: Placebo C: Combination
@@ -39,7 +39,7 @@
---

Code
cat(export_as_txt(res3, lpp = 100))
cat(formatters::export_as_txt(res3, lpp = 100))
Output
MedDRA System Organ Class
MedDRA Preferred Term A: Drug X B: Placebo C: Combination
@@ -77,7 +77,7 @@
# aet04 can handle some NA values

Code
cat(export_as_txt(res1, lpp = 100))
cat(formatters::export_as_txt(res1, lpp = 100))
Output
MedDRA System Organ Class
MedDRA Preferred Term A: Drug X B: Placebo C: Combination
@@ -181,7 +181,7 @@
---

Code
cat(export_as_txt(res3, lpp = 100))
cat(formatters::export_as_txt(res3, lpp = 100))
Output
MedDRA System Organ Class
MedDRA Preferred Term A: Drug X B: Placebo C: Combination
@@ -280,6 +280,11 @@
- Any Grade - 1 (0.7%) 0 0
Grade 3-5 1 (0.7%) 0 0
3 1 (0.7%) 0 0
\s\n MedDRA System Organ Class
MedDRA Preferred Term A: Drug X B: Placebo C: Combination
Grade (N=134) (N=134) (N=132)
——————————————————————————————————————————————————————————————————————————————————————
No Coding Available
No Coding Available
- Any Grade - 1 (0.7%) 0 0
Grade 3-5 1 (0.7%) 0 0
Loading