library(xpose) xpdb <- xpdb_ex_pk %>% set_var_types(idv = 'TIME') knitr::opts_chunk$set(fig.dpi = 96, fig.align = 'center', fig.height = 4, fig.width = 4, out.width = '50%', comment = '', message = FALSE)
The first step is to load xpose in R with the following command:
library(xpose)
The function xpose_data()
collects all model output files and table and organizes them into an R object commonly called xpdb
which stands for "xpose database".
xpdb <- xpose_data(runno = '001', dir = 'analysis/model/pk/')
The files attached to an xpdb object can be displayed to the console simply by writing its name to the console or by using the print()
function.
xpdb # or print(xpdb)
A summary of a model run can be displayed to the console by using the summary()
function on an xpdb object.
summary(xpdb)
A table of parameter estimates can be displayed to the console by using the prm_table()
function on an xpdb object.
prm_table(xpdb)
A list of available variables for plotting can be displayed to the console by using the list_vars()
function on an xpdb object.
list_vars(xpdb)
xpose
makes use of the pipe operator %>%
from the package dplyr. Pipes can be used to generate clear workflow.
xpose_data(runno = '001') %>% dv_vs_ipred() %>% xpose_save(file = 'run001_dv_vs_ipred.pdf')
Multiples edits can be made to the xpdb object. For instance the type (visible using the list_vars()
function described above) of a variable can be changed. Hence the independent variable (idv) could be changed from TIME
(default in NONMEM) to TAD
. All plots using idv
will then automatically use TAD
.
# With the TIME default xpdb %>% dv_vs_idv() # After IDV reassignment xpdb %>% set_var_types(idv = 'TAD') %>% dv_vs_idv()
Plotting functions are used as follows: ``` {r demo basic gof}
dv_vs_ipred(xpdb)
res_vs_pred(xpdb, res = 'CWRES')
### Saving plots The `xpose_save` function was designed to facilitate the export of xpose plots. The file extension is guessed from the file name and must match one of .pdf (default), .jpeg, .png, .bmp or .tiff. If no extension is provided as part of the file name a .pdf will be generated. Finally, if the `plot` argument is left empty `xpose_save` will automatically save the last plot that was created or modified. The `xpose_save()` function is compatible with templates titles and keywords such as `@run` for the run number and `@plotfun` for the name of the plotting function can be used to automatically name files. Learn more about the template titles keywords using `help('template_titles')`. ```r # Save the last generated plot dv_vs_ipred(xpdb) xpose_save(file = 'run001_dv_vs_ipred.pdf') # Template titles can also be used in filename and the directory xpdb %>% dv_vs_ipred() %>% xpose_save(file = '@run_@plotfun_[@ofv].jpeg', dir = '@dir')
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.