### Example: Setting a simulation output interval Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/setOutputInterval.html Demonstrates loading a simulation and configuring a new output interval starting at 1 hour and ending at 10 hours. ```R simPath <- system.file("extdata", "simple.pkml", package = "ospsuite") # Load the simulation sim <- loadSimulation(simPath, addToCache = FALSE, loadFromCache = FALSE) # Adds a new interval starting at 1h and ending at 10h with a resolution of 10 points per hour setOutputInterval(sim, 1 * 60, 10 * 60, 1 / 6) ``` -------------------------------- ### Set Parameter Values Examples Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/setParameterValues.html Examples demonstrating how to set values for a single parameter and multiple parameters with unit specifications. ```R simPath <- system.file("extdata", "simple.pkml", package = "ospsuite") sim <- loadSimulation(simPath) param <- getParameter("Organism|Liver|Volume", sim) setParameterValues(param, 1) params <- getAllParametersMatching("Organism|**|Volume", sim) setParameterValues(params, c(2, 3, 4), units = c("ml", "l", "ml")) ``` -------------------------------- ### Initialize PK-Sim in a project Source: https://www.open-systems-pharmacology.org/OSPSuite-R/articles/PKSim-installation.html Use this command at the start of your R script to point to a local PK-Sim installation folder. Restart the R session if the path is incorrect or if the command was previously run without a path. ```R ospsuite::initPKSim(pksimFolderPath = "PKSim") ``` -------------------------------- ### Export Individual Simulations Example Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/exportIndividualSimulations.html Example showing how to load a simulation and population, then export specific individuals to a temporary directory. ```R simPath <- system.file("extdata", "Aciclovir.pkml", package = "ospsuite") sim <- loadSimulation(simPath) popPath <- system.file("extdata", "pop.csv", package = "ospsuite") population <- loadPopulation(popPath) exportIndividualSimulations(population, c(1, 2), tempdir(), sim) #> [1] "/tmp/Rtmp3QhBnq/Vergin 1995 IV_1.pkml" #> [2] "/tmp/Rtmp3QhBnq/Vergin 1995 IV_2.pkml" ``` -------------------------------- ### Import Sensitivity Analysis Example Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/importSensitivityAnalysisResultsFromCSV.html Example demonstrating how to load a simulation and import associated sensitivity analysis results from a CSV file. ```R simPath <- system.file("extdata", "simple.pkml", package = "ospsuite") resultPath <- system.file("extdata", "sa.csv", package = "ospsuite") # Load the simulation sim <- loadSimulation(simPath) # Run the simulation results <- importSensitivityAnalysisResultsFromCSV(sim, resultPath) ``` -------------------------------- ### Get simulation tree example Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/getSimulationTree.html Demonstrates loading a simulation and accessing a specific entity path using the tree structure. ```R simPath <- system.file("extdata", "simple.pkml", package = "ospsuite") sim <- loadSimulation(simPath) tree <- getSimulationTree(sim) liver_volume_path <- tree$Organism$Liver$Volume$path ``` -------------------------------- ### Examples of creating a simulation batch Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/createSimulationBatch.html Demonstrates initializing a simulation batch for single or multiple parameters and molecules. ```R simPath <- system.file("extdata", "simple.pkml", package = "ospsuite") sim <- loadSimulation(simPath) # Create a simulation batch that will allow batch run for one parameter value simulationBatch <- createSimulationBatch(sim, "Organism|Liver|Volume") # Create a simulation batch that will allow batch run for multiple parameter # values and initial values simulationBatch <- createSimulationBatch( sim, c("Organism|Liver|Volume", "R1|k1"), c("Organism|Liver|A") ) ``` -------------------------------- ### Install ospsuite-r packages from local files Source: https://www.open-systems-pharmacology.org/OSPSuite-R/index.html Use these commands to install the required packages from local .zip or .tar.gz files. Replace the placeholder paths with the actual file locations on your system. ```R install.packages(pathTo_rSharp.zip, repos = NULL) ``` ```R install.packages(pathTo_ospsuite.utils.zip, repos = NULL) ``` ```R install.packages(pathTo_tlf.zip, repos = NULL) ``` ```R install.packages(pathTo_OSPSuite.zip, repos = NULL) ``` -------------------------------- ### Load aging data example Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/loadAgingDataFromCSV.html Demonstrates loading an aging data CSV file using a path from the package installation. ```R csvPath <- system.file("extdata", "aging_data.csv", package = "ospsuite") agingData <- loadAgingDataFromCSV(csvPath) ``` -------------------------------- ### Clear Memory Example Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/clearMemory.html Example demonstrating how to clear memory while also clearing the simulation cache. ```R # This will clear the memory and also clear the simulations cache but leave # the environment intact. clearMemory(clearSimulationsCache = TRUE) ``` -------------------------------- ### Get applications for a quantity Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/Simulation.html Returns a list of applications associated with a specific quantity path, ordered by start time. ```R Simulation$allApplicationsFor(quantityPath) ``` -------------------------------- ### Examples of getOSPSuiteSetting Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/getOSPSuiteSetting.html Retrieving specific configuration values such as the suite version or sensitivity analysis thresholds. ```R getOSPSuiteSetting("suiteVersion") #> [1] "12" getOSPSuiteSetting("sensitivityAnalysisConfig")$totalSensitivityThreshold #> [1] 0.9 ``` -------------------------------- ### Example: Running Simulation Batches Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/SimulationBatch.html Demonstrates creating simulation batches, adding multiple sets of run values, and executing them. ```R \dontrun{ sim1 <- loadSimulation("sim1", loadFromCache = TRUE) sim2 <- loadSimulation("sim2", loadFromCache = TRUE) parameters <- c("Organism|Liver|Volume", "R1|k1") molecules <- "Organism|Liver|A" # Create two simulation batches. simulationBatch1 <- createSimulationBatch(simulation = sim1, parametersOrPaths = parameters, moleculesOrPaths = molecules) simulationBatch2 <- createSimulationBatch(simulation = sim2, parametersOrPaths = parameters, moleculesOrPaths = molecules) #Ids of run values ids <- c() ids[[1]] <- simulationBatch1$addRunValues(parameterValues = c(1, 2), initialValues = 1) ids[[2]] <- simulationBatch1$addRunValues(parameterValues = c(1.6, 2.4), initialValues = 3) ids[[3]] <- simulationBatch2$addRunValues(parameterValues = c(4, 2), initialValues = 4) ids[[4]] <- simulationBatch2$addRunValues(parameterValues = c(2.6, 4.4), initialValues = 5) res <- runSimulationBatches(simulationBatches = list(simulationBatch1, simulationBatch2)) } ``` -------------------------------- ### Calculate PK Analyses Example Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/calculatePKAnalyses.html Demonstrates loading a simulation, adding outputs, running the simulation, and calculating PK parameters. ```R simPath <- system.file("extdata", "Aciclovir.pkml", package = "ospsuite") sim <- loadSimulation(simPath) addOutputs("Organism|VenousBlood|*|Aciclovir", sim) results <- runSimulations(sim)[[1]] pkAnalyses <- calculatePKAnalyses(results) ``` -------------------------------- ### Example of saving a DataSet to PKML Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/saveDataSetToPKML.html Demonstrates creating a new DataSet, setting its values, and saving it to a file. ```R if (FALSE) { # \dontrun{ dataSet <- DataSet$new(name = "NewDataSet") dataSet$setValues(xValues = c(1, 2, 3, 4, 5), yValues = c(10, 20, 30, 40, 50)) dataSet$saveToPKML(filePath = "../ObsData.pkml") } # } ``` -------------------------------- ### Set Quantity and Parameter Values Examples Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/setQuantityValuesByPath.html Demonstrates loading a simulation and updating quantity or parameter values using their paths. ```R simPath <- system.file("extdata", "simple.pkml", package = "ospsuite") sim <- loadSimulation(simPath) setQuantityValuesByPath("Organism|Liver|Volume", 1, sim) setParameterValuesByPath(list("Organism|Liver|Volume", "Organism|Liver|A"), c(2, 3), sim) ``` -------------------------------- ### Run Simulations From Snapshot Example Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/runSimulationsFromSnapshot.html Demonstrates how to call the function with a specific snapshot file path and enable CSV and PKML exports. ```R if (FALSE) { # \dontrun{ runSimulationsFromSnapshot("path/to/my_snapshot.json", csv = TRUE, pkml = TRUE) } # } ``` -------------------------------- ### Set Molecule Initial Values Examples Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/setMoleculeInitialValues.html Demonstrates setting initial values for a single molecule and multiple molecules with specific units. ```R simPath <- system.file("extdata", "simple.pkml", package = "ospsuite") sim <- loadSimulation(simPath) molecule <- getMolecule("Organism|Liver|A", sim) setMoleculeInitialValues(molecule, 1) molecules <- getAllMoleculesMatching("Organism|**|A", sim) setMoleculeInitialValues(molecules, c(2, 3), units = c("pmol", "mmol")) ``` -------------------------------- ### Adding Outputs to a Simulation Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/addOutputs.html Examples demonstrating how to add outputs using paths or parameter instances. ```R simPath <- system.file("extdata", "Aciclovir.pkml", package = "ospsuite") sim <- loadSimulation(simPath) paths <- c("Organism|VenousBlood|Plasma|Aciclovir", "Organism|ArterialBlood|**|Aciclovir") addOutputs(paths, sim) parameter <- getParameter("Organism|Liver|Volume", sim) addOutputs(parameter, sim) ``` -------------------------------- ### Set molecule start values by path Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/setMoleculeValuesByPath.html Demonstrates how to update molecule start values for a single molecule and multiple molecules with specified units. ```R simPath <- system.file("extdata", "simple.pkml", package = "ospsuite") sim <- loadSimulation(simPath) setMoleculeValuesByPath("Organism|Liver|A", 1, sim) setMoleculeValuesByPath( c("Organism|Liver|A", "Organism|Liver|B"), c(2, 3), sim, units = c("µmol", "mmol") ) ``` -------------------------------- ### Install OSPSuite from GitHub Source: https://www.open-systems-pharmacology.org/OSPSuite-R/index.html Use the remotes package to install the latest release or development version of OSPSuite directly from GitHub. ```R install.packages("remotes") remotes::install_github("Open-Systems-Pharmacology/OSPSuite-R@*release") ``` ```R install.packages("remotes") remotes::install_github("Open-Systems-Pharmacology/OSPSuite-R") ``` -------------------------------- ### Calculate and Apply Steady-State Values Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/getSteadyState.html Example demonstrating how to load a simulation, calculate steady-state values, and apply them as initial values for the simulation. ```R simPath <- system.file("extdata", "simple.pkml", package = "ospsuite") sim <- loadSimulation(simPath) steadyState <- getSteadyState(simulations = sim) # Set initial values for steady-state simulations setQuantityValuesByPath( quantityPaths = steadyState[[sim$id]]$paths, values = steadyState[[sim$id]]$values, simulation = sim ) ``` -------------------------------- ### Access the Aciclovir example model Source: https://www.open-systems-pharmacology.org/OSPSuite-R/articles/ospsuite.html Retrieves the file path for the Aciclovir example model included within the package. ```R system.file("extdata", "Aciclovir.pkml", package = "ospsuite") ``` -------------------------------- ### Observed vs Simulated Plot Example Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/plotObservedVsSimulated.html Example demonstrating how to load simulation and observed data, combine them into a DataCombined object, and generate a plot. ```R if (FALSE) { # \dontrun{ # simulated data simFilePath <- system.file("extdata", "Aciclovir.pkml", package = "ospsuite") sim <- loadSimulation(simFilePath) simResults <- runSimulations(sim)[[1]] outputPath <- "Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral Venous Blood)" # observed data obsData <- lapply( c("ObsDataAciclovir_1.pkml", "ObsDataAciclovir_2.pkml", "ObsDataAciclovir_3.pkml"), function(x) loadDataSetFromPKML(system.file("extdata", x, package = "ospsuite")) ) names(obsData) <- lapply(obsData, function(x) x$name) # Create a new instance of `DataCombined` class myDataCombined <- DataCombined$new() # Add simulated results myDataCombined$addSimulationResults( simulationResults = simResults, quantitiesOrPaths = outputPath, groups = "Aciclovir PVB" ) # Add observed data set myDataCombined$addDataSets(obsData$`Vergin 1995.Iv`, groups = "Aciclovir PVB") # Create a new instance of `DefaultPlotConfiguration` class myPlotConfiguration <- DefaultPlotConfiguration$new() myPlotConfiguration$title <- "My Plot Title" myPlotConfiguration$subtitle <- "My Plot Subtitle" myPlotConfiguration$caption <- "My Sources" # plot plotObservedVsSimulated(myDataCombined, myPlotConfiguration) } # } ``` -------------------------------- ### Convert DataCombined units example Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/convertUnits.html Example demonstrating the creation of a DataCombined instance, adding simulation and observed data, and performing unit conversion. ```R # simulated data simFilePath <- system.file("extdata", "Aciclovir.pkml", package = "ospsuite") sim <- loadSimulation(simFilePath) simResults <- runSimulations(sim)[[1]] outputPath <- "Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral Venous Blood)" # observed data obsData <- lapply( c("ObsDataAciclovir_1.pkml", "ObsDataAciclovir_2.pkml", "ObsDataAciclovir_3.pkml"), function(x) loadDataSetFromPKML(system.file("extdata", x, package = "ospsuite")) ) names(obsData) <- lapply(obsData, function(x) x$name) # Create a new instance of `DataCombined` class myDataCombined <- DataCombined$new() # Add simulated results myDataCombined$addSimulationResults( simulationResults = simResults, quantitiesOrPaths = outputPath, groups = "Aciclovir PVB" ) # Add observed data set myDataCombined$addDataSets(obsData$`Vergin 1995.Iv`, groups = "Aciclovir PVB") convertUnits( myDataCombined, xUnit = ospUnits$Time$s, yUnit = ospUnits$`Concentration [mass]`$`µg/l` ) ``` -------------------------------- ### Examples of getAllQuantitiesMatching Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/getAllQuantitiesMatching.html Demonstrates retrieving quantities using specific paths, wildcards, and multiple path criteria. ```R simPath <- system.file("extdata", "simple.pkml", package = "ospsuite") sim <- loadSimulation(simPath) # Return all `Volume` quantities defined in all direct containers of the organism quantities <- getAllQuantitiesMatching("Organism|*|Volume", sim) # Return all `Volume` quantities defined in all direct containers of the organism # and the parameter 'Weight (tissue)' of the container 'Liver' paths <- c("Organism|*|Volume", "Organism|Liver|Weight (tissue)") quantities <- getAllQuantitiesMatching(paths, sim) # Returns all `Volume` quantities defined in `Organism` and all its subcontainers quantities <- getAllQuantitiesMatching("Organism|**|Volume", sim) ``` -------------------------------- ### Example: Converting DataSet to DataFrame and back Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/dataSetsFromDataFrame.html Demonstrates the round-trip conversion between a DataSet object and a data.frame. ```R dataSet <- DataSet$new(name = "MyData") dataSet$setValues(xValues = c(1, 2, 3), yValues = c(10, 20, 30)) df <- dataSetToDataFrame(dataSet) dataSets <- dataSetsFromDataFrame(df) ``` -------------------------------- ### Split Population File Example Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/splitPopulationFile.html Demonstrates how to split a population file into three parts and save them to a temporary directory. ```R csvPath <- system.file("extdata", "pop.csv", package = "ospsuite") # Split the population in up to 3 files, saved in the temp folder splitFiles <- splitPopulationFile(csvPath, 3, tempdir(), "PopFile") ``` -------------------------------- ### Examples of getAllContainersMatching Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/getAllContainersMatching.html Demonstrates retrieving containers using various path patterns, including wildcards and recursive search. ```R simPath <- system.file("extdata", "simple.pkml", package = "ospsuite") sim <- loadSimulation(simPath) # Return all `Intracellular` containers defined in all direct containers of the organism containers <- getAllContainersMatching("Organism|*|Intracellular", sim) # Return all `Intracellular` containers defined in all direct containers of the organism # and the container "Interstitial" under 'Organism|Brain' paths <- c("Organism|*|Intracellular", "Organism|Brain|Interstitial") containers <- getAllContainersMatching(paths, sim) # Returns all `Intracellular` containers defined in `Organism` and all its subcontainers containers <- getAllContainersMatching("Organism|**|Intracellular", sim) ``` -------------------------------- ### Load simulation examples Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/loadSimulation.html Demonstrates loading simulations with and without cache, and how cached objects share state while non-cached objects remain independent. ```R simPath <- system.file("extdata", "simple.pkml", package = "ospsuite") # Load sim1 for the first time sim1 <- loadSimulation(simPath) # sim2 will be loaded from cache and will represent the same object as sim1 sim2 <- loadSimulation(simPath, loadFromCache = TRUE) parameter1 <- getParameter(toPathString(c("Organism", "Liver", "Volume")), sim1) parameter2 <- getParameter(toPathString(c("Organism", "Liver", "Volume")), sim2) # parameter1 and parameter2 belong to the same simulation object, so changing # one of the them will also change another setParameterValues(parameters = parameter2, values = 0) parameter1$value == parameter2$value # TRUE #> [1] TRUE # sim3 will not be loaded from cache sim3 <- loadSimulation(simPath, loadFromCache = FALSE) # parameter3 belong to different simulation object than parameter1 and parameter2 parameter3 <- getParameter(toPathString(c("Organism", "Liver", "Volume")), sim3) setParameterValues(parameters = parameter3, values = 1) parameter2$value == parameter3$value # FALSE#' #> [1] FALSE ``` -------------------------------- ### Example: Create and use DataImporterConfiguration Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/createImporterConfigurationForFile.html Demonstrates generating a configuration for a specific sheet and using it to load datasets from an Excel file. ```R xlsFilePath <- system.file("extdata", "CompiledDataSet.xlsx", package = "ospsuite") # When sheet is specified, it is automatically added to the configuration importerConfiguration <- createImporterConfigurationForFile( xlsFilePath, sheet = "TestSheet_1" ) dataSets <- loadDataSetsFromExcel( xlsFilePath = xlsFilePath, importerConfigurationOrPath = importerConfiguration, importAllSheets = FALSE ) ``` -------------------------------- ### Retrieving container paths from a simulation Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/getAllContainerPathsIn.html Example demonstrating how to load a simulation and extract all molecule container paths. ```R simPath <- system.file("extdata", "simple.pkml", package = "ospsuite") sim <- loadSimulation(simPath) # Returns the path of all molecules defined in the simulation moleculePaths <- getAllContainerPathsIn(sim) ``` -------------------------------- ### Load data sets from Excel examples Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/loadDataSetsFromExcel.html Demonstrates loading data sets using specific configurations and sheet selections. ```R xlsFilePath <- system.file( "extdata", "CompiledDataSet.xlsx", package = "ospsuite" ) # When sheet is specified, it is automatically added to the configuration importerConfiguration <- createImporterConfigurationForFile( xlsFilePath, sheet = "TestSheet_1" ) dataSets <- loadDataSetsFromExcel( xlsFilePath = xlsFilePath, importerConfigurationOrPath = importerConfiguration ) # Load specific sheets using the sheets parameter dataSets <- loadDataSetsFromExcel( xlsFilePath = xlsFilePath, importerConfigurationOrPath = importerConfiguration, sheets = c("TestSheet_1", "TestSheet_2") ) if (FALSE) { # \dontrun{ # Load all sheets by setting sheets to NULL and no sheets in configuration importerConfiguration <- createImporterConfigurationForFile(xlsFilePath) dataSets <- loadDataSetsFromExcel( xlsFilePath = xlsFilePath, importerConfigurationOrPath = importerConfiguration, sheets = NULL ) } # } ``` -------------------------------- ### Example data frame creation Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/dot-unitConverter.html Creating a small tibble to demonstrate unit conversion capabilities. ```R (df <- dplyr::tibble( dataType = c(rep("simulated", 3), rep("observed", 3)), xValues = c(0, 14.482, 28.965, 0, 1, 2), xUnit = "min", xDimension = "Time", yValues = c(1, 1, 1, 1, 1, 1), yUnit = c("mol", "mol", "mol", "g", "g", "g"), yDimension = c("Amount", "Amount", "Amount", "Mass", "Mass", "Mass"), yErrorValues = c(2.747, 2.918, 2.746, NA, NA, NA), yErrorUnit = c("mol", "mol", "mol", "g", "g", "g"), molWeight = c(10, 10, 20, 20, 20, 10) )) ``` -------------------------------- ### Example: Adding output intervals to a simulation Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/addOutputInterval.html Demonstrates loading a simulation, clearing existing intervals, and adding new custom output intervals with specific time ranges and resolutions. ```R simPath <- system.file("extdata", "simple.pkml", package = "ospsuite") # Load the simulation sim <- loadSimulation(simPath, addToCache = FALSE, loadFromCache = FALSE) # clears the previous output schema clearOutputIntervals(sim) # Adds a new interval starting at 1h and ending at 10h with a resolution of 10 points per hour addOutputInterval(sim, 1 * 60, 10 * 60, 1 / 6) # Adds another interval starting at 10h and ending at 17h with a resolution of 4 points per hour # and a specified name addOutputInterval(sim, 10 * 60, 17 * 60, 4 / 60, intervalName = "Second Interval") ``` -------------------------------- ### Clear simulation outputs example Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/clearOutputs.html Shows how to load a simulation and subsequently clear its output selections. ```R simPath <- system.file("extdata", "simple.pkml", package = "ospsuite") sim <- loadSimulation(simPath, ) clearOutputs(sim) ``` -------------------------------- ### Example of toPathString Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/toPathString.html Shows how to convert a character vector of path components into a single delimited string. ```R toPathString(c("Organism", "Organ", "Liver")) #> [1] "Organism|Organ|Liver" ``` -------------------------------- ### Exporting simulation results to CSV Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/dot-saveResultsToCSV.html Example demonstrating the workflow of loading a simulation, running it, and exporting the resulting data to a temporary CSV file. ```R simPath <- system.file("extdata", "simple.pkml", package = "ospsuite") # Load the simulation sim <- loadSimulation(simPath) # Add some outputs to the simulation addOutputs("Organism|**|*", sim) # Run the simulation results <- runSimulations(sim)[[1]] # Export the results to csv file exportResultsToCSV(results, tempfile()) ``` -------------------------------- ### Examples of adding user-defined PK parameters Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/addUserDefinedPKParameter.html Demonstrates creating custom AUC and Cmax parameters with specific time or application index constraints. ```R # Adds a user defined parameter named MyAuc that will calculate the value of AUC # between t=50 min and t=80min myAUC <- addUserDefinedPKParameter( name = "MyAUC", standardPKParameter = StandardPKParameter$AUC_tEnd ) myAUC$startTime <- 50 myAUC$endTime <- 80 # Adds a user defined parameter named MyCMax that will calculate the value of Cmax # between the 4th and 5th application myCMax <- addUserDefinedPKParameter( name = "MyCMax", standardPKParameter = StandardPKParameter$C_max ) myCMax$startApplicationIndex <- 4 myCMax$endApplicationIndex <- 5 ``` -------------------------------- ### Example of retrieving a liver container Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/getContainer.html Demonstrates loading a simulation and retrieving the liver container using a path string. ```R simPath <- system.file("extdata", "simple.pkml", package = "ospsuite") sim <- loadSimulation(simPath) container <- getContainer("Organism|Liver", sim) ``` -------------------------------- ### Exporting a Population to CSV Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/dot-savePopulationToCSV.html Example demonstrating loading a population from a CSV file and exporting it to a temporary file. ```R csvPath <- system.file("extdata", "pop.csv", package = "ospsuite") # Load the population population <- loadPopulation(csvPath) # Exports the population exportPopulationToCSV(population, tempfile()) ``` -------------------------------- ### Set molecule scale divisors examples Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/setMoleculeScaleDivisors.html Demonstrates how to retrieve molecules from a simulation and update their scale divisors individually or in bulk. ```R simPath <- system.file("extdata", "simple.pkml", package = "ospsuite") sim <- loadSimulation(simPath) molecule <- getMolecule("Organism|Liver|A", sim) setMoleculeScaleDivisors(molecule, 0.001) molecules <- getAllMoleculesMatching("Organism|**|A", sim) setMoleculeScaleDivisors(molecules, c(0.002, 0.003)) ``` -------------------------------- ### Set parameter values by path Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/setParameterValuesByPath.html Examples demonstrating how to update single or multiple parameter values within a loaded simulation. ```R simPath <- system.file("extdata", "simple.pkml", package = "ospsuite") sim <- loadSimulation(simPath) setParameterValuesByPath("Organism|Liver|Volume", 1, sim) setParameterValuesByPath(c("Organism|Liver|Volume", "Organism|Volume"), c(2, 3), sim) ``` -------------------------------- ### Initialize development environment Source: https://www.open-systems-pharmacology.org/OSPSuite-R/index.html Run this script to prepare platform-specific library files before using devtools::load_all(). This is required after cloning, switching branches, or pulling changes. ```R source("tools/setup_dev.R") setup_dev() ``` -------------------------------- ### initPKSim() Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/initPKSim.html Initializes the PK-Sim environment by loading the required DLLs. ```APIDOC ## initPKSim() ### Description Loads the `PKSim.R` dll that will enable create individual and create population workflows. ### Usage ```R initPKSim() ``` ### Note PKSim dlls are included in the package. ``` -------------------------------- ### Install CRAN Dependencies Source: https://www.open-systems-pharmacology.org/OSPSuite-R/index.html Install the required CRAN packages before manually installing OSPSuite from archive files. ```R # Install dependencies (e.g. R6) which are on CRAN install.packages("cli") install.packages("crayon") install.packages("data.table") install.packages("dplyr") install.packages("ggplot2") install.packages("ggtext") install.packages("glue") install.packages("jsonlite") install.packages("lifecycle") install.packages("logger") install.packages("openxlsx") install.packages("patchwork") install.packages("purrr") install.packages("R6") install.packages("readr") install.packages("rlang") install.packages("showtext") install.packages("stringi") install.packages("stringr") install.packages("tidyr") install.packages("xml2") ``` -------------------------------- ### List Installed System Fonts Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/DefaultPlotConfiguration.html Retrieve a list of available font families installed on the system using the systemfonts package. ```R # install.packages("systemfonts") library(systemfonts) system_fonts() ``` -------------------------------- ### Generate Q-Q plots Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/plotQuantileQuantilePlot.html Examples showing how to generate a Q-Q plot using default settings and with a linear residual scale. ```R if (FALSE) { # \dontrun{ # Generate a Q-Q plot with default settings plotQuantileQuantilePlot(myDataCombined) # Generate a Q-Q plot with linear scale plotQuantileQuantilePlot(myDataCombined, residualScale = "linear") } # } ``` -------------------------------- ### Example: Plotting individual time profiles Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/plotIndividualTimeProfile.html Demonstrates loading simulation and observed data, combining them into a DataCombined object, and generating a plot with custom configuration. ```R if (FALSE) { # \dontrun{ # simulated data simFilePath <- system.file("extdata", "Aciclovir.pkml", package = "ospsuite") sim <- loadSimulation(simFilePath) simResults <- runSimulations(sim)[[1]] outputPath <- "Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral Venous Blood)" # observed data obsData <- lapply( c("ObsDataAciclovir_1.pkml", "ObsDataAciclovir_2.pkml", "ObsDataAciclovir_3.pkml"), function(x) loadDataSetFromPKML(system.file("extdata", x, package = "ospsuite")) ) names(obsData) <- lapply(obsData, function(x) x$name) # Create a new instance of `DataCombined` class myDataCombined <- DataCombined$new() # Add simulated results myDataCombined$addSimulationResults( simulationResults = simResults, quantitiesOrPaths = outputPath, groups = "Aciclovir PVB" ) # Add observed data set myDataCombined$addDataSets(obsData$`Vergin 1995.Iv`, groups = "Aciclovir PVB") # Create a new instance of `DefaultPlotConfiguration` class myPlotConfiguration <- DefaultPlotConfiguration$new() myPlotConfiguration$title <- "My Plot Title" myPlotConfiguration$subtitle <- "My Plot Subtitle" myPlotConfiguration$caption <- "My Sources" # plot plotIndividualTimeProfile(myDataCombined, myPlotConfiguration) } # } ``` -------------------------------- ### Examples of plotting population time profiles Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/plotPopulationTimeProfile.html Demonstrates loading simulation results, preparing a DataCombined object, and generating plots with different aggregation settings. ```R if (FALSE) { # \dontrun{ simFilePath <- system.file("extdata", "Aciclovir.pkml", package = "ospsuite") sim <- loadSimulation(simFilePath) populationResults <- importResultsFromCSV( simulation = sim, filePaths = system.file("extdata", "SimResults_pop.csv", package = "ospsuite") ) # Create a new instance of `DataCombined` class myDataComb <- DataCombined$new() myDataComb$addSimulationResults(populationResults) # plot plotPopulationTimeProfile(myDataComb) # plot with other quantiles plotPopulationTimeProfile(myDataComb, quantiles = c(0.1, 0.5, 0.9)) # plot with arithmetic mean plotPopulationTimeProfile(myDataComb, aggregation = "arithmetic" ) } # } ``` -------------------------------- ### Initialize DotNetWrapper Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/DotNetWrapper.html Demonstrates how to instantiate a DotNetWrapper using an existing .NET object reference from a loaded simulation. ```R DotNetWrapper$new(netObject) ``` ```R sim <- loadSimulation(system.file("extdata", "simple.pkml", package = "ospsuite")) # looking at a reference to `.NET` simulation object sim$pointer #> # create a new instance of `DotNetWrapper` class using this reference DotNetWrapper$new(sim) ``` -------------------------------- ### Initialize ospsuite library Source: https://www.open-systems-pharmacology.org/OSPSuite-R/articles/create-individual.html Basic library import for ospsuite functionality. ```R library(ospsuite) ``` -------------------------------- ### Example usage of clearOutputIntervals Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/clearOutputIntervals.html Demonstrates loading a simulation and clearing its output intervals. ```R simPath <- system.file("extdata", "simple.pkml", package = "ospsuite") # Make sure we create a new simulation so that we do not impact other examples sim <- loadSimulation(simPath, addToCache = FALSE, loadFromCache = FALSE) clearOutputIntervals(sim) ``` -------------------------------- ### Get covariate values Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/Population.html Retrieves all values defined for a specific covariate name. ```R Population$getCovariateValues(covariateName) ``` -------------------------------- ### Example usage of removeSimulationFromCache Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/removeSimulationFromCache.html Demonstrates removing a cached simulation versus a non-cached simulation. ```R simPath <- system.file("extdata", "simple.pkml", package = "ospsuite") sim1 <- loadSimulation(simPath) sim2 <- loadSimulation(simPath, loadFromCache = FALSE, addToCache = FALSE) removeSimulationFromCache(sim1) # returns TRUE #> [1] TRUE removeSimulationFromCache(sim2) # returns FALSE #> [1] FALSE ``` -------------------------------- ### Initialize and Configure Sensitivity Analysis Source: https://www.open-systems-pharmacology.org/OSPSuite-R/articles/sensitivity-analysis.html Demonstrates loading a simulation, identifying variable parameters, and creating a SensitivityAnalysis object with specific or default parameters. ```R library(ospsuite) # Load simulation simFilePath <- system.file("extdata", "simple.pkml", package = "ospsuite") sim <- loadSimulation(simFilePath) # Get the paths of parameters that will be considered by default. potentialSAParameters <- potentialVariableParameterPathsFor(sim) print(potentialSAParameters) #> [1] "Organism|Volume" "Organism|Q" "R1|k1" # Create a default `SensitivityAnalysis` for the simulation sa <- SensitivityAnalysis$new(simulation = sim) print(sa) #> #> • Number of steps: 2 #> • Variation range: 0.1 #> • Number of parameters to vary: Will be estimated at run time # Create a `SensitivityAnalysis` with specified parameters sa <- SensitivityAnalysis$new(simulation = sim, parameterPaths = c("Organism|Q", "Organism|Volume")) print(sa) #> #> • Number of steps: 2 #> • Variation range: 0.1 #> • Number of parameters to vary: 2 # Show which parameters will be varied sa$parameterPaths #> [1] "Organism|Q" "Organism|Volume" ``` ```R library(ospsuite) ``` -------------------------------- ### Example of populationFromDataFrame usage Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/populationFromDataFrame.html Demonstrates converting a population to a data.frame and back to a Population object. ```R csvPath <- system.file("extdata", "pop.csv", package = "ospsuite") population <- loadPopulation(csvPath) df <- populationToDataFrame(population) populationFromDf <- populationFromDataFrame(df) ``` -------------------------------- ### Get Variable Molecules Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/SimulationBatch.html Retrieve the list of molecule paths defined as variable for the batch. ```R SimulationBatch$getVariableMolecules() ``` -------------------------------- ### Get Variable Parameters Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/SimulationBatch.html Retrieve the list of parameter paths defined as variable for the batch. ```R SimulationBatch$getVariableParameters() ``` -------------------------------- ### Get formatted print string Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/Quantity.html Returns a string representation of the quantity value and unit. ```R Quantity$getPrintValue() ``` -------------------------------- ### Calculate and retrieve PK parameters in R Source: https://www.open-systems-pharmacology.org/OSPSuite-R/articles/pk-analysis.html Demonstrates loading a simulation, running it, and calculating PK parameters for specific output paths. ```R library(ospsuite) # Load the simulation simFilePath <- system.file("extdata", "Aciclovir.pkml", package = "ospsuite") sim <- loadSimulation(simFilePath) # Run the simulation simulationResults <- runSimulations(simulations = sim)[[1]] # Calculate PK-analyses pkAnalysis <- calculatePKAnalyses(results = simulationResults) # Get the path of the simulated output outputPath <- simulationResults$allQuantityPaths[[1]] print(outputPath) #> [1] "Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral Venous Blood)" # Get all calculated PK parameters for the output path allPkParams <- pkAnalysis$allPKParametersFor(outputPath) print(allPkParams) #> [[1]] #> #> • Name: C_max #> • QuantityPath: Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral #> Venous Blood) #> • Dimension: Concentration (molar) #> • Unit: µmol/l #> #> [[2]] #> #> • Name: C_max_norm #> • QuantityPath: Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral #> Venous Blood) #> • Dimension: Concentration (mass) #> • Unit: kg/l #> #> [[3]] #> #> • Name: t_max #> • QuantityPath: Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral #> Venous Blood) #> • Dimension: Time #> • Unit: min #> #> [[4]] #> #> • Name: C_tEnd #> • QuantityPath: Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral #> Venous Blood) #> • Dimension: Concentration (molar) #> • Unit: µmol/l #> #> [[5]] #> #> • Name: AUC_tEnd #> • QuantityPath: Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral #> Venous Blood) #> • Dimension: AUC (molar) #> • Unit: µmol*min/l #> #> [[6]] #> #> • Name: AUC_tEnd_norm #> • QuantityPath: Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral #> Venous Blood) #> • Dimension: AUC (mass) #> • Unit: kg*min/l #> #> [[7]] #> #> • Name: AUC_inf #> • QuantityPath: Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral #> Venous Blood) #> • Dimension: AUC (molar) #> • Unit: µmol*min/l #> #> [[8]] #> #> • Name: AUC_inf_norm #> • QuantityPath: Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral #> Venous Blood) #> • Dimension: AUC (mass) #> • Unit: kg*min/l #> #> [[9]] #> #> • Name: MRT #> • QuantityPath: Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral #> Venous Blood) #> • Dimension: Time #> • Unit: min #> #> [[10]] #> #> • Name: Thalf #> • QuantityPath: Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral #> Venous Blood) #> • Dimension: Time #> • Unit: min #> #> [[11]] #> #> • Name: FractionAucLastToInf #> • QuantityPath: Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral #> Venous Blood) #> • Dimension: Fraction #> #> [[12]] #> #> • Name: CL #> • QuantityPath: Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral #> Venous Blood) #> • Dimension: Flow per weight #> • Unit: l/min/kg #> #> [[13]] #> #> • Name: Vss #> • QuantityPath: Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral #> Venous Blood) #> • Dimension: Volume per body weight #> • Unit: l/kg #> #> [[14]] #> #> • Name: Vd #> • QuantityPath: Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral #> Venous Blood) #> • Dimension: Volume per body weight #> • Unit: l/kg # Get C_max parameter c_max <- pkAnalysis$pKParameterFor(quantityPath = outputPath, pkParameter = "C_max") c_max #> #> • Name: C_max #> • QuantityPath: Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral #> Venous Blood) #> • Dimension: Concentration (molar) #> • Unit: µmol/l ``` -------------------------------- ### Get all values for an individual Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/Population.html Retrieves all parameter values defined for a specific individual ID. ```R Population$getParameterValuesForIndividual(individualId) ``` -------------------------------- ### Get specific covariate value Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/Population.html Retrieves the value of a covariate for a specific individual ID. ```R Population$getCovariateValue(covariateName, individualId) ``` -------------------------------- ### Get Print Value String Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/ParameterRange.html Returns a string representation of the parameter for one-line printing. ```R ParameterRange$getPrintValue() ``` -------------------------------- ### Update PK Parameter Example Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/updatePKParameter.html Demonstrates updating the display name and unit for the 't_max' parameter. ```R updatePKParameter("t_max", "MyTmax", "min") #> #> • Name: t_max #> • DisplayName: MyTmax #> • Dimension: Time #> • DisplayUnit: min ``` -------------------------------- ### Load and Inspect Simulations Source: https://www.open-systems-pharmacology.org/OSPSuite-R/articles/ospsuite.html Demonstrates how to load a .pkml file and print the simulation object details. ```R # Using the included example simFilePath <- system.file("extdata", "Aciclovir.pkml", package = "ospsuite") sim <- loadSimulation(simFilePath) # For custom files, use: # sim <- loadSimulation("path/to/simulation.pkml") # Explore the simulation print(sim) ``` -------------------------------- ### Example of population conversion Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/populationToDataFrame.html Demonstrates loading a population from a CSV file and converting it into a data frame. ```R csvPath <- system.file("extdata", "pop.csv", package = "ospsuite") population <- loadPopulation(csvPath) df <- populationToDataFrame(population) ``` -------------------------------- ### Execute a complete simulation workflow Source: https://www.open-systems-pharmacology.org/OSPSuite-R/articles/ospsuite.html Demonstrates the standard pipeline from loading a PKML file to visualizing and extracting simulation results. ```R # 1. Load simulation simFilePath <- system.file("extdata", "Aciclovir.pkml", package = "ospsuite") sim <- loadSimulation(simFilePath) # 2. Modify parameters (e.g., change dose) dose <- getParameter( path = "Events|IV 250mg 10min|Application_1|ProtocolSchemaItem|Dose", sim ) setParameterValues(dose, 0.006) # 6 mg/kg dose # 3. Run simulation results <- runSimulations(sim) # 4. Visualize results myDataCombined <- DataCombined$new() myDataCombined$addSimulationResults(results[[1]]) plotTimeProfile(myDataCombined) ``` -------------------------------- ### Convert snapshot and project files Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/convertSnapshot.html Demonstrates converting a snapshot file to a project format and a project file to a snapshot format. ```R if (FALSE) { # \dontrun{ convertSnapshot("path/to/snapshot.json", format = "project") convertSnapshot("path/to/project.pksim5", format = "snapshot") } # } ``` -------------------------------- ### SimulationBatch$new() Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/SimulationBatch.html Initializes a new instance of the SimulationBatch class. ```APIDOC ## SimulationBatch$new() ### Description Initialize a new instance of the SimulationBatch class. ### Usage SimulationBatch$new(netObject, simulation) ### Arguments - **netObject** (rSharp::NetObject) - An rSharp::NetObject object. - **simulation** (Simulation) - Simulation used in the batch run. ### Returns A new SimulationBatch object. ``` -------------------------------- ### Load and Configure Simulation Source: https://www.open-systems-pharmacology.org/OSPSuite-R/articles/create-run-population.html Load a simulation from a file and initialize simulation run options. ```R # Load simulation simFilePath <- system.file("extdata", "Aciclovir.pkml", package = "ospsuite") sim <- loadSimulation(simFilePath) # Create a SimulationRunOptions object simRunOptions <- SimulationRunOptions$new() print(simRunOptions) #> #> • numberOfCores: 3 #> • checkForNegativeValues: TRUE #> • showProgress: FALSE ``` -------------------------------- ### SimulationBatch$addRunValues() Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/SimulationBatch.html Adds a set of parameter and start values for the next execution of the simulation batch. ```APIDOC ## SimulationBatch$addRunValues() ### Description Add a set of parameter and start values for next execution. The simulation batch is executed with the sets of parameter and initial values that have been scheduled, and the set of run values is cleared after a successful run. ### Usage SimulationBatch$addRunValues(parameterValues = NULL, initialValues = NULL) ### Arguments - **parameterValues** (Vector) - Optional. Vector of parameter values to set in the simulation. - **initialValues** (Vector) - Optional. Vector of initial values to set in the simulation. ### Returns Id of the values set that can be used to get the correct result from runSimulationBatches. ``` -------------------------------- ### Get simulation tree usage Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/getSimulationTree.html Displays the function signature for retrieving a simulation tree structure. ```R getSimulationTree(simulationOrFilePath, quantityType = "Quantity") ``` -------------------------------- ### Initialize SimulationBatch Source: https://www.open-systems-pharmacology.org/OSPSuite-R/reference/SimulationBatch.html Create a new instance of the SimulationBatch class. ```R SimulationBatch$new(netObject, simulation) ```