-
Notifications
You must be signed in to change notification settings - Fork 3
add absorption examples #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,7 @@ | ||
| # Absorption models | ||
|
|
||
| [Sequential zero-/first-order absorption](sequential.md) | ||
| [Parallel-firstorder absorption](parallel-firstorder.md) | ||
| [Mixed first order abs and zero order infusion](mixedzeroandfirst.md) | ||
| [Weibull absorption](#) | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| --- | ||
| title: "Mixed first order abs and zero order infusion" | ||
| output: github_document | ||
| --- | ||
|
|
||
| ```{r,echo = FALSE, message = FALSE} | ||
| knitr::opts_chunk$set(comment='.', | ||
| message = FALSE, warning = FALSE) | ||
| ``` | ||
|
|
||
| ```{r} | ||
| library(mrgsolve) | ||
| library(tidyverse) | ||
| ``` | ||
|
|
||
| ## Mixed first order abs into gut and zero order infusion | ||
|
|
||
| ```{r} | ||
| code <- ' | ||
| $PARAM CL = 5, VC = 50, KA = 0.5, GUTBIOAV = 0.5, GUTLAGT=0 | ||
| BIOAV = 1, LAGT = 5, MODE = 0, DUR2 = 4, RAT2 = 10 | ||
|
|
||
| $CMT GUT CENT | ||
|
|
||
| $MAIN | ||
| F_GUT = GUTBIOAV; | ||
| ALAG_GUT = GUTLAGT; | ||
|
|
||
| F_CENT = 1-F_GUT; | ||
| ALAG_CENT = LAGT; | ||
|
|
||
| if(MODE==1) R_CENT = RAT2; | ||
| if(MODE==2) D_CENT = DUR2; | ||
|
|
||
| $ODE | ||
|
|
||
| dxdt_GUT = -KA*GUT; | ||
| dxdt_CENT = KA*GUT - (CL/VC)*CENT; | ||
|
|
||
| $TABLE | ||
| double CP = CENT/VC; | ||
|
|
||
| $CAPTURE CP GUT CENT | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove |
||
| ' | ||
|
|
||
| mod <- mcode_cache("mixed", code) | ||
| ``` | ||
|
|
||
| ```{r} | ||
| mod <- update(mod, end=72) | ||
| ``` | ||
|
|
||
| ### mixed zero and first-order events | ||
| ```{r} | ||
| ev2 <- ev(ID=1,amt = 10, time=0, cmt=1) + ev(ID=1,time = 0, amt = 10, cmt=2, rate=-2, MODE=2) | ||
| out <- mod %>% Req(GUT, CENT, CP) %>% mrgsim(ev2) | ||
| plot(out) | ||
| ``` | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| Mixed first order abs and zero order infusion | ||
| ================ | ||
|
|
||
| ``` r | ||
| library(mrgsolve) | ||
| library(tidyverse) | ||
| ``` | ||
|
|
||
| Mixed first order abs into gut and zero order infusion | ||
| ------------------------------------------------------ | ||
|
|
||
| ``` r | ||
| code <- ' | ||
| $PARAM CL = 5, VC = 50, KA = 0.5, GUTBIOAV = 0.5, GUTLAGT=0 | ||
| BIOAV = 1, LAGT = 5, MODE = 0, DUR2 = 4, RAT2 = 10 | ||
|
|
||
| $CMT GUT CENT | ||
|
|
||
| $MAIN | ||
| F_GUT = GUTBIOAV; | ||
| ALAG_GUT = GUTLAGT; | ||
|
|
||
| F_CENT = 1-F_GUT; | ||
| ALAG_CENT = LAGT; | ||
|
|
||
| if(MODE==1) R_CENT = RAT2; | ||
| if(MODE==2) D_CENT = DUR2; | ||
|
|
||
| $ODE | ||
|
|
||
| dxdt_GUT = -KA*GUT; | ||
| dxdt_CENT = KA*GUT - (CL/VC)*CENT; | ||
|
|
||
| $TABLE | ||
| double CP = CENT/VC; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ... and similar comment for other examples too. |
||
|
|
||
| $CAPTURE CP GUT CENT | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ... same comment for other examples too. |
||
| ' | ||
|
|
||
| mod <- mcode_cache("mixed", code) | ||
| ``` | ||
|
|
||
| ``` r | ||
| mod <- update(mod, end=72) | ||
| ``` | ||
|
|
||
| ### mixed zero and first-order events | ||
|
|
||
| ``` r | ||
| ev2 <- ev(ID=1,amt = 10, time=0, cmt=1) + ev(ID=1,time = 0, amt = 10, cmt=2, rate=-2, MODE=2) | ||
| out <- mod %>% Req(GUT, CENT, CP) %>% mrgsim(ev2) | ||
| plot(out) | ||
| ``` | ||
|
|
||
|  | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| --- | ||
| title: "Parallel-firstorder absorption" | ||
| output: | ||
| github_document | ||
| --- | ||
|
|
||
| ```{r,echo = FALSE, message = FALSE} | ||
| knitr::opts_chunk$set(comment='.', | ||
| message = FALSE, warning = FALSE) | ||
| ``` | ||
|
|
||
| ```{r} | ||
| library(mrgsolve) | ||
| library(tidyverse) | ||
| ``` | ||
|
|
||
| ## Two parallel first order absorption models | ||
|
|
||
| ```{r} | ||
| code <- ' | ||
| $PARAM CL = 5, VC = 50, KA1 = 0.8, KA2=0.6 | ||
| GUT1BIOAV = 0.5, GUT1LAGT=0, GUT2BIOAV = 1, GUT2LAGT=5 | ||
| BIOAV = 1, LAGT = 0 | ||
|
|
||
| $CMT GUT1 GUT2 CENT | ||
|
|
||
| $MAIN | ||
| F_GUT1 = GUT1BIOAV; | ||
| ALAG_GUT1 = GUT1LAGT; | ||
|
|
||
| F_GUT2 = 1- GUT1BIOAV; | ||
| ALAG_GUT2 = GUT2LAGT; | ||
|
|
||
| F_CENT = BIOAV; | ||
| ALAG_CENT = LAGT; | ||
|
|
||
| $ODE | ||
|
|
||
| dxdt_GUT1 = -KA1*GUT1; | ||
| dxdt_GUT2 = -KA2*GUT2; | ||
| dxdt_CENT = KA1*GUT1 + KA2*GUT2 - (CL/VC)*CENT; | ||
|
|
||
| $TABLE | ||
| double CP = CENT/VC; | ||
|
|
||
| $CAPTURE CP | ||
| ' | ||
|
|
||
| mod <- mcode_cache("parabs", code) | ||
| ``` | ||
|
|
||
| ```{r} | ||
| mod <- update(mod, end=72) | ||
| ``` | ||
|
|
||
| ### two-parallel first-order events | ||
|
|
||
| ```{r} | ||
| ev1 <- ev(ID=1, amt = 10, cmt=1) + ev(ID=1, amt = 10, cmt=2) | ||
| out <- mod %>% Req(GUT1, GUT2, CP) %>% mrgsim(ev1) | ||
| plot(out) | ||
| ``` | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| Parallel-firstorder absorption | ||
| ================ | ||
|
|
||
| ``` r | ||
| library(mrgsolve) | ||
| library(tidyverse) | ||
| ``` | ||
|
|
||
| Two parallel first order absorption models | ||
| ------------------------------------------ | ||
|
|
||
| ``` r | ||
| code <- ' | ||
| $PARAM CL = 5, VC = 50, KA1 = 0.8, KA2=0.6 | ||
| GUT1BIOAV = 0.5, GUT1LAGT=0, GUT2BIOAV = 1, GUT2LAGT=5 | ||
| BIOAV = 1, LAGT = 0 | ||
|
|
||
| $CMT GUT1 GUT2 CENT | ||
|
|
||
| $MAIN | ||
| F_GUT1 = GUT1BIOAV; | ||
| ALAG_GUT1 = GUT1LAGT; | ||
|
|
||
| F_GUT2 = 1- GUT1BIOAV; | ||
| ALAG_GUT2 = GUT2LAGT; | ||
|
|
||
| F_CENT = BIOAV; | ||
| ALAG_CENT = LAGT; | ||
|
|
||
| $ODE | ||
|
|
||
| dxdt_GUT1 = -KA1*GUT1; | ||
| dxdt_GUT2 = -KA2*GUT2; | ||
| dxdt_CENT = KA1*GUT1 + KA2*GUT2 - (CL/VC)*CENT; | ||
|
|
||
| $TABLE | ||
| double CP = CENT/VC; | ||
|
|
||
| $CAPTURE CP | ||
| ' | ||
|
|
||
| mod <- mcode_cache("parabs", code) | ||
| ``` | ||
|
|
||
| ``` r | ||
| mod <- update(mod, end=72) | ||
| ``` | ||
|
|
||
| ### two-parallel first-order events | ||
|
|
||
| ``` r | ||
| ev1 <- ev(ID=1, amt = 10, cmt=1) + ev(ID=1, amt = 10, cmt=2) | ||
| out <- mod %>% Req(GUT1, GUT2, CP) %>% mrgsim(ev1) | ||
| plot(out) | ||
| ``` | ||
|
|
||
|  |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| --- | ||
| title: "Weibull absorption" | ||
| output: github_document | ||
| --- | ||
|
|
||
| ```{r,echo = FALSE, message = FALSE} | ||
| knitr::opts_chunk$set(comment='.', | ||
| message = FALSE, warning = FALSE) | ||
| ``` | ||
|
|
||
| ```{r} | ||
| library(mrgsolve) | ||
| library(tidyverse) | ||
| ``` | ||
|
|
||
| ## Weibull-type absorption | ||
|
|
||
| ```{r} | ||
| code <- ' | ||
| $PARAM CL = 5, VC = 50, KA = 0.4, GUTBIOAV = 1, GUTLAGT=0, GAMA=4 | ||
| BIOAV = 1, LAGT = 0 | ||
|
|
||
| $CMT GUT CENT | ||
|
|
||
| $MAIN | ||
| // Weibull parameters | ||
| double GAMA1 = GAMA; | ||
|
|
||
| // Weibull function | ||
| double WB = 1 - exp(pow((-KA*TIME),GAMA1)); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @vjd move the minus sign? |
||
|
|
||
| F_GUT = GUTBIOAV; | ||
| ALAG_GUT = GUTLAGT; | ||
|
|
||
| F_CENT = BIOAV; | ||
| ALAG_CENT = LAGT; | ||
|
|
||
| $ODE | ||
| dxdt_GUT = -WB*GUT; | ||
| dxdt_CENT = WB*GUT - (CL/VC)*CENT; | ||
|
|
||
| $TABLE | ||
| double CP = CENT/VC; | ||
|
|
||
| $CAPTURE CP | ||
| ' | ||
|
|
||
| mod <- mcode_cache("weibull", code) | ||
| ``` | ||
|
|
||
| ```{r} | ||
| mod <- update(mod, end=72) | ||
| ``` | ||
|
|
||
| ### First order events | ||
|
|
||
| ```{r} | ||
| ev3 <- ev(ID=1,amt = 10, cmt=1) | ||
| out<- mod %>% Req(GUT, CENT, CP) %>% mrgsim(ev3) | ||
| plot(out) | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| Version: 1.0 | ||
|
|
||
| RestoreWorkspace: Default | ||
| SaveWorkspace: Default | ||
| AlwaysSaveHistory: Default | ||
|
|
||
| EnableCodeIndexing: Yes | ||
| UseSpacesForTab: Yes | ||
| NumSpacesForTab: 2 | ||
| Encoding: UTF-8 | ||
|
|
||
| RnwWeave: Sweave | ||
| LaTeX: pdfLaTeX |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
capture CP = CENT/VC;