Skip to contents

Display patient profile plot as a shiny module

Usage

tm_g_patient_profile(
  label = "Patient Profile Plot",
  patient_id,
  sl_dataname,
  ex_dataname,
  ae_dataname,
  rs_dataname,
  cm_dataname,
  lb_dataname,
  show_ex_plot = TRUE,
  show_ae_plot = TRUE,
  show_rs_plot = TRUE,
  show_cm_plot = TRUE,
  show_lb_plot = TRUE,
  sl_start_date,
  ex_var = NULL,
  ae_var = NULL,
  ae_line_col_var = NULL,
  ae_line_col_opt = NULL,
  rs_var = NULL,
  cm_var = NULL,
  lb_var = NULL,
  x_limit = "-28, 365",
  plot_height = c(1200L, 400L, 5000L),
  plot_width = NULL,
  pre_output = NULL,
  post_output = NULL
)

Arguments

label

(character(1))
menu item label of the module in the teal app.

patient_id

(choices_seleced) unique subject ID variable

sl_dataname

(character) subject level dataset name, needs to be available in the list passed to the data argument of init

ex_dataname

(character) exposures dataset name, needs to be available in the list passed to the data argument of init
specify to NA if no exposure data is available

ae_dataname

(character) adverse events dataset name, needs to be available in the list passed to the data argument of init
specify to NA if no adverse events data is available

rs_dataname

(character) response dataset name, needs to be available in the list passed to the data argument of init
specify to NA if no response data is available

cm_dataname

(character) concomitant medications dataset name, needs to be available in the list passed to the data argument of init
specify to NA if no concomitant medications data is available

lb_dataname

(character) labs dataset name, needs to be available in the list passed to the data argument of init
specify to NA if no labs data is available

show_ex_plot

boolean value of whether exposures plot is shown, default is TRUE

show_ae_plot

boolean value of whether adverse events plot is shown, default is TRUE

show_rs_plot

boolean value of whether response plot is shown, default is TRUE

show_cm_plot

boolean value of whether concomitant medications plot is shown, default is TRUE

show_lb_plot

boolean value of whether labs plot is shown, default is TRUE

sl_start_date

(choices_selected) study start date variable, usually set to treatment start date or randomization date

ex_var

(choices_selected) exposure variable to plot as each line
leave unspecified or set to NULL if exposure data is not available

ae_var

(choices_selected) adverse event variable to plot as each line
leave unspecified or set to NULL if adverse events data is not available

ae_line_col_var

(choices_selected) variable for coloring AE lines
leave unspecified or set to NULL if adverse events data is not available

ae_line_col_opt

aesthetic values to map color values (named vector to map color values to each name). If not NULL, please make sure this contains all possible values for ae_line_col_var values.
leave unspecified or set to NULL if adverse events data is not available

rs_var

(choices_selected) response variable to plot as each line
leave unspecified or set to NULL if response data is not available

cm_var

(choices_selected) concomitant medication variable to plot as each line
leave unspecified or set to NULL if concomitant medications data is not available

lb_var

(choices_selected) lab variable to plot as each line
leave unspecified or set to NULL if labs data is not available

x_limit

a single character string with two numbers separated by a comma indicating the x-axis limit, default is "-28, 365"

plot_height

(numeric(3))
vector to indicate default value, minimum and maximum values.

plot_width

(numeric(3))
vector to indicate default value, minimum and maximum values.

pre_output

(shiny.tag, optional)
with text placed before the output to put the output into context. For example a title.

post_output

(shiny.tag, optional) with text placed after the output to put the output into context. For example the shiny::helpText() elements are useful.

Value

the teal::module() object.

Details

As the patient profile module plots different domains in one plot, the study day (x-axis) is derived for consistency based the start date of user's choice in the app (for example, ADSL.RANDDT or ADSL.TRTSDT):

  • In ADAE, ADEX, and ADCM, it would be study day based on ASTDT and/or AENDT in reference to the start date

  • In ADRS and ADLB, it would be study day based on ADT in reference to the start date

Author

Xuefeng Hou (houx14) houx14@gene.com

Tina Cho (chot) tina.cho@roche.com

Molly He (hey59) hey59@gene.com

Ting Qi (qit3) qit3@gene.com

Examples

library(scda)

ADSL <- synthetic_cdisc_data("latest")$adsl
ADAE <- synthetic_cdisc_data("latest")$adae %>%
  mutate(
    ASTDT = as.Date(ASTDTM),
    AENDT = as.Date(AENDTM)
  )
ADCM <- synthetic_cdisc_data("latest")$adcm %>%
  mutate(
    ASTDT = as.Date(ASTDTM),
    AENDT = as.Date(AENDTM)
  )

# The step below is to pre-process ADCM to legacy standard
ADCM <- ADCM %>%
  select(-starts_with("ATC")) %>%
  unique()

ADRS <- synthetic_cdisc_data("latest")$adrs %>%
  mutate(ADT = as.Date(ADTM))
ADEX <- synthetic_cdisc_data("latest")$adex %>%
  mutate(
    ASTDT = as.Date(ASTDTM),
    AENDT = as.Date(AENDTM)
  )
ADLB <- synthetic_cdisc_data("latest")$adlb %>%
  mutate(
    ADT = as.Date(ADTM),
    LBSTRESN = as.numeric(LBSTRESC)
  )

x <- init(
  data = cdisc_data(
    cdisc_dataset("ADSL", ADSL,
      code = "ADSL <- synthetic_cdisc_data(\"latest\")$adsl"
    ),
    cdisc_dataset("ADRS", ADRS,
      code = "ADRS <- synthetic_cdisc_data(\"latest\")$adrs %>%
              mutate(ADT = as.Date(ADTM))"
    ),
    cdisc_dataset("ADAE", ADAE,
      code = "ADAE <- synthetic_cdisc_data(\"latest\")$adae %>%
              mutate(ASTDT = as.Date(ASTDTM),
                     AENDT = as.Date(AENDTM))"
    ),
    cdisc_dataset("ADCM", ADCM,
      code = "ADCM <- synthetic_cdisc_data(\"latest\")$adcm %>%
              mutate(ASTDT = as.Date(ASTDTM),
                     AENDT = as.Date(AENDTM))
              ADCM <- ADCM %>% select(-starts_with(\"ATC\")) %>% unique()",
      keys = c("STUDYID", "USUBJID", "ASTDTM", "CMSEQ", "CMDECOD")
    ),
    cdisc_dataset("ADLB", ADLB,
      code = "ADLB <- synthetic_cdisc_data(\"latest\")$adlb %>%
              mutate(ADT = as.Date(ADTM),
                     LBSTRESN = as.numeric(LBSTRESC))"
    ),
    cdisc_dataset("ADEX", ADEX,
      code = "ADEX <- synthetic_cdisc_data(\"latest\")$adex %>%
              mutate(ASTDT = as.Date(ASTDTM),
                     AENDT = as.Date(AENDTM))"
    ),
    check = TRUE
  ),
  modules = modules(
    tm_g_patient_profile(
      label = "Patient Profile Plot",
      patient_id = choices_selected(
        choices = unique(ADSL$USUBJID),
        selected = unique(ADSL$USUBJID)[1]
      ),
      sl_dataname = "ADSL",
      ex_dataname = "ADEX",
      ae_dataname = "ADAE",
      rs_dataname = "ADRS",
      cm_dataname = "ADCM",
      lb_dataname = "ADLB",
      show_ex_plot = TRUE,
      show_ae_plot = TRUE,
      show_rs_plot = TRUE,
      show_cm_plot = FALSE,
      show_lb_plot = TRUE,
      sl_start_date = choices_selected(
        selected = "TRTSDTM",
        choices = c("TRTSDTM", "RANDDT")
      ),
      ex_var = choices_selected(
        selected = "PARCAT2",
        choices = "PARCAT2"
      ),
      ae_var = choices_selected(
        selected = "AEDECOD",
        choices = c("AEDECOD", "AESOC")
      ),
      ae_line_col_var = choices_selected(
        selected = "AESER",
        choices = c("AESER", "AEREL")
      ),
      ae_line_col_opt = c("Y" = "red", "N" = "blue"),
      rs_var = choices_selected(
        selected = "PARAMCD",
        choices = "PARAMCD"
      ),
      cm_var = choices_selected(
        selected = "CMDECOD",
        choices = c("CMDECOD", "CMCAT")
      ),
      lb_var = choices_selected(
        selected = "LBTESTCD",
        choices = c("LBTESTCD", "LBCAT")
      ),
      x_limit = "-28, 750",
      plot_height = c(1200, 400, 5000)
    )
  )
)
if (FALSE) {
shinyApp(x$ui, x$server)
}