Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions absorption/README.md
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](#)

59 changes: 59 additions & 0 deletions absorption/mixedzeroandfirst.Rmd
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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

capture CP = CENT/VC;


$CAPTURE CP GUT CENT

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove $CAPTURE here.

'

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)
```

55 changes: 55 additions & 0 deletions absorption/mixedzeroandfirst.md
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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

capture CP = CENT/VC;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and similar comment for other examples too.


$CAPTURE CP GUT CENT

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove $CAPTURE

Choose a reason for hiding this comment

The 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)
```

![](mixedzeroandfirst_files/figure-markdown_github/unnamed-chunk-5-1.png)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 63 additions & 0 deletions absorption/parallel-firstorder.Rmd
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)
```

57 changes: 57 additions & 0 deletions absorption/parallel-firstorder.md
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)
```

![](parallel-firstorder_files/figure-markdown_github/unnamed-chunk-5-1.png)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 61 additions & 0 deletions absorption/weibull.Rmd
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));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vjd move the minus sign?
`double WB = 1 - exp(-pow((KA*TIME),GAMA));``


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)
```
13 changes: 13 additions & 0 deletions topics.Rproj
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