| Title: | ESQlabs utilities package |
|---|---|
| Description: | The `{esqlabsR}` package facilitates and standardizes the modeling and simulation of physiologically based kinetic (PBK) and quantitative systems pharmacology/toxicology (QSP/T) models implemented in the [Open Systems Pharmacology Software](https://www.open-systems-pharmacology.org/) (OSPS). |
| Authors: | ESQlabs GmbH [cph, fnd], Pavel Balazki [cre, aut] (https://github.com/PavelBal), Johanna Eitel [aut], Indrajeet Patil [aut] (ORCID: <https://orcid.org/0000-0003-1995-6531>, Twitter: @patilindrajeets), Sergei Vavilov [aut], Felix Mil [aut], Sia Mirza [aut] |
| Maintainer: | Pavel Balazki <[email protected]> |
| License: | GPL-2 |
| Version: | 5.7.0.9005 |
| Built: | 2026-07-15 10:32:22 UTC |
| Source: | https://github.com/esqLABS/esqlabsR |
Adds scenario configurations to the project's Scenarios.xlsx file and ensures that required application protocol sheets exist in the Applications.xlsx file. This function handles the Excel file operations for adding scenarios to a project.
addScenarioConfigurationsToExcel( scenarioConfigurations, projectConfiguration, appendToExisting = TRUE )addScenarioConfigurationsToExcel( scenarioConfigurations, projectConfiguration, appendToExisting = TRUE )
scenarioConfigurations |
Named list of |
projectConfiguration |
A |
appendToExisting |
Logical. Whether to append new scenarios to existing ones in the
scenarios file. If |
This function performs the following operations:
Checks for duplicate scenario names if appendToExisting is TRUE.
Creates missing application protocol sheets in Applications.xlsx by extracting parameters from PKML files (both Events and Applications parameters).
Writes scenario configurations to the Scenarios.xlsx file with proper structure.
Manages output paths and their IDs in the OutputPaths sheet.
The function ensures that the Excel files are properly structured with the following sheets:
Scenarios sheet: Contains scenario definitions with columns for scenario name, individual/population IDs, parameter sheets, application protocol, simulation time, steady state settings, model file, and output path IDs.
OutputPaths sheet: Contains output path IDs and their corresponding paths.
When named vectors are used for outputPaths in scenario configurations, the names
will be used as OutputPathId values.
Applications.xlsx: Contains application protocol sheets with parameter definitions.
The function handles parameter extraction from PKML files, excluding default parameters like "Volume" and "Application rate", and only includes constant parameters.
Invisibly returns the names of the added scenarios.
## Not run: # Create scenario configurations from PKML scenarios <- createScenarioConfigurationsFromPKML( pkmlFilePaths = "path/to/simulation.pkml", projectConfiguration = projectConfiguration ) # Add scenarios to project Excel files addScenarioConfigurationsToExcel( scenarioConfigurations = scenarios, projectConfiguration = projectConfiguration, appendToExisting = TRUE ) ## End(Not run)## Not run: # Create scenario configurations from PKML scenarios <- createScenarioConfigurationsFromPKML( pkmlFilePaths = "path/to/simulation.pkml", projectConfiguration = projectConfiguration ) # Add scenarios to project Excel files addScenarioConfigurationsToExcel( scenarioConfigurations = scenarios, projectConfiguration = projectConfiguration, appendToExisting = TRUE ) ## End(Not run)
createIndividual are applied.Apply an individual to the simulation. For human species, only parameters
that do not override formulas are applied. For other species, all parameters
returned by createIndividual are applied.
applyIndividualParameters(individualCharacteristics, simulation)applyIndividualParameters(individualCharacteristics, simulation)
individualCharacteristics |
|
simulation |
|
## Not run: simulation <- loadSimulation(filePath = modelPath) humanIndividualCharacteristics <- createIndividualCharacteristics( species = Species$Human, population = HumanPopulation$European_ICRP_2002, gender = Gender$Male, weight = 70 ) applyIndividualParameters(humanIndividualCharacteristics, simulation) ## End(Not run)## Not run: simulation <- loadSimulation(filePath = modelPath) humanIndividualCharacteristics <- createIndividualCharacteristics( species = Species$Human, population = HumanPopulation$European_ICRP_2002, gender = Gender$Male, weight = 70 ) applyIndividualParameters(humanIndividualCharacteristics, simulation) ## End(Not run)
DataSet
objectsCalculate mean and standard deviation for the yValues of the given DataSet
objects
calculateMeanDataSet( dataSets, method = "arithmetic", lloqMode = LLOQMode$`LLOQ/2`, outputXunit = NULL, outputYunit = NULL, outputMolWeight = NULL )calculateMeanDataSet( dataSets, method = "arithmetic", lloqMode = LLOQMode$`LLOQ/2`, outputXunit = NULL, outputYunit = NULL, outputMolWeight = NULL )
dataSets |
list of |
method |
method for calculating the mean and standard deviation - either
|
lloqMode |
how to treat data points below LLOQ if LLOQ is given -
|
outputXunit |
xUnit of output data set, if |
outputYunit |
yUnit of output data set, if |
outputMolWeight |
molWeight of output data set in |
Calculates mean and standard deviation of the yValues of the given
DataSet objects per xValue. The meta data of the returned DataSet
consists of all meta data that are equal in all initial data sets. Its LLOQ
is the mean LLOQ value of all data sets which have an LLOQ set, e.g. if
dataSet1 has LLOQ 1, dataSet2 has LLOQ 3 and dataSet3 has no LLOQ, then 2
is used for the returned DataSet. The LLOQ of the returned DataSet is
the arithmetic mean of LLOQ values of all DataSets
A single DataSet object
Returns the HSV values for a given R color name
col2hsv(color)col2hsv(color)
color |
vector of any of the three kinds of R color specifications,
i.e., either a color name (as listed by colors()), a hexadecimal string of
the form "#rrggbb" or "#rrggbbaa" (see rgb), or a positive integer |
A matrix with a column for each color. The three rows of the matrix indicate hue, saturation and value and are named "h", "s", and "v" accordingly.
col2hsv("yellow")col2hsv("yellow")
Compare two simulations
compareSimulations(simulation1, simulation2, compareFormulasByValue = FALSE)compareSimulations(simulation1, simulation2, compareFormulasByValue = FALSE)
simulation1 |
First |
simulation2 |
Second |
compareFormulasByValue |
If |
The function compares two simulations and returns a list of entities that differ:
Parameters: a named list with a list of all Parameter entities that are:
in simulation1 but not in simulation 2 (In1NotIn2)
in simulation 2 but not in simulation 1 (I21NotIn1)
a list Different with all parameters which values differ between the simulations.
Two parameters are considered different if their formulas or values differ.
Named list with following levels:
Parameters with named lists In1NotIn2, In2NotIn1, and Different,
holding the Parameter objects that are present in the first but not in
the second simulation, present in the second but not in the first
simulation, and present in both simulations but with different formulas
and/or values, respectively.
isParametersEqual
## Not run: humanSim <- loadSimulation(file.path(modelFolder, "DefaultHuman.pkml")) ratSim <- loadSimulation(file.path(modelFolder, "DefaultRat.pkml")) diffParams <- compareSimulationParameters(humanSim, ratSim) ## End(Not run)## Not run: humanSim <- loadSimulation(file.path(modelFolder, "DefaultHuman.pkml")) ratSim <- loadSimulation(file.path(modelFolder, "DefaultRat.pkml")) diffParams <- compareSimulationParameters(humanSim, ratSim) ## End(Not run)
NA
Compare values including NA
compareWithNA(v1, v2)compareWithNA(v1, v2)
v1 |
Value or a list of values to compare. May include |
v2 |
Value or a list of values to compare. May include |
From http://www.cookbook-r.com/Manipulating_data/Comparing_vectors_or_factors_with_NA/
TRUE wherever elements are the same, including NA's,
Generate DataCombined objects as defined in excel file
createDataCombinedFromExcel( projectConfiguration, dataCombinedNames = NULL, plotGridNames = NULL, simulatedScenarios = NULL, observedData = NULL, stopIfNotFound = TRUE )createDataCombinedFromExcel( projectConfiguration, dataCombinedNames = NULL, plotGridNames = NULL, simulatedScenarios = NULL, observedData = NULL, stopIfNotFound = TRUE )
projectConfiguration |
Object of class |
dataCombinedNames |
Names of the DataCombined objects that will be
created. If a DataCombined with a given name is not defined in the Excel
file, an error is thrown. Can be used together with |
plotGridNames |
Names of the plot grid specified in the sheet
|
simulatedScenarios |
A list of simulated scenarios as returned by
|
observedData |
A list of |
stopIfNotFound |
If TRUE (default), the function stops if any of the simulated results or observed data are not found. If FALSE a warning is printed. |
A list of DataCombined objects, or an empty list if both
dataCombinedNames and plotGridNames are NULL or stopIfNotFound = TRUE and the specified DataCombined could not be created.
ProjectConfiguration
Create a ProjectConfiguration based on the
"ProjectConfiguration.xlsx"
createDefaultProjectConfiguration( path = file.path("ProjectConfiguration.xlsx"), ignoreVersionCheck = FALSE )createDefaultProjectConfiguration( path = file.path("ProjectConfiguration.xlsx"), ignoreVersionCheck = FALSE )
path |
path to the |
ignoreVersionCheck |
If |
Object of type ProjectConfiguration
ExportConfiguration R6 classAn instance of ExportConfiguration R6 class from {tlf} package is needed
for saving the plots and plot grids created using the {ospsuite} package.
The default attributes of the class are chosen to reflect the corporate standards adopted by esqLABS GmbH.
createEsqlabsExportConfiguration(outputFolder)createEsqlabsExportConfiguration(outputFolder)
outputFolder |
Path to the folder where the results will be stored. |
An instance of ExportConfiguration R6 class.
Other create-plotting-configurations:
createEsqlabsPlotConfiguration(),
createEsqlabsPlotGridConfiguration()
myProjConfig <- ProjectConfiguration$new() createEsqlabsExportConfiguration(myProjConfig$outputFolder)myProjConfig <- ProjectConfiguration$new() createEsqlabsExportConfiguration(myProjConfig$outputFolder)
DefaultPlotConfiguration R6 classAn instance of DefaultPlotConfiguration R6 class from {tlf} package is
needed for creating visualizations with the {ospsuite} package.
The default attributes of the class are chosen to reflect the corporate standards adopted by esqLABS GmbH.
createEsqlabsPlotConfiguration()createEsqlabsPlotConfiguration()
An instance of DefaultPlotConfiguration R6 class.
Other create-plotting-configurations:
createEsqlabsExportConfiguration(),
createEsqlabsPlotGridConfiguration()
createEsqlabsPlotConfiguration()createEsqlabsPlotConfiguration()
PlotGridConfiguration R6 classAn instance of PlotGridConfiguration R6 class from {tlf} package is
needed for creating a grid of multiple visualizations created using the
{ospsuite} package.
The default attributes of the class are chosen to reflect the corporate standards adopted by esqLABS GmbH.
createEsqlabsPlotGridConfiguration()createEsqlabsPlotGridConfiguration()
An instance of PlotGridConfiguration R6 class.
Other create-plotting-configurations:
createEsqlabsExportConfiguration(),
createEsqlabsPlotConfiguration()
createEsqlabsPlotGridConfiguration()createEsqlabsPlotGridConfiguration()
Creates ParameterIdentification objects from PI configurations. Each PITaskConfiguration produces one ParameterIdentification object.
createPITasks( piTaskConfigurations, observedData = NULL, stopIfParameterNotFound = TRUE )createPITasks( piTaskConfigurations, observedData = NULL, stopIfParameterNotFound = TRUE )
piTaskConfigurations |
Named list of |
observedData |
Named list of |
stopIfParameterNotFound |
Logical. If |
Named list of ParameterIdentification objects
## Not run: projectConfiguration <- createProjectConfiguration( exampleProjectConfigurationPath(), ignoreVersionCheck = TRUE ) piTaskConfigurations <- readPITaskConfigurationFromExcel( projectConfiguration = projectConfiguration ) piTasks <- createPITasks(piTaskConfigurations) ## End(Not run)## Not run: projectConfiguration <- createProjectConfiguration( exampleProjectConfigurationPath(), ignoreVersionCheck = TRUE ) piTaskConfigurations <- readPITaskConfigurationFromExcel( projectConfiguration = projectConfiguration ) piTasks <- createPITasks(piTaskConfigurations) ## End(Not run)
projectConfiguration$plotsFile
Generate plots as defined in excel file projectConfiguration$plotsFile
createPlotsFromExcel( plotGridNames = NULL, simulatedScenarios = NULL, observedData = NULL, dataCombinedList = NULL, projectConfiguration, outputFolder = NULL, stopIfNotFound = TRUE )createPlotsFromExcel( plotGridNames = NULL, simulatedScenarios = NULL, observedData = NULL, dataCombinedList = NULL, projectConfiguration, outputFolder = NULL, stopIfNotFound = TRUE )
plotGridNames |
Names of the plot grid specified in the sheet
|
simulatedScenarios |
A list of simulated scenarios as returned by
|
observedData |
A list of |
dataCombinedList |
A (named) list of |
projectConfiguration |
Object of class |
outputFolder |
Optional - path to the folder where the results will be
stored. If |
stopIfNotFound |
If TRUE (default), the function stops if any of the simulated results or observed data are not found. If FALSE a warning is printed. |
A list of ggplot objects
ProjectConfiguration
Create a ProjectConfiguration based on the
"ProjectConfiguration.xlsx"
createProjectConfiguration( path = file.path("ProjectConfiguration.xlsx"), ignoreVersionCheck = FALSE )createProjectConfiguration( path = file.path("ProjectConfiguration.xlsx"), ignoreVersionCheck = FALSE )
path |
path to the |
ignoreVersionCheck |
If |
Object of type ProjectConfiguration
Creates scenario configurations from PKML files by extracting available information such as applications, output paths, and simulation time settings. This function creates scenario configuration objects that can be used with the esqlabsR workflow.
createScenarioConfigurationsFromPKML( pkmlFilePaths, projectConfiguration, scenarioNames = NULL, individualId = NULL, populationId = NULL, applicationProtocols = NULL, paramSheets = NULL, outputPaths = NULL, simulationTime = NULL, simulationTimeUnit = NULL, steadyState = FALSE, steadyStateTime = NULL, steadyStateTimeUnit = NULL, readPopulationFromCSV = FALSE )createScenarioConfigurationsFromPKML( pkmlFilePaths, projectConfiguration, scenarioNames = NULL, individualId = NULL, populationId = NULL, applicationProtocols = NULL, paramSheets = NULL, outputPaths = NULL, simulationTime = NULL, simulationTimeUnit = NULL, steadyState = FALSE, steadyStateTime = NULL, steadyStateTimeUnit = NULL, readPopulationFromCSV = FALSE )
pkmlFilePaths |
Character vector of paths to PKML files to create scenarios from. Can be a single string (recycled for all scenarios) or a vector with the same length as the number of scenarios being created (determined by the longest vector argument). |
projectConfiguration |
A |
scenarioNames |
Character vector. Optional custom names for the scenarios. If |
individualId |
Character vector. Optional individual IDs to use for scenarios. If |
populationId |
Character vector. Optional population IDs to use for scenarios. If |
applicationProtocols |
Character vector. Optional application protocol names to use for scenarios.
If |
paramSheets |
Character vector. Optional parameter sheet names to apply to scenarios.
If |
outputPaths |
Character vector or named vector. Optional output paths to use for scenarios. If |
simulationTime |
Character vector. Optional simulation time to use for scenarios as character strings containing one or
multiple time intervals separated by a ';'. Each time interval is a triplet of values <StartTime, EndTime, Resolution>,
where |
simulationTimeUnit |
Character vector. Optional simulation time units. Only used when |
steadyState |
Logical vector. Whether to simulate steady-state for each scenario. Default is |
steadyStateTime |
Numeric vector. Steady-state times. Only used when corresponding |
steadyStateTimeUnit |
Character vector. Steady-state time units. Only used when |
readPopulationFromCSV |
Logical vector. Whether to read population from CSV for each scenario. Default is |
This function extracts the following information from PKML files:
Applications: Application protocol names (defaults to scenario name).
Output paths: All selected outputs for the simulation from outputSelections$allOutputs.
Simulation time: Time intervals with start time, end time, and resolution from outputSchema$intervals.
Simulation time unit: Time unit from the output schema intervals (e.g., "h" for hours).
All arguments support vectorization to create scenarios with different parameter values:
Length 1: The value is recycled (applied to all scenarios).
Length > 1: All vector arguments must have the same length, which determines the number of scenarios.
Mixed lengths: An error is thrown if vector arguments have inconsistent lengths.
The number of scenarios created is determined by the longest vector argument. All shorter vectors
(including pkmlFilePaths) are recycled to match this length.
This allows you to efficiently create multiple scenarios in several ways:
Same PKML, different settings: Use a single PKML file with vectors of different parameter values.
Different PKMLs, same settings: Use multiple PKML files with single parameter values.
Different PKMLs, different settings: Use vectors of both PKML files and parameter values.
The function handles duplicate scenario names by appending indices (e.g., "Scenario_1", "Scenario_2").
It creates scenario configurations but does not write them to Excel files.
Use addScenarioConfigurationsToExcel() to add the scenarios to the project's Excel files.
A named list of ScenarioConfiguration objects with the names being
the scenario names.
## Not run: # Create default project configuration projectConfiguration <- createDefaultProjectConfiguration() # Create scenarios from a single PKML file pkmlPath <- "path/to/simulation.pkml" scenarios <- createScenarioConfigurationsFromPKML( pkmlFilePaths = pkmlPath, projectConfiguration = projectConfiguration ) # Add scenarios to Excel configuration addScenarioConfigurationsToExcel( scenarioConfigurations = scenarios, projectConfiguration = projectConfiguration ) # Create scenarios from multiple PKML files with custom names pkmlPaths <- c("path/to/sim1.pkml", "path/to/sim2.pkml") scenarios <- createScenarioConfigurationsFromPKML( pkmlFilePaths = pkmlPaths, projectConfiguration = projectConfiguration, scenarioNames = c("Scenario1", "Scenario2") ) # Add multiple scenarios to configuration addScenarioConfigurationsToExcel( scenarioConfigurations = scenarios, projectConfiguration = projectConfiguration ) # Example of vector recycling - single value applied to all scenarios scenarios <- createScenarioConfigurationsFromPKML( pkmlFilePaths = c("sim1.pkml", "sim2.pkml", "sim3.pkml"), projectConfiguration = projectConfiguration, individualId = "Individual_001", # Recycled to all scenarios steadyState = TRUE, # Recycled to all scenarios steadyStateTime = 1000 # Recycled to all scenarios ) # Example of vector arguments - different values per scenario scenarios <- createScenarioConfigurationsFromPKML( pkmlFilePaths = c("pediatric.pkml", "adult.pkml", "elderly.pkml"), projectConfiguration = projectConfiguration, scenarioNames = c("Pediatric", "Adult", "Elderly"), individualId = c("Child_001", "Adult_001", "Elderly_001"), applicationProtocols = c("Pediatric_Dose", "Standard_Dose", "Reduced_Dose"), steadyState = c(FALSE, TRUE, TRUE), steadyStateTime = c(NA, 2000, 1500) ) # Example of PKML recycling - same model, different settings scenarios <- createScenarioConfigurationsFromPKML( pkmlFilePaths = "base_model.pkml", # Single PKML recycled projectConfiguration = projectConfiguration, scenarioNames = c("LowDose", "MediumDose", "HighDose"), individualId = c("Patient1", "Patient2", "Patient3"), applicationProtocols = c("Low_Protocol", "Med_Protocol", "High_Protocol"), steadyState = c(FALSE, TRUE, TRUE) # Different settings per scenario ) ## End(Not run)## Not run: # Create default project configuration projectConfiguration <- createDefaultProjectConfiguration() # Create scenarios from a single PKML file pkmlPath <- "path/to/simulation.pkml" scenarios <- createScenarioConfigurationsFromPKML( pkmlFilePaths = pkmlPath, projectConfiguration = projectConfiguration ) # Add scenarios to Excel configuration addScenarioConfigurationsToExcel( scenarioConfigurations = scenarios, projectConfiguration = projectConfiguration ) # Create scenarios from multiple PKML files with custom names pkmlPaths <- c("path/to/sim1.pkml", "path/to/sim2.pkml") scenarios <- createScenarioConfigurationsFromPKML( pkmlFilePaths = pkmlPaths, projectConfiguration = projectConfiguration, scenarioNames = c("Scenario1", "Scenario2") ) # Add multiple scenarios to configuration addScenarioConfigurationsToExcel( scenarioConfigurations = scenarios, projectConfiguration = projectConfiguration ) # Example of vector recycling - single value applied to all scenarios scenarios <- createScenarioConfigurationsFromPKML( pkmlFilePaths = c("sim1.pkml", "sim2.pkml", "sim3.pkml"), projectConfiguration = projectConfiguration, individualId = "Individual_001", # Recycled to all scenarios steadyState = TRUE, # Recycled to all scenarios steadyStateTime = 1000 # Recycled to all scenarios ) # Example of vector arguments - different values per scenario scenarios <- createScenarioConfigurationsFromPKML( pkmlFilePaths = c("pediatric.pkml", "adult.pkml", "elderly.pkml"), projectConfiguration = projectConfiguration, scenarioNames = c("Pediatric", "Adult", "Elderly"), individualId = c("Child_001", "Adult_001", "Elderly_001"), applicationProtocols = c("Pediatric_Dose", "Standard_Dose", "Reduced_Dose"), steadyState = c(FALSE, TRUE, TRUE), steadyStateTime = c(NA, 2000, 1500) ) # Example of PKML recycling - same model, different settings scenarios <- createScenarioConfigurationsFromPKML( pkmlFilePaths = "base_model.pkml", # Single PKML recycled projectConfiguration = projectConfiguration, scenarioNames = c("LowDose", "MediumDose", "HighDose"), individualId = c("Patient1", "Patient2", "Patient3"), applicationProtocols = c("Low_Protocol", "Med_Protocol", "High_Protocol"), steadyState = c(FALSE, TRUE, TRUE) # Different settings per scenario ) ## End(Not run)
Scenario objects from ScenarioConfiguration objectsLoad simulation. Apply parameters from global XLS. Apply individual physiology. Apply individual model parameters. Set simulation outputs. Set simulation time. initializeSimulation(). Create population
createScenarios( scenarioConfigurations, customParams = NULL, stopIfParameterNotFound = TRUE )createScenarios( scenarioConfigurations, customParams = NULL, stopIfParameterNotFound = TRUE )
scenarioConfigurations |
List of |
customParams |
A list containing vectors 'paths' with the full paths to the parameters, 'values' the values of the parameters, and 'units' with the units the values are in. The values will be applied to all scenarios. |
stopIfParameterNotFound |
Boolean. If |
Named list of Scenario objects.
Supported distributions for sampling
DistributionsDistributions
Add a new key-value pairs to an enum, where the value is a list.
enumPutList(key, values, enum, overwrite = FALSE)enumPutList(key, values, enum, overwrite = FALSE)
key |
Key to be added |
values |
Values to be added |
enum |
enum the key-value pairs should be added to. WARNING: the original object is not modified! |
overwrite |
if TRUE and a |
Enum with added key-value pair.
library(ospsuite.utils) myEnum <- enum(c(a = "b")) myEnum <- enumPut("c", "d", myEnum) myEnum <- enumPut(c("c", "d", "g"), list(12, 2, "a"), myEnum, overwrite = TRUE) myEnum <- enumPutList("g", list(12, 2, "a"), myEnum, overwrite = TRUE)library(ospsuite.utils) myEnum <- enum(c(a = "b")) myEnum <- enumPut("c", "d", myEnum) myEnum <- enumPut(c("c", "d", "g"), list(12, 2, "a"), myEnum, overwrite = TRUE) myEnum <- enumPutList("g", list(12, 2, "a"), myEnum, overwrite = TRUE)
Returns the list of colors extrapolated between the esqLABS colors blue, red, and green.
esqlabsColors(nrOfColors)esqlabsColors(nrOfColors)
nrOfColors |
Positive integer defining the number of colors to be generated. |
For nrOfColors == 1, the esqLABS-blue is returned For nrOfColors == 2,
the esqLABS-blue and green are returned For nrOfColors == 3, the
esqLABS-blue, red, and green are returned For nrOfColors > 3, the three
esqLABS colors are fixed, and the remaining colors are extrapolated from blue
to red to green. If nrOfColors is uneven, the blue-to-red section becomes
one color more than the red-to-green section. In this implementation,
blue-to-green is not considered.
A list of colors as HEX values.
getEsqlabsRSetting()
Names of the settings stored in esqlabsEnv Can be used with getEsqlabsRSetting()
esqlabsRSettingNamesesqlabsRSettingNames
Get the path to example ProjectConfiguration.xlsx
exampleProjectConfigurationPath()exampleProjectConfigurationPath()
A string representing the path to the example ProjectConfiguration.xlsx file
exampleProjectConfigurationPath()exampleProjectConfigurationPath()
Parallelize the execution of a function over a list of arguments values
executeInParallel( fun, firstArguments, exports = NULL, ..., outputNames = NULL, nrOfCores = ospsuite::getOSPSuiteSetting("numberOfCores") )executeInParallel( fun, firstArguments, exports = NULL, ..., outputNames = NULL, nrOfCores = ospsuite::getOSPSuiteSetting("numberOfCores") )
fun |
A function that will be called with different arguments values |
firstArguments |
A list of the values of the first argument of the
function. The function will be called |
exports |
Names of the objects in the calling environment that the
function relies on that are not passed as arguments. May be |
... |
Further arguments of the function. |
outputNames |
Optional: a list of names used for the output list. Result
of each execution of |
nrOfCores |
Optional: the maximal number of parallel threads. By default
the value defined in |
A list containing the outputs of the function fun iterated over
the values in firstArguments.
R6 class extending tlf::ExportConfiguration with row-aware height.
Inherits fields and behavior from tlf::ExportConfiguration.
See tlf::ExportConfiguration for name, path,
format, width, height, units, and dpi.
tlf::ExportConfiguration -> ExportConfiguration
heightPerRowThe height of the plot dimensions for a row in a
multi panel plot. The final height of the figure will be 'heightPerRow'
times the number of rows. If NULL (default), value used in height
is used. If not NULL, this value always overrides the height
property.
ExportConfiguration$savePlot()Save/Export a plot
ExportConfiguration$savePlot(plotObject, fileName = NULL)
plotObjectA ggplot object
fileNamecharacter file name of the exported plot
The file name of the exported plot
ExportConfiguration$clone()The objects of this class are cloneable with this method.
ExportConfiguration$clone(deep = FALSE)
deepWhether to make a deep clone.
Creates an excel file with information from the passed
parameters. The excel sheet will contain columns "Container Path",
"Parameter Name", "Value", and "Units". The resulting file can be loaded in
MoBi or in R with the function readParametersFromXLS().
exportParametersToXLS(parameters, paramsXLSpath, sheet = NULL, append = FALSE)exportParametersToXLS(parameters, paramsXLSpath, sheet = NULL, append = FALSE)
parameters |
A single or a list of |
paramsXLSpath |
Path to the excel file |
sheet |
(Optional) name of the excel sheet |
append |
If TRUE, appends parameters to existing file. If the file exists but the sheet doesn't exist, creates a new sheet. If FALSE (default), overwrites the existing file. |
Extend parameters structure with new entries
extendParameterStructure(parameters, newParameters)extendParameterStructure(parameters, newParameters)
parameters |
A parameter structure (a list with elements |
newParameters |
A parameter structure (a list with elements |
This function adds new parameter entries from newParameters to
parameters. If an entry with the same path is already present in
parameters, its value and unit will be overwritten with the values from
newParameters.
Updated list of parameter paths, values, and units
Add user defined variability on parameters to a population.
extendPopulationByUserDefinedParams( population, parameterPaths, meanValues, sdValues, distributions = Distributions$Normal )extendPopulationByUserDefinedParams( population, parameterPaths, meanValues, sdValues, distributions = Distributions$Normal )
population |
Object of type |
parameterPaths |
Vector of parameter path for which the variability is to be added. |
meanValues |
Vector of mean values of the parameters. Must have the same
length as |
sdValues |
Vector of standard deviation values of the parameters. Must
have the same length as |
distributions |
Type of distribution from which the random values will
be sampled. Must have the same length as |
Add user defined variability on parameters to a population from an excel file.
extendPopulationFromXLS(population, XLSpath, sheet = NULL)extendPopulationFromXLS(population, XLSpath, sheet = NULL)
population |
Object of type |
XLSpath |
Path to the excel file that stores the information of parameters. The file must have the columns "Container Path", "Parameter Name", "Mean", "SD", "Units", and "Distribution". Mean and SD values must be in the base units of the parameters. |
sheet |
Name or the index of the sheet in the excel file. If |
The method reads the information from the specified excel sheet(s)
and calls extendPopulationByUserDefinedParams
Possible gender entries as integer values
GenderIntGenderInt
Calculate geometric mean of a numeric vector
geomean(x, na.rm = FALSE, trim = 0)geomean(x, na.rm = FALSE, trim = 0)
x |
Numeric array to calculate geometric mean for |
na.rm |
A logical value indicating whether |
trim |
Fraction (0 to 0.5) of observations to be trimmed from each end
of |
Geometric mean of x
Calculate geometric standard deviation of a numeric vector
geosd(x, na.rm = FALSE)geosd(x, na.rm = FALSE)
x |
Numeric array |
na.rm |
A logical value indicating whether |
Geometric standard deviation of x
Get parameters of applications in the simulation
getAllApplicationParameters(simulation, moleculeNames = NULL)getAllApplicationParameters(simulation, moleculeNames = NULL)
simulation |
A |
moleculeNames |
Names of the molecules which applications parameters
will be returned. If |
Every application event has a ProtocolSchemaItem container that
holds parameters describing the dose, start time, infusion time etc. This
function returns a list of all constant parameters located under the
ProtocolSchemaItem container of applications defined for the
moleculeNames.
A list of Parameter objects defining the applications in the
simulation.
simPath <- system.file("extdata", "Aciclovir.pkml", package = "ospsuite") simulation <- loadSimulation(simPath) applicationParams <- getAllApplicationParameters(simulation = simulation) applicationParams <- getAllApplicationParameters( simulation = simulation, moleculeNames = "Aciclovir" )simPath <- system.file("extdata", "Aciclovir.pkml", package = "ospsuite") simulation <- loadSimulation(simPath) applicationParams <- getAllApplicationParameters(simulation = simulation) applicationParams <- getAllApplicationParameters( simulation = simulation, moleculeNames = "Aciclovir" )
Get the value of a global esqlabsR setting.
getEsqlabsRSetting(settingName)getEsqlabsRSetting(settingName)
settingName |
String name of the setting |
Value of the setting stored in esqlabsEnv. If the setting does not exist, an error is thrown.
getEsqlabsRSetting("packageVersion") getEsqlabsRSetting("packageName")getEsqlabsRSetting("packageVersion") getEsqlabsRSetting("packageName")
Find the index of the value in an array that is closest to given
one. By default, no restriction is applied how big the absolute numerical
distance between value and a value in the array may be. A limit can be
set by the parameters thresholdAbs or thresholdRel. If no value within
the array has the distance to value that is equal to or less than the
threshold, the value is considered not present in the array and NULL
is returned.
getIndexClosestToValue(value, array, thresholdAbs = NULL, thresholdRel = NULL)getIndexClosestToValue(value, array, thresholdAbs = NULL, thresholdRel = NULL)
value |
Numerical value |
array |
Numerical array |
thresholdAbs |
Absolute numerical distance by which the closest value in
|
thresholdRel |
A fraction by which the closest value may differ from
|
Index of a value within the array which is closest to value and
the difference is within the defined threshold. If multiple entries of
array have the same difference which is minimal, a vector of indices is
returned. If no value is within the defined threshold, NULL is returned.
Returns the name of the molecule to which the quantity object is associated. The quantity could be the amount of the molecule in a container ('Organism|VenousBlood|Plasma|Aciclovir'), a parameter of the molecule ('Aciclovir|Lipophilicity' or 'Organism|VenousBlood|Plasma|Aciclovir|Concentration'), or an observer ("Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral Venous Blood)").
If the quantity is not associated with a molecule (e.g. 'Organism|Weight'), an error is thrown.
getMoleculeNameFromQuantity(quantity)getMoleculeNameFromQuantity(quantity)
quantity |
A |
Name of the molecule the quantity is associated with.
simulation <- loadSimulation(system.file("extdata", "Aciclovir.pkml", package = "ospsuite")) quantity <- getQuantity( path = "Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral Venous Blood)", container = simulation ) getMoleculeNameFromQuantity(quantity = quantity)simulation <- loadSimulation(system.file("extdata", "Aciclovir.pkml", package = "ospsuite")) quantity <- getQuantity( path = "Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral Venous Blood)", container = simulation ) getMoleculeNameFromQuantity(quantity = quantity)
Helper method that combines a set of common steps performed before running a simulation. This method applies individual parameters data set and additional user-defined parameters to the simulation and runs the simulation to its steady-state and applies the steady-state as new initial conditions.
initializeSimulation( simulation, individualCharacteristics = NULL, additionalParams = NULL, stopIfParameterNotFound = TRUE )initializeSimulation( simulation, individualCharacteristics = NULL, additionalParams = NULL, stopIfParameterNotFound = TRUE )
simulation |
|
individualCharacteristics |
Optional |
additionalParams |
Optional named list with lists 'paths', 'values', and 'units'. |
stopIfParameterNotFound |
Logical. If |
## Not run: simulation <- loadSimulation(filePath = modelPath) humanIndividualCharacteristics <- createIndividualCharacteristics( species = Species$Human, population = HumanPopulation$European_ICRP_2002, gender = Gender$Male, weight = 70 ) userParams <- readParametersFromXLS(parameterXLSPath) initializeSimulation(simulation, humanIndividualCharacteristics, userParams) simulationResults <- runSimulations(simulation = simulation) ## End(Not run)## Not run: simulation <- loadSimulation(filePath = modelPath) humanIndividualCharacteristics <- createIndividualCharacteristics( species = Species$Human, population = HumanPopulation$European_ICRP_2002, gender = Gender$Male, weight = 70 ) userParams <- readParametersFromXLS(parameterXLSPath) initializeSimulation(simulation, humanIndividualCharacteristics, userParams) simulationResults <- runSimulations(simulation = simulation) ## End(Not run)
Creates the default project folder structure with Excel file templates in the working directory.
initProject(destination = ".", overwrite = FALSE)initProject(destination = ".", overwrite = FALSE)
destination |
A string defining the path where to initialize the project. default to current working directory. |
overwrite |
If TRUE, overwrites existing project without asking for permission. If FALSE and a project already exists, asks user for permission to overwrite. |
Check if validation results contain any critical errors
isAnyCriticalErrors(validationResults)isAnyCriticalErrors(validationResults)
validationResults |
Output from validateAllConfigurations |
Logical indicating if there are critical errors
Check if two parameters are equal with respect to certain properties.
isParametersEqual( parameter1, parameter2, checkFormulaValues = FALSE, compareFormulasByValue = FALSE )isParametersEqual( parameter1, parameter2, checkFormulaValues = FALSE, compareFormulasByValue = FALSE )
parameter1 |
First parameter to compare |
parameter2 |
Second parameter to compare |
checkFormulaValues |
If TRUE, values of explicit formulas are always compared. Otherwise, the values are only compared if the formulas are overridden (isFixedValue == TRUE). FALSE by default. |
compareFormulasByValue |
If |
The parameters are not equal if: The paths of the parameters are not equal; The types of the formulas differ (types checked: isConstant, isDistributed, isExplicit, isTable); Constant formulas have different values; Distributed formulas have different values (not checking for distribution) Explicit formulas: If formula string are not equal, OR one of the parameter values is fixed (formula is overridden), OR both parameter values are fixed and differ, OR checkFormulaValues is TRUE and the values differ (disregarding of overridden or not) Table formulas: If the number of points differ, OR any of the points differ, OR one of the parameter values is fixed (formula is overridden), OR both parameter values are fixed and differ.
TRUE if parameters are considered equal, FALSE otherwise
Checks if a directory already contains an esqlabsR project by looking for the presence of ProjectConfiguration.xlsx file or Configurations folder.
isProjectInitialized(destination = ".")isProjectInitialized(destination = ".")
destination |
A string defining the path to check for an existing project. Defaults to current working directory. |
TRUE if an esqlabsR project exists in the directory, FALSE otherwise.
## Not run: # Check if current directory has a project hasProject <- isProjectInitialized() # Check if specific directory has a project hasProject <- isProjectInitialized("path/to/project") ## End(Not run)## Not run: # Check if current directory has a project hasProject <- isProjectInitialized() # Check if specific directory has a project hasProject <- isProjectInitialized("path/to/project") ## End(Not run)
Table formulas are equal if the number of points is equal and all x-y value pairs are equal between the two formulas
isTableFormulasEqual(formula1, formula2)isTableFormulasEqual(formula1, formula2)
formula1 |
First formula to compare |
formula2 |
Second formula to compare |
TRUE if the table formulas are equal, FALSE otherwise
lloqMode argument of calculateMeans()
Possible entries for the lloqMode argument of calculateMeans()
LLOQModeLLOQMode
Loads data sets from excel. The excel file containing the data
must be located in the folder projectConfiguration$dataFolder and be
named projectConfiguration$dataFile. Importer configuration file must be
located in the same folder and named
projectConfiguration$dataImporterConfigurationFile.
loadObservedData( projectConfiguration, sheets = NULL, importerConfiguration = NULL )loadObservedData( projectConfiguration, sheets = NULL, importerConfiguration = NULL )
projectConfiguration |
Object of class |
sheets |
String or a list of strings defining which sheets to load. If
|
importerConfiguration |
|
A named list of DataSet objects, with names being the names of the
data sets.
## Not run: # Create default project configuration projectConfiguration <- createProjectConfiguration() dataSets <- loadObservedData(projectConfiguration) ## End(Not run)## Not run: # Create default project configuration projectConfiguration <- createProjectConfiguration() dataSets <- loadObservedData(projectConfiguration) ## End(Not run)
Loads data sets that are exported as pkml. The files must be
located in the folder projectConfiguration$dataFolder, subfolder pkml.
and be named projectConfiguration$dataFile.
loadObservedDataFromPKML(projectConfiguration, obsDataNames = NULL)loadObservedDataFromPKML(projectConfiguration, obsDataNames = NULL)
projectConfiguration |
Object of class |
obsDataNames |
String or a list of strings defining data sets to load If
|
A named list of DataSet objects, with names being the names of the
data sets.
## Not run: # Create default project configuration projectConfiguration <- createProjectConfiguration() dataSets <- loadObservedData(projectConfiguration) ## End(Not run)## Not run: # Create default project configuration projectConfiguration <- createProjectConfiguration() dataSets <- loadObservedData(projectConfiguration) ## End(Not run)
Load simulated scenarios from csv and pkml.
loadScenarioResults(scenarioNames, resultsFolder)loadScenarioResults(scenarioNames, resultsFolder)
scenarioNames |
Names of simulated scenarios |
resultsFolder |
Path to the folder where simulation results as csv and the corresponding simulations as pkml are located. |
This function requires simulation results AND the corresponding
simulation files being located in the same folder (resultsFolder) and have
the names of the scenarios.
A named list, where the names are scenario names, and the values are
lists with the entries simulation being the initialized Simulation object with applied parameters,
results being SimulatioResults object produced by running the simulation,
and outputValues the output values of the SimulationResults.
## Not run: # First simulate scenarios and save the results projectConfiguration <- esqlabsR::createProjectConfiguration() scenarioConfigurations <- readScenarioConfigurationFromExcel( projectConfiguration = projectConfiguration ) scenarios <- createScenarios(scenarioConfigurations = scenarioConfigurations) simulatedScenariosResults <- runScenarios( scenarios = scenarios ) saveResults(simulatedScenariosResults, projectConfiguration) # Now load the results scnarioNames <- names(scenarios) simulatedScenariosResults <- loadScenarioResults( scnarioNames = scnarioNames, resultsFolder = pathToTheFolder ) ## End(Not run)## Not run: # First simulate scenarios and save the results projectConfiguration <- esqlabsR::createProjectConfiguration() scenarioConfigurations <- readScenarioConfigurationFromExcel( projectConfiguration = projectConfiguration ) scenarios <- createScenarios(scenarioConfigurations = scenarioConfigurations) simulatedScenariosResults <- runScenarios( scenarios = scenarios ) saveResults(simulatedScenariosResults, projectConfiguration) # Now load the results scnarioNames <- names(scenarios) simulatedScenariosResults <- loadScenarioResults( scnarioNames = scnarioNames, resultsFolder = pathToTheFolder ) ## End(Not run)
Restores a previously saved sensitivity calculation from a directory created
with saveSensitivityCalculation(). If no simulation object is provided, the
function loads the simulation.pkml bundled in the directory, falling back to
the simulation file path stored in the metadata for folders saved before the
pkml was bundled.
loadSensitivityCalculation(outputDir, simulation = NULL)loadSensitivityCalculation(outputDir, simulation = NULL)
outputDir |
Path to the directory containing the saved sensitivity calculation files. |
simulation |
Optional. A |
A named list of class SensitivityCalculation.
## Not run: # Load sensitivity analysis result from disk sensitivityCalculation <- loadSensitivityCalculation("output/my-sensitivity") ## End(Not run)## Not run: # Load sensitivity analysis result from disk sensitivityCalculation <- loadSensitivityCalculation("output/my-sensitivity") ## End(Not run)
Converts the Windows-like path (using \) from the clipboard to the form
readable by R (using /).
pathFromClipboard(path = "clipboard")pathFromClipboard(path = "clipboard")
path |
Path that will be converted. If |
String representation of a file path with / as separator.
An object storing configuration for a parameter identification
(PI) task. This class holds references to PI task settings defined in
ParameterIdentification.xlsx.
projectConfigurationProjectConfiguration that will be used.
Read-only.
taskNameName of the PI task. Key for lookup in
ParameterIdentification.xlsx. Read-only.
scenarioConfigurationNamed list of ScenarioConfiguration
objects for the PI task. Read-only.
piConfigurationNamed list of PI settings: algorithm, ciMethod, printEvaluationFeedback, autoEstimateCI, simulationRunOptions, objectiveFunctionOptions, algorithmOptions, ciOptions. Read-only.
piParametersNamed list of parameter configurations from PIParameters sheet. Read-only.
piOutputMappingsNamed list of output mapping configurations from PIOutputMappings sheet. Read-only.
PITaskConfiguration$new()Initialize a new instance of the class
PITaskConfiguration$new( taskName, projectConfiguration, scenarioConfiguration, piDefinitions = NULL )
taskNameCharacter. Name of the PI task (key for lookup in Excel).
projectConfigurationAn object of class ProjectConfiguration.
scenarioConfigurationAn object of class ScenarioConfiguration
or a named list of ScenarioConfiguration objects.
piDefinitionsNamed list containing:
piConfiguration: Named list of PI settings
piParameters: Named list of PI parameter configurations
piOutputMappings: Named list of PI output mapping configurations
A new PITaskConfiguration object.
PITaskConfiguration$print()Print the object to the console
PITaskConfiguration$print( className = TRUE, projectConfiguration = FALSE, scenarioConfiguration = FALSE )
classNameWhether to print the name of the class at the beginning. Default is TRUE.
projectConfigurationWhether to also print project configuration. Default is FALSE.
scenarioConfigurationWhether to also print scenario configurations. Default is FALSE.
PITaskConfiguration$clone()The objects of this class are cloneable with this method.
PITaskConfiguration$clone(deep = FALSE)
deepWhether to make a deep clone.
An object storing configuration used project-wide
projectConfigurationFilePathPath to the file that serve as base path for other parameters. If NULL, then, other paths should be absolute paths.
projectConfigurationDirPathPath to the folder that serve as base path for other paths. If NULL, then, other paths should be absolute paths.
modifiedLogical indicating whether any configuration properties have been modified since loading from file. Read-only.
modelFolderPath to the folder containing pkml simulation files.
configurationsFolderPath to the folder containing excel files with model parameterization.
modelParamsFileName of the excel file with global model parameterization. Must be located in the "configurationsFolder".
individualsFileName of the excel file with individual-specific model parameterization. Must be located in the "configurationsFolder".
populationsFileName of the excel file with population information. Must be located in the "configurationsFolder".
populationsFolderName of the folder containing population defined through csv files. Must be located in the "configurationsFolder".
scenariosFileName of the excel file with scenario definitions. Must be located in the "configurationsFolder".
applicationsFileName of the excel file scenario-specific parameters such as application protocol parameters. Must be located in the "configurationsFolder".
plotsFileName of the excel file with plot definitions. Must be located in the "configurationsFolder".
parameterIdentificationFileName of the excel file with parameter identification definitions. Must be located in the "configurationsFolder".
dataFolderPath to the folder where experimental data files are located.
dataFileName of the excel file with experimental data. Must be located in the "dataFolder"
dataImporterConfigurationFileName of data importer configuration file in xml format used to load the data. Must be located in the "dataFolder"
outputFolderPath to the folder where the results should be saved relative to the "Code" folder
esqlabsRVersionVersion of the esqlabsR package stored in the project configuration. Read-only. Initialize
ProjectConfiguration$new()ProjectConfiguration$new( projectConfigurationFilePath = character(), ignoreVersionCheck = FALSE )
projectConfigurationFilePathA string representing the path to the project configuration file.
ignoreVersionCheckIf TRUE, skip the version mismatch check when
loading the configuration file. Defaults to FALSE.
Print
ProjectConfiguration$print()print prints a summary of the Project Configuration.
ProjectConfiguration$print(className = TRUE)
classNameWhether to print the name of the class at the beginning. default to TRUE.
ProjectConfiguration$save()Export ProjectConfiguration object to ProjectConfiguration.xlsx
ProjectConfiguration$save(path)
patha string representing the path or file name where to save the file. Can be absolute or relative (to working directory).
ProjectConfiguration$clone()The objects of this class are cloneable with this method.
ProjectConfiguration$clone(deep = FALSE)
deepWhether to make a deep clone.
Compares Excel configuration files against their JSON snapshot to determine if they are synchronized. The JSON snapshot is considered the source of truth.
projectConfigurationStatus( projectConfig = "ProjectConfiguration.xlsx", jsonPath = NULL, silent = FALSE, ignoreVersionCheck = TRUE )projectConfigurationStatus( projectConfig = "ProjectConfiguration.xlsx", jsonPath = NULL, silent = FALSE, ignoreVersionCheck = TRUE )
projectConfig |
A ProjectConfiguration object or path to ProjectConfiguration excel file. Defaults to "ProjectConfiguration.xlsx". |
jsonPath |
Path to the JSON configuration file. If NULL (default), the function will look for a JSON file with the same name as the ProjectConfiguration file but with .json extension. |
silent |
Logical indicating whether to suppress informational messages. Defaults to FALSE. |
ignoreVersionCheck |
Logical. If |
A list with components:
in_sync |
Logical indicating whether all files are synchronized |
details |
A list with detailed comparison results for each file |
unsaved_changes |
Logical indicating whether the ProjectConfiguration object has unsaved modifications |
Other project configuration snapshots:
restoreProjectConfiguration(),
snapshotProjectConfiguration()
readxl::read_excel with suppressed warningsRead XLSX files using readxl::read_excel with suppressed warnings
readExcel(path, sheet = NULL, ...)readExcel(path, sheet = NULL, ...)
path |
Full path of an XLS/XLSX file |
sheet |
Name or number of the sheet. If |
... |
Any other parameters that can be passed to |
A tibble with the contents of the excel sheet
Read individual characteristics from file
readIndividualCharacteristicsFromXLS( XLSpath, individualId, sheet = "IndividualBiometrics", nullIfNotFound = TRUE )readIndividualCharacteristicsFromXLS( XLSpath, individualId, sheet = "IndividualBiometrics", nullIfNotFound = TRUE )
XLSpath |
Full path to the excel file |
individualId |
(String) Id of the individual as stored in the
|
sheet |
Name of the sheet. If |
nullIfNotFound |
Boolean. If |
Read individual characteristics from an excel sheet
and create an IndividualCharacteristics-object. The excel sheet must have
the columns IndividualId, Species, Population, Gender, Weight [kg],
Height [cm], Age [year(s)], and Protein Ontogenies.
An IndividualCharacteristics object
Read parameter values from a structured Excel file. Each excel sheet must consist of columns 'Container Path', 'Parameter Name', 'Value', and 'Units'
readParametersFromXLS(paramsXLSpath, sheets = NULL)readParametersFromXLS(paramsXLSpath, sheets = NULL)
paramsXLSpath |
Path to the excel file |
sheets |
Names of the excel sheets containing the information about the parameters. Multiple sheets can be processed. If no sheets are provided, the first one in the Excel file is used. |
A list containing vectors paths with the full paths to the
parameters, values the values of the parameters, and units with the
units the values are in.
Read Parameter Identification configurations from Excel
readPITaskConfigurationFromExcel(piTaskNames = NULL, projectConfiguration)readPITaskConfigurationFromExcel(piTaskNames = NULL, projectConfiguration)
piTaskNames |
Character vector. Names of the parameter identification
tasks that are defined in the Excel file. If |
projectConfiguration |
A |
Reads PI task configuration from the Excel file defined in
ProjectConfiguration and creates PITaskConfiguration objects. If a PI
task that is specified in piTaskNames is not found in the Excel file, an
error is thrown.
The function expects the Excel file to have a "PIOutputMappings" sheet with
PITaskName, Scenarios, OutputPath, ObservedDataSheet, DataSet,
Scaling, xOffset, yOffset, xFactor, yFactor, Weight columns.
OutputPath accepts either a full simulation output path or an
OutputPathId defined in the "OutputPaths" sheet of Scenarios.xlsx. It
also expects a "PIParameters" sheet with PITaskName, Scenarios,
Container Path, Parameter Name, Units, MinValue, MaxValue,
StartValue, Group columns, an optional "PIConfiguration" sheet with
PITaskName, Algorithm, CIMethod, PrintEvaluationFeedback,
AutoEstimateCI, numberOfCores, checkForNegativeValues,
ObjectiveFunctionType, ResidualWeightingMethod, RobustMethod,
ScaleVar, LinScaleCV, LogScaleSD columns, an "AlgorithmOptions" sheet
with PITaskName, OptionName, OptionValue columns, and a "CIOptions"
sheet with PITaskName, OptionName, OptionValue columns.
A named list of PITaskConfiguration objects.
## Not run: projectConfiguration <- createProjectConfiguration( exampleProjectConfigurationPath(), ignoreVersionCheck = TRUE ) piTaskConfigurations <- readPITaskConfigurationFromExcel( piTaskNames = "AciclovirSimple", projectConfiguration = projectConfiguration ) ## End(Not run)## Not run: projectConfiguration <- createProjectConfiguration( exampleProjectConfigurationPath(), ignoreVersionCheck = TRUE ) piTaskConfigurations <- readPITaskConfigurationFromExcel( piTaskNames = "AciclovirSimple", projectConfiguration = projectConfiguration ) ## End(Not run)
PopulationCharacteristics objectRead an excel file containing information about population and create a
PopulationCharacteristics object
readPopulationCharacteristicsFromXLS(XLSpath, populationName, sheet = NULL)readPopulationCharacteristicsFromXLS(XLSpath, populationName, sheet = NULL)
XLSpath |
Path to the excel file |
populationName |
Name of the population, as defined in the "PopulationName" column |
sheet |
Name or the index of the sheet in the excel file. If |
A PopulationCharacteristics object based on the information in the
excel file.
Read scenario definition(s) from Excel file
readScenarioConfigurationFromExcel(scenarioNames = NULL, projectConfiguration)readScenarioConfigurationFromExcel(scenarioNames = NULL, projectConfiguration)
scenarioNames |
Character vector. Names of the scenarios that are
defined in the Excel file. If |
projectConfiguration |
A |
Reads scenario definition from the Excel file defined in
ProjectConfiguration and creates ScenarioConfiguration objects with new
information. If a scenario that is specified in scenarioNames is not
found in the Excel file, an error is thrown.
The function expects the Excel file to have a "Scenarios" sheet with the
following columns: Scenario_name, IndividualId, PopulationId,
ReadPopulationFromCSV, ModelParameterSheets, ApplicationProtocol,
SimulationTime, SimulationTimeUnit, SteadyState, SteadyStateTime,
SteadyStateTimeUnit, ModelFile, OutputPathsIds. It also expects an
"OutputPaths" sheet with OutputPathId and OutputPath columns.
A named list of ScenarioConfiguration objects with the names of
the list being scenario names.
## Not run: # Create default ProjectConfiguration projectConfiguration <- createProjectConfiguration(ignoreVersionCheck = TRUE) scenarioName <- "MyScenario" # Read scenario definition from Excel scenarioConfiguration <- readScenarioConfigurationFromExcel( scenarioNames = scenarioName, projectConfiguration )[[scenarioName]] ## End(Not run)## Not run: # Create default ProjectConfiguration projectConfiguration <- createProjectConfiguration(ignoreVersionCheck = TRUE) scenarioName <- "MyScenario" # Read scenario definition from Excel scenarioConfiguration <- readScenarioConfigurationFromExcel( scenarioNames = scenarioName, projectConfiguration )[[scenarioName]] ## End(Not run)
Removes all occurrences of the entry from the list. If the entry is not in the list nothing is removed.
removeFromList(entry, listArg)removeFromList(entry, listArg)
entry |
The entry to be removed |
listArg |
The list from which the entry will be removed |
The list without the entry. If the input is a vector, it is converted to a list.
myList <- list("one", "two", "one", "three") myList <- removeFromList("one", myList) print(myList)myList <- list("one", "two", "one", "three") myList <- removeFromList("one", myList) print(myList)
Creates Excel configuration files from a JSON configuration file. This allows for recreating the project configuration from version-controlled JSON.
restoreProjectConfiguration( jsonPath = "ProjectConfiguration.json", outputDir = NULL, silent = FALSE )restoreProjectConfiguration( jsonPath = "ProjectConfiguration.json", outputDir = NULL, silent = FALSE )
jsonPath |
Path to the JSON configuration file. Defaults to "ProjectConfiguration.json". |
outputDir |
Directory where the Excel files will be created. If NULL (default), the Excel files will be created in the same directory as the source JSON file. |
silent |
Logical. If |
A ProjectConfiguration object initialized with the regenerated ProjectConfiguration.xlsx
Other project configuration snapshots:
projectConfigurationStatus(),
snapshotProjectConfiguration()
Executes parameter identification for all PI tasks. Handles failures gracefully - continues with other tasks if one fails.
runPI(piTasks)runPI(piTasks)
piTasks |
Named list of |
Named list of PI results. Each result contains:
task: original ParameterIdentification object
result: PIResult object from task$run(), or NULL if failed
error: Error message string if failed, absent on success
## Not run: # After creating PI tasks piResults <- runPI(piTasks) ## End(Not run)## Not run: # After creating PI tasks piResults <- runPI(piTasks) ## End(Not run)
Run a set of scenarios.
runScenarios(scenarios, simulationRunOptions = NULL)runScenarios(scenarios, simulationRunOptions = NULL)
scenarios |
List of |
simulationRunOptions |
Object of type |
If simulation of a scenario fails, a warning is produced, and the
outputValues for this scenario is NULL.
A named list, where the names are scenario names, and the values are
lists with the entries simulation being the initialized Simulation
object with applied parameters, results being SimulatioResults object
produced by running the simulation, outputValues the output values of the
SimulationResults, and population the Population object if the
scenario is a population simulation.
Sample a random value from a distribution
sampleRandomValue(distribution, mean, sd, n)sampleRandomValue(distribution, mean, sd, n)
distribution |
The type of the distribution the random variable is to be
sampled from. See |
mean |
Mean value of the random variable |
sd |
Standard deviation of the random variable |
n |
Size of the sample |
Numerical vector of size n with randomly sampled values
Save results of scenario simulations to csv.
saveScenarioResults( simulatedScenariosResults, projectConfiguration, outputFolder = NULL, saveSimulationsToPKML = TRUE )saveScenarioResults( simulatedScenariosResults, projectConfiguration, outputFolder = NULL, saveSimulationsToPKML = TRUE )
simulatedScenariosResults |
Named list with |
projectConfiguration |
An instance of |
outputFolder |
Optional - path to the folder where the results will be
stored. If |
saveSimulationsToPKML |
If |
For each scenario, a separate csv file will be created. If the scenario
is a population simulation, a population is stored along with the results with
the file name suffix _population. Results can be read with the loadScenarioResults() function.
outputFolder or the created output folder path, if no outputFolder was provided.
## Not run: projectConfiguration <- esqlabsR::createProjectConfiguration() scenarioConfigurations <- readScenarioConfigurationFromExcel( projectConfiguration = projectConfiguration ) scenarios <- createScenarios(scenarioConfigurations = scenarioConfigurations) simulatedScenariosResults <- runScenarios( scenarios = scenarios ) saveScenarioResults(simulatedScenariosResults, projectConfiguration) ## End(Not run)## Not run: projectConfiguration <- esqlabsR::createProjectConfiguration() scenarioConfigurations <- readScenarioConfigurationFromExcel( projectConfiguration = projectConfiguration ) scenarios <- createScenarios(scenarioConfigurations = scenarioConfigurations) simulatedScenariosResults <- runScenarios( scenarios = scenarios ) saveScenarioResults(simulatedScenariosResults, projectConfiguration) ## End(Not run)
Saves the results of a sensitivity analysis to a specified directory,
including metadata and simulation output required for restoring or sharing
the analysis. The underlying simulation is written to simulation.pkml in the
same directory so the saved calculation is self-contained and can be reloaded
without access to the original simulation file.
saveSensitivityCalculation( sensitivityCalculation, outputDir, overwrite = FALSE )saveSensitivityCalculation( sensitivityCalculation, outputDir, overwrite = FALSE )
sensitivityCalculation |
A named list of class |
outputDir |
A character string specifying the path to the directory where the results should be saved. |
overwrite |
Logical. If |
Invisibly returns NULL. Results are saved to disk in the specified
folder.
## Not run: sensitivityCalculation <- sensitivityCalculation( simulation = mySim, outputPaths = "Organism|PeripheralVenousBlood|Drug|Plasma", parameterPaths = c("Drug|Lipophilicity", "Application|Dose") ) saveSensitivityCalculation( sensitivityCalculation, outputDir = "output/my-sensitivity", overwrite = TRUE ) ## End(Not run)## Not run: sensitivityCalculation <- sensitivityCalculation( simulation = mySim, outputPaths = "Organism|PeripheralVenousBlood|Drug|Plasma", parameterPaths = c("Drug|Lipophilicity", "Application|Dose") ) saveSensitivityCalculation( sensitivityCalculation, outputDir = "output/my-sensitivity", overwrite = TRUE ) ## End(Not run)
Simulation scenario
scenarioConfigurationscenarioConfiguration used for creation of
this scenario. Read-only.
finalCustomParamsCustom parameters to be used for the simulation. Read-only.
simulationSimulation object created from the
ScenarioConfiguration. Read-only
populationPopulation object in case the scenario is a population simulation. Read-only.
scenarioTypeType of the scenario - individual or population. Read-only
Scenario$new()Custom parameters to be used for the simulation. The final
custom parameters are a combination of parametrization through the
excel files and the custom parameters specified by the user through the
customParams argument of the Scenario constructor.
Simulation object. Read-only.
Initialize a new instance of the class. Initializes the
scenario from ScenarioConfiguration object.
Scenario$new( scenarioConfiguration, customParams = NULL, stopIfParameterNotFound = TRUE )
scenarioConfigurationAn object of class ScenarioConfiguration.
customParamsCustom parameters to be used for the simulation. A list containing vectors 'paths' with the full paths to the parameters, 'values' the values of the parameters, and 'units' with the units the values are in.
stopIfParameterNotFoundLogical. If TRUE (default), an error is
thrown if any of the custom defined parameter does not exist. If
FALSE, non-existent parameters are ignored.
A new Scenario object.
Scenario$print()Print the object to the console
Scenario$print(...)
...Rest arguments.
An object storing configuration of a specific scenario
scenarioNameName of the simulated scenario
modelFileName of the simulation to be loaded (must include the extension ".pkml"). Must be located in the "modelFolder".
applicationProtocolName of the application protocol to be applied. Defined in the excel file "Applications.xlsx"
individualIdId of the individual as specified in
"Individuals.xlsx". If NULL (default), the individual as defined in
the simulation file will be simulated.
populationIdId of the population as specified in
"Populations.xlsx", sheet "Demographics". If
ScenarioConfguration$simulationType is population, a population
will be created a the scenario will be simulated as a population
simulation.
outputPathsa character vector or named vector of output paths for
which the results will be calculated. If NULL (default), outputs as
defined in the simulation are used. Can be a named vector where names
serve as aliases for the paths, e.g., c("plasma" =
"Organism|VenousBlood|Plasma|AKB-9090|Concentration in container").
simulateSteadyStateBoolean representing whether the simulation will be brought to a steady-state first
readPopulationFromCSVBoolean representing whether the a new
population will be created (value is FALSE) or an existing population
will be imported from a csv.
simulationTimeSpecified simulation time intervals. If NULL
(default), simulation time as defined in the Simulation object will
be used. Accepted are multiple time intervals separated by a ';'. Each
time interval is a triplet of values <StartTime, EndTime, Resolution>,
where Resolution is the number of simulated points per time unit
defined in the column TimeUnit.
simulationTimeUnitUnit of the simulation time intervals.
steadyStateTimeTime in minutes to simulate if simulating
steady-state. May be NULL.
paramSheetsA named list. Names of the sheets from the parameters-excel file that will be applied to the simulation
simulationTypeType of the simulation - "Individual" or
"Population". If "Population", population characteristics are created
based on information stored in populationsFile. Default is
"Individual"
projectConfigurationProjectConfiguration that will be used in
scenarios. Read-only
ScenarioConfiguration$new()Initialize a new instance of the class
ScenarioConfiguration$new(projectConfiguration)
projectConfigurationAn object of class ProjectConfiguration.
A new ScenarioConfiguration object.
ScenarioConfiguration$addParamSheets()Add the names of sheets in the parameters excel-file that will be applied to the simulation
ScenarioConfiguration$addParamSheets(sheetNames)
sheetNamesA name or a list of names of the excel sheet
ScenarioConfiguration$removeParamSheets()Remove the names of sheets in the parameters excel-file from
the list of sheets paramSheets
ScenarioConfiguration$removeParamSheets(sheetNames = NULL)
sheetNamesA name or a list of names of the excel sheet. If NULL
(default), all sheets are removed.
ScenarioConfiguration$print()Print the object to the console
ScenarioConfiguration$print(className = TRUE, projectConfiguration = FALSE)
classNameWhether to print the name of the class at the beginning. default to TRUE.
projectConfigurationWhether to also print project configuration. default to TRUE.
ScenarioConfiguration$clone()The objects of this class are cloneable with this method.
ScenarioConfiguration$clone(deep = FALSE)
deepWhether to make a deep clone.
Carry out and visualize sensitivity analysis (with OSPSuite)
sensitivityCalculation( simulation, outputPaths, parameterPaths, variationRange = c(seq(0.1, 1, by = 0.1), seq(2, 10, by = 1)), variationType = c("relative", "absolute"), pkParameters = c("C_max", "t_max", "AUC_inf"), customOutputFunctions = NULL, saOutputFilePath = NULL, simulationRunOptions = NULL )sensitivityCalculation( simulation, outputPaths, parameterPaths, variationRange = c(seq(0.1, 1, by = 0.1), seq(2, 10, by = 1)), variationType = c("relative", "absolute"), pkParameters = c("C_max", "t_max", "AUC_inf"), customOutputFunctions = NULL, saOutputFilePath = NULL, simulationRunOptions = NULL )
simulation |
An object of type |
outputPaths |
Path (or a vector of paths) to the output(s) for which the sensitivity will be analyzed. |
parameterPaths |
A single or a vector of the parameter path(s) to be varied. Can also be a named vector, where the names are user-defined labels. These names will be stored and used in downstream plotting functions (e.g., as legend labels) if provided. |
variationRange |
Optional numeric vector or list defining the scaling of
the parameters. The same variation range is applied to all specified
parameters unless a list is provided, in which case the length of the list
must match the length of |
variationType |
A string specifying whether the values in
|
pkParameters |
A vector of names of PK parameters for which the
sensitivities will be calculated. For a full set of available standard PK
parameters, run |
customOutputFunctions |
A named list with custom function(s) for output calculations. User-defined functions should have either 'x', 'y', or both 'x' and 'y' as parameters which correspond to x-Dimension (time) or y-Dimension values from simulation results. The output of the function is a single numerical value for each output and parameter path, which is then included in the returned dataframe of PK parameters. |
saOutputFilePath |
Path to excel file in which PK-parameter data should
be saved. If a file already exists, it will be overwritten. Default is
|
simulationRunOptions |
Optional instance of a |
A list containing following objects:
SimulationResults
specified output paths
specified parameter paths
A data frame of PK parameters
Other sensitivity-calculation:
sensitivitySpiderPlot(),
sensitivityTimeProfiles(),
sensitivityTornadoPlot()
## Not run: simPath <- system.file("extdata", "Aciclovir.pkml", package = "ospsuite") simulation <- loadSimulation(simPath) outputPaths <- "Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral Venous Blood)" parameterPaths <- c( "Aciclovir|Lipophilicity", "Events|IV 250mg 10min|Application_1|ProtocolSchemaItem|Dose", "Neighborhoods|Kidney_pls_Kidney_ur|Aciclovir|Glomerular Filtration-GFR-Aciclovir|GFR fraction" ) # extract the results into a list of dataframes sensitivityCalculation( simulation = simulation, outputPaths = outputPaths, parameterPaths = parameterPaths ) # Calculate sensitivity for a user-defined function that computes the # averate of the simulated y-values customOutputFunctions <- list( "Average" = function(y) mean(y) ) sensitivityCalculation( simulation = simulation, outputPaths = outputPaths, parameterPaths = parameterPaths, customOutputFunctions = customOutputFunctions ) ## End(Not run)## Not run: simPath <- system.file("extdata", "Aciclovir.pkml", package = "ospsuite") simulation <- loadSimulation(simPath) outputPaths <- "Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral Venous Blood)" parameterPaths <- c( "Aciclovir|Lipophilicity", "Events|IV 250mg 10min|Application_1|ProtocolSchemaItem|Dose", "Neighborhoods|Kidney_pls_Kidney_ur|Aciclovir|Glomerular Filtration-GFR-Aciclovir|GFR fraction" ) # extract the results into a list of dataframes sensitivityCalculation( simulation = simulation, outputPaths = outputPaths, parameterPaths = parameterPaths ) # Calculate sensitivity for a user-defined function that computes the # averate of the simulated y-values customOutputFunctions <- list( "Average" = function(y) mean(y) ) sensitivityCalculation( simulation = simulation, outputPaths = outputPaths, parameterPaths = parameterPaths, customOutputFunctions = customOutputFunctions ) ## End(Not run)
Creates spider plots for sensitivity calculation. A spider plot is a visualization technique that displays the sensitivity of a model output to changes in model parameters. Each plot displays the sensitivity of a set of PK parameters for a single output path to changes in model parameters. The x-axis represents the value of model parameters (absolute or percent from default value), and the y-axis represents the sensitivity of the output to changes in the model parameter.
sensitivitySpiderPlot( sensitivityCalculation, outputPaths = NULL, parameterPaths = NULL, pkParameters = NULL, xAxisScale = NULL, yAxisScale = NULL, xAxisType = "percent", yAxisType = "percent", yAxisFacetScales = "fixed", defaultPlotConfiguration = NULL )sensitivitySpiderPlot( sensitivityCalculation, outputPaths = NULL, parameterPaths = NULL, pkParameters = NULL, xAxisScale = NULL, yAxisScale = NULL, xAxisType = "percent", yAxisType = "percent", yAxisFacetScales = "fixed", defaultPlotConfiguration = NULL )
sensitivityCalculation |
The |
outputPaths, parameterPaths, pkParameters
|
A single or a vector of the
output path(s), parameter path(s), and PK parameters to be displayed,
respectively. If |
xAxisScale |
Character string, either "log" (logarithmic scale) or "lin" (linear scale), to set the x-axis scale. Default is "log". |
yAxisScale |
Character string, either "log" or "lin", sets the y-axis
scale similarly to |
xAxisType |
Character string, either "percent" (percentage change) or "absolute" (absolute values) for PK parameter values, for x-axis data normalization. Default is "percent". |
yAxisType |
Character string, either "percent" (percentage change) or "absolute" (absolute values) for PK parameter values, for y-axis data normalization. Default is "percent". |
yAxisFacetScales |
Character string, either "fixed" or "free", determines the scaling across y-axes of different facets. Default is "fixed". If "fixed", all facetes within one plot will have the same range, which allows for easier comparison between different PK parameters. If "free", each facet will have its own range, which allows for better visualization of the single PK parameters sensitivity. |
defaultPlotConfiguration |
An object of class Supported parameters include:
|
A patchwork object containing the combined ggplot objects if a
single output path is specified, or a list of patchwork objects for
multiple output paths.
Other sensitivity-calculation:
sensitivityCalculation(),
sensitivityTimeProfiles(),
sensitivityTornadoPlot()
## Not run: simPath <- system.file("extdata", "Aciclovir.pkml", package = "ospsuite") simulation <- loadSimulation(simPath) outputPaths <- "Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral Venous Blood)" parameterPaths <- c( "Aciclovir|Lipophilicity", "Events|IV 250mg 10min|Application_1|ProtocolSchemaItem|Dose", "Neighborhoods|Kidney_pls_Kidney_ur|Aciclovir|Glomerular Filtration-GFR-Aciclovir|GFR fraction" ) results <- sensitivityCalculation( simulation = simulation, outputPaths = outputPaths, parameterPaths = parameterPaths ) # Print plots with default settings sensitivitySpiderPlot(results) # Print plots with absolute y-axis values sensitivitySpiderPlot(results, yAxisType = "absolute", yAxisFacetScales = "free") # Print plots with custom configuration settings myPlotConfiguration <- createEsqlabsPlotConfiguration() myPlotConfiguration$pointsShape <- 22 myPlotConfiguration$subtitle <- "Custom settings" sensitivitySpiderPlot(results, defaultPlotConfiguration = myPlotConfiguration) # Use named parameter paths to customize legend labels namedParameterPaths <- c( "Lipophilicity" = "Aciclovir|Lipophilicity", "Dose" = "Events|IV 250mg 10min|Application_1|ProtocolSchemaItem|Dose", "GFR fraction" = "Neighborhoods|Kidney_pls_Kidney_ur|Aciclovir|Glomerular Filtration-GFR-Aciclovir|GFR fraction" ) resultsNamed <- sensitivityCalculation( simulation = simulation, outputPaths = outputPaths, parameterPaths = namedParameterPaths ) sensitivitySpiderPlot(resultsNamed) ## End(Not run)## Not run: simPath <- system.file("extdata", "Aciclovir.pkml", package = "ospsuite") simulation <- loadSimulation(simPath) outputPaths <- "Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral Venous Blood)" parameterPaths <- c( "Aciclovir|Lipophilicity", "Events|IV 250mg 10min|Application_1|ProtocolSchemaItem|Dose", "Neighborhoods|Kidney_pls_Kidney_ur|Aciclovir|Glomerular Filtration-GFR-Aciclovir|GFR fraction" ) results <- sensitivityCalculation( simulation = simulation, outputPaths = outputPaths, parameterPaths = parameterPaths ) # Print plots with default settings sensitivitySpiderPlot(results) # Print plots with absolute y-axis values sensitivitySpiderPlot(results, yAxisType = "absolute", yAxisFacetScales = "free") # Print plots with custom configuration settings myPlotConfiguration <- createEsqlabsPlotConfiguration() myPlotConfiguration$pointsShape <- 22 myPlotConfiguration$subtitle <- "Custom settings" sensitivitySpiderPlot(results, defaultPlotConfiguration = myPlotConfiguration) # Use named parameter paths to customize legend labels namedParameterPaths <- c( "Lipophilicity" = "Aciclovir|Lipophilicity", "Dose" = "Events|IV 250mg 10min|Application_1|ProtocolSchemaItem|Dose", "GFR fraction" = "Neighborhoods|Kidney_pls_Kidney_ur|Aciclovir|Glomerular Filtration-GFR-Aciclovir|GFR fraction" ) resultsNamed <- sensitivityCalculation( simulation = simulation, outputPaths = outputPaths, parameterPaths = namedParameterPaths ) sensitivitySpiderPlot(resultsNamed) ## End(Not run)
Creates time profiles for selected outputs generated in a sensitivity analysis. This function plots time profiles for each specified output path, illustrating the dynamics of model outputs to parameter variations.
sensitivityTimeProfiles( sensitivityCalculation, outputPaths = NULL, parameterPaths = NULL, xAxisScale = NULL, yAxisScale = NULL, xUnits = NULL, yUnits = NULL, observedData = NULL, defaultPlotConfiguration = NULL )sensitivityTimeProfiles( sensitivityCalculation, outputPaths = NULL, parameterPaths = NULL, xAxisScale = NULL, yAxisScale = NULL, xUnits = NULL, yUnits = NULL, observedData = NULL, defaultPlotConfiguration = NULL )
sensitivityCalculation |
The |
outputPaths, parameterPaths
|
A single or a vector of the output path(s)
to be plotted for parameter path(s) which impact is analyzed, respectively.
If |
xAxisScale |
Character string, either "log" (logarithmic scale) or "lin" (linear scale), to set the x-axis scale. Default is "lin". |
yAxisScale |
Character string, either "log" or "lin", sets the y-axis
scale similarly to |
xUnits, yUnits
|
Units for the x-axis and y-axis, respectively. Can be
provided as a single string (e.g., |
observedData |
Optional. A |
defaultPlotConfiguration |
An object of class Supported parameters for
|
A patchwork object containing the combined ggplot objects if a
single output path is specified, or a list of patchwork objects for
multiple output paths.
Other sensitivity-calculation:
sensitivityCalculation(),
sensitivitySpiderPlot(),
sensitivityTornadoPlot()
## Not run: simPath <- system.file("extdata", "Aciclovir.pkml", package = "ospsuite") simulation <- loadSimulation(simPath) outputPaths <- "Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral Venous Blood)" parameterPaths <- c( "Aciclovir|Lipophilicity", "Events|IV 250mg 10min|Application_1|ProtocolSchemaItem|Dose", "Neighborhoods|Kidney_pls_Kidney_ur|Aciclovir|Glomerular Filtration-GFR-Aciclovir|GFR fraction" ) results <- sensitivityCalculation( simulation = simulation, outputPaths = outputPaths, parameterPaths = parameterPaths ) # Print plots with default settings sensitivityTimeProfiles(results) # Print plots with linear y-axis values sensitivityTimeProfiles(results, yAxisScale = "lin") # Print plots with custom configuration settings myPlotConfiguration <- createEsqlabsPlotConfiguration() myPlotConfiguration$linesColor <- c("#4D8076", "#C34A36") myPlotConfiguration$subtitle <- "Custom settings" sensitivityTimeProfiles(results, defaultPlotConfiguration = myPlotConfiguration) # Use named parameter paths to customize facet labels namedParameterPaths <- c( "Lipophilicity" = "Aciclovir|Lipophilicity", "Dose" = "Events|IV 250mg 10min|Application_1|ProtocolSchemaItem|Dose", "GFR fraction" = "Neighborhoods|Kidney_pls_Kidney_ur|Aciclovir|Glomerular Filtration-GFR-Aciclovir|GFR fraction" ) resultsNamed <- sensitivityCalculation( simulation = simulation, outputPaths = outputPaths, parameterPaths = namedParameterPaths ) sensitivitySpiderPlot(resultsNamed) ## End(Not run)## Not run: simPath <- system.file("extdata", "Aciclovir.pkml", package = "ospsuite") simulation <- loadSimulation(simPath) outputPaths <- "Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral Venous Blood)" parameterPaths <- c( "Aciclovir|Lipophilicity", "Events|IV 250mg 10min|Application_1|ProtocolSchemaItem|Dose", "Neighborhoods|Kidney_pls_Kidney_ur|Aciclovir|Glomerular Filtration-GFR-Aciclovir|GFR fraction" ) results <- sensitivityCalculation( simulation = simulation, outputPaths = outputPaths, parameterPaths = parameterPaths ) # Print plots with default settings sensitivityTimeProfiles(results) # Print plots with linear y-axis values sensitivityTimeProfiles(results, yAxisScale = "lin") # Print plots with custom configuration settings myPlotConfiguration <- createEsqlabsPlotConfiguration() myPlotConfiguration$linesColor <- c("#4D8076", "#C34A36") myPlotConfiguration$subtitle <- "Custom settings" sensitivityTimeProfiles(results, defaultPlotConfiguration = myPlotConfiguration) # Use named parameter paths to customize facet labels namedParameterPaths <- c( "Lipophilicity" = "Aciclovir|Lipophilicity", "Dose" = "Events|IV 250mg 10min|Application_1|ProtocolSchemaItem|Dose", "GFR fraction" = "Neighborhoods|Kidney_pls_Kidney_ur|Aciclovir|Glomerular Filtration-GFR-Aciclovir|GFR fraction" ) resultsNamed <- sensitivityCalculation( simulation = simulation, outputPaths = outputPaths, parameterPaths = namedParameterPaths ) sensitivitySpiderPlot(resultsNamed) ## End(Not run)
Generates tornado plots to visualize the results of sensitivity
analysis. Each plot shows the effect of modifying parameters by a specific
scaling factor (parameterFactor) and its reciprocal on specific model
outputs. This visualization helps to assess the impact of parameter changes
on the results, highlighting the model's sensitivity to these parameters.
sensitivityTornadoPlot( sensitivityCalculation, outputPaths = NULL, parameterPaths = NULL, pkParameters = NULL, parameterFactor = 0.1, xAxisZoomRange = NULL, defaultPlotConfiguration = NULL )sensitivityTornadoPlot( sensitivityCalculation, outputPaths = NULL, parameterPaths = NULL, pkParameters = NULL, parameterFactor = 0.1, xAxisZoomRange = NULL, defaultPlotConfiguration = NULL )
sensitivityCalculation |
The |
outputPaths, parameterPaths, pkParameters
|
A single or a vector of the
output path(s), parameter path(s), and PK parameters to be displayed,
respectively. If |
parameterFactor |
Numeric; the scaling factor used to adjust parameters
during sensitivity analysis used in the tornado plot. Both the
|
xAxisZoomRange |
Numeric vector of length 2; specifies the x-axis limits to zoom into. This does not remove any data but constrains the visible plotting range for improved readability. |
defaultPlotConfiguration |
An object of class Supported parameters include:
|
A patchwork object containing the combined ggplot objects if a
single output path is specified, or a list of patchwork objects for
multiple output paths.
Other sensitivity-calculation:
sensitivityCalculation(),
sensitivitySpiderPlot(),
sensitivityTimeProfiles()
## Not run: simPath <- system.file("extdata", "Aciclovir.pkml", package = "ospsuite") simulation <- loadSimulation(simPath) outputPaths <- "Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral Venous Blood)" parameterPaths <- c( "Aciclovir|Lipophilicity", "Events|IV 250mg 10min|Application_1|ProtocolSchemaItem|Dose", "Neighborhoods|Kidney_pls_Kidney_ur|Aciclovir|Glomerular Filtration-GFR-Aciclovir|GFR fraction" ) results <- sensitivityCalculation( simulation = simulation, outputPaths = outputPaths, parameterPaths = parameterPaths, variationRange = c(seq(0.1, 1, by = 0.1), seq(2, 10, by = 1)), ) # Print plots with default settings sensitivityTornadoPlot(results) # Print plots with specific parameter scaling factor sensitivityTornadoPlot(results, parameterFactor = 0.5) # Print plots with custom configuration settings myPlotConfiguration <- createEsqlabsPlotConfiguration() myPlotConfiguration$legendPosition <- "bottom" myPlotConfiguration$subtitle <- "Custom settings" sensitivityTornadoPlot(results, defaultPlotConfiguration = myPlotConfiguration) # Use named parameter paths to customize axis labels namedParameterPaths <- c( "Lipophilicity" = "Aciclovir|Lipophilicity", "Dose" = "Events|IV 250mg 10min|Application_1|ProtocolSchemaItem|Dose", "GFR fraction" = "Neighborhoods|Kidney_pls_Kidney_ur|Aciclovir|Glomerular Filtration-GFR-Aciclovir|GFR fraction" ) resultsNamed <- sensitivityCalculation( simulation = simulation, outputPaths = outputPaths, parameterPaths = namedParameterPaths ) sensitivityTornadoPlot(resultsNamed) ## End(Not run)## Not run: simPath <- system.file("extdata", "Aciclovir.pkml", package = "ospsuite") simulation <- loadSimulation(simPath) outputPaths <- "Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral Venous Blood)" parameterPaths <- c( "Aciclovir|Lipophilicity", "Events|IV 250mg 10min|Application_1|ProtocolSchemaItem|Dose", "Neighborhoods|Kidney_pls_Kidney_ur|Aciclovir|Glomerular Filtration-GFR-Aciclovir|GFR fraction" ) results <- sensitivityCalculation( simulation = simulation, outputPaths = outputPaths, parameterPaths = parameterPaths, variationRange = c(seq(0.1, 1, by = 0.1), seq(2, 10, by = 1)), ) # Print plots with default settings sensitivityTornadoPlot(results) # Print plots with specific parameter scaling factor sensitivityTornadoPlot(results, parameterFactor = 0.5) # Print plots with custom configuration settings myPlotConfiguration <- createEsqlabsPlotConfiguration() myPlotConfiguration$legendPosition <- "bottom" myPlotConfiguration$subtitle <- "Custom settings" sensitivityTornadoPlot(results, defaultPlotConfiguration = myPlotConfiguration) # Use named parameter paths to customize axis labels namedParameterPaths <- c( "Lipophilicity" = "Aciclovir|Lipophilicity", "Dose" = "Events|IV 250mg 10min|Application_1|ProtocolSchemaItem|Dose", "GFR fraction" = "Neighborhoods|Kidney_pls_Kidney_ur|Aciclovir|Glomerular Filtration-GFR-Aciclovir|GFR fraction" ) resultsNamed <- sensitivityCalculation( simulation = simulation, outputPaths = outputPaths, parameterPaths = namedParameterPaths ) sensitivityTornadoPlot(resultsNamed) ## End(Not run)
Simulation from the Excel fileSet an application protocol in a Simulation from the Excel file
setApplications(simulation, scenarioConfiguration)setApplications(simulation, scenarioConfiguration)
simulation |
A |
scenarioConfiguration |
A |
Sets the parameter values describing the application protocol defined in the scenario configuration by reading from the Applications.xlsx file. The function looks for a sheet named after the application protocol and applies all parameter values found in that sheet to the simulation.
This function is deprecated. Use setParametersFromXLS instead for better
parameter handling and more flexibility.
condition is
true.Set the values of parameters in the simulation by path, if the condition is
true.
setParameterValuesByPathWithCondition( parameterPaths, values, simulation, condition = function(path) { TRUE }, units = NULL )setParameterValuesByPathWithCondition( parameterPaths, values, simulation, condition = function(path) { TRUE }, units = NULL )
parameterPaths |
A single or a list of parameter path |
values |
A numeric value that should be assigned to the parameters or a
vector of numeric values, if the value of more than one parameter should be
changed. Must have the same length as |
simulation |
Simulation used to retrieve parameter instances from given paths. |
condition |
A function that receives a parameter path as an argument and
returns |
units |
A string or a list of strings defining the units of the
|
simPath <- system.file("extdata", "simple.pkml", package = "ospsuite") sim <- loadSimulation(simPath) condition <- function(path) { ospsuite::isExplicitFormulaByPath( path = path, simulation = sim ) } setParameterValuesByPathWithCondition( c("Organism|Liver|Volume", "Organism|Volume"), c(2, 3), sim, condition )simPath <- system.file("extdata", "simple.pkml", package = "ospsuite") sim <- loadSimulation(simPath) condition <- function(path) { ospsuite::isExplicitFormulaByPath( path = path, simulation = sim ) } setParameterValuesByPathWithCondition( c("Organism|Liver|Volume", "Organism|Volume"), c(2, 3), sim, condition )
Exports all Excel configuration files in the Configurations folder of an esqlabsR project to a single JSON file. This allows for easier version control and programmatic manipulation.
snapshotProjectConfiguration( projectConfig = "ProjectConfiguration.xlsx", outputDir = NULL, ignoreVersionCheck = TRUE, ... )snapshotProjectConfiguration( projectConfig = "ProjectConfiguration.xlsx", outputDir = NULL, ignoreVersionCheck = TRUE, ... )
projectConfig |
A ProjectConfiguration object or path to ProjectConfiguration excel file. Defaults to "ProjectConfiguration.xlsx". |
outputDir |
Directory where the JSON file will be saved. If NULL (default), the JSON file will be created in the same directory as the source Excel file. |
ignoreVersionCheck |
Logical indicating whether to ignore version mismatch checks when creating the ProjectConfiguration from a file path. Defaults to TRUE. |
... |
Additional arguments. |
Invisibly returns the exported configuration data structure
Other project configuration snapshots:
projectConfigurationStatus(),
restoreProjectConfiguration()
Source all .R files located in a specific folder
sourceAll(folderPath, recursive = FALSE)sourceAll(folderPath, recursive = FALSE)
folderPath |
Path to the folder where .R files are located |
recursive |
If |
Convert string to numeric
stringToNum(string, lloqMode = LLOQMode$`LLOQ/2`, uloqMode = ULOQMode$ULOQ)stringToNum(string, lloqMode = LLOQMode$`LLOQ/2`, uloqMode = ULOQMode$ULOQ)
string |
A string or a list of strings to be converted to numeric values |
lloqMode |
How to treat entries below LLOQ, i.e., of a form "<2":
|
uloqMode |
How to treat entries above ULOQ, i.e., of a form ">2":
|
Tries to convert each string to a numeric with as.numeric(). If
any conversion fails and returns NA, the value is tested for being a
LLOQ- or a ULOQ value, i.e., of a form "<2" or ">2", respectively. If this
is a case, the returned value is defined by the parameters lloqMode and
uloqMode. In any other case where the string cannot be converted to a
numeric, NA is returned.
A numeric value or a list of numeric values
Possible modes to treat values above the upper limit of quantification.
ULOQModeULOQMode
Validate all configuration files in a project
validateAllConfigurations(projectConfiguration, ignoreVersionCheck = TRUE)validateAllConfigurations(projectConfiguration, ignoreVersionCheck = TRUE)
projectConfiguration |
ProjectConfiguration object or path to ProjectConfiguration.xlsx |
ignoreVersionCheck |
Logical; if TRUE, skip project configuration version mismatch checks when creating a ProjectConfiguration from a path. Defaults to TRUE |
Named list of validationResult objects
R6 class for storing validation results from Excel configuration files
dataSuccessfully validated/processed data
critical_errorsList of critical errors (blocking issues)
warningsList of warnings (non-blocking issues)
validationResult$new()Initialize a new ValidationResult
validationResult$new()
validationResult$add_critical_error()Add a critical error
validationResult$add_critical_error(category, message, details = NULL)
categoryError category (e.g., "Structure", "Missing Fields", "Uniqueness")
messageError message
detailsOptional list with additional details (sheet, row, column)
validationResult$add_warning()Add a warning
validationResult$add_warning(category, message, details = NULL)
categoryWarning category (e.g., "Data", "Structure")
messageWarning message
detailsOptional list with additional details (sheet, row, column)
validationResult$set_data()Set validated data
validationResult$set_data(data)
dataThe validated/processed data to store
validationResult$is_valid()Check if validation passed (no critical errors)
validationResult$is_valid()
validationResult$has_critical_errors()Check if there are critical errors
validationResult$has_critical_errors()
validationResult$get_formatted_messages()Get formatted messages for display
validationResult$get_formatted_messages()
validationResult$get_summary()Get validation summary
validationResult$get_summary()
validationResult$clone()The objects of this class are cloneable with this method.
validationResult$clone(deep = FALSE)
deepWhether to make a deep clone.
Get summary of all validation results
validationSummary(validationResults)validationSummary(validationResults)
validationResults |
Output from validateAllConfigurations |
List with summary statistics
Create a parameter set describing an individual and write it to the Excel file
writeIndividualToXLS(individualCharacteristics, outputXLSPath)writeIndividualToXLS(individualCharacteristics, outputXLSPath)
individualCharacteristics |
An |
outputXLSPath |
Path to the Excel file the parameter set will be written to |
Path to the created Excel file
createIndividualCharacteristics crateIndividual
## Not run: simulation <- loadSimulation(pathToPKML) humanIndividualCharacteristics <- createIndividualCharacteristics( species = Species$Human, population = HumanPopulation$European_ICRP_2002, gender = Gender$Male, weight = 70 ) writeIndividualToXLS(humanIndividualCharacteristics, pathToExcelFile) ## End(Not run)## Not run: simulation <- loadSimulation(pathToPKML) humanIndividualCharacteristics <- createIndividualCharacteristics( species = Species$Human, population = HumanPopulation$European_ICRP_2002, gender = Gender$Male, weight = 70 ) writeIndividualToXLS(humanIndividualCharacteristics, pathToExcelFile) ## End(Not run)
Write parameter structure to excel that can be loaded in MoBi
writeParameterStructureToXLS( parameterStructure, paramsXLSpath, sheet = NULL, append = FALSE )writeParameterStructureToXLS( parameterStructure, paramsXLSpath, sheet = NULL, append = FALSE )
parameterStructure |
A list containing vectors |
paramsXLSpath |
Path to the excel file |
sheet |
(Optional) name of the excel sheet |
append |
If TRUE, the existing excel file/sheet will be appended with the new parameter structure. If FALSE (default), the existing file will be overwritten. |
## Not run: params <- list( paths = c("Container1|Path1", "Container|Second|Third|Path2"), values = c(1, 2), units = c("", "µmol") ) writeParameterStructureToXLS(params, "test.xlsx") ## End(Not run)## Not run: params <- list( paths = c("Container1|Path1", "Container|Second|Third|Path2"), values = c(1, 2), units = c("", "µmol") ) writeParameterStructureToXLS(params, "test.xlsx") ## End(Not run)