insightsengineering / teal.gallery

A Gallery of Exploratory Web Apps used for Analyzing Clinical Trial Data
https://insightsengineering.github.io/teal.gallery/
Other
29 stars 7 forks source link

[Bug]: `{nest_early-dev_dev}` `Error: rlang::hash(ADSL) == "30e7c11581bd01098a8be28263ef4995" is not TRUE` #143

Closed m7pr closed 8 months ago

m7pr commented 8 months ago

Similar to https://github.com/insightsengineering/teal.gallery/issues/137 in other app

Go here https://genentech.shinyapps.io/nest_early-dev_dev/ -> Adverse Events panel.

Click Show R Code.

Code is not runnable

> stopifnot(rlang::hash(ADSL) == "30e7c11581bd01098a8be28263ef4995")
Error: rlang::hash(ADSL) == "30e7c11581bd01098a8be28263ef4995" is not TRUE
> stopifnot(rlang::hash(ADAE) == "053de441150756031658354bcb4c5e1f")
Error: rlang::hash(ADAE) == "053de441150756031658354bcb4c5e1f" is not TRUE
image
# Add any code to install/load your NEST environment here

library(shiny)
library(teal.code)
library(teal.data)
library(teal.slice)
library(teal)
library(magrittr)
library(teal.transform)
library(formatters)
library(rtables)
library(tern)
library(teal.modules.clinical)
library(ggplot2)
library(ggmosaic)
library(shinyTree)
library(teal.modules.general)
library(dplyr)
library(osprey)
library(teal.osprey)
library(scda)
library(scda.2022)
library(nestcolor)
library(sparkline)

library(scda)
library(scda.2022)
library(dplyr)
library(nestcolor)
library(sparkline)
ADSL <- synthetic_cdisc_data("latest")$adsl
adsl_labels <- teal.data::col_labels(ADSL, fill = FALSE)
ADSL <- ADSL %>% mutate(TRTDURD = as.numeric(as.Date(TRTEDTM) - as.Date(TRTSDTM)) + 1, DTHFL = ifelse(!is.na(DTHDT), "Y", NA), EOSSTT = factor(EOSSTT, levels = c("COMPLETED", "ONGOING", "DISCONTINUED"))) %>% teal.data::col_relabel(TRTDURD = "Treatment Duration in Days", DTHFL = "Death Flag", DCSREAS = "Reason for Study Discontinuation", EOSSTT = "End of Study Status") %>% droplevels()
teal.data::col_labels(ADSL)[c(names(adsl_labels))] <- adsl_labels
ADAE <- synthetic_cdisc_data("latest")$adae
ADAE <- ADAE %>% mutate_at(c("AESOC", "AEBODSYS", "AEHLT", "AEDECOD", "AETERM", "AELLT"), as.character) %>% mutate(RELFL = ifelse(AEREL == "Y", "Y", "N"), CTC35FL = ifelse(AETOXGR %in% c("3", "4", "5"), "Y", "N"), SERFL = ifelse(AESER == "Y", "Y", "N"), RELSERFL = ifelse(AEREL == "Y" & AESER == "Y", "Y", "N"), AEREL1 = (AEREL == "Y" & ACTARM == "A: Drug X"), AEREL2 = (AEREL == "Y" & ACTARM == "B: Placebo"), ASTDT = as.Date(ASTDTM), AENDT = as.Date(AENDTM)) %>% teal.data::col_relabel(RELFL = "Related AE", 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        CTC35FL = "Grade >=3 AE", SERFL = "Serious AE", RELSERFL = "Related Serious AE", AEREL1 = "AE related to A: Drug X", AEREL2 = "AE related to B: Placebo", ASTDT = "Analysis Start Date", AENDT = "Analysis End Date", AESOC = "Primary System Organ Class", AEBODSYS = "Body System or Organ Class", AEHLT = "High Level Term", AEDECOD = "Dictionary-Derived Term", AETERM = "Reported Term for the Adverse Event", AELLT = "Lowest Level Term")

stopifnot(rlang::hash(ADSL) == "30e7c11581bd01098a8be28263ef4995")
stopifnot(rlang::hash(ADAE) == "053de441150756031658354bcb4c5e1f")

ADSL <- dplyr::filter(ADSL, SEX == "M")
ADAE <- dplyr::inner_join(x = ADAE, y = ADSL[, c("STUDYID", "USUBJID"), drop = FALSE], by = c("STUDYID", "USUBJID"))

ANL <- merge(x = ADSL[, c("USUBJID", "STUDYID", "ARM"), drop = FALSE], y = ADAE[, c("USUBJID", "STUDYID", "AEDECOD"), drop = FALSE], all.x = FALSE, all.y = FALSE, by = c("USUBJID", "STUDYID"))
plot <- osprey::g_events_term_id(term = ANL[["AEDECOD"]], id = ANL$USUBJID, arm = ANL[["ARM"]], arm_N = table(ADSL[["ARM"]]), ref = "A: Drug X", trt = "C: Combination", sort_by = NULL, rate_range = c(0.1, 1), diff_range = c(-0.5, 0.5), reversed = FALSE, conf_level = 0.95, diff_ci_method = "wald", axis_side = "left", fontsize = 5, draw = TRUE)
plot
donyunardi commented 8 months ago

I can run the code: image

Similar with this could be scda version issue.

m7pr commented 8 months ago

Yeah but this screenshot doesn't show you can run stopifnot part that I am referring to. If the code is runnable on one machine, but not runnable on another machine, we need to include more instructions on how to get this code runnable on all machines

donyunardi commented 8 months ago

Yeah but this screenshot doesn't show you can run stopifnot part that I am referring to.

I see, no I didn't get any error when running this.

m7pr commented 8 months ago

As this is similar to https://github.com/insightsengineering/teal.gallery/issues/137#issuecomment-1947181906 I will continue the conversation there and will close this issue.