To produce a set of diagnostic plots that will be included in the report. Please note that these plots are just meant to provide an example of what could be created and how. They are not an exhaustive list of every possible plot and were chosen with the project aims in mind.
While this should give users examples of plots generated with the most up-to-date packages and methods, we’re always happy to have feedback. If you know of more efficient methods or want to suggest alternative ways of plotting the figures please open an issue with the details.
Define modelName
and path to the model directory
(MODEL_DIR
).
If saving figures out to pdf, define where those pdfs should be saved
to. Here the figures are saved to
deliv > figure > model_run_number
── Status ─────────────────────────────────
• Finished Running
── Absolute Model Path ───────────────────────────
• /data/bbr-nonmem-poppk-foce/model/pk/106
── YAML & Model Files ───────────────────────────
• /data/bbr-nonmem-poppk-foce/model/pk/106.yaml
• /data/bbr-nonmem-poppk-foce/model/pk/106.ctl
── Description ───────────────────────────────
• Final Model
── Tags ──────────────────────────────────
• two-compartment + absorption
• ETA-CL
• ETA-KA
• ETA-V2
• CLWT-allo
• V2WT-allo
• QWT-allo
• V3WT-allo
• CLEGFR
• CLAGE
• CLALB
• proportional RUV
── Notes ──────────────────────────────────
• 1: Client was interested in adding Albumin to CL
Dataset: ../../../data/derived/pk.csv
Records: 4292 Observations: 3142 Subjects: 160
Objective Function Value (final est. method): 30904.409
Estimation Method(s):
– First Order Conditional Estimation with Interaction
No Heuristic Problems Detected
parameter_names | estimate | stderr | shrinkage |
---|---|---|---|
THETA1 | 0.443 | 0.0643 | |
THETA2 | 4.12 | 0.0275 | |
THETA3 | 1.17 | 0.0280 | |
THETA4 | 4.21 | 0.0190 | |
THETA5 | 1.28 | 0.0348 | |
THETA6 | 0.485 | 0.0395 | |
THETA7 | -0.0378 | 0.0635 | |
THETA8 | 0.419 | 0.0863 | |
OMEGA(1,1) | 0.219 | 0.0526 | 14.4 |
OMEGA(2,2) | 0.0824 | 0.00981 | 5.51 |
OMEGA(3,3) | 0.114 | 0.0128 | 1.25 |
SIGMA(1,1) | 0.0399 | 0.00123 | 5.02 |
The aim is to use the information in the spec file to label the figures automatically.
Read in the model details using read_model
. Details
stored in the mod
object can be used to identify the
location of the source data (used in $DATA) - to see how this is done
look at the bbr::get_data_path()
and
bbr::build_path_from_model()
helper functions.
After reading in the nonmem dataset and the output dataset they’re
joined by a NUM
column. This assumes that a row
number column (called NUM
) was included during data
assembly. The idea here is that in NONMEM, you table just
NUM
and none of the other input data items. They all will
get joined back to the nonmem output … even character columns.
The data
used in the diagnostic plots has been filtered
to only include the observations (i.e. EVID==0
). Note that
further modifications maybe needed, for example, if BLQ data was
included in the model or if the DV
was log-transformed. The
dataset also converts the categorical covariates of interest to factors
using the yspec_add_factors
function and details described
in the spec file.
The id
subset gets the first record per ID. This would
usually be the baseline value but consider filtering on a baseline flag
if available. Also, if the model includes inter-occassion variaibility
(IOV), the occassion variable should be included within the
distinct
function.
The following plots assume that the preferred x-axis labels are defined here.
Create plots of DV vs PRED and IPRED for the full dataset and stratified by renal function and hepatic function.
## [1] "DV vs PRED and IPRED"
## [1] "DV vs PRED and IPRED by renal function"
## [1] "DV vs PRED and by hepatic function"
NPDE vs PRED, time and time after dose.
NPDE vs continuous covariates
NPDE vs categorical covariates.
These plots uses the yspec to automatically rename the axis labels.
Note that here we use a function that maps over the ETAs (not the covariates) because the purpose of these plots was to determine whether there were any trends in the covariates for a given ETA. This may need to be edited to address different study specific questions
## [[1]]
##
## [[2]]
##
## [[3]]
These plots uses the yspec to automatically rename the axis labels.
Note that here we use a function that maps over the covariates (not the ETAs) because the purpose of these plots was to determine whether there is any difference in the distribution of ETAs across studies, dosing groups and disease states. This should be updated to reflect the questions you’re trying to address.
## $STUDY
##
## $RF
##
## $CP
##
## $DOSE
It is considered good practice to include these details at the end of all rmd scripts
Sys.getenv("AMI_NAME")
## [1] ""
sessioninfo::session_info()
## ─ Session info ────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## setting value
## version R version 4.1.3 (2022-03-10)
## os Ubuntu 18.04.6 LTS
## system x86_64, linux-gnu
## ui RStudio
## language (EN)
## collate C.UTF-8
## ctype C.UTF-8
## tz America/New_York
## date 2024-03-12
## rstudio 2022.02.4+500.pro1 Prairie Trillium (server)
## pandoc 2.17.1.1 @ /usr/lib/rstudio-server/bin/quarto/bin/ (via rmarkdown)
##
## ─ Packages ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## package * version date (UTC) lib source
## assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.1.3)
## backports 1.4.1 2021-12-13 [1] CRAN (R 4.1.3)
## bbr * 1.7.0 2024-03-11 [1] MPNDEV (R 4.1.3)
## bit 4.0.5 2022-11-15 [1] CRAN (R 4.1.3)
## bit64 4.0.5 2020-08-30 [1] CRAN (R 4.1.3)
## bslib 0.5.1 2023-08-11 [1] CRAN (R 4.1.3)
## cachem 1.0.8 2023-05-01 [1] CRAN (R 4.1.3)
## checkmate 2.2.0 2023-04-27 [1] CRAN (R 4.1.3)
## cli 3.6.1 2023-03-23 [1] CRAN (R 4.1.3)
## colorspace 2.1-0 2023-01-23 [1] CRAN (R 4.1.3)
## crayon 1.5.2 2022-09-29 [1] CRAN (R 4.1.3)
## data.table 1.14.8 2023-02-17 [1] CRAN (R 4.1.3)
## diffobj 0.3.5 2021-10-05 [1] CRAN (R 4.1.3)
## digest 0.6.33 2023-07-07 [1] CRAN (R 4.1.3)
## dplyr * 1.1.3 2023-09-03 [1] CRAN (R 4.1.3)
## evaluate 0.21 2023-05-05 [1] CRAN (R 4.1.3)
## fansi 1.0.4 2023-01-22 [1] CRAN (R 4.1.3)
## farver 2.1.1 2022-07-06 [1] CRAN (R 4.1.3)
## fastmap 1.1.1 2023-02-24 [1] CRAN (R 4.1.3)
## forcats * 1.0.0 2023-01-29 [1] CRAN (R 4.1.3)
## fs 1.6.3 2023-07-20 [1] CRAN (R 4.1.3)
## generics 0.1.3 2022-07-05 [1] CRAN (R 4.1.3)
## GGally 2.1.2 2021-06-21 [1] CRAN (R 4.1.3)
## ggplot2 * 3.4.3 2023-08-14 [1] CRAN (R 4.1.3)
## glue * 1.6.2 2022-02-24 [1] CRAN (R 4.1.3)
## gridExtra 2.3 2017-09-09 [1] CRAN (R 4.1.3)
## gridGraphics 0.5-1 2020-12-13 [1] CRAN (R 4.1.3)
## gtable 0.3.4 2023-08-21 [1] CRAN (R 4.1.3)
## haven 2.5.3 2023-06-30 [1] CRAN (R 4.1.3)
## here * 1.0.1 2020-12-13 [1] CRAN (R 4.1.3)
## hms 1.1.3 2023-03-21 [1] CRAN (R 4.1.3)
## htmltools 0.5.6 2023-08-10 [1] CRAN (R 4.1.3)
## jquerylib 0.1.4 2021-04-26 [1] CRAN (R 4.1.3)
## jsonlite 1.8.7 2023-06-29 [1] CRAN (R 4.1.3)
## knitr * 1.44 2023-09-11 [1] CRAN (R 4.1.3)
## labeling 0.4.3 2023-08-29 [1] CRAN (R 4.1.3)
## lastdose * 0.4.1 2023-04-27 [1] MPNDEV (R 4.1.3)
## later 1.3.1 2023-05-02 [1] CRAN (R 4.1.3)
## lattice 0.21-8 2023-04-05 [1] CRAN (R 4.1.3)
## lifecycle 1.0.3 2022-10-07 [1] CRAN (R 4.1.3)
## lubridate * 1.9.2 2023-02-10 [1] CRAN (R 4.1.3)
## magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.1.3)
## Matrix 1.6-1.1 2023-09-18 [1] CRAN (R 4.1.3)
## mgcv 1.9-0 2023-07-11 [1] CRAN (R 4.1.3)
## mrgda * 0.9.0 2023-10-06 [1] MPNDEV (R 4.1.3)
## mrggsave * 0.4.5 2024-03-11 [1] MPNDEV (R 4.1.3)
## mrgmisc * 0.1.5 2024-03-11 [1] MPNDEV (R 4.1.3)
## munsell 0.5.0 2018-06-12 [1] CRAN (R 4.1.3)
## nlme 3.1-163 2023-08-09 [1] CRAN (R 4.1.3)
## patchwork * 1.1.3 2023-08-14 [1] CRAN (R 4.1.3)
## pillar 1.9.0 2023-03-22 [1] CRAN (R 4.1.3)
## pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.1.3)
## plyr 1.8.8 2022-11-11 [1] CRAN (R 4.1.3)
## pmplots * 0.3.7 2024-03-11 [1] MPNDEV (R 4.1.3)
## pmtables * 0.6.0 2024-03-11 [1] MPNDEV (R 4.1.3)
## prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.1.3)
## processx 3.8.2 2023-06-30 [1] CRAN (R 4.1.3)
## progress 1.2.2 2019-05-16 [1] CRAN (R 4.1.3)
## ps 1.7.5 2023-04-18 [1] CRAN (R 4.1.3)
## purrr * 1.0.2 2023-08-10 [1] CRAN (R 4.1.3)
## quarto 1.3 2023-09-19 [1] CRAN (R 4.1.3)
## R6 2.5.1 2021-08-19 [1] CRAN (R 4.1.3)
## RColorBrewer 1.1-3 2022-04-03 [1] CRAN (R 4.1.3)
## Rcpp 1.0.11 2023-07-06 [1] CRAN (R 4.1.3)
## readr * 2.1.4 2023-02-10 [1] CRAN (R 4.1.3)
## renv 1.0.3 2023-09-19 [1] CRAN (R 4.1.3)
## reshape 0.8.9 2022-04-12 [1] CRAN (R 4.1.3)
## rlang 1.1.1 2023-04-28 [1] CRAN (R 4.1.3)
## rmarkdown * 2.25 2023-09-18 [1] CRAN (R 4.1.3)
## rprojroot 2.0.3 2022-04-02 [1] CRAN (R 4.1.3)
## rstudioapi 0.15.0 2023-07-07 [1] CRAN (R 4.1.3)
## sass 0.4.7 2023-07-15 [1] CRAN (R 4.1.3)
## scales 1.2.1 2022-08-20 [1] CRAN (R 4.1.3)
## sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.1.3)
## stringi 1.7.12 2023-01-11 [1] CRAN (R 4.1.3)
## stringr * 1.5.0 2022-12-02 [1] CRAN (R 4.1.3)
## tibble * 3.2.1 2023-03-20 [1] CRAN (R 4.1.3)
## tidyr * 1.3.0 2023-01-24 [1] CRAN (R 4.1.3)
## tidyselect 1.2.0 2022-10-10 [1] CRAN (R 4.1.3)
## tidyverse * 2.0.0 2023-02-22 [1] CRAN (R 4.1.3)
## timechange 0.2.0 2023-01-11 [1] CRAN (R 4.1.3)
## tzdb 0.4.0 2023-05-12 [1] CRAN (R 4.1.3)
## utf8 1.2.3 2023-01-31 [1] CRAN (R 4.1.3)
## vctrs 0.6.3 2023-06-14 [1] CRAN (R 4.1.3)
## vroom 1.6.3 2023-04-28 [1] CRAN (R 4.1.3)
## withr 2.5.0 2022-03-03 [1] CRAN (R 4.1.3)
## xfun 0.40 2023-08-09 [1] CRAN (R 4.1.3)
## xtable 1.8-4 2019-04-21 [1] CRAN (R 4.1.3)
## yaml * 2.3.7 2023-01-23 [1] CRAN (R 4.1.3)
## yspec * 0.6.1 2024-03-11 [1] MPNDEV (R 4.1.3)
##
## [1] /data/bbr-nonmem-poppk-foce/renv/library/R-4.1/x86_64-pc-linux-gnu
## [2] /data/home/graceo/.cache/R/renv/sandbox/R-4.1/x86_64-pc-linux-gnu/dbd573bd
##
## ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
bbr::bbi_version()
## [1] "3.3.0"