timeProfileIntervalPlot: Visualize time intervals across subjects/parameters.

View source: R/plots-timeProfileIntervalPlot.R

timeProfileIntervalPlotR Documentation

Visualize time intervals across subjects/parameters.

Description

Visualize time intervals across subjects/parameters.

Usage

timeProfileIntervalPlot(
  data,
  paramVar,
  paramLab = getLabelVar(paramVar, labelVars = labelVars),
  paramVarSep = " - ",
  paramGroupVar = NULL,
  timeStartVar,
  timeStartLab = getLabelVar(timeStartVar, labelVars = labelVars),
  timeEndVar,
  timeEndLab = getLabelVar(timeEndVar, labelVars = labelVars),
  timeStartShapeVar = NULL,
  timeStartShapeLab = getLabelVar(timeStartShapeVar, labelVars = labelVars),
  timeEndShapeVar = NULL,
  timeEndShapeLab = getLabelVar(timeEndShapeVar, labelVars = labelVars),
  shapePalette = NULL,
  colorVar = NULL,
  colorLab = getLabelVar(colorVar, labelVars = labelVars),
  colorPalette = NULL,
  alpha = 1,
  yLab = NULL,
  xLab = paste(c(timeStartLab, timeEndLab), collapse = " and "),
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  labelVars = NULL,
  width = 800,
  height = NULL,
  hoverVars,
  hoverLab,
  idVar = "USUBJID",
  idLab = getLabelVar(idVar, labelVars = labelVars),
  pathVar = NULL,
  pathLab = getLabelVar(pathVar, labelVars = labelVars),
  id = paste0("plotClinData", sample.int(n = 1000, size = 1)),
  selectVars = NULL,
  selectLab = getLabelVar(selectVars, labelVars = labelVars),
  table = FALSE,
  tableVars,
  tableLab,
  tableButton = TRUE,
  tablePars = list(),
  verbose = FALSE
)

Arguments

data

Data.frame with data.

paramVar

Character vector with variable of data to represent in the y-axis.

paramLab

(optional) String with label for paramVar.

paramVarSep

(optional) String with separator used to combined paramVar if multiple.

paramGroupVar

(optional) Character vector with variable(s) to group/order the paramVar elements in the y-axis.

timeStartVar

String with variable with the start of the time interval.

timeStartLab

(optional) String with label for timeStartVar.

timeEndVar

String with variable with the end of the time interval.

timeEndLab

(optional) String with label for timeEndVar.

timeStartShapeVar

(optional) String with variable used for the shape of the start of the time interval.

timeStartShapeLab

(optional) String with label for timeStartShapeVar.

timeEndShapeVar

(optional) String with variable used for the shape of the end of the time interval.

timeEndShapeLab

(optional) String with label for timeEndShapeVar.

shapePalette

(optional) Character vector with shape palette for timeStartShapeVar and timeEndShapeVar.

colorVar

(optional) String with color variable.

colorLab

String with label for colorVar.

colorPalette

(optional) Named character vector with color palette. If not specified, the viridis color palette is used.
See clinColors.

alpha

(optional) Numeric with transparency, 1 by default.

xLab, yLab

(optional) String with labels for the x/y-axis.

title

String with title for the plot.

subtitle

String with subtitle.
The subtitle is included at the top left of the plot, below the title.

caption

String with caption.
The caption is included at the bottom right of the plot. Please note that this might overlap with vertical or rotated x-axis labels.

labelVars

Named character vector containing variable labels.

width

Numeric, width of the plot in pixels, 700 by default.

height

Numeric, height of the plot in pixels, 700 by default.

hoverVars

Character vector with variable(s) to be displayed in the hover, by default any position and aesthetic variables displayed in the plot.

hoverLab

Named character vector with labels for hoverVars.

idVar

String with variable containing subject ID.

idLab

String with label for idVar.

pathVar

String with variable of data containing hyperlinks with path to the subject-specific report, formatted as:

<a href="./path-to-report">label</a>

.
If multiple, they should be separated by: ', '.
The report(s) will be:

  • compressed to a zip file and downloaded if the user clicks on the 'p' (a.k.a 'profile') key when hovering on a point of the plot

  • included in a collapsible row, and clickable with hyperlinks in the table

pathLab

String with label for pathVar, included in the collapsible row in the table.

id

String with general id for the plot:

  • 'id' is used as group for the SharedData

  • 'button:[id]' is used as button ID if table is TRUE

If not specified, a random id, as 'plotClinData[X]' is used.

selectVars

(optional) Character vector with variable(s) from data for which a selection box should be included. This enables to select the data displayed in the plot (and associated table).

selectLab

(Named) character vector with label for selectVars.

table

Logical, if TRUE (FALSE by default) returns also a datatable containing the plot data. The plot and table are linked when included in a Rmarkdown document: when clicking on an plot element, only the corresponding records are retained in the associated table; when some records are selected in the table, they are highlighted in the associated table.

tableVars

Character vector with variables to be included in the table.

tableLab

Named character vector with labels for each tableVars.

tableButton

Logical, if TRUE (by default) the table is included within an HTML button.

tablePars

List with parameters passed to the getClinDT function.

verbose

Logical, if TRUE (FALSE by default) progress messages are printed in the current console. For the visualizations, progress messages during download of subject-specific report are displayed in the browser console.

Value

Either:

  • if a table is requested: a clinDataReview object, a.k.a a list with the 'plot' (plotly object) and 'table' (datatable object)

  • otherwise: a plotly object

Author(s)

Laure Cougnaud

See Also

Other Clinical data visualization of individual profiles.: scatterplotClinData()

Examples

library(clinUtils)

data(dataADaMCDISCP01)
labelVars <- attr(dataADaMCDISCP01, "labelVars")

dataAE <- dataADaMCDISCP01$ADAE

# basic plot
timeProfileIntervalPlot(
	data = dataAE,
	paramVar = "USUBJID",
	# time-variables
	timeStartVar = "ASTDY",
	timeEndVar = "ASTDY",
	# colored by severity
	colorVar = "AESEV",
	labelVars = labelVars
)

# add caption & subtitle
timeProfileIntervalPlot(
	data = dataAE,
	paramVar = "USUBJID",
	timeStartVar = "ASTDY",
	timeEndVar = "ASTDY",
	colorVar = "AESEV",
	labelVars = labelVars,
	title = "Adverse events",
	subtitle = "Time intervals",
	caption = "Day is relative to the study baseline"
)

# add a selection box
if(interactive()){
  timeProfileIntervalPlot(
    data = dataAE,
    paramVar = "USUBJID",
    # time-variables
    timeStartVar = "ASTDY",
    timeEndVar = "ASTDY",
    # colored by severity
    colorVar = "AESEV",
    labelVars = labelVars,
    selectVars = "AEDECOD"
  )
}

clinDataReview documentation built on March 7, 2023, 5:13 p.m.