Skip to content

Commit

Permalink
Merge branch 'develop' into get_ores_by_id
Browse files Browse the repository at this point in the history
  • Loading branch information
plakrisenko authored Oct 10, 2023
2 parents d536f82 + 2f0f50d commit a74ab99
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ jobs:
run: .github/workflows/install_deps.sh

- name: Install PEtabJL dependencies
run: julia -e 'using Pkg; Pkg.add("PEtab"); Pkg.add("OrdinaryDiffEq"), Pkg.add("Sundials")'
run: julia -e 'using Pkg; Pkg.add(name="PEtab", version="1.4.2"); Pkg.add("OrdinaryDiffEq"), Pkg.add("Sundials")'

- name: Run tests
timeout-minutes: 25
Expand Down
3 changes: 3 additions & 0 deletions pypesto/C.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
ENSEMBLE_TYPE = 'ensemble_type'
PREDICTIONS = 'predictions'

SIMULTANEOUS = 'simultaneous'
POINTWISE = 'pointwise'

LOWER_BOUND = 'lower_bound'
UPPER_BOUND = 'upper_bound'
PREEQUILIBRATION_CONDITION_ID = 'preequilibrationConditionId'
Expand Down
27 changes: 23 additions & 4 deletions pypesto/ensemble/ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@
OUTPUT,
OUTPUT_SENSI,
PERCENTILE,
POINTWISE,
PREDICTION_ARRAYS,
PREDICTION_ID,
PREDICTION_RESULTS,
PREDICTION_SUMMARY,
PREDICTIONS,
PREDICTOR,
SIMULTANEOUS,
STANDARD_DEVIATION,
SUMMARY,
TIMEPOINTS,
Expand Down Expand Up @@ -1204,7 +1206,11 @@ def get_percentile_label(percentile: Union[float, int, str]) -> str:
return f'{PERCENTILE} {percentile}'


def calculate_cutoff(result: Result, percentile: float = 0.95):
def calculate_cutoff(
result: Result,
percentile: float = 0.95,
cr_option: str = SIMULTANEOUS,
):
"""
Calculate the cutoff of the ensemble.
Expand All @@ -1220,6 +1226,10 @@ def calculate_cutoff(result: Result, percentile: float = 0.95):
The percentile of the chi^2 distribution. Between 0 and 100.
Higher values will result in a more lax cutoff. If the value is greater
than 100, the cutoff will be returned as np.inf.
cr_option:
The type of confidence region, which determines the degree of freedom of
the chi^2 distribution for the cutoff value. It can take 'simultaneous' or
'pointwise'.
Returns
-------
Expand All @@ -1230,10 +1240,19 @@ def calculate_cutoff(result: Result, percentile: float = 0.95):
f"percentile={percentile} is too large. Choose "
f"0<=percentile<=100."
)
if cr_option not in [SIMULTANEOUS, POINTWISE]:
raise ValueError(
"Confidence region must be either simultaneous or pointwise."
)

# optimal point as base:
fval_opt = result.optimize_result[0].fval
# degrees of freedom is equal to the number of parameters
df = result.problem.dim
range = chi2.ppf(q=percentile / 100, df=df)
if cr_option == SIMULTANEOUS:
# degrees of freedom is equal to the number of parameters
df = result.problem.dim
elif cr_option == POINTWISE:
# degrees of freedom is equal to 1
df = 1

range = chi2.ppf(q=percentile / 100, df=df)
return fval_opt + range
10 changes: 7 additions & 3 deletions pypesto/petab/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,15 @@

class PetabImporter(AmiciObjectBuilder):
"""
Importer for Petab files.
Importer for PEtab files.
Create an `amici.Model`, an `objective.AmiciObjective` or a
`pypesto.Problem` from Petab files.
"""
`pypesto.Problem` from PEtab files. The created objective function is a
negative log-likelihood function and can thus be negative. The actual
form of the likelihood depends on the noise model specified in the provided PEtab problem.
For more information, see
[the PEtab documentation](https://petab.readthedocs.io/en/latest/documentation_data_format.html#noise-distributions)
""" # noqa

MODEL_BASE_DIR = "amici_models"

Expand Down

0 comments on commit a74ab99

Please sign in to comment.