knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) source(system.file("extdata", "vignette-helpers.R", package = "ospsuite.reportingengine"))
require(ospsuite.reportingengine)
This vignette focuses on PK parameters plots and tables generated using either mean model or population workflows.
The PK parameter task aims at generating tables and, when possible, plots of requested PK parameters. Depending on the workflow type, different plots and tables can be obtained.
Results obtained from the calculatePKParameters
task and stored as csv files within the subdirectory PKAnalysisResults from the workflowFolder
directory are required in order to perform the PK parameters (plotPKParameters
) task.
As a consequence, if the workflow output folder does not include the appropriate simulations, the task calculatePKParameters
needs to be active.
The objects SimulationSet
(or PopulationSimulationSet
for population workflows) and Output
define which and how the simulated PK parameters will be reported.
For mean model workflows, the PK parameters task generates directly the table of PK parameters requested in the requested Output
field pkParameters
.
The distribution of the calculated PK parameters for each requested output are plotted as Box Whisker plots along with a table. By default, the 5th, 25th, 50th, 75th and 95th percentiles are plotted.
Check the article PK Parameters in Population Workflows for more details
The following sections will introduce template scripts including PK parameter tasks as well as their associated reports. Table 1 shows the features tested in each template script. All the examples use Mean Model Workflows.
examplesTable <- data.frame( Example = seq(1, 4), Workflow = "MeanModelWorkflow", `Simulation Sets` = c(1, 1, 2, 2), check.names = FALSE ) knitr::kable(examplesTable, caption = "Table 1: Features tested by each template script")
Example 1 shows a basic example of PK parameters performed by a mean model workflow.
In this example, 'C_max' and 'AUC_tEnd' are calculated.
Since the task PK parameters requires results from the folder PKAnalysisResults,
the tasks simulate
and calculatePKParameters
need to be performed.
The task simulate
needs to be performed because the task calculatePKParameters
is using the time profile simulation results.
Code
# Get the pkml simulation file: "MiniModel2.pkml" simulationFile <- system.file("extdata", "MiniModel2.pkml", package = "ospsuite.reportingengine" ) # Define the input parameters outputA <- Output$new( path = "Organism|A|Concentration in container", displayName = "A", pkParameters = c("C_max", "AUC_tEnd") ) setA <- SimulationSet$new( simulationSetName = "A", simulationFile = simulationFile, outputs = outputA ) # Create the workflow instance workflow1 <- MeanModelWorkflow$new( simulationSets = setA, workflowFolder = "Example-1" ) # Set the workflow tasks to be run workflow1$activateTasks(c( "simulate", "calculatePKParameters", "plotPKParameters" )) # Run the workflow workflow1$runWorkflow()
The output report for Example 1 is shown below. The table indicates the requested parameters in their base unit.
cat(includeReportFromWorkflow(workflow1))
# Remove the workflow folders unlink(workflow1$workflowFolder, recursive = TRUE)
Example 2 shows how to perform workflows with user defined PK parameters.
In this example, 'MyAUC' is added to the list of PK parameters.
To create user defined PK parameter, the function addUserDefinedPKParameter() from the ospsuite
package needs to be used.
Code
# Get the pkml simulation file: "MiniModel2.pkml" simulationFile <- system.file("extdata", "MiniModel2.pkml", package = "ospsuite.reportingengine" ) myAUC <- addUserDefinedPKParameter(name = "MyAUC", standardPKParameter = StandardPKParameter$AUC_tEnd) myAUC$startTime <- 50 myAUC$endTime <- 80 # Define the input parameters outputA <- Output$new( path = "Organism|A|Concentration in container", displayName = "A", pkParameters = c("C_max", "AUC_tEnd", "MyAUC") ) setA <- SimulationSet$new( simulationSetName = "A", simulationFile = simulationFile, outputs = outputA ) # Create the workflow instance workflow2 <- MeanModelWorkflow$new( simulationSets = setA, workflowFolder = "Example-2" ) # Set the workflow tasks to be run workflow2$activateTasks(c( "simulate", "calculatePKParameters", "plotPKParameters" )) # Run the workflow workflow2$runWorkflow()
The output report for Example 2 is shown below. The table indicates the requested parameters in their base unit.
cat(includeReportFromWorkflow(workflow2))
# Remove the workflow folders unlink(workflow2$workflowFolder, recursive = TRUE)
Example 3 shows a similar example with 2 simulation sets.
In this example, the names and units of the PK parameters are updated using the function updatePKParameter from the ospsuite
package.
Code
# Get the pkml simulation file: "MiniModel2.pkml" simulationFileA <- system.file("extdata", "MiniModel1.pkml", package = "ospsuite.reportingengine" ) simulationFileB <- system.file("extdata", "MiniModel2.pkml", package = "ospsuite.reportingengine" ) updatePKParameter("C_max", displayName = "Cmax", displayUnit = "nmol/l" ) updatePKParameter("AUC_tEnd", displayName = "AUC", displayUnit = "nmol*min/l" ) # Define the input parameters outputA <- Output$new( path = "Organism|A|Concentration in container", displayName = "A", pkParameters = c("C_max", "AUC_tEnd") ) outputB <- Output$new( path = "Organism|B|Concentration in container", displayName = "B", pkParameters = c("C_max", "AUC_tEnd") ) setA <- SimulationSet$new( simulationSetName = "A", simulationFile = simulationFileA, outputs = outputA ) setB <- SimulationSet$new( simulationSetName = "B", simulationFile = simulationFileB, outputs = outputB ) # Create the workflow instance workflow3 <- MeanModelWorkflow$new( simulationSets = c(setA, setB), workflowFolder = "Example-3" ) # Set the workflow tasks to be run workflow3$activateTasks(c( "simulate", "calculatePKParameters", "plotPKParameters" )) # Run the workflow workflow3$runWorkflow()
The output report for Example 3 is shown below. The table indicates the requested parameters in the updated units and display names.
cat(includeReportFromWorkflow(workflow3))
# Go back to previous PK parameter settings updatePKParameter("C_max", displayName = "C_max", displayUnit = "µmol/l" ) updatePKParameter("AUC_tEnd", displayName = "AUC_tEnd", displayUnit = "µmol*min/l" )
Example 4 shows a different way of updating the PK parameters using the instance PkParameterInfo. Using that instance, it is possible to define different names and units for the same parameters from different paths or simulations.
Code
# Get the pkml simulation file: "MiniModel2.pkml" simulationFile <- system.file("extdata", "MiniModel2.pkml", package = "ospsuite.reportingengine" ) CmaxA <- PkParameterInfo$new("C_max", displayName = "Cmax from A", displayUnit = "µmol/l" ) CmaxB <- PkParameterInfo$new("C_max", displayName = "Cmax from B", displayUnit = "nmol/l" ) AUCA <- PkParameterInfo$new("AUC_tEnd", displayName = "AUC from A", displayUnit = "µmol*min/l" ) AUCB <- PkParameterInfo$new("AUC_tEnd", displayName = "AUC from B", displayUnit = "nmol*min/l" ) # Define the input parameters outputA <- Output$new( path = "Organism|A|Concentration in container", displayName = "A", pkParameters = c(CmaxA, AUCA) ) outputB <- Output$new( path = "Organism|B|Concentration in container", displayName = "B", pkParameters = c(CmaxB, AUCB) ) setA <- SimulationSet$new( simulationSetName = "A", simulationFile = simulationFile, outputs = outputA ) setB <- SimulationSet$new( simulationSetName = "B", simulationFile = simulationFile, outputs = outputB ) # Create the workflow instance workflow4 <- MeanModelWorkflow$new( simulationSets = c(setA, setB), workflowFolder = "Example-3" ) # Set the workflow tasks to be run workflow4$activateTasks("plotPKParameters") workflow4$inactivateTasks(c("simulate", "calculatePKParameters")) # Run the workflow workflow4$runWorkflow()
The output report for Example 4 is shown below. The table indicates the requested parameters in the updated units and display names.
cat(includeReportFromWorkflow(workflow4))
# Convert the markdown document into html # Otherwise the root path is messed up and cannot print the report correctly rmarkdown::render(workflow4$reportFilePath)
# Remove the workflow folders unlink(workflow4$workflowFolder, recursive = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.