Skip to content

Commit 02be9f2

Browse files
authored
Merge branch 'test' into 257261_default_col_palette
2 parents 53f47db + 1a1048b commit 02be9f2

14 files changed

Lines changed: 426 additions & 41 deletions

File tree

NAMESPACE

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
# Generated by roxygen2: do not edit by hand
22

3-
S3method("$",pack_of_constants)
4-
S3method("[",pack_of_constants)
5-
S3method("[[",pack_of_constants)
63
export(explorer_app)
74
export(mock_patient_profile_UI)
85
export(mock_patient_profile_app)

NEWS.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
# dv.papo 2.0.5-900
2-
32
- Fixes missing palette colours for AE, CM grading values.
43

54
# dv.papo 2.0.4-900
6-
75
- Fixes issue with labels not working fully if a data.frame is passed as input.
86

97
# dv.papo 2.0.3-900
10-
118
- Fixes y-axis getting squashed if blank values present in DECODE variable for AE/CM plots.
129

13-
# dv.papo 2.0.1-900
10+
# dv.papo 2.0.2-900
11+
- Fixes Serious AE labels mapping when the column is a "Y/N" `character` or `factor` variable instead of `logical`.
12+
1413

1514
# dv.papo 2.0.1
1615

R/aaa_preface.R

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
#' Build a collection of named constants
55
#'
66
#' @param ... Named parameters to be collected as constants
7-
#'
8-
#' @keywords internal
9-
#'
107
#' @details
118
#' Shiny uses strings as IDs to link UI and server elements. E.g:
129
#' foo_UI(id = ns("foo")) ...
@@ -37,6 +34,7 @@
3734
#' It is tagged as an S3 object to override its extraction operators.
3835
#'
3936
#' The use of checkmate is unnecessary, but it's a Good Library(TM) and your module should rely on it anyways
37+
#' @keywords internal
4038
pack_of_constants <- function(...) {
4139
result <- list(...)
4240
checkmate::assert_list(result, any.missing = FALSE, names = "unique")
@@ -51,24 +49,16 @@ pack_of_constants <- function(...) {
5149
#'
5250
#' This function differs from the base list extraction method in that it avoids partial matching of keys and throws
5351
#' an error if the looked-for constant is not contained within the pack.
54-
#'
5552
#' @keywords internal
56-
#'
57-
#' @export
5853
`$.pack_of_constants` <- function(pack, name) {
5954
checkmate::assert_true(name %in% names(pack), .var.name = paste0(deparse(substitute(pack)), "$", name))
6055
NextMethod()
6156
}
6257

63-
# This exports are recent requirement for devtools check https://github.com/r-lib/roxygen2/issues/1592#issue-2121199122
64-
#'
6558
#' @keywords internal
66-
#'
67-
#' @export
6859
`[[.pack_of_constants` <- `$.pack_of_constants`
6960

7061
#' @keywords internal
71-
#' @export
7262
`[.pack_of_constants` <- function(pack, name) {
7363
stop("Invalid pack_of_constants method")
7464
}

R/check_papo_call_manual.R

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,18 @@ check_papo_call <- function(datasets, module_id, subject_level_dataset_name, sub
243243
"`plots$timeline_info$%s` (%s) is not of allowed types (%s)",
244244
"trt_start_date", col, paste(allowed_classes_date, collapse = ",")
245245
)
246+
) &&
247+
assert_err(
248+
!anyNA(sl_dataset[[col]]),
249+
sprintf(
250+
"Dataset: '%s' `plots$timeline_info$%s` (%s) can not contain missing values. <br>
251+
trt_start_date is used as Day 1 reference date;
252+
together with trt_end_date, they define the extent of the x-axis",
253+
subject_level_dataset_name, "trt_start_date", col
246254
)
255+
256+
)
257+
247258
# timeline_info$trt_end_date
248259
col <- timeline_info[["trt_end_date"]]
249260
end_date_ok <-
@@ -260,7 +271,16 @@ check_papo_call <- function(datasets, module_id, subject_level_dataset_name, sub
260271
"`plots$timeline_info$%s` (%s) is not of allowed types (%s)",
261272
"trt_end_date", col, paste(allowed_classes_date, collapse = ",")
262273
)
274+
) &&
275+
assert_err(
276+
!anyNA(sl_dataset[[col]]),
277+
sprintf(
278+
"Dataset: '%s' `plots$timeline_info$%s` (%s) can not contain missing values.
279+
trt_start_date is used as Day 1 reference date;
280+
together with trt_end_date, they define the extent of the x-axis",
281+
subject_level_dataset_name, "trt_end_date", col
263282
)
283+
)
264284
# timeline_info$part_end_date
265285
part_end_date_ok <- FALSE
266286
if ("part_end_date" %in% names(timeline_info)) {

R/create_plots.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ create_ae_cm_plot <- function(data, x_limits, palette, sl_info, vline_vars, vlin
2727
grading <- "<no grading>"
2828
if (grading_available) grading <- data[["grading"]]
2929

30+
# fix for AE/CM y-axis getting squashed:
31+
blank_decode_indexes <- which(trimws(data[["decode"]]) == "")
32+
data[["decode"]][blank_decode_indexes] <- htmltools::HTML("<b><i>undefined</i></b>")
33+
3034
p <- ggplot2::ggplot(data, ggplot2::aes(x = .data[["start_day_z"]], y = .data[["decode"]]))
3135
p <- p + ggplot2::theme_bw()
3236
p <- p + ggplot2::geom_rect(

R/data_prep.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ pt_info_data_filter <- function(df, subjid_var, columns, selected_key) {
1313
row_index <- which(df[[subjid_var]] == selected_key)
1414
if (length(row_index) == 1) {
1515
res <- df[row_index, columns]
16+
df_labels <- structure(get_labels(df), names = names(df))[columns] #extract and save labels
17+
for (i in columns) {
18+
attr(res[[i]], "label") <- df_labels[[i]] # re-apply saved labels
19+
}
1620
}
17-
1821
return(res)
1922
}
2023

R/mod_patient_profile.R

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ mod_patient_profile_server <- function(id, subject_level_dataset, extra_datasets
8888
return(res)
8989
})
9090

91-
# (ag4hj): Without these outputOptions the update selector (See: ag4hj) tries to update a selector that is not yet
92-
# in the UI. Therefore the update is lost. In practice this means that when using the receiver_ids the first
93-
# subjid is lost and the interaction is incorrect.
91+
# (#ag4hj): Without these outputOptions the update selector tries to update a selector that is not yet in the UI.
92+
# Therefore the update is lost. In practice this means that when using the receiver_ids the first subjid is lost
93+
# and the interaction is incorrect.
9494
shiny::outputOptions(output, "ui", suspendWhenHidden = FALSE)
9595

9696
output[["selector"]] <- shiny::renderUI({
@@ -103,25 +103,23 @@ mod_patient_profile_server <- function(id, subject_level_dataset, extra_datasets
103103
)
104104
})
105105

106-
# See: (ag4hj)
106+
# See: (#ag4hj)
107107
shiny::outputOptions(output, "selector", suspendWhenHidden = FALSE)
108108

109-
# See: (ag4hj)
109+
# See: (#ag4hj)
110110
# change selected patient based on sender_ids
111-
if (!is.null(sender_ids)) {
112-
lapply(sender_ids, function(x) {
113-
shiny::observeEvent(x()[["subj_id"]](), {
114-
pid_passed <- x()[["subj_id"]]()
115-
if (!identical(pid_passed, character(0))) {
116-
shiny::updateSelectInput(
117-
session = session,
118-
inputId = "patient_selector",
119-
selected = pid_passed
120-
)
121-
}
122-
})
111+
lapply(sender_ids, function(x) {
112+
shiny::observeEvent(x()[["subj_id"]](), {
113+
pid_passed <- x()[["subj_id"]]()
114+
if (!identical(pid_passed, character(0))) {
115+
shiny::updateSelectInput(
116+
session = session,
117+
inputId = "patient_selector",
118+
selected = pid_passed
119+
)
120+
}
123121
})
124-
}
122+
})
125123

126124
assert <- function(condition, message) shiny::validate(shiny::need(condition, message))
127125

R/mod_plots.R

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,14 @@ patient_plot_server <- function(id, subject_var,
231231
df[["end_date"]] <- as.Date(df[[vars[["end_date"]]]])
232232
df[["decode"]] <- df[[vars[["decode"]]]]
233233
if ("grading" %in% names(vars)) df[["grading"]] <- df[[vars[["grading"]]]]
234-
if ("serious_ae" %in% names(vars)) df[["serious_ae"]] <- df[[vars[["serious_ae"]]]]
234+
if ("serious_ae" %in% names(vars)) {
235+
# FIXME: This is a temporal patch while we fix the modular API part
236+
if (!is.logical(df[["serious_ae"]])) {
237+
df[["serious_ae"]] <- df[[vars[["serious_ae"]]]] == "Y"
238+
} else {
239+
df[["serious_ae"]] <- df[[vars[["serious_ae"]]]]
240+
}
241+
}
235242

236243
# wrap decode column
237244
df[["decode"]] <- strwrap(df[["decode"]],
@@ -298,6 +305,7 @@ patient_plot_server <- function(id, subject_var,
298305
exported_test_data[[paste0("plot_first_line_color/", plot_name)]] <<-
299306
plot[["x"]][["data"]][[1]][["line"]][["color"]]
300307
exported_test_data[[paste0("arrow_right/", plot_name)]] <<- df[["arrow_right"]]
308+
exported_test_data[[paste0("serious_ae/", plot_name)]] <<- df[["serious_ae"]]
301309
}
302310

303311
# tweak legend manually - adapted from dv.papo 1; maybe there's a documented way of achieving the same?

R/utils-misc.R

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,28 @@ silence_warning <- function(expr, warning_message) {
2929

3030
merge_with_no_duplicate_cols <- function(a, b, by) merge(a, b[c(by, setdiff(names(b), names(a)))], by)
3131

32-
robust_min <- function(...) min(..., +Inf, na.rm = TRUE) # TODO: Remove if unused
33-
robust_max <- function(...) max(..., -Inf, na.rm = TRUE) # TODO: Remove if unused
34-
32+
#' Convert possibly truncated character(n) 'yyyy-mm-dd' to Date(n)
33+
#' performing optional round up using the level of precision present
34+
#' in the input data
35+
#'
36+
#' @param data [character(n)] Vector of dates
37+
#'
38+
#' @keywords internal
39+
#'
3540
robust_ymd <- function(data, round_up = FALSE) {
41+
# NOTE(miguel):
42+
# `dv.papo` used to rely on `lubridate` for date parsing.
43+
# We dropped that library because we didn't need any of its many advanced features.
44+
# Instead, we wrote this function to parse the only format we cared about ('yyyy-mm-dd'),
45+
# and to round end-dates up taking into account the unit information implicit to possibly
46+
# truncated ('yyyy', 'yyyy-mm') input strings.
47+
# Using `lubridate::ceiling_date` instead results in even more code on our part, since
48+
# that call assumes that all input dates have a homogeneous precision, which is not the case
49+
# for us.
50+
#
51+
# In any case, the point is moot because we now require users of `dv.papo` to provide Date
52+
# objects and this function is a (non-exported) helper to deal with character dates.
53+
3654
label <- attr(data, "label")
3755

3856
data <- substr(data, 1, 10)

man/robust_ymd.Rd

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)