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

SRC does not capture title and footnotes for modules which use ui_g_decorate #46

Open
nikolas-burkoff opened this issue Oct 4, 2021 · 4 comments

Comments

@nikolas-burkoff
Copy link
Contributor

https://rsconnect.roche.com/content/6127/

For example:

image

Give SRC without title and footnote:


# 
# Automatically generated R code
# 
#   Running: /opt/rstudio-connect/mnt/app
#        on: rkaub00459.kau.roche.com
# R version: R version 4.0.3 (2020-10-10)
#      Date: Mon Oct  4 16:12:01 2021
# 
# Current libraries loaded (derived by .libPaths()):
#   - /opt/bee/share/nest-packages/UAT_2021_10_01_fin/4.0.3/libs
#   - /opt/bee_tools/R/4.0.3/lib64/R/library
# 
# Packages versions: teal.osprey (0.1.11), osprey (0.1.11), teal.modules.general
#                    (0.2.11), ggmosaic (0.3.3), teal.modules.clinical (0.8.10),
#                    tern (0.7.5), optimx (2020-4.2), rtables (0.3.8.9101),
#                    magrittr (1.5), teal (0.10.0), ggplot2 (3.3.2), dplyr
#                    (1.0.2), scda (0.1.1), reticulate (1.18), shiny (1.5.0)
# 
# You can run this code interactively on http://r.roche.com
# 

# Next two lines are for using NEST packages on BEE (r.roche.com)
source("https://raw.github.roche.com/NEST/nest_on_bee/master/bee_nest_utils.R")
bee_use_nest(release = "UAT_2021_10_01_fin")

library(shiny)
library(reticulate)
library(scda)
library(dplyr)
library(ggplot2)
library(teal)
library(magrittr)
library(rtables)
library(optimx)
library(tern)
library(teal.modules.clinical)
library(ggmosaic)
library(teal.modules.general)
library(osprey)
library(teal.osprey)

ADSL <- synthetic_cdisc_data("latest")$adsl
adsl_labels <- rtables::var_labels(ADSL)
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"))) %>%
  rtables::var_relabel(TRTDURD = "Treatment Duration in Days", DTHFL = "Death Flag", DCSREAS = "Reason for Study Discontinuation", EOSSTT = "End of Study Status") %>%
  droplevels()
rtables::var_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)) %>%
  rtables::var_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"
  )



## NOTE: Reproducibility of data import and preprocessing was not
## explicitly checked (argument "check = FALSE" is set).
## The app developer has the choice to check the reproducibility
## and might have omitted this step for some reason. Please reach
## out to the app developer for details.

# ADSL MD5 hash at the time of analysis: 5682036b72676588166a34045edb7cfe
# ADAE MD5 hash at the time of analysis: 1c289c802f0c346ed30725f1cf116ff1


ADSL_FILTERED <- ADSL
ADAE_FILTERED_ALONE <- ADAE
ADAE_FILTERED <- dplyr::inner_join(x = ADAE_FILTERED_ALONE, y = ADSL_FILTERED[, c("STUDYID", "USUBJID"), drop = FALSE], by = c("STUDYID", "USUBJID"))



ANL <- merge(x = ADSL_FILTERED[, c("USUBJID", "STUDYID", "ARM"), drop = FALSE], y = ADAE_FILTERED[, c("USUBJID", "STUDYID", "AEDECOD"), drop = FALSE], all.x = FALSE, all.y = FALSE, by = c("USUBJID", "STUDYID"))
term <- ANL[["AEDECOD"]]
id <- ANL$USUBJID
arm <- ANL[["ARM"]]
arm_N <- table(ADSL_FILTERED[["ARM"]])
ref <- "A: Drug X"
trt <- "B: Placebo"
osprey::g_events_term_id(term = term, id = id, arm = arm, arm_N = arm_N, ref = "A: Drug X", trt = "B: Placebo", 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 = 5L, draw = TRUE)
@pawelru
Copy link
Contributor

pawelru commented Oct 4, 2021

this has been already reported in the past and the conclusion is that was never needed / required - closing

@pawelru pawelru closed this as completed Oct 4, 2021
@pawelru
Copy link
Contributor

pawelru commented Oct 4, 2021

Looks that I was wrong with my previous statement. I checked it and indeed it was reported but not closed. Moving to the main backlog then

@pawelru pawelru reopened this Oct 4, 2021
@pawelru
Copy link
Contributor

pawelru commented Nov 18, 2021

would be good to wait with that until more general approach would be in place https://github.com/insightsengineering/coredev-tasks/issues/361

@gogonzo
Copy link
Contributor

gogonzo commented Apr 26, 2022

It needs some solution. We have title, subtitle, footnote reproducible in tmc, and tmg where we use

  • teal.widgets::ggplot2_args which can't be used here (with grid plots). Extend ggplot2_args? (rather not)

  • We might consider here not using ui_g_decorate to decorate the object but maybe returning a call to be used in chunks.

  • We can also add title and footnotes in the chunks directly in each module (without srv_g_decorate).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants