Coder Social home page Coder Social logo

davaug / chi Goto Github PK

View Code? Open in Web Editor NEW
7.0 7.0 4.0 1.08 GB

Chi is an open source Python package which is designed for treatment response modelling.

Home Page: https://doi.org/10.21105/joss.05925

License: BSD 3-Clause "New" or "Revised" License

Python 100.00%
bayesian-inference inference pkpd python treatment-planning

chi's People

Contributors

davaug avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

chi's Issues

Add erlotinib PK dataset

Add an exemplary PK dataset to the data library

  • Document in a notebook where the data comes from
  • Add cleaned data to the data library
  • Implement a PKTimeSeriesPlot which shows one biomarker and the dosing point (amount on y axis)
  • Implement a PKPDTimeSeriesPlot which combines the PKTimeSeriesPlot and the PDTimeSeriesPlot

Implement HierarchicalLogLikelihood

A HierarchicalLogLikelihood

  • Takes a list of pints.LogPDFs
  • Takes a list of PopulationLogPDFs.
  • Implement a PopulationLogPDF base class
    • n_pop_params - population level parameters
    • sample for fixed pop parameters
    • call takes individual and pop parameters and returns score
    • pools_parameters return False or True
  • Implement a PoolParameters class that simply takes all parameters and sets them equal.
    • Evaluation returns 0
    • sampling return the input parameter
  • HierarchicalLogLikelihood checks whether pop pools, if so, adds just n_pop_params to input parameters, if not adds individual params and n_pop_params.
  • Then distributes the right parameters to the right log_likelihoods and PopulationLogPDFs. Possibly index entries for each individual loglikelihood and also index(mask) parameters for the population parameters.

Implement support in the ProblemModellingController

  • Extend the set_population_model class.

Create an app Convergence analysis app

Building on the PosteriorConvergencePlot build an app that

  • allows to dynamically set warm up phase
  • computes R hat, ESS etc live for everything but warm up phase
  • visualises left out samples from trace
  • updates marginal posterior for the non-warm up samples.

Create a log-likelihood wrapper more suitable for hierarchical modelling

Create a log-likelihood that

  • takes a pints.log-likelihood
  • takes the data as DataFrame
  • dynamically allows to perform individualised, (partially) pooled, and (later) hierarchical inference, possibly with a method for each
  • it should be possible to use them with a pints posterior
  • Create tickets for the inference controllers to return the estimates / samples with ID

Create a PKTimeSeriesPlot

Similar to PDTimeSeriesPlot

  • Displays dose events
  • Displays time series
  • Should expect pandas.DataFrame with a columns of applied dose
  • Also for model (look at PDTimeSeriesModel)

Create a PharmacokineticModel

Similar to Pharmacodynamic model, but

  • Needs set dosing regimen class
  • set and get PD output variable method typically drug.conc in central compartment
  • Set get dose input

Add support for PK datasets to ProblemModellingController

The controller takes a

  • pandas.DataFrame with keys for ID, time, and at least one biomarker. Optionally a dose key can be provided, by default None
  • Set model method accepts PharmacodynamicModels and PharmacokineticModels.
  • If dose_key None PharmacokineticModel is provided, show a Warning that doses are not set from the data.
  • If dose_key is provided and PharmacodynamicModel is provided, show a Warning that for PharmacodynamicModels dosing regimens cannot be set
  • If dose_key is not None and PharmacokineticModel is provided, set doses according to dataframe when error models are create. I.e. set flag self._dose_applied to True.

When this is done, complete #56 by 'hacking', i.e. set ID in dataset to pooled for all individuals and run optimisation.

Create a problem class

Create a problem class that

  • inherits from pints' problem base class
  • takes an instance of the erlotinib base class model, and times and values.
  • additionally to the standard pints.problem methods, create a method that allows to fix parameter values for the inference
  • set the output states.

Create a notebook that cleans the medium dose lung cancer data

In this issue I am creating a notebook that takes the lung cancer medium dose data from [1], imports it, cleans it, and exports the cleaned data file

  • Put data in raw_data repository
  • Import data
  • Interpret columns
  • Clean data
  • Visualise data
  • Export data to data directory

[1] Eigenmann et. al., Combining Nonclinical Experiments with Translational PKPD Modeling to Differentiate Erlotinib and Gefitinib, Mol Cancer Ther (2016)

Create a LogPosterior class

Create a log-posterior class similar to pints.LogPosterior

Additional features:

  • parameter_names method
  • id method

Create a SimulationController

Create a SimulationController dash app with the following features

  • Initialises as an empty figure.
  • Has an add model method that sets the model to be simulated (for now overwrite any previous model)
  • Generates sliders for all parameters of the model
  • Solves the model live for slider values (for now only allow SingleOutput models)
  • Has an add data method that shows the creates a scatter representation of the data
  • Has a method to set the simulation time range
  • Has a method that starts the app.
  • Potentially: Has a method that returns a static plotly.Figure of some slider configuration, such that simulation may be presented with nbviewer.

Possible extensions:

  1. Allow multiple outputs
  2. Allow simulation of multiple models
  3. Allow marking of current simulation, i.e. create a permanent trace of the current simulation, so outputs of multiple simulations may be more easily compared.

Refactor the OptimisationController

Following the ProblemModellingController class in #43, refactor the OptimisationController such that

  • instead of taking just one log-posterior, it can also take a list of log-posteriors.
  • if log-posterior is a list, run the defined optimisation for all log-posteriors.
  • The results have an ID column with the ID from the respective log-posterior.
  • Update the individual inference notebook.
  • Update the pooled inference nottebook.

Create a model structure that can combine different PK and PD models

  • Create a base class model
  • Create a PDModel class that inherits from the base class. This class should define methods that specify the PK input / and PD output states.
  • Create a PKModel class that inherits from the base class. This class should define methods that specify the PD input / and PK output states.
  • Create a PKPDModel class that inherits from the base class. This model takes a PK and PD model and combines them based on their specified PK/PD input/output states.
  • Improve docs of set administration (align equal signs)

Create a notebook that allows to explore the tumour growth PD model

Create a notebook that solves the tumour growth PD model with the error model suggested by Eigenmann et al.

  • Solve PD model in absence of treatment
  • Create sliders for all mechanistic and error parameters. Because combining parameters arbitrarily when precomputing the model, it makes sense to find the optimal parameters for one individual, and allow the sliders to perturb values around this optimal solution.
  • Allow to plot data next to the model.

Create a notebook that cleans the lung cancer control growth dataset

In this issue I am creating a notebook that takes the lung cancer control growth data from [1], imports it, cleans it, and exports the cleaned data file

  • Put data in raw_data repository
  • Import data
  • Interpret columns
  • Clean data
  • Visualise data
  • Export data to data directory

[1] Eigenmann et. al., Combining Nonclinical Experiments with Translational PKPD Modeling to Differentiate Erlotinib and Gefitinib, Mol Cancer Ther (2016)

Robustly test inference on individual mice

Extends #24.

The inference has been performed rather rash and not very controlled. Add the following features:

  • Prior predictive analysis to find suitable parameter priors, likely best done in an app that allows adjusting priors dynamically.
  • Keep optimisation
  • Run AMCMC or HMC for a short time in the vicinity of those points.
  • Plot marginal posteriors with their traces to explore convergence
  • Plot pair-wise correlations between parameters
  • Construct priors that encapsulate the inferred posteriors
  • Run simulation-based calibration for HMC
  • With the calibrated HMC and new priors run final chains
  • Show marginals and traces to convergence check
  • Plot marginal posterior distributions
  • Plot pair-wise correlations between parameters
  • Plot posterior predictive model

Create figure class that visualises marginal posteriors across individuals

This figure is not supposed to assess convergence, but compare marginal posteriors across individuals

  • Allow setting a warm up phase that can be excluded from the plot
  • Plots marginal posteriors of individuals next to each other (different chain runs are now taken as one chain)
  • Computes R hat and ESS in hovertext

Set up documentation

Setup docs generation with Sphinx and test documentation

  • Set up sphinx
  • Improve docstrings
  • Add docs to README
  • Set up doc tests.

Create a notebook that runs the control group inference for each individual

This notebook should

  • Display the data
  • Run an optimisation multiple times for each individual separately
  • Display the point estimates in a figure
  • Run an MCMC sampling routine for each individual separately
  • Display the traces as time series to visually inspect convergence
  • Display the traces as marginal histograms for the parameters
  • Display multi-dimensional histograms to explore correlations
  • Compute R, ESS, possibly rank R or R*

Replace brew update-reset

brew update-reset sometimes takes forever to setup Homebrew for sundials. Check whether there is a more light weight command.

Create a figure class that displays the MAP of multiple runs

Create a figure that

  • Takes a pandas.DataFrame with keys ['ID', 'Parameter', 'Estimate' , 'Score', 'Run']
  • Displays the estimates across runs in a bar plot. Each parameter in a separate figure.
  • Score and run in hovertext
  • Each individual gets a different colour

Create a figure class that visualises MCMC traces

Create a figure that takes samples from one individual and plots marginal posterior with trace.

This class is mainly to assess convergence of the traces.

  • Chains are assigned with different colours

Create a predictive Model class

The class should be initialised with a

  1. mechanistic model
  2. an error model
  3. optionally a population model

Has method

  • takes data, parameters (or prior/posterior dist) num of individuals and returns dataframe with simulated individuals.

Create a notebook that cleans the high dose lung cancer data

In this issue I am creating a notebook that takes the lung cancer control growth data from [1], imports it, cleans it, and exports the cleaned data file

  • Put data in raw_data repository
  • Import data
  • Interpret columns
  • Clean data
  • Visualise data
  • Export data to data directory

[1] Eigenmann et. al., Combining Nonclinical Experiments with Translational PKPD Modeling to Differentiate Erlotinib and Gefitinib, Mol Cancer Ther (2016)

Create a notebook that cleans the low dose lung cancer data

In this issue I am creating a notebook that takes the lung cancer low dose data from [1], imports it, cleans it, and exports the cleaned data file

  • Put data in raw_data repository
  • Import data
  • Interpret columns
  • Clean data
  • Visualise data
  • Export data to data directory

[1] Eigenmann et. al., Combining Nonclinical Experiments with Translational PKPD Modeling to Differentiate Erlotinib and Gefitinib, Mol Cancer Ther (2016)

Create SamplingController

Create a SamplingControler similar to the OptimisationController and building on pints.MCMCController

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.