Execute a PopSim Run
This RMarkdown file executes an existing PopSim Run. The script utilizes the gastroPlusAPI package to communicate with the GastroPlus X 10.2 service.
To customize your study with this script for a different simulation / project / variables, please make changes to the “Set Input Information” section.
Configure required packages
Load other necessary packages required to execute the script
Load gastroPlusAPI package
library(tidyverse)
library(gastroPlusAPI)
library(gastroPlusRModuLens)
Set working directory
Set working directory as the current source editor context
if (rstudioapi::isAvailable()){
current_working_directory <- dirname(rstudioapi::getSourceEditorContext()$path)
setwd(current_working_directory)
}
Start GPX Service
Establishes a connection to the GastroPlus service, which allows R to communicate with GastroPlus through its API
gpx_service <- start_service(verbose=FALSE)
✔ Configured the GastroPlus Service
gpx_service$is_alive()
[1] TRUE
Set Input Information
Make modification to the variables in this chunk to customize your analysis.
project_path = Location of the project with the Population Simulation run popsim_run_name = Name of the Population Simulation run to be executed compound_name = Name of the Compound in the Simulation
project_path = "../../ProjectFiles/Valproate-VBE.gpproject"
popsim_run_name = "popsim_2_trial_100_pop"
compound_name = "Valproate"
Execute the run
Checks if the specified run exists in the project and executes it
open_project(project_path)
#available runs
get_runs()
# A tibble: 4 × 1
run_name
<chr>
1 Exploratory Simulation
2 popsim_2_trial_100_pop
3 vbe_slow_vs_slightly_slow
4 vbe_replicate_slow_vs_slightly_slow
#execute the run
execute_run(popsim_run_name)
Process Run Output
Get summary output for all iterations in the run
#Get summary output table for all simulations in the run
summary_output <- get_summary_output_tidy(popsim_run_name)
#Review available simulations in the PopSim run
get_simulations_in_run(popsim_run_name)
[[1]]
[1] "500mg-ER Slow"
#Get concentration plasma for all the iterations in the run
plasma_concentration_series_descriptor <- build_series_descriptors(compound_name, c(CompartmentType$SystemicCirculation, StateType$ConcentrationPlasma))
#Get concentration plasma data for all the iterations within the popsim run
series_data <- get_series_data_run(run_name= popsim_run_name, series_descriptor= plasma_concentration_series_descriptor)
glimpse(series_data)
Rows: 28,326
Columns: 11
$ run_name <chr> "popsim_2_trial_100_pop", "popsim_2_tr…
$ simulation_name <chr> "500mg-ER Slow", "500mg-ER Slow", "500…
$ series_name <chr> "Valproate - Systemic Circulation - Co…
$ dependent_unit <chr> "ng/mL", "ng/mL", "ng/mL", "ng/mL", "n…
$ independent_unit <chr> "h", "h", "h", "h", "h", "h", "h", "h"…
$ iteration <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
$ dependent <dbl> 0.000000e+00, 1.594398e-16, 3.545188e-…
$ independent <dbl> 0.000000e+00, 1.211665e-05, 6.298034e-…
$ simulation_iteration_key_name <chr> "500mg-ER Slow \a1 \a1", "500mg-ER Slo…
$ simulation_iteration_key_name_2 <chr> "500mg-ER Slow | Trial 1", "500mg-ER S…
$ trial <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
#plot with group as a stratifier using modulens
Kill GPX Service
gpx_service$kill()
[1] TRUE