Overview

Description

Read data in a Monolix/NONMEM format and Monolix project

Usage

readDatamlx(project = NULL, datafile = NULL, header = NULL, infoProject = NULL, addl.ss = 10)

Arguments

project
a Monolix project
datafile
a formatted data file
header
a vector of strings (mandatory if datafile is used)
infoProject

an xmlfile

addl.ss
number of additional doses to use for steady-state (default=10)

Value

A list of data frame.


Reading a data file

The header

Let us use the warfarin data file in a Monolix format:

head(read.table('data/warfarin_data.txt', header=TRUE, sep="\t"))
##    id time amt  dv dvid   wt age sex
## 1 100  0.0 100   .    1 66.7  50   1
## 2 100  0.5   .   0    1 66.7  50   1
## 3 100  1.0   . 1.9    1 66.7  50   1
## 4 100  2.0   . 3.3    1 66.7  50   1
## 5 100  3.0   . 6.6    1 66.7  50   1
## 6 100  6.0   . 9.1    1 66.7  50   1

readDatamlx(datafile= ..., header=...) reads a Monolix data file and create several data frames. A header should be provided, using the following reserved key-words:

id, time, amt, rate, tinf, y, ytype, x, cov, cat, occ, mdv, evid, addl, ss, ii, ignore

In this example, wt and age are continuous covariates while sex is categorical

d <- readDatamlx(datafile = 'data/warfarin_data.txt', 
                 header   = c('id','time','amt','y','ytype','cov','cov','cat'))
names(d)
## [1] "treatment" "y1"        "y2"        "covariate" "id"        "N"        
## [7] "catNames"
head(d$treatment)
##    id time amount
## 1 100    0    100
## 2   1    0    100
## 3   2    0    100
## 4   3    0    120
## 5   4    0     60
## 6   5    0    113
head(d$covariate)
##    id   wt age sex
## 1 100 66.7  50   1
## 2   1 66.7  50   1
## 3   2 66.7  31   1
## 4   3 80.0  40   1
## 5   4 40.0  46   0
## 6   5 75.3  43   1
head(d$y1)
##    id time   y1
## 1 100  0.5  0.0
## 2 100  1.0  1.9
## 3 100  2.0  3.3
## 4 100  3.0  6.6
## 5 100  6.0  9.1
## 6 100  9.0 10.8

Some columns can be ignored:

d <- readDatamlx(datafile = 'data/warfarin_data.txt', 
                 header   = c('id','time','amt','y','ytype','cov','ignore','ignore'))
head(d$covariate)
##    id   wt
## 1 100 66.7
## 2   1 66.7
## 3   2 66.7
## 4   3 80.0
## 5   4 40.0
## 6   5 75.3


EVID and MDV columns

Column EVID can be used instead of dots (“.”) in the data file

head(read.table('data/warfarin_data_evid.txt', header=TRUE, sep="\t"))
##    id time amt  dv dvid   wt age sex evid
## 1 100  0.0 100   0    1 66.7  50   1    1
## 2 100  0.5   0   0    1 66.7  50   1    0
## 3 100  1.0   0 109    1 66.7  50   1    0
## 4 100  2.0   0 303    1 66.7  50   1    0
## 5 100  3.0   0 606    1 66.7  50   1    0
## 6 100  6.0   0 901    1 66.7  50   1    0
d <- readDatamlx(datafile = 'data/warfarin_data_evid.txt', 
                 header   = c('id','time','amt','y','ytype','cov','cov','cat','evid'))
head(d$treatment)
##    id time amount
## 1 100    0    100
## 2   1    0    100
## 3   2    0    100
## 4   3    0    120
## 5   4    0     60
## 6   5    0    113

Column MDV allows one to ignore some observations

head(read.table('data/warfarin_data_mdv.txt', header=TRUE, sep="\t"))
##    id time amt  dv dvid   wt age sex mdv
## 1 100  0.0 100   .    1 66.7  50   1   1
## 2 100  0.5   .   0    1 66.7  50   1   1
## 3 100  1.0   . 1.9    1 66.7  50   1   1
## 4 100  2.0   . 3.3    1 66.7  50   1   0
## 5 100  3.0   . 6.6    1 66.7  50   1   1
## 6 100  6.0   . 9.1    1 66.7  50   1   0
d <- readDatamlx(datafile = 'data/warfarin_data_mdv.txt', 
                 header   = c('id','time','amt','y','ytype','cov','cov','cat','mdv'))
head(d$y1)
##    id time  y1
## 1 100    2 3.3
## 2 100    6 9.1
## 3 100   24 5.6
## 5 100   36 4.0
## 7 100   48 2.7
## 9 100   72 0.8


SS and ADDL columns

A column SS may be used in the data file in order to indicate that the system is at steady-state. Column II (interdose interval) is the time between two successive doses.

head(read.csv('data/dataSS.csv'))
##   time        y amount ss ii
## 1    0        .    100  1 12
## 2    1  3.95484      .  .  .
## 3    3 10.28948      .  .  .
## 4    5  5.74431      .  .  .
## 5    7  3.70618      .  .  .
## 6    9  2.60192      .  .  .

By default, readDatamlx adds 10 doses to reach steady state.

d <- readDatamlx(datafile = "data/dataSS.csv",  
                 header   = c('time','y','amt','ss','ii'))
d$treatment
##     time amount
## 1.9 -120    100
## 1.8 -108    100
## 1.7  -96    100
## 1.6  -84    100
## 1.5  -72    100
## 1.4  -60    100
## 1.3  -48    100
## 1.2  -36    100
## 1.1  -24    100
## 11   -12    100
## 1      0    100

This number of additional doses to reach steady-state may be modified with the input argument addl.ss

d <- readDatamlx(datafile = "data/dataSS.csv",  
                 header   = c('time','y','amt','ss','ii'),
                 addl.ss  = 5)
d$treatment
##     time amount
## 1.4  -60    100
## 1.3  -48    100
## 1.2  -36    100
## 1.1  -24    100
## 11   -12    100
## 1      0    100

Any number of additional doses may be considered, before the current dose using a negative number (here, 5 doses are added before t=0),

head(read.csv('data/dataADDL1.csv'))
##   time        y amount addl ii
## 1    0        .    100   -5 12
## 2    1  3.95484      .    .  .
## 3    3 10.28948      .    .  .
## 4    5  5.74431      .    .  .
## 5    7  3.70618      .    .  .
## 6    9  2.60192      .    .  .
d <- readDatamlx(datafile = "data/dataADDL1.csv",  
                 header   = c('time','y','amt','addl','ii'))
d$treatment
##     time amount
## 1.4  -60    100
## 1.3  -48    100
## 1.2  -36    100
## 1.1  -24    100
## 11   -12    100
## 1      0    100

or after the current dose with a positive number of doses (here, 5 doses are added after t=-60),

head(read.csv('data/dataADDL2.csv'))
##   time        y amount addl ii
## 1  -60        .    100    5 12
## 2    1  3.95484      .    .  .
## 3    3 10.28948      .    .  .
## 4    5  5.74431      .    .  .
## 5    7  3.70618      .    .  .
## 6    9  2.60192      .    .  .
d <- readDatamlx(datafile = "data/dataADDL2.csv",  
                 header   = c('time','y','amt','addl','ii'))
d$treatment
##     time amount
## 1    -60    100
## 11   -48    100
## 1.1  -36    100
## 1.2  -24    100
## 1.3  -12    100
## 1.4    0    100


Reading a Monolix project

project.file <- 'monolixRuns/theophylline_project.mlxtran'

readDatamlx(project) reads a Monolix project and creates several data frames

theo.data <- readDatamlx(project = project.file)
names(theo.data)
## [1] "treatment" "y"         "covariate" "id"        "N"
head(theo.data$y)    
##   id time     y
## 1  1 0.25  2.84
## 2  1 0.57  6.57
## 3  1 1.12 10.50
## 4  1 2.02  9.66
## 5  1 3.82  8.58
## 6  1 5.10  8.36

readDatamlx(project, out.data=TRUE) returns a list with the original data and information about the project

theo.data <- readDatamlx(project = project.file, out.data=TRUE)
names(theo.data)
## [1] "data"        "infoProject"
head(theo.data$data)    #  original data
##   ID AMT AMT.KG TIME CONC WEIGHT SEX
## 1  1 320   4.02 0.00    .   79.6   M
## 2  1   .      . 0.25 2.84   79.6   M
## 3  1   .      . 0.57 6.57   79.6   M
## 4  1   .      . 1.12 10.5   79.6   M
## 5  1   .      . 2.02 9.66   79.6   M
## 6  1   .      . 3.82 8.58   79.6   M
theo.data$infoProject$datafile #  path & name of the data file
## [1] "monolixRuns/theophylline_data.txt"
theo.data$infoProject$dataheader # header/keywords used by Monolix
## [1] "ID"     "AMT"    "IGNORE" "TIME"   "Y"      "COV"    "IGNORE"
theo.data$infoProject$resultFolder  # result folder
## [1] "monolixRuns/theophylline_project"