dMod provides several list objects, i.e., objects which are organized as lists but carry their own class. This vignette is about the typical dMod list objects
datalistprdlistand what they do or do not have in common.
datalistData lists are used to represent the data in dMod. Data lists are
most conveniently produced using the as.datalist() function
on data frames:
myframe <- data.frame(
# required columns
name = "A",
time = 1:5,
value = c(exp(-0.1 * 1:5), exp(-0.3 * 1:5)),
sigma = 0.05,
# additional columns to specify the data records
treatment = "TRTno",
inhibitor = rep(c("INHno", "INHx"), each = 5)
)
mydata <- as.datalist(myframe)
mydata## TRTno_INHno:
## name time value sigma lloq
## 1 A 1 0.9048374 0.05 -Inf
## 2 A 2 0.8187308 0.05 -Inf
## 3 A 3 0.7408182 0.05 -Inf
## 4 A 4 0.6703200 0.05 -Inf
## 5 A 5 0.6065307 0.05 -Inf
## TRTno_INHx:
## name time value sigma lloq
## 6 A 1 0.7408182 0.05 -Inf
## 7 A 2 0.5488116 0.05 -Inf
## 8 A 3 0.4065697 0.05 -Inf
## 9 A 4 0.3011942 0.05 -Inf
## 10 A 5 0.2231302 0.05 -Inf
All non-standard columns are used to create a condition
identifier. A separate data frame is returned for each condition,
structured as a list. Because the non-standard columns describing the
data records could potentially be used as covariates for model
parameters, the mapping between conditions and covariates can be
accessed via
## treatment inhibitor
## TRTno_INHno TRTno INHno
## TRTno_INHx TRTno INHx
Data lists can be
c() function or the
+ operator,plot() or plotData(),
andas.data.frame().Whenever parameters are estimated from data with dMod, a valid data list needs to be created.
prdlistPrediction lists are the counterpart of data lists. They are returned by prediction functions. The prediction function returns a separate matrix with the simulation result for each condition, structured as a list.
Prediction lists can be
plot() or
plotPrediction(),as.data.frame(x, data = NULL, errfn = NULL). Optionally, a
data list can be provided from where the covariate table is used to
produce extra covariate columns in the output data frame. If an error
model ist provided (errfn is formally an observation
function), it is used to impute the sigma column.getParameters().There are some other list structures in dMod which fit a bit less
into the schematics presented above. These are eqnlist
(model representation), objlist (list with value, gradient
and Hessian returned by an objective function) and parlist
(a list of parameter fits as returned by mstrust()). In the
following, we will look a bit close into eqnlist and
parlist.
eqnlistEquation lists (eqnlist) are used to store differential
equation models in a list containing the stoichiometric matrix, the
states, the rate expressions, volume expressions and a description
field:
reactions <- eqnlist() %>%
addReaction("A", "B", "k_on*A", "Forward reaction") %>%
addReaction("B", "A", "k_off*B", "Backward reaction")
unclass(reactions)## $smatrix
## A B
## 1 -1 1
## 11 1 -1
##
## $states
## [1] "A" "B"
##
## $rates
## [1] "k_on*A" "k_off*B"
##
## $volumes
## NULL
##
## $description
## [1] "Forward reaction" "Backward reaction"
c().write().subset().as.eqnvec().as.data.frame() to extract the stoichiometric
matrix and rate expressions as data frame.getParameters().getReactions() to get the reactions as reaction
table.getFluxes() returns the reaction fluxes from and to
every state.parlistParlists are defined by the mstrust() output: a list of
all the fits. The most important method to run on parlist
objects is
as.parframe() which extracts the fitted parameter
values from the fits and structures them in a nice data frame and,
subsequently,as.parvec() which extracts the first parameter vector
(or the one with the lowest objective value) from the parframe.Happy listing!!