ICB-DCM / pyPESTO

python Parameter EStimation TOolbox
https://pypesto.readthedocs.io
BSD 3-Clause "New" or "Revised" License
220 stars 47 forks source link

Mapping of condition ids to plots of sampling prediction trajectories #1091

Open shoepfl opened 1 year ago

shoepfl commented 1 year ago

Hi,

how does visualize.sampling_prediction_trajectories handle the plot titles when plots are grouped by condition?

My problem is that the plots are named condition_0, condition_1 ... but I do not know for sure which condition that is in my conditions file. Also setting lables for this does not help as the conditions are only numbered but do not refer to the condition_ids.

Refering to the example in the docs with the conversion reaction the label for condition 0 is set via ""condition_0": "cond_0"" but in the experimental conditions file the names are c0 and c1.

How can I find out how my condition_ids map to condition_0, condition_1 etc.?

Thanks for your advice

Best, Sebastian

shoepfl commented 1 year ago

The problem seems to be that my ensemble_predicion (from ensemble.predict) also only saves condition_0 etc. not the condition ids which makes a mapping afterwards impossible

PaulJonasJost commented 1 year ago

The conditions are assigned based on the condition ids passed on to the AmiciPredictor, which leaves the question how to assign those. My strong guess currently is that this can be done by the order they are saved in the petab conditions file, but I will dig a bit through the code to find it. Thanks for notifying, you are correct, this at least something that needs to be documented more clearly and (if possible) automatically made more informative.

shoepfl commented 1 year ago

Ordering according to the conditions file was also my first guess. However, I realized this issue because it is for my example not the ordering of the PEtab conditions file. Of course now I can guess which condition corresponds to which plot but thats not a good way to do it.

Thanks for looking into it

PaulJonasJost commented 1 year ago

if you are using a petab problem, you could call the objective function with return_dict=True in order to find the correct condition ids. There in the rdatas object you can check the id of your amici model. An example code would be

objective = problem.objective
res = objective(example_parameter, return_dict=True)
ids = [rdata.id for rdata in res["rdatas"]]
shoepfl commented 1 year ago

@PaulJonasJost Thanks a lot the objective function indeed returns the correct ids.

This confirmed my strong assumption that the order of the conditions does not follow the order in the condition table. A direct mapping to the condition ids would be desirable