Skip to contents

[Stable]

Display patient profile plot as a shiny module

Usage

tm_g_patient_profile(
  label = "Patient Profile Plot",
  patient_id,
  sl_dataname,
  ex_dataname = NA,
  ae_dataname = NA,
  rs_dataname = NA,
  cm_dataname = NA,
  lb_dataname = NA,
  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, ae_dataname, rs_dataname, cm_dataname, lb_dataname

(character(1)) names of exposure, adverse events, response, concomitant medications, and labs datasets, respectively; must be available in the list passed to the data argument of init
set to NA (default) to omit from analysis

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(nestcolor)

ADSL <- osprey::rADSL
ADAE <- osprey::rADAE %>%
  mutate(
    ASTDT = as.Date(ASTDTM),
    AENDT = as.Date(AENDTM)
  )
ADCM <- osprey::rADCM %>%
  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 <- osprey::rADRS %>%
  mutate(ADT = as.Date(ADTM))
ADEX <- osprey::rADEX %>%
  mutate(
    ASTDT = as.Date(ASTDTM),
    AENDT = as.Date(AENDTM)
  )
ADLB <- osprey::rADLB %>%
  mutate(
    ADT = as.Date(ADTM),
    LBSTRESN = as.numeric(LBSTRESC)
  )
#> Warning: There was 1 warning in `mutate()`.
#>  In argument: `LBSTRESN = as.numeric(LBSTRESC)`.
#> Caused by warning:
#> ! NAs introduced by coercion

app <- init(
  data = cdisc_data(
    cdisc_dataset("ADSL", ADSL, code = "ADSL <- osprey::rADSL"),
    cdisc_dataset("ADRS", ADRS, code = "ADRS <- osprey::rADRS %>% mutate(ADT = as.Date(ADTM))"),
    cdisc_dataset("ADAE", ADAE,
      code = "ADAE <- osprey::rADAE %>%
              mutate(ASTDT = as.Date(ASTDTM),
                     AENDT = as.Date(AENDTM))"
    ),
    cdisc_dataset("ADCM", ADCM,
      code = "ADCM <- osprey::rADCM %>%
              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 <- osprey::rADLB %>%
              mutate(ADT = as.Date(ADTM),
                     LBSTRESN = as.numeric(LBSTRESC))"
    ),
    cdisc_dataset("ADEX", ADEX,
      code = "ADEX <- osprey::rADEX %>%
              mutate(ASTDT = as.Date(ASTDTM),
                     AENDT = as.Date(AENDTM))"
    ),
    check = FALSE # set FALSE here to keep run time of example short, should be set to TRUE
  ),
  modules = modules(
    tm_g_patient_profile(
      label = "Patient Profile Plot",
      patient_id = teal.transform::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",
      sl_start_date = teal.transform::choices_selected(
        selected = "TRTSDTM",
        choices = c("TRTSDTM", "RANDDT")
      ),
      ex_var = teal.transform::choices_selected(
        selected = "PARCAT2",
        choices = "PARCAT2"
      ),
      ae_var = teal.transform::choices_selected(
        selected = "AEDECOD",
        choices = c("AEDECOD", "AESOC")
      ),
      ae_line_col_var = teal.transform::choices_selected(
        selected = "AESER",
        choices = c("AESER", "AEREL")
      ),
      ae_line_col_opt = c("Y" = "red", "N" = "blue"),
      rs_var = teal.transform::choices_selected(
        selected = "PARAMCD",
        choices = "PARAMCD"
      ),
      cm_var = teal.transform::choices_selected(
        selected = "CMDECOD",
        choices = c("CMDECOD", "CMCAT")
      ),
      lb_var = teal.transform::choices_selected(
        selected = "LBTESTCD",
        choices = c("LBTESTCD", "LBCAT")
      ),
      x_limit = "-28, 750",
      plot_height = c(1200, 400, 5000)
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}