Skip to contents

[Deprecated]

tm_g_gh_scatterplot is deprecated. Please use tm_g_gh_correlationplot instead.

Usage

tm_g_gh_scatterplot(
  label,
  dataname,
  param_var,
  param,
  xaxis_var,
  yaxis_var,
  trt_group,
  color_manual = NULL,
  shape_manual = NULL,
  facet_ncol = 2,
  trt_facet = FALSE,
  reg_line = FALSE,
  rotate_xlab = FALSE,
  hline = NULL,
  vline = NULL,
  plot_height = c(500, 200, 2000),
  plot_width = NULL,
  font_size = c(12, 8, 20),
  dot_size = c(1, 1, 12),
  reg_text_size = c(3, 3, 10),
  pre_output = NULL,
  post_output = NULL
)

Arguments

label

menu item label of the module in the teal app.

dataname

analysis data passed to the data argument of init. E.g. ADaM structured laboratory data frame ADLB.

param_var

name of variable containing biomarker codes e.g. PARAMCD.

param

biomarker selected.

xaxis_var

name of variable containing biomarker results displayed on x-axis e.g. BASE.

yaxis_var

name of variable containing biomarker results displayed on y-axis e.g. AVAL.

trt_group

choices_selected object with available choices and pre-selected option for variable names representing treatment group e.g. ARM.

color_manual

vector of colors applied to treatment values.

shape_manual

vector of symbols applied to LOQ values.

facet_ncol

numeric value indicating number of facets per row.

trt_facet

facet by treatment group trt_group.

reg_line

include regression line and annotations for slope and coefficient in visualization. Use with facet TRUE.

rotate_xlab

45 degree rotation of x-axis values.

hline

y-axis value to position of horizontal line.

vline

x-axis value to position a vertical line.

plot_height

controls plot height.

plot_width

optional, controls plot width.

font_size

font size control for title, x-axis label, y-axis label and legend.

dot_size

plot dot size.

reg_text_size

font size control for regression line annotations.

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.

Author

Nick Paszty (npaszty) paszty.nicholas@gene.com

Balazs Toth (tothb2) toth.balazs@gene.com

Examples

# Example using ADaM structure analysis dataset.

# original ARM value = dose value
arm_mapping <- list(
  "A: Drug X" = "150mg QD",
  "B: Placebo" = "Placebo",
  "C: Combination" = "Combination"
)

ADSL <- goshawk::rADSL
ADLB <- goshawk::rADLB
var_labels <- lapply(ADLB, function(x) attributes(x)$label)
ADLB <- ADLB %>%
  dplyr::mutate(
    AVISITCD = dplyr::case_when(
      AVISIT == "SCREENING" ~ "SCR",
      AVISIT == "BASELINE" ~ "BL",
      grepl("WEEK", AVISIT) ~ paste("W", stringr::str_extract(AVISIT, "(?<=(WEEK ))[0-9]+")),
      TRUE ~ as.character(NA)
    ),
    AVISITCDN = dplyr::case_when(
      AVISITCD == "SCR" ~ -2,
      AVISITCD == "BL" ~ 0,
      grepl("W", AVISITCD) ~ as.numeric(gsub("[^0-9]*", "", AVISITCD)),
      TRUE ~ as.numeric(NA)
    ),
    AVISITCD = factor(AVISITCD) %>% stats::reorder(AVISITCDN),
    TRTORD = dplyr::case_when(
      ARMCD == "ARM C" ~ 1,
      ARMCD == "ARM B" ~ 2,
      ARMCD == "ARM A" ~ 3
    ),
    ARM = as.character(arm_mapping[match(ARM, names(arm_mapping))]),
    ARM = factor(ARM) %>% stats::reorder(TRTORD),
    ACTARM = as.character(arm_mapping[match(ACTARM, names(arm_mapping))]),
    ACTARM = factor(ACTARM) %>% stats::reorder(TRTORD)
  )
attr(ADLB[["ARM"]], "label") <- var_labels[["ARM"]]
attr(ADLB[["ACTARM"]], "label") <- var_labels[["ACTARM"]]

app <- teal::init(
  data = teal.data::cdisc_data(
    adsl <- teal.data::cdisc_dataset("ADSL", ADSL, code = "ADSL <- goshawk::rADSL"),
    teal.data::cdisc_dataset(
      "ADLB",
      ADLB,
      code = "ADLB <- goshawk::rADLB
              var_labels <- lapply(ADLB, function(x) attributes(x)$label)
              ADLB <- ADLB %>%
                dplyr::mutate(AVISITCD = dplyr::case_when(
                    AVISIT == 'SCREENING' ~ 'SCR',
                    AVISIT == 'BASELINE' ~ 'BL',
                    grepl('WEEK', AVISIT) ~
                      paste('W', stringr::str_extract(AVISIT, '(?<=(WEEK ))[0-9]+')),
                    TRUE ~ as.character(NA)),
                  AVISITCDN = dplyr::case_when(
                    AVISITCD == 'SCR' ~ -2,
                    AVISITCD == 'BL' ~ 0,
                    grepl('W', AVISITCD) ~ as.numeric(gsub('[^0-9]*', '', AVISITCD)),
                    TRUE ~ as.numeric(NA)),
                  AVISITCD = factor(AVISITCD) %>% reorder(AVISITCDN),
                  TRTORD = dplyr::case_when(
                    ARMCD == 'ARM C' ~ 1,
                    ARMCD == 'ARM B' ~ 2,
                    ARMCD == 'ARM A' ~ 3),
                  ARM = as.character(arm_mapping[match(ARM, names(arm_mapping))]),
                  ARM = factor(ARM) %>% reorder(TRTORD),
                  ACTARM = as.character(arm_mapping[match(ACTARM, names(arm_mapping))]),
                  ACTARM = factor(ACTARM) %>% reorder(TRTORD))
               attr(ADLB[['ARM']], 'label') <- var_labels[['ARM']]
               attr(ADLB[['ACTARM']], 'label') <- var_labels[['ACTARM']]",
      vars = list(ADSL = adsl, arm_mapping = arm_mapping)
    ),
    check = TRUE
  ),
  modules = teal::modules(
    teal.goshawk::tm_g_gh_scatterplot(
      label = "Scatter Plot",
      dataname = "ADLB",
      param_var = "PARAMCD",
      param = choices_selected(c("ALT", "CRP", "IGA"), "ALT"),
      xaxis_var = choices_selected(c("AVAL", "BASE", "CHG", "PCHG"), "BASE"),
      yaxis_var = choices_selected(c("AVAL", "BASE", "CHG", "PCHG"), "AVAL"),
      trt_group = choices_selected(c("ARM", "ACTARM"), "ARM"),
      color_manual = c(
        "150mg QD" = "#000000",
        "Placebo" = "#3498DB",
        "Combination" = "#E74C3C"
      ),
      shape_manual = c("N" = 1, "Y" = 2, "NA" = 0),
      plot_height = c(500, 200, 2000),
      facet_ncol = 2,
      trt_facet = FALSE,
      reg_line = FALSE,
      font_size = c(12, 8, 20),
      dot_size = c(1, 1, 12),
      reg_text_size = c(3, 3, 10)
    )
  )
)
#> Warning: `tm_g_gh_scatterplot()` was deprecated in teal.goshawk 0.1.15.
#>  You should use teal.goshawk::tm_g_gh_correlationplot instead of
#>   teal.goshawk::tm_g_gh_scatterplot
#> [INFO] 2023-08-14 13:52:04.4837 pid:1122 token:[] teal.goshawk Initializing tm_g_gh_scatterplot
if (interactive()) {
  shinyApp(app$ui, app$server)
}