Type: | Package |
Title: | Clinical Data Review Tool |
Version: | 1.6.2 |
Date: | 2025-04-11 |
Description: | Creation of interactive tables, listings and figures ('TLFs') and associated report for exploratory analysis of data in a clinical trial, e.g. for clinical oversight activities. Interactive figures include sunburst, treemap, scatterplot, line plot and barplot of counts data. Interactive tables include table of summary statistics (as counts of adverse events, enrollment table) and listings. Possibility to compare data (summary table or listing) across two data batches/sets. A clinical data review report is created via study-specific configuration files and template 'R Markdown' reports contained in the package. |
Imports: | bookdown, clinUtils (≥ 0.1.0), crosstalk, data.table, ggplot2, grid, haven, htmltools, htmlwidgets, knitr, jsonlite, jsonvalidate, methods, plotly, plyr, rmarkdown, stats, stringr, utils, tools, yaml, xml2, xfun, base64enc |
Suggests: | countrycode, inTextSummaryTable (≥ 3.1.0), patientProfilesVis (≥ 0.12.0), testthat, DT, scales, grDevices |
SystemRequirements: | pandoc (to create a clinical data review report) |
URL: | https://github.com/openanalytics/clinDataReview |
BugReports: | https://github.com/openanalytics/clinDataReview/issues |
License: | MIT + file LICENSE |
VignetteBuilder: | knitr |
RoxygenNote: | 7.3.2 |
NeedsCompilation: | no |
Packaged: | 2025-04-11 19:04:21 UTC; lcougnaud |
Author: | Laure Cougnaud [aut, cre], Michela Pasetto [aut], Lennart Tuijnder [aut], Adriaan Blommaert [aut], Arne De Roeck [ctb, rev] (rev: tests), Open Analytics [cph] |
Maintainer: | Laure Cougnaud <laure.cougnaud@openanalytics.eu> |
Repository: | CRAN |
Date/Publication: | 2025-04-11 22:10:02 UTC |
Get R Documentation from a JSON schema.
Description
Note: this function doesn't support the full JSON schema specification, currently only the functionalities required by the templates of the package are implemented.
Usage
JSONSchToRd(JSONSch, title = NULL)
Arguments
JSONSch |
List with JSON schema, as returned by |
title |
(optional) String with title. This will combined with the JSON schema 'title' tag if this is specified. is not available. |
Value
Character vector with R documentation for the specified JSON schema.
Supported JSON schema tags
'title' is used as Rd section header
'description' is included in the text
parameters are extracted from the following 'properties' tag:
'type': object type
'doc': documentation for the parameter (custom JSON schema tag). This can contain any Roxygen tags, e.g.:
\link[package]{function}
.'pattern' (optional): required value for the parameter
'items' (optional): JSON schema for the different elements of an 'object'
'minItems'/'maxItems' (optional): minimum/maximum number of elements in an 'array'
'enum' (optional): set of possible values
'const' (optional): fixed value for the parameter (a.k.a 'constant')
If a parameter is required, it should be listed in the 'required' tag of the schema (outside of the 'properties' tag).
Author(s)
Laure Cougnaud
Add date of report running
Description
Add the today's date of when the report runs to the info of the metadata.
Usage
addDateOfReportRun(summaryInfo)
Arguments
summaryInfo |
matrix, see output from |
Value
A matrix, same as input summaryInfo
with an extra row with the date
of today.
Add facet-panel to single plotly plot.
Description
Add facet-panel to single plotly plot.
Usage
addFacetPanel(
pl,
panelLab,
panelWidth = 20,
fontSize = 15,
side = c("top", "right")
)
Arguments
pl |
|
panelLab |
text to be shown in the facet panel |
panelWidth |
thickness of the panel in pixels. |
fontSize |
fontsize of |
side |
the side of the plot to show the panel (currently only right panels are implemented.) |
Details
plot title clipping.
In case side = 'top', the plot title (eg. layout(title = "title")) will clip with the top panel.
Resolve this with the following configurations:
(once all the subplots have already been combined)
layout(
# place the title at absolute top of the page
title = list(text = "title", yref = "container", y = 1))
# If font size = 15 roughly equal to 20 pixels.
margin = list(t = panelWidth + heightTitleTextInPixels)
Value
plotly object with the facet panel added.
Author(s)
lennart tuijnder
Helper function to add layer to scatter plot
Description
Helper function to add layer to scatter plot
Usage
addLayerToScatterPlot(
gg,
aesVar,
pars,
generalPars,
layerFunction,
useHandlers = FALSE
)
Arguments
gg |
|
aesVar |
layers specific aesthetics list of layer specific aesthetics |
pars |
list of parameters specific to the layer |
generalPars |
overall, not layer specific parameters can be overwritten by |
layerFunction |
function to use for adding the layer e.g. |
useHandlers |
if |
Value
ggplot
object
Author(s)
Adriaan Blommaert Laure Cougnaud
Add reference (horizontal/vertical/diagonal) lines to a clinical data plot
Description
Add reference (horizontal/vertical/diagonal) lines to a clinical data plot
Usage
addReferenceLinesClinDataPlot(
gg,
data,
xVar,
yVar,
xLim = NULL,
yLim = NULL,
refLinePars = NULL,
facetPars = NULL
)
Arguments
gg |
|
data |
Data.frame with data. |
xVar |
String with column of |
yVar |
String with column of |
xLim , yLim |
Numeric vector of length 2 with limits for the x/y axes. |
refLinePars |
(optional) Nested list, with parameters for each reference line(s). Each sublist (a.k.a reference line) contains:
|
facetPars |
List with facetting parameters,
passed to the facetting function. Variables should be specified
as character or formula.
For 'wrap' facetting ( |
Value
Updated ggplot
object.
Author(s)
Laure Cougnaud
Add selection box(es) to a plotly plot.
Description
Add selection box(es) to a plotly plot.
Usage
addSelectBtn(
data,
pl,
selectVars = NULL,
selectLab = NULL,
labelVars = NULL,
id = paste0("plotClinData", sample.int(n = 1000, size = 1)),
keyVar
)
Arguments
data |
|
pl |
|
selectVars |
(optional) Character vector with variable(s) from |
selectLab |
(Named) character vector with label for |
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. |
keyVar |
String with unique key variable, identifying unique group for which the link between the table and the plot should be done. |
Value
if selectVars
is specified: a browsable
object combining the select buttons and the plotly
object.
Otherwise, the input plotly
object.
Add a watermark to a plotly
object.
Description
Add a watermark to a plotly
object.
Usage
addWatermark(pl, watermark = NULL)
Arguments
pl |
|
watermark |
(optional) String with path to a file containing a watermark. |
Value
plotly
object with a watermark (if specified)
See Also
Other watermark helpers:
getWatermark()
Examples
watermark <- tempfile(pattern = "watermark", fileext = ".png")
getWatermark(file = watermark)
addWatermark(pl = plotly::plot_ly(), watermark = watermark)
Annotate a dataset.
Description
Standard annotation variables are available via the
parameter annotType
. Custom dataset/variables of interest
are specified via the annotDataset
/annotVar
parameters.
Usage
annotateData(
data,
dataPath = ".",
annotations,
subjectVar = "USUBJID",
verbose = FALSE,
labelVars = NULL,
labelData = "data"
)
Arguments
data |
Data.frame with input data to annotate. |
dataPath |
String with path to the data. |
annotations |
Annotations (or list of those) either as a:
|
subjectVar |
String with subject ID variable, 'USUBJID' by default. |
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. |
labelVars |
Named character vector containing variable labels of |
labelData |
(optional) String with label for input |
Value
Annotated data
.
If labelVars
is specified, the output contains an
extra attribute: 'labelVars'
containing updated labelVars
(accessible via: in attr(output, 'labelVars')
).
Examples
library(clinUtils)
data(dataADaMCDISCP01)
dataLB <- dataADaMCDISCP01$ADLBC
dataDM <- dataADaMCDISCP01$ADSL
dataAE <- dataADaMCDISCP01$ADAE
labelVars <- attr(dataADaMCDISCP01, "labelVars")
# standard annotations:
# path to dataset should be specified via: 'pathData'
# annotateData(dataLB, annotations = "demographics", pathData = ...)
# add all variables in annotation data (if not already available)
head(annotateData(dataLB, annotations = list(data = dataDM)), 1)
# only variables of interest
head(annotateData(dataLB, annotations = list(data = dataDM, vars = c("ARM", "ETHNIC"))), 1)
# filter annotation dataset
dataAnnotated <- annotateData(dataLB,
annotations = list(
data = dataDM,
vars = c("ARM", "ETHNIC"),
filters = list(var = "ARM", value = "Placebo")
)
)
head(subset(dataAnnotated, ARM == "Placebo"), 1)
head(subset(dataAnnotated, is.na(ARM)), 1)
# worst-case scenario: add a new variable based on filtering condition
dataAE$AESEV <- factor(dataAE$AESEV, levels = c('MILD', "MODERATE", "SEVERE"))
dataAEWC <- annotateData(
data = dataAE,
annotations = list(
vars = "WORSTINT",
# create new variable: 'WORSTINT'
# with TRUE if maximum toxicity grade per subject/test
# (if multiple, they are all retained)
filters = list(
var = "AESEV",
# max will take latest level in a factor
# (so 'MODERATE' if 'MILD'/'MODERATE' are available)
valueFct = function(x) x[which.max(as.numeric(x))],
varsBy = c("USUBJID", "AEDECOD"),
keepNA = FALSE,
varNew = "WORSTINT",
labelNew = "worst-case"
)
),
labelVars = labelVars,
verbose = TRUE
)
attr(dataAEWC, "labelVars")["WORSTINT"]
# add a new variable based on a combination of variables:
dataLB <- annotateData(dataLB,
annotations = list(vars = "HILORATIO", varFct = "A1HI / A1LO")
)
# add a new variable based on extraction of a existing variable
# Note: slash should be doubled when the function is specified as text
dataLB <- annotateData(dataLB,
annotations = list(vars = "PERIOD", varFct = "sub('.* Week (.+)', 'Week \\\\1', AVISIT)")
)
# multiple annotations:
dataAnnotated <- annotateData(dataLB,
annotations = list(
list(data = dataDM, vars = c("ARM", "ETHNIC")),
list(data = dataAE, vars = c("AESEV"))
)
)
head(dataAnnotated, 1)
Barplot visualization of clinical data.
Description
Barplot visualization of clinical data.
Usage
barplotClinData(
data,
xVar,
yVar,
xLab = getLabelVar(xVar, labelVars = labelVars),
xLabVar = NULL,
yLab = getLabelVar(yVar, labelVars = labelVars),
yLabVar = NULL,
colorVar = NULL,
colorLab = getLabelVar(colorVar, labelVars = labelVars),
colorPalette = NULL,
barmode = "group",
title = paste(c(paste(yLab, "vs", xLab), titleExtra), collapse = "<br>"),
titleExtra = NULL,
caption = NULL,
subtitle = NULL,
labelVars = NULL,
width = NULL,
height = NULL,
hoverVars,
hoverLab,
textVar = NULL,
pathVar = NULL,
pathLab = getLabelVar(pathVar, labelVars = labelVars),
table = FALSE,
tableVars,
tableLab,
tableButton = TRUE,
tablePars = list(),
id = paste0("plotClinData", sample.int(n = 1000, size = 1)),
selectVars = NULL,
selectLab = getLabelVar(selectVars, labelVars = labelVars),
watermark = NULL,
verbose = FALSE
)
Arguments
data |
Data.frame with data. |
xVar |
String with column of |
yVar |
String with column of |
xLab |
String with label for |
xLabVar |
(optional) Character vector with column(s) of |
yLab |
String with label for |
yLabVar |
(optional) Character vector with column(s) of |
colorVar |
(optional) String with color variable. |
colorLab |
String with label for |
colorPalette |
(optional) Named character vector with color palette.
If not specified, the viridis color palette is used. |
barmode |
String with type of barplot, either:
'group' or 'stack' (see parameter in |
title |
String with title for the plot. |
titleExtra |
String with extra title for the plot (appended after |
caption |
String with caption. |
subtitle |
String with subtitle. |
labelVars |
Named character vector containing variable labels. |
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 |
textVar |
(optional) String with a text variable, that will be displayed outside of each bar. |
pathVar |
String with variable of <a href="./path-to-report">label</a> .
|
pathLab |
String with label for |
table |
Logical, if TRUE (FALSE by default)
returns also a |
tableVars |
Character vector with variables to be included in the table. |
tableLab |
Named character vector with labels
for each |
tableButton |
Logical, if TRUE (by default) the table is included within an HTML button. |
tablePars |
List with parameters passed to the
|
id |
String with general id for the plot:
If not specified, a random id, as 'plotClinData[X]' is used. |
selectVars |
(optional) Character vector with variable(s) from |
selectLab |
(Named) character vector with label for |
watermark |
(optional) String with path to a file containing a watermark. |
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: aclinDataReview
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:
boxplotClinData()
,
errorbarClinData()
,
plotCountClinData()
,
sunburstClinData()
,
treemapClinData()
Examples
library(clinUtils)
data(dataADaMCDISCP01)
labelVars <- attr(dataADaMCDISCP01, "labelVars")
dataAE <- dataADaMCDISCP01$ADAE
dataDM <- dataADaMCDISCP01$ADSL
## example of basic barplot:
# 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::computeSummaryStatisticsTable(
data = dataAE,
rowVar = c("AEBODSYS", "AEDECOD"),
rowOrder = "total",
dataTotal = dataTotal,
labelVars = labelVars,
stats = inTextSummaryTable::getStats("count")
)
dataPlot <- subset(tableAE, AEDECOD != "Total")
dataPlot$n <- as.numeric(dataPlot$n)
# create plot
barplotClinData(
data = dataPlot,
xVar = "AEDECOD",
yVar = "n", yLab = "Number of patients with adverse events",
labelVars = labelVars
)
# add number on top of the bars
barplotClinData(
data = dataPlot,
xVar = "AEDECOD",
yVar = "n", yLab = "Number of patients with adverse events",
textVar = "n",
labelVars = labelVars
)
# add a selection box
if(interactive()){
barplotClinData(
data = dataPlot,
xVar = "AEDECOD",
yVar = "n", yLab = "Number of patients with adverse events",
labelVars = labelVars,
selectVars = "AEBODSYS"
)
}
# display percentage of events per severity
tableAEBySeverity <- inTextSummaryTable::computeSummaryStatisticsTable(
data = dataAE,
rowVar = c("AEDECOD", "AESEV"),
dataTotal = dataTotal,
labelVars = labelVars,
statsPerc = "statm",
stats = inTextSummaryTable::getStats("%m"),
dataTotalPerc = dataAE,
rowVarTotalPerc = "AEDECOD"
)
barplotClinData(
data = tableAEBySeverity,
xVar = "AEDECOD", xLab = "Adverse event term",
yVar = "statPercm", yLab = "Percentage of adverse events",
labelVars = labelVars,
colorVar = "AESEV", barmode = "stack",
hoverVar = c("AEDECOD", "AESEV", "statN", "statm", "statPercm"),
hoverLab = c(
labelVars["AEDECOD"],
labelVars["AESEV"],
statN = "Number of patients",
statm = "Number of events",
statPercm = "Percentage of events"
),
textVar = "%m",
# add subtitle
subtitle = "Group: severity"
)
}
Boxplot interactive plot.
Description
Boxplot interactive plot.
Usage
boxplotClinData(
data,
xVar,
yVar,
xLab = getLabelVar(xVar, labelVars = labelVars),
xLabVar = NULL,
yLab = getLabelVar(yVar, labelVars = labelVars),
yLabVar = NULL,
colorVar = NULL,
colorLab = getLabelVar(colorVar, labelVars = labelVars),
colorPalette = NULL,
facetVar = NULL,
facetLab = getLabelVar(facetVar, labelVars = labelVars),
ncol = 1L,
title = paste(c(paste(yLab, "vs", xLab), titleExtra), collapse = "<br>"),
titleExtra = NULL,
subtitle = NULL,
caption = NULL,
labelVars = NULL,
width = NULL,
height = NULL,
hoverVars,
hoverLab,
pathVar = NULL,
pathLab = getLabelVar(pathVar, labelVars = labelVars),
idVar = "USUBJID",
idLab = getLabelVar(idVar, labelVars = labelVars),
table = FALSE,
tableVars,
tableLab,
tableButton = TRUE,
tablePars = list(),
id = paste0("plotClinData", sample.int(n = 1000, size = 1)),
watermark = NULL,
verbose = FALSE
)
Arguments
data |
Data.frame with data. |
xVar |
String with column of |
yVar |
String with column of |
xLab |
String with label for |
xLabVar |
(optional) Character vector with column(s) of |
yLab |
String with label for |
yLabVar |
(optional) Character vector with column(s) of |
colorVar |
(optional) String with color variable. |
colorLab |
String with label for |
colorPalette |
(optional) Named character vector with color palette.
If not specified, the viridis color palette is used. |
facetVar |
(optional) String with facet variable. |
facetLab |
String with label for |
ncol |
single-length integer denoting the number of columns for the facetting. |
title |
String with title for the plot. |
titleExtra |
String with extra title for the plot (appended after |
subtitle |
String with subtitle. |
caption |
String with caption. |
labelVars |
Named character vector containing variable labels. |
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 |
pathVar |
String with variable of <a href="./path-to-report">label</a> .
|
pathLab |
String with label for |
idVar |
String with variable containing subject ID. |
idLab |
String with label for |
table |
Logical, if TRUE (FALSE by default)
returns also a |
tableVars |
Character vector with variables to be included in the table. |
tableLab |
Named character vector with labels
for each |
tableButton |
Logical, if TRUE (by default) the table is included within an HTML button. |
tablePars |
List with parameters passed to the
|
id |
String with general id for the plot:
If not specified, a random id, as 'plotClinData[X]' is used. |
watermark |
(optional) String with path to a file containing a watermark. |
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: aclinDataReview
object, a.k.a a list with the 'plot' (plotly
object) and 'table' (datatable
object)otherwise: a
plotly
object
Author(s)
Lennart Tuijnder
See Also
Other visualizations of summary statistics for clinical data:
barplotClinData()
,
errorbarClinData()
,
plotCountClinData()
,
sunburstClinData()
,
treemapClinData()
Examples
library(clinUtils)
data(dataADaMCDISCP01)
labelVars <- attr(dataADaMCDISCP01, "labelVars")
## example of basic boxplot:
data <- subset(dataADaMCDISCP01$ADVS,
PARAMCD == "DIABP" & ANL01FL == "Y" &
AVISIT %in% c("Baseline", "Week 2", "Week 4", "Week 6", "Week 8")
)
## example of basic boxplot:
# With color var and facet:
boxplotClinData(
data = data,
xVar = "AVISIT",
yVar = "AVAL",
colorVar = "TRTA",
facetVar = "ATPT",
title = "Diastolic Blood Pressure distribution by actual visit and analysis timepoint",
yLab = "Actual value of the Diastolic Blood Pressure parameter (mmHg)",
labelVars = labelVars
)
# Control number of facet columns:
boxplotClinData(
data = data,
xVar = "AVISIT",
yVar = "AVAL",
colorVar = "TRTA",
facetVar = "ATPT",
ncol = 2,
title = "Diastolic Blood Pressure distribution by actual visit and analysis timepoint",
yLab = "Actual value of the Diastolic Blood Pressure parameter (mmHg)",
labelVars = labelVars
)
# Facet or color is optional:
boxplotClinData(
data = data,
xVar = "AVISIT",
yVar = "AVAL",
colorVar = "TRTA"
)
boxplotClinData(
data = data,
xVar = "AVISIT",
yVar = "AVAL",
facetVar = "ATPT"
)
# add caption & subtitle
boxplotClinData(
data = data,
xVar = "AVISIT",
yVar = "AVAL",
facetVar = "ATPT", ncol = 2,
colorVar = "TRTA",
title = "Diastolic Blood Pressure distribution",
subtitle = "By actual visit and analysis timepoint",
yLab = "Actual value of the Diastolic Blood Pressure parameter (mmHg)",
caption = "Summary statistics are computed internally.",
labelVars = labelVars
)
Build the book
Description
Build the book
Usage
buildBook(htmlFiles, verbose = TRUE)
Arguments
htmlFiles |
character vector with path to HTML files |
verbose |
Logical, if TRUE (FALSE by default) progress messages are printed during the report execution. |
Value
String with path to the front page of the report.
Author(s)
Laure Cougnaud
Check availability of arguments in list
Description
Check availability of arguments in list
Usage
checkAvailabilityMetadata(paramsList, subListName)
Arguments
paramsList |
A named list. |
subListName |
String indicating which of the sublist names to check for existance. |
Value
The content of the sublist. If not available, returns "Not Available".
Check if a chapter is run internally in parallel or not.
Description
This is identified via the 'parallel' parameter from the config file. If this parameter is not available in the config file (or the parameters are imported with an error), the chapter is considered to not be run in parallel.
Usage
checkChapterParallel(
configFile,
configDir = file.path(inputDir, "config"),
inputDir = "."
)
Arguments
configFile |
String with filename of the config file of interest in YAML format. |
configDir |
String with directory with config files,
by default a 'config' folder in |
inputDir |
String with input directory, working directory by default. |
Value
Logical, if TRUE, the chapter is run in parallel (FALSE if not available).
Check a configuration file (in _YAML_ format) based on a requirement file in JSON Schema format.
Description
Check a configuration file (in _YAML_ format) based on a requirement file in JSON Schema format.
Usage
checkConfigFile(configFile, configSpecFile, configDir = "./config")
Arguments
configFile |
path to the config file |
configSpecFile |
String with path to the file containing requirements in JSON Schema format. |
configDir |
String with directory with config files,
by default a 'config' folder in |
Value
No returned value, an error message is printed in the console if the configuration file doesn't comply to the specified specifications.
Author(s)
Laure Cougnaud
Check report titles
Description
Check uniqueness of report titles across the config files. If not unique titles are provided, an error is returned.
Usage
checkReportTitles(
configFiles,
configDir = file.path(inputDir, "config"),
inputDir = "."
)
Arguments
configFiles |
Character vector with config file names |
configDir |
String with directory with config files, ('config' by default) |
inputDir |
String with input directory, working directory by default. |
Value
A named vector with the report titles and the corresponding config file
Author(s)
Michela Pasetto
See Also
Other clinical data reporting:
forceParams()
,
getMdHeader()
,
getParamsFromConfig()
,
gitbook_clinDataReview_report()
,
html_clinDataReview_report()
,
knitPrintClinDataReview()
,
postProcessReport()
,
render_clinDataReviewReport()
Checks of config files template.
Description
Check if the templates specified in the input config files
don't originate from multiple sources (e.g. custom and R package
via the parameter templatePackage
).
If so, the corresponding config files are not considered.
Usage
checkTemplatesName(
configFiles,
configDir = file.path(inputDir, "config"),
inputDir = "."
)
Arguments
configFiles |
Character vector with name or path of the config file(s). |
configDir |
String with directory with config files,
by default a 'config' folder in |
inputDir |
String with input directory, working directory by default. |
Value
Updated configFiles
Author(s)
Laure Cougnaud
Check if the specified valueType
parameter can be passed to the
branchvalues
of the plot_ly
treemap/sunburst visualizations.
Description
If this parameter is set to 'total' and the sum of the counts of the the children nodes is not bigger than the parent node, an empty plot is created. In this case, this function set this parameter to: 'relative'.
Usage
checkValueType(data, vars, valueVar, valueType = "total", labelVars = NULL)
Arguments
data |
Data.frame with data. |
vars |
Character vector with variables of |
valueVar |
String with numeric variable of |
valueType |
String with type of values in |
labelVars |
Named character vector containing variable labels. |
Value
If the condition is fullfilled:
updated valueType
and warning;
otherwise input valueType
.
Author(s)
Laure Cougnaud
Common arguments for the functions of the clinDataReview package
Description
Common arguments for the functions of the clinDataReview package
Arguments
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. |
gg |
|
pl |
|
xVar |
String with column of |
yVar |
String with column of |
xLab |
String with label for |
xLabVar |
(optional) Character vector with column(s) of |
yLab |
String with label for |
yLabVar |
(optional) Character vector with column(s) of |
xLim , yLim |
Numeric vector of length 2 with limits for the x/y axes. |
idVar |
String with variable containing subject ID. |
idLab |
String with label for |
width |
Numeric, width of the plot in pixels, 800 by default. |
height |
Numeric, height of the plot in pixels, 500 by default. |
facetPars |
List with facetting parameters,
passed to the facetting function. Variables should be specified
as character or formula.
For 'wrap' facetting ( |
lineVars |
List with parameters for the reference lines. |
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 |
pathExpand |
Logical, should the variable in |
table |
Logical, if TRUE (FALSE by default)
returns also a |
refLinePars |
(optional) Nested list, with parameters for each reference line(s). Each sublist (a.k.a reference line) contains:
|
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 |
caption |
String with caption. |
subtitle |
String with subtitle. |
colorVar |
(optional) String with color variable. |
colorLab |
String with label for |
colorPalette |
(optional) Named character vector with color palette.
If not specified, the viridis color palette is used. |
selectVars |
(optional) Character vector with variable(s) from |
selectLab |
(Named) character vector with label for |
keyVar |
String with unique key variable, identifying unique group for which the link between the table and the plot should be done. |
watermark |
(optional) String with path to a file containing a watermark. |
Value
No return value, used for the documentation of the functions of the package.
Common parameters for the clinical data reporting function
Description
Common parameters for the clinical data reporting function
Arguments
indexPath |
String with path to the index file,
by default 'index.Rmd' in |
configDir |
String with directory with config files,
by default a 'config' folder in |
configFile |
String with filename of the config file of interest in YAML format. |
inputDir |
String with input directory, working directory by default. |
outputDir |
String with output directory, ('report' by default). |
intermediateDir |
String with intermediate directory ('interim'
by default), where
markdown files and rds file specifying Js libraries (with |
extraDirs |
Character vector with extra directories required by
the report, directory with external images.
By default, the directories: 'figures', 'tables' and mentioned in the
'patientProfilePath' parameter of the
general config file are included.
All these folders should be available in |
mdFile |
String with path of the Markdown file |
logFile |
(optional) String with path to a log file, where output (also error/messages/warnings) should be stored. If specified, the entire output is re-directed to this file. |
nCores |
Integer containing the number of cores used to render the report (1 by default). If more than 1, two steps of the report creation are run in parallel across chapters:
|
verbose |
Logical, if TRUE (FALSE by default) progress messages are printed during the report execution. |
Value
No return value, used for the documentation of the clinical data reporting functions of the package.
Common arguments for the plotting functions summary statistics of the clinDataReview package
Description
Common arguments for the plotting functions summary statistics of the clinDataReview package
Arguments
vars |
Character vector with variables of |
varsLab |
Named character vector with labels for |
valueVar |
String with numeric variable of |
valueLab |
String with label for the |
valueType |
String with type of values in |
pathVar |
String with variable of <a href="./path-to-report">label</a> .
|
pathLab |
String with label for |
table |
Logical, if TRUE (FALSE by default)
returns also a |
Value
No return value, used for the documentation of the plotting functions of summary statistics of the package.
Rmarkdown templates for clinical data
Description
Template reports with standard visualizations/tables available in the package are described here.
Details
For each template, required parameters are indicated in bold.
Value
No return value, used for the documentation of the Rmarkdown template reports contained in the package.
Parameter type
Please note that the type mentioned below corresponds to the type in the config file (in YAML/JSON format).
The mapping to R data type is as followed:
string: character vector of length 1
integer: integer vector of length 1
array: vector/list without names
object: list with names
Clinical data template for a visualization of count data : countsVisualizationTemplate
This report compute counts of variable(s) of interest (with the inTextSummaryTable
package) and visualize them with a treemap and/or sunburst.
The following parameters are available:
template
: string set to: 'countsVisualizationTemplate.Rmd', name of the template reporttemplatePackage
: string set to: 'clinDataReview', package from which the template should be extractedreportTitle
: string, header titlereportTitleLevel
: (optional) integer, header level, 1 by default (1: 'chapter', '2': 'section', '3': subsection, ...)parallel
: (optional) boolean, does this chapter use parallel execution? If the entire report is run in parallel, this ensures that this specific chapter is created outside of the report parallelization.split_by
: (optional) integer of length: minimum 0, maximum 7 or string among: 'none', 'chapter', 'section' , split the chapter at the specified level: 1 (for 'chapter'), 2 (for 'section') until 7. This overwrites the 'split_by' parameter defined in the output format of the report.dataFileName
: string or array, name of the data file(s) of interest. If multiple files are specified, the data are combined by rows ('row bind'), with a column: 'DATASET' containing the name of the file (in upper case and without extension) the data originate from.dataProcessing
: (optional) array, data processing parameters, passed to processDatadataTotalFileName
: (optional) string, filename of the total datasetdataTotalProcessing
: (optional) array, data processing parameters for 'dataTotalFileName', passed to processDatacountVar
: string, variable of data to count onparentVar
: (optional) string or array, parent variable(s) of the counting variable, used for groupingcolorVar
: (optional) string or object, numeric variable(s) to consider for coloring, named by count/parent variable if different for each variablecolorRange
: (optional) array of number(s) of length: minimum 2, maximum 2, range of the color variable for the visualizationloopingVar
: (optional) array or string, data variable(s) to loop over. Each group of the variable(s) is displayed in a separated section of the report.loopingNMax
: (optional) integer, maximum number of elements ofloopingVar
to include in the reportloopingTotal
: (optional) boolean, should the total also be computed byloopingVar
(TRUE by default)?typePlot
: (optional) array or string of string(s) among: 'sunburst', 'treemap'startup
: (optional) array or string, R commands that should be run at the start of the report
Clinical data template to create a report division : divisionTemplate
This report includes a division, i.e. extra chapter, section of subsection in the report.
The following parameters are available:
template
: string set to: 'divisionTemplate.Rmd', name of the template reporttemplatePackage
: string set to: 'clinDataReview', package from which the template should be extractedreportTitle
: string, header titlereportTitleLevel
: (optional) integer, header level, 1 by default (1: 'chapter', '2': 'section', '3': subsection, ...)parallel
: (optional) boolean, does this chapter use parallel execution? If the entire report is run in parallel, this ensures that this specific chapter is created outside of the report parallelization.split_by
: (optional) integer of length: minimum 0, maximum 7 or string among: 'none', 'chapter', 'section' , split the chapter at the specified level: 1 (for 'chapter'), 2 (for 'section') until 7. This overwrites the 'split_by' parameter defined in the output format of the report.content
: (optional) string, any content that should be included after the title
Clinical data template to create a listing : listingTemplate
This report displays a listing of the variables and data of interest, displayed in an interactive table. This table can contains comparison with a previous batch ('comparisonTable' parameters).
The following parameters are available:
template
: string set to: 'listingTemplate.Rmd', name of the template reporttemplatePackage
: string set to: 'clinDataReview', package from which the template should be extractedreportTitle
: string, header titlereportTitleLevel
: (optional) integer, header level, 1 by default (1: 'chapter', '2': 'section', '3': subsection, ...)parallel
: (optional) boolean, does this chapter use parallel execution? If the entire report is run in parallel, this ensures that this specific chapter is created outside of the report parallelization.split_by
: (optional) integer of length: minimum 0, maximum 7 or string among: 'none', 'chapter', 'section' , split the chapter at the specified level: 1 (for 'chapter'), 2 (for 'section') until 7. This overwrites the 'split_by' parameter defined in the output format of the report.dataFileName
: string or array, name of the data file(s) of interest. If multiple files are specified, the data are combined by rows ('row bind'), with a column: 'DATASET' containing the name of the file (in upper case and without extension) the data originate from.dataProcessing
: (optional) array, data processing parameters, passed to processDatadataTotalFileName
: (optional) string, filename of the total datasetdataTotalProcessing
: (optional) array, data processing parameters for 'dataTotalFileName', passed to processDatatableParams
: (optional) object, parameters to create the table, passed to tableClinDatacomparisonTableType
: (optional) string among: 'none', 'newData-diff-interactive', 'table-comparison-interactive' , output type of the comparison tablecomparisonTableParams
: (optional) object, parameters for the comparison table, passed to compareTablesloopingVar
: (optional) array or string, data variable(s) to loop over. Each group of the variable(s) is displayed in a separated section of the report.loopingNMax
: (optional) integer, maximum number of elements ofloopingVar
to include in the reportlistingDocx
: (optional) boolean, export listing to Word
Clinical data template for the creation of patient profiles : patientProfilesTemplate
This report creates the specified patient profiles (with the patientProfilesVis
package) by subject, and export them to a specified directory.
The following parameters are available:
template
: string set to: 'patientProfilesTemplate.Rmd', name of the template reporttemplatePackage
: string set to: 'clinDataReview', package from which the template should be extractedreportTitle
: string, header titlereportTitleLevel
: (optional) integer, header level, 1 by default (1: 'chapter', '2': 'section', '3': subsection, ...)parallel
: (optional) boolean, does this chapter use parallel execution? If the entire report is run in parallel, this ensures that this specific chapter is created outside of the report parallelization.split_by
: (optional) integer of length: minimum 0, maximum 7 or string among: 'none', 'chapter', 'section' , split the chapter at the specified level: 1 (for 'chapter'), 2 (for 'section') until 7. This overwrites the 'split_by' parameter defined in the output format of the report.createPatientProfiles
: (optional) boolean, Should the patient profiles be created or only loaded from a previous execution?patientProfilesGeneralParams
: (optional) object, set of parameters used for all patient profiles modules. These parameters are passed to allsubjectProfile[]Plot
functions.patientProfilesParams
: array of object(s)
The following parameters are available:typePlot
: string among: 'text', 'line', 'interval', 'event' , plot type, used to get the appropriate plot module function:'text': subjectProfileTextPlot
'line': subjectProfileLinePlot
'interval': subjectProfileIntervalPlot
'event': subjectProfileEventPlot
dataFileName
: string, name of the data file of interestdataProcessing
: (optional) array, data processing parameters, passed to processDataplotParams
: object, parameters for the plotting function. Parameters depending on the dataset of interest can be specified as:[parameterName]: !r-lazy [dataI]
, parameters for each patient profile module
patientProfilesCreateReportParams
: (optional) object, parameters for the creation of the patient profile report(s), passed to createSubjectProfileReporttableParams
: (optional) object, parameters specifying a table containing data of interest and links to created patient profilesstartup
: (optional) array or string, R commands that should be run at the start of the report
Clinical data generic template for visualization : plotTemplate
This report visualizes input data with a function of the clinical data review package. The data can be compared to the data of a previous batch, in the table associated to the plot ('comparisonTable' parameters).Summary statistics can be computed optionally and included in the plot (see 'tableParams' parameter).
The following parameters are available:
template
: string set to: 'plotTemplate.Rmd', name of the template reporttemplatePackage
: string set to: 'clinDataReview', package from which the template should be extractedreportTitle
: string, header titlereportTitleLevel
: (optional) integer, header level, 1 by default (1: 'chapter', '2': 'section', '3': subsection, ...)parallel
: (optional) boolean, does this chapter use parallel execution? If the entire report is run in parallel, this ensures that this specific chapter is created outside of the report parallelization.split_by
: (optional) integer of length: minimum 0, maximum 7 or string among: 'none', 'chapter', 'section' , split the chapter at the specified level: 1 (for 'chapter'), 2 (for 'section') until 7. This overwrites the 'split_by' parameter defined in the output format of the report.dataFileName
: string or array, name of the data file(s) of interest. If multiple files are specified, the data are combined by rows ('row bind'), with a column: 'DATASET' containing the name of the file (in upper case and without extension) the data originate from.dataProcessing
: (optional) array, data processing parameters, passed to processDataplotFunction
: string among: 'timeProfileIntervalPlot', 'scatterplotClinData', 'boxplotClinData' , plotting function of the package to considerplotParams
: object, parameters for the plotting function. Parameters depending on the dataset of interest can be specified as:
[parameterName]: !r-lazy [dataI]
tableParams
: (optional) object, parameters for a summary table, passed to computeSummaryStatisticsTable
Summary statistics are computed and merged as extra columns available for the plot data.tableProcessing
: (optional) array, data processing parameters for the summary table, passed to processDatacomparisonTableType
: (optional) string among: 'none', 'newData-diff' , output type of the comparison table. If specified, an additional column: 'Comparison Type' is included in the table attached to the plot.comparisonTableParams
: (optional) object, parameters for the comparison table, passed to compareTables. If referenceVars is not specified, all variables displayed in the plot are used.loopingVar
: (optional) array or string, data variable(s) to loop over. Each group of the variable(s) is displayed in a separated section of the report.loopingNMax
: (optional) integer, maximum number of elements ofloopingVar
to include in the reportstartup
: (optional) array or string, R commands that should be run at the start of the report
Clinical data template for visualization of summarized data : summaryPlotTemplate
This report summarizes the data of interest (with the inTextSummaryTable
package) and visualize it with any clinical data review plot function.
The following parameters are available:
template
: string set to: 'summaryPlotTemplate.Rmd', name of the template reporttemplatePackage
: string set to: 'clinDataReview', package from which the template should be extractedreportTitle
: string, header titlereportTitleLevel
: (optional) integer, header level, 1 by default (1: 'chapter', '2': 'section', '3': subsection, ...)parallel
: (optional) boolean, does this chapter use parallel execution? If the entire report is run in parallel, this ensures that this specific chapter is created outside of the report parallelization.split_by
: (optional) integer of length: minimum 0, maximum 7 or string among: 'none', 'chapter', 'section' , split the chapter at the specified level: 1 (for 'chapter'), 2 (for 'section') until 7. This overwrites the 'split_by' parameter defined in the output format of the report.dataFileName
: string or array, name of the data file(s) of interest. If multiple files are specified, the data are combined by rows ('row bind'), with a column: 'DATASET' containing the name of the file (in upper case and without extension) the data originate from.dataProcessing
: (optional) array, data processing parameters, passed to processDatadataTotalFileName
: (optional) string, filename of the total datasetdataTotalProcessing
: (optional) array, data processing parameters for 'dataTotalFileName', passed to processDatatableParams
: object, parameters to summarize the data in a table, passed to computeSummaryStatisticsTabletableProcessing
: (optional) array, data processing parameters for the summary table, passed to processDataplotFunction
: string among: 'timeProfileIntervalPlot', 'scatterplotClinData', 'sunburstClinData', 'treemapClinData', 'barplotClinData', 'errorbarClinData' , plotting function to visualize summary dataplotParams
: object, parameters for the plotting function. Parameters depending on the dataset of interest can be specified as:
[parameterName]: !r-lazy [summaryTableI]
loopingVar
: (optional) array or string, data variable(s) to loop over. Each group of the variable(s) is displayed in a separated section of the report.loopingNMax
: (optional) integer, maximum number of elements ofloopingVar
to include in the reportloopingTotal
: (optional) boolean, should the total also be computed byloopingVar
(TRUE by default)?startup
: (optional) array or string, R commands that should be run at the start of the report
Clinical data template for a summary table of the data : summaryTableTemplate
This report summarizes the data of interest (with the inTextSummaryTable
package). This table is displayed with an interactive table in the report, and exported to a docx file. This table can be compared to a summary table of a previous batch ('comparisonTable' parameters).
The following parameters are available:
template
: string set to: 'summaryTableTemplate.Rmd', name of the template reporttemplatePackage
: string set to: 'clinDataReview', package from which the template should be extractedreportTitle
: string, header titlereportTitleLevel
: (optional) integer, header level, 1 by default (1: 'chapter', '2': 'section', '3': subsection, ...)parallel
: (optional) boolean, does this chapter use parallel execution? If the entire report is run in parallel, this ensures that this specific chapter is created outside of the report parallelization.split_by
: (optional) integer of length: minimum 0, maximum 7 or string among: 'none', 'chapter', 'section' , split the chapter at the specified level: 1 (for 'chapter'), 2 (for 'section') until 7. This overwrites the 'split_by' parameter defined in the output format of the report.dataFileName
: string or array, name of the data file(s) of interest. If multiple files are specified, the data are combined by rows ('row bind'), with a column: 'DATASET' containing the name of the file (in upper case and without extension) the data originate from.dataProcessing
: (optional) array, data processing parameters, passed to processDatadataTotalFileName
: (optional) string, filename of the total datasetdataTotalProcessing
: (optional) array, data processing parameters for 'dataTotalFileName', passed to processDatatableParams
: object, parameters to summarize the data in a table, passed to computeSummaryStatisticsTable .Parameters depending on the dataset of interest can be specified as:[parameterName]: !r-lazy [dataI]
.tableParamsDocx
: (optional) object, parameters to format the table to the docx format, passed to exportSummaryStatisticsTabletableParamsDT
: (optional) object, parameters to format the table to the DT interactive table included in the report, passed to exportSummaryStatisticsTablecomparisonTableType
: (optional) string among: 'none', 'table-comparison-interactive', 'newData-diff', 'table-combine' , output type of the comparison table:'table-comparison-interactive': the summary statistics are computed for the old and new batch separately, and the statistics are compared
'newData-diff': the differences at a record level between the new and old batch are first identified, and then summarized
'table-combine': the summary tables are computed for the old and new batch and displayed next to each other in a combined table
comparisonTableParams
: (optional) object, parameters for the comparison table, passed to compareTables. By default, statistics variables are compared across row and column elements.loopingVar
: (optional) array or string, data variable(s) to loop over. Each group of the variable(s) is displayed in a separated section of the report.loopingNMax
: (optional) integer, maximum number of elements ofloopingVar
to include in the reportloopingTotal
: (optional) boolean, should the total also be computed byloopingVar
(TRUE by default)?
Function to create collapsible HTML content
Description
Please note that the button is of class: 'hideshow', defined in the 'input.hideshow.js' js file included in the package.
Usage
collapseHtmlContent(input, title = "Click to show or hide")
Arguments
input |
Object to be collapse, e.g. datatable. |
title |
String with button title. |
Value
tag
object
Author(s)
Laure Cougnaud
Combine select box(es) and the plot
Description
Combine select box(es) and the plot
Usage
combineButtonsAndPlot(x)
Arguments
x |
Object of class |
Value
x
object:
with the
plot
element containing a combination of thebuttons
and theplot
without the
buttons
element
Convert the Md file for a specific chapter to html
Description
Convert the Md file for a specific chapter to html
Usage
convertMdToHtml(
mdFile,
configFile = NULL,
indexPath = "index.Rmd",
intermediateDir = "./interim",
outputDir = "./report",
setTitle = TRUE,
verbose = TRUE,
...
)
Arguments
mdFile |
String with path of the Markdown file |
configFile |
String with filename of the config file of interest in YAML format. |
indexPath |
String with path to the index file,
by default 'index.Rmd' in |
intermediateDir |
String with intermediate directory ('interim'
by default), where
markdown files and rds file specifying Js libraries (with |
outputDir |
String with output directory, ('report' by default). |
setTitle |
Logical (TRUE by default), should the title be set
to the document? If so, the pandoc metadata option: 'pagetitle' is set to:
base file name of |
verbose |
Logical, if TRUE (FALSE by default) progress messages are printed during the report execution. |
... |
Arguments passed to |
Value
No returned value, the files in the intermediateDir
are converted to HTML
Author(s)
Laure Cougnaud
Convert report format from .html to .aspx
Description
Report files generated as output of render_clinDataReviewReport
are converted from .html to
to .aspx format by changing extensions and cross-links of all files within the directory reportDir
.
This allows for deployment on SharePoint.
Usage
convertReportToAspx(reportDir = ".")
Arguments
reportDir |
String for the path to the directory where the clinical data reports are stored, defaults to current directory |
Value
no return value, files in directory are modified
Count number of lines in a vector
Description
Count number of lines in a vector
Usage
countNLines(x)
Arguments
x |
Character vector. |
Value
Integer vector of length x
with number
of lines
Author(s)
Laure Cougnaud
Create the skeleton of a report
Description
Creates the skeleton of a report to start running the analyses.
Usage
createClinDataReviewReportSkeleton(dir = ".")
Arguments
dir |
String with the path of the directory where the skeleton should be created. The current working directory is used as default. |
Details
This function is meant to get familiar with the use of the package and the necessary files to create a report.
It will create a ready-to-use report with example data from the clinUtils
package. After getting use to the file structure, the user can
substitute the example data with
custom data sets and add specific configuration files.
Value
The files to run a report are written in the specified
directory. To run the report, the user can call the
render_clinDataReviewReport
.
Create an example metadata file
Description
Create an example of metadata file for the createClinDataReviewReportSkeleton
.
Usage
createExampleMetadata(dir)
Arguments
dir |
String, path to the directory. |
Value
Nothing, the example metadata file is created in the specified directory.
Create the config file for the skeleton
Description
This function creates the main config file for the createClinDataReviewReportSkeleton
with the directory where the data are stored.
Usage
createMainConfigSkeleton(dir, dirData)
Arguments
dir |
String, path to the directory. |
dirData |
String, path to the directory of the data. |
Value
No return value, a file _config.yml_ is created in the specified directory.
Create a output YAML file
Description
This file containing the contents of the
output
field of the YAML header of a Markdown file.
It can be passed to the output_yaml
parameter
of the render
function.
Usage
createOutputYaml(indexPath, outputDir)
Arguments
indexPath |
String with path to the index file,
by default 'index.Rmd' in |
outputDir |
String with output directory, ('report' by default). |
Value
String with file to the _output.yml
file
in a temporary folder.
Create link to patient profile
Description
Create a link to a patient profile directory
(where the patient profile files are saved) by adding an extra column with the link
in the data.
The path to the patient profile is built as:
[patientProfilePath]/subjectProfile-[subjectID].pdf,
where '/' are replaced with '-' in the subject
identifier (subjectVar
).
Usage
createPatientProfileVar(
data,
patientProfilePath,
subjectVar = "USUBJID",
checkExist = TRUE
)
Arguments
data |
a data.frame |
patientProfilePath |
string indicating the directory where the patient profiles are stored. |
subjectVar |
string indicating which column in the data represents the unique subject identifier, "USUBJID" by default. |
checkExist |
Logical, if TRUE (by default)
the |
Value
A data.frame with two extra columns:
patientProfilePath
and patientProfileLink
with
the path to the patient profile and an hyperlink to it, respectively.
Author(s)
Michela Pasetto
Examples
# Typical CDISC dataset contains universal subject ID (USUBJID)
data <- data.frame(USUBJID = c("subj1", "subj2", "subj3"))
dataWithPatientProfileVar <- createPatientProfileVar(
data = data,
patientProfilePath = "pathProfiles",
checkExist = FALSE
)
# path and HTML link are included in the output dataset
head(dataWithPatientProfileVar[, c("USUBJID", "patientProfilePath", "patientProfileLink")])
Create a redirect page
Description
Create an html page that redirects to the
"1-introduction.html" page of the clinical data report available in
a directory.
See output from render_clinDataReviewReport
.
Usage
createRedirectPage(redirectPage = "report.html", dir = "report_dependencies")
Arguments
redirectPage |
String with the path of the html file that redirects to the "1-introduction.html" page of the report. |
dir |
String for the path where the "1-introduction.html" is stored. |
Value
The html file is created.
Create documentation for clinical data template reports available in the 'template' folder of the package.
Description
If a JSON schema file available, the information relative
to the template is extracted from this file with the function
JSONSchToRd
.
Usage
createTemplateDoc(
templatePath = system.file("template", package = "clinDataReview")
)
Arguments
templatePath |
string with path where the template Rmd reports and associated JSON schema files are stored, by default path of the installed version of the package. This parameter is only for expert use of the package. |
Value
Character vector with Rd code containing description for all template documents.
Author(s)
Laure Cougnaud
References
Interactive plot of confidence interval/error interval of clinical data.
Description
This plot is designed to display summary statistics
of a continuous variable with (confidence) intervals.
The intervals are either displayed:
vertically if
yErrorVar
is specifiedhorizontally if
xErrorVar
is specified
Error bars can visualized by group, via the color variable parameter.
Different symbols are set for each central point of the error bar
via the shape variable parameter.
Usage
errorbarClinData(
data,
xVar,
xLab = getLabelVar(xVar, labelVars = labelVars),
xLabVar = NULL,
yVar,
yLab = getLabelVar(yVar, labelVars = labelVars),
yLabVar = NULL,
yErrorVar = NULL,
yErrorLab = getLabelVar(yErrorVar, labelVars = labelVars),
xErrorVar = NULL,
xErrorLab = getLabelVar(xErrorVar, labelVars = labelVars),
xLabVars = NULL,
xAxisLab = paste(c(xLab, xErrorLab), collapse = " and "),
yAxisLab = paste(c(yLab, yErrorLab), collapse = " and "),
colorVar = NULL,
colorLab = getLabelVar(colorVar, labelVars = labelVars),
colorPalette = NULL,
shapeVar = NULL,
shapeLab = getLabelVar(shapeVar, labelVars = labelVars),
shapePalette = NULL,
size = 6,
title = paste(c(paste(yAxisLab, "vs", xAxisLab), titleExtra), collapse = "<br>"),
titleExtra = NULL,
subtitle = NULL,
caption = NULL,
labelVars = NULL,
mode = "markers",
legendPosition = "bottom",
width = NULL,
height = NULL,
pathVar = NULL,
pathLab = getLabelVar(pathVar, labelVars = labelVars),
hoverVars,
hoverLab,
id = paste0("plotClinData", sample.int(n = 1000, size = 1)),
selectVars = NULL,
selectLab = getLabelVar(selectVars, labelVars = labelVars),
table = FALSE,
tableVars,
tableLab,
tableButton = TRUE,
tablePars = list(),
watermark = NULL,
verbose = FALSE
)
Arguments
data |
Data.frame with data. |
xVar |
String with column of |
xLab |
String with label for |
xLabVar |
(optional) Character vector with column(s) of |
yVar |
String with column of |
yLab |
String with label for |
yLabVar |
(optional) Character vector with column(s) of |
xErrorVar , yErrorVar |
String with variable of |
xErrorLab , yErrorLab |
String with labels
for |
xLabVars |
(vertical error bars)
Character vector with variable(s) to be displayed
as the labels of the ticks in the x-axis. |
xAxisLab , yAxisLab |
Label for the x/y-axis. |
colorVar |
(optional) String with color variable. |
colorLab |
String with label for |
colorPalette |
(optional) Named character vector with color palette.
If not specified, the viridis color palette is used. |
shapeVar |
(optional) String with shape variable. |
shapeLab |
String with label for |
shapePalette |
(optional) Named character vector with
shape palette, |
size |
Integer with size of markers in pixels, 6 by default. |
title |
String with title for the plot. |
titleExtra |
String with extra title for the plot (appended after |
subtitle |
String with subtitle. |
caption |
String with caption. |
labelVars |
Named character vector containing variable labels. |
mode |
String with the mode of the plot,
'markers' by default, so only data points are displayed. |
legendPosition |
String with position of the legend, among: 'top'/'left'/'bottom'/'right', 'bottom' by default. |
width |
Numeric, width of the plot in pixels, 800 by default. |
height |
Numeric, height of the plot in pixels, 500 by default. |
pathVar |
String with variable of <a href="./path-to-report">label</a> .
|
pathLab |
String with label for |
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 |
id |
String with general id for the plot:
If not specified, a random id, as 'plotClinData[X]' is used. |
selectVars |
(optional) Character vector with variable(s) from |
selectLab |
(Named) character vector with label for |
table |
Logical, if TRUE (FALSE by default)
returns also a |
tableVars |
Character vector with variables to be included in the table. |
tableLab |
Named character vector with labels
for each |
tableButton |
Logical, if TRUE (by default) the table is included within an HTML button. |
tablePars |
List with parameters passed to the
|
watermark |
(optional) String with path to a file containing a watermark. |
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: aclinDataReview
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()
,
plotCountClinData()
,
sunburstClinData()
,
treemapClinData()
Examples
library(clinUtils)
data(dataADaMCDISCP01)
labelVars <- attr(dataADaMCDISCP01, "labelVars")
## Summary plot with vertical error bars
dataVSDIABP <- subset(dataADaMCDISCP01$ADVS,
PARAMCD == "DIABP" & ANL01FL == "Y" &
AVISIT %in% c("Baseline", "Week 2", "Week 4", "Week 6", "Week 8")
)
# compute summary statistics by visit
if (requireNamespace("inTextSummaryTable", quietly = TRUE)) {
summaryTableVSDIABP <- inTextSummaryTable::computeSummaryStatisticsTable(
data = dataVSDIABP,
rowVar = c("AVISIT", "ATPT"),
var = "AVAL",
stats = inTextSummaryTable::getStats(c("n", "Mean", "SE")),
labelVars = labelVars
)
dataPlot <- subset(summaryTableVSDIABP, !isTotal)
errorbarClinData(
data = dataPlot,
xVar = "AVISIT",
colorVar = "ATPT",
# use non-rounded statistics for the plot
yVar = "statMean", yErrorVar = "statSE",
yLab = "Mean", yErrorLab = "Standard Error",
# include lines connecting the error bars
mode = "markers+lines",
labelVars = labelVars
)
# add number of subjects in labels
dataPlot$nSubj <- with(dataPlot, paste0("N=", n))
errorbarClinData(
data = dataPlot,
xVar = "AVISIT",
xLabVars = c("AVISIT", "nSubj"),
colorVar = "ATPT",
yVar = "statMean", yLab = "Mean",
yErrorVar = "statSE", yErrorLab = "Standard error",
mode = "markers+lines",
title = paste("Diastolic Blood Pressure summary profile by actual visit",
"and analysis timepoint"),
labelVars = labelVars
)
## Add a selection box
if(interactive()){
summaryTable <- inTextSummaryTable::computeSummaryStatisticsTable(
data = subset(dataADaMCDISCP01$ADVS,
ANL01FL == "Y" &
AVISIT %in% c("Baseline", "Week 2", "Week 4", "Week 6", "Week 8")
),
rowVar = c("PARAM", "AVISIT", "ATPT"),
var = "AVAL",
stats = inTextSummaryTable::getStats(c("Mean", "SE")),
labelVars = labelVars
)
dataPlot <- subset(summaryTable, !isTotal)
errorbarClinData(
data = dataPlot,
xVar = "AVISIT",
colorVar = "ATPT",
yVar = "statMean", yLab = "Mean",
yErrorVar = "statSE", yErrorLab = "Standard error",
mode = "markers+lines",
title = paste("Lab parameters summary profile by actual visit",
"and analysis timepoint"),
labelVars = labelVars,
selectVars = "PARAM"
)
}
## Summary plot with horizontal error bars
# Data of interest: ratio from baseline at week 16
dataLBW8 <- subset(dataADaMCDISCP01$ADLBC, grepl("Week 8", AVISIT))
# compute ratio from baseline
dataLBW8$R2BASE <- with(dataLBW8, AVAL/BASE)
dataLBW8 <- subset(dataLBW8, !is.na(R2BASE))
# Order actual treatments
dataLBW8$TRTA <- with(dataLBW8, reorder(TRTA, TRTAN))
# compute summary statistics of the ratio per baseline per parameter
summaryTableLBW8 <- inTextSummaryTable::computeSummaryStatisticsTable(
data = dataLBW8,
var = "R2BASE",
rowVar = "PARAM",
colVar = "TRTA",
stats = inTextSummaryTable::getStats(x = dataLBW8$R2BASE, type = c("n", "Median", "SD"))
)
dataPlot <- subset(summaryTableLBW8, !isTotal)
# extract direction of ratio
dataPlot$dir <- factor(
ifelse(dataPlot$statMedian >= 1, "Increase", "Decrease"),
levels = c("Decrease", "Increase")
)
# compute relative ratio (percentage above 1)
dataPlot$statMedianRelative <- with(dataPlot,
ifelse(statMedian < 1, 1/statMedian, statMedian)
)
# order based on mean relative ratio across treatment arms
params <- names(sort(with(dataPlot, tapply(statMedianRelative, PARAM, mean))))
dataPlot$PARAM <- factor(dataPlot$PARAM, levels = params)
errorbarClinData(
data = dataPlot,
xVar = "statMedianRelative", xErrorVar = "statSD",
xLab = "Median", xErrorLab = "Standard deviation",
xAxisLab = "Relative ratio from baseline (Median +- SD)",
yVar = "PARAM",
colorVar = "TRTA",
shapeVar = "dir", shapeLab = "Direction of ratio",
shapePalette = c(`Decrease` = 25, `Increase` = 24),
size = 10,
labelVars = labelVars,
title = "Summary ratio from baseline at week 8 by treatment"
)
}
Combine all session informations across all clinical data reports and export them into a dedicated Markdown document
Description
Combine all session informations across all clinical data reports and export them into a dedicated Markdown document
Usage
exportSessionInfoToMd(
sessionInfos,
intermediateDir = "interim",
logFile = NULL,
...
)
Arguments
sessionInfos |
List with |
intermediateDir |
String with intermediate directory ('interim'
by default), where
markdown files and rds file specifying Js libraries (with |
logFile |
(optional) String with path to a log file, where output (also error/messages/warnings) should be stored. If specified, the entire output is re-directed to this file. |
... |
Any parameters passed to |
Value
String with path to Markdown file containing the session information, NULL if no session information(s) are provided.
Author(s)
Laure Cougnaud
Filter a dataset based on specified filters.
Description
A dataset can be filtered:
on a specific
value
of intereston a function of a variable (
valueFct
parameter), e.g. maximum of the variable)to retain only non missing values of a variable (
keepNA
set toFALSE
)by groups (
varsBy
parameter)
Note that by default, missing values in the filtering variable are retained
(which differs from the default behaviour in R).
To filter missing records, please set the keepNA
parameter to FALSE
.
Usage
filterData(
data,
filters,
keepNA = TRUE,
returnAll = FALSE,
verbose = FALSE,
labelVars = NULL,
labelData = "data"
)
Arguments
data |
Data.frame with data. |
filters |
Unique filter or list of filters.
If a list of filters is specified, the different filters are independently
executed on the entire dataset to identify the records to retain for
each filtering condition. |
keepNA |
Logical, if TRUE (by default) missing values in |
returnAll |
Logical:
|
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. |
labelVars |
Named character vector containing variable labels. |
labelData |
(optional) String with label for input |
Value
If returnAll
is
FALSE
:data
filtered with the specified filtersis
TRUE
:data
with the additional column:keep
orvarNew
(if specified), containingTRUE
for records which fulfill the specified condition(s) andFALSE
otherwise.
The output contains the additional attribute: msg
which contains a message
describing the filtered records.
Author(s)
Laure Cougnaud
Examples
library(clinUtils)
data(dataADaMCDISCP01)
labelVars <- attr(dataADaMCDISCP01, "labelVars")
dataDM <- dataADaMCDISCP01$ADSL
## single filter
# filter with inclusion criteria:
filterData(
data = dataDM,
filters = list(var = "SEX", value = "M"),
# optional
labelVars = labelVars, verbose = TRUE
)
# filter with non-inclusion criteria
filterData(
data = dataDM,
filters = list(var = "SEX", value = "M", rev = TRUE),
# optional
labelVars = labelVars, verbose = TRUE
)
# filter based on inequality operator
filterData(
data = dataDM,
filters = list(var = "AGE", value = 75, op = "<="),
# optional
labelVars = labelVars, verbose = TRUE
)
# missing values are retained by default!
dataDMNA <- dataDM
dataDMNA[1 : 2, "AGE"] <- NA
filterData(
data = dataDMNA,
filters = list(var = "AGE", value = 75, op = "<="),
# optional
labelVars = labelVars, verbose = TRUE
)
# filter missing values on variable
filterData(
data = dataDMNA,
filters = list(var = "AGE", value = 75, op = "<=", keepNA = FALSE),
# optional
labelVars = labelVars, verbose = TRUE
)
# retain only missing values
filterData(
data = dataDMNA,
filters = list(var = "AGE", value = NA, keepNA = TRUE),
# optional
labelVars = labelVars, verbose = TRUE
)
# filter missing values
filterData(
data = dataDMNA,
filters = list(var = "AGE", keepNA = FALSE),
# optional
labelVars = labelVars, verbose = TRUE
)
## multiple filters
# by default the records fulfilling all conditions are retained ('AND')
filterData(
data = dataDM,
filters = list(
list(var = "AGE", value = 75, op = "<="),
list(var = "SEX", value = "M")
),
# optional
labelVars = labelVars, verbose = TRUE
)
# custom operator:
filterData(
data = dataDM,
filters = list(
list(var = "AGE", value = 75, op = "<="),
"|",
list(var = "SEX", value = "M")
),
# optional
labelVars = labelVars, verbose = TRUE
)
# filter by group
# only retain adverse event records with worst-case severity
dataAE <- dataADaMCDISCP01$ADAE
dataAE$AESEV <- factor(dataAE$AESEV, levels = c("MILD", "MODERATE", "SEVERE"))
dataAE$AESEVN <- as.numeric(dataAE$AESEV)
nrow(dataAE)
dataAEWorst <- filterData(
data = dataAE,
filters = list(
var = "AESEVN",
valueFct = max,
varsBy = c("USUBJID", "AEDECOD"),
keepNA = FALSE
),
# optional
labelVars = labelVars, verbose = TRUE
)
nrow(dataAEWorst)
# post-processing function
# keep subjects with at least one severe AE:
dataSubjectWithSevereAE <- filterData(
data = dataAE,
filters = list(
var = "AESEV",
value = "SEVERE",
varsBy = "USUBJID",
postFct = any
),
# optional
labelVars = labelVars, verbose = TRUE
)
# for each laboratory parameter: keep only subjects which have at least one
# measurement classified as low or high
dataLB <- subset(dataADaMCDISCP01$ADLBC, !grepl("change", PARAM))
dataLBFiltered <- filterData(
data = dataLB,
filters = list(
var = "LBNRIND",
value = c("LOW", "HIGH"),
varsBy = c("PARAMCD", "USUBJID"),
postFct = any
),
# optional
labelVars = labelVars, verbose = TRUE
)
Filter data for a single filter
Description
Filter data for a single filter
Usage
filterDataSingle(
data,
filters,
keepNA = TRUE,
returnAll = FALSE,
labelVars = NULL,
labelData = "data"
)
Arguments
data |
Data.frame with data. |
filters |
Unique filter or list of filters. |
keepNA |
Logical, if TRUE (by default) missing values in |
returnAll |
Logical:
|
labelVars |
Named character vector containing variable labels. |
labelData |
(optional) String with label for input |
Value
Updated data
with attributes:
'labelVars': input
labelVars
with any new variables iflabelNew
is specified.'msg': message describing the filtering process
'warn': warning describing the filtering process
Author(s)
Laure Cougnaud
Force the evaluation of the parameters from config file.
Description
This function is only useful if some
parameters should be lazy-evaluated in the report.
These parameters should have the class: r-lazy
.
A typical use case is a parameter that
consists of a R expression
depending on objects created in a template
report (typically data
).
Parameters are searched in the environment
in which this function is called from.
Usage
forceParams(params)
Arguments
params |
List of parameters as obtained
via the |
Value
Input parameter list, with
object(s) of class r-lazy
evaluated.
Author(s)
Laure Cougnaud
See Also
Other clinical data reporting:
checkReportTitles()
,
getMdHeader()
,
getParamsFromConfig()
,
gitbook_clinDataReview_report()
,
html_clinDataReview_report()
,
knitPrintClinDataReview()
,
postProcessReport()
,
render_clinDataReviewReport()
Examples
data <- mtcars
params <- list(label = "Cars dataset", nrow = structure("nrow(data)", class = "r-lazy"))
str(params)
str(forceParams(params))
Format data for interactive plot for clinical data
Description
Format data for interactive plot for clinical data
Usage
formatDataForPlotClinData(
data,
hoverVars = NULL,
hoverLab = getLabelVar(hoverVars, labelVars = labelVars),
hoverByVar = NULL,
keyVar = NULL,
id = paste0("plotClinData", sample.int(n = 1000, size = 1)),
labelVars = NULL
)
Arguments
data |
Data.frame with data. |
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 |
hoverByVar |
Character vector with variables identifying unique elements in the plot, usually x, y, facet variables. These variables are used to identify records with the same position in the plot, their information are combined in the hover. |
keyVar |
String with unique key variable, identifying unique group for which the link between the table and the plot should be done. |
id |
String with general id for the plot:
If not specified, a random id, as 'plotClinData[X]' is used. |
labelVars |
Named character vector containing variable labels. |
Value
SharedData
object containing the data
,
with an extra column: 'hover' with the combined info from hoverVars
,
and the key defined as keyVar
and group as id
.
Author(s)
Laure Cougnaud
Format hover text for use in plotly interactive plots. The labels are wrapped to multiple lines if exceed the width of the plotly hover box, e.g. in case labels for points with same x/y coordinates overlap, and corresponding labels are truncated.
Description
Format hover text for use in plotly interactive plots. The labels are wrapped to multiple lines if exceed the width of the plotly hover box, e.g. in case labels for points with same x/y coordinates overlap, and corresponding labels are truncated.
Usage
formatHoverText(x, label, width = 50)
Arguments
x |
Vector with hover text information. |
label |
Label for the variable |
width |
Integer, number of characters at which the hover text should be cut at to multiple lines. |
Value
String with formatted hover label.
Author(s)
Laure Cougnaud
Format the info on paths from metadata
Description
Format the info on paths from metadata
Usage
formatPathDateInfoMetadata(summaryInfo, namesInfo)
Arguments
summaryInfo |
matrix, see output from |
namesInfo |
Named vector to rename the final output. |
Value
A kable object, to be printed.
Format interactive plot, with possibility to download patient profiles on a click event.
Description
Format interactive plot, with possibility to download patient profiles on a click event.
Usage
formatPlotlyClinData(
pl,
data,
idVar = "USUBJID",
pathVar = NULL,
pathDownload = TRUE,
idFromDataPlot = FALSE,
idVarPlot = "key",
labelVarPlot = NULL,
highlightOn = "plotly_click",
highlightOff = "plotly_doubleclick",
id = paste0("plotClinData", sample.int(n = 1000, size = 1)),
selectVars = NULL,
selectLab = getLabelVar(selectVars, labelVars = labelVars),
keyVar = NULL,
keyHighlightBox = FALSE,
labelVars = NULL,
verbose = FALSE
)
Arguments
pl |
|
data |
Data.frame with data. |
idVar |
String with variable of |
pathVar |
String with variable of |
pathDownload |
Logical, if TRUE (by default) the subject-specific report(s)
are downloaded in a zip compressed file.
If FALSE (only available if unique report per |
idFromDataPlot |
Logical, if TRUE (by default) |
idVarPlot |
String with variable in the |
labelVarPlot |
String with plotly variable used to
extract label to build the file name of the zip compressed
file containing patient report.
If not specified, the label are extracted based on the |
highlightOn |
String with event to turn on the selection
( |
highlightOff |
String with event to turn off the selection
( |
id |
String with general id for the plot:
If not specified, a random id, as 'plotClinData[X]' is used. |
selectVars |
(optional) Character vector with variable(s) from |
selectLab |
(Named) character vector with label for |
keyVar |
String with unique key variable, identifying unique group for which the link between the table and the plot should be done. |
keyHighlightBox |
Logical, if TRUE (FALSE by default) a selectize box is included to highlight selected element(s) of the key variable. |
labelVars |
Named character vector containing variable labels. |
verbose |
Logical, if TRUE report progress messages during execution (included in the browser 'Console'). |
Value
Updated plotly
object.
Author(s)
Laure Cougnaud
Format data to a hierarchical data, in the format as required by the plotly sunburst and treemap.
Description
Note that new variables are created for each variable of interest (the variables are not overwritten) to avoid issues with cases where the value in the child and parent variables are the same.
Usage
formatToHierarchicalData(data, vars, valueVar)
Arguments
data |
Data.frame with data. |
vars |
Character vector with variables of |
valueVar |
String with numeric variable of |
Value
Updated data.frame with vars
in
hierarchical format, with extra attributes (in 'metadat'):
'varID': String with column of output containing ID of specific element.
This is a combination from the specifiedvars
, or 'Overall' for the grand total.'varParent': String with column of output containing ID of the parent element
'varLabel': String with column of output containing the label to display.
This is usually the name of the child element.
Author(s)
Laure Cougnaud
Get axis label
Description
Get axis label
Usage
getAxisLab(axisVar, axisLab, labVar = NULL, data, labelVars)
Arguments
axisVar |
String with column of |
axisLab |
(optional) String with label for |
labVar |
String with column of |
data |
Data.frame with data. |
labelVars |
Named character vector containing variable labels. |
Value
String with label for the axis.
Set different variables for the x-axis labels
Description
Set different variables for the x-axis labels
Usage
getAxisLabs(data, var, labVars)
Arguments
data |
Data.frame with data. |
var |
String with variable displayed in the axis. |
labVars |
Character vector with variable(s) to be displayed as the labels of the ticks in the axis. |
Value
Named character vector. The names are the position in the x-axis, the values are the new labels.
Author(s)
Laure Cougnaud
Get axis limits for a ggplot
plot
from the input dataset.
Description
Get axis limits for a ggplot
plot
from the input dataset.
Usage
getAxisLimPlot(
data,
xVar,
yVar,
xLim = NULL,
yLim = NULL,
facetPars = NULL,
refLineData = NULL
)
Arguments
data |
Data.frame with data. |
xVar |
String with column of |
yVar |
String with column of |
xLim , yLim |
Numeric vector of length 2 with limits for the x/y axes. |
facetPars |
List with facetting parameters,
passed to the facetting function. Variables should be specified
as character or formula.
For 'wrap' facetting ( |
refLineData |
Data used for the reference lines, as
output of the |
Value
Data.frame with limits of the:
x-axis: 'xmin'/'xmax'
y-axis: 'ymin'/'ymax'
for each element of the facetting variable (if any).
Extract data for the reference lines
Description
This function especially extracts the data if an aesthetic variable is specified in the reference line parameters.
Usage
getDataReferenceLines(refLinePars, data, facetPars = NULL)
Arguments
refLinePars |
(optional) Nested list, with parameters for each reference line(s). Each sublist (a.k.a reference line) contains:
|
data |
Data.frame with data. |
facetPars |
List with facetting parameters,
passed to the facetting function. Variables should be specified
as character or formula.
For 'wrap' facetting ( |
Value
List of data for the lines
Author(s)
Laure Cougnaud
Get plot dimensions
Description
Get plot dimensions
Usage
getDimGgplot(gg)
Arguments
gg |
Value
Numeric vector with number of rows ('nrow') and columns ('ncol') of the plot
Author(s)
Laure Cougnaud
Get extra directory(ies) required for the clinical data review report
Description
By default, the 'figures', 'tables' and patient profiles folders
(patientProfilePath
parameter in the general
config file, if specified) in the input directory are considered.
Usage
getExtraDirs(inputDir = ".", configDir = file.path(inputDir, "config"))
Arguments
inputDir |
String with input directory, working directory by default. |
configDir |
String with directory with config files,
by default a 'config' folder in |
Value
Character vector with extra directories required by the report
Author(s)
Laure Cougnaud
Get facetting variables from facet parameters.
Description
Get facetting variables from facet parameters.
Usage
getFacetVars(facetPars = list())
Arguments
facetPars |
List with facetting parameters,
passed to the facetting function. Variables should be specified
as character or formula.
For 'wrap' facetting ( |
Value
Character vector with facetting variable
Author(s)
Laure Cougnaud
Get function code
Description
Get function code
Usage
getFctCode(fct)
Arguments
fct |
a R function |
Value
String with function code
Get the names of the ggplot
function
to use for the reference lines
Description
Get the names of the ggplot
function
to use for the reference lines
Usage
getFctTypeReferenceLines(refLinePars)
Arguments
refLinePars |
(optional) Nested list, with parameters for each reference line(s). Each sublist (a.k.a reference line) contains:
|
Value
List of type of each reference lines, among: 'vline', 'hline' and 'abline'.
Author(s)
Laure Cougnaud
Get HTML toc
Description
Get HTML toc
Usage
getHTMLToc(toc)
Arguments
toc |
data.frame with TOC info |
Value
Character vector with HTML toc
Get height of labels: title, subtitle or caption
Description
Get height of labels: title, subtitle or caption
Usage
getHeightLab(lab)
Arguments
lab |
String with label. |
Value
Integer with height in pixels for this element.
Author(s)
Laure Cougnaud
Get index of the line containing the HTML title in a vector of HTML strings
Description
Get index of the line containing the HTML title in a vector of HTML strings
Usage
getIndexHTMLTitle(x)
Arguments
x |
Character vector with HTML |
Value
Integer vector with index of the title in the vector x
Get interim res file
Description
Get interim res file
Usage
getInterimResFile(intermediateDir = "./interim", mdFile)
Arguments
intermediateDir |
String with intermediate directory ('interim'
by default), where
markdown files and rds file specifying Js libraries (with |
mdFile |
String with path of the Markdown file |
Value
String with path to the file with intermediate results.
Add jitter to the variable of the plot, based on the different groups of a grouping variable
Description
Add jitter to the variable of the plot, based on the different groups of a grouping variable
Usage
getJitterVar(data, var, byVar)
Arguments
data |
Data.frame with data. |
var |
String with variable to add a jitter to. |
byVar |
String with variable containing the groups to jitter by. |
Value
Numeric vector of length nrow(data)
containing the jittered variable.
Author(s)
Laure Cougnaud
Get Javascript custom scripts required for specific clinical data functionalities.
Description
Get Javascript custom scripts required for specific clinical data functionalities.
Usage
getJsDepClinDataReview(
type = c("collapsibleButton", "patientProfiles"),
dep = NULL
)
Arguments
type |
(optional) Character vector with type of dependencies, either: 'collapsibleButton' or 'patientProfiles'. |
dep |
(optional) Character vector with names of Javascript dependencies By default, all dependencies are included. |
Value
List of htmlDependency
.
To include this dependency in a report e.g. generated with rmarkdown,
these can be passed to the: extra_dependencies
parameter
of the output_format
specific function, e.g.:
rmarkdown::render(...,
output_format = rmarkdown::html_document(extra_dependencies = dep))
Author(s)
Laure Cougnaud
Get path of the HTML
file corresponding
to a specific config file.
Description
The name of the Markdown
file is based on:
for the general
config.yml
file: the basename of the specifiedindexPath
for other config file (each sub-report): the name of the config file, after removal of the '
config-
' part.
Usage
getMdFromConfig(
configFiles,
indexPath = "index.Rmd",
intermediateDir = "./interim"
)
Arguments
configFiles |
Character vector with name or path of the config file(s). |
indexPath |
String with path to the index file,
by default 'index.Rmd' in |
intermediateDir |
String with intermediate directory ('interim'
by default), where
markdown files and rds file specifying Js libraries (with |
Value
String with path to the HTML file
Author(s)
Laure Cougnaud
Get Markdown header, for creation in Rmarkdown.
Description
The depth is extracted:
from the
settings
if a specified depth is provided in the 'rmd_file_depth' for the current knitted file-
level
parameter otherwise
Usage
getMdHeader(title, level = 1)
Arguments
title |
String with header title. |
level |
Integer of length 1 with header depth/level, 1 by default |
Value
String with Markdown header,
to be included in R within cat
.
See Also
Other clinical data reporting:
checkReportTitles()
,
forceParams()
,
getParamsFromConfig()
,
gitbook_clinDataReview_report()
,
html_clinDataReview_report()
,
knitPrintClinDataReview()
,
postProcessReport()
,
render_clinDataReviewReport()
Read metadata file
Description
Read the metadata file from a yaml format. This function checks for existance of the metadata file and its content. In particular, within the yaml file matches the following strings:
-
path
: Path to the data. More than one path is allowed. -
dateTime
: Date and time, usually of the SDTM data creation. When printing the metadata in Rmd document, there is the possibility to add the date and time of the report generation. Seeknit_print.clinDataReviewMetadata
. -
datasetInfo
: General information about the data sets.
Usage
getMetadata(filePath, namesInfo)
Arguments
filePath |
String of path to file. Currently only one file path is supported. If more than one paths are provided, a warning will be printed and the first path will be used. |
namesInfo |
Named vector to rename the final output when printed in Rmd. The renaming happens only if the metadata info are printed in Rmd and not in the console. |
Details
Note that the input names do not necessarly have to match the exact names. For instance, the user can also write "dataTimeMySDTMData", and the function will parse for existance of the string "dataTime".
Value
A list of:
-
summaryInfo
Information extracted from the inputspath
, anddateTime
. -
datasetInfo
Information extracted fromdatasetInfo
.
Examples
# Create temporary yaml file
tmpdir <- tempdir()
library(yaml)
tmpYamlFile <- tempfile(
pattern = "file", tmpdir = tempdir(), fileext = ".yml"
)
listArgs <- list(
pathSDTMs = "path/To/SDTM",
pathSDTMReformat = "path/To/SDTMReformat",
dateTime = "20200101",
datasetInfo = list(
list(
column1 = "ex.xpt",
column2 = "20200101"
),
list(
column1 = "sl.xpt",
column2 = "20200101",
column3 = "OK"
)
)
)
write_yaml(
listArgs,
file = tmpYamlFile
)
# Run metadata
# Note: the 'datasetInfo' can also contain empty elements
getMetadata(filePath = tmpYamlFile)
Get parameter of function used for reference lines
Description
Get parameter of function used for reference lines
Usage
getParFctReferenceLines(type)
Arguments
type |
string with line type, either: 'hline', 'abline' or 'vline'. |
Value
Character vector with parameter names of the functions
Author(s)
Laure Cougnaud
Get parameters from a config file
Description
Please note that the information from this config file
and the general config file: config.yml
are considered.
In case parameters are defined both in the general
and specific config files, the parameter from the
general config file is ignored.
Usage
getParamsFromConfig(
configFile,
configDir = file.path(inputDir, "config"),
inputDir = "."
)
Arguments
configFile |
String with filename of the config file of interest in YAML format. |
configDir |
String with directory with config files,
by default a 'config' folder in |
inputDir |
String with input directory, working directory by default. |
Value
List with parameters from the specified configFile
and the general config file: config.yml
.
There are two specific handlers:
parameters tagged with '[param] !r [value]' are evaluated in R, and their evaluated value is returned
parameters tagged with '[param] !r-lazy [value]' are imported as character, and need to be further process with
forceParams
inside the report.
Parameters with YAML type 'r-lazy' are imported as character, with this additional class.
Author(s)
Laure Cougnaud
See Also
Other clinical data reporting:
checkReportTitles()
,
forceParams()
,
getMdHeader()
,
gitbook_clinDataReview_report()
,
html_clinDataReview_report()
,
knitPrintClinDataReview()
,
postProcessReport()
,
render_clinDataReviewReport()
Get path ('href') property from hyperlink(s).
Description
Get path ('href') property from hyperlink(s).
Usage
getPathHyperlink(x)
Arguments
x |
Character vector with hyperlink(s). If multiple, the hyperlinks should be separated by: ', '. |
Value
Character vector of length x
containing only the hyperlinks.
Author(s)
Laure Cougnaud
Get path of template clinical data report
Description
Get path of template clinical data report
Usage
getPathTemplate(file, package = "clinDataReview")
Arguments
file |
String with name of the template Rmd document |
package |
String, which package the template should be extracted from,
by default the |
Value
String with path to the template in the installed clinDataReview
package
Author(s)
Laure Cougnaud
Examples
pathDivisionTemplate <- getPathTemplate("divisionTemplate.Rmd") # get path template in the package
tmp <- file.copy(from = pathDivisionTemplate, to = tempdir()) # copy to temporary dir (for example)
params <- list(reportTitle = "Adverse events")
rmarkdown::render(file.path(tempdir(), basename(pathDivisionTemplate))) # run file
Extract variables displayed in the attached table, for each available plotting function of the clinDataReview package.
Description
This function is used in each plotting function of the package
to extract the variable(s) displayed in the table associated to the
plot and their associated labels.
This can also be used in the template reports, e.g. to extract
reference variable(s) for the comparison table functionality
in the plot template report.
The following framework is used:
if variables to be displayed in the table (
tableVars
) are not specified:
all variables displayed in the plot are selected, based on the plot arguments.
For example: the variables displayed in the x and y axis and for coloring are extracted for thescatterplotClinData
plotting function.
Label for these variable(s) are extracted from the associated parameter (e.g.xLab
forxVar
and so on) or the general parameter for the variable labels (labelVars
) if not specified.if variables to be displayed in the table (
tableVars
) are specified:
these variable(s) are returned.
The associated label(s) are extracted from the associated parameter (tableLab
) or the general parameter for the variable labels (labelVars
) if not specified.
For the functions: plotCountClinData
,
treemapClinData
, sunburstClinData
:
value to represent are included in the table and colored with a bar.
Usage
getPlotTableVars(plotFunction, plotArgs)
Arguments
plotFunction |
String with name of the plotting function,
be available in the |
plotArgs |
List with parameters passed to the plotting function. |
Value
Character vector with variable to include in the table,
with extra attributes (passed to tableClinData
):
'tableLab': Named character vector with labels for the table variables
'tablePars' : extra table parameters, only included if specified as input or specified internally.
labels and the table parameters .
Author(s)
Laure Cougnaud
Get margins and positions of specific elements for a clinical data plot
Description
The elements are positioned as following:
on top of the plot
title
subtitle
legend, if positioned on top of the plot
facet title
at the bottom of the plot
label for the x-axis
legend, if positioned on the bottom of the plot
caption
Margins are computed based on the presence
of these elements.
Only one line is counted for the legend,
as plotly will extend the margin
if necessary for the legend (for bottom legend).
Usage
getPositionAndMargins(
title = NULL,
subtitle = NULL,
xLab = NULL,
caption = NULL,
facet = FALSE,
includeLegend = TRUE,
legendPosition = "right"
)
Arguments
title |
String with title for the plot. |
subtitle |
String with subtitle. |
xLab |
String with label for |
caption |
String with caption. |
facet |
Logical, if TRUE the plot contains facets. |
includeLegend |
Logical, if TRUE (by default) a legend is available in the plot. |
legendPosition |
String with position of the legend, among: 'top'/'left'/'bottom'/'right', 'right' by default. |
Value
List with:
'margin': List with bottom ('t') and top ('t') margins in pixels
'position': List with position of the following plot elements:
on top of the plot: subtitle and legend (if positioned at the top).
The position is defined as the distance in pixels from the top of the plotting area to the bottom of the element (yanchor = 'bottom'
)at the bottom of the plot: caption, xLab and legend (if positioned at the bottom).
The position is defined as the distance in pixels from the bottom of the plotting area to the top of the element (yanchor = 'top'
)
Especially, the legend should be positioned with anchor 'top' such as the margins are automatically expanded if the legend contains multiple rows.
Author(s)
Laure Cougnaud
Get dimensions for a clinical data plot
Description
This function set sensitive defaults dimensions for a plot in the package. This includes:
setting a default width for a figure to fit in a standard clinical data review report
increasing the figure height:
for facetted plot, ensuring that each facet is relatively squared
if a caption, subtitle, title, title for the x-axis are specified
if a legend is set at the bottom or the top of the plot
increasing the figure width if a legend is set at the left or the right of the plot
Usage
getSizePlot(
width = NULL,
height = NULL,
gg = NULL,
nrow = 1L,
ncol = 1L,
title = NULL,
subtitle = NULL,
caption = NULL,
xLab = NULL,
facet = FALSE,
includeLegend = TRUE,
legendPosition = "right",
y = NULL
)
Arguments
width |
Numeric, width of the plot in pixels, 800 by default. |
height |
Numeric, height of the plot in pixels, 500 by default. |
gg |
|
nrow |
single-length integer specifying the
number of facet rows in the plot. (default = 1)
Overwritten if |
ncol |
single-length integer specifying the
number of facet columns in the plot. (default = 1)
Overwritten if |
title |
String with title for the plot. |
subtitle |
String with subtitle. |
caption |
String with caption. |
xLab |
String with label for |
facet |
Logical, if TRUE the plot contains facets. |
includeLegend |
Logical, if TRUE (by default) a legend is available in the plot. |
legendPosition |
String with position of the legend, among: 'top'/'left'/'bottom'/'right', 'right' by default. |
y |
Character vector or factor with elements in the y-axis, or list of such vectors. If a list is provided, the maximum height obtained across the different list elements is used. |
Value
Numeric vector with width ('width') and height ('height') of the plot in pixels.
Author(s)
Laure Cougnaud
Get TOC numbering
Description
Get TOC numbering
Usage
getTocNumbering(levels)
Arguments
levels |
vector with levels of the section, in the order as available in the book. |
Value
Character vector with section numbers
Author(s)
Laure Cougnaud
Get a watermark, to be included in a clinical visualization
Description
Get a watermark, to be included in a clinical visualization
Usage
getWatermark(
label = "EXPLORATORY",
color = "lightgrey",
fontsize = 20,
file = NULL,
width = 800,
height = 500
)
Arguments
label |
String with label for the watermark, 'EXPLORATORY' by default. |
color |
String with color for the watermark, 'lightgrey' by default. |
fontsize |
Integer with fontsize for the watermark, 20 by default. |
file |
(optional) String with path to a file where the watermark will be exported to. |
width |
Numeric, width of the plot in pixels, 800 by default. |
height |
Numeric, height of the plot in pixels, 500 by default. |
Value
The file
with the watermark (invisibly).
Author(s)
Laure Cougnaud, Kirsten van Hoorde
See Also
Other watermark helpers:
addWatermark()
Examples
# export a watermark to a file
watermark <- tempfile(pattern = "watermark", fileext = ".png")
getWatermark(file = watermark)
Clinical data format for bookdown report.
Description
This function is only meant to set sensitive
defaults for gitbook.
gitbook
can be used instead.
Usage
gitbook_clinDataReview_report(
logo = NULL,
logoHeight = "60px",
split_by = "section+number",
config = list(sharing = NULL, toc = list(collapse = "section")),
extra_dependencies = NULL,
css = NULL,
...
)
Arguments
logo |
String, path to the logo. No logo is printed by default. |
logoHeight |
String, indicating the logo height; 60px height by default. |
split_by |
String, how the reports should be split, (see help of the gitbook function) |
config |
List with config parameters, by default: no sharing and collapsed by section. (see help of the gitbook function) |
extra_dependencies |
NULL by default |
css |
String, path to the css. |
... |
Extra parameters passed to the gitbook function. |
Value
R Markdown output format to pass to render_book
.
Author(s)
Laure Cougnaud
See Also
Other clinical data reporting:
checkReportTitles()
,
forceParams()
,
getMdHeader()
,
getParamsFromConfig()
,
html_clinDataReview_report()
,
knitPrintClinDataReview()
,
postProcessReport()
,
render_clinDataReviewReport()
Clinical data format for rmarkdown report.
Description
This function only kept for back-compatibility,
html_document
can be used instead.
Usage
html_clinDataReview_report(extra_dependencies = NULL, ...)
Arguments
extra_dependencies |
NULL by default. |
... |
Extra parameters passed to the html_document function. |
Value
R Markdown output format to pass to render
.
Author(s)
Laure Cougnaud
See Also
Other clinical data reporting:
checkReportTitles()
,
forceParams()
,
getMdHeader()
,
getParamsFromConfig()
,
gitbook_clinDataReview_report()
,
knitPrintClinDataReview()
,
postProcessReport()
,
render_clinDataReviewReport()
Include output from clinical data, or list of such outputs in a Rmarkdown report, with an appropriate title.
Description
Include output from clinical data, or list of such outputs in a Rmarkdown report, with an appropriate title.
Usage
knitPrintClinDataReview(list, sep = ".", level = 1)
Arguments
list |
Named list of clinical data plots, the names are used for the section header. If several section header should be created, either:
|
sep |
String with separator used to distinguish different levels in the labels of the list. e.g. '.' by default. |
level |
Integer with base level for section, 1 by default. |
Value
No returned value, the plots are included in the report. If a element in the list are empty (NULL), these elements (and the associated sections) are not included in the report.
Author(s)
Laure Cougnaud
See Also
Other clinical data reporting:
checkReportTitles()
,
forceParams()
,
getMdHeader()
,
getParamsFromConfig()
,
gitbook_clinDataReview_report()
,
html_clinDataReview_report()
,
postProcessReport()
,
render_clinDataReviewReport()
Print clinDataReviewTable
object in a knitted document
(e.g. Rmarkdown document).
Description
Print clinDataReviewTable
object in a knitted document
(e.g. Rmarkdown document).
Usage
## S3 method for class 'clinDataReview'
knit_print(x, ...)
Arguments
x |
Object of class |
... |
Extra parameters for compatibility with |
Author(s)
Laure Cougnaud
Print metadata file in the clinical data report
Description
This function receives the metadata information from getMetadata
and
prints them in a format for an Rmd report.
In general, any list could be called as long as it is composed by two elements:
-
summaryInfo
: an R object. -
datasetInfo
: a data.frame or a matrix.
The first (summaryInfo
) is printed as kable
object
and the second (datasetInfo
) is printed as hide/show html button with
the function collapseHtmlContent
.
Usage
## S3 method for class 'clinDataReviewMetadata'
knit_print(x, options = list(), ...)
Arguments
x |
List of two elements named |
options |
List of extra options to be passed as chunk options.
The option |
... |
Extra arguments to be passed. |
Value
Nothing. The tables are ready to be printed in Rmd.
html code to include metadata in a report
Set layout for a clinical data plot.
Description
Set layout for a clinical data plot.
Usage
layoutClinData(
xLab = NULL,
yLab = NULL,
title = NULL,
caption = NULL,
subtitle = NULL,
includeLegend = FALSE,
legendPosition = "right",
facet = FALSE,
nrow = 1L,
ncol = 1L,
width,
height,
watermark = NULL,
...
)
Arguments
xLab |
String with label for |
yLab |
String with label for |
title |
String with title for the plot. |
caption |
String with caption. |
subtitle |
String with subtitle. |
includeLegend |
Logical, if TRUE (by default) a legend is available in the plot. |
legendPosition |
String with position of the legend, among: 'top'/'left'/'bottom'/'right', 'right' by default. |
facet |
Logical (FALSE by default), does the plot contains facets? |
nrow |
single-length integer specifying the
number of facet rows in the plot. (default = 1)
Overwritten if |
ncol |
single-length integer specifying the
number of facet columns in the plot. (default = 1)
Overwritten if |
width |
Numeric, width of the plot in pixels, 800 by default. |
height |
Numeric, height of the plot in pixels, 500 by default. |
watermark |
(optional) String with path to a file containing a watermark. |
... |
Any parameters for the |
Value
The updated plotly
object
Author(s)
Laure Cougnaud
Merge multiple session information
Description
Merge multiple session information
Usage
## S3 method for class 'sessionInfo'
merge(...)
Arguments
... |
objects of type |
Value
sessionInfo
with combined information
Author(s)
Laure Cougnaud
Move skeleton files from the package to a directory
Description
This function moves the files used to create the skeleton from the package to a specified directory.
Usage
moveSkeletonFiles(dir)
Arguments
dir |
String, path to the directory. |
Value
Nothing, the files are available in the specified directory.
Move data sets from clinUtils
Description
Move SDTM data sets available in clinUtils
into a
specified local directory.
Usage
moveXpt(dir)
Arguments
dir |
String, path to the directory. |
Value
Nothing, the data are saved in the dedicated location.
Interactive plot of 'count' data
Description
Note: the table and plot are not (yet) linked.
Usage
plotCountClinData(
data,
vars,
varsLab = getLabelVar(vars, labelVars = labelVars),
valueVar,
valueLab = getLabelVar(valueVar, labelVars = labelVars),
colorVar = NULL,
colorLab = getLabelVar(valueVar, labelVars = labelVars),
colorPalette = getOption("clinDataReview.colors"),
colorRange = NULL,
valueType = "total",
title = paste(c(paste(valueLab, "by", paste(varsLab, collapse = " and ")), titleExtra),
collapse = "<br>"),
titleExtra = NULL,
subtitle = NULL,
caption = NULL,
labelVars = NULL,
width = NULL,
height = NULL,
pathVar = NULL,
pathLab = getLabelVar(pathVar, labelVars = labelVars),
hoverVars = c(vars, valueVar, colorVar),
hoverLab = getLabelVar(hoverVars, labelVars = labelVars),
table = FALSE,
tableVars,
tableLab,
tableButton = TRUE,
tablePars = list(),
id = paste0("plotClinData", sample.int(n = 1000, size = 1)),
verbose = FALSE,
typePlot = c("sunburst", "treemap"),
watermark = NULL
)
Arguments
data |
Data.frame with data. |
vars |
Character vector with variables of |
varsLab |
Named character vector with labels for |
valueVar |
String with numeric variable of |
valueLab |
String with label for the |
colorVar |
(optional) String with coloring variable (NULL by default). By default, the treemap is colored based by section. |
colorLab |
String with label for |
colorPalette |
(optional) Named character vector with color palette.
If not specified, the viridis color palette is used. |
colorRange |
(optional) Numeric vector of length 2 with range for the color variable, in case it is a numeric variable. |
valueType |
String with type of values in |
title |
String with title for the plot. |
titleExtra |
String with extra title for the plot (appended after |
subtitle |
String with subtitle. |
caption |
String with caption. |
labelVars |
Named character vector containing variable labels. |
width |
Numeric, width of the plot in pixels, 800 by default. |
height |
Numeric, height of the plot in pixels, 500 by default. |
pathVar |
String with variable of <a href="./path-to-report">label</a> .
|
pathLab |
String with label for |
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 |
table |
Logical, if TRUE (FALSE by default)
returns also a |
tableVars |
Character vector with variables to be included in the table. |
tableLab |
Named character vector with labels
for each |
tableButton |
Logical, if TRUE (by default) the table is included within an HTML button. |
tablePars |
List with parameters passed to the
|
id |
String with general id for the plot:
If not specified, a random id, as 'plotClinData[X]' is used. |
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. |
typePlot |
String with plot type, 'treemap' or 'sunburst'. |
watermark |
(optional) String with path to a file containing a watermark. |
Value
Either:
if a
table
is requested: aclinDataReview
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()
,
sunburstClinData()
,
treemapClinData()
Convert clinical data Markdown files to HTML
Description
Convert clinical data Markdown files to HTML
Usage
postProcessReport(
inputDir = ".",
configDir = file.path(inputDir, "config"),
indexPath = file.path(inputDir, "index.Rmd"),
extraDirs = getExtraDirs(inputDir = inputDir, configDir = configDir),
outputDir = "./report",
intermediateDir = "./interim",
mdFiles = NULL,
nCores = 1,
logFile = NULL,
verbose = TRUE,
...
)
Arguments
inputDir |
String with input directory, working directory by default. |
configDir |
String with directory with config files,
by default a 'config' folder in |
indexPath |
String with path to the index file,
by default 'index.Rmd' in |
extraDirs |
Character vector with extra directories required by
the report, directory with external images.
By default, the directories: 'figures', 'tables' and mentioned in the
'patientProfilePath' parameter of the
general config file are included.
All these folders should be available in |
outputDir |
String with output directory, ('report' by default). |
intermediateDir |
String with intermediate directory ('interim'
by default), where
markdown files and rds file specifying Js libraries (with |
mdFiles |
(optional) Path to the |
nCores |
Integer containing the number of cores used to render the report (1 by default). If more than 1, two steps of the report creation are run in parallel across chapters:
|
logFile |
(optional) String with path to a log file, where output (also error/messages/warnings) should be stored. If specified, the entire output is re-directed to this file. |
verbose |
Logical, if TRUE (FALSE by default) progress messages are printed during the report execution. |
... |
Any parameters passed to |
Value
String with path to the front page of the report.
Author(s)
Laure Cougnaud
See Also
Other clinical data reporting:
checkReportTitles()
,
forceParams()
,
getMdHeader()
,
getParamsFromConfig()
,
gitbook_clinDataReview_report()
,
html_clinDataReview_report()
,
knitPrintClinDataReview()
,
render_clinDataReviewReport()
Print a clinDataReview
object in the console
Description
Print a clinDataReview
object in the console
Usage
## S3 method for class 'clinDataReview'
print(x, ...)
Arguments
x |
Object of class |
... |
Extra parameters for compatibility with |
Value
No returned value, the object is printed into the console.
Process a dataset.
Description
This function is intended to automate all data processing steps for use in the 'clinDataReview' reports using config files.
Usage
processData(data, processing, labelVars = NULL, ...)
Arguments
data |
Data.frame with data. |
processing |
List with processing steps for the data. Each element in the list should be a named list containing the parameters for the specific processing function. The name specifies the processing step, among:
Multiple steps of each kind can be specified after each other (e.g. 1: filter,
2: transform, 3: filter, ...). |
labelVars |
Named character vector containing variable labels. |
... |
Any parameters passed to all processing functions
(if this parameter is available).
If specified, these parameters shouldn't be specified also in |
Value
Data.frame with processed data
,
with extra attribute: labelVars
.
Author(s)
Laure Cougnaud
Examples
library(clinUtils)
data(dataADaMCDISCP01)
dataLB <- dataADaMCDISCP01$ADLBC
# filter and annotate data
processData(
data = dataLB,
processing = list(
list(filter = list(var = "ANL01FL", value = "Y")),
list(annotate = list(vars = "ANRIND", varFct = 'factor(ANRIND, levels = c("L", "N", "H"))'))
)
)
## multiple filtering steps:
# If these are specified in the same 'filter' step condition, these are considered independently,
# and the selected records combined with an 'AND' operator.
# Example: consider only records:
# - with analysis flag AND
# - from subject with high/low measurement (for all records) for each parameter
processData(
data = dataLB,
processing = list(
list(filter = list(
list(var = "ANL01FL", value = "Y"),
list(var = "ANRIND", value = c("L", "H"),
postFct = any, varsBy = c("USUBJID", "PARAM"))
)
)
)
)
# a custom operator to combine the selected records can be specified
# Example: consider only records:
# - with analysis flag OR
# - from subject with high/low measurement (for all records) for each parameter
processData(
data = dataLB,
processing = list(
list(filter = list(
list(var = "ANL01FL", value = "Y"),
"|",
list(var = "ANRIND", value = c("L", "H"),
postFct = any, varsBy = c("USUBJID", "PARAM"))
)
)
)
)
# If the filtering conditions are specified in different filtering steps, these are
# considered sequentially.
# Example:
# 1) consider only analysis records and
# 2) from these records, consider only subject with high/low measurement for
# each parameter
processData(
data = dataLB,
processing = list(
list(filter = list(var = "ANL01FL", value = "Y")),
list(filter = list(var = "ANRIND", value = c("L", "H"),
postFct = any, varsBy = c("USUBJID", "PARAM")))
)
)
# Note for this particular
Rename variable names of metadata info
Description
Rename variable names referring to the paths and the date.
Usage
renamePathDateInfoMetadata(summaryInfo, namesInfo)
Arguments
summaryInfo |
A matrix, see output from |
namesInfo |
Named vector to rename the final output. |
Value
A matrix, same as input summaryInfo
with renamed variable names.
Render one chapter of a clinical report, based on a configuration file
Description
Render one chapter of a clinical report, based on a configuration file
Usage
renderChapter(
configFile,
configGeneralParams = getParamsFromConfig(configFile = "config.yml", configDir =
configDir, inputDir = inputDir),
configDir = file.path(inputDir, "config"),
indexPath = file.path(inputDir, "index.Rmd"),
inputDir = ".",
intermediateDir = "./interim",
logFile = NULL,
verbose = TRUE,
...
)
Arguments
configFile |
String with filename of the config file of interest in YAML format. |
configGeneralParams |
List with parameters from the general config file |
configDir |
String with directory with config files,
by default a 'config' folder in |
indexPath |
String with path to the index file,
by default 'index.Rmd' in |
inputDir |
String with input directory, working directory by default. |
intermediateDir |
String with intermediate directory ('interim'
by default), where
markdown files and rds file specifying Js libraries (with |
logFile |
(optional) String with path to a log file, where output (also error/messages/warnings) should be stored. If specified, the entire output is re-directed to this file. |
verbose |
Logical, if TRUE (FALSE by default) progress messages are printed during the report execution. |
... |
options passed to |
Value
No output file, the Markdown report for the chapter
and the knit_meta
object is available in the
intermediateDir
directory.
If the input parameters are not correctly extracted, NULL is returned.
Render a rmarkdown file, possibly in a new R session
Description
This has the possibility to save output in a log file, and saving also session information.
Usage
renderFile(input, encoding = "UTF-8", params = NULL, logFile = NULL, ...)
Arguments
input |
Input file to be rendered. |
encoding |
String with encoding, 'UTF-8' by default. |
params |
List with input parameters for this document. |
logFile |
(optional) String with path to a log file, where output (also error/messages/warnings) should be stored. If specified, the entire output is re-directed to this file. |
... |
Any extra parameters passed to |
Details
Note: this function is inspired from xfun::Rscript_call
Value
Output of the function with additional attribute: 'sessionInfo' containing the details of the session information. If the report fails, an error message is returned.
Author(s)
Laure Cougnaud
Render a clinical data review report.
Description
Render a clinical data review report.
Usage
render_clinDataReviewReport(
configFiles = NULL,
configDir = file.path(inputDir, "config"),
logFile = NULL,
indexPath = file.path(inputDir, "index.Rmd"),
inputDir = ".",
outputDir = "./report",
intermediateDir = "./interim",
extraDirs = getExtraDirs(inputDir = inputDir, configDir = configDir),
quiet = FALSE,
verbose = TRUE,
nCores = 1
)
Arguments
configFiles |
(optional) Character vector with specific config files to be converted from Rmarkdown to Markdown. If
|
configDir |
String with directory with config files,
by default a 'config' folder in |
logFile |
(optional) String with path to a log file, where output (also error/messages/warnings) should be stored. If specified, the entire output is re-directed to this file. |
indexPath |
String with path to the index file,
by default 'index.Rmd' in |
inputDir |
String with input directory, working directory by default. |
outputDir |
String with output directory, ('report' by default). |
intermediateDir |
String with intermediate directory ('interim'
by default), where
markdown files and rds file specifying Js libraries (with |
extraDirs |
Character vector with extra directories required by
the report, directory with external images.
By default, the directories: 'figures', 'tables' and mentioned in the
'patientProfilePath' parameter of the
general config file are included.
All these folders should be available in |
quiet |
Logical, if TRUE (FALSE by default)
messages during the execution of each report are not displayed
in the console (see |
verbose |
Logical, if TRUE (FALSE by default) progress messages are printed during the report execution. |
nCores |
Integer containing the number of cores used to render the report (1 by default). If more than 1, two steps of the report creation are run in parallel across chapters:
|
Value
String with path to the front page of the report.
Process
This function is based on the render_book function, with the extra functionalities:
specification of chapter-specific input parameters, specified in YAML configuration files
(optional) creation of each chapter in parallel if
nCores
> 1. In that case, all chapters are run in parallel, excepted the chapter(s) run internally in parallel (config file withparallel
set to 'TRUE').(optional) split of each chapter into html file specific for each chapter, by specifying the
split_by
parameter in the chapter-specific config file
This consists of:
importing the general config file ('config'.yml) to identify each report of interest ('config' tag)
for each report of interest:
loading the report specific parameters from the associated 'config' file (see the
getParamsFromConfig
function)if the template should be extracted from a specified package (
templatePackage
tag), this template is copied to the current directory. Please note that if a file with same name is available in the working directory, this file will be overwritten.running the report ('template' tag) with the associated parameters in a new R session for reproducibility, to obtain the associated Markdown file.
This step is parallelized across the different config files, if thenCores
parameter is specified.
checking if the associated
Markdown
andrds
file (list of Js dependencies) are available inintermediateDir
split each chapter into separated Markdown documents, based on the
split_by
parameter (specified at the report or config level)conversion of each Markdown document to an HTML document.
This step is parallelized across the different Markdown documents, if thenCores
parameter is specified.build the book:
creation of a common TOC for the book
inclusion of the TOC in each Markdown file
update of the section number in each chapter
inclusion of the section number in each HTML file name
If the execution of a specific report fails with error, a warning message is triggered. A report containing only the specified title is created, to ensure output consistency (especially html file numbering) in case the report succeeds.
Available template report
see ? `clinDataReview-templates`
for a list of
clinical data template report available in the package.
Extension to chapter-specific split
The bookdown 'split_by' parameter is extended, to support:
chapter-specific split, specified in the configuration file of the specific chapter, via the
split_by
parameterspecification as a number (if specified within a config file), e.g. '0' for no split, 1' for chapter, '2' for section, '3' for subsection, ...
split at section level higher than 2 (until 7) (if specified within a config file)
Author(s)
Laure Cougnaud
See Also
Other clinical data reporting:
checkReportTitles()
,
forceParams()
,
getMdHeader()
,
getParamsFromConfig()
,
gitbook_clinDataReview_report()
,
html_clinDataReview_report()
,
knitPrintClinDataReview()
,
postProcessReport()
Scatterplot of variables of interest for clinical data visualization.
Description
The parameters for this visualization
are based on ggplot2
(aesthetic, scale, ...), parameter specification,
unlike the other visualizations of the package.
Usage
scatterplotClinData(
data,
xVar,
yVar,
xLab = getLabelVar(var = xVar, labelVars = labelVars),
xLabVar = NULL,
yLab = getLabelVar(var = yVar, labelVars = labelVars),
yLabVar = NULL,
aesPointVar = list(),
pointPars = list(),
aesLineVar = list(),
linePars = list(),
lineInclude = length(aesLineVar) > 0,
aesSmoothVar = list(),
smoothPars = list(),
smoothInclude = length(c(aesSmoothVar, smoothPars)) > 0,
aesLab,
xTrans = "identity",
yTrans = "identity",
xPars = list(),
yPars = list(),
xLabVars = NULL,
yLim = NULL,
xLim = NULL,
yLimExpandData = TRUE,
xLimExpandData = TRUE,
title = paste(c(paste(yLab, "vs", xLab), titleExtra), collapse = "<br>"),
titleExtra = NULL,
caption = NULL,
subtitle = NULL,
facetPars = list(),
facetType = c("wrap", "grid"),
scalePars = list(),
themePars = list(legend.position = "bottom"),
refLinePars = NULL,
labelVars = NULL,
width = NULL,
height = NULL,
hoverVars,
hoverLab,
idVar = "USUBJID",
idLab = getLabelVar(idVar, labelVars = labelVars),
idHighlightBox = FALSE,
pathVar = NULL,
pathExpand = FALSE,
id = paste0("plotClinData", sample.int(n = 1000, size = 1)),
selectVars = NULL,
selectLab = getLabelVar(selectVars, labelVars = labelVars),
table = FALSE,
tableVars,
tableLab,
tableButton = TRUE,
tablePars = list(),
watermark = NULL,
verbose = FALSE
)
Arguments
data |
Data.frame with input data. |
xVar |
String with column of |
yVar |
String with column of |
xLab |
String with label for |
xLabVar |
(optional) Character vector with column(s) of |
yLab |
String with label for |
yLabVar |
(optional) Character vector with column(s) of |
aesPointVar |
List with specification of aesthetic variable(s),
for the point, passed to the |
pointPars |
List with parameters other than aesthetic variables to pass to |
aesLineVar |
List with specification of aesthetic variable(s),
for the line, passed to the |
linePars |
List with parameters other than aesthetic variables to pass to |
lineInclude |
Logical, if TRUE (by default if |
aesSmoothVar |
List with specification of aesthetic variable(s),
for the smoothing layer, passed to the |
smoothPars |
List with parameters other than aesthetic variables to pass to |
smoothInclude |
Logical, if TRUE (by default if one of |
aesLab |
Named character vector with labels for each aesthetic variable. |
xTrans , yTrans |
Transformation for the x/y- variables,
passed to the |
xPars , yPars |
List with extra parameters for x/y axis, passed to the
|
xLabVars |
Character vector with variable(s) to be displayed
as the labels of the ticks in the x-axis. |
xLim , yLim |
Numeric vector of length 2 with limits for the x/y axes. |
xLimExpandData , yLimExpandData |
Logical (TRUE by default), should the
limits specified via |
title |
String with title for the plot. |
titleExtra |
String with extra title for the plot (appended after |
caption |
String with caption. |
subtitle |
String with subtitle. |
facetPars |
List with facetting parameters, passed to the facetting function. |
facetType |
String with facetting type, either:
|
scalePars |
List with parameters to customize
scales. Each sublist should contains a set of parameters
passed to the |
themePars |
List with general theme parameters
(see |
refLinePars |
(optional) Nested list, with parameters for each reference line(s). Each sublist (a.k.a reference line) contains:
|
labelVars |
Named character vector containing variable labels. |
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 variables to be displayed in the hover,
by default |
hoverLab |
Named character vector with labels for |
idVar |
String with variable containing subject ID. |
idLab |
String with label for |
idHighlightBox |
Logical, if TRUE (FALSE by default) a selectize box
is included to highlight selected element(s) of the ID variable ( |
pathVar |
String with variable of
|
pathExpand |
Logical, if FALSE (by default)
the path to subject-report is included in an hyperlink in the table,
otherwise a collapsed row is created.
This should be set to TRUE only if multiple paths
are included for each row in |
id |
String with general id for the plot:
If not specified, a random id, as 'plotClinData[X]' is used. |
selectVars |
(optional) Character vector with variable(s) from |
selectLab |
(Named) character vector with label for |
table |
Logical, if TRUE (FALSE by default)
returns also a |
tableVars |
Character vector with variables to be included in the table. |
tableLab |
Named character vector with labels
for each |
tableButton |
Logical, if TRUE (by default) the table is included within an HTML button. |
tablePars |
List with parameters passed to the
|
watermark |
(optional) String with path to a file containing a watermark. |
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: aclinDataReview
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.:
timeProfileIntervalPlot()
Examples
library(clinUtils)
data(dataADaMCDISCP01)
labelVars <- attr(dataADaMCDISCP01, "labelVars")
dataLB <- dataADaMCDISCP01$ADLBC
dataDM <- dataADaMCDISCP01$ADSL
dataLB <- annotateData(dataLB, annotations = list(data = dataDM))
# subset of the data for the example
dataLB <- subset(dataLB, VISIT %in% c("SCREENING 1", "WEEK 2", "WEEK 8"))
## time profile
dataPlot <- subset(dataLB, PARAMCD == "ALT")
# with relative day
scatterplotClinData(
data = dataPlot,
xVar = "ADY",
yVar = "LBSTRESN",
aesPointVar = list(color = "TRTP", fill = "TRTP"),
aesLineVar = list(group = "USUBJID", color = "TRTP"),
labelVars = labelVars
)
# with actual visit
dataPlot$AVISIT <- with(dataPlot, reorder(trimws(AVISIT), AVISITN))
scatterplotClinData(
data = dataPlot,
xVar = "AVISIT",
yVar = "LBSTRESN",
aesPointVar = list(color = "TRTP", fill = "TRTP"),
aesLineVar = list(group = "USUBJID", color = "TRTP"),
labelVars = labelVars
)
# add number of subjects below each visit
if (requireNamespace("inTextSummaryTable", quietly = TRUE)) {
# compute number of subjects by visit
summaryTable <- inTextSummaryTable::computeSummaryStatisticsTable(
dataPlot,
rowVar = "AVISIT",
stats = "n"
)
# add it in the data
dataPlot <- merge(dataPlot, summaryTable[, c("AVISIT", "n")], all.x = TRUE)
dataPlot$n <- paste0("N=", dataPlot$n)
scatterplotClinData(
data = dataPlot,
xVar = "AVISIT", xLabVars = c("AVISIT", "n"),
yVar = "LBSTRESN",
aesPointVar = list(color = "TRTP", fill = "TRTP"),
aesLineVar = list(group = "USUBJID", color = "TRTP"),
labelVars = labelVars
)
}
## pairwise comparison plot of two parameters of interest:
# format data long -> wide format (one column per lab param)
dataPlot <- subset(dataLB, PARAMCD %in% c("ALT", "AST"))
dataPlot <- stats::aggregate(
LBSTRESN ~ USUBJID + VISIT + VISITNUM + PARAMCD,
data = dataPlot,
FUN = mean
)
dataPlotWide <- stats::reshape(
data = dataPlot,
timevar = "PARAMCD", idvar = c("USUBJID", "VISIT", "VISITNUM"),
direction = "wide"
)
colnames(dataPlotWide) <- sub("^LBSTRESN.", "", colnames(dataPlotWide))
# scatterplot per visit
scatterplotClinData(
data = dataPlotWide,
xVar = "ALT", yVar = "AST",
aesPointVar = list(color = "USUBJID", fill = "USUBJID"),
themePars = list(legend.position = "none"),
facetPars = list(facets = "VISIT"),
labelVars = labelVars,
subtitle = "Visualization is split by visit",
caption = "Points are colored by subject ID"
)
# scatterplot with all visits, link subjects
xLab <- getLabelParamcd(paramcd = "ALT", data = dataLB,
paramcdVar = "PARAMCD", paramVar = "PARAM")
yLab <- getLabelParamcd(paramcd = "AST", data = dataLB,
paramcdVar = "PARAMCD", paramVar = "PARAM")
scatterplotClinData(
data = dataPlotWide,
xVar = "ALT", yVar = "AST",
xLab = xLab,
yLab = yLab,
aesPointVar = list(color = "VISIT", fill = "VISIT"),
aesLineVar = list(group = "USUBJID"),
labelVars = labelVars
)
# scatterplot of different visits versus baseline
# add baseline as extra column:
dataPlot <- subset(dataLB, PARAMCD == "ALT")
dataPlotBL <- subset(dataPlot, VISIT == "SCREENING 1")
dataPlotBL <- dataPlotBL[with(dataPlotBL, order(USUBJID, -ADY)), ]
dataPlotBL <- dataPlotBL[!duplicated(dataPlotBL$USUBJID), ]
dataPlot$LBSTRESNBL <- dataPlot[match(dataPlot$USUBJID, dataPlotBL$USUBJID), "LBSTRESN"]
# sort visits:
dataPlot$VISIT <- with(dataPlot, reorder(VISIT, VISITNUM))
xLab <- paste(labelVars["LBSTRESN"], "for last screening visit")
yLab <- paste(labelVars["LBSTRESN"], "at visit X")
paramLab <- getLabelParamcd(paramcd = "ALT", data = dataLB,
paramcdVar = "PARAMCD", paramVar = "PARAM")
scatterplotClinData(
data = dataPlot,
xVar = "LBSTRESNBL", xLab = xLab,
yVar = "LBSTRESN", yLab = yLab,
aesPointVar = list(color = "USUBJID", fill = "USUBJID"),
aesLineVar = list(group = "USUBJID", color = "USUBJID"),
hoverVars = c("USUBJID", "VISIT", "ADY", "LBSTRESN"),
labelVars = labelVars,
facetPars = list(facets = "VISIT"),
themePars = list(legend.position = "none"),
title = paste("Comparison of actual value of",
paramLab,
"at each visit versus baseline"
),
refLinePars = list(
list(slope = 1, intercept = 0, linetype = 1, color = "black",
label = FALSE),
list(yintercept = "A1LO", linetype = 2, color = "blue"),
list(yintercept = "A1HI", linetype = 2, color = "purple",
label = "Reference Range Upper Limit")
)
)
## scatterplot with smoothing layer
data <- data.frame(
USUBJID = c(rep('subj1', 20), rep('subj2', 20)),
time = rep( 1:20 , 2 ),
response = c(1:20, 50:31) + runif(min =-3, max = +3, 40),
treat = rep(c('trA', 'trB'), 20),
stringsAsFactors = FALSE
)
# smoothing per subject
scatterplotClinData(
data = data,
xVar = "time", yVar = "response",
aesPointVar = list(color = "treat"),
aesLineVar = list(group = 'USUBJID'),
linePars = list(linetype='dotted'),
aesSmoothVar = list(color='USUBJID', group='USUBJID'),
smoothPars = list(alpha=0.5, size=0.3 , se=TRUE, color = 'black')
)
# plot smoothing over subjects
scatterplotClinData(
data = data,
xVar = "time", yVar = "response",
aesPointVar = list(color = "treat"),
aesLineVar = list(group = 'USUBJID'),
linePars = list(linetype='dotted'),
aesSmoothVar = list(),
smoothPars = list(alpha=0.5, size=0.3 , se=TRUE, color = 'black')
)
# add a selection box
if(interactive()){
dataPlot <- subset(dataLB, PARAMCD == "ALT")
dataPlot$TRTA <- with(dataPlot, reorder(TRTA, TRTAN))
scatterplotClinData(
data = dataPlot,
xVar = "ADY",
yVar = "LBSTRESN",
aesPointVar = list(fill = "TRTA", color = "TRTA"),
aesLineVar = list(group = "USUBJID", color = "TRTA"),
selectVars = "TRTA",
labelVars = labelVars
)
}
Set facetting layout for 'wrap' facetting.
Description
By default, the number of columns is 2.
Usage
setFacetLayoutWrap(data, facetPars = list())
Arguments
data |
Data.frame with data. |
facetPars |
List with facetting parameters,
passed to the facetting function. Variables should be specified
as character or formula.
For 'wrap' facetting ( |
Value
Updated facetPars
.
Author(s)
Laure Cougnaud
Get standard palette for the staticScatterplotClinData
function.
Description
Get standard palette for the staticScatterplotClinData
function.
Usage
setPaletteStaticScatterplotClinData(data, var, aes, scalePars, geomAes, ...)
Arguments
data |
Data.frame with data for the plot. |
var |
Character vector with variable(s) to consider. If multiple, currently only the first one is considered. |
aes |
String with aesthetic, either: 'color', 'shape' or 'linetype'. |
scalePars |
List with parameters to customize
scales. Each sublist should contains a set of parameters
passed to the |
geomAes |
List with aesthetic for each geom. |
... |
Any extra parameters than |
Value
List with: scalePars
and geomAes
,
each of those potentially updated with default palette(s).
Author(s)
Laure Cougnaud
Split a chapter based on the 'split_by' parameter.
Description
Split a chapter based on the 'split_by' parameter.
Usage
splitChapter(
configFile = NULL,
configDir = "./config",
mdFile = NULL,
indexPath = "index.Rmd",
intermediateDir = "./interim",
outputDir = "./report",
verbose = TRUE
)
Arguments
configFile |
String with filename of the config file of interest in YAML format. |
configDir |
String with directory with config files,
by default a 'config' folder in |
mdFile |
(optional) Path to the Markdown file containing the chapter.
If not specified, the Markdown file corresponding to the specified
|
indexPath |
String with path to the index file,
by default 'index.Rmd' in |
intermediateDir |
String with intermediate directory ('interim'
by default), where
markdown files and rds file specifying Js libraries (with |
outputDir |
String with output directory, ('report' by default). |
verbose |
Logical, if TRUE (FALSE by default) progress messages are printed during the report execution. |
Value
No return value, the Markdown files are split as specified.
Extension to chapter-specific split
The bookdown 'split_by' parameter is extended, to support:
chapter-specific split, specified in the configuration file of the specific chapter, via the
split_by
parameterspecification as a number (if specified within a config file), e.g. '0' for no split, 1' for chapter, '2' for section, '3' for subsection, ...
split at section level higher than 2 (until 7) (if specified within a config file)
Author(s)
Laure Cougnaud
Scatterplot of variables of interest for clinical data visualization
Description
Scatterplot of variables of interest for clinical data visualization
Usage
staticScatterplotClinData(
data,
xVar,
yVar,
xLab = getLabelVar(xVar, labelVars = labelVars),
yLab = getLabelVar(yVar, labelVars = labelVars),
aesPointVar = list(),
pointPars = list(),
aesLineVar = list(),
linePars = list(),
lineInclude = length(c(aesLineVar, linePars)) > 0,
aesSmoothVar = list(),
smoothPars = list(),
smoothInclude = length(c(aesSmoothVar, smoothPars)) > 0,
aesLab,
xTrans = "identity",
yTrans = "identity",
xPars = list(),
yPars = list(),
xLabVars = NULL,
yLim = NULL,
xLim = NULL,
yLimExpandData = TRUE,
xLimExpandData = TRUE,
title = paste(c(paste(yLab, "vs", xLab), titleExtra), collapse = "<br>"),
titleExtra = NULL,
facetPars = list(),
facetType = c("wrap", "grid"),
scalePars = list(),
themePars = list(legend.position = "bottom"),
refLinePars = NULL,
labelVars = NULL,
hoverVars = NULL,
geomType = c("point", "col")
)
Arguments
data |
Data.frame with input data. |
xVar |
String with column of |
yVar |
String with column of |
xLab |
String with label for |
yLab |
String with label for |
aesPointVar |
List with specification of aesthetic variable(s),
for the point, passed to the |
pointPars |
List with parameters other than aesthetic variables to pass to |
aesLineVar |
List with specification of aesthetic variable(s),
for the line, passed to the |
linePars |
List with parameters other than aesthetic variables to pass to |
lineInclude |
Logical, if TRUE (by default if |
aesSmoothVar |
List with specification of aesthetic variable(s),
for the smoothing layer, passed to the |
smoothPars |
List with parameters other than aesthetic variables to pass to |
smoothInclude |
Logical, if TRUE (by default if one of |
aesLab |
Named character vector with labels for each aesthetic variable. |
xTrans , yTrans |
Transformation for the x/y- variables,
passed to the |
xPars , yPars |
List with extra parameters for x/y axis, passed to the
|
xLabVars |
Character vector with variable(s) to be displayed
as the labels of the ticks in the x-axis. |
xLim , yLim |
Numeric vector of length 2 with limits for the x/y axes. |
xLimExpandData , yLimExpandData |
Logical (TRUE by default), should the
limits specified via |
title |
String with title for the plot. |
titleExtra |
String with extra title for the plot (appended after |
facetPars |
List with facetting parameters, passed to the facetting function. |
facetType |
String with facetting type, either:
|
scalePars |
List with parameters to customize
scales. Each sublist should contains a set of parameters
passed to the |
themePars |
List with general theme parameters
(see |
refLinePars |
(optional) Nested list, with parameters for each reference line(s). Each sublist (a.k.a reference line) contains:
|
labelVars |
Named character vector containing variable labels. |
hoverVars |
Character vector with variables to be displayed in the hover,
by default |
geomType |
String with type of the geom used, either:
|
Value
ggplot
object
Author(s)
Laure Cougnaud, Adriaan Blommaert
Sunburst interactive plot.
Description
Note: the table and plot are not (yet) linked.
Usage
sunburstClinData(...)
Arguments
... |
Arguments passed on to
|
Value
Either:
if a
table
is requested: aclinDataReview
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()
,
treemapClinData()
Examples
library(clinUtils)
data(dataADaMCDISCP01)
labelVars <- attr(dataADaMCDISCP01, "labelVars")
dataAE <- dataADaMCDISCP01$ADAE
dataDM <- dataADaMCDISCP01$ADSL
## example of basic sunburst:
# sunburst 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"
)
dataSunburst <- tableAE
dataSunburst$n <- as.numeric(dataSunburst$n)
# create plot
sunburstClinData(
data = dataSunburst,
vars = c("AESOC", "AEDECOD"),
valueVar = "n",
valueLab = "Number of patients with adverse events"
)
## example where sum(counts) of child = counts of parent
# counts of patients per arm/site
tableDM <- inTextSummaryTable::getSummaryStatisticsTable(
data = dataDM,
rowVar = c("ARM", "SITEID"),
labelVars = labelVars,
# plotly treemap requires records (rows) for each group
rowVarTotalInclude = "SITEID",
rowTotalInclude = TRUE,
outputType = "data.frame-base"
)
tableDM$statN <- as.numeric(tableDM$statN)
# create the plot
sunburstClinData(
data = tableDM,
vars = c("ARM", "SITEID"),
valueVar = "statN", valueLab = "Counts of patients",
valueType = "total",
caption = "The sectors are colored by category.",
subtitle = "Group: treatment and site"
)
}
Create a 'clinical data table', associated to a plot.
Description
Interactive table is created, with the possibility to have clickeable link to patient-specific report, and included within a button.
Usage
tableClinData(
data,
idVar = "USUBJID",
idLab = getLabelVar(idVar, labelVars = labelVars),
keyVar = NULL,
keyLab = getLabelVar(keyVar, labelVars = labelVars),
pathVar = NULL,
pathLab = getLabelVar(pathVar, labelVars = labelVars),
pathExpand = FALSE,
tableVars = colnames(data),
tableLab = getLabelVar(tableVars, labelVars = labelVars),
tableButton = TRUE,
tablePars = list(),
id = paste0("plotClinData", sample.int(n = 1000, size = 1)),
labelVars = NULL,
verbose = FALSE
)
Arguments
data |
Data.frame with data. |
idVar |
String with variable containing subject ID. |
idLab |
String with label for |
keyVar |
String with unique key variable, identifying unique group for which the link between the table and the plot should be done. |
keyLab |
String with label for |
pathVar |
String with variable of <a href="./path-to-report">label</a> .
|
pathLab |
String with label for |
pathExpand |
Logical, should the variable in |
tableVars |
Character vector with variables to be included in the table. |
tableLab |
Named character vector with labels
for each |
tableButton |
Logical, if TRUE (by default) the table is included within an HTML button. |
tablePars |
List with parameters passed to the
|
id |
String with general id for the plot:
If not specified, a random id, as 'plotClinData[X]' is used. |
labelVars |
Named character vector containing variable labels. |
verbose |
Logical, if TRUE (FALSE by default) progress messages are printed in the current console. |
Value
Author(s)
Laure Cougnaud
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(),
watermark = NULL,
verbose = FALSE
)
Arguments
data |
Data.frame with data. |
paramVar |
Character vector with variable of |
paramLab |
(optional) String with label for |
paramVarSep |
(optional) String with separator used to combined |
paramGroupVar |
(optional) Character vector with variable(s) to group/order
the |
timeStartVar |
String with variable with the start of the time interval. |
timeStartLab |
(optional) String with label for |
timeEndVar |
String with variable with the end of the time interval. |
timeEndLab |
(optional) String with label for |
timeStartShapeVar |
(optional) String with variable used for the shape of the start of the time interval. |
timeStartShapeLab |
(optional) String with label for |
timeEndShapeVar |
(optional) String with variable used for the shape of the end of the time interval. |
timeEndShapeLab |
(optional) String with label for |
shapePalette |
(optional) Character vector with shape palette for
|
colorVar |
(optional) String with color variable. |
colorLab |
String with label for |
colorPalette |
(optional) Named character vector with color palette.
If not specified, the viridis color palette is used. |
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. |
caption |
String with caption. |
labelVars |
Named character vector containing variable labels. |
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 |
idVar |
String with variable containing subject ID. |
idLab |
String with label for |
pathVar |
String with variable of <a href="./path-to-report">label</a> .
|
pathLab |
String with label for |
id |
String with general id for the plot:
If not specified, a random id, as 'plotClinData[X]' is used. |
selectVars |
(optional) Character vector with variable(s) from |
selectLab |
(Named) character vector with label for |
table |
Logical, if TRUE (FALSE by default)
returns also a |
tableVars |
Character vector with variables to be included in the table. |
tableLab |
Named character vector with labels
for each |
tableButton |
Logical, if TRUE (by default) the table is included within an HTML button. |
tablePars |
List with parameters passed to the
|
watermark |
(optional) String with path to a file containing a watermark. |
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: aclinDataReview
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"
)
}
Transform data.
Description
Transform data from long to wide format.
This function converts formats with the stats::reshape
function.
Usage
transformData(data, transformations, verbose = FALSE, labelVars = NULL)
Arguments
data |
Data.frame with input data to transform. |
transformations |
Transformations (or list of those) as a list with:
|
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. |
labelVars |
Named character vector containing variable labels. |
Value
A data.frame in wide format.
Author(s)
Laure Cougnaud
Treemap interactive plot.
Description
Note: the table and plot are not (yet) linked.
Usage
treemapClinData(...)
Arguments
... |
Arguments passed on to
|
Value
Either:
if a
table
is requested: aclinDataReview
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"
)
}
Get formula for a specific variable,
to be used in aesthetic specification in plot_ly
.
Description
Get formula for a specific variable,
to be used in aesthetic specification in plot_ly
.
Usage
varToFm(var)
Arguments
var |
Character vector with variable to combine. Otherwise with the '+' operator. |
Value
Author(s)
Laure Cougnaud
Zip the clinical data report
Description
Create a zip folder of clinical data reports with a redirect page.
The clinical data report out of the
render_clinDataReviewReport
is copied into a new folder.
A redirect html page is created to enable the user to navigate the report
without needing to look into the new directory.
Usage
zipClinDataReview(
reportDir = "report",
newDir = "report_dependencies",
redirectPage = "report.html",
zipFolder = "report.zip"
)
Arguments
reportDir |
String for the path to the directory where the clinical data reports are stored |
newDir |
String for the path where the files from
|
redirectPage |
String with the path of the html file that redirects to the "1-introduction.html" page of the report. |
zipFolder |
String with the path to the zipped folder. |
Value
The zip folder is created in the specified location.