The xpose package was designed as a standardized interface between model outputs and R. Hence model output files can easily be imported in R and used to summarize data or create plots.

Glimpse at the xpdb

The files attached to an xpdb object can be displayed to the console simply by writing the xpdb name to the console or by using the print() function. Any of these files can be accessed from the xpdb using one of the functions listed below.

xpdb # or print(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 = FALSE, manual_import = NULL

Access the model code

The get_code() function can be used to access the parsed model code from the xpdb. This code was used to create the summary and find table names. The parsed code can be used to get additional information about the run. If the argument .problem is specified a subset of the code can be returned based on $PROBLEM.

Note that general code warnings and PsN outputs appended are listed as problem 0.

code <- get_code(xpdb)
code

[38;5;246m# A tibble: 764 × 5
[39m
   problem level subroutine code                                                     comment        
 
[38;5;250m*
[39m   
[3m
[38;5;246m<int>
[39m
[23m 
[3m
[38;5;246m<int>
[39m
[23m 
[3m
[38;5;246m<chr>
[39m
[23m      
[3m
[38;5;246m<chr>
[39m
[23m                                                    
[3m
[38;5;246m<chr>
[39m
[23m          

[38;5;250m 1
[39m       0     0 oth        
[38;5;246m"
[39mMon Oct 16 13:34:28 CEST 2017
[38;5;246m"
[39m                          
[38;5;246m"
[39m
[38;5;246m"
[39m             

[38;5;250m 2
[39m       0     0 oth        
[38;5;246m"
[39m
[38;5;246m"
[39m                                                       
[38;5;246m"
[39m; 1. Based on…

[38;5;250m 3
[39m       0     0 oth        
[38;5;246m"
[39m
[38;5;246m"
[39m                                                       
[38;5;246m"
[39m; 2. Descript…

[38;5;250m 4
[39m       0     0 oth        
[38;5;246m"
[39m
[38;5;246m"
[39m                                                       
[38;5;246m"
[39m; NONMEM PK e…

[38;5;250m 5
[39m       1     1 pro        
[38;5;246m"
[39mParameter estimation
[38;5;246m"
[39m                                   
[38;5;246m"
[39m
[38;5;246m"
[39m             

[38;5;250m 6
[39m       1     2 inp        
[38;5;246m"
[39mID DOSE DV SCR AGE SEX CLASS WT ACE MED1 MED2 TAD TIME
[38;5;246m"
[39m 
[38;5;246m"
[39m
[38;5;246m"
[39m             

[38;5;250m 7
[39m       1     2 inp        
[38;5;246m"
[39m CLCR AMT SS II EVID
[38;5;246m"
[39m                                   
[38;5;246m"
[39m
[38;5;246m"
[39m             

[38;5;250m 8
[39m       1     3 dat        
[38;5;246m"
[39m../../mx19_2.csv IGNORE=@
[38;5;246m"
[39m                              
[38;5;246m"
[39m
[38;5;246m"
[39m             

[38;5;250m 9
[39m       1     4 abb        
[38;5;246m"
[39mDERIV2=NO
[38;5;246m"
[39m                                              
[38;5;246m"
[39m
[38;5;246m"
[39m             

[38;5;250m10
[39m       1     5 sub        
[38;5;246m"
[39mADVAN2 TRANS1
[38;5;246m"
[39m                                          
[38;5;246m"
[39m
[38;5;246m"
[39m             

[38;5;246m# ℹ 754 more rows
[39m

Access the output data

The get_data() function can be used to access the imported table files. Tables can be accessed by table name or by .problem. In the latter a single dataset containing all aggregated tables is returned. If more than one table name or .problem number is provided a named list is returned.

Note when providing a table name it is not guaranteed that the table will be identical to its file (i.e. the order of the columns may have been changed and tables with FIRSTONLY will no longer be deduplicated).

data <- get_data(xpdb, table = 'cotab001')
data

[38;5;246m# A tibble: 550 × 4
[39m
   ID     CLCR   AGE    WT
   
[3m
[38;5;246m<fct>
[39m
[23m 
[3m
[38;5;246m<dbl>
[39m
[23m 
[3m
[38;5;246m<dbl>
[39m
[23m 
[3m
[38;5;246m<dbl>
[39m
[23m

[38;5;250m 1
[39m 110      66    68   105

[38;5;250m 2
[39m 110      66    68   105

[38;5;250m 3
[39m 110      66    68   105

[38;5;250m 4
[39m 110      66    68   105

[38;5;250m 5
[39m 110      66    68   105

[38;5;250m 6
[39m 110      66    68   105

[38;5;250m 7
[39m 110      66    68   105

[38;5;250m 8
[39m 112      47    73    80

[38;5;250m 9
[39m 112      47    73    80

[38;5;250m10
[39m 112      47    73    80

[38;5;246m# ℹ 540 more rows
[39m

Access the run files

The get_file() function can be used to access the imported output files. Files can be accessed by file name, by .problem, .subprob and/or .method. If more than one file name, .problem, .subprob, or .method is provided a named list is returned.

file <- get_file(xpdb, file = 'run001.ext')
file

[38;5;246m# A tibble: 28 × 16
[39m
   ITERATION THETA1 THETA2 THETA3 THETA4 THETA5  THETA6  THETA7 `SIGMA(1,1)` `OMEGA(1,1)`
       
[3m
[38;5;246m<dbl>
[39m
[23m  
[3m
[38;5;246m<dbl>
[39m
[23m  
[3m
[38;5;246m<dbl>
[39m
[23m  
[3m
[38;5;246m<dbl>
[39m
[23m  
[3m
[38;5;246m<dbl>
[39m
[23m  
[3m
[38;5;246m<dbl>
[39m
[23m   
[3m
[38;5;246m<dbl>
[39m
[23m   
[3m
[38;5;246m<dbl>
[39m
[23m        
[3m
[38;5;246m<dbl>
[39m
[23m        
[3m
[38;5;246m<dbl>
[39m
[23m

[38;5;250m 1
[39m         0   25.4   1.47   7.45  0.214  0.200 0.009
[4m8
[24m
[4m3
[24m 0.006
[4m0
[24m
[4m1
[24m            1       0.074
[4m0
[24m

[38;5;250m 2
[39m         1   26.3   1.26   7.35  0.219  0.217 0.009
[4m8
[24m
[4m9
[24m 0.006
[4m0
[24m
[4m2
[24m            1       0.074
[4m4
[24m

[38;5;250m 3
[39m         2   25.6   1.47   7.29  0.216  0.212 0.009
[4m8
[24m
[4m7
[24m 0.006
[4m0
[24m
[4m3
[24m            1       0.074
[4m1
[24m

[38;5;250m 4
[39m         3   26.8   1.49   5.76  0.213  0.213 0.009
[4m7
[24m
[4m9
[24m 0.006
[4m2
[24m
[4m8
[24m            1       0.073
[4m0
[24m

[38;5;250m 5
[39m         4   26.7   1.49   5.69  0.213  0.212 0.009
[4m7
[24m
[4m9
[24m 0.006
[4m2
[24m
[4m9
[24m            1       0.073
[4m0
[24m

[38;5;250m 6
[39m         5   26.7   1.49   5.66  0.213  0.212 0.009
[4m7
[24m
[4m9
[24m 0.006
[4m3
[24m
[4m0
[24m            1       0.073
[4m0
[24m

[38;5;250m 7
[39m         6   26.6   1.49   5.03  0.210  0.217 0.010
[4m0
[24m  0.006
[4m5
[24m
[4m2
[24m            1       0.072
[4m4
[24m

[38;5;250m 8
[39m         7   26.6   1.49   4.93  0.205  0.217 0.010
[4m0
[24m  0.006
[4m5
[24m
[4m8
[24m            1       0.071
[4m7
[24m

[38;5;250m 9
[39m         8   26.6   1.48   4.62  0.211  0.217 0.009
[4m5
[24m
[4m1
[24m 0.007
[4m3
[24m
[4m5
[24m            1       0.063
[4m3
[24m

[38;5;250m10
[39m         9   26.6   1.46   4.41  0.209  0.217 0.009
[4m0
[24m
[4m3
[24m 0.008
[4m7
[24m
[4m4
[24m            1       0.076
[4m6
[24m

[38;5;246m# ℹ 18 more rows
[39m

[38;5;246m# ℹ 6 more variables: `OMEGA(2,1)` <dbl>, `OMEGA(2,2)` <dbl>, `OMEGA(3,1)` <dbl>,
[39m

[38;5;246m#   `OMEGA(3,2)` <dbl>, `OMEGA(3,3)` <dbl>, OBJ <dbl>
[39m

Access the parameter estimates

The get_prm() function can be used to access the parameter estimates. To get a nice parameter table printed to the console use the function prm_table() instead. The arguments .problem, .subprob and .method can be used to select the parameter estimates to output.

# Raw output for editing
prm <- get_prm(xpdb, digits = 4)
prm

[38;5;246m# A tibble: 11 × 10
[39m
   type  name       label           value       se     rse fixed diagonal     m     n
 
[38;5;250m*
[39m 
[3m
[38;5;246m<chr>
[39m
[23m 
[3m
[38;5;246m<chr>
[39m
[23m      
[3m
[38;5;246m<chr>
[39m
[23m           
[3m
[38;5;246m<dbl>
[39m
[23m    
[3m
[38;5;246m<dbl>
[39m
[23m   
[3m
[38;5;246m<dbl>
[39m
[23m 
[3m
[38;5;246m<lgl>
[39m
[23m 
[3m
[38;5;246m<lgl>
[39m
[23m    
[3m
[38;5;246m<dbl>
[39m
[23m 
[3m
[38;5;246m<dbl>
[39m
[23m

[38;5;250m 1
[39m the   THETA1     
[38;5;246m"
[39mTVCL
[38;5;246m"
[39m       26.3      0.892    0.033
[4m9
[24m FALSE 
[31mNA
[39m           1    
[31mNA
[39m

[38;5;250m 2
[39m the   THETA2     
[38;5;246m"
[39mTVV
[38;5;246m"
[39m         1.35     0.043
[4m8
[24m   0.032
[4m5
[24m FALSE 
[31mNA
[39m           2    
[31mNA
[39m

[38;5;250m 3
[39m the   THETA3     
[38;5;246m"
[39mTVKA
[38;5;246m"
[39m        4.20     0.809    0.192  FALSE 
[31mNA
[39m           3    
[31mNA
[39m

[38;5;250m 4
[39m the   THETA4     
[38;5;246m"
[39mLAG
[38;5;246m"
[39m         0.208    0.015
[4m7
[24m   0.075
[4m5
[24m FALSE 
[31mNA
[39m           4    
[31mNA
[39m

[38;5;250m 5
[39m the   THETA5     
[38;5;246m"
[39mProp. Err
[38;5;246m"
[39m   0.205    0.022
[4m4
[24m   0.110  FALSE 
[31mNA
[39m           5    
[31mNA
[39m

[38;5;250m 6
[39m the   THETA6     
[38;5;246m"
[39mAdd. Err
[38;5;246m"
[39m    0.010
[4m6
[24m   0.003
[4m6
[24m
[4m6
[24m  0.347  FALSE 
[31mNA
[39m           6    
[31mNA
[39m

[38;5;250m 7
[39m the   THETA7     
[38;5;246m"
[39mCRCL on CL
[38;5;246m"
[39m  0.007
[4m1
[24m
[4m7
[24m  0.001
[4m7
[24m
[4m0
[24m  0.237  FALSE 
[31mNA
[39m           7    
[31mNA
[39m

[38;5;250m 8
[39m ome   OMEGA(1,1) 
[38;5;246m"
[39mIIV CL
[38;5;246m"
[39m      0.270    0.023
[4m3
[24m   0.086
[4m2
[24m FALSE TRUE         1     1

[38;5;250m 9
[39m ome   OMEGA(2,2) 
[38;5;246m"
[39mIIV V
[38;5;246m"
[39m       0.195    0.032
[4m0
[24m   0.164  FALSE TRUE         2     2

[38;5;250m10
[39m ome   OMEGA(3,3) 
[38;5;246m"
[39mIIV KA
[38;5;246m"
[39m      1.38     0.202    0.146  FALSE TRUE         3     3

[38;5;250m11
[39m sig   SIGMA(1,1) 
[38;5;246m"
[39m
[38;5;246m"
[39m            1       
[31mNA
[39m       
[31mNA
[39m      TRUE  TRUE         1     1
# Nicely formated table
prm_table(xpdb, digits = 4)

Reporting transformed parameters:
For the OMEGA and SIGMA matrices, values are reported as standard deviations for the diagonal elements and as correlations for the off-diagonal elements. The relative standard errors (RSE) for OMEGA and SIGMA are reported on the approximate standard deviation scale (SE/variance estimate)/2. Use `transform = FALSE` to report untransformed parameters.

Estimates for $prob no.1, subprob no.1, method foce
 Parameter  Label      Value        RSE
 THETA1     TVCL       26.29        0.03391
 THETA2     TVV        1.348        0.0325
 THETA3     TVKA       4.204        0.1925
 THETA4     LAG        0.208        0.07554
 THETA5     Prop. Err  0.2046       0.1097
 THETA6     Add. Err   0.01055      0.3466
 THETA7     CRCL on CL 0.007172     0.2366
 OMEGA(1,1) IIV CL     0.2701       0.08616
 OMEGA(2,2) IIV V      0.195        0.1643
 OMEGA(3,3) IIV KA     1.381        0.1463
 SIGMA(1,1)            1        fix  - 

Access the run summary

The get_summary() function can be used to access the generated run summary from which the template_titles. If the argument .problem is specified a subset of the summary can be returned based on $PROBLEM.

Note that general summary information are listed as problem 0.

run_sum <- get_summary(xpdb, .problem = 0)
run_sum

[38;5;246m# A tibble: 12 × 5
[39m
   problem subprob descr               label       value                        
     
[3m
[38;5;246m<dbl>
[39m
[23m   
[3m
[38;5;246m<dbl>
[39m
[23m 
[3m
[38;5;246m<chr>
[39m
[23m               
[3m
[38;5;246m<chr>
[39m
[23m       
[3m
[38;5;246m<chr>
[39m
[23m                        

[38;5;250m 1
[39m       0       0 Run description     descr       NONMEM PK example for xpose  

[38;5;250m 2
[39m       0       0 Run directory       dir         data                         

[38;5;250m 3
[39m       0       0 Run errors          errors      na                           

[38;5;250m 4
[39m       0       0 ESAMPLE seed number esampleseed na                           

[38;5;250m 5
[39m       0       0 Run file            file        run001.lst                   

[38;5;250m 6
[39m       0       0 Number of ESAMPLE   nesample    na                           

[38;5;250m 7
[39m       0       0 Reference model     ref         000                          

[38;5;250m 8
[39m       0       0 Run number          run         run001                       

[38;5;250m 9
[39m       0       0 Software            software    nonmem                       

[38;5;250m10
[39m       0       0 Run start time      timestart   Mon Oct 16 13:34:28 CEST 2017

[38;5;250m11
[39m       0       0 Run stop time       timestop    Mon Oct 16 13:34:35 CEST 2017

[38;5;250m12
[39m       0       0 Software version    version     7.3.0