Skip to content

credibility

The evidence and the battery of the credibility of a PBPK model.

The credibility of a model for its contexts of use is sbmlsim.credibility: the declaration, the selection of the evidence, the assessment, the verification, the report and the scorecard. pkpdsim adds what is specific to the models of pkdb_models, registered by every pkpdsim.model.PKPDModel (pkpdsim.model.CREDIBILITY_SETTINGS: the metadata PKPDMappingMetaData, the fields of the domain DOMAIN_FIELDS, the extensions and the battery hook):

  • the evidence extensions (EXTENSIONS, sbmlsim.credibility.extensions): the ratio pairs of the ratio quantities with the limits of Guest et al. (ratios, Ratio, GuestAcceptance), the temporal validation on the studies collected after their fit (temporal), the equivalency of the simulated and the reported inputs of the subjects (inputs) and the provenance of the study data (studies);
  • the battery hook of the PK checks (PK_BATTERY, pkpdsim.credibility.battery): the dose states of the model, mass balance, zero dose and superposition on the doses of every route of every substance, with the fates of the doses.

Fate dataclass

Fate(*, build, dose, substance, amount, parts, imbalance)

Where a dose went at the end of the horizon, the mass balance of a route.

The parts are the differences to the simulation without a dose, so the fate of a dose of an endogenous substance is that of the dose and not of its production.

Attributes:

Name Type Description
build str

the build, e.g. male.

dose str

the dose state or infusion rate, e.g. IVDOSE_tor.

substance str

the dosed substance.

amount float

the dose (mmole).

parts Mapping[str, float]

the parts of the dose (mmole) by name: body (the species which are no sink), urine, feces and loss (the sinks: feces holds the unabsorbed part of a rectal dose as well, loss what an injected depot does not absorb), dose (not yet applied) and a reaction which does not read a dose by its id (negative for an elimination, positive for a production).

imbalance float

the imbalance of the dose simulation relative to the largest term of its balance.

to_dict

to_dict()

Get the fate as plain data.

from_dict classmethod

from_dict(data)

Get the fate from plain data.

FlatBuild dataclass

FlatBuild(
    *,
    name,
    path,
    substances,
    species,
    tracked,
    amounts,
    doses,
    dose_states,
    unknown_doses,
    flows,
    inputs,
    outside,
    states,
    accumulating,
    sbml,
)

What the battery reads from a flat build of a model.

Attributes:

Name Type Description
name str

the build, e.g. male.

path Path

the flat SBML file.

substances tuple[str, ...]

the substances with a molecular weight, the longest id first.

species tuple[str, ...]

the species which are states (not constant, no boundary condition, no assignment rule).

tracked Mapping[str, str]

the substance of every species which belongs to one.

amounts frozenset[str]

the species whose id is their amount (hasOnlySubstanceUnits), AMICI gives them as amounts and the others as concentrations.

doses Mapping[str, str]

the substance of every dose state and infusion rate, which a dose is given to.

dose_states Mapping[str, str]

the substance of every state of the dose (mg): the dose states and the parameters in mg with a rate rule which reads one, e.g. the drug in the stomach of a model, also through the assignment rules and transitively.

unknown_doses tuple[str, ...]

the states in mg which a reaction reads and which are no dose of any prefix of dose_prefixes, so they are a dose state or a depot of a dose which the battery does not know; the check dose_states reports them instead of leaving them out in silence. A heuristic in both directions, and not a guarantee that no dose is skipped: it finds a parameter with a rate rule, in mg, which a reaction reads, which is what every dose state of the models looks like. It has no false positive over the tracked builds of pkdb_models, but a model may have such a state which is no dose; and it does not find a dose state in another unit, one which is a species, or one which is a constant parameter without a rate rule, each of which stays skipped in silence and needs a reader of its own (none of the three occurs in the tracked builds).

flows Mapping[str, float]

the net change of the amount of the tracked species per unit of the rate of every reaction which changes it, by reaction id.

inputs frozenset[str]

the reactions of flows which read a state of the dose or an infusion rate of a substance they form, also through assignment rules.

outside tuple[str, ...]

the tracked species which a rule or an event changes, not a reaction.

states tuple[str, ...]

the ids of the states without the species: the parameters and compartments with a rate rule.

accumulating frozenset[str]

the states which nothing drains (the sinks).

sbml str

the SBML of the build with a parameter per flow which integrates it, battery_flow_<reaction>.

selections property

selections

Get the selections of a simulation: the states and the flows.

A species is selected as its amount, a parameter by its id.

read classmethod

read(name, path)

Read a flat build.

Parameters:

Name Type Description Default
name str

the build, e.g. male.

required
path Path

the flat SBML file.

required

Returns:

Type Description
FlatBuild

The build with the SBML which integrates its flows.

PKBattery

Bases: BatteryHook

The battery hook of the PBPK models, see the module.

Reads every build as a FlatBuild, simulates the SBML which integrates the flows of the reactions with the cases of the doses (dose_cases) and adds the checks PK_CHECKS with the fates of the doses (section fates). The check dose_states needs no simulation, so a build without a substance with a molecular weight has it as well.

settings

settings()

Get two days on a grid of 10 min, a model at its steady state and AMICI.

read

read(variant, path)

Read a build as a FlatBuild.

sbml

sbml(data)

Get the SBML of a build which integrates the flows of its reactions.

selections

selections(data)

Select the flows of the reactions as well.

cases

cases(data)

Get the doses of a build, see dose_cases.

not_applicable

not_applicable(check, data)

Leave a build without a substance out of the steady state.

The steady state holds for the physiology of a PBPK model by construction, a build without a substance with a molecular weight is no such model; the other generic checks apply to every build.

contribute

contribute(runs)

Check the dose states, the mass balance, the zero dose and the superposition.

describe

describe()

Get the doses of the cases in words.

report_html

report_html(sections)

Show the fates of the doses after the table of the battery, none without.

report_tables

report_tables(sections)

Write fates.tsv: one row per build, dose and part of the fate of a dose.

Without a battery the sections are empty and the table has no rows.

InputCheck

Bases: TypedDict

The check of a simulated input of a mapping against the reported one.

Attributes:

Name Type Description
fit str

the subset of the fit.

experiment str

the experiment, the study.

mapping str

the key of the mapping.

target str

the target of the model.

kind str

covariate or dose.

measurement str

the measurement type of the reported value (weight, height, ..., dosing).

unit str

the unit of the target in the model, of every value.

simulated float

the simulated value.

source str

simulation (set by the simulation) or model (the value of the model).

reported float | None

the reported central value (mean, median, geometric mean, the value of an individual, the dose) the simulated one is compared with, None without.

low float | None

the low end of the reported range, None without.

high float | None

the high end of the reported range, None without.

reported_by list[str]

the groups, individuals or interventions of the reported value.

status str

the result, see InputStatus.

ratio float | None

the simulated over the reported central value, None without.

InputsExtension

Bases: EvidenceExtension

The equivalency of the inputs of the contexts of use, see the module.

Prepared: the checks of the inputs of every mapping of the adopted fits.

prepare

prepare(project, credibility, fits)

Check the inputs of the mappings with the covariates of the declaration.

assess_context

assess_context(cou, decisive, fits, prepared)

Summarize the checks of the decisive mappings, none without the checks.

assessment_section

assessment_section(prepared)

Get the checks of every mapping as the section of the assessment.

context_report_blocks

context_report_blocks(context, section)

Show the inputs of the decisive mappings after the parameter uncertainty.

report_tables

report_tables(record)

Write inputs.tsv and input_ranges.tsv.

inputs.tsv: one row per mapping of the adopted fits and simulated input, the reporting groups, individuals and interventions joined by ;; input_ranges.tsv: one row per context of use and input of its decisive mappings.

scorecard_columns

scorecard_columns(context)

Get the inputs of the decisive mappings which differ, empty without the checks.

InputsRecord

Bases: TypedDict

The equivalency of the inputs of the decisive mappings of a context.

Attributes:

Name Type Description
n_mappings int

the decisive mappings.

n_checked int

the decisive mappings with at least one input checked.

inputs list[InputSummary]

the summary of every input, sorted by kind and target.

differs list[InputCheck]

the checks which differ.

InputStatus

Bases: StrEnum

How a simulated input compares with the reported one.

InputSummary

Bases: TypedDict

The checks of one input over the decisive mappings of a context.

Attributes:

Name Type Description
target str

the target of the model.

kind str

covariate or dose.

unit str

the unit of the target in the model.

n_mappings int

the decisive mappings with the input.

low float

the smallest simulated value, the low end of the inputs the evidence covers.

high float

the largest simulated value.

n_equivalent int

the checks which are equivalent.

n_in_range int

the checks in the reported range.

n_differs int

the checks which differ.

n_not_reported int

the checks without a reported value.

GuestAcceptance dataclass

GuestAcceptance(minimum, delta=GUEST_DELTA)

The percentage of the ratio pairs within the limits of Guest et al. is at least minimum.

The setting of the extension ratios of a context of use, ContextOfUse(extensions={"ratios": GuestAcceptance(80)}).

Attributes:

Name Type Description
minimum float

the minimum percentage (0 to 100).

delta float

the accepted variability at a ratio of 1, see guest_limit.

name property

name

Get the name of the rule.

limit property

limit

Get the limit, e.g. >= 80.

evaluate

evaluate(pairs)

Evaluate the percentage of the evaluable pairs within the limits.

Parameters:

Name Type Description Default
pairs Collection[bool | None]

whether every pair is within, None for one which is not evaluable.

required

Returns:

Type Description
AcceptanceResult

The result, not evaluable without an evaluable pair.

problems

problems()

Get the problems of the rule: a minimum outside 0 to 100, a delta not above 1.

Ratio dataclass

Ratio(*, observable, numerator, denominator, summary=AUC)

The arms of a ratio quantity: a numerator over its reference in a study.

The pairing of a ratio quantity (sbmlsim.credibility.extensions.Pairing), which RatiosExtension claims: per fit and study (the experiment) every decisive mapping of the observable which numerator selects is paired with the one which denominator selects, and the ratio of their summaries is compared for the data and the predictions.

Attributes:

Name Type Description
observable str

the observable of the arms, e.g. Carm_hctz; compared without the brackets of a concentration.

numerator MappingFilter

selects the mappings of the arms, e.g. the renal impairment.

denominator MappingFilter

selects the mapping of the reference arm, e.g. healthy.

summary Summary

how the points of an arm are summarized.

RatioRecord

Bases: TypedDict

A pair of arms of a ratio quantity.

Attributes:

Name Type Description
quantity str

the id of the ratio quantity.

fit str

the subset of the fit of the points.

experiment str

the experiment, the study of the arms.

numerator str

the key of the mapping of the numerator.

denominator str

the key of the mapping of the denominator.

observed float

the ratio of the summaries of the data, NaN if one is not evaluable.

predicted float

the ratio of the summaries of the predictions.

limit float

the limit of Guest et al. for the observed ratio.

within bool | None

whether the predicted ratio lies within the limits, None if the pair is not evaluable.

metadata dict[str, str]

the values of the fields of the domain of the numerator, by name, e.g. {"health": "RENAL_IMPAIRMENT"}, which the qualification across models groups by.

RatiosExtension

Bases: EvidenceExtension

The ratio pairs of the ratio quantities, see the module.

Prepared: the fields of the domain of the project, which the pairs record of their numerator.

claims

claims(pairing)

Claim the pairings of the arms of a study, Ratio.

selection_problems

selection_problems(cou, decisive, lookup)

Report every study of a ratio with more than one denominator.

prepare

prepare(project, credibility, fits)

Get the fields of the domain of the project.

assess_context

assess_context(cou, decisive, fits, prepared)

Assess the pairs of the ratio quantities of a context, none without.

acceptance

acceptance(cou, decisive, lookup)

Evaluate the rule of the ratio pairs on other predictions.

context_report_blocks

context_report_blocks(context, section)

Show the ratio pairs after the acceptance of a context with the rule.

report_tables

report_tables(record)

Write ratios.tsv: one row per context of use and pair of a ratio quantity.

pool_lines

pool_lines(table, options)

Word the pooled rows (the model all) as the share within the limits of Guest.

pool

pool(contexts, options)

Pool the ratio pairs of the models by a value of the metadata of their numerator.

Every evaluable pair of every context of use counts once per study and arms: a pair which two contexts of a model share counts once; a pair whose numerator has the value NR (not reported) counts for no value.

Parameters:

Name Type Description Default
contexts Mapping[str, Sequence[Mapping[str, Any] | None]]

the sections of the contexts of use, by model.

required
options Mapping[str, Any]

field, the field of the metadata of the numerator, health without.

required

Returns:

Type Description
DataFrame | None

The columns of QUALIFICATION_COLUMNS: per value of the field one

DataFrame | None

row per model and one pooled row with the model all: the

DataFrame | None

evaluable pairs, the pairs within the limits of Guest et al., their

DataFrame | None

percentage and the geometric mean fold error of the predicted over

DataFrame | None

the observed ratios; sorted by value with the pooled row first.

Summary

Bases: StrEnum

How the points of an arm of a ratio are summarized, see Ratio.

StudiesExtension

Bases: EvidenceExtension

The provenance of the study data of an assessment, see the module.

Prepared: the StudyData of every study with points in the adopted fits.

prepare

prepare(project, credibility, fits)

Get the study data of the points of the adopted fits.

assessment_section

assessment_section(prepared)

Get the study data as the section of the assessment, none without.

report_section

report_section(record)

Show the section Study data, none without a study.

report_tables

report_tables(record)

Write studies.tsv: one row per study with points in the adopted fits.

The fits and the changed tables are joined by ;.

StudyData

Bases: TypedDict

The data of a study the adopted fits of a model have points of.

Attributes:

Name Type Description
study str

the study (the experiment).

folder str | None

the folder of the study relative to the folder of the model, None if no data path of the model has it.

fits list[str]

the subsets of the fits with points of the study.

n_points int

the data points of the study in the fits, a point of two fits twice.

recorded bool

whether the folder has a record of its collection.

collected str | None

the day of the first collection, ISO format.

dating str | None

how the day of the first collection is known.

updated str | None

the day of the latest collection, ISO format.

released str | None

the day PK-DB released the study, ISO format.

pkdb_id str | None

the identifier of the release in PK-DB.

source_digest str | None

the digest of the source files in PK-DB.

pkdb_data_commit str | None

the commit of pkdb_data of the latest collection.

pkdb_data_dirty bool | None

whether the study folder of that checkout had changes.

n_tables int

the tables of the record.

changed list[str] | None

the tables which differ from the record (- removed, + added), None without the digests of the tables.

Chronology dataclass

Chronology(fits, studies)

When the adopted fits of a model ran and when it collected its studies.

Attributes:

Name Type Description
fits Mapping[str, date]

the day of every adopted fit, by its subset.

studies Mapping[str, StudyRecord]

the record of every study of the data of the model, by study.

collected

collected(study)

Get the day the model collected a study, None if not known.

new

new(points)

Get which points are of a study collected after the day of their fit.

Parameters:

Name Type Description Default
points DataFrame

data points with the columns fit and experiment.

required

Returns:

Type Description
Series

True for a point whose study the model collected after the day of

Series

its fit; False for a point without a day of collection or fit.

TemporalExtension

Bases: EvidenceExtension

The temporal validation of the contexts of use, see the module.

Prepared: the Chronology of the model.

prepare

prepare(project, credibility, fits)

Get the chronology of the model.

assess_context

assess_context(cou, decisive, fits, prepared)

Split the decisive points by the chronology, none without it.

context_report_blocks

context_report_blocks(context, section)

Show the temporal validation after the acceptance of a context.

report_tables

report_tables(record)

Write temporal.tsv: one row per context of use and study collected after its fit.

scorecard_columns

scorecard_columns(context)

Get the evaluable new points and whether every rule is met on them.

regressions

regressions(baseline, current)

Report the rules met on the new studies before which no longer are.

TemporalRecord

Bases: TypedDict

The decisive points of a context of use which are new for their fit.

Attributes:

Name Type Description
studies list[TemporalStudy]

the new studies, by study and fit.

n_points int

the decisive points of the new studies.

n_evaluable int

those the fold criteria can evaluate.

acceptance list[AcceptanceRecord]

the acceptance rules of the context on the new points.

n_known int

the decisive studies which the model collected no later than the day of their fit.

undated list[str]

the decisive studies without a day of collection.

TemporalStudy

Bases: TypedDict

A study a model collected after the fit of its decisive points.

Attributes:

Name Type Description
study str

the study (the experiment).

fit str

the subset of the fit.

fit_date str

the day the fit ran, ISO format.

collected str

the day the model collected the study, ISO format.

released str | None

the day PK-DB released the study, None if not released.

pkdb_id str | None

the identifier of the release in PK-DB.

n_points int

the decisive points of the study of this fit.

n_evaluable int

those the fold criteria can evaluate.

input_checks

input_checks(model, fits, covariates)

Check the simulated inputs of every mapping of the adopted fits.

Parameters:

Name Type Description Default
model Project

the model, the folders of its studies hold the reported values.

required
fits FitTable

the evaluated adopted fits with their reports, see sbmlsim.credibility.records.evaluate_fits.

required
covariates Mapping[str, str]

the target of every covariate and the measurement type of its reported value, see Credibility.covariates.

required

Returns:

Type Description
list[InputCheck]

The checks of every mapping of the points, in the order of the fits and

list[InputCheck]

their mappings.

guest_limit

guest_limit(observed, delta=GUEST_DELTA)

Get the limit of Guest et al. (2011) of an observed ratio.

Parameters:

Name Type Description Default
observed float

the observed ratio, positive.

required
delta float

the accepted variability at a ratio of 1.

GUEST_DELTA

Returns:

Type Description
float

The limit, NaN for a ratio which is not positive and finite.

study_data

study_data(model, points)

Get the provenance of the studies the data points are of.

Parameters:

Name Type Description Default
model Project

the model.

required
points DataFrame

the data points of the adopted fits, with the columns fit and experiment, see sbmlsim.credibility.records.evaluate_fits.

required

Returns:

Type Description
list[StudyData]

A record per study of the points, sorted by study.

Raises:

Type Description
ValueError

if a record is not readable, see pkpdsim.data.read_study_record.

chronology

chronology(model)

Get when the adopted fits of a model ran and when it collected its studies.

Parameters:

Name Type Description Default
model Project

the model.

required

Returns:

Type Description
Chronology

The days of the adopted fits of the model (Project.adopted_fits) and

Chronology

the earliest collection record for each study. If any copy of a study

Chronology

lacks a record, its collection date is unknown.

Raises:

Type Description
ValueError

if a record is not readable, see pkpdsim.data.read_study_record.