Skip to contents

Principal component analysis module

Usage

tm_a_pca(
  label = "Principal Component Analysis",
  dat,
  plot_height = c(600, 200, 2000),
  plot_width = NULL,
  ggtheme = c("gray", "bw", "linedraw", "light", "dark", "minimal", "classic", "void",
    "test"),
  ggplot2_args = teal.widgets::ggplot2_args(),
  rotate_xaxis_labels = FALSE,
  font_size = c(12, 8, 20),
  alpha = c(1, 0, 1),
  size = c(2, 1, 8),
  pre_output = NULL,
  post_output = NULL
)

Arguments

label

(character) Label shown in the navigation item for the module.

dat

(data_extract_spec or list of multiple data_extract_spec) Datasets used to compute PCA.

plot_height

optional, (numeric) A vector of length three with c(value, min and max) for a slider encoding the plot height.

plot_width

optional, (numeric) A vector of length three with c(value, min and max) for a slider encoding the plot width.

ggtheme

optional, (character) ggplot2 theme to be used by default. One of c("gray", "bw", "linedraw", "light", "dark", "minimal", "classic", "void", "test"). Each theme can be chosen by the user during the session. Defaults to "gray".

ggplot2_args

optional, (ggplot2_args) object created by teal.widgets::ggplot2_args() with settings for all the plots or named list of ggplot2_args objects for plot-specific settings. The argument is merged with options variable teal.ggplot2_args and default module setup.

List names should match the following: c("default", "Elbow plot", "Circle plot", "Biplot", "Eigenvector plot").

For more details see the vignette: vignette("custom-ggplot2-arguments", package = "teal.widgets").

rotate_xaxis_labels

optional, (logical) Whether to rotate plot X axis labels. Does not rotate by default (FALSE).

font_size

optional, (numeric) font size control for title, x-axis label, y-axis label and legend. If scalar then the font size will have a fixed size. If a slider should be presented to adjust the plot point sizes dynamically then it can be a vector of length three with c(value, min, max).

alpha

optional, (numeric) If scalar then the plot points will have a fixed opacity. If a slider should be presented to adjust the plot point opacity dynamically then it can be a vector of length three with c(value, min, max).

size

optional, (numeric) If scalar then the plot point sizes will have a fixed size. If a slider should be presented to adjust the plot point sizes dynamically then it can be a vector of length three with c(value, min, max).

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.

Examples


# ADSL example

library(scda)
#> 
ADSL <- synthetic_cdisc_data("latest")$adsl

app <- teal::init(
  data = cdisc_data(cdisc_dataset(
    "ADSL", ADSL,
    code = "ADSL <- synthetic_cdisc_data(\"latest\")$adsl"
  ),
  check = TRUE
  ),
  modules = modules(
    tm_a_pca(
      "PCA",
      data_extract_spec(
        dataname = "ADSL",
        select = select_spec(
          choices = variable_choices(data = ADSL, c("BMRKR1", "AGE", "EOSDY")),
          selected = c("BMRKR1", "AGE"),
          multiple = TRUE
        ),
        filter = NULL
      ),
      ggplot2_args = teal.widgets::ggplot2_args(labs = list(subtitle = "Plot generated by PCA Module"))
    )
  )
)
#> [INFO] 2022-06-14 17:42:07.4991 pid:1110 token:[] teal.modules.general Initializing tm_a_pca
if (FALSE) {
shinyApp(app$ui, app$server)
}