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

SensitivityAnalysis WP6 #146

Closed PavelBal closed 2 years ago

PavelBal commented 2 years ago

Also read https://docs.open-systems-pharmacology.org/shared-tools-and-example-workflows/sensitivity-analysis for introduction of how sensitivity analysis (SA) is performed in OSPS.

A function (or a set of functions) for convenient execution of local sensitivity analysis on models developed with OSPS. As inputs, the user should be able to specify:

Sensitivity calculation

The first function, e.g. sensitivityCalculation, should perform the following:

Results should be returned in a structure (data frame?) that can be passed to the functions that will create time-values profiles and sensitivity "spider plot" figures (definition below). Additionally, results should be saved in an excel file if the user specifies a path to the file (if the file with the specified name is already present, it will be overwritten). The excel file should have the following structure:

image

Time profiles visualization

A second function, eg. sensivitityTimeProfiles, should create time-values profile figures for the output generated by sensitivityCalculation.

For each output defined in sensivitityTimeProfiles:

Sensitivity spider plots

A third function, e.g. sensitivitySpiderPlot, generates a set of so-called sensitivity spider plots (example below. Be aware that the example shows % change on the y-axis, but the specification requires [% of reference]:)

image

For each output defined in sensivitityTimeProfiles:

Remarks

PavelBal commented 2 years ago
IndrajeetPatil commented 2 years ago

Instead of

  pkParams = c(
    StandardPKParameter$C_max,
    StandardPKParameter$t_max,
    StandardPKParameter$AUC_tEnd
  )

I was thinking the default will be NULL, which would include all PK parameters. When not NULL, only those PK parameters will be retained in data and plots. Sounds reasonable?

PavelBal commented 2 years ago

Hmm no, not really, there are 22 standard PK parameters defined in PK sim and it would generate just too much output. Most of the time people are just interested in

    StandardPKParameter$C_max,
    StandardPKParameter$t_max,
    StandardPKParameter$AUC_inf
IndrajeetPatil commented 2 years ago

In that case, is it okay if the parameter actually takes in a vector of strings/character type specifying needed PK parameters? That is,

pkParams = c("C_max", "t_max", "AUC_inf")

And the documentation will make clear that the names of all available PK parameters can be found in names(StandardPKParameter)?

Those enums evaluate to numbers and are difficult to work with further, while with a character vector, I can just filter out the needed PK parameters.

PavelBal commented 2 years ago

Ah yes... No idea why the enum is defined that way.... Yes sure, it should be strings, I didn't realize these were integers in the enum.

IndrajeetPatil commented 2 years ago

We also have outputPath argument for sensitivityAnalysis(). What needs to happen if there are multiple output paths specified by the user? Do they need to be mapped to color or shape or etc.?

PavelBal commented 2 years ago

What needs to happen if there are multiple output paths specified by the user? Do they need to be mapped to color or shape or etc.?

No, let's keep it simple and create one figure per path.

IndrajeetPatil commented 2 years ago

Okay, I have implemented this, but can't find a dataset to play with that has multiple output paths. There is simple.pkml in the package, but that doesn't seem to be a realistic dataset to try this out.

Any suggestions?

Current example, which has only a single path:

simulation <- loadSimulation("Aciclovir.pkml")
outputPaths <- "Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral Venous Blood)"
parameterPaths <- c(
  "Aciclovir|Lipophilicity",
  "Applications|IV 250mg 10min|Application_1|ProtocolSchemaItem|Dose",
  "Neighborhoods|Kidney_pls_Kidney_ur|Aciclovir|Glomerular Filtration-GFR|GFR fraction"
)
variationRange <- c(seq(0.2, 1, by = 0.1), seq(2, 10, by = 1)) # c(0.1, 1, 2)

sensitivityAnalysis(
  simulation = simulation,
  outputPaths = outputPaths,
  parameterPaths = parameterPaths,
  variationRange = variationRange,
  pkParams = NULL
)
msevestre commented 2 years ago

Just add any other output from your model Organism|VenousBlood|Plasma|Aciclovir