-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
192 lines (141 loc) · 7.17 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# monolix2rx <img src="man/figures/logo.png" align="right" height="138" alt="" />
<!-- badges: start -->
[![R-CMD-check](https://github.com/nlmixr2/monolix2rx/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/nlmixr2/monolix2rx/actions/workflows/R-CMD-check.yaml)
[![Codecov test
coverage](https://codecov.io/gh/nlmixr2/monolix2rx/branch/main/graph/badge.svg)](https://app.codecov.io/gh/nlmixr2/monolix2rx?branch=main)
[![CRAN
version](http://www.r-pkg.org/badges/version/monolix2rx)](https://cran.r-project.org/package=monolix2rx)
[![CRAN total
downloads](https://cranlogs.r-pkg.org/badges/grand-total/monolix2rx)](https://cran.r-project.org/package=monolix2rx)
[![CRAN total
downloads](https://cranlogs.r-pkg.org/badges/monolix2rx)](https://cran.r-project.org/package=monolix2rx)
[![CodeFactor](https://www.codefactor.io/repository/github/nlmixr2/monolix2rx/badge)](https://www.codefactor.io/repository/github/nlmixr2/monolix2rx)
![r-universe](https://nlmixr2.r-universe.dev/badges/monolix2rx)
<!-- badges: end -->
The goal of monolix2rx is to convert `Monolix` to `rxode2` to use for
simulation and sharing the model in an open-source framework.
## Installation
You can install the development version of monolix2rx from
[GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("nlmixr2/monolix2rx")
```
## What you can do with `monolix2rx`/`babelmixr2`
You can do many useful tasks directly converting between nlmixr2 and
NONMEM models; you can:
- [Convert a Monolix model to a rxode2/nlmixr2 model](https://nlmixr2.github.io/monolix2rx/articles/convert-nlmixr2.html)
Then with nlmixr2 fit models and monolix2rx models coming from both conversions, you can:
- [Perform simulations of new
dosing](https://nlmixr2.github.io/monolix2rx/articles/simulate-new-dosing.html) from the Monolix model or even [simulate using the uncertainty in your model to simulate new scenarios](https://nlmixr2.github.io/monolix2rx/articles/simulate-uncertainty.html)
- [Modify the model to calculate derived parameters](https://nlmixr2.github.io/monolix2rx/articles/simulate-extra-items.html) (like AUC). These parameters slow down Monolix’s optimization, but can help in your simulation scenario.
- [Simulating with Covariates/Input PK
parameters](https://nlmixr2.github.io/monolix2rx/articles/simulate-new-dosing-with-covs.html). This example shows approaches to resample from the input dataset for covariate selection.
With nonmem2rx and babelmixr2, convert the imported rxode2 model to a nlmixr2 object, allowing:
- [Generation of Word and PowerPoint plots with
nlmixr2rpt](https://nlmixr2.github.io/monolix2rx/articles/create-office.html)
- [Easy VPC
creation](https://nlmixr2.github.io/monolix2rx/articles/create-vpc.html)
(with `vpcPlot()`)
- [Easy Individual plots with extra solved
points](https://nlmixr2.github.io/monolix2rx/articles/create-augPred.html). This
will show the curvature of individual and population fits for
sparse data-sets (with `augPred()`)
## Example
If you are trying to convert a Monolix to a rxode2 model you simply
need the path to the `mlxtran` file. For example, the classic demo of
theophylline is included in `monolix2rx` and can be imported below:
```{r example}
library(monolix2rx)
# First load in the model; in this case the theo model
# This is modified from the Monolix demos by saving the model
# file as a text file (hence you can access without model library).
# Additionally some of the file paths were shortened so they could
# be included with monolix2rx
pkgTheo <- system.file("theo", package="monolix2rx")
mlxtranFile <- file.path(pkgTheo, "theophylline_project.mlxtran")
rx <- monolix2rx(mlxtranFile)
rx
# If you are only interseted in the parsing you can use `mlxtran`
mlx <- mlxtran(mlxtranFile)
mlx
# this can be converted to a list
mlx <- as.list(mlx)
mlx$DATAFILE$FILEINFO$FILEINFO
```
## Translating models from the Monolix model library
For models using Monolix's model library, the models may not be
accessible as text files in all versions of Monolix. In the `mlxtran`
files you may see something like:
```
lib:bolus_1cpt_TlagVCl.txt
```
For older versions of Monolix, the model libraries are a group of text
files. You can find it by looking for a file in the Monolix library
like `bolus_1cpt_TlagVCl.txt`. In this case it would be in
`pk/bolus_1cpt_TlagVCl.txt`. The parent directory would be the model
library. If you have access to these files (even if they are from an
old version of Monolix) you can make `monolix2rx` aware of the model
library by using:
```{r setupLib}
# If the model library was located in ~/src/monolix/library
# Then you would set the model library up as follows:
options(monolix2rx.library="~/src/monolix/library/")
```
In Unix, this can be a symbolic link to whatever model library you
would like to use.
You can check to see if it works by trying to translate the model file
to `rxode2`:
```{r monolix2rxLib}
monolix2rx("lib:bolus_1cpt_TlagVCl.txt")
```
If you computer is setup correctly (like above) you will see the
translated model. Note since it isn't a `mlxtran` file the
relationship between population parameters, between subject
variability etc and initial parameter estimates are not in the model.
If the model library is not setup correctly you will see or cannot be
found in an old model library you get:
```{r monolix2rxLib2}
try(monolix2rx("lib:notThere.txt"))
```
In newer versions of Monolix, the model library was turned into a
binary database that is accessed by the GUI and `lixoftConnectors`.
If you have `lixoftConnectors` on your system and it can successfully
load the model with `lixoftConnectors::getLibraryModelContent()` then
`monolix2rx` will also load the model correctly (and will use this
version over the text files when both are setup)
This means you will need to import models into `rxode2` you need to:
- For a model built from the model library you will need:
- have a path to the text file Monolix Library and setup the
`monolix2rx.library` with
`options(monolix2rx.library="~/src/monolix/library/")`
- have `lixoftConnectors` installed and connected to a newer (and
licensed) version of Monolix that can get the model library
content by `lixoftConnectors::getLibraryModelContent()`
- or without these options, you will need to save the model to a
text file outside of the model library so you can import the model.
# Note on testing
The tests in this package include testing the `Monolix` demo files,
the `Monolix` library files (if available), and Monolix validation
suite.
Since these are a part of Monolix itself, they are not included in
this package. You can setup `monolix2rx` to run tests on all of these
files as well by setting up some options:
``` r
# setup monolix library (and will test that the parsing and translation are as expected)
options(monolix2rx.library="~/src/monolix/library/")
# setup monolix demos to be tested
options(monolix2rx.demo="~/src/monolix/demos/")
```