esqLABS / esqlabsR

Utility functions for modelling and simulation workflows within esqLABS organization
https://esqlabs.github.io/esqlabsR/
GNU General Public License v2.0
18 stars 2 forks source link

Idea: Make `projectConfiguration` object contain _ALL_ the project's parameters #560

Open Felixmil opened 1 year ago

Felixmil commented 1 year ago

This would allow the user to navigate in the projectConfiguration easily using only one entry point:

projectConfigurations$scenarios[["my_scenario"]]

projectConfigurations$individuals

projectConfigurations$modelParameters

projectConfigurations$plots$exportConfiguration

...

This would exploit the most of the OOP structure of our project since we could use active bindings to validate projectConfiguration.

For example:

Also, this would simplify the code in many parts where we pass projectConfiguration to other methods or functions.

This would also make things easier to import/export all the configuration and wrangle between format (json, excel, R object).

Felixmil commented 6 months ago

Quick demo of what I got so far:

devtools::load_all()
#> ℹ Loading esqlabsR
#> Loading required package: ospsuite
#> 
#> Loading required package: rClr
#> 
#> Loading the dynamic library for Microsoft .NET runtime...
#> Loaded Common Language Runtime version 4.0.30319.42000

myProject <-  Project$new(projectConfiguration = testProjectConfiguration())

myProject$models
#> [1] "Aciclovir.pkml"

names(myProject$configurations)
#> [1] "modelParameters" "individuals"     "applications"

myProject$configurations$modelParameters
#> $Global
#> $Global$`EHC continuous fraction`
#> $Global$`EHC continuous fraction`$containerPath
#> [1] "Organism|Liver"
#> 
#> $Global$`EHC continuous fraction`$parameterName
#> [1] "EHC continuous fraction"
#> 
#> $Global$`EHC continuous fraction`$value
#> [1] 1
#> 
#> $Global$`EHC continuous fraction`$units
#> [1] NA
#> 
#> 
#> 
#> $MissingParam
#> $MissingParam$bar
#> $MissingParam$bar$containerPath
#> [1] "foo"
#> 
#> $MissingParam$bar$parameterName
#> [1] "bar"
#> 
#> $MissingParam$bar$value
#> [1] 2
#> 
#> $MissingParam$bar$units
#> [1] NA
#> 
#> 
#> 
#> $Aciclovir
#> $Aciclovir$Lipophilicity
#> $Aciclovir$Lipophilicity$containerPath
#> [1] "Aciclovir"
#> 
#> $Aciclovir$Lipophilicity$parameterName
#> [1] "Lipophilicity"
#> 
#> $Aciclovir$Lipophilicity$value
#> [1] -0.1
#> 
#> $Aciclovir$Lipophilicity$units
#> [1] "Log Units"

myProject$configurations$individuals
#> $Indiv1
#> $Indiv1$characteristics
#> IndividualCharacteristics: 
#>    Species: Human 
#>    Population: European_ICRP_2002 
#>    Gender: MALE 
#>    Age: 30.00 [year(s)] 
#>    Gestational age: 40.00 [week(s)] 
#>    Weight: 73.00 [kg] 
#>    Height: 176.00 [cm] 
#> 
#> $Indiv1$parameters
#> $Indiv1$parameters$GFR
#> $Indiv1$parameters$GFR$containerPath
#> [1] "Organism|Kidney"
#> 
#> $Indiv1$parameters$GFR$parameterName
#> [1] "GFR"
#> 
#> $Indiv1$parameters$GFR$value
#> [1] 90
#> 
#> $Indiv1$parameters$GFR$units
#> [1] "ml/min"

subsetScenarios <- c("TestScenario", "TestScenario2")
myProject$setScenarioConfigurations(subsetScenarios)

myProject$runScenarios()
#> Creating scenarios
#>  ■■■■■■■■■■■■■■■■                  50% |  ETA:  3s                                                   Running simulations
#> Simulation Results computed for:
#>   - TestScenario,
#>   - TestScenario2

names(myProject$simulationResults)
#> [1] "TestScenario"  "TestScenario2"

Created on 2024-04-22 with reprex v2.1.0