Learn R Programming

xpose

Overview

xpose was designed as a ggplot2-based alternative to xpose4. xpose aims to reduce the post processing burden and improve diagnostics commonly associated the development of non-linear mixed effect models.

Installation

# Install the lastest release from the CRAN
install.packages('xpose')

# Or install the development version from GitHub
# install.packages('devtools')
devtools::install_github('UUPharmacometrics/xpose')

Getting started

Load xpose

library(xpose)

Import run output

xpdb <- xpose_data(runno = '001')

Glance at the data object

xpdb
run001.lst overview: 
 - Software: nonmem 7.3.0 
 - Attached files (memory usage 1.4 Mb): 
   + obs tabs: $prob no.1: catab001.csv, cotab001, patab001, sdtab001 
   + sim tabs: $prob no.2: simtab001.zip 
   + output files: run001.cor, run001.cov, run001.ext, run001.grd, run001.phi, run001.shk 
   + special: <none> 
 - gg_theme: theme_readable 
 - xp_theme: theme_xp_default 
 - Options: dir = data, quiet = TRUE, manual_import = NULL

Model summary

summary(xpdb, problem = 1)
Summary for problem no. 0 [Global information] 
 - Software                      @software   : nonmem
 - Software version              @version    : 7.3.0
 - Run directory                 @dir        : data
 - Run file                      @file       : run001.lst
 - Run number                    @run        : run001
 - Reference model               @ref        : 000
 - Run description               @descr      : NONMEM PK example for xpose
 - Run start time                @timestart  : Mon Oct 16 13:34:28 CEST 2017
 - Run stop time                 @timestop   : Mon Oct 16 13:34:35 CEST 2017

Summary for problem no. 1 [Parameter estimation] 
 - Input data                    @data       : ../../mx19_2.csv
 - Number of individuals         @nind       : 74
 - Number of observations        @nobs       : 476
 - ADVAN                         @subroutine : 2
 - Estimation method             @method     : foce-i
 - Termination message           @term       : MINIMIZATION SUCCESSFUL
 - Estimation runtime            @runtime    : 00:00:02
 - Objective function value      @ofv        : -1403.905
 - Number of significant digits  @nsig       : 3.3
 - Covariance step runtime       @covtime    : 00:00:03
 - Condition number              @condn      : 21.5
 - Eta shrinkage                 @etashk     : 9.3 [1], 28.7 [2], 23.7 [3]
 - Epsilon shrinkage             @epsshk     : 14.9 [1]
 - Run warnings                  @warnings   : (WARNING 2) NM-TRAN INFERS THAT THE DATA ARE POPULATION.

Summary for problem no. 2 [Model simulations] 
 - Input data                    @data       : ../../mx19_2.csv
 - Number of individuals         @nind       : 74
 - Number of observations        @nobs       : 476
 - Estimation method             @method     : sim
 - Number of simulations         @nsim       : 20
 - Simulation seed               @simseed    : 221287
 - Run warnings                  @warnings   : (WARNING 2) NM-TRAN INFERS THAT THE DATA ARE POPULATION.
                                               (WARNING 22) WITH $MSFI AND "SUBPROBS", "TRUE=FINAL" ...

Generate diagnostics

Standard goodness-of-fit plots

dv_vs_ipred(xpdb)

Individual plots

ind_plots(xpdb, page = 1)

Visual predictive checks

xpdb %>% 
  vpc_data(stratify = 'SEX', opt = vpc_opt(n_bins = 7, lloq = 0.1)) %>% 
  vpc()

Distribution plots

eta_distrib(xpdb, labeller = 'label_value')

Minimization diagnostics

prm_vs_iteration(xpdb, labeller = 'label_value')

Recommended reading

The xpose website contains several useful articles to make full use of xpose

When working with xpose, a working knowledge of ggplot2 is recommended. Help for ggplot2 can be found in:

Contribute

Please note that the xpose project is released with a Contributor Code of Conduct and Contributing Guidelines. By contributing to this project, you agree to abide these.

Copy Link

Version

Install

install.packages('xpose')

Monthly Downloads

961

Version

0.4.19

License

LGPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Benjamin Guiastrennec

Last Published

January 7th, 2025

Functions in xpose (0.4.19)

as.ctime

Time converter
amt_vs_idv

Compartment kinetics
default_plot_problem

Get the default data problem to be plotted
distrib_plot

Distribution plots of ETA and parameters
combine_tables

Combine tables
gg_themes

An additional set of themes for ggplot2
grab_iter

Grab parameter for a given iteration number
as.xpdb

Convert an object to `xpose_data` class
is.xpdb

Test for xpose_data class
append_suffix

Append suffix contained in the `xp_theme` to titles
data_opt

Create options for data import
file_path

Generate clean file paths
as.xpose.plot

Convert an object to `xpose_plot` class
list_vars

List available variables
is.xpose.plot

Test for xpose_plot class
add_facet_var

Add faceting variable
list_xpdb

List available datasets
get_prm_transformation_formulas

Generate default transformation formulas for parameters
aes_c

Set new default value for ggplot2 aesthetics
get_code

Access model code
drop_fixed_cols

Return names of columns having several unique values
make_extension

Generate extension string
all_file_problem

Get all file problems
dv_vs_pred

Observations plotted against model predictions
aes_filter

Convenience function to easily filter ggplot2 aesthetics
get_prm

Access model parameters
parse_nm_files

Parse NONMEM output files
aes_rename

Convenience function to easily rename ggplot2 aesthetics
index_table

Index table columns
filter_xp_theme

Subset an `xp_theme`
check_scales

Check plot scales
all_data_problem

Get all data problems
software

Get software from the xpdb
get_extension

Get file extension
get_special

Access special model data
ind_plots

Observations, individual predictions and population predictions plotted against the independent variable for every individual
parse_title

Parse keywords in string based on values contained in an xpdb
check_xpdb

Check xpdb
irep

Add simulation counter
last_file_method

Get last file estimation method
as.xpose.theme

Convert an object to `xpose_theme` class
check_problem

Check .problem, .subprob and .method
is.formula

Test for formula class
is.nm.model

Test for nm_model class
xp_themes

A set of xpose themes
read_nm_model

NONMEM model file parser
summary.xpose_data

Summarizing xpose_data
manual_nm_import

Manually define nonmem tables to be imported
check_quo_vars

Check quoted variables
check_plot_type

Check plot `type`
msg

Message function
get_data

Access model output table data
get_summary

Access model summary data
get_file

Access model output file data
xpdb_ex_pk

xpose_data examples
read_nm_tables

NONMEM output table import function
is.nm.table.list

Test for nm_table_list class
set_vars

Set variable type, label or units
template_titles

Template titles
list_nm_tables_manual

Creates an nm_table_list from manually defined table name patterns
only_obs

Create functions to drop non observation records
parse_arg

Parse arguments from xpose to ggplot2 format
last_file_subprob

Get last file subproblem
res_vs_idv

Residuals plotted against the independent variable
xp_var

Access xpdb index information for a given variable or variable type
pred_vs_idv

Observations and model predictions plotted against the independent variable
xplot_distrib

Default xpose distribution plot function
res_vs_pred

Residuals plotted against population predictions
xplot_qq

Default xpose QQ plot function
last_file_problem

Get last file problem
update_args

Update `xpose_geoms` arguments
merge_firstonly

Merge firstonly table with full length tables
xpose_panels

Generic panel function for `xpose_plots`
prm_table

Display a parameter estimates to the console
update_extension

Update file extension
edit_xpose_data

Master xpdb editing function
xp_geoms

Generic ggplot2 layer for `xpose_plots`
read_funs

Define data import functions
xpose_save

Save xpose plot
fetch_data

Fetch data
print.xpose_data

Print an xpose_data object
reexports

Objects exported from other packages
is.xpose.theme

Test for xpose_theme class
last_data_problem

Get last data problem
xp_map

ggplot2 layer call
read_nm_files

NONMEM output file import function
tidyr_new_interface

Check tidyr version
xplot_scatter

Default xpose scatter plot function
print.ggplot

Import print ggplot method
modify_xpdb

Add, remove or rename variables in an xpdb
minimization_plots

Parameter value or gradient vs. iterations
list_nm_tables

List NONMEM output tables
raw_to_tibble

Convert raw strings to tibble
qq_plot

QQ plots of ETA and residuals
vpc_data

Visual predictive checks data
only_distinct

Create functions for data deduplication
transform_prm

Mean and variance of tranformed parameters
xpose_data

Import NONMEM output into R
xpose-package

xpose: graphical diagnostics for pharmacometric models
read_args

Define data import arguments
update_themes

Create xpose theme
vpc

Visual predictive checks
print.xpose_plot

Draw an xpose_plot object
reorder_factors

Reorder factors by numerical order
subset_xpdb

Subset datasets in an xpdb
vpc_opt

Generate a list of options for VPC data generation
xpdb_index_update

Update data index
summarise_xpdb

Group/ungroup and summarize variables in an xpdb
as.nm.table.list

Convert an object to `nm_table_list` class