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)

Load xpose

The first step is to load xpose in R with the following command:


Import model output

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/')

Glimpse at the xpdb

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)

Model summary

A summary of a model run can be displayed to the console by using the summary() function on an xpdb object.


Parameter estimates

A table of parameter estimates can be displayed to the console by using the prm_table() function on an xpdb object.


Listing variables

A list of available variables for plotting can be displayed to the console by using the list_vars() function on an xpdb object.



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

Editing the xpdb

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 %>% 

# After IDV reassignment
xpdb %>% 
  set_var_types(idv = 'TAD') %>% 

Generating plots

Plotting functions are used as follows: ``` {r demo basic gof}

DV vs. IPRED plot


CWRES vs. PRED plot

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

# Save the last generated plot
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')

Try the xpose package in your browser

Any scripts or data that you put into this service are public.

xpose documentation built on June 30, 2021, 9:07 a.m.