Author: Benjamin Guiastrennec

# Access the xpdb data

#### Benjamin Guiastrennec

#### 02 March, 2026

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

    # A tibble: 764 × 5
       problem level subroutine code                                                     comment
     *   <int> <int> <chr>      <chr>                                                    <chr>
     1       0     0 oth        "Mon Oct 16 13:34:28 CEST 2017"                          ""
     2       0     0 oth        ""                                                       "; 1. Based on…
     3       0     0 oth        ""                                                       "; 2. Descript…
     4       0     0 oth        ""                                                       "; NONMEM PK e…
     5       1     1 pro        "Parameter estimation"                                   ""
     6       1     2 inp        "ID DOSE DV SCR AGE SEX CLASS WT ACE MED1 MED2 TAD TIME" ""
     7       1     2 inp        " CLCR AMT SS II EVID"                                   ""
     8       1     3 dat        "../../mx19_2.csv IGNORE=@"                              ""
     9       1     4 abb        "DERIV2=NO"                                              ""
    10       1     5 sub        "ADVAN2 TRANS1"                                          ""
    # ℹ 754 more rows

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

    # A tibble: 550 × 4
       ID     CLCR   AGE    WT
       <fct> <dbl> <dbl> <dbl>
     1 110      66    68   105
     2 110      66    68   105
     3 110      66    68   105
     4 110      66    68   105
     5 110      66    68   105
     6 110      66    68   105
     7 110      66    68   105
     8 112      47    73    80
     9 112      47    73    80
    10 112      47    73    80
    # ℹ 540 more rows

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

    # A tibble: 28 × 16
       ITERATION THETA1 THETA2 THETA3 THETA4 THETA5  THETA6  THETA7 `SIGMA(1,1)` `OMEGA(1,1)`
           <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>   <dbl>   <dbl>        <dbl>        <dbl>
     1         0   25.4   1.47   7.45  0.214  0.200 0.00983 0.00601            1       0.0740
     2         1   26.3   1.26   7.35  0.219  0.217 0.00989 0.00602            1       0.0744
     3         2   25.6   1.47   7.29  0.216  0.212 0.00987 0.00603            1       0.0741
     4         3   26.8   1.49   5.76  0.213  0.213 0.00979 0.00628            1       0.0730
     5         4   26.7   1.49   5.69  0.213  0.212 0.00979 0.00629            1       0.0730
     6         5   26.7   1.49   5.66  0.213  0.212 0.00979 0.00630            1       0.0730
     7         6   26.6   1.49   5.03  0.210  0.217 0.0100  0.00652            1       0.0724
     8         7   26.6   1.49   4.93  0.205  0.217 0.0100  0.00658            1       0.0717
     9         8   26.6   1.48   4.62  0.211  0.217 0.00951 0.00735            1       0.0633
    10         9   26.6   1.46   4.41  0.209  0.217 0.00903 0.00874            1       0.0766
    # ℹ 18 more rows
    # ℹ 6 more variables: `OMEGA(2,1)` <dbl>, `OMEGA(2,2)` <dbl>, `OMEGA(3,1)` <dbl>,
    #   `OMEGA(3,2)` <dbl>, `OMEGA(3,3)` <dbl>, OBJ <dbl>

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

    # A tibble: 11 × 10
       type  name       label           value       se     rse fixed diagonal     m     n
     * <chr> <chr>      <chr>           <dbl>    <dbl>   <dbl> <lgl> <lgl>    <dbl> <dbl>
     1 the   THETA1     "TVCL"       26.3      0.892    0.0339 FALSE NA           1    NA
     2 the   THETA2     "TVV"         1.35     0.0438   0.0325 FALSE NA           2    NA
     3 the   THETA3     "TVKA"        4.20     0.809    0.192  FALSE NA           3    NA
     4 the   THETA4     "LAG"         0.208    0.0157   0.0755 FALSE NA           4    NA
     5 the   THETA5     "Prop. Err"   0.205    0.0224   0.110  FALSE NA           5    NA
     6 the   THETA6     "Add. Err"    0.0106   0.00366  0.347  FALSE NA           6    NA
     7 the   THETA7     "CRCL on CL"  0.00717  0.00170  0.237  FALSE NA           7    NA
     8 ome   OMEGA(1,1) "IIV CL"      0.270    0.0233   0.0862 FALSE TRUE         1     1
     9 ome   OMEGA(2,2) "IIV V"       0.195    0.0320   0.164  FALSE TRUE         2     2
    10 ome   OMEGA(3,3) "IIV KA"      1.38     0.202    0.146  FALSE TRUE         3     3
    11 sig   SIGMA(1,1) ""            1       NA       NA      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

    # A tibble: 12 × 5
       problem subprob descr               label       value
         <dbl>   <dbl> <chr>               <chr>       <chr>
     1       0       0 Run description     descr       NONMEM PK example for xpose
     2       0       0 Run directory       dir         data
     3       0       0 Run errors          errors      na
     4       0       0 ESAMPLE seed number esampleseed na
     5       0       0 Run file            file        run001.lst
     6       0       0 Number of ESAMPLE   nesample    na
     7       0       0 Reference model     ref         000
     8       0       0 Run number          run         run001
     9       0       0 Software            software    nonmem
    10       0       0 Run start time      timestart   Mon Oct 16 13:34:28 CEST 2017
    11       0       0 Run stop time       timestop    Mon Oct 16 13:34:35 CEST 2017
    12       0       0 Software version    version     7.3.0