Title: | Clinical Data Review Tool |
---|---|
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. |
Authors: | 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 <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.6.1 |
Built: | 2024-10-31 18:38:45 UTC |
Source: | https://github.com/openanalytics/clindatareview |
Add the today's date of when the report runs to the info of the metadata.
addDateOfReportRun(summaryInfo)
addDateOfReportRun(summaryInfo)
summaryInfo |
matrix, see output from |
A matrix, same as input summaryInfo
with an extra row with the date
of today.
Add facet-panel to single plotly plot.
addFacetPanel( pl, panelLab, panelWidth = 20, fontSize = 15, side = c("top", "right") )
addFacetPanel( pl, panelLab, panelWidth = 20, fontSize = 15, side = c("top", "right") )
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.) |
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)
plotly object with the facet panel added.
lennart tuijnder
Helper function to add layer to scatter plot
addLayerToScatterPlot( gg, aesVar, pars, generalPars, layerFunction, useHandlers = FALSE )
addLayerToScatterPlot( gg, aesVar, pars, generalPars, layerFunction, useHandlers = FALSE )
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 |
ggplot
object
Adriaan Blommaert Laure Cougnaud
Add reference (horizontal/vertical/diagonal) lines to a clinical data plot
addReferenceLinesClinDataPlot( gg, data, xVar, yVar, xLim = NULL, yLim = NULL, refLinePars = NULL, facetPars = NULL )
addReferenceLinesClinDataPlot( gg, data, xVar, yVar, xLim = NULL, yLim = NULL, refLinePars = NULL, facetPars = NULL )
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 ( |
Updated ggplot
object.
Laure Cougnaud
Add selection box(es) to a plotly plot.
addSelectBtn( data, pl, selectVars = NULL, selectLab = NULL, labelVars = NULL, id = paste0("plotClinData", sample.int(n = 1000, size = 1)), keyVar )
addSelectBtn( data, pl, selectVars = NULL, selectLab = NULL, labelVars = NULL, id = paste0("plotClinData", sample.int(n = 1000, size = 1)), keyVar )
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. |
if selectVars
is specified: a browsable
object combining the select buttons and the plotly
object.
Otherwise, the input plotly
object.
plotly
object.Add a watermark to a plotly
object.
addWatermark(pl, watermark = NULL)
addWatermark(pl, watermark = NULL)
pl |
|
watermark |
(optional) String with path to a file containing a watermark. |
plotly
object with a watermark (if specified)
Other watermark helpers:
getWatermark()
watermark <- tempfile(pattern = "watermark", fileext = ".png") getWatermark(file = watermark) addWatermark(pl = plotly::plot_ly(), watermark = watermark)
watermark <- tempfile(pattern = "watermark", fileext = ".png") getWatermark(file = watermark) addWatermark(pl = plotly::plot_ly(), watermark = watermark)
Standard annotation variables are available via the
parameter annotType
. Custom dataset/variables of interest
are specified via the annotDataset
/annotVar
parameters.
annotateData( data, dataPath = ".", annotations, subjectVar = "USUBJID", verbose = FALSE, labelVars = NULL, labelData = "data" )
annotateData( data, dataPath = ".", annotations, subjectVar = "USUBJID", verbose = FALSE, labelVars = NULL, labelData = "data" )
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 |
Annotated data
.
If labelVars
is specified, the output contains an
extra attribute: 'labelVars'
containing updated labelVars
(accessible via: in attr(output, 'labelVars')
).
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' ## Not run: annotateData(dataLB, annotations = "demographics", pathData = ...) ## End(Not run) # 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)
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' ## Not run: annotateData(dataLB, annotations = "demographics", pathData = ...) ## End(Not run) # 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.
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 )
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 )
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. |
Either:
if a table
is requested: a clinDataReview
object,
a.k.a a list with the 'plot' (plotly
object) and 'table'
(datatable
object)
otherwise: a plotly
object
Laure Cougnaud
Other visualizations of summary statistics for clinical data:
boxplotClinData()
,
errorbarClinData()
,
plotCountClinData()
,
sunburstClinData()
,
treemapClinData()
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" ) } ## Not run: # 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" ) ## End(Not run) }
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" ) } ## Not run: # 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" ) ## End(Not run) }
Boxplot interactive plot.
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 )
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 )
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. |
Either:
if a table
is requested: a clinDataReview
object,
a.k.a a list with the 'plot' (plotly
object) and 'table'
(datatable
object)
otherwise: a plotly
object
Lennart Tuijnder
Other visualizations of summary statistics for clinical data:
barplotClinData()
,
errorbarClinData()
,
plotCountClinData()
,
sunburstClinData()
,
treemapClinData()
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 ) ## Not run: # 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 ) ## End(Not run)
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 ) ## Not run: # 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 ) ## End(Not run)
Build the book
buildBook(htmlFiles, verbose = TRUE)
buildBook(htmlFiles, verbose = TRUE)
htmlFiles |
character vector with path to HTML files |
verbose |
Logical, if TRUE (FALSE by default) progress messages are printed during the report execution. |
String with path to the front page of the report.
Laure Cougnaud
Check availability of arguments in list
checkAvailabilityMetadata(paramsList, subListName)
checkAvailabilityMetadata(paramsList, subListName)
paramsList |
A named list. |
subListName |
String indicating which of the sublist names to check for existance. |
The content of the sublist. If not available, returns "Not Available".
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.
checkChapterParallel( configFile, configDir = file.path(inputDir, "config"), inputDir = "." )
checkChapterParallel( configFile, configDir = file.path(inputDir, "config"), inputDir = "." )
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. |
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.
checkConfigFile(configFile, configSpecFile, configDir = "./config")
checkConfigFile(configFile, configSpecFile, configDir = "./config")
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 |
No returned value, an error message is printed in the console if the configuration file doesn't comply to the specified specifications.
Laure Cougnaud
Check uniqueness of report titles across the config files. If not unique titles are provided, an error is returned.
checkReportTitles( configFiles, configDir = file.path(inputDir, "config"), inputDir = "." )
checkReportTitles( configFiles, configDir = file.path(inputDir, "config"), inputDir = "." )
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. |
A named vector with the report titles and the corresponding config file
Michela Pasetto
Other clinical data reporting:
forceParams()
,
getMdHeader()
,
getParamsFromConfig()
,
gitbook_clinDataReview_report()
,
html_clinDataReview_report()
,
knitPrintClinDataReview()
,
postProcessReport()
,
render_clinDataReviewReport()
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.
checkTemplatesName( configFiles, configDir = file.path(inputDir, "config"), inputDir = "." )
checkTemplatesName( configFiles, configDir = file.path(inputDir, "config"), inputDir = "." )
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. |
Updated configFiles
Laure Cougnaud
valueType
parameter can be passed to the
branchvalues
of the plot_ly
treemap/sunburst visualizations.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'.
checkValueType(data, vars, valueVar, valueType = "total", labelVars = NULL)
checkValueType(data, vars, valueVar, valueType = "total", labelVars = NULL)
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. |
If the condition is fullfilled:
updated valueType
and warning;
otherwise input valueType
.
Laure Cougnaud
Common arguments for the functions of the clinDataReview package
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. |
No return value, used for the documentation of the functions of the package.
Common parameters for the clinical data reporting function
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. |
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
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 |
No return value, used for the documentation of the plotting functions of summary statistics of the package.
Template reports with standard visualizations/tables available in the package are described here.
For each template, required parameters are indicated in bold.
No return value, used for the documentation of the Rmarkdown template reports contained in the package.
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
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 report
templatePackage
: string set to: 'clinDataReview', package from which the template should be extracted
reportTitle
: string, header title
reportTitleLevel
: (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 processData
dataTotalFileName
: (optional) string, filename of the total dataset
dataTotalProcessing
: (optional) array, data processing parameters for 'dataTotalFileName', passed to processData
countVar
: string, variable of data to count on
parentVar
: (optional) string or array, parent variable(s) of the counting variable, used for grouping
colorVar
: (optional) string or object, numeric variable(s) to consider for coloring, named by count/parent variable if different for each variable
colorRange
: (optional) array of number(s) of length: minimum 2, maximum 2, range of the color variable for the visualization
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 of loopingVar
to include in the report
loopingTotal
: (optional) boolean, should the total also be computed by loopingVar
(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
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 report
templatePackage
: string set to: 'clinDataReview', package from which the template should be extracted
reportTitle
: string, header title
reportTitleLevel
: (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
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 report
templatePackage
: string set to: 'clinDataReview', package from which the template should be extracted
reportTitle
: string, header title
reportTitleLevel
: (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 processData
dataTotalFileName
: (optional) string, filename of the total dataset
dataTotalProcessing
: (optional) array, data processing parameters for 'dataTotalFileName', passed to processData
tableParams
: (optional) object, parameters to create the table, passed to tableClinData
comparisonTableType
: (optional) string among: 'none', 'newData-diff-interactive', 'table-comparison-interactive' , output type of the comparison table
comparisonTableParams
: (optional) object, parameters for the comparison table, passed to compareTables
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 of loopingVar
to include in the report
listingDocx
: (optional) boolean, export listing to Word
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 report
templatePackage
: string set to: 'clinDataReview', package from which the template should be extracted
reportTitle
: string, header title
reportTitleLevel
: (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 all subjectProfile[]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 interest
dataProcessing
: (optional) array, data processing parameters, passed to processData
plotParams
: 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 createSubjectProfileReport
tableParams
: (optional) object, parameters specifying a table containing data of interest and links to created patient profiles
startup
: (optional) array or string, R commands that should be run at the start of the report
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 report
templatePackage
: string set to: 'clinDataReview', package from which the template should be extracted
reportTitle
: string, header title
reportTitleLevel
: (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 processData
plotFunction
: string among: 'timeProfileIntervalPlot', 'scatterplotClinData', 'boxplotClinData' , plotting function of the package to consider
plotParams
: 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 processData
comparisonTableType
: (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 of loopingVar
to include in the report
startup
: (optional) array or string, R commands that should be run at the start of the report
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 report
templatePackage
: string set to: 'clinDataReview', package from which the template should be extracted
reportTitle
: string, header title
reportTitleLevel
: (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 processData
dataTotalFileName
: (optional) string, filename of the total dataset
dataTotalProcessing
: (optional) array, data processing parameters for 'dataTotalFileName', passed to processData
tableParams
: object, parameters to summarize the data in a table, passed to computeSummaryStatisticsTable
tableProcessing
: (optional) array, data processing parameters for the summary table, passed to processData
plotFunction
: string among: 'timeProfileIntervalPlot', 'scatterplotClinData', 'sunburstClinData', 'treemapClinData', 'barplotClinData', 'errorbarClinData' , plotting function to visualize summary data
plotParams
: 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 of loopingVar
to include in the report
loopingTotal
: (optional) boolean, should the total also be computed by loopingVar
(TRUE by default)?
startup
: (optional) array or string, R commands that should be run at the start of the report
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 report
templatePackage
: string set to: 'clinDataReview', package from which the template should be extracted
reportTitle
: string, header title
reportTitleLevel
: (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 processData
dataTotalFileName
: (optional) string, filename of the total dataset
dataTotalProcessing
: (optional) array, data processing parameters for 'dataTotalFileName', passed to processData
tableParams
: 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 exportSummaryStatisticsTable
tableParamsDT
: (optional) object, parameters to format the table to the DT interactive table included in the report, passed to exportSummaryStatisticsTable
comparisonTableType
: (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 of loopingVar
to include in the report
loopingTotal
: (optional) boolean, should the total also be computed by loopingVar
(TRUE by default)?
Please note that the button is of class: 'hideshow', defined in the 'input.hideshow.js' js file included in the package.
collapseHtmlContent(input, title = "Click to show or hide")
collapseHtmlContent(input, title = "Click to show or hide")
input |
Object to be collapse, e.g. datatable. |
title |
String with button title. |
tag
object
Laure Cougnaud
Combine select box(es) and the plot
combineButtonsAndPlot(x)
combineButtonsAndPlot(x)
x |
Object of class |
x
object:
with the plot
element containing a combination of the
buttons
and the plot
without the buttons
element
Convert the Md file for a specific chapter to html
convertMdToHtml( mdFile, configFile = NULL, indexPath = "index.Rmd", intermediateDir = "./interim", outputDir = "./report", setTitle = TRUE, verbose = TRUE, ... )
convertMdToHtml( mdFile, configFile = NULL, indexPath = "index.Rmd", intermediateDir = "./interim", outputDir = "./report", setTitle = TRUE, verbose = TRUE, ... )
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 |
No returned value, the files in the intermediateDir
are converted to HTML
Laure Cougnaud
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.
convertReportToAspx(reportDir = ".")
convertReportToAspx(reportDir = ".")
reportDir |
String for the path to the directory where the clinical data reports are stored, defaults to current directory |
no return value, files in directory are modified
Count number of lines in a vector
countNLines(x)
countNLines(x)
x |
Character vector. |
Integer vector of length x
with number
of lines
Laure Cougnaud
clinDataReview:::countNLines(x = c("A\nB", "blabla", "This\nis\na\nsentence."))
clinDataReview:::countNLines(x = c("A\nB", "blabla", "This\nis\na\nsentence."))
Creates the skeleton of a report to start running the analyses.
createClinDataReviewReportSkeleton(dir = ".")
createClinDataReviewReportSkeleton(dir = ".")
dir |
String with the path of the directory where the skeleton should be created. The current working directory is used as default. |
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.
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 of metadata file for the createClinDataReviewReportSkeleton
.
createExampleMetadata(dir)
createExampleMetadata(dir)
dir |
String, path to the directory. |
Nothing, the example metadata file is created in the specified directory.
This function creates the main config file for the createClinDataReviewReportSkeleton
with the directory where the data are stored.
createMainConfigSkeleton(dir, dirData)
createMainConfigSkeleton(dir, dirData)
dir |
String, path to the directory. |
dirData |
String, path to the directory of the data. |
No return value, a file _config.yml_ is created in the specified directory.
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.
createOutputYaml(indexPath, outputDir)
createOutputYaml(indexPath, outputDir)
indexPath |
String with path to the index file,
by default 'index.Rmd' in |
outputDir |
String with output directory, ('report' by default). |
String with file to the _output.yml
file
in a temporary folder.
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
).
createPatientProfileVar( data, patientProfilePath, subjectVar = "USUBJID", checkExist = TRUE )
createPatientProfileVar( data, patientProfilePath, subjectVar = "USUBJID", checkExist = TRUE )
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 |
A data.frame with two extra columns:
patientProfilePath
and patientProfileLink
with
the path to the patient profile and an hyperlink to it, respectively.
Michela Pasetto
# 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")])
# 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 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
.
createRedirectPage(redirectPage = "report.html", dir = "report_dependencies")
createRedirectPage(redirectPage = "report.html", dir = "report_dependencies")
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. |
The html file is created.
If a JSON schema file available, the information relative
to the template is extracted from this file with the function
JSONSchToRd
.
createTemplateDoc( templatePath = system.file("template", package = "clinDataReview") )
createTemplateDoc( templatePath = system.file("template", package = "clinDataReview") )
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. |
Character vector with Rd code containing description for all template documents.
Laure Cougnaud
This plot is designed to display summary statistics
of a continuous variable with (confidence) intervals.
The intervals are either displayed:
vertically if yErrorVar
is specified
horizontally 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.
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 )
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 )
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. |
Either:
if a table
is requested: a clinDataReview
object,
a.k.a a list with the 'plot' (plotly
object) and 'table'
(datatable
object)
otherwise: a plotly
object
Laure Cougnaud
Other visualizations of summary statistics for clinical data:
barplotClinData()
,
boxplotClinData()
,
plotCountClinData()
,
sunburstClinData()
,
treemapClinData()
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" ) }
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
exportSessionInfoToMd( sessionInfos, intermediateDir = "interim", logFile = NULL, ... )
exportSessionInfoToMd( sessionInfos, intermediateDir = "interim", logFile = NULL, ... )
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 |
String with path to Markdown file containing the session information, NULL if no session information(s) are provided.
Laure Cougnaud
A dataset can be filtered:
on a specific value
of interest
on a function of a variable (valueFct
parameter),
e.g. maximum of the variable)
to retain only non missing values of a variable (keepNA
set to FALSE
)
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
.
filterData( data, filters, keepNA = TRUE, returnAll = FALSE, verbose = FALSE, labelVars = NULL, labelData = "data" )
filterData( data, filters, keepNA = TRUE, returnAll = FALSE, verbose = FALSE, labelVars = NULL, labelData = "data" )
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 |
If returnAll
is FALSE
: data
filtered with the specified filters
is TRUE
: data
with the additional column: keep
or varNew
(if specified), containing TRUE
for records
which fulfill the specified condition(s) and FALSE
otherwise.
The output contains the additional attribute: msg
which contains a message
describing the filtered records.
Laure Cougnaud
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 )
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
filterDataSingle( data, filters, keepNA = TRUE, returnAll = FALSE, labelVars = NULL, labelData = "data" )
filterDataSingle( data, filters, keepNA = TRUE, returnAll = FALSE, labelVars = NULL, labelData = "data" )
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 |
Updated data
with attributes:
'labelVars': input labelVars
with any new variables
if labelNew
is specified.
'msg': message describing the filtering process
'warn': warning describing the filtering process
Laure Cougnaud
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.
forceParams(params)
forceParams(params)
params |
List of parameters as obtained
via the |
Input parameter list, with
object(s) of class r-lazy
evaluated.
Laure Cougnaud
Other clinical data reporting:
checkReportTitles()
,
getMdHeader()
,
getParamsFromConfig()
,
gitbook_clinDataReview_report()
,
html_clinDataReview_report()
,
knitPrintClinDataReview()
,
postProcessReport()
,
render_clinDataReviewReport()
data <- mtcars params <- list(label = "Cars dataset", nrow = structure("nrow(data)", class = "r-lazy")) str(params) str(forceParams(params))
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
formatDataForPlotClinData( data, hoverVars = NULL, hoverLab = getLabelVar(hoverVars, labelVars = labelVars), hoverByVar = NULL, keyVar = NULL, id = paste0("plotClinData", sample.int(n = 1000, size = 1)), labelVars = NULL )
formatDataForPlotClinData( data, hoverVars = NULL, hoverLab = getLabelVar(hoverVars, labelVars = labelVars), hoverByVar = NULL, keyVar = NULL, id = paste0("plotClinData", sample.int(n = 1000, size = 1)), labelVars = NULL )
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. |
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
.
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.
formatHoverText(x, label, width = 50)
formatHoverText(x, label, width = 50)
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. |
String with formatted hover label.
Laure Cougnaud
Format the info on paths from metadata
formatPathDateInfoMetadata(summaryInfo, namesInfo)
formatPathDateInfoMetadata(summaryInfo, namesInfo)
summaryInfo |
matrix, see output from |
namesInfo |
Named vector to rename the final output. |
A kable object, to be printed.
Format interactive plot, with possibility to download patient profiles on a click event.
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 )
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 )
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'). |
Updated plotly
object.
Laure Cougnaud
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.
formatToHierarchicalData(data, vars, valueVar)
formatToHierarchicalData(data, vars, valueVar)
data |
Data.frame with data. |
vars |
Character vector with variables of |
valueVar |
String with numeric variable of |
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 specified vars
,
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.
Laure Cougnaud
Get axis label
getAxisLab(axisVar, axisLab, labVar = NULL, data, labelVars)
getAxisLab(axisVar, axisLab, labVar = NULL, data, labelVars)
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. |
String with label for the axis.
Set different variables for the x-axis labels
getAxisLabs(data, var, labVars)
getAxisLabs(data, var, labVars)
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. |
Named character vector. The names are the position in the x-axis, the values are the new labels.
Laure Cougnaud
ggplot
plot
from the input dataset.Get axis limits for a ggplot
plot
from the input dataset.
getAxisLimPlot( data, xVar, yVar, xLim = NULL, yLim = NULL, facetPars = NULL, refLineData = NULL )
getAxisLimPlot( data, xVar, yVar, xLim = NULL, yLim = NULL, facetPars = NULL, refLineData = NULL )
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 |
Data.frame with limits of the:
x-axis: 'xmin'/'xmax'
y-axis: 'ymin'/'ymax'
for each element of the facetting variable (if any).
This function especially extracts the data if an aesthetic variable is specified in the reference line parameters.
getDataReferenceLines(refLinePars, data, facetPars = NULL)
getDataReferenceLines(refLinePars, data, facetPars = NULL)
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 ( |
List of data for the lines
Laure Cougnaud
Get plot dimensions
getDimGgplot(gg)
getDimGgplot(gg)
gg |
Numeric vector with number of rows ('nrow') and columns ('ncol') of the plot
Laure Cougnaud
By default, the 'figures', 'tables' and patient profiles folders
(patientProfilePath
parameter in the general
config file, if specified) in the input directory are considered.
getExtraDirs(inputDir = ".", configDir = file.path(inputDir, "config"))
getExtraDirs(inputDir = ".", configDir = file.path(inputDir, "config"))
inputDir |
String with input directory, working directory by default. |
configDir |
String with directory with config files,
by default a 'config' folder in |
Character vector with extra directories required by the report
Laure Cougnaud
Get facetting variables from facet parameters.
getFacetVars(facetPars = list())
getFacetVars(facetPars = list())
facetPars |
List with facetting parameters,
passed to the facetting function. Variables should be specified
as character or formula.
For 'wrap' facetting ( |
Character vector with facetting variable
Laure Cougnaud
Get function code
getFctCode(fct)
getFctCode(fct)
fct |
a R function |
String with function code
ggplot
function
to use for the reference linesGet the names of the ggplot
function
to use for the reference lines
getFctTypeReferenceLines(refLinePars)
getFctTypeReferenceLines(refLinePars)
refLinePars |
(optional) Nested list, with parameters for each reference line(s). Each sublist (a.k.a reference line) contains:
|
List of type of each reference lines, among: 'vline', 'hline' and 'abline'.
Laure Cougnaud
Get height of labels: title, subtitle or caption
getHeightLab(lab)
getHeightLab(lab)
lab |
String with label. |
Integer with height in pixels for this element.
Laure Cougnaud
Get HTML toc
getHTMLToc(toc)
getHTMLToc(toc)
toc |
data.frame with TOC info |
Character vector with HTML toc
Get index of the line containing the HTML title in a vector of HTML strings
getIndexHTMLTitle(x)
getIndexHTMLTitle(x)
x |
Character vector with HTML |
Integer vector with index of the title in the vector x
Get interim res file
getInterimResFile(intermediateDir = "./interim", mdFile)
getInterimResFile(intermediateDir = "./interim", mdFile)
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 |
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
getJitterVar(data, var, byVar)
getJitterVar(data, var, byVar)
data |
Data.frame with data. |
var |
String with variable to add a jitter to. |
byVar |
String with variable containing the groups to jitter by. |
Numeric vector of length nrow(data)
containing the jittered variable.
Laure Cougnaud
Get Javascript custom scripts required for specific clinical data functionalities.
getJsDepClinDataReview( type = c("collapsibleButton", "patientProfiles"), dep = NULL )
getJsDepClinDataReview( type = c("collapsibleButton", "patientProfiles"), dep = NULL )
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. |
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))
Laure Cougnaud
HTML
file corresponding
to a specific config file.The name of the Markdown
file is based on:
for the general config.yml
file:
the basename of the specified indexPath
for other config file (each sub-report):
the name of the config file, after removal of the
'config-
' part.
getMdFromConfig( configFiles, indexPath = "index.Rmd", intermediateDir = "./interim" )
getMdFromConfig( configFiles, indexPath = "index.Rmd", intermediateDir = "./interim" )
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 |
String with path to the HTML file
Laure Cougnaud
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
getMdHeader(title, level = 1)
getMdHeader(title, level = 1)
title |
String with header title. |
level |
Integer of length 1 with header depth/level, 1 by default |
String with Markdown header,
to be included in R within cat
.
Other clinical data reporting:
checkReportTitles()
,
forceParams()
,
getParamsFromConfig()
,
gitbook_clinDataReview_report()
,
html_clinDataReview_report()
,
knitPrintClinDataReview()
,
postProcessReport()
,
render_clinDataReviewReport()
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.
See knit_print.clinDataReviewMetadata
.
datasetInfo
: General information about the data sets.
getMetadata(filePath, namesInfo)
getMetadata(filePath, namesInfo)
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. |
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".
A list of:
summaryInfo
Information extracted from the inputs
path
, and dateTime
.
datasetInfo
Information extracted from datasetInfo
.
# 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)
# 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)
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.
getParamsFromConfig( configFile, configDir = file.path(inputDir, "config"), inputDir = "." )
getParamsFromConfig( configFile, configDir = file.path(inputDir, "config"), inputDir = "." )
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. |
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.
Laure Cougnaud
Other clinical data reporting:
checkReportTitles()
,
forceParams()
,
getMdHeader()
,
gitbook_clinDataReview_report()
,
html_clinDataReview_report()
,
knitPrintClinDataReview()
,
postProcessReport()
,
render_clinDataReviewReport()
Get parameter of function used for reference lines
getParFctReferenceLines(type)
getParFctReferenceLines(type)
type |
string with line type, either: 'hline', 'abline' or 'vline'. |
Character vector with parameter names of the functions
Laure Cougnaud
Get path ('href') property from hyperlink(s).
getPathHyperlink(x)
getPathHyperlink(x)
x |
Character vector with hyperlink(s). If multiple, the hyperlinks should be separated by: ', '. |
Character vector of length x
containing only the hyperlinks.
Laure Cougnaud
Get path of template clinical data report
getPathTemplate(file, package = "clinDataReview")
getPathTemplate(file, package = "clinDataReview")
file |
String with name of the template Rmd document |
package |
String, which package the template should be extracted from,
by default the |
String with path to the template in the installed clinDataReview
package
Laure Cougnaud
## Not run: pathDivisionTemplate <- getPathTemplate("divisionTemplate.Rmd") # get path template in the package file.copy(from = pathDivisionTemplate, to = ".") # copy to current directlory rmarkdown::render(pathDivisionTemplate) # run file ## End(Not run)
## Not run: pathDivisionTemplate <- getPathTemplate("divisionTemplate.Rmd") # get path template in the package file.copy(from = pathDivisionTemplate, to = ".") # copy to current directlory rmarkdown::render(pathDivisionTemplate) # run file ## End(Not run)
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 the scatterplotClinData
plotting function.
Label for these variable(s) are extracted from the associated parameter
(e.g. xLab
for xVar
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.
getPlotTableVars(plotFunction, plotArgs)
getPlotTableVars(plotFunction, plotArgs)
plotFunction |
String with name of the plotting function,
be available in the |
plotArgs |
List with parameters passed to the plotting function. |
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 .
Laure Cougnaud
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).
getPositionAndMargins( title = NULL, subtitle = NULL, xLab = NULL, caption = NULL, facet = FALSE, includeLegend = TRUE, legendPosition = "right" )
getPositionAndMargins( title = NULL, subtitle = NULL, xLab = NULL, caption = NULL, facet = FALSE, includeLegend = TRUE, legendPosition = "right" )
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. |
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.
Laure Cougnaud
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
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 )
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 )
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. |
Numeric vector with width ('width') and height ('height') of the plot in pixels.
Laure Cougnaud
Get TOC numbering
getTocNumbering(levels)
getTocNumbering(levels)
levels |
vector with levels of the section, in the order as available in the book. |
Character vector with section numbers
Laure Cougnaud
Get a watermark, to be included in a clinical visualization
getWatermark( label = "EXPLORATORY", color = "lightgrey", fontsize = 20, file = NULL, width = 800, height = 500 )
getWatermark( label = "EXPLORATORY", color = "lightgrey", fontsize = 20, file = NULL, width = 800, height = 500 )
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. |
The file
with the watermark (invisibly).
Laure Cougnaud, Kirsten van Hoorde
Other watermark helpers:
addWatermark()
# export a watermark to a file watermark <- tempfile(pattern = "watermark", fileext = ".png") getWatermark(file = watermark)
# export a watermark to a file watermark <- tempfile(pattern = "watermark", fileext = ".png") getWatermark(file = watermark)
This function is only meant to set sensitive
defaults for gitbook.gitbook
can be used instead.
gitbook_clinDataReview_report( logo = NULL, logoHeight = "60px", split_by = "section+number", config = list(sharing = NULL, toc = list(collapse = "section")), extra_dependencies = NULL, css = NULL, ... )
gitbook_clinDataReview_report( logo = NULL, logoHeight = "60px", split_by = "section+number", config = list(sharing = NULL, toc = list(collapse = "section")), extra_dependencies = NULL, css = NULL, ... )
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. |
R Markdown output format to pass to render_book
.
Laure Cougnaud
Other clinical data reporting:
checkReportTitles()
,
forceParams()
,
getMdHeader()
,
getParamsFromConfig()
,
html_clinDataReview_report()
,
knitPrintClinDataReview()
,
postProcessReport()
,
render_clinDataReviewReport()
This function only kept for back-compatibility,
html_document
can be used instead.
html_clinDataReview_report(extra_dependencies = NULL, ...)
html_clinDataReview_report(extra_dependencies = NULL, ...)
extra_dependencies |
NULL by default. |
... |
Extra parameters passed to the html_document function. |
R Markdown output format to pass to render
.
Laure Cougnaud
Other clinical data reporting:
checkReportTitles()
,
forceParams()
,
getMdHeader()
,
getParamsFromConfig()
,
gitbook_clinDataReview_report()
,
knitPrintClinDataReview()
,
postProcessReport()
,
render_clinDataReviewReport()
Note: this function doesn't support the full JSON schema specification, currently only the functionalities required by the templates of the package are implemented.
JSONSchToRd(JSONSch, title = NULL)
JSONSchToRd(JSONSch, title = NULL)
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. |
Character vector with R documentation for the specified JSON schema.
'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).
Laure Cougnaud
clinDataReviewTable
object in a knitted document
(e.g. Rmarkdown document).Print clinDataReviewTable
object in a knitted document
(e.g. Rmarkdown document).
## S3 method for class 'clinDataReview' knit_print(x, ...)
## S3 method for class 'clinDataReview' knit_print(x, ...)
x |
Object of class |
... |
Extra parameters for compatibility with |
Laure Cougnaud
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
.
## S3 method for class 'clinDataReviewMetadata' knit_print(x, options = list(), ...)
## S3 method for class 'clinDataReviewMetadata' knit_print(x, options = list(), ...)
x |
List of two elements named |
options |
List of extra options to be passed as chunk options.
The option |
... |
Extra arguments to be passed. |
Nothing. The tables are ready to be printed in Rmd.
html code to include metadata in a report
Include output from clinical data, or list of such outputs in a Rmarkdown report, with an appropriate title.
knitPrintClinDataReview(list, sep = ".", level = 1)
knitPrintClinDataReview(list, sep = ".", level = 1)
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. |
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.
Laure Cougnaud
Other clinical data reporting:
checkReportTitles()
,
forceParams()
,
getMdHeader()
,
getParamsFromConfig()
,
gitbook_clinDataReview_report()
,
html_clinDataReview_report()
,
postProcessReport()
,
render_clinDataReviewReport()
Set layout for a clinical data plot.
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, ... )
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, ... )
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 |
The updated plotly
object
Laure Cougnaud
Merge multiple session information
## S3 method for class 'sessionInfo' merge(...)
## S3 method for class 'sessionInfo' merge(...)
... |
objects of type |
sessionInfo
with combined information
Laure Cougnaud
This function moves the files used to create the skeleton from the package to a specified directory.
moveSkeletonFiles(dir)
moveSkeletonFiles(dir)
dir |
String, path to the directory. |
Nothing, the files are available in the specified directory.
Move SDTM data sets available in clinUtils
into a
specified local directory.
moveXpt(dir)
moveXpt(dir)
dir |
String, path to the directory. |
Nothing, the data are saved in the dedicated location.
Note: the table and plot are not (yet) linked.
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 )
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 )
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. |
Either:
if a table
is requested: a clinDataReview
object,
a.k.a a list with the 'plot' (plotly
object) and 'table'
(datatable
object)
otherwise: a plotly
object
Laure Cougnaud
Other visualizations of summary statistics for clinical data:
barplotClinData()
,
boxplotClinData()
,
errorbarClinData()
,
sunburstClinData()
,
treemapClinData()
Convert clinical data Markdown files to HTML
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, ... )
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, ... )
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 |
String with path to the front page of the report.
Laure Cougnaud
Other clinical data reporting:
checkReportTitles()
,
forceParams()
,
getMdHeader()
,
getParamsFromConfig()
,
gitbook_clinDataReview_report()
,
html_clinDataReview_report()
,
knitPrintClinDataReview()
,
render_clinDataReviewReport()
clinDataReview
object in the consolePrint a clinDataReview
object in the console
## S3 method for class 'clinDataReview' print(x, ...)
## S3 method for class 'clinDataReview' print(x, ...)
x |
Object of class |
... |
Extra parameters for compatibility with |
No returned value, the object is printed into the console.
This function is intended to automate all data processing steps for use in the 'clinDataReview' reports using config files.
processData(data, processing, labelVars = NULL, ...)
processData(data, processing, labelVars = NULL, ...)
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 |
Data.frame with processed data
,
with extra attribute: labelVars
.
Laure Cougnaud
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
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 referring to the paths and the date.
renamePathDateInfoMetadata(summaryInfo, namesInfo)
renamePathDateInfoMetadata(summaryInfo, namesInfo)
summaryInfo |
A matrix, see output from |
namesInfo |
Named vector to rename the final output. |
A matrix, same as input summaryInfo
with renamed variable names.
Render a clinical data review report.
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 )
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 )
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:
|
String with path to the front page of the report.
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 with parallel
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 the
nCores
parameter is specified.
checking if the associated Markdown
and rds
file
(list of Js dependencies) are available in intermediateDir
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 the
nCores
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.
see ? `clinDataReview-templates`
for a list of
clinical data template report available in the package.
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
parameter
specification 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)
Laure Cougnaud
Other clinical data reporting:
checkReportTitles()
,
forceParams()
,
getMdHeader()
,
getParamsFromConfig()
,
gitbook_clinDataReview_report()
,
html_clinDataReview_report()
,
knitPrintClinDataReview()
,
postProcessReport()
Render one chapter of a clinical report, based on a configuration file
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, ... )
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, ... )
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 |
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.
This has the possibility to save output in a log file, and saving also session information.
renderFile(input, encoding = "UTF-8", params = NULL, logFile = NULL, ...)
renderFile(input, encoding = "UTF-8", params = NULL, logFile = NULL, ...)
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 |
Note: this function is inspired from xfun::Rscript_call
Output of the function with additional attribute: 'sessionInfo' containing the details of the session information. If the report fails, an error message is returned.
Laure Cougnaud
The parameters for this visualization
are based on ggplot2
(aesthetic, scale, ...), parameter specification,
unlike the other visualizations of the package.
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 )
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 )
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. |
Either:
if a table
is requested: a clinDataReview
object,
a.k.a a list with the 'plot' (plotly
object) and 'table'
(datatable
object)
otherwise: a plotly
object
Laure Cougnaud
Other Clinical data visualization of individual profiles.:
timeProfileIntervalPlot()
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 ) ## Not run: # 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 ) } ## End(Not run) ## 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" ) ## Not run: # 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( subj = 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 smoothPlot <- scatterplotClinData( data = data, xVar = "time", yVar = "response", aesPointVar = list(color = "treat"), aesLineVar = list(group = 'subj'), linePars = list(linetype='dotted'), aesSmoothVar = list(color='subj', group='subj'), smoothPars = list(alpha=0.5, size=0.3 , se=TRUE, color = 'black') ) smoothPlot # plot smoothing over subjects smoothPlot <- scatterplotClinData( data = data, xVar = "time", yVar = "response", aesPointVar = list(color = "treat"), aesLineVar = list(group = 'subj'), linePars = list(linetype='dotted'), aesSmoothVar = list(), smoothPars = list(alpha=0.5, size=0.3 , se=TRUE, color = 'black') ) smoothPlot ## End(Not run) # 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 ) }
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 ) ## Not run: # 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 ) } ## End(Not run) ## 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" ) ## Not run: # 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( subj = 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 smoothPlot <- scatterplotClinData( data = data, xVar = "time", yVar = "response", aesPointVar = list(color = "treat"), aesLineVar = list(group = 'subj'), linePars = list(linetype='dotted'), aesSmoothVar = list(color='subj', group='subj'), smoothPars = list(alpha=0.5, size=0.3 , se=TRUE, color = 'black') ) smoothPlot # plot smoothing over subjects smoothPlot <- scatterplotClinData( data = data, xVar = "time", yVar = "response", aesPointVar = list(color = "treat"), aesLineVar = list(group = 'subj'), linePars = list(linetype='dotted'), aesSmoothVar = list(), smoothPars = list(alpha=0.5, size=0.3 , se=TRUE, color = 'black') ) smoothPlot ## End(Not run) # 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 ) }
By default, the number of columns is 2.
setFacetLayoutWrap(data, facetPars = list())
setFacetLayoutWrap(data, facetPars = list())
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 ( |
Updated facetPars
.
Laure Cougnaud
staticScatterplotClinData
function.Get standard palette for the staticScatterplotClinData
function.
setPaletteStaticScatterplotClinData(data, var, aes, scalePars, geomAes, ...)
setPaletteStaticScatterplotClinData(data, var, aes, scalePars, geomAes, ...)
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 |
List with: scalePars
and geomAes
,
each of those potentially updated with default palette(s).
Laure Cougnaud
Split a chapter based on the 'split_by' parameter.
splitChapter( configFile = NULL, configDir = "./config", mdFile = NULL, indexPath = "index.Rmd", intermediateDir = "./interim", outputDir = "./report", verbose = TRUE )
splitChapter( configFile = NULL, configDir = "./config", mdFile = NULL, indexPath = "index.Rmd", intermediateDir = "./interim", outputDir = "./report", verbose = TRUE )
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. |
No return value, the Markdown files are split as specified.
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
parameter
specification 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)
Laure Cougnaud
Scatterplot of variables of interest for clinical data visualization
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") )
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") )
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:
|
ggplot
object
Laure Cougnaud, Adriaan Blommaert
Note: the table and plot are not (yet) linked.
sunburstClinData(...)
sunburstClinData(...)
... |
Arguments passed on to
|
Either:
if a table
is requested: a clinDataReview
object,
a.k.a a list with the 'plot' (plotly
object) and 'table'
(datatable
object)
otherwise: a plotly
object
Laure Cougnaud
Other visualizations of summary statistics for clinical data:
barplotClinData()
,
boxplotClinData()
,
errorbarClinData()
,
plotCountClinData()
,
treemapClinData()
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" ) }
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" ) }
Interactive table is created, with the possibility to have clickeable link to patient-specific report, and included within a button.
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 )
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 )
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. |
Laure Cougnaud
Visualize time intervals across subjects/parameters.
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 )
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 )
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. |
Either:
if a table
is requested: a clinDataReview
object,
a.k.a a list with the 'plot' (plotly
object) and 'table'
(datatable
object)
otherwise: a plotly
object
Laure Cougnaud
Other Clinical data visualization of individual profiles.:
scatterplotClinData()
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" ) }
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 from long to wide format.
This function converts formats with the stats::reshape
function.
transformData(data, transformations, verbose = FALSE, labelVars = NULL)
transformData(data, transformations, verbose = FALSE, labelVars = NULL)
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. |
A data.frame in wide format.
Laure Cougnaud
Note: the table and plot are not (yet) linked.
treemapClinData(...)
treemapClinData(...)
... |
Arguments passed on to
|
Either:
if a table
is requested: a clinDataReview
object,
a.k.a a list with the 'plot' (plotly
object) and 'table'
(datatable
object)
otherwise: a plotly
object
Laure Cougnaud
Other visualizations of summary statistics for clinical data:
barplotClinData()
,
boxplotClinData()
,
errorbarClinData()
,
plotCountClinData()
,
sunburstClinData()
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" ) }
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" ) }
plot_ly
.Get formula for a specific variable,
to be used in aesthetic specification in plot_ly
.
varToFm(var)
varToFm(var)
var |
Character vector with variable to combine. Otherwise with the '+' operator. |
Laure Cougnaud
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.
zipClinDataReview( reportDir = "report", newDir = "report_dependencies", redirectPage = "report.html", zipFolder = "report.zip" )
zipClinDataReview( reportDir = "report", newDir = "report_dependencies", redirectPage = "report.html", zipFolder = "report.zip" )
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. |
The zip folder is created in the specified location.