Skip to content

sensitivity

The PK and PBPK parts of the sensitivity analyses of the models.

The runner of the sensitivity analyses of a model and the table of their parameters are sbmlsim's: sbmlsim.sensitivity.runner (SensitivityRunner, SensitivityGroup, SensitivityOutput, LocalAnalysis, SamplingAnalysis, FastAnalysis, SobolAnalysis, run_subfolders, sample_size with SBMLSIM_SENSITIVITY_N) and sbmlsim.sensitivity.parameters (parameters_from_sbml, set_bounds, set_relative_bounds, write_parameters, free_parameters, ...). A PKPDModel is the project of a runner, its builds are the variants of the groups (variant=Sex.FEMALE). This module holds what is pharmacokinetic or of the PBPK library: the observables of the non-compartmental analysis of a substance (pk_observables, the observables of a runner, max_after_dose), the parameters of an analysis of a library model (library_parameters, notes_sources, SEVERITY_IDS) and the local analysis of its nonzero parameters (NonzeroLocalAnalysis):

# not executed
SENSITIVITY = SensitivityRunner(
    project=MODEL,
    parameters=sensitivity_parameters,
    outputs=OUTPUTS,
    observables=lambda: pk_observables(
        "hctz", "[Cve_hctz]", {"cmax": "mM"}, dose="PODOSE_hctz", pk_id="pk_hctz"
    ),
    analyses={
        "local": NonzeroLocalAnalysis(groups=GROUPS[:1]),
        "sampling": SamplingAnalysis(groups=GROUPS),
    },
    out=MODEL.results_dir / "sensitivity",
)

if __name__ == "__main__":
    SENSITIVITY.main()

NonzeroLocalAnalysis dataclass

NonzeroLocalAnalysis()

Bases: LocalAnalysis

The local analysis of the parameters whose value is not 0.

A local design changes a value relative to itself, so a severity at 0 (the healthy individual) is not changed and its sensitivity is 0/0; the sampled analyses vary the severities within their bounds.

pk_observables

pk_observables(
    prefix,
    selection,
    outputs,
    *,
    dose=None,
    route=None,
    options=None,
    per_dose_mass=(),
    mr=None,
    pk_id=None,
)

Get the non-compartmental analysis of a concentration and its outputs.

The observables of a sensitivity analysis of the pharmacokinetics of a substance: the analysis pk_id (sbmlsim PK) of the concentration selection with the parameters of the outputs, then an observable <prefix>_<key> of every output in its unit (sbmlsim Formula). The dose of an analysis is a mass (PODOSE_<s> in mg), so an output whose unit has the amount of the dose (per_dose_mass, e.g. cl_f and vz_f) is divided by the molecular weight mr at the start (at(Mr_<s>, 0), a value per simulation like the parameter of the analysis); the molecular weight of the dosed substance, also for a metabolite of it. The observables are the observables of a sbmlsim.sensitivity.runner.SensitivityRunner, as a list or as a function which builds them when a run starts, whose outputs (SensitivityOutput(observable=...)) name the ids <prefix>_<key> or the parameters <pk_id>.<key> of the analysis directly.

# not executed
OBSERVABLES = [
    *pk_observables(
        "tor",
        "Carm_tor",
        {"auc_inf_obs": "mM*min", "cl_f": "ml/min"},
        dose="PODOSE_tor",
        route="oral",
        options=NCAOptions(lloq=LLOQ),
        per_dose_mass={"cl_f", "vz_f"},
        mr="Mr_tor",
    ),
    *pk_observables("Carm_tor_m5", "Carm_tor_m5", {"cmax": "mM"}, pk_id="pk_m5"),
]

Parameters:

Name Type Description Default
prefix str

the prefix of the ids of the outputs, e.g. the substance tor (tor_cmax) or the concentration Carm_api (Carm_api_cmax).

required
selection str

the concentration, e.g. Carm_tor.

required
outputs Mapping[str, str]

the unit of every output by the key of its parameter of the analysis (pkpdutils, e.g. auc_inf_obs, cmax, cl_f).

required
dose str | None

the dose state of the analysis, None for an analysis without a dose (a metabolite), see sbmlsim.simulation.PK.

None
route str | None

the route of the dose, e.g. oral or iv_bolus.

None
options NCAOptions | None

the options of the analysis, e.g. the limit of quantification relative to the maximum (NCAOptions(lloq=...)).

None
per_dose_mass Collection[str]

the outputs whose unit has the amount of the dose.

()
mr str | None

the id of the molecular weight of the dosed substance, which an output of per_dose_mass is divided by, e.g. Mr_tor.

None
pk_id str | None

the id of the analysis, pk_<prefix> by default; an id of the model, e.g. a species hctz, is no id of an observable.

None

Returns:

Type Description
list[Observable]

The analysis and the outputs.

Raises:

Type Description
ValueError

if an output per dose mass has no molecular weight.

max_after_dose

max_after_dose(time, values)

Get the maximum of a timecourse after the dose at the time 0.

The function of a Custom observable of one selection, e.g. the largest diuresis after a dose of a simulation which starts before it: Custom("max_diuresis", max_after_dose, "ml/min", symbols=["FLUID__diuresis"]).

Parameters:

Name Type Description Default
time ndarray

the times of the timecourse.

required
values Mapping[str, ndarray]

the timecourse of the one selection of the observable.

required

Returns:

Type Description
float

The maximum from the time 0 on.

Raises:

Type Description
ValueError

for more or less than one selection.

notes_sources

notes_sources(sbase)

Get the sources in the notes of an element of a library model.

The library writes the sources of a value as a list after a paragraph Sources: of its notes.

Parameters:

Name Type Description Default
sbase SBase

the element.

required

Returns:

Type Description
list[str]

The sources, one text per list item; empty without notes or sources.

library_parameters

library_parameters(
    model_path,
    ids,
    *,
    fit_ids,
    scaling_ids,
    references=MappingProxyType({}),
    relative=0.15,
    clip=True,
    unclipped=(),
)

Get the parameters of the analyses of a model of the PBPK library.

A library model has hundreds of constants, most of them initial assignments of the covariates, which an analysis of all constants would vary as well; the analysis names the parameters it varies. They are the ids, in this order, with these bounds:

  • fitted parameters (fit_ids, type fitted): value * (1 +- relative);
  • scaling factors (scaling_ids, type scaling, 1 in the healthy individual): 1 +- relative;
  • severities (SEVERITY_IDS, type scaling): 0 to relative * top, the top being the upper bound of the domain of the severity in the model, since relative bounds around 0 would be 0;
  • any other parameter: value * (1 +- relative).

A relative span does not know what a value means: 0.94 of a fraction absorbed +- 0.15 reaches 1.081, more than a dose. With clip the bounds of every parameter are intersected with the domain the model states for it (pkpdsim.sbml.domains.domains), and every bound which moves is logged as a warning. A parameter which states no domain keeps its bounds, which one summary warning counts. A model which states no domain for any quantity was built before the domain contract: it gets the plain relative span for every parameter, severities included, and one warning, and raises nothing. A pair of bounds whose lower bound is above its upper bound (the relative bounds of a negative value) is left as it is. The two ways out of the clip are clip=False for the whole analysis and unclipped for single parameters, which keep the span they were given.

The reference of a parameter is the sources of its notes (; separated), replaced by the text in references (e.g. the guideline of the classes of the renal function, whose notes give no source). A parameter of the type not set with a reference is of the type data.

Parameters:

Name Type Description Default
model_path Path

the SBML model.

required
ids Sequence[str]

the parameters of the analysis.

required
fit_ids Collection[str]

the fitted parameters among the ids.

required
scaling_ids Collection[str]

the scaling factors among the ids.

required
references Mapping[str, str]

references by id, which replace those of the notes.

MappingProxyType({})
relative float

the relative half width of the bounds.

0.15
clip bool

intersect the bounds with the domains of the model.

True
unclipped Collection[str]

the ids whose bounds are not intersected with their domain.

()

Returns:

Type Description
list[SensitivityParameter]

The parameters of the ids with bounds, types and references.

Raises:

Type Description
ValueError

naming every id which is no parameter of the model, and every id of fit_ids, scaling_ids, references or unclipped which is not in ids, a severity without a finite upper bound of its domain in a model which states domains, and a clipped parameter whose value is outside its domain.