treemapClinData {clinDataReview} | R Documentation |
Treemap interactive plot.
Description
Note: the table and plot are not (yet) linked.
Usage
treemapClinData(...)
Arguments
... |
Arguments passed on to plotCountClinData
colorVar (optional) String with coloring variable
(NULL by default).
By default, the treemap is colored based by section.
colorRange (optional) Numeric vector of length 2 with range
for the color variable, in case it is a numeric variable.
vars Character vector with variables of data
containing the groups. If multiple, they should be specified in
hierarchical order (from parent to child node).
varsLab Named character vector with labels for vars .
valueVar String with numeric variable of data
containing the value to display.
valueLab String with label for the valueVar variable.
valueType String with type of values in valueVar
(branchvalues of the plot_ly ) function),
among others: 'total' (default, only if sum(child) <= to parent)
or 'relative'.
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.
table Logical, if TRUE (FALSE by default)
returns also a datatable containing the plot data.
(The plot and the table are not linked.)
data Data.frame with data.
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.
width Numeric, width of the plot in pixels,
800 by default.
height Numeric, height of the plot in pixels,
500 by default.
hoverVars Character vector with variable(s) to be displayed in the hover,
by default any position (and axis) and aesthetic variables displayed in the plot.
hoverLab Named character vector with labels for hoverVars .
labelVars Named character vector containing variable labels.
id String with general id for the plot:
If not specified, a random id, as 'plotClinData[X]' is used.
title String with title for the plot.
titleExtra String with extra title for the plot (appended after 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.
subtitle String with subtitle.
The subtitle is included at the top left of the plot,
below the title.
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 .
watermark (optional) String with path to a file containing a watermark.
tableButton Logical, if TRUE (by default)
the table is included within an HTML button.
tableVars Character vector with variables to be included
in the table.
tableLab Named character vector with labels
for each tableVars .
tablePars List with parameters passed to the
getClinDT function.
|
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 visualizations of summary statistics for clinical data:
barplotClinData()
,
boxplotClinData()
,
errorbarClinData()
,
plotCountClinData()
,
sunburstClinData()
Examples
library(clinUtils)
data(dataADaMCDISCP01)
labelVars <- attr(dataADaMCDISCP01, "labelVars")
dataDM <- dataADaMCDISCP01$ADSL
dataAE <- dataADaMCDISCP01$ADAE
library(plyr)
## basic treemap:
# treemap takes as input table with counts
if (requireNamespace("inTextSummaryTable", quietly = TRUE)) {
# total counts: Safety Analysis Set (patients with start date for the first treatment)
dataTotal <- subset(dataDM, RFSTDTC != "")
# compute adverse event table
tableAE <- inTextSummaryTable::getSummaryStatisticsTable(
data = dataAE,
rowVar = c("AESOC", "AEDECOD"),
dataTotal = dataTotal,
rowOrder = "total",
labelVars = labelVars,
stats = inTextSummaryTable::getStats("count"),
# plotly treemap requires records (rows) for each group
rowVarTotalInclude = "AEDECOD",
outputType = "data.frame-base"
)
dataPlot <- tableAE
dataPlot$n <- as.numeric(dataPlot$n)
# create plot
treemapClinData(
data = dataPlot,
vars = c("AESOC", "AEDECOD"),
valueVar = "n",
valueLab = "Number of patients with adverse events"
)
## treemap with coloring
# extract worst-case scenario
dataAE$AESEVN <- as.numeric(factor(dataAE$AESEV, levels = c("MILD", "MODERATE", "SEVERE")))
if(any(is.na(dataAE$AESEVN)))
stop("Severity should be filled for all subjects.")
dataAEWC <- ddply(dataAE, c("AESOC", "AEDECOD", "USUBJID"), function(x){
x[which.max(x$AESEVN), ]
})
dataTotalRow <- list(AEDECOD =
ddply(dataAEWC, c("AESOC", "USUBJID"), function(x){
x[which.max(x$AESEVN), ]
})
)
# compute adverse event table
tableAE <- inTextSummaryTable::getSummaryStatisticsTable(
data = dataAEWC,
rowVar = c("AESOC", "AEDECOD"),
var = "AESEVN",
dataTotal = dataTotal,
rowOrder = "total",
labelVars = labelVars,
# plotly treemap requires records (rows) for each group
rowVarTotalInclude = "AEDECOD",
dataTotalRow = dataTotalRow,
outputType = "data.frame-base"
)
dataPlot <- tableAE
dataPlot$statN <- as.numeric(dataPlot$statN)
dataPlot$statMean <- as.numeric(dataPlot$statMean)
# create plot
treemapClinData(
data = dataPlot,
vars = c("AESOC", "AEDECOD"),
valueVar = "statN", valueLab = "Number of patients with adverse events",
colorVar = "statMean", colorLab = "Mean severity"
)
}
[Package
clinDataReview version 1.6.1
Index]