Skip to content

Commit

Permalink
use rxode2 model functions in the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
levenc committed Aug 27, 2024
1 parent 7b79d42 commit ba9b5db
Show file tree
Hide file tree
Showing 63 changed files with 2,815 additions and 1,490 deletions.
3 changes: 0 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ S3method(posologyr_error_lines,default)
S3method(posologyr_error_lines,norm)
S3method(posologyr_error_lines,rxUi)
S3method(posologyr_error_lines,t)
export(error_model_comb1)
export(error_model_comb2)
export(error_model_mixednm)
export(poso_dose_auc)
export(poso_dose_conc)
export(poso_estim_map)
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
## Documentation
* The README illustrates a simple example of dose adaptation
* `vignette("route_of_administration")` shows how to select a route of administration for optimal dosing
* `vignette("population_models")` describes the structure of prior population models written as model functions which can be parsed by `rxode2` and used by `posologyr`
* `vignette("posologyr_user_defined_models")` is renamed `vignette("classic_posologyr_models")`
* Examples use `rxode2` model functions

## Bug fix
* Fix a bug where `poso_estim_map()`, `poso_estim_sir()` and `poso_simu_pop()` failed for models featuring a single parameter with IIV.
Expand Down
210 changes: 97 additions & 113 deletions R/dosing_optim.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------
# posologyr: individual dose optimisation using population PK
# posologyr: individual dose optimization using population PK
# Copyright (C) Cyril Leven
#
# This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -100,37 +100,33 @@
#' rxode2::setRxThreads(2L) # limit the number of threads
#'
#' # model
#' mod_run001 <- list(
#' ppk_model = rxode2::rxode({
#' centr(0) = 0;
#' depot(0) = 0;
#' mod_run001 <- function() {
#' ini({
#' THETA_Cl <- 4.0
#' THETA_Vc <- 70.0
#' THETA_Ka <- 1.0
#' ETA_Cl ~ 0.2
#' ETA_Vc ~ 0.2
#' ETA_Ka ~ 0.2
#' prop.sd <- sqrt(0.05)
#' })
#' model({
#' TVCl <- THETA_Cl
#' TVVc <- THETA_Vc
#' TVKa <- THETA_Ka
#'
#' TVCl = THETA_Cl;
#' TVVc = THETA_Vc;
#' TVKa = THETA_Ka;
#' Cl <- TVCl*exp(ETA_Cl)
#' Vc <- TVVc*exp(ETA_Vc)
#' Ka <- TVKa*exp(ETA_Ka)
#'
#' Cl = TVCl*exp(ETA_Cl);
#' Vc = TVVc*exp(ETA_Vc);
#' Ka = TVKa*exp(ETA_Ka);
#' K20 <- Cl/Vc
#' Cc <- centr/Vc
#'
#' K20 = Cl/Vc;
#' Cc = centr/Vc;
#'
#' d/dt(depot) = -Ka*depot;
#' d/dt(centr) = Ka*depot - K20*centr;
#' d/dt(AUC) = Cc;
#' }),
#' error_model = function(f,sigma) {
#' dv <- cbind(f,1)
#' g <- diag(dv%*%sigma%*%t(dv))
#' return(sqrt(g))
#' },
#' theta = c(THETA_Cl=4.0, THETA_Vc=70.0, THETA_Ka=1.0),
#' omega = lotri::lotri({ETA_Cl + ETA_Vc + ETA_Ka ~
#' c(0.2,
#' 0, 0.2,
#' 0, 0, 0.2)}),
#' sigma = lotri::lotri({prop + add ~ c(0.05,0.0,0.00)}))
#' d/dt(depot) = -Ka*depot
#' d/dt(centr) = Ka*depot - K20*centr
#' Cc ~ prop(prop.sd)
#' })
#' }
#' # df_patient01: event table for Patient01, following a 30 minutes intravenous
#' # infusion
#' df_patient01 <- data.frame(ID=1,
Expand Down Expand Up @@ -399,37 +395,33 @@ poso_time_cmin <- function(dat=NULL,prior_model=NULL,tdm=FALSE,
#' rxode2::setRxThreads(2L) # limit the number of threads
#'
#' # model
#' mod_run001 <- list(
#' ppk_model = rxode2::rxode({
#' centr(0) = 0;
#' depot(0) = 0;
#' mod_run001 <- function() {
#' ini({
#' THETA_Cl <- 4.0
#' THETA_Vc <- 70.0
#' THETA_Ka <- 1.0
#' ETA_Cl ~ 0.2
#' ETA_Vc ~ 0.2
#' ETA_Ka ~ 0.2
#' prop.sd <- sqrt(0.05)
#' })
#' model({
#' TVCl <- THETA_Cl
#' TVVc <- THETA_Vc
#' TVKa <- THETA_Ka
#'
#' TVCl = THETA_Cl;
#' TVVc = THETA_Vc;
#' TVKa = THETA_Ka;
#' Cl <- TVCl*exp(ETA_Cl)
#' Vc <- TVVc*exp(ETA_Vc)
#' Ka <- TVKa*exp(ETA_Ka)
#'
#' Cl = TVCl*exp(ETA_Cl);
#' Vc = TVVc*exp(ETA_Vc);
#' Ka = TVKa*exp(ETA_Ka);
#' K20 <- Cl/Vc
#' Cc <- centr/Vc
#'
#' K20 = Cl/Vc;
#' Cc = centr/Vc;
#'
#' d/dt(depot) = -Ka*depot;
#' d/dt(centr) = Ka*depot - K20*centr;
#' d/dt(AUC) = Cc;
#' }),
#' error_model = function(f,sigma) {
#' dv <- cbind(f,1)
#' g <- diag(dv%*%sigma%*%t(dv))
#' return(sqrt(g))
#' },
#' theta = c(THETA_Cl=4.0, THETA_Vc=70.0, THETA_Ka=1.0),
#' omega = lotri::lotri({ETA_Cl + ETA_Vc + ETA_Ka ~
#' c(0.2,
#' 0, 0.2,
#' 0, 0, 0.2)}),
#' sigma = lotri::lotri({prop + add ~ c(0.05,0.0,0.00)}))
#' d/dt(depot) = -Ka*depot
#' d/dt(centr) = Ka*depot - K20*centr
#' Cc ~ prop(prop.sd)
#' })
#' }
#' # df_patient01: event table for Patient01, following a 30 minutes intravenous
#' # infusion
#' df_patient01 <- data.frame(ID=1,
Expand Down Expand Up @@ -725,37 +717,33 @@ poso_dose_auc <- function(dat=NULL,prior_model=NULL,tdm=FALSE,
#' rxode2::setRxThreads(2L) # limit the number of threads
#'
#' # model
#' mod_run001 <- list(
#' ppk_model = rxode2::rxode({
#' centr(0) = 0;
#' depot(0) = 0;
#' mod_run001 <- function() {
#' ini({
#' THETA_Cl <- 4.0
#' THETA_Vc <- 70.0
#' THETA_Ka <- 1.0
#' ETA_Cl ~ 0.2
#' ETA_Vc ~ 0.2
#' ETA_Ka ~ 0.2
#' prop.sd <- sqrt(0.05)
#' })
#' model({
#' TVCl <- THETA_Cl
#' TVVc <- THETA_Vc
#' TVKa <- THETA_Ka
#'
#' TVCl = THETA_Cl;
#' TVVc = THETA_Vc;
#' TVKa = THETA_Ka;
#' Cl <- TVCl*exp(ETA_Cl)
#' Vc <- TVVc*exp(ETA_Vc)
#' Ka <- TVKa*exp(ETA_Ka)
#'
#' Cl = TVCl*exp(ETA_Cl);
#' Vc = TVVc*exp(ETA_Vc);
#' Ka = TVKa*exp(ETA_Ka);
#' K20 <- Cl/Vc
#' Cc <- centr/Vc
#'
#' K20 = Cl/Vc;
#' Cc = centr/Vc;
#'
#' d/dt(depot) = -Ka*depot;
#' d/dt(centr) = Ka*depot - K20*centr;
#' d/dt(AUC) = Cc;
#' }),
#' error_model = function(f,sigma) {
#' dv <- cbind(f,1)
#' g <- diag(dv%*%sigma%*%t(dv))
#' return(sqrt(g))
#' },
#' theta = c(THETA_Cl=4.0, THETA_Vc=70.0, THETA_Ka=1.0),
#' omega = lotri::lotri({ETA_Cl + ETA_Vc + ETA_Ka ~
#' c(0.2,
#' 0, 0.2,
#' 0, 0, 0.2)}),
#' sigma = lotri::lotri({prop + add ~ c(0.05,0.0,0.00)}))
#' d/dt(depot) = -Ka*depot
#' d/dt(centr) = Ka*depot - K20*centr
#' Cc ~ prop(prop.sd)
#' })
#' }
#' # df_patient01: event table for Patient01, following a 30 minutes intravenous
#' # infusion
#' df_patient01 <- data.frame(ID=1,
Expand Down Expand Up @@ -1015,37 +1003,33 @@ poso_dose_conc <- function(dat=NULL,prior_model=NULL,tdm=FALSE,
#' rxode2::setRxThreads(2L) # limit the number of threads
#'
#' # model
#' mod_run001 <- list(
#' ppk_model = rxode2::rxode({
#' centr(0) = 0;
#' depot(0) = 0;
#' mod_run001 <- function() {
#' ini({
#' THETA_Cl <- 4.0
#' THETA_Vc <- 70.0
#' THETA_Ka <- 1.0
#' ETA_Cl ~ 0.2
#' ETA_Vc ~ 0.2
#' ETA_Ka ~ 0.2
#' prop.sd <- sqrt(0.05)
#' })
#' model({
#' TVCl <- THETA_Cl
#' TVVc <- THETA_Vc
#' TVKa <- THETA_Ka
#'
#' TVCl = THETA_Cl;
#' TVVc = THETA_Vc;
#' TVKa = THETA_Ka;
#' Cl <- TVCl*exp(ETA_Cl)
#' Vc <- TVVc*exp(ETA_Vc)
#' Ka <- TVKa*exp(ETA_Ka)
#'
#' Cl = TVCl*exp(ETA_Cl);
#' Vc = TVVc*exp(ETA_Vc);
#' Ka = TVKa*exp(ETA_Ka);
#' K20 <- Cl/Vc
#' Cc <- centr/Vc
#'
#' K20 = Cl/Vc;
#' Cc = centr/Vc;
#'
#' d/dt(depot) = -Ka*depot;
#' d/dt(centr) = Ka*depot - K20*centr;
#' d/dt(AUC) = Cc;
#' }),
#' error_model = function(f,sigma) {
#' dv <- cbind(f,1)
#' g <- diag(dv%*%sigma%*%t(dv))
#' return(sqrt(g))
#' },
#' theta = c(THETA_Cl=4.0, THETA_Vc=70.0, THETA_Ka=1.0),
#' omega = lotri::lotri({ETA_Cl + ETA_Vc + ETA_Ka ~
#' c(0.2,
#' 0, 0.2,
#' 0, 0, 0.2)}),
#' sigma = lotri::lotri({prop + add ~ c(0.05,0.0,0.00)}))
#' d/dt(depot) = -Ka*depot
#' d/dt(centr) = Ka*depot - K20*centr
#' Cc ~ prop(prop.sd)
#' })
#' }
#' # df_patient01: event table for Patient01, following a 30 minutes intravenous
#' # infusion
#' df_patient01 <- data.frame(ID=1,
Expand Down
2 changes: 1 addition & 1 deletion R/input_validation.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------
# posologyr: individual dose optimisation using population PK
# posologyr: individual dose optimization using population PK
# Copyright (C) Cyril Leven
#
# This program is free software: you can redistribute it and/or modify
Expand Down
2 changes: 1 addition & 1 deletion R/iov.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------
# posologyr: individual dose optimisation using population PK
# posologyr: individual dose optimization using population PK
# Copyright (C) Cyril Leven
#
# This program is free software: you can redistribute it and/or modify
Expand Down
2 changes: 1 addition & 1 deletion R/ofv.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------
# posologyr: individual dose optimisation using population PK
# posologyr: individual dose optimization using population PK
# Copyright (C) Cyril Leven
#
# This program is free software: you can redistribute it and/or modify
Expand Down
Loading

0 comments on commit ba9b5db

Please sign in to comment.