diff --git a/R/check_papo_call_manual.R b/R/check_papo_call_manual.R index 0f5526f..b896544 100644 --- a/R/check_papo_call_manual.R +++ b/R/check_papo_call_manual.R @@ -1,4 +1,4 @@ -# nolint start object_usage_linter +# nolint start object_usage_linter # styler: off # TODO: Generate from mod_patient_profile_API # This function has been written manually, but mod_patient_profile_API carries diff --git a/R/create_plots.R b/R/create_plots.R index bdf945a..6d47eaf 100644 --- a/R/create_plots.R +++ b/R/create_plots.R @@ -29,57 +29,62 @@ create_ae_cm_plot <- function(data, x_limits, palette, sl_info, vline_vars, vlin p <- ggplot2::ggplot(data, ggplot2::aes(x = .data[["start_day_z"]], y = .data[["decode"]])) p <- p + ggplot2::theme_bw() - p <- p + ggplot2::geom_rect(ggplot2::aes( - xmin = .data[["start_day_z"]], - xmax = .data[["end_day_z"]], - ymin = .data[["decode"]], - ymax = .data[["decode"]], - color = grading - ), - size = 3 + p <- p + ggplot2::geom_rect( + ggplot2::aes( + xmin = .data[["start_day_z"]], + xmax = .data[["end_day_z"]], + ymin = .data[["decode"]], + ymax = .data[["decode"]], + color = grading + ), + size = 3 ) if ("serious_ae" %in% names(data)) { sae_labels <- ifelse(data[["serious_ae"]], "SAE", "") - p <- p + ggplot2::geom_text(ggplot2::aes( - x = .data[["start_day_z"]], - y = .data[["decode"]], - label = sae_labels - ), - colour = "red", nudge_y = 0.25, nudge_x = 1, size = 3 + p <- p + ggplot2::geom_text( + ggplot2::aes( + x = .data[["start_day_z"]], + y = .data[["decode"]], + label = sae_labels + ), + colour = "red", nudge_y = 0.25, nudge_x = 1, size = 3 ) } # hack to allow hover info at the beginning of the range through transparent dots - p <- p + ggplot2::geom_point(ggplot2::aes( - x = .data[["start_day_z"]], - y = .data[["decode"]], - color = grading - ), - size = 5, alpha = 0, show.legend = FALSE + p <- p + ggplot2::geom_point( + ggplot2::aes( + x = .data[["start_day_z"]], + y = .data[["decode"]], + color = grading + ), + size = 5, alpha = 0, show.legend = FALSE ) p <- p + ggplot2::scale_colour_manual(name = "Legend", values = palette) p <- p + ggplot2::scale_fill_manual(name = "Legend", values = palette) if (any(!is.na(data[["arrow_left"]]))) { - p <- p + ggplot2::geom_text(ggplot2::aes( - x = .data[["arrow_left_z"]] - .5, - y = .data[["decode"]], - label = sprintf("\u2190"), - color = grading - ), - size = 10, show.legend = FALSE + p <- p + ggplot2::geom_text( + ggplot2::aes( + x = .data[["arrow_left_z"]] - .5, + y = .data[["decode"]], + label = sprintf("\u2190"), + color = grading + ), + size = 10, show.legend = FALSE ) } if (any(!is.na(data[["arrow_right"]]))) { - p <- p + ggplot2::geom_text(ggplot2::aes( - x = .data[["arrow_right_z"]] + .7, - y = .data[["decode"]], - label = sprintf("\u2192"), - color = grading - ), - size = 10, show.legend = FALSE + p <- p + ggplot2::geom_text( + ggplot2::aes( + x = .data[["arrow_right_z"]] + .7, + y = .data[["decode"]], + label = sprintf("\u2192"), + color = grading + ), + size = 10, show.legend = FALSE ) } @@ -158,12 +163,13 @@ create_lb_vs_plot <- function(data, date, val, low_limit, high_limit, param, sum plot <- plot + ggplot2::geom_line(ggplot2::aes(linetype = .data[[param]]), size = 0.1) } else { summary_stats_label <- attr(data[[summary_stats]], "label") - plot <- plot + ggplot2::geom_line(ggplot2::aes( - x = .data[["date_z"]], - y = .data[[summary_stats]], - linetype = summary_stats_label - ), - size = 0.1 + plot <- plot + ggplot2::geom_line( + ggplot2::aes( + x = .data[["date_z"]], + y = .data[[summary_stats]], + linetype = summary_stats_label + ), + size = 0.1 ) } diff --git a/R/dressing_room.R b/R/dressing_room.R index 53141c6..ba5e20b 100644 --- a/R/dressing_room.R +++ b/R/dressing_room.R @@ -54,7 +54,7 @@ T_is_of_kind <- function(var, type) { res <- (is.integer(var) || (is.numeric(var) && all(var[is.finite(var)] %% 1 == 0))) && all(var[is.finite(var)] != 0) } else if (type[["kind"]] == "YN") { res <- ((is.character(var) && setequal(unique(var), c("Y", "N"))) || - is.factor(var) && setequal(levels(var), c("Y", "N"))) + is.factor(var) && setequal(levels(var), c("Y", "N"))) } else { browser() } @@ -405,8 +405,10 @@ explorer_ui <- function() { shiny::div( class = "col-sm-3", panel( - shiny::h4("DaVinci's Module Dressing Room", align = "center", - style = "margin-top:0; margin-bottom:2rem; font-weight:bold"), + shiny::h4("DaVinci's Module Dressing Room", + align = "center", + style = "margin-top:0; margin-bottom:2rem; font-weight:bold" + ), inline_shiny_input( shiny::selectInput( inputId = "spec", label = NULL, diff --git a/R/mod_patient_info.R b/R/mod_patient_info.R index d0e158d..60fe06a 100644 --- a/R/mod_patient_info.R +++ b/R/mod_patient_info.R @@ -26,7 +26,6 @@ patient_info_server <- function(id, record, subjid_var, column_count = 3) { shiny::moduleServer( id, function(input, output, session) { - # parts in ui_out output$ui_out <- shiny::renderUI({ shiny::req(nrow(record()) == 1 && ncol(record()) > 0) diff --git a/R/prep_safety_data.R b/R/prep_safety_data.R index f19f92a..00caead 100644 --- a/R/prep_safety_data.R +++ b/R/prep_safety_data.R @@ -18,7 +18,7 @@ prep_safety_data <- function(n = 200) { } adsl_info <- safetyData::adam_adsl[1:n, ] - adsl_info[["TRTSDT"]] <- robust_ymd(adsl_info[["TRTSDT"]]) |> structure(label = "Treatment Start Date") + adsl_info[["TRTSDT"]] <- robust_ymd(adsl_info[["TRTSDT"]]) |> structure(label = "Treatment Start Date") adsl_info[["TRTEDT"]] <- robust_ymd(adsl_info[["TRTEDT"]], round_up = TRUE) |> structure(label = "Treatment End Date") adsl_info[["RFICDT"]] <- robust_ymd(adsl_info[["RFSTDTC"]]) |> structure(label = "Informed Consent Date") adsl_info[["TRTDUR"]] <- as.numeric(adsl_info[["TRTDUR"]]) |> structure(label = "Treatment duration (days)") @@ -44,18 +44,18 @@ prep_safety_data <- function(n = 200) { # vs vs_info <- safetyData::adam_advs |> dplyr::left_join(safetyData::adam_advs |> - dplyr::group_by(.data[["USUBJID"]], .data[["PARAM"]], .data[["VISIT"]]) |> - dplyr::summarise(AVAL_MEAN = mean(as.numeric(.data$AVAL)), .groups = "drop") |> - dplyr::ungroup(), by = c("USUBJID", "PARAM", "VISIT")) + dplyr::group_by(.data[["USUBJID"]], .data[["PARAM"]], .data[["VISIT"]]) |> + dplyr::summarise(AVAL_MEAN = mean(as.numeric(.data$AVAL)), .groups = "drop") |> + dplyr::ungroup(), by = c("USUBJID", "PARAM", "VISIT")) attr(vs_info[["AVAL_MEAN"]], "label") <- "Mean Value" # lb lb_info <- safetyData::adam_adlbc |> dplyr::left_join(safetyData::adam_adlbc |> - dplyr::group_by(.data[["USUBJID"]], .data[["PARAM"]], .data[["VISIT"]]) |> - dplyr::summarise(AVAL_MEAN = mean(as.numeric(.data$AVAL)), .groups = "drop") |> - dplyr::ungroup(), by = c("USUBJID", "PARAM", "VISIT")) |> + dplyr::group_by(.data[["USUBJID"]], .data[["PARAM"]], .data[["VISIT"]]) |> + dplyr::summarise(AVAL_MEAN = mean(as.numeric(.data$AVAL)), .groups = "drop") |> + dplyr::ungroup(), by = c("USUBJID", "PARAM", "VISIT")) |> dplyr::filter( .data$USUBJID %in% adsl_info$USUBJID ) diff --git a/README.Rmd b/README.Rmd index 3cffa78..00d4687 100644 --- a/README.Rmd +++ b/README.Rmd @@ -10,7 +10,7 @@ output: knitr::opts_chunk$set( collapse = TRUE, comment = "#>", - out.width = "100%", + out.width = "100%", tidy = "styler" ) ``` @@ -42,50 +42,50 @@ To use `dv.papo` inside a DaVinci app, add the module to your module list. The c See `vignette("a00-papo")` for further information on how to use `dv.papo` with `dv.manager`. ```{r example, eval = FALSE} - dataset_list <- list( - "demo" = dv.papo:::prep_safety_data(5), - "demo2" = dv.papo:::prep_safety_data(10) - ) +dataset_list <- list( + "demo" = dv.papo:::prep_safety_data(5), + "demo2" = dv.papo:::prep_safety_data(10) +) - module_list <- list( - "Patient Profile" = dv.papo::mod_patient_profile( - module_id = "papo", - subject_level_dataset_name = "adsl", - subjid_var = "USUBJID", - summary = list( - vars = c("SUBJID", "SITEID", "ARM", "TRTSDT", "TRTEDT", "AGE", "RACE", "SEX", "BMIBL"), - column_count = 3L - ), - listings = list( - "Concomitant Medication" = list( - dataset = "cm" - ), - "Adverse Events" = list( - dataset = "adae", - default_vars = c("ASTDT", "ASTDY", "AENDT", "AENDY", "AEDECOD", "AESEV") - ) - ), - plots = list( - timeline_info = c(trt_start_date = "TRTSDT", trt_end_date = "TRTEDT"), - range_plots = list( - "Adverse Events" = list( - dataset = "adae", - vars = c( - start_date = "ASTDT", end_date = "AENDT", - decode = "AEDECOD", grading = "AESEV", serious_ae = "AESER" - ), - tooltip = c("AE Start Day: " = "ASTDY", "AE End Day: " = "AENDY") - ) - ), - value_plots = list(), - vline_vars = c("Informed Consent Date" = "RFICDT") - ) +module_list <- list( + "Patient Profile" = dv.papo::mod_patient_profile( + module_id = "papo", + subject_level_dataset_name = "adsl", + subjid_var = "USUBJID", + summary = list( + vars = c("SUBJID", "SITEID", "ARM", "TRTSDT", "TRTEDT", "AGE", "RACE", "SEX", "BMIBL"), + column_count = 3L + ), + listings = list( + "Concomitant Medication" = list( + dataset = "cm" + ), + "Adverse Events" = list( + dataset = "adae", + default_vars = c("ASTDT", "ASTDY", "AENDT", "AENDY", "AEDECOD", "AESEV") + ) + ), + plots = list( + timeline_info = c(trt_start_date = "TRTSDT", trt_end_date = "TRTEDT"), + range_plots = list( + "Adverse Events" = list( + dataset = "adae", + vars = c( + start_date = "ASTDT", end_date = "AENDT", + decode = "AEDECOD", grading = "AESEV", serious_ae = "AESER" + ), + tooltip = c("AE Start Day: " = "ASTDY", "AE End Day: " = "AENDY") + ) + ), + value_plots = list(), + vline_vars = c("Informed Consent Date" = "RFICDT") ) ) - - dv.manager::run_app( - data = dataset_list, - module_list = module_list, - filter_data = "adsl" - ) +) + +dv.manager::run_app( + data = dataset_list, + module_list = module_list, + filter_data = "adsl" +) ``` diff --git a/tests/testthat/apps/root/app.R b/tests/testthat/apps/root/app.R index 757728c..fe24c08 100644 --- a/tests/testthat/apps/root/app.R +++ b/tests/testthat/apps/root/app.R @@ -1,4 +1,3 @@ - # TODO(miguel): Avoid having to install the package when testing locally by following # dv.biomarker.general/browse/tests/testthat/app/app.R?at=dev # nolint (false positive for commented_code_linter) # to run the current version of the code diff --git a/vignettes/a02-communication.Rmd b/vignettes/a02-communication.Rmd index ed626ff..88bccd2 100644 --- a/vignettes/a02-communication.Rmd +++ b/vignettes/a02-communication.Rmd @@ -38,7 +38,7 @@ module_list <- list( module_id = "mod2", ..., # ommitted for brevity receiver_id = "mod1" - ) + ) ) ```