Title: | Visualization of Patient Profiles |
---|---|
Description: | Creation of patient profile visualizations for exploration, diagnostic or monitoring purposes during a clinical trial. These static visualizations display a patient-specific overview of the evolution during the trial time frame of parameters of interest (as laboratory, ECG, vital signs), presence of adverse events, exposure to a treatment; associated with metadata patient information, as demography, concomitant medication. The visualizations can be tailored for specific domain(s) or endpoint(s) of interest. Visualizations are exported into patient profile report(s) or can be embedded in custom report(s). |
Authors: | Laure Cougnaud [aut, cre], Margaux Faes [rev] (tests), Open Analytics [cph] |
Maintainer: | Laure Cougnaud <[email protected]> |
License: | MIT + file LICENSE |
Version: | 2.0.9 |
Built: | 2025-02-13 04:29:44 UTC |
Source: | https://github.com/openanalytics/patientprofilesvis |
Add reference lines to a profile plot
addReferenceLinesProfilePlot( gg, subjectVar = "USUBJID", refLines = NULL, refLinesData = NULL, refLinesTimeVar = NULL, refLinesLabelVar = NULL, refLinesColor = "black", refLinesLinetype = "dotted", timeLim = NULL, addLabel = FALSE )
addReferenceLinesProfilePlot( gg, subjectVar = "USUBJID", refLines = NULL, refLinesData = NULL, refLinesTimeVar = NULL, refLinesLabelVar = NULL, refLinesColor = "black", refLinesLinetype = "dotted", timeLim = NULL, addLabel = FALSE )
gg |
|
subjectVar |
String, variable of |
refLines |
(optional) nested list with details for reference line(s). Each sublist contains:
|
refLinesData |
data.frame with data from which the reference line(s) should be extracted |
refLinesTimeVar |
string, variable of |
refLinesLabelVar |
string, variable of |
refLinesColor |
vector of length 1 with default color for reference line(s) |
refLinesLinetype |
vector of length 1 with default linetype for reference line(s) |
timeLim |
vector of length 2 with time limits. This is used to set the limits to the plot containing the reference lines labels (if requested). |
addLabel |
logical, if TRUE (FALSE by default) add the label of the reference line(s) at the bottom of the plot |
If addLabel
is:
TRUE
: list with:
FALSE
: ggplot2
plot with reference lines
Laure Cougnaud
Check if some of the modules are time expanded, and extract maximum time expand for each module.
checkTimeExpand(listPlots, timeLim = NULL)
checkTimeExpand(listPlots, timeLim = NULL)
listPlots |
list of plots |
timeLim |
time limits |
List of time expand for each module
(named by listPlots
)
Laure Cougnaud
timeLim
)
have compatible time transformation alignments.Check if the subject profiles are time transformed,
and if some of the plots to align (with specified timeLim
)
have compatible time transformation alignments.
checkTimeTrans(listPlots, timeLim = NULL)
checkTimeTrans(listPlots, timeLim = NULL)
listPlots |
list of plots |
timeLim |
time limits |
List of time transformation for each module
(named by listPlots
)
Laure Cougnaud
Check if specified variable(s) are present in the data.
checkVar(var, data)
checkVar(var, data)
var |
Character vector with variable(s) of interest. |
data |
Data.frame with data. |
No returned value, an error message is triggered if some variable(s) are not available in the data.
Laure Cougnaud
ggplot
.If the different modules for a subject don't fit in the page, there are automatically split in multiple pages. The margins are extracted across plots to ensure that plots will be probably aligned.
combineVerticallyGGplot( listPlots, maxNLines = NULL, nCores = 1, shiny = FALSE, verbose = FALSE, reportPerSubject = FALSE )
combineVerticallyGGplot( listPlots, maxNLines = NULL, nCores = 1, shiny = FALSE, verbose = FALSE, reportPerSubject = FALSE )
listPlots |
listPlots per subject as created inside the
|
maxNLines |
Maximum number of lines for a combined plot,
to fit in the page height. |
nCores |
Integer containing the number of cores used for the computation
(1 by default). If more than 1, computation is parallelized, in this case
the package |
shiny |
logical, set to TRUE (FALSE by default)
if the report is generated from a Shiny application.
Messages during report creation will be included in the Shiny interface,
and it will be mentioned at the end of the report.
In this case, the |
verbose |
logical, if TRUE print messages during execution |
reportPerSubject |
Logical, if TRUE (FALSE by default) export a subject profile report by subject. |
a list (by subject) of list (by page)
of ggplot
object
Laure Cougnaud
This converts the empty values (”) to NA.
The variable is then converted as a factor.
Missing values are also included in the
levels of the factor, to ensure that missing values
are displayed in the legend of the plot.
convertAesVar(data, var)
convertAesVar(data, var)
data |
data.frame with data |
var |
variable of |
updated factor var
variable
Laure Cougnaud
Count number of lines ('\n' character) per character in a vector
countNLines(x)
countNLines(x)
x |
character vector |
numeric vector with same length than x
containing number of lines in each element
Laure
By default all subjects available in at least one module of listPlots
are considered.
If only a set of subjects are of interest, these are specified either:
directly with the subject IDs of interest via subjectSubset
by extracting subjects with a specific value (subjectSubsetValue
)
in a variable (subjectSubsetVar
) in a specific dataset subjectSubsetData
createSubjectProfileReport( listPlots, timeLim = NULL, timeAlign = "all", timeAlignPerSubject = "none", refLines = NULL, refLinesData = NULL, refLinesTimeVar = NULL, refLinesLabelVar = NULL, bookmarkData = NULL, bookmarkVar = NULL, subjectSortData = bookmarkData, subjectSortVar = bookmarkVar, subjectSortDecreasing = FALSE, subjectVar = "USUBJID", subjectSubset = NULL, subjectSubsetData = NULL, subjectSubsetVar = NULL, subjectSubsetValue = NULL, subjectSample = NULL, seed = 123, subset = NULL, outputFile = "subjectProfile.pdf", exportFigures = FALSE, reportPerSubject = FALSE, exportBatchSize = NULL, labelVars = NULL, maxNLines = NULL, shiny = FALSE, formatReport = subjectProfileReportFormat(), verbose = FALSE, nCores = 1 )
createSubjectProfileReport( listPlots, timeLim = NULL, timeAlign = "all", timeAlignPerSubject = "none", refLines = NULL, refLinesData = NULL, refLinesTimeVar = NULL, refLinesLabelVar = NULL, bookmarkData = NULL, bookmarkVar = NULL, subjectSortData = bookmarkData, subjectSortVar = bookmarkVar, subjectSortDecreasing = FALSE, subjectVar = "USUBJID", subjectSubset = NULL, subjectSubsetData = NULL, subjectSubsetVar = NULL, subjectSubsetValue = NULL, subjectSample = NULL, seed = 123, subset = NULL, outputFile = "subjectProfile.pdf", exportFigures = FALSE, reportPerSubject = FALSE, exportBatchSize = NULL, labelVars = NULL, maxNLines = NULL, shiny = FALSE, formatReport = subjectProfileReportFormat(), verbose = FALSE, nCores = 1 )
listPlots |
nested list of plots, as returned by the |
timeLim |
Time limits, as a numeric vector of length 2,
or a list with time limits for each module,
or nested list with time limits for each module and subject.
If not specified, these are set to the time limits specified
when creating each module (stored in |
timeAlign |
Character vector with time alignment across modules/subjects, either:
|
timeAlignPerSubject |
Character vector, specifying if the plots should be aligned (or not) across subjects
Only the modules already specified in |
refLines |
(optional) nested list with details for reference line(s). Each sublist contains:
|
refLinesData |
data.frame with data from which the reference line(s) should be extracted |
refLinesTimeVar |
string, variable of |
refLinesLabelVar |
string, variable of |
bookmarkData , bookmarkVar
|
Data.frame with data containing information for the index,
and character vector with corresponding variable(s) of interest.
An index will be created at the end of the subject profile report. |
subjectSortData |
Data.frame with data containing information on how the subjects
should be sorted (by default same as
This data should contain |
subjectSortVar |
Character vector,
variable(s) of |
subjectSortDecreasing |
Logical, if TRUE (FALSE by default)
subjects are sorted based on decreasing order of |
subjectVar |
String, variable of |
subjectSubset |
subjectSubset (optional) Character vector with subjects of interest
(available in |
subjectSubsetData |
Data.frame used to select subset of subjects of interest. |
subjectSubsetVar |
String with variable of |
subjectSubsetValue |
Character vector with value(s) of |
subjectSample |
(optional) Integer of length 1 with number of random subject(s) that should be considered in the specified subset dataset. By default, all specified subjects are considered (set to NULL). |
seed |
(optional) Integer of length 1 with seed used to select random subjects
if |
subset |
Character vector with subjects of interest
(among names of each list in |
outputFile |
string, path to the output report |
exportFigures |
Logical, if TRUE (FALSE by default) the
subject profile figures are also exported
in pdf format in a 'figures' folder. |
reportPerSubject |
Logical, if TRUE (FALSE by default) export a subject profile report by subject. |
exportBatchSize |
(optional) Integer, if specified, the
patient-profile reports are created by batch of this number of subjects.
This might speed up the export for a high number of subjects.
Only available if report is created by subject ( |
labelVars |
Named character vector with variable labels (names are the variable code) |
maxNLines |
Maximum number of lines for a combined plot,
to fit in the page height. |
shiny |
logical, set to TRUE (FALSE by default)
if the report is generated from a Shiny application.
Messages during report creation will be included in the Shiny interface,
and it will be mentioned at the end of the report.
In this case, the |
formatReport |
list with parameters used to specify the format of the report,
e.g. output of the |
verbose |
logical, if TRUE print messages during execution |
nCores |
Integer containing the number of cores used for the computation
(1 by default). If more than 1, computation is parallelized, in this case
the package |
The path(s) of the report(s) is returned invisibly, and the
report is created at the location
specified by outputFile
.
If the report is created by subject,
the name of the exported subject profile is built as:
[filename]-[subjectID].pdf
, with [filename] extracted from
outputFile
.
Space and platform-specific file separator are replaced by
a dash in the filename.
If no patient profiles are available in the input,
nothing is returned and a warning is triggered.
Laure Cougnaud
Define LaTeX index based on specified variable(s) of the dataset
defineIndex(subjects, data, var, subjectVar = "USUBJID", labelVars = NULL)
defineIndex(subjects, data, var, subjectVar = "USUBJID", labelVars = NULL)
subjects |
vector with subject IDs (based on the |
data |
data.frame with data containing information on which the index should be based |
var |
variable(s) of |
subjectVar |
String, variable of |
labelVars |
Named character vector with variable labels (names are the variable code) |
list with elements:
'indexMake': string with LaTeX code for creation of index,
to be included directly with cat
in a knitr document
(two backslashes)
'indexEntry': character vector, named with named with subject ID,
containing LaTeX code for index for each subject
specified in subjects
parameter, to be included in a knitr document
as text (four backslashes)
'indexPrint': string with LaTeX code for printing/inclusion of index,
to be included directly with cat
in a knitr document
(two backslashes)
Laure Cougnaud
Data is filtered based on the following workflow:
The subset dataset (of data
if not specified)
is filtered based on subject variable and value (if specified).
If a external subset dataset is specified, only the subject IDs of this filtered dataset are considered.
The data
is filtered based on the selected subjects,
from subjectSubset
(if specified) or from step 2.
The data is filtered based on a random selection of subjects, if
subjectSample
is specified.
This filtering workflow is used for all subject profile visualization functions of the package.
filterData( data, subsetData = NULL, subsetVar = NULL, subsetValue = NULL, subjectVar = "USUBJID", subjectSubset = NULL, subjectSample = NULL, seed = 123 )
filterData( data, subsetData = NULL, subsetVar = NULL, subsetValue = NULL, subjectVar = "USUBJID", subjectSubset = NULL, subjectSample = NULL, seed = 123 )
data |
Data.frame with data |
subsetData |
(optional) Data.frame with extra dataset to filter on.
This dataset is filtered, and only records from |
subsetVar |
(optional) String with variable of subset data to filter on.
|
subsetValue |
(optional) Character vector with value(s) of interest to
retain in the filtered data.
These values should be available in |
subjectVar |
String, variable of data (and subset data) with subject ID. |
subjectSubset |
(optional) Character vector with subjects of interest
(available in |
subjectSample |
(optional) Integer of length 1 with number of random subject(s) that should be considered, e.g. to check the created patient profiles for a subset of the data. By default, all specified subjects are considered (set to NULL). |
seed |
(optional) Integer of length 1 with seed used to select random subjects
if |
possibly filtered dataset
Laure Cougnaud
library(clinUtils) data(dataSDTMCDISCP01) dataAll <- dataSDTMCDISCP01 # keep only a subset of subjects # (e.g. to visualize specified patient profiles # before creating them for all subject) filterData( data = dataAll$AE, subjectSample = 2 ) # filter based on specified variable/value: # only adverse events possibly related filterData( data = dataAll$AE, subsetVar = "AEREL", subsetValue = "POSSIBLE" ) # filter based on a different dataset: # keep only adverse events for subjects in a specific treatment arm filterData( data = dataAll$AE, subsetData = dataAll$DM, subsetVar = "ACTARM", subsetValue = "Placebo" ) # filter based on subjects of interest filterData( data = dataAll$AE, subjectSubset = c("01-701-1148", "01-701-1211") )
library(clinUtils) data(dataSDTMCDISCP01) dataAll <- dataSDTMCDISCP01 # keep only a subset of subjects # (e.g. to visualize specified patient profiles # before creating them for all subject) filterData( data = dataAll$AE, subjectSample = 2 ) # filter based on specified variable/value: # only adverse events possibly related filterData( data = dataAll$AE, subsetVar = "AEREL", subsetValue = "POSSIBLE" ) # filter based on a different dataset: # keep only adverse events for subjects in a specific treatment arm filterData( data = dataAll$AE, subsetData = dataAll$DM, subsetVar = "ACTARM", subsetValue = "Placebo" ) # filter based on subjects of interest filterData( data = dataAll$AE, subjectSubset = c("01-701-1148", "01-701-1211") )
Filter missing records in data in the time and y variables, with informative message.
filterMissingInVar( data, var, varLab = getLabelVar(var, labelVars = labelVars), labelVars = NULL )
filterMissingInVar( data, var, varLab = getLabelVar(var, labelVars = labelVars), labelVars = NULL )
data |
Data.frame with data. |
var |
String with variable of interest. |
varLab |
String, label for |
labelVars |
Named character vector with variable labels (names are the variable code) |
Update data with filtered records + message in the console.
Laure Cougnaud
Text variables are wrapped across multiple lines if needed, and optionally sorted according to the levels of a grouping variable.
formatParamVarTextPlot( data, paramVar = NULL, paramValueVar = NULL, paramValueLab = NULL, paramGroupVar = NULL, revert = FALSE, width = formatReport$yLabelWidth, widthValue = ifelse(formatReport$landscape, 240, 190), formatReport = subjectProfileReportFormat(), table = FALSE, colWidth = NULL )
formatParamVarTextPlot( data, paramVar = NULL, paramValueVar = NULL, paramValueLab = NULL, paramGroupVar = NULL, revert = FALSE, width = formatReport$yLabelWidth, widthValue = ifelse(formatReport$landscape, 240, 190), formatReport = subjectProfileReportFormat(), table = FALSE, colWidth = NULL )
data |
data.frame with data |
paramVar |
string, variable of |
paramValueVar |
string, variable of |
paramValueLab |
Character vector with labels for |
paramGroupVar |
(optional) character vector with variable(s) of |
revert |
logical, if TRUE revert the order of the levels of the variable |
width |
max number of characters in the |
widthValue |
max number of characters in the |
formatReport |
list with parameters used to specify the format of the report,
e.g. output of the |
table |
Logical, if TRUE the |
colWidth |
Numeric vector with approximate
width of each parameter value column
for a table layout. |
data
with reformatted paramVar
and paramValueVar
variables,
with additional attribute: colWidth
.
Laure Cougnaud
Set missing start/end time variable in the data.
formatTimeInterval( data, timeStartVar, timeStartLab = getLabelVar(timeStartVar, labelVars = labelVars), timeEndVar, timeEndLab = getLabelVar(timeEndVar, labelVars = labelVars), timeStartShapeVar = NULL, timeEndShapeVar = NULL, subjectVar = "USUBJID", timeLim = NULL, timeLimData = NULL, timeLimStartVar = NULL, timeLimStartLab = getLabelVar(timeLimStartVar, labelVars = labelVars), timeLimEndVar = NULL, timeLimEndLab = getLabelVar(timeLimEndVar, labelVars = labelVars), timeImpType = c("minimal", "data-based", "none"), labelVars = NULL )
formatTimeInterval( data, timeStartVar, timeStartLab = getLabelVar(timeStartVar, labelVars = labelVars), timeEndVar, timeEndLab = getLabelVar(timeEndVar, labelVars = labelVars), timeStartShapeVar = NULL, timeEndShapeVar = NULL, subjectVar = "USUBJID", timeLim = NULL, timeLimData = NULL, timeLimStartVar = NULL, timeLimStartLab = getLabelVar(timeLimStartVar, labelVars = labelVars), timeLimEndVar = NULL, timeLimEndLab = getLabelVar(timeLimEndVar, labelVars = labelVars), timeImpType = c("minimal", "data-based", "none"), labelVars = NULL )
data |
Data.frame with data. |
timeStartVar |
String, variable of |
timeStartLab |
String, label for |
timeEndVar |
String, variable of |
timeEndLab |
String, label for |
timeStartShapeVar |
(optional) String, variable of |
timeEndShapeVar |
String, variable of |
subjectVar |
String, variable of |
timeLim |
(optional) Vector of length 2 with time limits (x-axis).
If not specified, these are extracted from the minimum |
timeLimData |
Data.frame with data used to impute time
in case some time records are missing in |
timeLimStartVar |
String, variable of |
timeLimStartLab |
String, label for |
timeLimEndVar |
String, variable of |
timeLimEndLab |
String, label for |
timeImpType |
String with imputation type: 'minimal' (default),
'data-based' or 'none', see section: 'Time interval representation'. |
labelVars |
Named character vector with variable labels (names are the variable code) |
list with:
'data': Data with:
imputed timeStartVar
and timeEndVar
new column 'timeStartStatus':
character vector containing status of timeStartVar
variable:
'Complete' or 'Missing start' or NA
new column 'timeEndStatus':
character vector containing status of timeEndVar
variable:
'Complete' or 'Missing end' or NA
'timeLim': vector of length 2 with minimum/maximum time limits across subjects.
'timeLimSpecified': vector of length 2 with time limits as specified
by the user, either extracted from timeLim
or from timeLimData
.
If missing value within timeLim
, the corresponding minimum/maximum
value in the (updated) data is used.
'timeShapePalette': Named character vector with symbols for the different time status
'caption': String with extra explanation concerning imputation that could be included in plot caption.
In case the start or the end of the time interval contain missing values:
if a dataset (timeLimData
), start (timeLimStartVar
)
and end (timeLimEndVar
) variables are specified:
for each subject:
the minimum and maximum time values across these specified time variables are extracted
missing start values are replaced by the minimum time
missing start values are replaced by the maximum time
if all values are missing for this subject, they are taken across subjects
otherwise, depending on the imputation type (timeImpType
):
'minimal' (by default):
if the start and the end of the interval are missing: no imputation is done, only the label is displayed
if the start time is missing and the end time is not missing: start time is imputed with end time, and status is set to 'Missing start'
if the end time is missing and the start time is not missing: end time is imputed with start time, and status is set to 'Missing end'
'data-based' (default in version < 1.0.0): minimum/maximum values in the start/end time variables in the data are considered for the specific subject (if available). If there are missing for a specific subject, they are taken across subjects. If all time are missings, the range is set to 0 and Inf
'none': no imputation is done
The symbols displayed at the start and end of the interval are:
by default:
a filled square labelled 'Complete' if the time is not missing
a filled left-directed arrow in case of missing start time
a filled right-directed arrow in case of missing end time
if the variable(s) used for the shape of the start or end
of the interval are specified (via
timeStartShapeVar
/timeEndShapeVar
):
labels are based on these variables, and a standard shape palette is used
The time limits are the same across subjects, and set to:
timeLim
if specified
maximum time range in timeLimStartVar
and
timeLimEndVar
in timeLimData
if specified
the maximum range on the data obtained after imputation of missing values
Laure Cougnaud
timeLim
.In case one of the limits if missing, the corresponding minimum/maximum across subjects is used.
formatTimeLim( data, subjectVar = "USUBJID", timeStartVar, timeEndVar, timeLim = NULL )
formatTimeLim( data, subjectVar = "USUBJID", timeStartVar, timeEndVar, timeLim = NULL )
data |
Data.frame with data. |
subjectVar |
String, variable of |
timeStartVar |
String, variable of |
timeEndVar |
String, variable of |
timeLim |
(optional) Vector of length 2 with time limits (x-axis).
If not specified, these are extracted from the minimum |
Numeric vector of length 2 or list of such element for each subject.
Laure Cougnaud
Get custom 'scale_[type]_manual' function
getAesScaleManual(lab, palette, type)
getAesScaleManual(lab, palette, type)
lab |
label for the scale (title of the legend) |
palette |
named vector with color palette |
type |
string with type of scale, e.g. 'color' |
output of the 'scale_[type]_manual' function
Laure Cougnaud
This is a simple wrapper around getColorPalette, with different defaults:
inclusion of missing values
by default (includeNA
set to TRUE
)
getColorPalettePatientProfile(..., includeNA = TRUE)
getColorPalettePatientProfile(..., includeNA = TRUE)
... |
Arguments passed on to
|
includeNA |
Logical (TRUE by default),
should NA elements be retained in the palette in case
|
Vector of shapes,
named with the elements in x
if x
is specified.
Laure Cougnaud
Get maximum number of lines of a 'combined plot' for a specific document
getMaxNLinesCombinePlot( heightLineIn = subjectProfileReportFormat()$heightLineIn, margin = subjectProfileReportFormat()$margin, landscape = subjectProfileReportFormat()$landscape, aspectRatio = subjectProfileReportFormat()$aspectRatio )
getMaxNLinesCombinePlot( heightLineIn = subjectProfileReportFormat()$heightLineIn, margin = subjectProfileReportFormat()$margin, landscape = subjectProfileReportFormat()$landscape, aspectRatio = subjectProfileReportFormat()$aspectRatio )
heightLineIn |
Numeric of length 1 with height of a line in inches, 0.2 by default. |
margin |
Numeric of length 1, with margin in inches. |
landscape |
Logical, if TRUE the created report is in landscape format. FALSE by default, the report is created in portrait format. |
aspectRatio |
Numeric of length 1 (0.75 by default)
with ratio between size of image in inches
(derived from specified |
numeric with maximum height for plot
Laure Cougnaud
ggplot2
object via gg
or from the label via value
Get number of lines for specific label either
from a ggplot2
object via gg
or from the label via value
getNLinesLabel( gg, value, elName = c("x", "y", "title", "caption"), elNLines = NULL )
getNLinesLabel( gg, value, elName = c("x", "y", "title", "caption"), elNLines = NULL )
gg |
|
value |
String with label value. |
elName |
string with name of label to extract, among 'x', 'y' and 'title' |
elNLines |
(optional) Named integer with number of lines, by default 2 for 'x'/'y', 3 for 'title' and 1 for caption. |
integer with (approximated) number of lines
Laure Cougnaud
ggplot2
object,
or from the values of the legend (legendValues
)
and title (legendTitle
)Get number of lines in the legend,
either from directly the ggplot2
object,
or from the values of the legend (legendValues
)
and title (legendTitle
)
getNLinesLegend(gg, values, title)
getNLinesLegend(gg, values, title)
gg |
|
values |
Vector with unique legend values |
title |
String, title for the plot. |
integer with (approximated) number of lines
Laure Cougnaud
This is extracted from the presence of labels in the y-axis, labels and title in the x-axis, general title and number of lines in the legend. Can be used to specify plot-specific height during the export.
getNLinesSubjectProfile(gg)
getNLinesSubjectProfile(gg)
gg |
|
integer with (approximated) number of lines
Laure Cougnaud
Get optimal column widths, based on the minimum word size and median number of characters in each column.
getOptimalColWidth( data, widthValue = ifelse(formatReport$landscape, 240, 190), labels = NULL, formatReport = subjectProfileReportFormat() )
getOptimalColWidth( data, widthValue = ifelse(formatReport$landscape, 240, 190), labels = NULL, formatReport = subjectProfileReportFormat() )
data |
Data.frame with columns for which optimal width should be extracted. |
widthValue |
max number of characters in the |
labels |
(optional) Character vector with column labels for |
formatReport |
list with parameters used to specify the format of the report,
e.g. output of the |
Numeric vector of length(ncol(data))
with optimal widths.
Laure Cougnaud
Get variable with page of the plot, used for automatic paging of a plot
getPageVar( data, var, typeVar = c("y", "panel"), formatReport = subjectProfileReportFormat(), title = TRUE, xLab = TRUE, caption = TRUE, paging = TRUE, table = FALSE )
getPageVar( data, var, typeVar = c("y", "panel"), formatReport = subjectProfileReportFormat(), title = TRUE, xLab = TRUE, caption = TRUE, paging = TRUE, table = FALSE )
data |
data.frame with data |
var |
string, variable of |
typeVar |
string, type of the variable, either: 'y': the variable is displayed in the x-axis or 'panel': the variable is displayed as separated facets. This is used to compute height for each line of the plot. |
formatReport |
list with parameters used to specify the format of the report,
e.g. output of the |
title |
logical, has the plot a title? |
xLab |
logical, has the plot a label for the x-axis? |
caption |
logical, has the plot a caption? |
paging |
Logical, if TRUE (by default), automatic
paging is enabled, so patient profiles module too big to fit
in one page will span multiple pages.
Please note that the size of the graphic window
(or report page) may need
to be re-sized in order that the plot fits.
|
table |
Logical, if TRUE the |
input data
with additional column 'pagePlot'
containing the page for the plot
Laure Cougnaud
patientProfilesVis
packageGet path of the report template
in the patientProfilesVis
package
getPathTemplate(file)
getPathTemplate(file)
file |
file name (with extension) |
String with path to the template in the
installed patientProfilesVis
package
Laure Cougnaud
This is a simple wrapper around getShapePalette, with different defaults:
inclusion of missing values by
default (includeNA
set to TRUE
)
the extraction of shapes as text
by default (asText
set to TRUE
)
getShapePalettePatientProfile(..., includeNA = TRUE, asText = TRUE)
getShapePalettePatientProfile(..., includeNA = TRUE, asText = TRUE)
... |
Arguments passed on to
|
includeNA |
Logical (TRUE by default),
should NA elements be retained in the palette in case
|
asText |
Logical (TRUE by default), should the palette be expressed as integer (base R plot and ggplot2 compatible) or in text format (e.g. required if combined with unicode symbols in ggplot2)? |
Vector of shapes,
named with the elements in x
if x
is specified.
Laure Cougnaud
Split/combine a vector of size(s) to have a fixed combined size
getSplitVectorByInt(sizes, max = NULL)
getSplitVectorByInt(sizes, max = NULL)
sizes |
vector with size |
max |
integer with maximum combined size in output, Inf by default. |
vector of same length as sizeVect
,
containing corresponding class
Laure Cougnaud
These limits are extracted from specified timeLim
for each
module (stored in the attributes()$metaData$timeLim
),
and if empty for all modules: from the maximal range
of the x-coordinates across all plots.
getTimeLimSubjectProfilePlots( listPlots, timeAlign = "all", timeAlignPerSubject = "none" )
getTimeLimSubjectProfilePlots( listPlots, timeAlign = "all", timeAlignPerSubject = "none" )
listPlots |
list of list of |
timeAlign |
Character vector with time alignment across modules/subjects, either:
|
timeAlignPerSubject |
Character vector, specifying if the plots should be aligned (or not) across subjects
Only the modules already specified in |
Time limits, as a numeric vector of length 2.
If time limits should be set by module, named list
with time limits by module.
If time limits should be set by module and subject, nested list
with time limits 1) by module 2) by subject.
The names of the list contains the module/subject name extracted
from the names of listPlots
.
The time limits are only returned if they will need to be explicitly set
for a plot. Otherwise, NULL is returned.
Laure Cougnaud
Get useful transformation for the time variable in patient profiles.
getTimeTrans( type = c("asinh", "asinh-neg"), scale = 1, formatFct = prettyNum, n = 10 )
getTimeTrans( type = c("asinh", "asinh-neg"), scale = 1, formatFct = prettyNum, n = 10 )
type |
String with transformation type, either:
|
scale |
Numeric vector of length 1 (1 by default)
with size of the linear region around 0, only used if in case
|
formatFct |
function formatting the time axis breaks,
( |
n |
Integer of length 1 with number of breaks, 10 by default. |
ggplot2 transformation (see trans_new
)
Pieter-Jan Stiers, Laure Cougnaud
Get width for a plot for a certain page layout
getWidthPlot( margin = subjectProfileReportFormat()$margin, landscape = subjectProfileReportFormat()$landscape, aspectRatio = subjectProfileReportFormat()$aspectRatio )
getWidthPlot( margin = subjectProfileReportFormat()$margin, landscape = subjectProfileReportFormat()$landscape, aspectRatio = subjectProfileReportFormat()$aspectRatio )
margin |
Numeric of length 1, with margin in inches. |
landscape |
Logical, if TRUE the created report is in landscape format. FALSE by default, the report is created in portrait format. |
aspectRatio |
Numeric of length 1 (0.75 by default)
with ratio between size of image in inches
(derived from specified |
width for the plot in inches
Laure Cougnaud
This ensures that missing values in one of the variable(s) don't propagate, so the combined result will be: 'NA - a', and that the levels of the combined vector are sorted as the levels of the specified variables (levels of the first variable varying first).
interactionWithMissing(data, vars, varSep = " - ")
interactionWithMissing(data, vars, varSep = " - ")
data |
Data.frame with data. |
vars |
Character vector with variable(s) of interest. |
varSep |
String with separator to which the variable(s) should be combined. |
Vector of length: nrow(data)
,
with interaction vector.
Laure Cougnaud
Check if the all profile(s) is/are 'time-variant', so not a subject profile 'text' module or empty plot
isSubjectProfileTimeVariant(gg, empty = TRUE)
isSubjectProfileTimeVariant(gg, empty = TRUE)
gg |
object of class |
empty |
Logical, should empty subject profile be considered as time-variant? |
Logical, is plot time variant?
Laure Cougnaud
Arguments used across the functions of the patientProfilesVis package.
data |
Data.frame with data. |
colorVar |
String, variable of |
colorLab |
String, label for |
colorPalette |
Named vector with color palette.
The variable should be named with the corresponding element
in
|
shapeVar |
String, variable of |
shapeLab |
String, label for |
shapePalette |
Named character vector with shape palette
for
Note it is advised to specify the shapes as character,
e.g. 'cross' instead of |
paramGroupVar |
(optional) Character vector with variable(s)
of |
xLab |
String, label for the x-axis. |
yLab |
String, label for the y-axis. |
label |
String, label for the visualization.
This label is stored as attributes of the output
from the |
title |
String, title for the plot. |
timeVar |
String, variable of |
timeLab |
String, label for |
paramVar |
Character vector with variable(s) of |
paramLab |
Named character vector,
with label for the parameter variable(s) ( |
timeLim |
(optional) Vector of length 2 with time limits (x-axis).
If not specified, these are extracted from the minimum |
timeTrans |
transformation for the time variable,
(see |
timeExpand |
Vector of range expansion constants for the time axis
(see |
listPlots |
Named list of subject profiles.
Each sublist contains subject profiles as returned
by the |
alpha |
Numeric with transparency, 1 by default. |
labelVars |
Named character vector with variable labels (names are the variable code) |
subjectVar |
String, variable of |
formatReport |
list with parameters used to specify the format of the report,
e.g. output of the |
paramVarSep |
string with character(s) used to concatenate multiple
|
No return value, used for the documentation of the functions of the package.
Parameters for all patient profiles visualization palette functions.
includeNA |
Logical (TRUE by default),
should NA elements be retained in the palette in case
|
No return value, used for the documentation of the palette functions of the package.
combineVerticallyGGplot
prepare list of subject profile (s) to be combined with the combineVerticallyGGplot
prepareSubjectProfile( ..., labels, timeLim = NULL, refLines = NULL, refLinesData = NULL, refLinesTimeVar = NULL, refLinesLabelVar = NULL, subjectVar = "USUBJID", timeTrans = NULL, timeExpand = NULL )
prepareSubjectProfile( ..., labels, timeLim = NULL, refLines = NULL, refLinesData = NULL, refLinesTimeVar = NULL, refLinesLabelVar = NULL, subjectVar = "USUBJID", timeTrans = NULL, timeExpand = NULL )
... |
list of subject profiles (across modules) |
labels |
string with labels for the plots |
timeLim |
time limits, as returned by the
|
refLines |
(optional) nested list with details for reference line(s). Each sublist contains:
|
refLinesData |
data.frame with data from which the reference line(s) should be extracted |
refLinesTimeVar |
string, variable of |
refLinesLabelVar |
string, variable of |
subjectVar |
String, variable of |
timeTrans |
Time transformation, or list of such transformation named by module. If NULL, no transformation are done. |
timeExpand |
Vector of range expansion constants for the time axis
(see |
subjectProfilePlot
object, containing the combined
profile plots
Laure Cougnaud
Sort subjects based on a specified dataset/variable.
sortSubjects( subjects, subjectVar = "USUBJID", subjectSortData = NULL, subjectSortVar = NULL, subjectSortDecreasing = FALSE, verbose = FALSE )
sortSubjects( subjects, subjectVar = "USUBJID", subjectSortData = NULL, subjectSortVar = NULL, subjectSortDecreasing = FALSE, verbose = FALSE )
subjects |
Character vector with subjects of interest |
subjectVar |
String, variable of |
subjectSortData |
Data.frame with data containing information on how the subjects should be sorted. |
subjectSortVar |
Variable(s) of |
subjectSortDecreasing |
Logical, if TRUE (FALSE by default)
subjects are sorted based on inverse order of |
verbose |
logical, if TRUE print messages during execution |
Updated subjects
Laure Cougnaud
Visualizations of different modules are combined by subject. The plots are aligned in the time axis (if requested). If the plots should be aligned:
the same time limits are set for all plots
the time axis is transformed if any of the plot was created with a time transformation
the time axis is expanded for all plots
if any of the plot was created with a time axis expanded.
The expansion
object for
the combined plot is created
from the max of each expansion element across modules.
If some plots are missing for a specific subject,
an empty plot is created, containing information
as a text based on the label
with which the plot was created.
subjectProfileCombine( listPlots, timeLim = NULL, timeAlign = "all", timeAlignPerSubject = "none", subjectVar = "USUBJID", maxNLines = NULL, refLines = NULL, refLinesData = NULL, refLinesTimeVar = NULL, refLinesLabelVar = NULL, shiny = FALSE, verbose = FALSE, nCores = 1, reportPerSubject = FALSE )
subjectProfileCombine( listPlots, timeLim = NULL, timeAlign = "all", timeAlignPerSubject = "none", subjectVar = "USUBJID", maxNLines = NULL, refLines = NULL, refLinesData = NULL, refLinesTimeVar = NULL, refLinesLabelVar = NULL, shiny = FALSE, verbose = FALSE, nCores = 1, reportPerSubject = FALSE )
listPlots |
listPlots per subject as created inside the
|
timeLim |
time limits, as returned by the
|
timeAlign |
Character vector with time alignment across modules/subjects, either:
|
timeAlignPerSubject |
Character vector, specifying if the plots should be aligned (or not) across subjects
Only the modules already specified in |
subjectVar |
String, variable of |
maxNLines |
Maximum number of lines for a combined plot,
to fit in the page height. |
refLines |
(optional) nested list with details for reference line(s). Each sublist contains:
|
refLinesData |
data.frame with data from which the reference line(s) should be extracted |
refLinesTimeVar |
string, variable of |
refLinesLabelVar |
string, variable of |
shiny |
logical, set to TRUE (FALSE by default)
if the report is generated from a Shiny application.
Messages during report creation will be included in the Shiny interface,
and it will be mentioned at the end of the report.
In this case, the |
verbose |
logical, if TRUE print messages during execution |
nCores |
Integer containing the number of cores used for the computation
(1 by default). If more than 1, computation is parallelized, in this case
the package |
reportPerSubject |
Logical, if TRUE (FALSE by default) export a subject profile report by subject. |
a nested list of ggplot
object,
containing the combined
profile plots across modules for each subject/page.
Each plot object contains in the associated attribute:
metaData
containing: nLines
: an estimation
of the number of 'lines' each plot occupies
(e.g. to set height of the exported figure).
Laure Cougnaud
Visualize events in subject profiles, so event with a single time.
subjectProfileEventPlot( data, paramVar, paramLab = getLabelVar(paramVar, labelVars = labelVars), paramVarSep = " - ", paramGroupVar = NULL, colorVar = NULL, colorLab = getLabelVar(colorVar, labelVars = labelVars), colorPalette = NULL, shapeVar = colorVar, shapeLab = if (isTRUE(colorVar == shapeVar)) { colorLab } else getLabelVar(shapeVar, labelVars = labelVars), shapePalette = NULL, alpha = 1, timeVar, timeLab = getLabelVar(timeVar, labelVars = labelVars), timeTrans = NULL, timeExpand = NULL, subjectVar = "USUBJID", subjectSubset = NULL, subjectSample = NULL, seed = 123, subsetData = NULL, subsetVar = NULL, subsetValue = NULL, xLab = timeLab, yLab = "", timeLim = NULL, title = toString(getLabelVar(paramVar, labelVars = labelVars, label = paramLab)), label = title, labelVars = NULL, formatReport = subjectProfileReportFormat(), paging = TRUE )
subjectProfileEventPlot( data, paramVar, paramLab = getLabelVar(paramVar, labelVars = labelVars), paramVarSep = " - ", paramGroupVar = NULL, colorVar = NULL, colorLab = getLabelVar(colorVar, labelVars = labelVars), colorPalette = NULL, shapeVar = colorVar, shapeLab = if (isTRUE(colorVar == shapeVar)) { colorLab } else getLabelVar(shapeVar, labelVars = labelVars), shapePalette = NULL, alpha = 1, timeVar, timeLab = getLabelVar(timeVar, labelVars = labelVars), timeTrans = NULL, timeExpand = NULL, subjectVar = "USUBJID", subjectSubset = NULL, subjectSample = NULL, seed = 123, subsetData = NULL, subsetVar = NULL, subsetValue = NULL, xLab = timeLab, yLab = "", timeLim = NULL, title = toString(getLabelVar(paramVar, labelVars = labelVars, label = paramLab)), label = title, labelVars = NULL, formatReport = subjectProfileReportFormat(), paging = TRUE )
data |
Data.frame with data. |
paramVar |
Character vector with variable(s) of |
paramLab |
Named character vector,
with label for the parameter variable(s) ( |
paramVarSep |
string with character(s) used to concatenate multiple
|
paramGroupVar |
(optional) Character vector with variable(s)
of |
colorVar |
String, variable of |
colorLab |
String, label for |
colorPalette |
Named vector with color palette.
The variable should be named with the corresponding element
in
|
shapeVar |
String, variable of |
shapeLab |
String, label for |
shapePalette |
Named character vector with shape palette
for
Note it is advised to specify the shapes as character,
e.g. 'cross' instead of |
alpha |
Numeric with transparency, 1 by default. |
timeVar |
String, variable of |
timeLab |
String, label for |
timeTrans |
transformation for the time variable,
(see |
timeExpand |
Vector of range expansion constants for the time axis
(see |
subjectVar |
String, variable of |
subjectSubset |
(optional) Character vector with subjects of interest
(available in |
subjectSample |
(optional) Integer of length 1 with number of random subject(s) that should be considered, e.g. to check the created patient profiles for a subset of the data. By default, all specified subjects are considered (set to NULL). |
seed |
(optional) Integer of length 1 with seed used to select random subjects
if |
subsetData |
(optional) Data.frame with extra dataset to filter on.
This dataset is filtered, and only records from |
subsetVar |
(optional) String with variable of subset data to filter on.
|
subsetValue |
(optional) Character vector with value(s) of interest to
retain in the filtered data.
These values should be available in |
xLab |
String, label for the x-axis. |
yLab |
String, label for the y-axis. |
timeLim |
(optional) Vector of length 2 with time limits (x-axis).
If not specified, these are extracted from the minimum |
title |
String with title, label of the parameter variable by default. |
label |
String, label for the visualization.
This label is stored as attributes of the output
from the |
labelVars |
Named character vector with variable labels (names are the variable code) |
formatReport |
list with parameters used to specify the format of the report,
e.g. output of the |
paging |
Logical, if TRUE (by default), automatic
paging is enabled, so patient profiles module too big to fit
in one page will span multiple pages.
Please note that the size of the graphic window
(or report page) may need
to be re-sized in order that the plot fits.
|
list of (across subjects) of list (across modules) of ggplot2 objects
,
also of class subjectProfileEventPlot
, with additional metaData attributes containing
'label
', 'timeLim' and 'timeTrans' (if specified).
Laure Cougnaud
Other patient profiles plotting function:
subjectProfileIntervalPlot()
,
subjectProfileLinePlot()
,
subjectProfileTextPlot()
Create report
subjectProfileExport( listPlotsSubject, outputFile = "subjectProfile.pdf", index = NULL, formatReport = subjectProfileReportFormat(), shiny = FALSE, verbose = FALSE, nCores = NULL, exportFigures = FALSE )
subjectProfileExport( listPlotsSubject, outputFile = "subjectProfile.pdf", index = NULL, formatReport = subjectProfileReportFormat(), shiny = FALSE, verbose = FALSE, nCores = NULL, exportFigures = FALSE )
listPlotsSubject |
List of plots for each subject |
outputFile |
string, path to the output report |
index |
Index, output from |
formatReport |
list with parameters used to specify the format of the report,
e.g. output of the |
shiny |
logical, set to TRUE (FALSE by default)
if the report is generated from a Shiny application.
Messages during report creation will be included in the Shiny interface,
and it will be mentioned at the end of the report.
In this case, the |
verbose |
logical, if TRUE print messages during execution |
nCores |
Integer containing the number of cores used for the computation
(1 by default). If more than 1, computation is parallelized, in this case
the package |
exportFigures |
Logical, if TRUE (FALSE by default) the
subject profile figures are also exported
in pdf format in a 'figures' folder. |
No returned value, the plots are exported to outputDir
Laure Cougnaud
Visualize time interval in subject profiles, so event with a start and end time.
subjectProfileIntervalPlot( data, paramVar, paramVarSep = " - ", paramLab = getLabelVar(paramVar, labelVars = labelVars), paramGroupVar = NULL, timeStartVar, timeStartLab = getLabelVar(timeStartVar, labelVars = labelVars), timeEndVar, timeEndLab = getLabelVar(timeEndVar, labelVars = labelVars), timeLab = toString(c(timeStartLab, timeEndLab)), subjectVar = "USUBJID", subjectSubset = NULL, subjectSample = NULL, seed = 123, subsetData = NULL, subsetVar = NULL, subsetValue = NULL, timeImpType = c("minimal", "data-based", "none"), timeLim = NULL, timeLimData = NULL, timeLimStartVar = NULL, timeLimStartLab = getLabelVar(timeLimStartVar, labelVars = labelVars), timeLimEndVar = NULL, timeLimEndLab = getLabelVar(timeLimEndVar, labelVars = labelVars), timeTrans = NULL, timeExpand = NULL, timeAlign = TRUE, xLab = timeLab, yLab = "", colorVar = NULL, colorLab = getLabelVar(colorVar, labelVars = labelVars), colorPalette = NULL, alpha = 1, timeStartShapeVar = NULL, timeEndShapeVar = NULL, shapePalette = NULL, shapeLab = toString(unique(getLabelVar(c(timeStartShapeVar, timeEndShapeVar), labelVars = labelVars))), shapeSize = rel(3), title = toString(getLabelVar(paramVar, labelVars = labelVars, label = paramLab)), label = title, caption, labelVars = NULL, formatReport = subjectProfileReportFormat(), paging = TRUE )
subjectProfileIntervalPlot( data, paramVar, paramVarSep = " - ", paramLab = getLabelVar(paramVar, labelVars = labelVars), paramGroupVar = NULL, timeStartVar, timeStartLab = getLabelVar(timeStartVar, labelVars = labelVars), timeEndVar, timeEndLab = getLabelVar(timeEndVar, labelVars = labelVars), timeLab = toString(c(timeStartLab, timeEndLab)), subjectVar = "USUBJID", subjectSubset = NULL, subjectSample = NULL, seed = 123, subsetData = NULL, subsetVar = NULL, subsetValue = NULL, timeImpType = c("minimal", "data-based", "none"), timeLim = NULL, timeLimData = NULL, timeLimStartVar = NULL, timeLimStartLab = getLabelVar(timeLimStartVar, labelVars = labelVars), timeLimEndVar = NULL, timeLimEndLab = getLabelVar(timeLimEndVar, labelVars = labelVars), timeTrans = NULL, timeExpand = NULL, timeAlign = TRUE, xLab = timeLab, yLab = "", colorVar = NULL, colorLab = getLabelVar(colorVar, labelVars = labelVars), colorPalette = NULL, alpha = 1, timeStartShapeVar = NULL, timeEndShapeVar = NULL, shapePalette = NULL, shapeLab = toString(unique(getLabelVar(c(timeStartShapeVar, timeEndShapeVar), labelVars = labelVars))), shapeSize = rel(3), title = toString(getLabelVar(paramVar, labelVars = labelVars, label = paramLab)), label = title, caption, labelVars = NULL, formatReport = subjectProfileReportFormat(), paging = TRUE )
data |
Data.frame with data. |
paramVar |
Character vector with variable(s) of |
paramVarSep |
string with character(s) used to concatenate multiple
|
paramLab |
Named character vector,
with label for the parameter variable(s) ( |
paramGroupVar |
(optional) Character vector with variable(s)
of |
timeStartVar |
String, variable of |
timeStartLab |
String, label for |
timeEndVar |
String, variable of |
timeEndLab |
String, label for |
timeLab |
String, label for |
subjectVar |
String, variable of |
subjectSubset |
(optional) Character vector with subjects of interest
(available in |
subjectSample |
(optional) Integer of length 1 with number of random subject(s) that should be considered, e.g. to check the created patient profiles for a subset of the data. By default, all specified subjects are considered (set to NULL). |
seed |
(optional) Integer of length 1 with seed used to select random subjects
if |
subsetData |
(optional) Data.frame with extra dataset to filter on.
This dataset is filtered, and only records from |
subsetVar |
(optional) String with variable of subset data to filter on.
|
subsetValue |
(optional) Character vector with value(s) of interest to
retain in the filtered data.
These values should be available in |
timeImpType |
String with imputation type: 'minimal' (default),
'data-based' or 'none', see section: 'Time interval representation'. |
timeLim |
(optional) Vector of length 2 with time limits (x-axis).
If not specified, these are extracted from the minimum |
timeLimData |
Data.frame with data used to impute time
in case some time records are missing in |
timeLimStartVar |
String, variable of |
timeLimStartLab |
String, label for |
timeLimEndVar |
String, variable of |
timeLimEndLab |
String, label for |
timeTrans |
transformation for the time variable,
(see |
timeExpand |
Vector of range expansion constants for the time axis
(see |
timeAlign |
Logical, if TRUE (by default)
the different plots are horizontally aligned.
If set to FALSE, each plot has its own time-limits. |
xLab |
String, label for the x-axis. |
yLab |
String, label for the y-axis. |
colorVar |
String, variable of |
colorLab |
String, label for |
colorPalette |
Named vector with color palette.
The variable should be named with the corresponding element
in
|
alpha |
Numeric with transparency, 1 by default. |
timeStartShapeVar |
(optional) String, variable of |
timeEndShapeVar |
String, variable of |
shapePalette |
Named vector with (combined) shape palette for
|
shapeLab |
String with label for |
shapeSize |
Size for symbols (only used if |
title |
String with title, label of the parameter variable by default. |
label |
String, label for the visualization.
This label is stored as attributes of the output
from the |
caption |
(optional) String with caption (NULL for no caption). By default the caption contains information on the imputation strategy for missing time. |
labelVars |
Named character vector with variable labels (names are the variable code) |
formatReport |
list with parameters used to specify the format of the report,
e.g. output of the |
paging |
Logical, if TRUE (by default), automatic
paging is enabled, so patient profiles module too big to fit
in one page will span multiple pages.
Please note that the size of the graphic window
(or report page) may need
to be re-sized in order that the plot fits.
|
list of (across subjects) of list (across pages)
of ggplot2 objects
,
also of class subjectProfileIntervalPlot
.
with additional 'metaData' attributes containing
'label
', 'timeLim' timeTrans
and timeExpand
(if specified).
In case the start or the end of the time interval contain missing values:
if a dataset (timeLimData
), start (timeLimStartVar
)
and end (timeLimEndVar
) variables are specified:
for each subject:
the minimum and maximum time values across these specified time variables are extracted
missing start values are replaced by the minimum time
missing start values are replaced by the maximum time
if all values are missing for this subject, they are taken across subjects
otherwise, depending on the imputation type (timeImpType
):
'minimal' (by default):
if the start and the end of the interval are missing: no imputation is done, only the label is displayed
if the start time is missing and the end time is not missing: start time is imputed with end time, and status is set to 'Missing start'
if the end time is missing and the start time is not missing: end time is imputed with start time, and status is set to 'Missing end'
'data-based' (default in version < 1.0.0): minimum/maximum values in the start/end time variables in the data are considered for the specific subject (if available). If there are missing for a specific subject, they are taken across subjects. If all time are missings, the range is set to 0 and Inf
'none': no imputation is done
The symbols displayed at the start and end of the interval are:
by default:
a filled square labelled 'Complete' if the time is not missing
a filled left-directed arrow in case of missing start time
a filled right-directed arrow in case of missing end time
if the variable(s) used for the shape of the start or end
of the interval are specified (via
timeStartShapeVar
/timeEndShapeVar
):
labels are based on these variables, and a standard shape palette is used
The time limits are the same across subjects, and set to:
timeLim
if specified
maximum time range in timeLimStartVar
and
timeLimEndVar
in timeLimData
if specified
the maximum range on the data obtained after imputation of missing values
Laure Cougnaud
Other patient profiles plotting function:
subjectProfileEventPlot()
,
subjectProfileLinePlot()
,
subjectProfileTextPlot()
Visualize subject profiles of the evolution of continuous parameters versus time (spaghetti plot).
subjectProfileLinePlot( data, paramValueVar, paramLab = getLabelVar(paramValueVar, labelVars = labelVars), paramNameVar = NULL, paramVarSep = " - ", paramValueRangeVar = NULL, colorValueRange = "lightgreen", yLimFrom = c("all", "value"), colorVar = NULL, colorLab = getLabelVar(colorVar, labelVars = labelVars), colorPalette = NULL, shapeVar = colorVar, shapeLab = if (isTRUE(colorVar == shapeVar)) { colorLab } else getLabelVar(shapeVar, labelVars = labelVars), shapePalette = NULL, paramGroupVar = NULL, timeVar, timeLab = getLabelVar(timeVar, labelVars = labelVars), timeTrans = NULL, timeExpand = NULL, subjectVar = "USUBJID", subjectSubset = NULL, subjectSample = NULL, seed = 123, subsetData = NULL, subsetVar = NULL, subsetValue = NULL, xLab = timeLab, yLab = "", timeLim = NULL, title = toString(getLabelVar(paramValueVar, labelVars = labelVars, label = paramLab)), label = title, labelVars = NULL, formatReport = subjectProfileReportFormat(), paging = TRUE, alpha = 1, shapeSize = rel(1) )
subjectProfileLinePlot( data, paramValueVar, paramLab = getLabelVar(paramValueVar, labelVars = labelVars), paramNameVar = NULL, paramVarSep = " - ", paramValueRangeVar = NULL, colorValueRange = "lightgreen", yLimFrom = c("all", "value"), colorVar = NULL, colorLab = getLabelVar(colorVar, labelVars = labelVars), colorPalette = NULL, shapeVar = colorVar, shapeLab = if (isTRUE(colorVar == shapeVar)) { colorLab } else getLabelVar(shapeVar, labelVars = labelVars), shapePalette = NULL, paramGroupVar = NULL, timeVar, timeLab = getLabelVar(timeVar, labelVars = labelVars), timeTrans = NULL, timeExpand = NULL, subjectVar = "USUBJID", subjectSubset = NULL, subjectSample = NULL, seed = 123, subsetData = NULL, subsetVar = NULL, subsetValue = NULL, xLab = timeLab, yLab = "", timeLim = NULL, title = toString(getLabelVar(paramValueVar, labelVars = labelVars, label = paramLab)), label = title, labelVars = NULL, formatReport = subjectProfileReportFormat(), paging = TRUE, alpha = 1, shapeSize = rel(1) )
data |
Data.frame with data. |
paramValueVar |
String, variable of |
paramLab |
Named character vector,
with label for the parameter variable(s) ( |
paramNameVar |
Character vector with variable(s) of |
paramVarSep |
string with character(s) used to concatenate multiple
|
paramValueRangeVar |
Character vector of length 2 containing
variables of |
colorValueRange |
String with color for the filling of
the ribbon represented by |
yLimFrom |
String with specification on the limits of the y-axis, either:
|
colorVar |
String, variable of |
colorLab |
String, label for |
colorPalette |
Named vector with color palette.
The variable should be named with the corresponding element
in
|
shapeVar |
String, variable of |
shapeLab |
String, label for |
shapePalette |
Named character vector with shape palette
for
Note it is advised to specify the shapes as character,
e.g. 'cross' instead of |
paramGroupVar |
(optional) Character vector with variable(s)
of |
timeVar |
String, variable of |
timeLab |
String, label for |
timeTrans |
transformation for the time variable,
(see |
timeExpand |
Vector of range expansion constants for the time axis
(see |
subjectVar |
String, variable of |
subjectSubset |
(optional) Character vector with subjects of interest
(available in |
subjectSample |
(optional) Integer of length 1 with number of random subject(s) that should be considered, e.g. to check the created patient profiles for a subset of the data. By default, all specified subjects are considered (set to NULL). |
seed |
(optional) Integer of length 1 with seed used to select random subjects
if |
subsetData |
(optional) Data.frame with extra dataset to filter on.
This dataset is filtered, and only records from |
subsetVar |
(optional) String with variable of subset data to filter on.
|
subsetValue |
(optional) Character vector with value(s) of interest to
retain in the filtered data.
These values should be available in |
xLab |
String, label for the x-axis. |
yLab |
String, label for the y-axis. |
timeLim |
(optional) Vector of length 2 with time limits (x-axis).
If not specified, these are extracted from the minimum |
title |
String with title, label of the parameter value variable by default. |
label |
String, label for the visualization.
This label is stored as attributes of the output
from the |
labelVars |
Named character vector with variable labels (names are the variable code) |
formatReport |
list with parameters used to specify the format of the report,
e.g. output of the |
paging |
Logical, if TRUE (by default), automatic
paging is enabled, so patient profiles module too big to fit
in one page will span multiple pages.
Please note that the size of the graphic window
(or report page) may need
to be re-sized in order that the plot fits.
|
alpha |
Numeric with transparency, 1 by default. |
shapeSize |
Size for the symbols, any integer or
object supported by |
List of (across subjects) of list (across modules)
of ggplot2 objects
,
also of class subjectProfileLinePlot
.
Each subject profile contains attributes: 'subjectID' and 'nLines'
(estimated number of lines of space the plot will take).
The entire list also contains attributes: 'label
',
'timeLim' and 'timeTrans' (if specified).
Laure Cougnaud
Other patient profiles plotting function:
subjectProfileEventPlot()
,
subjectProfileIntervalPlot()
,
subjectProfileTextPlot()
This format is used to set default for the created subject profile report: line height, margin, report in landscape or portrait format, aspect ratio and width for the y-label.
subjectProfileReportFormat( heightLineIn = 0.2, margin = 0.75, landscape = FALSE, aspectRatio = 0.5, yLabelWidth = 30 )
subjectProfileReportFormat( heightLineIn = 0.2, margin = 0.75, landscape = FALSE, aspectRatio = 0.5, yLabelWidth = 30 )
heightLineIn |
Numeric of length 1 with height of a line in inches, 0.2 by default. |
margin |
Numeric of length 1, with margin in inches. |
landscape |
Logical, if TRUE the created report is in landscape format. FALSE by default, the report is created in portrait format. |
aspectRatio |
Numeric of length 1 (0.75 by default)
with ratio between size of image in inches
(derived from specified |
yLabelWidth |
Integer of length 1 with approximate maximum number of characters in the y-label of the plot, 30 by default. If the label of the y-axis is longer than this number of character, it will be splitted between words in separated lines. |
List with parameters to set format of the subject profile report. If not specified, default are used.
Laure Cougnaud
There are two ways to specify the variables of interest to include:
by specifying column(s) of interest containing parameter values, passed
to the paramValueVar
parameter.
In this case, variable value is displayed in the plot area,
and variable name in the label of the y-axis, as:
variable 1 | value 1 - value 2 - ...
variable 2 | value 1 - value 2 - ...
by specifying column(s) of interest containing parameter values,
displayed as a table
.
In this case, variable are displayed in columns
in the plot area. Variable names are displayed
on top of table, and associated values below, as:
| variable 1 variable 2
| value 1 value 1
| ...
by specifying a combination of a variable containing the parameter name
(paramNameVar
), coupled with a variable containing the
parameter values (paramValueVar
).
In this case, parameter values (if multiple) are concatenated
and displayed in the plot area for each parameter name,
displayed in the label of the y-axis, as:
variable name 1 | variable value 1 - variable value 2 - ...
variable name 2 | variable value 1 - ...
subjectProfileTextPlot( data, paramValueVar, paramValueLab = getLabelVar(paramValueVar, labelVars = labelVars), paramNameVar = NULL, paramGroupVar = NULL, subsetData = NULL, subsetVar = NULL, subsetValue = NULL, subjectVar = "USUBJID", subjectSubset = NULL, subjectSample = NULL, seed = 123, xLab = "", yLab = "", title = "Subject information", label = title, labelVars = NULL, paramVarSep = " - ", formatReport = subjectProfileReportFormat(), paging = TRUE, table = FALSE, colWidth = NULL )
subjectProfileTextPlot( data, paramValueVar, paramValueLab = getLabelVar(paramValueVar, labelVars = labelVars), paramNameVar = NULL, paramGroupVar = NULL, subsetData = NULL, subsetVar = NULL, subsetValue = NULL, subjectVar = "USUBJID", subjectSubset = NULL, subjectSample = NULL, seed = 123, xLab = "", yLab = "", title = "Subject information", label = title, labelVars = NULL, paramVarSep = " - ", formatReport = subjectProfileReportFormat(), paging = TRUE, table = FALSE, colWidth = NULL )
data |
Data.frame with data. |
paramValueVar |
Character vector, either:
|
paramValueLab |
(optional) Named character vector with
labels for |
paramNameVar |
(optional) Character vector of length 1 with
variable of |
paramGroupVar |
(optional) Character vector with variable(s)
of |
subsetData |
(optional) Data.frame with extra dataset to filter on.
This dataset is filtered, and only records from |
subsetVar |
(optional) String with variable of subset data to filter on.
|
subsetValue |
(optional) Character vector with value(s) of interest to
retain in the filtered data.
These values should be available in |
subjectVar |
String, variable of |
subjectSubset |
(optional) Character vector with subjects of interest
(available in |
subjectSample |
(optional) Integer of length 1 with number of random subject(s) that should be considered, e.g. to check the created patient profiles for a subset of the data. By default, all specified subjects are considered (set to NULL). |
seed |
(optional) Integer of length 1 with seed used to select random subjects
if |
xLab |
String, label for the x-axis. |
yLab |
String, label for the y-axis. |
title |
String with title, 'Subject information' by default. |
label |
String, label for the visualization.
This label is stored as attributes of the output
from the |
labelVars |
Named character vector with variable labels (names are the variable code) |
paramVarSep |
String (' - ' by default) with character(s) used to concatenate multiple variables for the same record in the plot area. |
formatReport |
list with parameters used to specify the format of the report,
e.g. output of the |
paging |
Logical, if TRUE (by default), automatic
paging is enabled, so patient profiles module too big to fit
in one page will span multiple pages.
Please note that the size of the graphic window
(or report page) may need
to be re-sized in order that the plot fits.
|
table |
Logical, if TRUE (FALSE by default) the information
contained in the variables: |
colWidth |
Numeric vector with approximate
width of each parameter value column
for a table layout. |
list of (across subjects) of list (across modules) of ggplot2 objects
,
also of class subjectProfileTextPlot
, with additional metaData
attributes containing
'label
' and 'timeLim'.
Laure Cougnaud
Other patient profiles plotting function:
subjectProfileEventPlot()
,
subjectProfileIntervalPlot()
,
subjectProfileLinePlot()
theme
for subject profile plot.
Currently classic dark-on-light ggplot2 theme with alternated
grey color for vertical grid linesCustom theme
for subject profile plot.
Currently classic dark-on-light ggplot2 theme with alternated
grey color for vertical grid lines
subjectProfileTheme()
subjectProfileTheme()
theme
object
Laure Cougnaud