Git Product home page Git Product logo

pkme's Introduction

pkme

This package is designed for classic compartmental or physiologically-based pharmacokinetic models. These types of models are most frequently described by systems of linear ordinary differential equations ODEs. This package takes a matrix-based approach by finding the eigenvalue/eigenvector solution to a linear system of ODEs. Matrix manipulation is computationally fast in R, making it ideal for model fitting/parameter estimation, particularly for large models. This function most benefits models/systems with high dimensionality and/or problems with stiffness. The manner in which the exact solutions are solved for and integrated allows for relatively accurate estimates while using larger step sizes than traditional methods - increasing computation speed. We do not claim that this method is faster than traditional methods for all models, but it is a nice option for difficult models.

Structure: It is designed to take an initial condition matrix (single column vector of initial concentrations) and a rate coefficient matrix (flow/volume), dose profile (number of doses, start and stop time of each dose) along with any parameters needed to solve the system, and outputs a matrix of the concentrations in each compartment (rows) versus the time course (columns) for a given step size h. Each column represents a predicted data point at every 2*h.

Additional details:

Rate Coefficient Matrix (rate_coeff) : your flow per volume and any other parameters and microconstants included in the equations – as you’re looking at the matrix, rows represent compartments and columns represent concentrations

Initial Conditions Matrix (init_condition): just your initial conditions or in this case, initial concentrations in each compartment. Normally a vector of zeroes, but if you did have existing drug concentrations in some organs, it could be represented here

Dose Vector (dose) : where the dose is designated – the nice thing about this function is you can dose into any compartment just by specifying the row in the vector corresponding to that compartment. Let’s say you’re dosing IM and your muscle compartment is #4, you would place your dose in this vector in row 4. Homogenous and non-homogenous linear systems are handled using the same function. For homogenous systems, the "g vector" corresponding to the dose profile can be replaced by setting the total dose as the initial condition for the first compartment and the dose amount in the function to 0.

Also, some first order linear systems produce complex conjugate pairs in the eigenvalues or eigenvectors of the matrix solution. This function handles those complex conjugate pairs automatically.

Installation Shortcut

Install the latest release on CRAN with:

install.packages("pkme")

Install the current development version from GitHub with:

# install.packages("devtools")
devtools::install_git("git://github.com/hillaryhusband/pkme.git")

Examples:

One-compartment IV bolus:

library(pkme)

Model structure: dC/dt = -k10*C

Designate PK parameters

CL = 2.08 #(mL/min)
V = 7.88 #(mL)
k10 = CL/V #(1/min)
# create parameter vector to feed into solver
params <- c(CL, V, k10)

Create matrix form of model

pmat = matrix(0, nrow=1, ncol=1)
pmat[1,1] = -k10

Initialize initial conditions matrix

init = matrix(0, nrow=1, ncol=1)

Designate time:

tfinal = 10  # end of analysis (min)
dt = 0.5     # time step (min)

Set-up dose:

begin <- 0
end <- dt # for bolus, set infusion rate to length of time step
dosen <- 1
doseamt <- 30

Solve system:

model1 <- pkme(minute = tfinal,
               h = dt,
               rate_coeff = pmat,
               init_condition = init,
               pars = params,
               number_of_doses = dosen,
               dose = doseamt,
               start_time = begin,
               stop_time = end)

Output prints concentration at each time step for each compartment in the system. This code is available in the R directory as R/pkme-bolus-example.

NOTE: Three-compartment PK model vignette is available in the R directory as R/pkme-infusion-example.R.

pkme's People

Contributors

hillaryhusband avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

kylebaron rafudu

pkme's Issues

Release pkme 0.2.0

First release:

Prepare for release:

  • git pull
  • usethis::use_github_links()
  • urlchecker::url_check()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • git push
  • Draft blog post

Submit to CRAN:

  • usethis::use_version('minor')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • Add preemptive link to blog post in pkgdown news menu
  • usethis::use_github_release()
  • usethis::use_dev_version(push = TRUE)
  • Finish blog post
  • Tweet

Release pkme 0.2.1

First release:

Prepare for release:

  • git pull
  • urlchecker::url_check()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • git push

Submit to CRAN:

  • usethis::use_version('patch')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version(push = TRUE)

Release pkme 0.2.3

First release:

Prepare for release:

  • git pull
  • urlchecker::url_check()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • git push

Submit to CRAN:

  • usethis::use_version('patch')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version(push = TRUE)

Release pkme 0.1.1

First release:

Prepare for release:

  • git pull
  • usethis::use_github_links()
  • urlchecker::url_check()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • git push

Submit to CRAN:

  • usethis::use_version('patch')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version(push = TRUE)
  • usethis::use_news_md()

Release pkme 0.1.1

First release:

Prepare for release:

  • git pull
  • usethis::use_github_links()
  • urlchecker::url_check()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • git push

Submit to CRAN:

  • usethis::use_version('patch')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version(push = TRUE)
  • usethis::use_news_md()

Release pkme 0.2.1

First release:

Prepare for release:

  • git pull
  • urlchecker::url_check()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • git push

Submit to CRAN:

  • usethis::use_version('patch')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version(push = TRUE)

Release pkme 0.1.1

First release:

Prepare for release:

  • git pull
  • usethis::use_github_links()
  • urlchecker::url_check()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • git push

Submit to CRAN:

  • usethis::use_version('patch')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version(push = TRUE)

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.