Git Product home page Git Product logo

pkpd's Introduction

PKPD: pharmacokinetics simplified

PKPD is a graphical interface for pharmacokinetic and (work in progress) pharmacodynamic modelling. It's for people who want to model pharmacological metabolism without having to touch any code!

Quickstart

PKPD requires python 3.6+ and myokit. To get started, git clone the repository and run the setup.py to install it as a python module. The interface can then be called from the terminal or command line using python -m PKPD.

In-depth installation guide

This guide is split into sections:-
A) Install python
B) Install myokit
C) Install git
D) Install PKPD
E) Use PKPD
F) Troubleshooting

A) How to install Python

  1. Open a terminal (iOS or ubuntu: search your apps for 'terminal') or command line (windows: open start menu & search 'cmd').
  2. Check if you have python already by typing python --version. If the version is 3.6 or above then you can skip this section.
  3. Go to www.python.org.
  4. Go to 'Downloads' and click on any release 3.6 or higher to download it.
  5. on windows or iOS, open your downloads folder and double-click the installer file. Follow the installer instructions. On ubuntu, python should be installed already; if it is not then something is horribly wrong.

B) How to install myokit

Full instructions for installing myokit on each operating system can be found here: www.myokit.org/install

C) How to install git

Type git --version to check if you have git already.

  • On windows, you can download an installer from www.git-scm.com/download/win.
  • On ubuntu, run sudo apt-get install git.
  • On iOS, the command above will show you how to install it if it is not installed.

D) How to install PKPD

  1. Make sure you have python and myokit installed.
  2. Open the terminal (or command line, on windows) and go to the folder you want to download to (using cd).
  3. Download PKPD using:-
git clone https://github.com/SABS-R3-projects/PKPD/
  1. Enter the installed directory by typing
cd PKPD
  1. Install the PKPD module and all dependencies with
pip install -e .

These commands should look like the picture below.

Congratulations! You successfully installed PKPD.

E) Use

Start the program by opening a terminal (or command line, on windows) and typing

python3 -m PKPD

F) Troubleshooting

I get the message Command 'git' not found

You might not have git installed: go to that section. Alternatively, you can download a .zip file from github, unzip it, and proceed with the instructions in the same way from there.

I get the message 'python' is not recognized as an internal or external command, operable program or batch file

Try replacing python with python3. If this doesn't work then you might not have python installed: go to that section.

I get the message Command 'pip' not found

Try replacing pip with pip3. If this doesn't work then you might not have python installed: go to that section.

I get the message ṫ̵̛͇̺͇͓͐̈́̀͒̿̏̆͝h̵̡̯̮̬̍͗̿̐̐̏̅͗̉̆̅̉͜ĕ̴͓̯͉͗̒̎͑͂̂̒̒͗̈́̓ṛ̶̡̭̗͕̀̄̅͐ę̶͔̹̥̖̠̼̎i̷̞̗̥̮̒̕s̵̲̱̭͔͙̑̐̾́̀̏̊̚͠â̶̧̫̣̗͔̘̹̝͓̬͇͒̿́̿̎ͅn̵̢̨̹̼̭̯͈̻̺̼̉̿̊̾͂̅͆͋̾̓͠ͅê̷̻͚̞̠̻̥̦͉̥͉̳̼̓͐̀́̓̌͗̃̕͠͝r̴̢̤͖̫͇̰̦̾͐̐̋͋͑̇͑͝r̸̛̛̼͔̺̹̯̼̻̅̾̐̅̋̋̉̍̀̚͝o̸͉̖̗̮̣͙͆̔̚r̵̠̳̖̟͉̞̰͕͍͂̋͒̾͗̿̋͜i̴̩̬͕̙̠͂̀̅n̴̢̢̳̤̥̣̠̻̹̥̼̮̞͑̍̒̈t̵̖̉̐̃́̊̌̋̚͝͝h̸̪̞͕̘̯̞͒̅̇e̴̠̓͌̒ṃ̷̧̭̞̬̳̹͔̹̙̈̊̑̓̇͛͒̓å̷͚̲̝͖̬̗̓͐̾̀̈͒͂̚͝ͅt̶͚̗͇̹̦̀͛̋ŗ̶̯͕̟̜͇̣̬̻̖̗̆̈́̍̊̀̎̈̑͑́͜͠i̸̡̡̛̟̺̮̤̽̒̋͒͝x̶̠̯͔̯̖̼̣̫͔̲̼̳̃̎

Your computer is haunted. Consider employing an exorcist.

Issues and contributions

If you find a bug or would like to contribute, then you are very welcome to get in contact through the github issues.

pkpd's People

Contributors

barnums avatar davaug avatar rebecca-rumney avatar simonmarchant avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pkpd's Issues

Speed up the model solve method

model.solve()

The model class works properly but is too slow for useful inference times. This is likely because of unnecessary logs in the background of Myokit.

Currently solving the test one compartment model takes 0.745 sec.

more details:

>>> p = pstats.Stats('tests/model/profile_solve')
>>> p.sort_stats('cumulative').print_stats(50)
Wed Dec 18 12:19:03 2019    tests/model/profile_solve

         335637 function calls (324001 primitive calls) in 0.745 seconds

   Ordered by: cumulative time
   List reduced from 3297 to 50 due to restriction <50>

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
    676/1    0.005    0.000    0.746    0.746 {built-in method builtins.exec}
        1    0.000    0.000    0.746    0.746 tests/model/profile_solve.py:15(<module>)
        1    0.000    0.000    0.498    0.498 /Users/david/Workspace/sabs-r3/PKPD/PKPD/model/model.py:73(solve)
        1    0.000    0.000    0.487    0.487 /Users/david/Workspace/sabs-r3/PKPD/env/lib/python3.7/site-packages/myokit/_sim/cvodesim.py:82(__init__)
        1    0.000    0.000    0.486    0.486 /Users/david/Workspace/sabs-r3/PKPD/env/lib/python3.7/site-packages/myokit/_sim/__init__.py:88(_compile)
   507/21    0.000    0.000    0.410    0.020 <frozen importlib._bootstrap>:211(_call_with_frames_removed)
        1    0.000    0.000    0.339    0.339 /Users/david/Workspace/sabs-r3/PKPD/env/lib/python3.7/site-packages/setuptools/__init__.py:142(setup)
        1    0.000    0.000    0.327    0.327 /usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/core.py:57(setup)
        1    0.000    0.000    0.323    0.323 /usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py:960(run_commands)
     10/2    0.000    0.000    0.323    0.162 /usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py:970(run_command)
      8/5    0.000    0.000    0.322    0.064 /usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/cmd.py:308(run_command)
        1    0.000    0.000    0.287    0.287 /usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/command/build.py:128(run)
        1    0.000    0.000    0.285    0.285 /Users/david/Workspace/sabs-r3/PKPD/env/lib/python3.7/site-packages/setuptools/command/build_ext.py:75(run)
        1    0.000    0.000    0.285    0.285 /usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/command/build_ext.py:278(run)
        1    0.000    0.000    0.284    0.284 /usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/command/build_ext.py:443(build_extensions)
        1    0.000    0.000    0.284    0.284 /usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/command/build_ext.py:471(_build_extensions_serial)
        1    0.000    0.000    0.284    0.284 /Users/david/Workspace/sabs-r3/PKPD/env/lib/python3.7/site-packages/setuptools/command/build_ext.py:193(build_extension)
        1    0.000    0.000    0.284    0.284 /usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/command/build_ext.py:486(build_extension)
   411/16    0.002    0.000    0.283    0.018 <frozen importlib._bootstrap>:978(_find_and_load)
   411/16    0.001    0.000    0.283    0.018 <frozen importlib._bootstrap>:948(_find_and_load_unlocked)
        2    0.000    0.000    0.282    0.141 /usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/ccompiler.py:909(spawn)
        2    0.000    0.000    0.282    0.141 /usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/spawn.py:16(spawn)
        2    0.000    0.000    0.282    0.141 /usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/spawn.py:88(_spawn_posix)
   387/20    0.001    0.000    0.280    0.014 <frozen importlib._bootstrap>:663(_load_unlocked)
        3    0.280    0.093    0.280    0.093 {built-in method posix.waitpid}
   325/19    0.001    0.000    0.279    0.015 <frozen importlib._bootstrap_external>:722(exec_module)
        1    0.000    0.000    0.243    0.243 /usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/ccompiler.py:511(compile)
        1    0.000    0.000    0.242    0.242 /usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/unixccompiler.py:111(_compile)
   425/84    0.000    0.000    0.188    0.002 {built-in method builtins.__import__}
  371/368    0.001    0.000    0.158    0.000 <frozen importlib._bootstrap>:576(module_from_spec)
    41/39    0.000    0.000    0.151    0.004 <frozen importlib._bootstrap_external>:1040(create_module)
    41/39    0.150    0.004    0.151    0.004 {built-in method _imp.create_dynamic}

New execution time: 0.327 including initialization. Just solving the ODE after initialization is now much faster.

Progress:

  • Implementation complete.
  • Fully tested.

Data display and check boxes for user to clarify data structure

Data display and check boxes for user to clarify data structure

Data file is displayed in home tab, once selected and a first structural analysis is performed (are patient IDs/ dose schedule present. These properties are highlighted in the data display.

The presence of bespoken properties are identified by heuristic methods, are hence prone to errors. Thus check boxes are provided to enable the user to correct the heuristic tests.

Progress:

  • [x ] Implementation complete.
  • [ x] manually tested.

Catch common errors

Catch errors

Use try/except blocks to catch errors that we know are possible. Requested Jan 15th.

Progress:

  • Implementation complete.
  • Fully tested.

Model Class

Model Class

Adding functionality to model class

Progress:
Most functions copied over

  • Implementation complete.
  • Fully tested.

Model unit read-in and dimensional analysis

Model units

Add a function to mmt read-in to grab param units and check that they are consistent. Requested Jan 15th.

Progress:

  • Read in units
  • Check units
  • Give preferred units

Inference options

Inference options

Allow bounded or non-bounded problems. Requested Jan 15th.

Progress:

  • Implementation complete.
  • Fully tested.

Create MultiOutputModel class for MultiOutputProblem

MultiOutputModel Class

Extension of pints.ForwardModel for MultiOutputProblem. Changes to to SingleOutputModel are almost trivial and are mainly in the simulate method.

Progress:

  • Implementation complete.
  • Fully tested.

Find optimal parameters

find_optimal_parameter

Within the SingleOutputProblem class the find_optimal_parameter method finds a set of parameters that optimises a chosen objective function.

Progress:

  • Implementation complete.
  • Fully tested.

How to run the application

I've just tried to install and run the PKPD gui, pip install looked like it worked fine.

There wasn't any information on how to run the gui? I tried:

python PKPD/gui/mainWindow.py

and got the following error:

WARNING:myokit._config:Unable to auto-detect Sundials version.
WARNING:myokit._config:Sundials version not set in myokit.ini and version auto-detection failed.
Traceback (most recent call last):
  File "PKPD/gui/mainWindow.py", line 8, in <module>
    from PKPD.inference import inference as inf
  File "/home/mrobins/git/PKPD/PKPD/inference/inference.py", line 4, in <module>
    import pints
ModuleNotFoundError: No module named 'pints'

looks like pints isn't installed by setup.py. even though pints doesn't have a pip install route, you can add a url dependency to setup.py, see here: https://stackoverflow.com/questions/32688688/how-to-write-setup-py-to-include-a-git-repo-as-a-dependency

set window size

_set_window_size

Method of the MainWindow class to set its window size.

Progress:

  • Implementation complete.
  • Fully tested.

MainWindow._set_tab_structure

_set_tab_structure

Sets up how the tab structure will work and look.

Progress:

  • Implementation complete.
  • Fully tested.

Profile Model and Inference

Performance improvement

Within Myokit and Pints some methods perform, for our means, irrelevant checks and data type conversions, because we only allow interaction via GUI and thus have full control over data types.

We might be able to improve performance by copying the relevant functionality and leave out checks.

Progress:

  • Implementation complete.
  • Fully tested.

mainWindow._set_geometry

"_set_geometry"

"Function to add a layout to the main window."

Progress:

  • Implementation complete.
  • Fully tested.

Create Model Repository and Refactor Code accordingly

Model Repository

"Create Model Repository in an easily generalizable manner. Update the Code to read-in those model files."

Progress:

  • Create 1-comparment model (bolus + subcut)
  • Update SingleOutput routine
  • Create 2-compartment model (bolus + subcut)
  • Update MultiOutput routine
  • Create 3-compartment model (bolus + subcut)
  • Create handler to choose the dimensionality of output and which compartments should be fitted and which be plotted. (Could by default choose centralCompartment for 1 dim data.)

Minimal home tab

Minimal home tab

  • File dialog for the model & protocol .mmt file
  • File dialog for the data file
  • Button to forward to simulation tab.

Progress:

  • Implementation complete.
  • manually tested.

Travis install

Hi guys!

Few quick comments after looking at your travis config

  1. There's a lot of PINTS constants that you don't need (these lines can all go, I think)
  2. You have a very big requirements.txt file with "pinned" (version-specific) dependencies, not sure you need this!
  3. PINTS isn't pip installable yet, so you'll need to do something more complicated, e.g. adding this to your travis before_install bit: - pip install -e git://github.com/pints-team/pints.git#egg=pints
  4. There's no setup.py file, so pip install . won't do anything

install PINTS with a setup.py

setup.py

"Create a setup.py that install PINTS and other dependencies."

Progress:

  • Implementation complete.
  • Fully tested.

Minimal simulation tab

Minimal simulation tab

Create minimal simulation tab:

  • plot data
  • read parameter in model and allow for input of initial values
  • find optimal parameters upon pressing an inference button
  • display found parameters with stats somewhere
  • plot model solution into data figure

Progress:

  • Implementation complete.
  • Fully tested.

Plot options

Plot options

Boundaries, logarithmic y-axis option. Requested Jan 15th.

Progress:

  • Implementation complete.
  • Fully tested.

MCMC sampler

"Method or Function Name"

"Short description of the method/function."

Progress:

  • Implementation complete.
  • Fully tested.

Create MultiOutputProblem class

MultiOutputProblem class

In spirit the same as the SingleOutputProblem but now solving the ODEs with the MultiOutputModel and suited to infer parameters from higher dimensional models.

Progress:

  • Implementation complete.
  • Fully tested.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.