Skip to content
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
993babd
Add numericRangeInput widget for x and y axes
luffmark Apr 23, 2025
afa93b5
Remove commented code
luffmark Apr 23, 2025
1ea37fa
Add test for x and y axes ranges
luffmark Apr 24, 2025
d041303
Use all_of() and fix mod_edish test
luffmark Apr 24, 2025
0613c7f
Update range id lookup
luffmark Apr 24, 2025
e1ed7b6
Fix issue with range id ref, and update upper limit of axes
luffmark Apr 25, 2025
4d709ed
Fix issues with 05-mod_edish test
luffmark Apr 28, 2025
184f78b
Fix snapshot
luffmark Apr 28, 2025
6972dd1
Fix comment in code
luffmark Apr 28, 2025
e613173
Update bookmarking test
luffmark Apr 28, 2025
19761c5
Add ranges to bookmark test
luffmark Apr 28, 2025
ae677e7
Update bookmarking test
luffmark Apr 29, 2025
a21dc28
Modify range in bookmarking test
luffmark Apr 29, 2025
011b631
Try to fix failing bookmarking test
luffmark Apr 29, 2025
571d038
Try to fix bookmarking test
luffmark Apr 29, 2025
82f02f7
Update handling of x- and y-axis ranges
luffmark May 2, 2025
a3f76bc
Update tests
luffmark May 2, 2025
936f325
Fix snapshot
luffmark May 2, 2025
c49bc75
Debugging test
luffmark May 2, 2025
b557b98
Debug test
luffmark May 2, 2025
1e223e1
debug
luffmark May 2, 2025
e320a89
debug
luffmark May 2, 2025
f03f774
debug
luffmark May 2, 2025
aa2e10b
debug
luffmark May 2, 2025
a630678
Update header of function
luffmark May 2, 2025
bc18d57
fix range testing
zsigmas May 5, 2025
205e200
Update test
luffmark May 5, 2025
258005e
Set x_ref as decimal to avoid type mismatch
luffmark May 5, 2025
83ae910
Address review comment - change point to limit in comment
luffmark May 6, 2025
c32864f
Update documentation
luffmark May 6, 2025
3502d64
Fix range widget label
luffmark May 6, 2025
1b2171c
Update screenshot for README.md
luffmark May 7, 2025
edfaa53
Build documentation
luffmark May 8, 2025
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
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
Package: dv.edish
Type: Package
Title: eDISH Plot Module for DILI assessment
Version: 1.1.0
Version: 1.1.0-1
Authors@R:
c(
person("Boehringer-Ingelheim Pharma GmbH & Co.KG", role = c("cph", "fnd")),
person("Isabel", "Glauss", email = "isabel.glauss@boehringer-ingelheim.com", role = c("aut", "cre"))
person("Isabel", "Glauss", email = "isabel.glauss@boehringer-ingelheim.com", role = c("aut", "cre")),
person("Mark", "Luff", email = "mark.luff.ext@boehringer-ingelheim.com", role = "aut")
)
Description: This DaVinci package contains a module which is meant to support the assessment of drug-induced liver
injury by means of the (modified) evaluation of Drug-Induced Serious Hepatotoxicity plot.
Expand Down
5 changes: 4 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# dv.edish 1.1.0-1

- The user can now specify the x- and y-axis range limits, or go with the default `{plotly}` ranges.

# dv.edish 1.1.0

- Remove support for data dispatchers.
Expand All @@ -18,7 +22,6 @@
- When there is no data to display, e.g., due to filter settings, the module will provide a meaningful output.
- The module has been updated to show commonly used default values for reference lines. For the x-axis, the default value is 3, and for the y-axis, the default value is 2.


# dv.edish 1.0.1

- Bugfix: Bookmarking the app's state failed for arm and parameter selection but is fixed now.
Expand Down
50 changes: 43 additions & 7 deletions R/helper_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ filter_data <- function(dataset, arm_var, sel_arm, lb_test_var, sel_lb_test) {
#'
#' @param dataset `[data.frame]`
#'
#' A dataframe containing the variables listed below as columns.
#' A data frame containing the variables listed below as columns.
#' @param subjectid_var `[character(1)]`
#'
#' Name of the variable containing the unique subject IDs.
Expand Down Expand Up @@ -175,7 +175,7 @@ derive_req_vars <- function(
return(NULL)
}

# Get the data-frame in required structure (Pivot wider grouped by certain variables)
# Get the data frame in required structure (Pivot wider grouped by certain variables)
dataset <- dataset %>%
dplyr::filter(.data[[lb_test_var]] %in% c(sel_x, sel_y)) %>%
dplyr::mutate(
Expand All @@ -185,7 +185,7 @@ derive_req_vars <- function(
dplyr::select(dplyr::all_of(c(subjectid_var, arm_var, lb_test_var, visit_var, "r_ULN", "r_Baseline"))) %>%
dplyr::group_by(.data[[subjectid_var]], .data[[arm_var]], .data[[lb_test_var]], .data[[visit_var]]) %>%
dplyr::mutate(row = dplyr::row_number()) %>%
tidyr::pivot_wider(names_from = lb_test_var, values_from = c("r_ULN", "r_Baseline")) %>%
tidyr::pivot_wider(names_from = tidyr::all_of(lb_test_var), values_from = c("r_ULN", "r_Baseline")) %>%
dplyr::select(-dplyr::all_of("row")) %>%
dplyr::mutate(
"r_ULN_{{sel_x}}" = as.numeric(.data[[paste0("r_ULN_", sel_x)]]),
Expand All @@ -205,7 +205,7 @@ derive_req_vars <- function(
#'
#' @param dataset `[data.frame]`
#'
#' A dataframe containing the variables listed below as columns.
#' A data frame containing the variables listed below as columns.
#' @param subjectid_var `[character(1)]`
#'
#' Name of the variable containing the unique subject IDs.
Expand All @@ -229,6 +229,24 @@ derive_req_vars <- function(
#'
#' Character specifying the plot type for the y-axis. This leads to
#' using the `dataset`'s column "r_<y_plot_type>_<y_sel>" for the y-values.
#' @param x_ref_line_num `[numeric(1)]`
#'
#' Numeric specifying the reference line for the x-axis.
#' @param y_ref_line_num `[numeric(1)]`
#'
#' Numeric specifying the reference line for the y-axis.
#' @param x_rng_lower `[numeric(1)]`
#'
#' Numeric specifying the lower limit in the x-axis range.
#' @param x_rng_upper `[numeric(1)]`
#'
#' Numeric specifying the upper limit in the x-axis range.
#' @param y_rng_lower `[numeric(1)]`
#'
#' Numeric specifying the lower limit in the y-axis range.
#' @param y_rng_upper `[numeric(1)]`
#'
#' Numeric specifying the upper limit in the y-axis range.
#'
Comment thread
luffmark marked this conversation as resolved.
#' @return A plotly object specifying the generated eDISH plot.
#'
Expand All @@ -243,11 +261,29 @@ generate_plot <- function(
x_plot_type,
y_plot_type,
x_ref_line_num,
y_ref_line_num) {
y_ref_line_num,
x_rng_lower,
x_rng_upper,
y_rng_lower,
y_rng_upper) {
if (is.null(dataset)) {
return(dataset)
}

# Prepare x-axis layout based on whether range has been specified
layout_xaxis <- list(title = paste0(sel_x, "/", x_plot_type))
if (!is.null(x_rng_lower) && !is.null(x_rng_upper)) {
layout_xaxis <- c(layout_xaxis,
list(range = c(x_rng_lower, x_rng_upper)))
}

# Prepare y-axis layout based on whether range has been specified
layout_yaxis <- list(title = paste0(sel_y, "/", y_plot_type))
if (!is.null(y_rng_lower) && !is.null(y_rng_upper)) {
layout_yaxis <- c(layout_yaxis,
list(range = c(y_rng_lower, y_rng_upper)))
}

Comment thread
luffmark marked this conversation as resolved.
plt_obj <- dataset %>%
plotly::plot_ly(type = "scatter", mode = "markers", color = .[[arm_var]]) %>%
plotly::add_trace(
Expand All @@ -263,8 +299,8 @@ generate_plot <- function(
hoverinfo = "text"
) %>%
plotly::layout(
xaxis = list(title = paste0(sel_x, "/", x_plot_type)),
yaxis = list(title = paste0(sel_y, "/", y_plot_type)),
xaxis = layout_xaxis,
yaxis = layout_yaxis,
shapes = list(
list( # vline
type = "line",
Expand Down
30 changes: 26 additions & 4 deletions R/mod_edish.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ EDISH <- pack_of_constants(
X_REF_ID = "x_ref",
Y_REF_ID = "y_ref",
REF_LABEL = "Reference line:",
X_RNG_ID = "x_rng",
Y_RNG_ID = "y_rng",
RNG_LABEL = "Range:",
X_PLOT_TYPE_ID = "x_plot_type",
Y_PLOT_TYPE_ID = "y_plot_type",
PLOT_TYPE_CHOICES = c("x ULN (eDISH)", "x Baseline (mDISH)"),
PLOT_TYPE_CHOICES = c("\u00d7 ULN (eDISH)" = "ULN",
"\u00d7 Baseline (mDISH)" = "Baseline"),
PLOT_ID = "plot",
NO_PLOT = "noplot"
)
Expand Down Expand Up @@ -59,6 +63,14 @@ edish_UI <- function(module_id) {
max = 100,
step = 0.5
),
shinyWidgets::numericRangeInput(
inputId = ns(EDISH$X_RNG_ID),
label = EDISH$RNG_LABEL,
value = c(NA, NA),
min = 0,
max = 100,
step = 0.1
),
shiny::radioButtons(
inputId = ns(EDISH$X_PLOT_TYPE_ID),
label = NULL,
Expand All @@ -79,6 +91,14 @@ edish_UI <- function(module_id) {
max = 100,
step = 0.5
),
shinyWidgets::numericRangeInput(
inputId = ns(EDISH$Y_RNG_ID),
label = EDISH$RNG_LABEL,
value = c(NA, NA),
min = 0,
max = 100,
step = 0.1
),
shiny::radioButtons(
inputId = ns(EDISH$Y_PLOT_TYPE_ID),
label = NULL,
Expand Down Expand Up @@ -269,9 +289,11 @@ edish_server <- function(
dataset = plot_data(),
subjectid_var = subjectid_var, arm_var = arm_var, visit_var = visit_var,
sel_x = input[[EDISH$X_AXIS_ID]], sel_y = input[[EDISH$Y_AXIS_ID]],
x_plot_type = ifelse(grepl("eDISH", input[[EDISH$X_PLOT_TYPE_ID]]), "ULN", "Baseline"),
y_plot_type = ifelse(grepl("eDISH", input[[EDISH$Y_PLOT_TYPE_ID]]), "ULN", "Baseline"),
x_ref_line_num = input[[EDISH$X_REF_ID]], y_ref_line_num = input[[EDISH$Y_REF_ID]]
x_plot_type = input[[EDISH$X_PLOT_TYPE_ID]],
y_plot_type = input[[EDISH$Y_PLOT_TYPE_ID]],
x_ref_line_num = input[[EDISH$X_REF_ID]], y_ref_line_num = input[[EDISH$Y_REF_ID]],
x_rng_lower = input[[EDISH$X_RNG_ID]][1], x_rng_upper = input[[EDISH$X_RNG_ID]][2],
y_rng_lower = input[[EDISH$Y_RNG_ID]][1], y_rng_upper = input[[EDISH$Y_RNG_ID]][2]
)
)

Expand Down
29 changes: 17 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# eDISH Module

The {dv.edish} package is meant to support the assessment of drug-induced liver injury
by means of the (modified) evaluation of Drug-Induced Serious Hepatotoxicity plot.
The eDISH module supports the assessment of drug-induced liver injury by means of the (modified)
evaluation of Drug-Induced Serious Hepatotoxicity plot.

![](man/figures/full_app.png)

Expand All @@ -14,19 +14,24 @@ remotes::install_github("Boehringer-Ingelheim/dv.edish")

## Features

The eDISH module shows a scatter plot depicting correlations of two lab parameters on subject-level.
The parameter to be displayed on each axis can be selected by the app user.
Moreover, the parameters can be displayed in multiples of either their upper limit normals
(resulting in the eDISH plot) or the corresponding subject's baseline values (resulting in the mDISH plot).
Horizontal and vertical lines are indicating Hy's law and are customizable as well within the input menu.
The eDISH module shows a scatter plot depicting correlations of two lab parameters on a
subject-level.

The parameter to be displayed on each axis can be selected by the app user. Moreover, the parameters
can be displayed in multiples of either their upper limit normals (resulting in the eDISH plot) or
the corresponding subject's baseline values (resulting in the mDISH plot).

Horizontal and vertical reference lines indicate Hy's law multiples and can be updated by the user.

By default, the x- and y-axis ranges are determined by the data, but the user can specify their own
ranges. Both lower and upper values of an axis range need to be specified for the range to take
effect. If either value is missing then the default axis range is used.

## Creating an eDISH application

The following example shows how to set up a simple DaVinci app by means of {dv.manager}.
The app contains the eDISH module to display dummy data provided by the {pharmaverseadam} package:


``` r
dm <- pharmaverseadam::adsl
lb <- pharmaverseadam::adlb
Expand All @@ -50,13 +55,15 @@ dv.manager::run_app(

Note that the module expects two datasets:

- A Demographics dataset (e.g. `dm` or `adsl`) including, at least, variables containing the following information:
- A Demographics dataset (e.g. `dm` or `adsl`) including, at least, variables containing the
following information:

- Unique subject identifier (e.g. `USUBJID`)

- Arm (e.g. `ACTARM`)

- A Laboratory Test Results dataset (e.g. `lb` or `adlb`) including, at least, variables containing the following information:
- A Laboratory Test Results dataset (e.g. `lb` or `adlb`) including, at least, variables containing
the following information:

- Unique subject identifier (e.g. `USUBJID`)

Expand All @@ -67,5 +74,3 @@ Note that the module expects two datasets:
- Numeric lab test result (e.g. `LBSTRESN`)

- Lab test reference range upper limit (e.g. `LBSTNRHI`)


1 change: 1 addition & 0 deletions inst/validation/specs.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ plot_specs <- specs_list(
normalization = "The plot displays data normalized according to the selected method.",
axis_labels = "The plot's axis are labelled according to the parameter selection and normalization method.",
ref_lines = "The plot displays the specified reference lines.",
axis_ranges = "The plot shows the x- and y-axis ranges according to specified lower and upper limits.",
hovering = "The plot shows details when hovering over a data point.",
multiple_vals = "In case of multiple values per subject, visit, and lab test, only the maximum value should be shown."
)
Expand Down
Binary file modified man/figures/full_app.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions tests/testthat/_snaps/05-mod_edish.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,26 @@
[1] "test 1"

$input$`edish-x_plot_type`
[1] "x ULN (eDISH)"
[1] "ULN"

$input$`edish-x_ref`
[1] 3

$input$`edish-x_rng`
NULL

$input$`edish-y_axis`
[1] "test 2"

$input$`edish-y_plot_type`
[1] "x ULN (eDISH)"
[1] "ULN"

$input$`edish-y_ref`
[1] 2

$input$`edish-y_rng`
NULL

$input$`plotly_afterplot-A`
[1] "\"edish-plot\""

Expand Down
22 changes: 21 additions & 1 deletion tests/testthat/test-04-generate_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ x_plot_type <- "ULN"
y_plot_type <- "Baseline"
x_ref_line_num <- 3
y_ref_line_num <- 2
x_rng_lower <- 0
x_rng_upper <- 10
y_rng_lower <- 0
y_rng_upper <- 10

# Invoke the function
plt_obj <- generate_plot(
Expand All @@ -60,7 +64,11 @@ plt_obj <- generate_plot(
x_plot_type = x_plot_type,
y_plot_type = y_plot_type,
x_ref_line_num = x_ref_line_num,
y_ref_line_num = y_ref_line_num
y_ref_line_num = y_ref_line_num,
x_rng_lower = x_rng_lower,
x_rng_upper = x_rng_upper,
y_rng_lower = y_rng_lower,
y_rng_upper = y_rng_upper
)

# Tests
Expand Down Expand Up @@ -110,6 +118,18 @@ test_that("the resulting plot object includes the correct reference lines" %>%
expect_identical(actual_y1, y_ref_line_num)
})

test_that("the resulting plot object includes the correct axis range" %>%
vdoc[["add_spec"]](specs$plot_specs$axis_ranges), {
actual_x <- plt_obj$x$layoutAttrs[[1]]$xaxis$range
actual_y <- plt_obj$x$layoutAttrs[[1]]$yaxis$range

expected_x <- c(x_rng_lower, x_rng_upper)
expected_y <- c(y_rng_lower, y_rng_upper)

expect_identical(actual_x, expected_x)
expect_identical(actual_y, expected_y)
})

test_that("the resulting plot object includes the correct coloring" %>%
vdoc[["add_spec"]](specs$plot_specs$arm_coloring), {
actual <- plt_obj$x$attrs[[1]]$color
Expand Down
Loading
Loading