Open-Systems-Pharmacology / R-Toolbox

Other
4 stars 7 forks source link

New function request: Scaling between species #39

Closed PavelBal closed 4 years ago

PavelBal commented 6 years ago

It should be possible to scale an existing model to the physiology of another species from within the toolbox. E.g., if a human to a mouse model.

The problem is described here: #378. In short, the structures differ between species, so simply applying the parameter sets of a respective species leads to faulty models.

We should agree on a strategy here. The desired behavior is that of the "Scale"-function in PK-Sim. Support from the PK-Sim core team would be of great help, as they know best what the differences are.

msevestre commented 6 years ago

With Scale function do you mean Individual scaling? All is done by parameter path in the hierarchie

PavelBal commented 6 years ago

With Scale function do you mean Individual scaling?

Yes.

All is done by parameter path in the hierarchie

But the discussion in #378 points to the fact, that the paths are not consistent?

msevestre commented 6 years ago

If the individual structure is different, then scaling will simply ignore those parameters, this is correct.

Now if the structure is based on the calculation method used, then this is different because the modules (e.g. ORAL model) are created dynamically WHEN the simulation is built.

The parameter mentioned in #378 can definitely be found by path in both individuals. Only one is a formula based on heights, the other one is a constant value. No problem there for scaling

So which parameters are the one causing the issue?

StephanSchaller commented 6 years ago

Only one is a formula based on heights, the other one is a constant value. No problem there for scaling

It may be/is a problem for an "easy" solution to scaling. Ideally we we want to scale by only overwriting constants. So a scaling that keeps (most) formulas intact and not turn them into constants.

A quick way would be sth like [path, value] = getParameter('*','allNonFormula') --> setParameter(value, path) (not actually correct code). However the path vectors we would get from human and e.g. monkey here would in fact be inconsistent (as the set of paths of only constant parameters is not the same). So we will need a routine that predefines the MINIMAL set of Parameters (constant or formula) that need to be overwritten.

The set returned by the current Matlab function createPKSimIndividual in not suitable for this.

So maybe this function could be developed in a way such that if you hand it a PBPK-based simulation file (XML) of any species it turns it into a PBPK-Simulation file of the specified species with the specified antropometric values (height, weight, age...)....while keeping (as many as possible) formulas intact.

Of course, aligning model (i.e. formula) structures between species and integrating parameter-based switches for PBPK modules/spatial structures (i.e. GI Tract, pregnancy,...) would certainly make this function a lot simpler.

msevestre commented 6 years ago

So we will need a routine that predefines the MINIMAL set of Parameters (constant or formula) that need to be overwritten.

Not sure what you mean here

The set returned by the current Matlab function createPKSimIndividual in not suitable for this.

It only returns parameter changed by the create individual parameters. What other parameters do you need?

StephanSchaller commented 6 years ago

Not sure what you mean here

Makes sense, because I meant: we need a routine that uses a predefined MINIMAL set of parameters (constant or formula) that need to be overwritten.

It only returns parameter changed by the create individual parameters. What other parameters do you need?

Well, it only returns parameters to change an individual within the SAME species, e,g changing a young to an old human (at least last time I checked). Monkey_Physiology.xlsx

I have attached a list of parameters required to make a monkey from a human (using the mapping descibed in #378 (unrelated: somehow cross-repository issue referecing does not work automatically?))

msevestre commented 6 years ago

unrelated: somehow cross-repository issue referecing does not work automatically?

Only works within the same repository automatically (github cannot know otherwise which repo you are referencing...#378 could be defined in MoBi, PKSim etc..). If you want to point to #378 in PK-sim for example, you need to copy the full path like so #378

Well, it only returns parameters to change an individual within the SAME species

This method does not deal with scaling / changing from one species to another. It returns ALL parameters that are changed by the create individual algorithm. This is not a scaling method algorithm nor should it be used as such. Here is the actual code

we need a routine that uses a predefined MINIMAL set of parameters (constant or formula) that need to be overwritten

Can you give me an example of what is it you mean?

Also can you give me an example of the scaling you want to achieve. I don't think that what you are trying to do is even working in PK-Sim. For example scaling a Human that is taller than average to Monkey by changing only the height would result in no scaling at all

Here I just scaled one tall default human (where I also changed the length of duodenum) to monkey and only this one parameter is available for scaling image

All others parameters are left as is....

In general (at least in PKSim) we scale from Animal => Human and then from Adult to Kid so this use case does not really apply probably

StephanSchaller commented 6 years ago

Can you give me an example of what is it you mean?

Okay, I have a use case: As you know, I have developed a rather complex PBPK/PD model for Diabetes in the past. For this, I coupled 3 human PBPK models for Insulin, Glucose and glucagon and added quite a number of additional reactions and even some compartments (that automatically scale with BW) in MoBi.

Now, for preclinical research we scaled this model to Rats, Minipigs and Monkeys. One part of the scaling was to scale the PBPK backbone (so all parameters/structures as they are generated in PKSim) from human to animal. To find out, what Parameters Need changing, I looked into the parameter space for a human PBPK model and the animal PBPK models and tried to find out:

  1. Which Parameters are exactly the same (either the same constants or exactly the same formula with same references)
  2. Which formula-based Parameters use different formulas and
  3. Which Parameters are unique for either human or animal (e.g. gestational age does not exist in animals)

Now 2 & 3 and the the mapping described in #378, resulted in the parameter-set I attached above. If you initialize a human PBPK model in Matlab (or R) and set These Parameters you will turn your human into a monkey. I am pretty sure it works exactöy as expected but urrently I am doing some quality checks if this is really the case ;-)

However, this is a manual (and slightly customized) Workaround and I think there should be an "official" Quality-controlled function in the Matlab & R Toolboxes that does the same.

I don't think that what you are trying to do is even working in PK-Sim.

I hope this is not the case because users are expecting the scaling to do exactly that: turn the individual they want to scale (be it animal or human) into an individual they specify in the scale method (be it animal or human). No matter if it was a extremely tall or big individual.

@Yuri05 ist this the case?

PavelBal commented 6 years ago

This method does not deal with scaling / changing from one species to another.

OK, finally we arrived at the source of the problem. Now we can go back to the actual feature request: "It should be possible to scale an existing model to the physiology of another species from within the toolbox. E.g., if a human to a mouse model." Or, if it sounds better, let's substitute "scale" by "translate".

So, in PK-Sim, one can "scale" a human individual to a monkey/rat/whatever individual. I suppose (hope) that the resulting simulation reflects the physiology of the selected species. We would like to have a similar option from within the toolboxes (change a species of the provided model).

As we just figured out, simple applying the parameter set produced by PKSimCreateIndividual() does not solve the problem (not intended to). How must the workflow look like?

msevestre commented 6 years ago

First and foremost, Individual in PK-Sim has nothing to do with a Simulation. It is just a building block that will be used eventually in one or many simulations. From reading the last two posts, it seems that there is some misunderstanding there.

Here is how the Individual scaling was specified and implemented in PK-Sim.

That means that if you do not change any parameter in your source individual, the scaling algorithm won't change anything. It will simply create a NEW Individual albeit adding all enzymes from Ind1 to Ind2.

So, in PK-Sim, one can "scale" a human individual to a monkey/rat/whatever individual. I suppose (hope) that the resulting simulation reflects the physiology of the selected species.

When you scale an individual in PK-Sim, you only create an Individual. This has nothing to do with a simulation. So if you scale a human to a monkey, you will get a monkey alright but a NEW monkey not used in any simulation. So there is no resulting simulation whatsoever.

Now that this is out of the way, what you are trying to do in R works at a complete other level, the xml file that is the most simple representation of a simulation where all structure has been removed.

I am not sure how the workflow should look like but I can imagine that a new function is required in PK-Sim that would return for a given {Species, Population, Gender..}

  1. the list of all parameters (similar as now)
  2. the list of all derived parameters (all parameters that are a function of those parameters in 1).

That way, you would also get a parameter such as Human length of duodenum, even though this is not changed by the create individual algorithm directly.

With this information for the source individual (in your case human) and the target individual (in your case Monkey), you should be able to see what parameter have changed from human to monkey and set them accordingly....

Does that work in all cases (constant vs formula etc..) no idea.. :)

StephanSchaller commented 6 years ago

From reading the last two posts, it seems that there is some misunderstanding there.

Absolutely not. Scaling in PKSim was just given as an example to somehow make clear what we want to achieve on the "Simulation" Level. But I guess that just caused more confusion.

what you are trying to do in R works at a complete other Level

Agreed. On the simulation level.

the xml file that is the most simple representation of a simulation where all structure has been removed.

Disagree. Structure is contained within the path Information. If you mean the BuildingBlock structure, I agree. But does that matter? We still know what makes up the "individual" (or "physiology") part of the simulation that defines a human or an animal. You just have to compare two "dummy" simulations created in PKSim.

Of course it becomes more complicated if the user changed formula based parameters to become constants But I guess we can catch this, put out a warning, or ask if the parameter should be set back to formula or propose a scaling method (similar to the scale funtion for an "individual" in PKSim). This is easier when scaling from human to animal, as the animal structure is kind of a subset of the human structure (you will have to set age and weight and a few other parameters to zero) but could also be possible the other way round, but then you would have to insert structure/parameters on the XML level.

And here I come back to my original proposal: to make all PBPK model structures the same (formulas and numer of parameters and structures) and define them solely by their constants (to become a rat without gallbladder, a pregnant woman or even to deactivate the GITract if we do not have oral administration. Then you just need to set a few prameters to "true" or "false").

This would make "simulation-level-inter-species-scaling" a lot easier and less error prone. And the standardization would make additional QC functions possible (did I accidently change a formula to become a constant?). Or first you develop a comples QSP model in animals but then realize you also need to simulate pregnant women?!

And as I believe QSP modeling (complex PBPK/PD models) will also be a very important pillar for success of the OSP, we should really be thinking about taking that step!?

...maybe we should continue this discussion somwhere over a glass of red wine? ;-)

Yuri05 commented 6 years ago

I would suggest to adjust OSP PBPK models as described here.

Then (in my understanding) no additional "scaling" functionality in the toolboxes would be required. Having a model for _Species1 the user would just call _PKSimCreateIndividual(Species2) and overwrite model parameters with the new data set.