ADMET Predictor: Import Structure To Existing Project
This RMarkdown file executes the workflow of importing structure through ADMET Predictor module API functions into a pre-existing Gastroplus project. 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 necessary packages(tidyverse) required to execute the data manipulation in the script
Load gastroPlusAPI package
Load gastroPlusRModuLens for easy visualization workflow in conjunction the the project setup.
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 import workflow.
project_path = Location of the project for the import
structure_file = Location of the smi/mol/sdf file of the import compounds
current_compounds = Variable to collect the pre-existing compounds in the project before the ADMET Predictor import
project_name = "../../ProjectFiles/GPX Library.gpproject"
structure_file = "../../ProjectFiles/ap_import_files/2compounds.sdf"
open_project(project_name)
current_compounds <- unlist(get_project_assets(AssetType$Compound)$assets)
Load and Import Structure
Load the structure, change the configuration of the import (eg., dose schedule, physiology schedule), update the configurations and import the structure.
load_structure(structure_file)
#Get import configuration
import_configuration <- get_admet_predictor_import_configuration()
#View the contents of the import configuration
#str(import_configuration$toJSON())
#Make changes to the configuration
import_configuration$dose_regimen_name = '100mg PO tablet 25um'
set_admet_predictor_import_configuration(import_configuration)
#Confirm if the changes were processed
updated_import_configuration <- get_admet_predictor_import_configuration()
updated_import_configuration$dose_regimen_name
[1] "100mg PO tablet 25um"
#Now import the structure with the updated configuration
import_structure()
Process Run Output
Get and execute the run with the ADMET predictor simulations after the import and collect the series of the imported compounds to plot them. The two functions to collect the series
# get the runs of the project after the import
get_runs()
# A tibble: 2 × 1
run_name
<chr>
1 PO doses
2 Run
# set the run_name for the ADMET predictor import run to a variable
run_name= "Run"
# get the simulations in the run from the import. name of the run created with the import: "Run"
get_simulations_in_run("Run")
[[1]]
[1] "Simulation for Carbamazepine1"
[[2]]
[1] "Simulation for Propranolol HCl1"
# execute the run with the ADMET predictor import simulations
execute_run(run_name)
all_compounds <- unlist(get_project_assets(AssetType$Compound)$assets)
admet_import_compounds <- setdiff(all_compounds,current_compounds)
# gastroPlusRModuLens function: build the series for the ADMET Predictor import
series_descriptors <- build_series_descriptors(
compound = admet_import_compounds,
c(CompartmentType[["SystemicCirculation"]], StateType[["ConcentrationPlasma"]])
)
series_descriptors
[1] "Propranolol HCl1 - Systemic Circulation - Concentration Plasma"
[2] "Carbamazepine1 - Systemic Circulation - Concentration Plasma"
# gastroPlusRModuLens function: get the series in the ADMET Predictor run
series_data_APimport <- get_series_data_run(run_name=run_name,series_descriptor = series_descriptors)
Plot Results
User can set the default theme provided in the package or implement their own theme. They can also write their own ggplot instance to have customized plot for internal needs.
# Getting the plotting environment ready
# set default ggplot2 theme
theme_set(
theme_gastroPlus_grid()
)
set_default_ggplot_options()
#plot the simulations
plot_series_data(series_data_APimport,
color = series_name,
x_label = "Time (h)",
y_label = "Concentration (ng/mL)",
) +
facet_wrap(~simulation_name)+
labs(color=NULL)
Kill GPX Service
gpx_service$kill()
[1] TRUE