metrumresearchgroup / mrgsolve

Simulate from ODE-based population PK/PD and QSP models in R
https://mrgsolve.org
GNU General Public License v2.0
130 stars 36 forks source link

Infusion issues and resolution #272

Closed kylebaron closed 6 years ago

kylebaron commented 7 years ago

After a recent refactoring of the main simulation loop (#241, #248) , we discovered some problems with the way infusions were implemented when there was also a lag time in the simulation.

Several issues have now been dealt with and are merged with the master branch. I also added several new unit tests to the package and re-visited the NONMEM comparison code (attached).

nmtest2.pdf

vjd commented 7 years ago

@kylebmetrum is infusion/bolus (out10) set up correctly in this document? It is an infusion + bolus and you provide a rate of 10 into cmt=1 which is the gut compartment.

ev <- ev(amt = 100, rate = 10) + ev(time = 12, amt = 50)

gives this below.. image

Should it not be

ev <- ev(amt = 100, rate = 10, cmt=2) + ev(time = 12, amt = 50)

just checking.

kylebaron commented 7 years ago

@vjd Thanks for (carefully) reading and checking the document! I'll add another scenario for IV infusion. We do a lot of sequential zero / first order absorption models so the example in there was sort of intended to be an infusion into GUT.

I have been working on SS with a lagtime (harder than it sounds ... at least with the way I have things set up. I'll be adding those tests and will fill in the IV infusion too.

KTB

vjd commented 7 years ago

@kylebmetrum I assumed so, but just wanted to confirm. This is an excellent resource to teach folks on how events are set up. Do you have a repo that I can contribute to? Couldn't find it

kylebaron commented 7 years ago

@vjd https://github.com/mrgsolve/nmtests Probably needs some organization to make it easy to contribute to and I'm not sure how easy it would be to run the NONMEM stuff on another platform. But please feel free to make a PR or even just suggest other scenarios that need to be tested.

dpastoor commented 7 years ago

@kylebmetrum you don't need to run nonmem on other platforms though. You just need to run nonmem once, then capture and store the results to compare against.

In addition, all the nonmem stuff could also have been run in a docker container, such as using https://hub.docker.com/r/osmosisfoundation/nonmem/ so all that would be needed is to add a license file to re-run the tests. We could help set this up.

IMO the flow would be

run nonmem --> parse outputs --> store as rds files for comparison.

run mrgsolve --> compare to stored output

benefit of this is the tests can still be managed over CI, and would also be reasonably quick since just comparing against rds outputs.

kylebaron commented 7 years ago

@dpastoor Thanks. The docker sounds like a nice option for this. In the comment I just wanted to make the point that the NONMEM setup (as it exists in the repo) couldn't be thought of as portable. It would be nice to (at least) get the nonmem "standards" organized somewhere to check against.