Title: | 'ggplot2' Based Tool to Facilitate Diagnostic Plots for NLME Models |
Description: | At Novartis, we aimed at standardizing the set of diagnostic plots used for modeling activities in order to reduce the overall effort required for generating such plots. For this, we developed a guidance that proposes an adequate set of diagnostics and a toolbox, called 'ggPMX' to execute them. 'ggPMX' is a toolbox that can generate all diagnostic plots at a quality sufficient for publication and submissions using few lines of code. This package focuses on plots recommended by ISoP <doi:10.1002/psp4.12161>. While not required, you can get/install the 'R' 'lixoftConnectors' package in the 'Monolix' installation, as described at the following url https://monolixsuite.slp-software.com/r-functions/2024R1/installation-and-initialization. When 'lixoftConnectors' is available, 'R' can use 'Monolix' directly to create the required Chart Data instead of exporting it from the 'Monolix' gui. |
Version: | 1.3.0 |
URL: | https://github.com/ggPMXdevelopment/ggPMX |
BugReports: | https://github.com/ggPMXdevelopment/ggPMX/issues |
Depends: | R (≥ 3.5) |
Imports: | data.table, yaml, R6, gtable, ggplot2 (≥ 3.4.0), ggforce, magrittr, stringr, assertthat, GGally, zoo, knitr, rmarkdown, tidyr, dplyr, purrr, readr, rlang, checkmate, scales |
License: | GPL-2 |
Suggests: | testthat, xtable, vdiffr, rxode2, nlmixr2est, nlmixr2data, nlme, lixoftConnectors, xgxr, withr, lifecycle |
VignetteBuilder: | knitr |
NeedsCompilation: | no |
RoxygenNote: | 7.3.2 |
Encoding: | UTF-8 |
Packaged: | 2025-07-16 08:10:33 UTC; codespace |
Author: | Amine Gassem [aut],
Bruno Bieth [aut],
Irina Baltcheva [aut],
Thomas Dumortier [aut],
Christian Bartels [aut],
Souvik Bhattacharya [aut],
Inga Ludwig [aut],
Ines Paule [aut],
Didier Renard [aut],
Matthew Fidler |
Maintainer: | Aleksandr Pogodaev <alex.pogodaev@novartis.com> |
Repository: | CRAN |
Date/Publication: | 2025-07-16 10:20:02 UTC |
ggPMX: A ggplot2 toolbox for Nonlinear Mixed-Effect Model graphical
Description
This package aims to generate diagnostic plots in a standard way. The tool reads data from many sources (MONOLIX,NONMEM,others) and generates standard grahics that can be easily integrated in a single report.
Details
Get data from different system and create a data source
Plot many plots using the generic plot method
plot_pmx
.
For support, feedback or bug reports, please reach out to ggPMX_ORG@dl.mgd.novartis.com.
Version History
- Jan 11 2017, 0.0.0
Init ggPMX from Novartis rtemplate.
- Feb 06 2017, 0.3.0
Import version 0.3.0 of package.
Author(s)
Maintainer: Aleksandr Pogodaev alex.pogodaev@novartis.com (ORCID)
Authors:
Amine Gassem contact@ag-study.com
Bruno Bieth biethb@hotmail.com
Irina Baltcheva irina.baltcheva@gmail.com
Thomas Dumortier thomas.dumortier@novartis.com
Christian Bartels christian.bartels@novartis.com
Souvik Bhattacharya souvik.bhattacharya@novartis.com
Inga Ludwig inga.ludwig@novartis.com
Ines Paule ines.paule@novartis.com
Didier Renard didier.renard@novartis.com
Matthew Fidler matt.fidler@novartis.com (ORCID)
Seid Hamzic se.hamzic@gmail.com
Danielle Navarro djnavarro@protonmail.com
Other contributors:
Benjamin Guiastrennec guiastrennec@gmail.com [contributor]
Kyle T Baron kyleb@metrumrg.com (ORCID) [contributor]
Qing Xi Ooi ooi.qingxi@gmail.com [contributor]
Ibtissem Rebai ibtissem.rebai@certara.com [contributor]
Mahmoud Ali mahmoud.ali@certara.com [contributor]
Novartis Pharma AG [copyright holder]
See Also
Useful links:
Report bugs at https://github.com/ggPMXdevelopment/ggPMX/issues
Method for subsetting "pmx_gpar" objects
Description
Method for subsetting "pmx_gpar" objects
Usage
## S3 method for class 'pmx_gpar'
x[index, ...]
Arguments
x |
pmx_gpar object |
index |
can be character/integer of element |
... |
other parameter (not used just for generic) |
Value
if exists the parameter description
Give the whole abbreviation definition
Description
Give the whole abbreviation definition
Usage
abbrev(param)
Arguments
param |
abbreviation term |
Value
character abbreviation definition
Examples
abbrev("VPC")
Add draft layer annotation
Description
This function adds the word draft to certain graphics.
Usage
add_draft(
label = "DRAFT",
size = 10,
colour = "grey50",
x = Inf,
y = -Inf,
...
)
Arguments
label |
draft layer default to DRAFT |
size |
size of the annotation |
colour |
color of the annotation default to grey50 |
x |
|
y |
|
... |
extra parameters to geom text used to annotate the draft |
Value
ggplot2 annotation
Performs checks of names in shrink list
Description
Performs checks of names in shrink list
Usage
check_shrink(shrink_list)
Arguments
shrink_list |
|
creates a graphic distribution object
Description
creates a graphic distribution object
Usage
distrib(
labels,
is.shrink,
type = c("box", "hist"),
is.jitter = FALSE,
jitter = NULL,
facets = NULL,
histogram = NULL,
shrink = NULL,
dname = NULL,
...
)
Arguments
labels |
list of texts/titles used within the plot |
is.shrink |
|
type |
box for boxplot or histogram |
is.jitter |
|
jitter |
list set jitter parameter |
facets |
list set the facet setting in case of histogram plot |
histogram |
|
shrink |
|
dname |
name of dataset to be used |
... |
others graphics arguments passed to |
Details
labels is a list that contains:
-
title: plot title default "EBE distribution"
-
subtitle: plot subtitle default empty
-
x: x axis label default to "Etas"
-
y: y axis label default to empty
-
legend: legend title default to "random Effect"
shrink is a list that contains:
-
fun: shrinkage function can be
sd
orvar
-
size: shrinkage text size
-
color: shrinkage text color
-
vjust: shrinkage position vertical adjustment
Value
distrib object
See Also
Other plot_pmx:
eta_cov()
,
eta_pairs()
,
individual()
,
plot_pmx()
,
plot_pmx.distrib()
,
plot_pmx.eta_cov()
,
plot_pmx.eta_pairs()
,
plot_pmx.individual()
,
plot_pmx.pmx_dens()
,
plot_pmx.pmx_gpar()
,
plot_pmx.pmx_param_history()
,
plot_pmx.pmx_qq()
,
plot_pmx.residual()
This creates an ETA covariance matrix which can be used to define the co-relation between the parameters and its shrinkage..
Description
This creates an ETA covariance matrix which can be used to define the co-relation between the parameters and its shrinkage..
Usage
eta_cov(
labels,
type = c("cats", "conts"),
dname = NULL,
show.correl = TRUE,
correl = NULL,
facets = NULL,
point = NULL,
covariates = NULL,
is.strat.color = FALSE,
...
)
Arguments
labels |
list of texts/titles used within the plot |
type |
box for cats or conts |
dname |
name of dataset to be used |
show.correl |
|
correl |
|
facets |
|
point |
|
covariates |
|
is.strat.color |
|
... |
others graphics arguments passed to |
Details
labels is a list that contains:
-
title: plot title default "EBE vs. covariates"
-
x: x axis label default to "Etas"
-
y: y axis label default to empty
Value
eta_cov
object
See Also
Other plot_pmx:
distrib()
,
eta_pairs()
,
individual()
,
plot_pmx()
,
plot_pmx.distrib()
,
plot_pmx.eta_cov()
,
plot_pmx.eta_pairs()
,
plot_pmx.individual()
,
plot_pmx.pmx_dens()
,
plot_pmx.pmx_gpar()
,
plot_pmx.pmx_param_history()
,
plot_pmx.pmx_qq()
,
plot_pmx.residual()
Eta Covariates plots
Description
Eta Covariates plots
Relationships between (ETA) and categorical covariates
Relationships between (ETA) and continuous covariates
Usage
dummy(
dname,
show.correl,
correl,
point,
facets,
covariates,
filter,
strat.facet,
strat.color,
trans,
pmxgpar,
labels,
axis.title,
axis.text,
ranges,
is.smooth,
smooth,
is.band,
band,
is.draft,
draft,
is.identity_line,
identity_line,
scale_x_log10,
scale_y_log10,
color.scales
)
pmx_plot_eta_cats(ctr, ...)
pmx_plot_eta_conts(ctr, ...)
Arguments
dname |
|
show.correl |
|
correl |
|
point |
|
facets |
|
covariates |
list of selected covariates and custom labels, e.g. pmx_update parameters |
filter |
|
strat.facet |
|
strat.color |
|
trans |
|
pmxgpar |
a object of class pmx_gpar possibly the output of the pmx_gpar: Shared basic graphics parameters |
labels |
|
axis.title |
|
axis.text |
|
ranges |
|
is.smooth |
|
smooth |
|
is.band |
|
band |
|
is.draft |
|
draft |
|
is.identity_line |
|
identity_line |
|
scale_x_log10 |
|
scale_y_log10 |
|
color.scales |
|
ctr |
pmx controller |
... |
others graphics parameters passed :
eta_cov parameters |
Value
ggplot2 object
ggplot2 object
ggplot2 object
Examples
# basic use ---------------------------------------
ctr <- theophylline()
ctr %>% pmx_plot_eta_cats
ctr %>% pmx_plot_eta_conts
# update graphical parameter ----------------------
## plot selected covariates
ctr %>% pmx_plot_eta_cats(
covariates = pmx_cov(values = list("SEX"))
)
## update labels
ctr %>% pmx_plot_eta_cats(
labels = list(title = "New eta cats title")
)
## remove draft
ctr %>% pmx_plot_eta_cats(is.draft = FALSE)
## change text color line
ctr %>% pmx_plot_eta_conts(
correl=list(colour="magenta")
)
## set covariates custom labels
ctr %>% pmx_plot_eta_conts(
covariates=pmx_cov(values=list("WT0","AGE0"),
labels=list("Weight","Age"))
)
## set effects and covaraites custom labels
ctr <- theophylline( settings = pmx_settings(
effects=list( levels=c("ka", "V", "Cl"),
labels=c("Concentration","Volume","Clearance")
)
)
)
ctr %>% pmx_plot_eta_conts(
covariates=pmx_cov(values=list("WT0","AGE0"),
labels=list("Weight","Age"))
)
Eta distribution plots
Description
Eta distribution plots
Eta Distribution boxplot
Eta Distribution histogram plot
Usage
eta_distribution_plot(
jitter,
type,
dname,
is.shrink,
shrink,
is.jitter,
histogram,
filter,
strat.facet,
facets,
strat.color,
trans,
pmxgpar,
labels,
axis.title,
axis.text,
ranges,
is.smooth,
smooth,
is.band,
band,
is.draft,
draft,
is.identity_line,
identity_line,
scale_x_log10,
scale_y_log10,
color.scales,
...
)
pmx_plot_eta_box(ctr, ...)
pmx_plot_eta_hist(ctr, ...)
Arguments
jitter |
list set jitter parameter |
type |
box for boxplot or histogram |
dname |
name of dataset to be used |
is.shrink |
|
shrink |
|
is.jitter |
|
histogram |
pmx_update parameters |
filter |
|
strat.facet |
|
facets |
|
strat.color |
|
trans |
|
pmxgpar |
a object of class pmx_gpar possibly the output of the pmx_gpar: Shared basic graphics parameters |
labels |
|
axis.title |
|
axis.text |
|
ranges |
|
is.smooth |
|
smooth |
|
is.band |
|
band |
|
is.draft |
|
draft |
|
is.identity_line |
|
identity_line |
|
scale_x_log10 |
|
scale_y_log10 |
|
color.scales |
|
... |
others graphics parameters passed :
distrib parameters |
ctr |
pmx controller |
Value
ggplot2 object
Examples
# *************** basic use ***************** ------
ctr <- theophylline()
## boxplot variation
p <- ctr %>% pmx_plot_eta_box()
## histogram variation
p <- ctr %>% pmx_plot_eta_hist()
# update graphical parameter ----------------------
## add jitter
ctr %>%
pmx_plot_eta_hist(is.jitter = TRUE, jitter = list(alpha = 0.4, color = "red"))
## remove shrinkage
ctr %>%
pmx_plot_eta_hist(is.shrink = FALSE)
## update histogram graphical parameters
ctr %>%
pmx_plot_eta_hist(
histogram = list(
color = NA,
position = "fill",
binwidth = 1 / 100
)
)
# stratification ----------------------------------
## categorical stratification color parameter
ctr %>% pmx_plot_eta_hist(is.jitter = TRUE, strat.facet = ~STUD, strat.color = ~SEX)
## categorical stratification facetting
ctr %>% pmx_plot_eta_hist(strat.facet = ~SEX)
## using formula categorical stratification facetting
ctr %>% pmx_plot_eta_hist(
strat.facet = STUD ~ SEX,
shrink = pmx_shrink(hjust = 0.5)
)
# subsetting --------------------------------------
## select a set of random effect
ctr %>% pmx_plot_eta_hist(filter = EFFECT %in% c("ka", "Cl"))
## filter and stratify by facets
ctr %>% pmx_plot_eta_hist(
filter = EFFECT %in% c("ka", "Cl"), strat.facet = ~SEX
)
ctr %>% pmx_plot_eta_hist(
filter = EFFECT %in% c("ka", "Cl"), strat.facet = ~SEX
)
This creates an eta correlation which defines the relationship between parameters
Description
This creates an eta correlation which defines the relationship between parameters
Usage
eta_pairs(
is.title,
title,
dname = NULL,
type.eta = c("mode", "mean"),
text_color = "black",
is.shrink = TRUE,
is.smooth = TRUE,
smooth = NULL,
point = NULL,
shrink = NULL,
is.hline = FALSE,
hline = NULL,
is.vreference_line = FALSE,
vreference_line = list(colour = "orange", linetype = "longdash"),
...
)
Arguments
is.title |
|
title |
character the plot title |
dname |
name of dataset to be used |
type.eta |
|
text_color |
color of the correlation text in the upper matrix |
is.shrink |
|
is.smooth |
|
smooth |
|
point |
|
shrink |
|
is.hline |
|
hline |
|
is.vreference_line |
|
vreference_line |
|
... |
others graphics arguments passed to |
Value
ecorrel object
See Also
Other plot_pmx:
distrib()
,
eta_cov()
,
individual()
,
plot_pmx()
,
plot_pmx.distrib()
,
plot_pmx.eta_cov()
,
plot_pmx.eta_pairs()
,
plot_pmx.individual()
,
plot_pmx.pmx_dens()
,
plot_pmx.pmx_gpar()
,
plot_pmx.pmx_param_history()
,
plot_pmx.pmx_qq()
,
plot_pmx.residual()
Try to evaluate a symbol in the parent frame (on error return the symbol)
Description
Try to evaluate a symbol in the parent frame (on error return the symbol)
Usage
eval_sym_parent_env(x)
Arguments
x |
any object |
Value
evaluated symbol or the symbol in case of evaluation error
Get ggPMX Option
Description
Get ggPMX Option
Usage
getPmxOption(name, default = NULL)
Arguments
name |
Name of an option to get. |
default |
Value to be returned if the option is not currently set. |
Value
value of the option or NULL
Examples
## Not run:
pmxOptions(myOption = 10)
getPmxOption("myOption")
## End(Not run)
Get abbreviation definition by key
Description
Get abbreviation definition by key
Usage
get_abbrev(ctr, param)
Arguments
ctr |
|
param |
abbreviation term |
Value
character
abbreviation definition
Get category covariates
Description
Get category covariates
Usage
get_cats(ctr)
Arguments
ctr |
the controller object |
Value
a charcater vector
See Also
Other pmxclass:
get_conts()
,
get_covariates()
,
get_data()
,
get_occ()
,
get_plot()
,
get_plot_config()
,
get_strats()
,
plot_names()
,
plots()
,
pmx_update()
,
set_data()
,
set_plot()
Get continuous covariates
Description
Get continuous covariates
Usage
get_conts(ctr)
Arguments
ctr |
the controller object |
Value
a charcater vector
See Also
Other pmxclass:
get_cats()
,
get_covariates()
,
get_data()
,
get_occ()
,
get_plot()
,
get_plot_config()
,
get_strats()
,
plot_names()
,
plots()
,
pmx_update()
,
set_data()
,
set_plot()
Get covariates variables
Description
Get covariates variables
Usage
get_covariates(ctr)
Arguments
ctr |
the controller object |
Value
a charcater vector
See Also
Other pmxclass:
get_cats()
,
get_conts()
,
get_data()
,
get_occ()
,
get_plot()
,
get_plot_config()
,
get_strats()
,
plot_names()
,
plots()
,
pmx_update()
,
set_data()
,
set_plot()
Get controller data set
Description
Get controller data set
Usage
get_data(
ctr,
data_set = c("estimates", "predictions", "eta", "finegrid", "input", "sim",
"individual")
)
Arguments
ctr |
the controller object |
data_set |
the data set name |
Value
a data.table of the named data set if available.
See Also
Other pmxclass:
get_cats()
,
get_conts()
,
get_covariates()
,
get_occ()
,
get_plot()
,
get_plot_config()
,
get_strats()
,
plot_names()
,
plots()
,
pmx_update()
,
set_data()
,
set_plot()
Get controller occasional covariates
Description
Get controller occasional covariates
Usage
get_occ(ctr)
Arguments
ctr |
the controller object |
Value
a charcater vector
See Also
Other pmxclass:
get_cats()
,
get_conts()
,
get_covariates()
,
get_data()
,
get_plot()
,
get_plot_config()
,
get_strats()
,
plot_names()
,
plots()
,
pmx_update()
,
set_data()
,
set_plot()
Get plot object
Description
Get plot object
Usage
get_plot(ctr, nplot, which_pages = "all")
Arguments
ctr |
|
nplot |
character the plot name |
which_pages |
integer vector (can be length 1), set page number in case of multi pages plot, or character "all" to plot all pages. |
Value
ggplot object
See Also
Other pmxclass:
get_cats()
,
get_conts()
,
get_covariates()
,
get_data()
,
get_occ()
,
get_plot_config()
,
get_strats()
,
plot_names()
,
plots()
,
pmx_update()
,
set_data()
,
set_plot()
Examples
library(ggPMX)
ctr <- theophylline()
p1 <- ctr %>% get_plot("iwres_ipred")
## get all pages or some pages
p2 <- ctr %>% get_plot("individual")
## returns one page of individual plot
p2 <- ctr %>% get_plot("individual", which_pages = 1)
p3 <- ctr %>% get_plot("individual", which_pages = c(1, 3))
## get distribution plot
pdistri <- ctr %>% get_plot("eta_hist")
Get the plot config by name
Description
Get the plot config by name
Usage
get_plot_config(ctr, pname)
Arguments
ctr |
the controller object |
pname |
the plot name |
Value
the config object
See Also
Other pmxclass:
get_cats()
,
get_conts()
,
get_covariates()
,
get_data()
,
get_occ()
,
get_plot()
,
get_strats()
,
plot_names()
,
plots()
,
pmx_update()
,
set_data()
,
set_plot()
Examples
ctr <- theophylline()
ctr %>% set_plot("IND", pname = "indiv1")
ctr %>% get_plot_config("distr1")
Get extra stratification variables
Description
Get extra stratification variables
Usage
get_strats(ctr)
Arguments
ctr |
the controller object |
Value
a charcater vector
See Also
Other pmxclass:
get_cats()
,
get_conts()
,
get_covariates()
,
get_data()
,
get_occ()
,
get_plot()
,
get_plot_config()
,
plot_names()
,
plots()
,
pmx_update()
,
set_data()
,
set_plot()
Remove named elements from gtable
Description
Remove named elements from gtable
Usage
gtable_remove_grobs(table, names, ...)
Arguments
table |
The table from which grobs should be removed |
names |
A character vector of the grob names (as listed in |
... |
Other parameters passed through to |
Value
table The table with removed grobs
This function can be used to obtain individual prediction and compare with observed data and population prediction for each individual separately
Description
This function can be used to obtain individual prediction and compare with observed data and population prediction for each individual separately
Usage
individual(
labels,
facets = NULL,
dname = NULL,
ipred_line = NULL,
pred_line = NULL,
point = NULL,
bloq = NULL,
is.legend,
use.finegrid,
...
)
Arguments
labels |
plot texts. labels, axis, |
facets |
list facets settings nrow/ncol |
dname |
name of dataset to be used |
ipred_line |
|
pred_line |
|
point |
|
bloq |
|
is.legend |
|
use.finegrid |
|
... |
others graphics arguments passed to |
Value
individual fit object
See Also
Other plot_pmx:
distrib()
,
eta_cov()
,
eta_pairs()
,
plot_pmx()
,
plot_pmx.distrib()
,
plot_pmx.eta_cov()
,
plot_pmx.eta_pairs()
,
plot_pmx.individual()
,
plot_pmx.pmx_dens()
,
plot_pmx.pmx_gpar()
,
plot_pmx.pmx_param_history()
,
plot_pmx.pmx_qq()
,
plot_pmx.residual()
Merge input and fingrid data sets
Description
Merge input and fingrid data sets
Usage
input_finegrid(input, finegrid)
Arguments
input |
|
finegrid |
|
Value
data.table
Check if an object is a pmx_gpar class
Description
Check if an object is a pmx_gpar class
Usage
is.pmx_gpar(x)
Arguments
x |
pmx_gpar object |
Value
logical
returns TRUE if it is a pmx_gpar
object
Merge 2 lists
Description
left join , the first list is updated by the seond one
Usage
l_left_join(base_list, overlay_list, recursive = TRUE)
Arguments
base_list |
list to update |
overlay_list |
list used to update the first list |
recursive |
logical if TRUE do the merge in depth |
Value
list
Obtain the data source config
Description
Obtain the data source config
Usage
load_config(x, sys = c("mlx", "nm", "mlx18"))
Arguments
x |
the config name. |
sys |
can be mlx,nm,... |
Value
a list :data configuration object
Load data set
Description
Load data set
Usage
load_data_set(x, path, sys, ...)
Arguments
x |
data set config |
path |
character path to the directory |
sys |
|
... |
extra parameter passed to special readers |
Value
data.table
Load all/or some source data set
Description
Load all/or some source data set
Usage
load_source(sys, path, dconf, ...)
Arguments
sys |
type cane mlx/nom |
path |
|
dconf |
configuration object |
... |
any extra parameters for readers |
Value
list of data.table
Determine the number of pages in a paginated facet plot
Description
This is a simple helper that returns the number of pages it takes to plot all
panels when using facet_wrap_paginate
. It partially builds the plot so depending
on the complexity of your plot it might take some time to calculate...
Usage
n_pages(plot)
Arguments
plot |
A ggplot object using either facet_wrap_paginate or facet_grid_paginate |
Value
If the plot uses using either facet_wrap_paginate or facet_grid_paginate it returns the total number of pages. Otherwise it returns NULL
Creates parameter kable
Description
Creates parameter kable
Usage
param_table(ctr, fun, return_table = FALSE, scientific = FALSE, digits = 2)
Arguments
ctr |
Generated controller from e.g. |
fun |
|
return_table |
If TRUE, returns the same table as in get_data('estimates') otherwise it returns a kable |
scientific |
|
digits |
|
Value
Returns a kable with the parameter estimates from get_data('estimates')
Examples
#ctr <- theophylline()
#my_params <- ctr %>% param_table(fun = "var")
Parse MONOLIX mlxtran file
Description
Parse MONOLIX mlxtran file
Usage
parse_mlxtran(file_name)
Arguments
file_name |
absolute path to mlxtran file |
Value
list
key/values to initialize ggPMX controller
Creates pmx controller using monlix data having Occasional variable
Description
Creates pmx controller using monlix data having Occasional variable
Usage
pk_occ()
Value
pmx controller
Examples
## Not run:
pk_occ()
## End(Not run)
Creates pkpd pmx controller using package internal data
Description
Creates pkpd pmx controller using package internal data
Usage
pk_pd(code = "3")
Arguments
code |
can be 3 or 4 |
Get plot names
Description
Get plot names
Usage
plot_names(ctr)
Arguments
ctr |
|
Value
list of plot names
See Also
Other pmxclass:
get_cats()
,
get_conts()
,
get_covariates()
,
get_data()
,
get_occ()
,
get_plot()
,
get_plot_config()
,
get_strats()
,
plots()
,
pmx_update()
,
set_data()
,
set_plot()
This is a generic plot method that produces all plots by default described in pmx model evaluation guidance.
Description
This is a generic plot method that produces all plots by default described in pmx model evaluation guidance.
Usage
plot_pmx(x, dx, ...)
## S3 method for class 'pmx_vpc'
plot_pmx(x, dx, ...)
Arguments
x |
object to plot |
dx |
data.table , plot source data |
... |
extra argument (not used) |
See Also
Other plot_pmx:
distrib()
,
eta_cov()
,
eta_pairs()
,
individual()
,
plot_pmx.distrib()
,
plot_pmx.eta_cov()
,
plot_pmx.eta_pairs()
,
plot_pmx.individual()
,
plot_pmx.pmx_dens()
,
plot_pmx.pmx_gpar()
,
plot_pmx.pmx_param_history()
,
plot_pmx.pmx_qq()
,
plot_pmx.residual()
Plot EBE distribution
Description
Plot EBE distribution
Usage
## S3 method for class 'distrib'
plot_pmx(x, dx, ...)
Arguments
x |
distribution object |
dx |
data set |
... |
not used for the moment |
Value
ggplot2 plot
See Also
Other plot_pmx:
distrib()
,
eta_cov()
,
eta_pairs()
,
individual()
,
plot_pmx()
,
plot_pmx.eta_cov()
,
plot_pmx.eta_pairs()
,
plot_pmx.individual()
,
plot_pmx.pmx_dens()
,
plot_pmx.pmx_gpar()
,
plot_pmx.pmx_param_history()
,
plot_pmx.pmx_qq()
,
plot_pmx.residual()
This plots an ETA covariance matrix which can be used to define the co-relation between the parameters and its shrinkage
Description
This plots an ETA covariance matrix which can be used to define the co-relation between the parameters and its shrinkage
Usage
## S3 method for class 'eta_cov'
plot_pmx(x, dx, ...)
Arguments
x |
eta_cov object |
dx |
data set |
... |
not used for the moment |
Value
ggplot2 plot
See Also
Other plot_pmx:
distrib()
,
eta_cov()
,
eta_pairs()
,
individual()
,
plot_pmx()
,
plot_pmx.distrib()
,
plot_pmx.eta_pairs()
,
plot_pmx.individual()
,
plot_pmx.pmx_dens()
,
plot_pmx.pmx_gpar()
,
plot_pmx.pmx_param_history()
,
plot_pmx.pmx_qq()
,
plot_pmx.residual()
Plot random effect correlation plot
Description
Plot random effect correlation plot
Usage
## S3 method for class 'eta_pairs'
plot_pmx(x, dx, ...)
Arguments
x |
distribution object |
dx |
data set |
... |
not used for the moment |
Value
ggpairs plot
See Also
Other plot_pmx:
distrib()
,
eta_cov()
,
eta_pairs()
,
individual()
,
plot_pmx()
,
plot_pmx.distrib()
,
plot_pmx.eta_cov()
,
plot_pmx.individual()
,
plot_pmx.pmx_dens()
,
plot_pmx.pmx_gpar()
,
plot_pmx.pmx_param_history()
,
plot_pmx.pmx_qq()
,
plot_pmx.residual()
This function can be used to plot individual prediction and compare with observed data and population prediction for each individual separately
Description
This function can be used to plot individual prediction and compare with observed data and population prediction for each individual separately
Usage
## S3 method for class 'individual'
plot_pmx(x, dx, ...)
Arguments
x |
individual object |
dx |
data set |
... |
not used for the moment |
Value
a list of ggplot2
See Also
Other plot_pmx:
distrib()
,
eta_cov()
,
eta_pairs()
,
individual()
,
plot_pmx()
,
plot_pmx.distrib()
,
plot_pmx.eta_cov()
,
plot_pmx.eta_pairs()
,
plot_pmx.pmx_dens()
,
plot_pmx.pmx_gpar()
,
plot_pmx.pmx_param_history()
,
plot_pmx.pmx_qq()
,
plot_pmx.residual()
This function plots EBE versus covariates using qq plots
Description
This function plots EBE versus covariates using qq plots
Usage
## S3 method for class 'pmx_dens'
plot_pmx(x, dx, ...)
Arguments
x |
eta_cov object |
dx |
data set |
... |
not used for the moment |
Value
ggplot2 plot
See Also
Other plot_pmx:
distrib()
,
eta_cov()
,
eta_pairs()
,
individual()
,
plot_pmx()
,
plot_pmx.distrib()
,
plot_pmx.eta_cov()
,
plot_pmx.eta_pairs()
,
plot_pmx.individual()
,
plot_pmx.pmx_gpar()
,
plot_pmx.pmx_param_history()
,
plot_pmx.pmx_qq()
,
plot_pmx.residual()
The ggPMX base plot function
Description
This function should be called internally by other plots to set general settings like , smoothing, add band, labelling, theming,...
Usage
## S3 method for class 'pmx_gpar'
plot_pmx(x, dx, ...)
Arguments
x |
object of pmx_gpar type |
dx |
plot |
... |
ignored parameters |
Value
ggplot2 object
See Also
Other plot_pmx:
distrib()
,
eta_cov()
,
eta_pairs()
,
individual()
,
plot_pmx()
,
plot_pmx.distrib()
,
plot_pmx.eta_cov()
,
plot_pmx.eta_pairs()
,
plot_pmx.individual()
,
plot_pmx.pmx_dens()
,
plot_pmx.pmx_param_history()
,
plot_pmx.pmx_qq()
,
plot_pmx.residual()
S3 method for plots of class pmx_param_history
Description
S3 method for plots of class pmx_param_history
Usage
## S3 method for class 'pmx_param_history'
plot_pmx(x, dx, ...)
Arguments
x |
pmx_param_history object |
dx |
data set |
... |
not used |
Value
ggplot2 plot
See Also
Other plot_pmx:
distrib()
,
eta_cov()
,
eta_pairs()
,
individual()
,
plot_pmx()
,
plot_pmx.distrib()
,
plot_pmx.eta_cov()
,
plot_pmx.eta_pairs()
,
plot_pmx.individual()
,
plot_pmx.pmx_dens()
,
plot_pmx.pmx_gpar()
,
plot_pmx.pmx_qq()
,
plot_pmx.residual()
This function plot EBE versus covariates using qq plots
Description
This function plot EBE versus covariates using qq plots
Usage
## S3 method for class 'pmx_qq'
plot_pmx(x, dx, ...)
Arguments
x |
pmx_qq object |
dx |
data set |
... |
not used for the moment |
Value
ggplot2 plot
See Also
Other plot_pmx:
distrib()
,
eta_cov()
,
eta_pairs()
,
individual()
,
plot_pmx()
,
plot_pmx.distrib()
,
plot_pmx.eta_cov()
,
plot_pmx.eta_pairs()
,
plot_pmx.individual()
,
plot_pmx.pmx_dens()
,
plot_pmx.pmx_gpar()
,
plot_pmx.pmx_param_history()
,
plot_pmx.residual()
This function plots residual for each observed value by finding the difference between observed and predicted points. It also fits a distribution to the residual value.
Description
This function plots residual for each observed value by finding the difference between observed and predicted points. It also fits a distribution to the residual value.
Usage
## S3 method for class 'residual'
plot_pmx(x, dx, ...)
Arguments
x |
residual object |
dx |
data set |
... |
not used for the moment |
Value
ggplot2 object
See Also
Other plot_pmx:
distrib()
,
eta_cov()
,
eta_pairs()
,
individual()
,
plot_pmx()
,
plot_pmx.distrib()
,
plot_pmx.eta_cov()
,
plot_pmx.eta_pairs()
,
plot_pmx.individual()
,
plot_pmx.pmx_dens()
,
plot_pmx.pmx_gpar()
,
plot_pmx.pmx_param_history()
,
plot_pmx.pmx_qq()
Plot shrink in eta matric
Description
Plot shrink in eta matric
Usage
plot_shrink(x, shrink.dx, shrink)
Arguments
x |
pmx_gpar object |
shrink.dx |
data.table of shrinkage |
shrink |
|
Value
ggplot2 object
Get plots description
Description
Get plots description
Usage
plots(ctr)
Arguments
ctr |
|
Value
data.frame of plots
See Also
Other pmxclass:
get_cats()
,
get_conts()
,
get_covariates()
,
get_data()
,
get_occ()
,
get_plot()
,
get_plot_config()
,
get_strats()
,
plot_names()
,
pmx_update()
,
set_data()
,
set_plot()
Create a pmx object
Description
Create a pmx object from a data source
Usage
pmx(
config,
sys = "mlx",
directory,
input,
dv,
dvid,
cats = NULL,
conts = NULL,
occ = NULL,
strats = NULL,
settings = NULL,
endpoint = NULL,
sim = NULL,
bloq = NULL,
id = NULL,
time = NULL,
sim_blq = NULL
)
pmx_mlx(
config,
directory,
input,
dv,
dvid,
cats,
conts,
occ,
strats,
settings,
endpoint,
sim,
bloq,
id,
time,
sim_blq
)
pmx_mlxtran(
file_name,
config = "standing",
call = FALSE,
endpoint,
version = -1,
...
)
Arguments
config |
Can be either : The complete path for the configuration file, the name of configuration within the built-in list of configurations, or a configuration object. |
sys |
the system name can "mlx" (for Monolix 2016) or "mlx18" (for Monolix 2018/19 and later) |
directory |
|
input |
|
dv |
|
dvid |
[Optional] |
cats |
[Optional] |
conts |
[Optional] |
occ |
[Optional] |
strats |
[Optional] |
settings |
[Optional] |
endpoint |
|
sim |
|
bloq |
|
id |
[Optional] |
time |
[Optional] |
sim_blq |
|
file_name |
|
call |
|
version |
|
... |
extra arguments passed to pmx_mlx. |
Details
pmx_mlx
is a wrapper to mlx for the MONOLIX system ( sys="mlx"
)
pmx_mlxtran
parses mlxtran file and guess pmx_mlx
arguments. In case of
multi endpoint the first endpoint is selected. You can though set the endpoint through the same argument.
When you set call=TRUE
,no controller is created but only the parameters parsed
by mlxtran. This can be very helpful, in case you would like to customize parameters
(adding settings vi pmx_settings, chnag eth edefault endpoint.)
Value
pmxClass
controller object.
Examples
## Example to create the controller using theophylline data
theophylline <- file.path(system.file(package = "ggPMX"), "testdata",
"theophylline")
WORK_DIR <- file.path(theophylline, "Monolix")
input_file <- file.path(theophylline, "data_pk.csv")
## using only mandatory variables
ctr <- pmx(
sys="mlx",
config = "standing",
directory = WORK_DIR,
input = input_file,
dv = "Y",
dvid ="DVID"
)
## Using covariates
ctr <- pmx(
sys="mlx",
config = "standing",
directory = WORK_DIR,
input = input_file,
dv = "Y",
dvid ="DVID",
cats=c("SEX"),
conts=c("WT0","AGE0"),
strats="STUD"
)
## using settings parameter
ctr <- pmx(
sys="mlx",
config = "standing",
directory = WORK_DIR,
input = input_file,
dv = "Y",
dvid ="DVID",
settings=list(is.draft=FALSE)
)
## using mlxtran file
mlxtran_file <-
file.path(system.file(package = "ggPMX"),
"testdata","1_popPK_model","project.mlxtran")
pmx_mlxtran(mlxtran_file)
## mlxtran , call =TRUE to get the pmx_mlx argument parsed by pmx_mlxtran
params <- pmx_mlxtran(mlxtran_file,call=TRUE)
str(params)
# $ directory: chr results_pathile
# $ input : chr observation file path
# $ dv : chr "DV"
# $ cats : chr [1:4] "SEX" "RACE" "DISE" "ILOW"
# $ conts : chr [1:4] "AGE0" "WT0" "HT0" "TRT"
# $ occ : chr "ISS"
# $ dvid : chr "YTYPE"
# $ endpoint :List of 5
# ..$ code : chr "1"
# ..$ label : chr ""
# ..$ unit : chr ""
# ..$ file.code: chr "1"
# ..$ trans : NULL
# ..- attr(*, "class")= chr "pmxEndpointClass"
# $ config : chr "standing"
This function can be used to set ggPMX options
Description
getPmxOption
retrieves the value of a ggPMX option.
ggPMXOptions
sets the value of ggPMX options; it can also be used to
return a list of all currently-set ggPMX options.
Usage
pmxOptions(...)
Arguments
... |
Options to set, with the form |
Details
There is a global option set, which is available by default.
Value
list with options that were set by the user
Options used in ggPMX
-
template_dir: path to template directory
Examples
## Not run:
pmxOptions(template_dir = PATH_TO_CUSTOM_CONFIGURATION)
## End(Not run)
Creates BLOQ object attributes
Description
Creates BLOQ object attributes
Usage
pmx_bloq(
cens = "CENS",
limit = "LIMIT",
colour = "pink",
size = 2,
linewidth = 1,
alpha = 0.9,
show = TRUE,
...
)
Arguments
cens |
|
limit |
|
colour |
|
size |
|
linewidth |
|
alpha |
|
show |
|
... |
any other graphical parameter |
Details
To define that a measurement is censored, the observation data set should include
a CENSORING column ( default to 'CENS' ) and put 1 for lower limit or -1 for upper limit.
Optionally, data set can contain have a limit column ( default to 'LIMIT') column to set the other limit.
Combine tables
Description
Combine tables
Usage
pmx_combine_tables(x)
Arguments
x |
A list containing the tables ('x$data') to be combined, their names ('x$name'), their number of rows ('x$nrow') and their respective index ('x$index'). |
Value
A list containing 'data' and 'index' of the combined table.
Compute Shrinkage
Description
Compute Shrinkage
Usage
pmx_comp_shrink(
ctr,
fun = c("var", "sd"),
strat.facet,
strat.color,
filter,
...
)
Arguments
ctr |
|
fun |
|
strat.facet |
|
strat.color |
|
filter |
optional filter which will be applied to plotting data |
... |
others parameters not used for the moment |
Value
data.table
This function can be used to define the pmx configuration used in plots. e.g. Monolix/Nonmem
Description
This function can be used to define the pmx configuration used in plots. e.g. Monolix/Nonmem
Usage
pmx_config(sys = "mlx", inputs, plots, ...)
Arguments
sys |
|
inputs |
|
plots |
|
... |
extra arguments not used |
Details
To create a controller user can create a pmxConfig object using
- either an input template file
- or a plot template file
- or both.
By default the 'standing' configuration will be used.
Value
pmxConfig
object
Examples
# *************** Create a controller using custom plot configuration ***************** ------
library(ggPMX)
theophylline <- file.path(
system.file(package = "ggPMX"), "testdata",
"theophylline"
)
WORK_DIR <- file.path(theophylline, "Monolix")
input_file <- file.path(theophylline, "data_pk.csv")
# create a controller with a custom plots template
ctr <- pmx_mlx(
config = pmx_config(
plots=file.path( system.file(package = "ggPMX"),"examples/plots.yaml"),
inputs = system.file(package = "ggPMX","examples/custom_inputs.yaml")
),
directory = WORK_DIR,
input = input_file,
dv = "Y",
dvid = "DVID",
cats = c("SEX"),
conts = c("WT0", "AGE0"),
strats = "STUD"
)
## get the list of plots
ctr %>% plots
ctr %>% get_plot("custom_res_time")
ctr %>% get_plot("custom_npde_time")
Creates a deep copy of the controller
Description
Creates a deep copy of the controller
Usage
pmx_copy(ctr, keep_globals = FALSE, ...)
Arguments
ctr |
|
keep_globals |
|
... |
extra parameters passed to |
Details
The controller is an 'R6' object, it behaves like a reference object.
Some functions ( methods) can have a side effect on the controller and modify it internally.
Technically speaking we talk about chaining not piping here. However ,
using pmx_copy
user can work on a copy of the controller.
By default the copy does not keep global parameters set using pmx_settings.
Value
an object of pmxClass
Examples
ctr <- theophylline()
cctr <- ctr %>% pmx_copy()
## Any change in the ctr has no side effect in the ctr and vice versa
Select/Map covariates using human labels
Description
Select/Map covariates using human labels
Usage
pmx_cov(values, labels = NULL)
Arguments
values |
|
labels |
|
Details
In case of 'pmx_plot_eta_cats' and 'pmx_plot_eta_conts' you can customize the covariates and covaraites labels using 'pmx_cov'.
Value
pmxCOVObject
object
Creates a density plot object
Description
Creates a density plot object
Usage
pmx_dens(
x,
labels,
dname = NULL,
xlim = 3,
var_line = NULL,
snd_line = NULL,
vline = NULL,
is.legend = TRUE,
...
)
Arguments
x |
|
labels |
list of texts/titles used within the plot |
dname |
name of dataset to be used |
xlim |
|
var_line |
|
snd_line |
|
vline |
|
is.legend |
|
... |
others graphics arguments passed to |
Details
labels is a list that contains:
-
title: plot title default "IWRES density plot"
-
x: x axis label default to "Etas"
-
y: y axis label default to empty
var_line is a list that contains:
-
linetype: default to 1
-
color: default to black
-
linewidth: default to 1
snd_line is a list that contains:
-
linetype: default to 2
-
color: default to black
-
linewidth: default to 1
vline is a list that contains:
-
linetype: default to 3
-
color: default to black
-
linewidth: default to 1
Value
list with options for density plot object
Creates pmx endpoint object
Description
Creates pmx endpoint object
Usage
pmx_endpoint(code, label = "", unit = "", file.code = code, trans = NULL)
Arguments
code |
|
label |
|
unit |
|
file.code |
|
trans |
|
Details
In case of multiple endpoints, pkpd case for example, we need to pass endpoint to the pmx call.
Internally , ggPMX will filter the observations data set to keep only rows satisfying DVID==code
.
The code
is also used to find the right predictions and or fingrid files.
ggPMX use the configuration file to fine the path of the predictions file
(like the single endpoint case) and then filter the right file using the code parameter.
For example:
predictions{code}.txt for mlx16
predictions{code}.txt and y{code}_residual for mlx18
For some tricky examples the code parameter is not enough to find the files. In that case the
file.code
parameter is used to distinguish the endpoint files.
Examples
## Use file.code parameter
pk_pd_path <- file.path(system.file(package = "ggPMX"), "testdata","pk_pd")
WORK_DIR <- file.path(pk_pd_path, "RESULTS")
ep <- pmx_endpoint(
code="4",
file.code="2"
)
input_file <- file.path(pk_pd_path, "pk_pd.csv")
ctr <- pmx_mlx(
config = "standing",
directory = WORK_DIR,
input = input_file,
dv = "dv",
dvid = "dvid",
cats = "sex",
conts = "wt",
endpoint = ep
)
## using mlxtran
ep <- pmx_endpoint(
code="3",
file.code="1"
)
mlxtran_file <- file.path(pk_pd_path, "pk_pd.mlxtran")
ctr <- pmx_mlxtran(mlxtran_file,endpoint=ep)
Generate clean file paths
Description
Wrapper around 'file.path' that cleans trailing forward slash and missing 'dir'.
Usage
pmx_file_path(dir, file)
Arguments
dir |
A string or vector of strings containing the directory path. |
file |
A file name or vector containing the file names. |
Value
A string or vector of string of the full file path.
filter data in a pmx controller
Description
filter data in a pmx controller
Usage
pmx_filter(
ctr,
data_set = c("estimates", "predictions", "eta", "finegrid", "shrink", "input",
"individual", "sim_blq"),
pmx_exp
)
Arguments
ctr |
A controller. An object of 'pmxClass' |
data_set |
A data_set within the controller to apply a filter to. |
pmx_exp |
A filter expression |
Value
Returns a pmx controller with a filtered data set.
Examples
## example of global filter
ctr <- theophylline()
ctr %>% pmx_filter(data_set = "prediction", ID == 5 & TIME < 2)
ctr %>% get_data("prediction")
Get List of built-in configurations
Description
Get List of built-in configurations
Usage
pmx_get_configs(sys = "mlx")
Arguments
sys |
can be mlx, by default all configurations will be listed |
Value
names of the config
Examples
pmx_get_configs()
Get file extension
Description
Extract file extension from the filename string.
Usage
pmx_get_extension(x, dot = TRUE)
Arguments
x |
A string or vector of strings containing the filenames with the extension. |
dot |
Logical, if 'TRUE' the returned value will contain the dot (e.g '.mod') else only the extension itself will be returned (e.g. 'mod'). |
Value
A string or vector of string of the file(s) extension.
Handling pmx Graphical parameters
Description
Handling pmx Graphical parameters
Usage
pmx_gpar(
is.title,
labels,
axis.title,
which_pages,
print,
axis.text,
ranges,
is.smooth,
smooth,
is.band,
band,
is.draft,
draft,
discrete,
is.identity_line,
identity_line,
smooth_with_bloq,
scale_x_log10,
scale_y_log10,
color.scales,
is.legend,
legend.position
)
Arguments
is.title |
|
labels |
list of labels, like title, subtitle, x , y |
axis.title |
list or element_text (same as ggplot2 axis.title theme) |
which_pages |
page(s) to display; if "all" display all pages, if 1 display first page, if c(1,2) display first and second pages |
print |
if TRUE the ouptut will be a print not a ggplot2. This is useful for rmarkdwon output to avoid verbose list index print. |
axis.text |
list or element_text (same as ggplot2 axis.text theme) |
ranges |
limits of x/y ranges |
is.smooth |
logical if set to TRUE add smooth layer |
smooth |
smooth layer parameters |
is.band |
logical if TRUE add horizontal band |
band |
horizontal band parameters |
is.draft |
logical if TRUE add draft layer |
draft |
draft layer parameters |
discrete |
logical if TRUE x axis is discrete(FALSE by default) |
is.identity_line |
|
identity_line |
|
smooth_with_bloq |
|
scale_x_log10 |
logical if TRUE add scale_x_log10 layer |
scale_y_log10 |
logical if TRUE add scale_y_log10 layer |
color.scales |
|
is.legend |
|
legend.position |
|
Details
This object contains all general graphic settings. It used internally by all pmx_plot(generic function) to set the default behavior.
Value
An object of class "pmx_gpar"
.
Index table columns
Description
Index table columns
Usage
pmx_index_table(x)
Arguments
x |
A list containing the tables ('x$data') to be combined along with their respective names ('x$name'). |
Value
A tibble of the index.
Test for nm_table_list class
Description
Reports whether x is a 'nm_table_list' object
Usage
pmx_is.nm.table.list(x)
Arguments
x |
An object to be tested. |
Value
Logical value, 'TRUE' for 'nm_table_list' class and 'FALSE' otherwise.
List NONMEM output tables
Description
List NONMEM output tables file names from a nm_model
object.
Usage
pmx_list_nm_tables(nm_model = NULL)
Arguments
nm_model |
An nm_model object generated with |
See Also
pmx_read_nm_model
, pmx_read_nm_tables
Examples
## Not run:
pmx_read_nm_model(file = 'run001.lst') %>%
pmx_list_nm_tables()
## End(Not run)
Creates an nm_table_list from manually defined table name patterns
Description
Creates an nm_table_list from manually defined table name patterns
Usage
pmx_list_nm_tables_manual(runno = NULL, file = NULL, dir = NULL, tab_list)
Arguments
runno |
Run number to be used to generate model file name. |
file |
Model file name containing the file extension. |
dir |
Location of the model files. |
tab_list |
A list of table definition generated by 'pmx_manual_nm_import'. |
Value
A 'nm_table_list'
Generate extension string
Description
Generate consistent extension strings by adding dot prefix whenever necessary.
Usage
pmx_make_extension(x)
Arguments
x |
A string or vector of strings containing the extension to be standardized. |
Value
A string or vector of strings of extension(s).
Manually define nonmem tables to be imported
Description
Manually provide names of the table files to be imported.
Usage
pmx_manual_nm_import(
tab_names = c("sdtab", "mutab", "patab", "catab", "cotab", "mytab", "extra", "xptab",
"cwtab"),
tab_suffix = "",
sim_suffix = "sim"
)
Arguments
tab_names |
Provide the name of the tables to import e.g. 'sdtab', 'patab', 'cotab', 'catab' for NONMEM. |
tab_suffix |
Default is ”, but can be changed to any character string to be used as suffix in the table names. |
sim_suffix |
Default is 'sim', but can be changed to any character string to be used as suffix in the simulation table names e.g. sdtab001sim. |
Merge firstonly table with full length tables
Description
Merge firstonly table with full length tables
Usage
pmx_merge_firstonly(x, quiet)
Arguments
x |
A list containing the tables ('x$data') to be merged, the firstonly flag ('x$firstonly') and the indexes ('x$index'). |
quiet |
Should messages be displayed to the console. |
Value
A list containing 'data' and 'index' of the merged table.
Message function
Description
Message function with quiet option inspired from 'ronkeizer/vpc'.
Usage
pmx_msg(txt, quiet = TRUE)
Arguments
txt |
A string for the message. |
quiet |
Should messages be displayed to the console. |
Value
Silent when quiet is 'TRUE' or a message is quiet is 'FALSE'.
Creates pmx controller from an nlimxr fit object
Description
Creates pmx controller from an nlimxr fit object
Usage
pmx_nlmixr(fit, dvid, conts, cats, strats, endpoint, settings, vpc = FALSE)
Arguments
fit |
nlmixr object |
dvid |
[Optional] |
conts |
[Optional] |
cats |
[Optional] |
strats |
[Optional] |
endpoint |
|
settings |
[Optional] |
vpc |
[Optional] |
Value
pmxClass
controller object.
Creates pmx controller from NONMEM model outputs
Description
Creates pmx controller from NONMEM model outputs
Usage
pmx_nm(
file = NULL,
directory = ".",
runno = NULL,
ext = ".lst",
table_suffix = "",
sim_suffix = "sim",
simfile = NULL,
prefix = "run",
table_names = c("sdtab", "mutab", "patab", "catab", "cotab", "mytab", "extra", "xptab",
"cwtab"),
dvid = "DVID",
pred = "PRED",
time = "TIME",
dv = "DV",
conts,
cats,
npde,
iwres,
ipred,
endpoint,
strats = "",
settings = pmx_settings(),
vpc = TRUE,
bloq = NULL,
obs = FALSE,
quiet = FALSE
)
Arguments
file |
A character vector of path to the files or a |
directory |
directory of the model files. |
runno |
run number which is used for generating the model file name, or used for alternative import of NONMEM-output tables. |
ext |
Extension to be used to generate model file name. Should be one of'.lst' (default), '.out', '.res', '.mod' or '.ctl' for NONMEM. |
table_suffix |
suffix of the output tables, standard is "" (no suffix). |
sim_suffix |
suffix of the simulation output tables, standard is "sim" (e.g. stdab1sim). |
simfile |
Useful if the simulation is peformed post-hoc and an additional simulation model file is generated e.g. "simulation.lst"; similar to "file" see above. |
prefix |
Prefix to be used to generate model file name. Used in combination with |
table_names |
contains the names of the NONMEM-output tables e.g. "sdtab", "patab", "cotab", "catab". |
dvid |
[Optional] |
pred |
[Optional] |
time |
[Optional] |
dv |
|
conts |
[Optional] |
cats |
[Optional] |
npde |
[Optional] |
iwres |
[Optional] |
ipred |
[Optional] |
endpoint |
[Optional] |
strats |
[Optional] |
settings |
|
vpc |
|
bloq |
|
obs |
|
quiet |
Logical, if |
Value
pmxClass
controller object.
Author(s)
The ggPMX NONMEM reader (pmx_nm) is strongly based on NONMEM reading functions of the xpose package (v.0.4.11) (Thanks to Benjamin Guiastrennec) To avoid conflicts with the xpose package, the necessary xpose-based functions have been renamed with a "pmx_" prefix. If the user wants to use individual functions e.g. "read_nm_tables" please use the xpose-package
Examples
## using only runnumber
# ctr <- pmx_nm(
# directory=model_dir,
# runno = "001"
#)
## using a model file (e.g. run001.lst)
#ctr <- pmx_nm(
# directory=model_dir,
# file = "run001.lst"
#)
## if simulation was performed post-hoc, an additional simulation file can be loaded for VPC
#ctr <- pmx_nm(
# directory=model_dir,
# file = "run001.lst",
# simfile = "simulation.ctl"
#)
## loading with individual table(s)-names
#ctr <- pmx_nm(directory = model_dir,
# runno = 3,
# table_names = "xptab")
Parse NONMEM output files
Description
Function parsing NONMEM output files from their raw input.
Usage
pmx_parse_nm_files(dat, quiet)
Arguments
dat |
A list containing the raw data as vector of strings ('dat$raw') and their respective file names ('dat$name'). |
quiet |
Logical, if |
Value
A tibble containing the parsed 'data' along with 'name', 'problem', 'subprob', and 'method'.
Generic pmx plot
Description
Generic pmx plot
Usage
pmx_plot(ctr, pname, ...)
Arguments
ctr |
|
pname |
plot name |
... |
others graphics parameters passed :
|
Value
ggplot2 object
Generic pmx stratified plot
Description
Generic pmx stratified plot
Usage
pmx_plot_cats(ctr, pname, cats, chunk = "", print = TRUE, ...)
Arguments
ctr |
|
pname |
plot name |
cats |
list of categorical variables. By default all of them |
chunk |
chunk name |
print |
|
... |
others graphics parameters passed :
|
Value
ggplot2 object(s)
Eta matrix plot
Description
Eta matrix plot
Usage
pmx_plot_eta_matrix(
ctr,
title,
dname,
type.eta,
text_color,
is.shrink,
shrink,
point,
is.smooth,
smooth,
is.hline,
hline,
is.vreference_line,
vreference_line,
filter,
strat.facet,
facets,
strat.color,
trans,
pmxgpar,
labels,
axis.title,
axis.text,
ranges,
is.band,
band,
is.draft,
draft,
is.identity_line,
identity_line,
scale_x_log10,
scale_y_log10,
color.scales,
...
)
Arguments
ctr |
pmx controller |
title |
character the plot title |
dname |
name of dataset to be used |
type.eta |
|
text_color |
color of the correlation text in the upper matrix |
is.shrink |
|
shrink |
|
point |
|
is.smooth |
|
smooth |
|
is.hline |
|
hline |
|
is.vreference_line |
|
vreference_line |
pmx_update parameters |
filter |
|
strat.facet |
|
facets |
|
strat.color |
|
trans |
|
pmxgpar |
a object of class pmx_gpar possibly the output of the pmx_gpar: Shared basic graphics parameters |
labels |
|
axis.title |
|
axis.text |
|
ranges |
|
is.band |
|
band |
|
is.draft |
|
draft |
|
is.identity_line |
|
identity_line |
|
scale_x_log10 |
|
scale_y_log10 |
|
color.scales |
|
... |
others graphics parameters passed :
eta_pairs parameters |
Value
ggplot2 object
Examples
# basic use ---------------------------------------
ctr <- theophylline()
p <- ctr %>% pmx_plot_eta_matrix
# update graphical parameter ----------------------
## update labels
ctr %>% pmx_plot_eta_matrix(
labels = list(title = "Eta matrix new title")
)
## remove draft
ctr %>% pmx_plot_eta_matrix(is.draft = FALSE)
## change text color line
ctr %>% pmx_plot_eta_matrix(
text_color="red",
shrink=pmx_shrink(mapping=aes(color="magenta"))
)
## custom point aes and static parameters
## we can customize any geom_point parameter
ctr %>% pmx_plot_eta_matrix(
point = list(color = "blue", shape = 4)
)
# stratification ----------------------------------
## IGNORE continuous stratification
ctr %>% pmx_plot_eta_matrix(strat.color = "WT0")
## IGNORE categorical stratification
ctr %>% pmx_plot_eta_matrix(strat.facet = ~SEX)
# subsetting --------------------------------------
## we can use any expression involving the data
ctr %>% pmx_plot_eta_matrix(filter = EFFECT%in% c("Cl","ka"))
Individual plot
Description
Individual plot
Usage
pmx_plot_individual(
ctr,
which_pages = 1L,
print = FALSE,
dname,
pred_line,
ipred_line,
point,
is.legend,
use.finegrid,
bloq,
filter,
strat.facet,
facets,
strat.color,
trans,
pmxgpar,
labels,
axis.title,
axis.text,
ranges,
is.smooth,
smooth,
is.band,
band,
is.draft,
draft,
is.identity_line,
identity_line,
scale_x_log10,
scale_y_log10,
color.scales,
...
)
Arguments
ctr |
pmx controller |
which_pages |
|
print |
|
dname |
|
pred_line |
|
ipred_line |
|
point |
|
is.legend |
|
use.finegrid |
|
bloq |
pmx_update parameters |
filter |
|
strat.facet |
|
facets |
|
strat.color |
|
trans |
|
pmxgpar |
a object of class pmx_gpar possibly the output of the pmx_gpar: Shared basic graphics parameters |
labels |
|
axis.title |
|
axis.text |
|
ranges |
|
is.smooth |
|
smooth |
|
is.band |
|
band |
|
is.draft |
|
draft |
|
is.identity_line |
|
identity_line |
|
scale_x_log10 |
|
scale_y_log10 |
|
color.scales |
|
... |
others graphics parameters passed :
individual parameters |
Value
ggplot2 or list of ggplot2 objects
Examples
# basic use ---------------------------------------
ctr <- theophylline()
ctr %>% pmx_plot_individual(which_pages = 1)
## multiple pages
ctr %>% pmx_plot_individual(which_pages = c(1, 3))
## change faceting
ctr %>% pmx_plot_individual(facets = list(nrow = 5, ncol = 5), which_pages = 2)
# update graphical parameter ----------------------
## update labels
ctr %>% pmx_plot_individual(
labels = list(title = "Custom individual plot")
)
## remove draft
ctr %>% pmx_plot_individual(is.draft = FALSE)
## Customize ipred_line with any geom_line parameter
ctr %>% pmx_plot_individual(
pred_line = list(color = "red", linetype = 20, alpha = 0.5)
)
## Customize ipred_line with any geom_line parameter
ctr %>% pmx_plot_individual(
ipred_line = list(size = 5)
)
## Customize any geom_point parameter
ctr %>% pmx_plot_individual(
point = list(aes(alpha = DV), color = "green", shape = 4)
)
## legend
p <- ctr %>% pmx_plot_individual(
is.legend=TRUE,
point=list(shape=20),
pred_line=list(linetype=6)
)
# # stratification ----------------------------------
#
# ## continuous stratification
ctr %>% pmx_plot_individual(strat.color = "WT0")
# # subsetting --------------------------------------
#
# ## we can use any expression involving the data
# ## filter and stratify
ctr %>% pmx_plot_individual(
filter = SEX == 1, strat.facet = ~SEX,
facets = list(nrow = 5, ncol = 5))
# # transformation --------------------------------------
#
# ## apply a log transformation in y
ctr %>% pmx_plot_individual(trans = "log10_y")
# ## apply a custonm trsnformation to normalize axis between 0 and 1
## get a list of parameter
p <- ctr %>% pmx_plot_individual(
which_pages="all",
point=list(shape=4,color='blue',size=10),
facets = list(nrow = 5, ncol = 5),
labels = list(title = "My individuals",x='my time',y='PD data')
)
IWRES density plot
Description
IWRES density plot
Usage
pmx_plot_iwres_dens(
ctr,
sim_blq,
dname,
xlim,
var_line,
snd_line,
vline,
filter,
strat.facet,
facets,
strat.color,
trans,
pmxgpar,
labels,
axis.title,
axis.text,
ranges,
is.smooth,
smooth,
is.band,
band,
is.draft,
draft,
is.identity_line,
identity_line,
scale_x_log10,
scale_y_log10,
color.scales,
...
)
Arguments
ctr |
pmx controller |
sim_blq |
|
dname |
|
xlim |
|
var_line |
|
snd_line |
|
vline |
pmx_update parameters |
filter |
|
strat.facet |
|
facets |
|
strat.color |
|
trans |
|
pmxgpar |
a object of class pmx_gpar possibly the output of the pmx_gpar: Shared basic graphics parameters |
labels |
|
axis.title |
|
axis.text |
|
ranges |
|
is.smooth |
|
smooth |
|
is.band |
|
band |
|
is.draft |
|
draft |
|
is.identity_line |
|
identity_line |
|
scale_x_log10 |
|
scale_y_log10 |
|
color.scales |
|
... |
others graphics parameters passed :
pmx_dens parameters |
Value
ggplot2 or list of ggplot2 objects
SAEM Convergence Plot
Description
This plot displays the sequence of estimates for population parameters computed after each iteration of the SAEM algorithm. The purpose is to check the convergence of the algorithm. In addition, a convergence indicator gives the estimation for -2 x log-likelihood along the iterations.
Usage
pmx_plot_saem_convergence(ctr, ...)
Arguments
ctr |
|
... |
additional parameters (not used). |
Value
A ggplot
object showing SAEM convergence plot.
VPC plot
Description
VPC plot
Usage
pmx_plot_vpc(
ctr,
type,
idv,
obs,
pi,
ci,
rug,
bin,
is.legend,
sim_blq,
dname,
filter,
strat.facet,
facets,
strat.color,
trans,
pmxgpar,
labels,
axis.title,
axis.text,
ranges,
is.smooth,
smooth,
is.band,
band,
is.draft,
draft,
is.identity_line,
identity_line,
scale_x_log10,
scale_y_log10,
color.scales,
is.footnote,
...
)
Arguments
ctr |
pmx controller |
type |
|
idv |
|
obs |
|
pi |
|
ci |
|
rug |
|
bin |
|
is.legend |
|
sim_blq |
|
dname |
added for compatibility with other ggPMX plots pmx_update parameters |
filter |
|
strat.facet |
|
facets |
|
strat.color |
|
trans |
|
pmxgpar |
a object of class pmx_gpar possibly the output of the pmx_gpar: Shared basic graphics parameters |
labels |
|
axis.title |
|
axis.text |
|
ranges |
|
is.smooth |
|
smooth |
|
is.band |
|
band |
|
is.draft |
|
draft |
|
is.identity_line |
|
identity_line |
|
scale_x_log10 |
|
scale_y_log10 |
|
color.scales |
|
is.footnote |
|
... |
others graphics parameters passed :
pmx_vpc parameters |
Details
You can use pmx_vpc_bin to set the bin parameters. In case of stratification,
binning can be different for each strat level (case within_strat
equal to FALSE).
Value
ggplot2 or list of ggplot2 objects
See Also
Other vpc:
pmx_vpc()
,
pmx_vpc_bin()
,
pmx_vpc_ci()
,
pmx_vpc_obs()
,
pmx_vpc_pi()
,
pmx_vpc_rug()
Examples
library(ggPMX)
theo_path <- file.path(
system.file(package = "ggPMX"), "testdata",
"theophylline"
)
WORK_DIR <- file.path(theo_path, "Monolix")
input_file <- file.path(theo_path, "data_pk.csv")
vpc_file <- file.path(theo_path, "sim.csv")
ctr <- pmx_mlx(
config = "standing",
directory = WORK_DIR,
input = input_file,
dv = "Y",
dvid = "dvid",
cats = c("SEX"),
conts = c("WT0", "AGE0"),
strats = "STUD",
settings = pmx_settings(
use.labels=TRUE,
cats.labels=list(
SEX=c("0"="Male","1"="Female")
)
),
sim = pmx_sim(
file = vpc_file,
irun ="rep",
idv="TIME"
)
)
ctr %>% pmx_plot_vpc(
strat.facet=~SEX,
facets=list(nrow=2),
type="percentile",
is.draft = FALSE,
pi = pmx_vpc_pi(interval = c(0.1,0.9),
median=list(color="green"),
extreme= list(color="green")),
obs = pmx_vpc_obs(color="blue",shape=18,size=2),
ci = pmx_vpc_ci(interval = c(0.1,0.9),
median=list(fill="pink")),
bin=pmx_vpc_bin("kmeans",n=5)
)
ctr %>%
pmx_plot_vpc(bin= pmx_vpc_bin(
style = "fixed",
fixedBreaks=c(-10,2, 5, 10,15,50))
)
# example with legend
ctr %>% pmx_plot_vpc(
is.legend = TRUE,
pi = pmx_vpc_pi(interval=c(0.02,0.98),median = list(linetype="dotted")),
ci = pmx_vpc_ci(interval = c(0.05,0.95),median=list(fill="red"))
)
This function creates a qq plot object
Description
This function creates a qq plot object
Usage
pmx_qq(
x,
labels,
dname = NULL,
point = NULL,
xmax = TRUE,
facets = NULL,
is.reference_line = NULL,
reference_line = NULL,
is.shrink = NULL,
shrink = NULL,
is.hline = NULL,
hline = NULL,
is.vline = NULL,
vline = NULL,
...
)
Arguments
x |
|
labels |
list of texts/titles used within the plot |
dname |
name of dataset to be used |
point |
|
xmax |
|
facets |
|
is.reference_line |
|
reference_line |
|
is.shrink |
|
shrink |
|
is.hline |
logical if TRUE add horizontal line y=0 ( TRUE by default) |
hline |
geom hline graphical parameters |
is.vline |
logical if TRUE add vertical line x=0 ( TRUE by default) |
vline |
geom vline graphical parameters |
... |
others graphics arguments passed to |
Details
labels is a list that contains:
-
title: plot title default "EBE vs. covariates"
-
x: x axis label default to "Etas"
-
y: y axis label default to empty
point is a list that contains:
-
shape: default to 1
-
color: default to black
-
size: default to 1
Value
pmx_qq
object
Quantile-quantile plots
Description
Quantile-quantile plots
Quantile-quantile plot of IWRES
Quantile-quantile plot of eta variables
Quantile-quantile plot of NPDE
Quantile-quantile plot of NPD
Quantile-quantile plot of CWRES
Usage
pmx_qq_plot(
dname,
point,
is.reference_line,
reference_line,
is.shrink,
shrink,
is.hline,
hline,
is.vline,
vline,
filter,
strat.facet,
facets,
strat.color,
trans,
pmxgpar,
labels,
axis.title,
axis.text,
ranges,
is.smooth,
smooth,
is.band,
band,
is.draft,
draft,
is.identity_line,
identity_line,
scale_x_log10,
scale_y_log10,
color.scales,
...
)
pmx_plot_iwres_qq(ctr, ...)
pmx_plot_eta_qq(ctr, ...)
pmx_plot_npde_qq(ctr, ...)
pmx_plot_npd_qq(ctr, ...)
pmx_plot_cwres_qq(ctr, ...)
Arguments
dname |
name of dataset to be used |
point |
|
is.reference_line |
|
reference_line |
|
is.shrink |
|
shrink |
|
is.hline |
|
hline |
|
is.vline |
|
vline |
pmx_update parameters |
filter |
|
strat.facet |
|
facets |
|
strat.color |
|
trans |
|
pmxgpar |
an object of class pmx_gpar |
labels |
|
axis.title |
|
axis.text |
|
ranges |
|
is.smooth |
|
smooth |
|
is.band |
|
band |
|
is.draft |
|
draft |
|
is.identity_line |
|
identity_line |
|
scale_x_log10 |
|
scale_y_log10 |
|
color.scales |
|
... |
others graphics parameters passed :
pmx_qq parameters |
ctr |
pmx controller |
Value
ggplot2 object
Examples
# *************** basic use ***************** ------
ctr <- theophylline()
ctr %>% pmx_plot_eta_qq
ctr %>% pmx_plot_npde_qq
ctr %>% pmx_plot_iwres_qq
# update graphical parameter ----------------------
## add reference line
ctr %>% pmx_plot_npde_qq(reference_line=list(color="blue"))
## remove reference line
ctr %>% pmx_plot_eta_qq(reference_line=NULL)
# stratification ----------------------------------
## categorical stratification color parameter
ctr %>% pmx_plot_iwres_qq(strat.facet=~STUD,strat.color="SEX")
## categorical stratification facetting
ctr %>% pmx_plot_eta_qq(strat.facet = ~SEX)
## do not use symmetric axis
ctr %>% pmx_plot_npde_qq(xmax=FALSE,reference_line=list())
Convert raw strings to tibble
Description
Convert raw data strings to a tibble format.
Usage
pmx_raw_to_tibble(x, sep, file)
Arguments
x |
A list containing the raw data as vector of strings ('x$raw'). |
sep |
A separator which will be used to create columns. |
file |
The name of the file to be parsed. |
Value
A tibble.
Define data import arguments
Description
Define data import arguments
Usage
pmx_read_args(
x,
quiet,
col_types = readr::cols(.default = "d"),
na = "NA",
comment = "TABLE",
skip = 1,
...
)
Arguments
x |
A list containing a the 3 first records of a dataset under '[[1]]'. |
quiet |
Should messages be displayed to the console. |
col_types |
Defines the type of each column to be passed to the 'readr' import function. |
na |
Character string defining the values to be treated as 'NA'. |
comment |
Character string defining the value to mark comments. |
skip |
Number of rows to be skipped before reading the data. |
... |
Additional arguments to be passed to the 'readr' function |
Value
A list of 2 levels fun (the import function) and params (a list of arguments to be used when calling fun).
Define data import functions
Description
Define data import functions
Usage
pmx_read_funs(fun)
Arguments
fun |
Abbreviated 'readr' data import function. Can be 'csv', 'csv2' or 'table'. |
Value
A data import function.
NONMEM output file import function
Description
Quickly import NONMEM output files into R.
Usage
pmx_read_nm_files(
runno = NULL,
prefix = "run",
ext = c(".ext", ".cor", ".cov", ".phi", ".grd", ".shk"),
file = NULL,
dir = NULL,
quiet = FALSE
)
Arguments
runno |
Run number to be evaluated. |
prefix |
Prefix of the model file names. |
ext |
A vector of the file extension to import. By default '.ext', '.cor', '.cov', '.phi', '.grd', '.shk' files are listed. |
file |
Names of the model output file to be imported. Alternative argument to |
dir |
Location of the model files. |
quiet |
Logical, if |
Examples
## Not run:
# Using the `file` argument to import a model file:
ext_file <- pmx_read_nm_files(file = 'run001.ext', dir = 'models')
# Using the `runno` argument to import a model file:
ext_file <- pmx_read_nm_files(runno = '001', ext = '.ext', dir = 'models')
## End(Not run)
NONMEM model file parser
Description
Parse NONMEM model files in R format
Usage
pmx_read_nm_model(
runno = NULL,
prefix = "run",
ext = ".lst",
file = NULL,
dir = NULL
)
Arguments
runno |
run number which is used for generating the model file name |
prefix |
Prefix to be used to generate model file name. Used in combination with |
ext |
Extension to be used to generate model file name. Should be one of'.lst' (default), '.out', '.res', '.mod' or '.ctl' for NONMEM. |
file |
A character vector of path to the files or a |
dir |
directory of the model files. |
Value
A tibble
of class model
containing the following columns:
-
problem: a numeric identifier for the $PROBLEM associated with the code.
-
level: a unique numeric identifier to each subroutine block associated with the code.
-
subroutine: a character identifier named after the 3 first letters of the subroutine name e.g. '$THETA' and '$TABLE' will become 'the' and 'tab' respectively. In addition all output from the .lst is labeled 'lst', the general nonmem output e.g. NM-TRAN messages are labelled 'oth'. With priors thp, tpv, omp, opd, sip, spd abbreviations are given to the THETAP, THETAPV, OMEGAP, etc.
-
code: the code without comments or subroutine names e.g. '$THETA 0.5 ; TVCL' will return '0.5'.
-
comment: the last comment of a record e.g. '0.5 ; Clearance (L/h) ; TVCL' will return 'TVCL'.
See Also
Examples
## Not run:
# Using the `file` argument to import a model file:
nm_model <- pmx_read_nm_model(file = 'run001.lst', dir = 'models')
# Using the `runno` argument to import a model file:
nm_model <- pmx_read_nm_model(runno = '001', ext = '.lst', dir = 'models')
## End(Not run)
NONMEM output table import function
Description
Quickly import NONMEM output tables into R. This function automatically detects the optimal settings to import the tables from nonmem. It is based on the read_nm_tables function of xpose. Slight adjustment were made for purposes of pmx_nm()
Usage
pmx_read_nm_tables(
file = NULL,
dir = NULL,
combined = TRUE,
rm_duplicates = TRUE,
quiet = FALSE,
simtab = NULL,
ziptab = TRUE,
user_mode = TRUE,
...
)
Arguments
file |
A character vector of path to the files or a |
dir |
Location of the model files. |
combined |
Logical value indicating whether multiple tables should be combined into a single one. If the number of rows does not match an error will be returned. |
rm_duplicates |
Logical value indicating whether duplicated columns should be removed. |
quiet |
Logical, if |
simtab |
If |
ziptab |
If |
user_mode |
Adjustment to the original code: usermode is set to "usermode = TRUE" in order to improve this function for purposes of pmx_nm() (nonmem_reader.R), In order to use this function seperatly, the use of the original function in the xpose package is advised. |
... |
Additional arguments to be passed to the |
Table format requirement
When using pmx_read_nm_tables
with the combined
argument set to FALSE
an ID
column
must be present in all data tables. When combined
is set to TRUE
instead an ID
column must be
present in at least one table for each problem and for each 'firstonly' category. ID
columns are required
to properly combine/merge tables and removing NA
records. If the ID
column is missing from a table and
combined = FALSE
pmx_read_nm_tables
will return the following warning: Unknown variables: `ID`
. While
the data is returned beware that NA
records might be left in the data and the output should be checked carefully.
If combined = TRUE
pmx_read_nm_tables
is more strict and will return the following warning instead:
Dropped `<tablenames>` due to missing required `ID` column.
.
Examples
## Not run:
# Adjustment to the original code: usermode is set to "usermode = TRUE"
# in order to improve this function for purposes of pmx_nm() (nonmem_reader.R)
# In order to use this function seperatly, the use of the original function in
# the xpose package is advised.
# Import tables manually and return them as a list of individual tables
nm_tables <- pmx_read_nm_tables(file = c('sdtab001', 'patab001'),
dir = 'models', combined = FALSE)
# Import tables manually and return them as a single merged table
nm_tables <- pmx_read_nm_tables(file = c('sdtab001', 'patab001'),
dir = 'models', combined = TRUE)
## End(Not run)
Register plot (Jun2025, Alex: I believe it doesn't work at all)
Description
Register plot (Jun2025, Alex: I believe it doesn't work at all)
Usage
pmx_register_plot(ctr, pp, pname = NULL)
Arguments
ctr |
|
pp |
|
pname |
|
Generates ggpmX report from a pre-defined template
Description
Generates ggpmX report from a pre-defined template
Usage
pmx_report(
contr,
name,
save_dir,
plots_subdir = "ggpmx_GOF",
output = c("all", "plots", "report"),
template = "standing",
footnote = output == "all",
edit = FALSE,
format = NULL,
title,
...
)
Arguments
contr |
|
name |
|
save_dir |
Output directory. A directory to write the results files to |
plots_subdir |
Output folder name, ggpmx_GOF by default |
output |
|
template |
|
footnote |
|
edit |
|
format |
|
title |
|
... |
extra parameters depending in the template used |
Details
pmx_report
uses pre-defined template .Rmd to generate the report.
The idea is to pass the controller as a report argument using knitr params
artifact.
Examples
library(ggPMX)
# you probably want to create the report in your own directory
# But using a temp directory allows for easy cleanup
## case1: generate a single report
withr::with_tempdir({
ctr <- theophylline()
ctr %>% pmx_report(
name = "my_report",
save_dir = getwd(),
output="report"
)
})
## case2: generate standalone plots
withr::with_tempdir({
ctr <- theophylline()
ctr %>% pmx_report(
name = "my_report",
save_dir = getwd(),
output="plots"
)
})
## case3: generate both : reports + plots
## by default add footnote
## Note, you can force footnote to FALSE using footnote parameter
withr::with_tempdir({
ctr <- theophylline()
ctr %>% pmx_report(
name="my_report",
save_dir=getwd(),
output="all"
)
})
## case4 : generate standalone plots with footnotes
withr::with_tempdir({
ctr <- theophylline()
ctr %>% pmx_report(
name="my_report",
save_dir=getwd(),
footnote=TRUE,
output="plots"
)
})
## case6: dynamic edit
## uncomment to run
# ctr <- theophylline()
# ctr %>% pmx_report(
# save_dir = file.path(getwd(),"case6"),
# name="my_report",
# output="report",
# edit = TRUE)
## case7 : generate individual plots report
## ctr <- theophylline()
## ctr %>% pmx_report(
## name="report2",
## save_dir = getwd(),
## template="individual",
## format="all",
## which_pages=1:2
## )
Gets build-in report templates
Description
Gets build-in report templates
Usage
pmx_report_template()
Value
list of templates names
Examples
pmx_report_template()
Create controller global settings
Description
Create controller global settings
Usage
pmx_settings(
is.draft = TRUE,
use.abbrev = TRUE,
color.scales = NULL,
cats.labels = NULL,
use.labels = FALSE,
use.titles = FALSE,
effects = NULL,
...
)
Arguments
is.draft |
|
use.abbrev |
|
color.scales |
|
cats.labels |
|
use.labels |
|
use.titles |
|
effects |
|
... |
extra parameter not used yet |
Value
pmxSettingsClass object
Examples
library(ggPMX)
library(ggplot2)
ctr <- theophylline(
settings=
pmx_settings(
color.scales=list(
"Study",
labels=c("Study 1","Study 2"),
values=c("1"="lightyellow","2"="lightblue")),
cats.labels=list(
SEX=c("0"="M","1"="F"),
STUD=c("1"="Study 1","2"="Study 2")
),
use.abbrev=TRUE,
is.draft=TRUE,
use.labels=TRUE
)
)
ctr %>%
pmx_plot_npde_time(strat.color="STUD",strat.facet=~SEX)
#
#
ctr %>%
pmx_plot_eta_box(strat.color="STUD", strat.facet =~SEX)
ctr %>% pmx_plot_eta_hist
Create shrinkage parameter object
Description
Create shrinkage parameter object
Usage
pmx_shrink(
fun = c("var", "sd"),
size = 1,
color = "green",
vjust = 1.5,
hjust = 0.5,
...
)
Arguments
fun |
|
size |
|
color |
|
vjust |
|
hjust |
|
... |
any other parameter |
Value
pmxShrinkClass
object (list
)
Create simulation object
Description
Create simulation object
Usage
pmx_sim(file, data, irun, idv)
Arguments
file |
|
data |
|
irun |
|
idv |
|
Examples
library(ggPMX)
theo_path <- file.path(
system.file(package = "ggPMX"), "testdata",
"theophylline"
)
WORK_DIR <- file.path(theo_path, "Monolix")
input_file <- file.path(theo_path, "data_pk.csv")
vpc_file <- file.path(theo_path, "sim.csv")
ctr <- pmx_mlx(
config = "standing",
directory = WORK_DIR,
input = input_file,
dv = "Y",
dvid = "dvid",
cats = c("SEX"),
conts = c("WT0", "AGE0"),
strats = "STUD",
settings = pmx_settings(
use.labels=TRUE,
cats.labels=list(
SEX=c("0"="Male","1"="Female")
)
),
sim = pmx_sim(
file = vpc_file,
irun ="rep",
idv="TIME"
)
)
ctr %>% pmx_plot_vpc(
strat.facet=~SEX,
facets=list(nrow=2),
type="percentile",
is.draft = FALSE,
pi = pmx_vpc_pi(interval = c(0.1,0.9),
median=list(color="green"),
extreme= list(color="green")),
obs = pmx_vpc_obs(color="blue",shape=18,size=2),
ci = pmx_vpc_ci(interval = c(0.1,0.9),
median=list(fill="pink")),
bin=pmx_vpc_bin("kmeans",n=5)
)
ctr %>%
pmx_plot_vpc(bin= pmx_vpc_bin(
style = "fixed",
fixedBreaks=c(-10,2, 5, 10,15,50))
)
# example with legend
ctr %>% pmx_plot_vpc(
is.legend = TRUE,
pi = pmx_vpc_pi(interval=c(0.02,0.98),median = list(linetype="dotted")),
ci = pmx_vpc_ci(interval = c(0.05,0.95),median=list(fill="red"))
)
Define ggPMX theme
Description
This theme is a simple wrapper gdoc theme from ggthems package.
Usage
pmx_theme(...)
Arguments
... |
can contain any valid argument of |
Value
ggplot2 theme object
Check tidyr version
Description
Check the version of tidyr to handle the gap between v0.8.3 and v1.0.0
Usage
pmx_tidyr_new_interface()
Value
the package version of tidyr
Update plot object
Description
Update plot object
Usage
pmx_update(
ctr,
pname,
strat.color = NULL,
strat.facet = NULL,
color.scales = NULL,
filter = NULL,
trans = NULL,
...,
pmxgpar = NULL
)
Arguments
ctr |
|
pname |
character the plot name to update |
strat.color |
|
strat.facet |
|
color.scales |
|
filter |
optional filter which will be applied to plotting data |
trans |
|
... |
others graphical parameters given to set the plot |
pmxgpar |
a object of class pmx_gpar possibly the output of the |
Details
trans is a transformation that user can apply to x, or y coordinates. The transformation is applied to the data before the plotting. This gives more felxiblilty to the user and also conserves all static positions like annotations ( draft specially)
For example:
var_x apply variance to x coordinates the variance function
var_xy apply variance to both This mechanism is applied internally to scale log.
Value
controller object with the plot updated
See Also
Other pmxclass:
get_cats()
,
get_conts()
,
get_covariates()
,
get_data()
,
get_occ()
,
get_plot()
,
get_plot_config()
,
get_strats()
,
plot_names()
,
plots()
,
set_data()
,
set_plot()
Update file extension
Description
Change the extension of a file.
Usage
pmx_update_extension(x, ext)
Arguments
x |
A string or vector of strings containing the file name to be modified. |
ext |
A string or vector of strings containing the name of the new extension(s). |
Value
A string or vector of strings of file name(s).
Creates vpc object
Description
Creates vpc object
Usage
pmx_vpc(
type = c("percentile", "scatter"),
idv = "TIME",
obs = pmx_vpc_obs(),
pi = pmx_vpc_pi(),
ci = pmx_vpc_ci(),
rug = pmx_vpc_rug(),
bin = pmx_vpc_bin(),
labels = NULL,
facets = NULL,
is.legend = TRUE,
is.footnote = TRUE,
dname = NULL,
...
)
Arguments
type |
|
idv |
|
obs |
|
pi |
|
ci |
|
rug |
|
bin |
|
labels |
|
facets |
is a list of parameters passed to facet_wrap in case of startification |
is.legend |
|
is.footnote |
|
dname |
added for compatibility with other ggPMX plots |
... |
extra parameters passed to base graphical parameters |
Value
list with parameters of the vpc object
See Also
Other vpc:
pmx_plot_vpc()
,
pmx_vpc_bin()
,
pmx_vpc_ci()
,
pmx_vpc_obs()
,
pmx_vpc_pi()
,
pmx_vpc_rug()
Creates vpc bins
Description
Creates vpc bins
Usage
pmx_vpc_bin(style, within_strat = TRUE, seed = 42, ...)
Arguments
style |
|
within_strat |
|
seed |
|
... |
other classInt::classIntervals parameters excpet |
Details
This is a wrapper to the bin based VPC
Value
list with options for 'pmx_vpc_bin' object
See Also
Other vpc:
pmx_plot_vpc()
,
pmx_vpc()
,
pmx_vpc_ci()
,
pmx_vpc_obs()
,
pmx_vpc_pi()
,
pmx_vpc_rug()
Sets vpc confidence interval layer
Description
Sets vpc confidence interval layer
Usage
pmx_vpc_ci(
show = c("all", "median"),
interval = c(0.025, 0.975),
method = c("ribbon", "rectangle"),
median = list(fill = "red", alpha = 0.3),
extreme = list(fill = "#3388cc", alpha = 0.3)
)
Arguments
show |
|
interval |
|
method |
|
median |
|
extreme |
|
Value
list with options for Confidence Interval layer
See Also
Other vpc:
pmx_plot_vpc()
,
pmx_vpc()
,
pmx_vpc_bin()
,
pmx_vpc_obs()
,
pmx_vpc_pi()
,
pmx_vpc_rug()
Sets vpc observation layer
Description
Sets vpc observation layer
Usage
pmx_vpc_obs(show = TRUE, color = "#000000", size = 1, alpha = 0.7, shape = 1)
Arguments
show |
|
color |
|
size |
|
alpha |
|
shape |
|
Value
list with options for ggplot2 layer with observations
See Also
Other vpc:
pmx_plot_vpc()
,
pmx_vpc()
,
pmx_vpc_bin()
,
pmx_vpc_ci()
,
pmx_vpc_pi()
,
pmx_vpc_rug()
Sets vpc percentile layer
Description
Sets vpc percentile layer
Usage
pmx_vpc_pi(
show = c("all", "median", "area"),
interval = c(0.05, 0.95),
median = list(color = "#000000", linewidth = 1, alpha = 0.7, linetype = "solid"),
extreme = list(color = "#000000", linewidth = 1, alpha = 0.7, linetype = "dashed"),
area = list(fill = "blue", alpha = 0.1)
)
Arguments
show |
|
interval |
|
median |
|
extreme |
|
area |
|
Value
list with options for Prediction Interval layer
See Also
Other vpc:
pmx_plot_vpc()
,
pmx_vpc()
,
pmx_vpc_bin()
,
pmx_vpc_ci()
,
pmx_vpc_obs()
,
pmx_vpc_rug()
Sets vpc rug layer
Description
Sets vpc rug layer
Usage
pmx_vpc_rug(show = TRUE, color = "#000000", linewidth = 1, alpha = 0.7, size)
Arguments
show |
|
color |
|
linewidth |
|
alpha |
|
size |
|
Details
When the vpc confidence interval layer method is rectangles we don't show rug separators.
Value
list with options for the rug layer
See Also
Other vpc:
pmx_plot_vpc()
,
pmx_vpc()
,
pmx_vpc_bin()
,
pmx_vpc_ci()
,
pmx_vpc_obs()
,
pmx_vpc_pi()
S3 print abbreviation
Description
S3 print abbreviation
Usage
## S3 method for class 'abbreviation'
print(x, ...)
Arguments
x |
object of class configs |
... |
pass additional options (not used presently) |
Value
print abbreviation
This function can be used to print configuration of the defined object using S3 method.
Description
This function can be used to print configuration of the defined object using S3 method.
Usage
## S3 method for class 'configs'
print(x, ...)
Arguments
x |
object of class configs |
... |
pass additional options (not used presently) |
Value
print result
Print pmxClass object
Description
Print pmxClass object
Usage
## S3 method for class 'pmxClass'
print(x, ...)
Arguments
x |
pmxClass object |
... |
additinal arguments to pass to print |
Value
print object to screen
S3 method print pmxConfig object
Description
S3 method print pmxConfig object
Usage
## S3 method for class 'pmxConfig'
print(x, ...)
Arguments
x |
pmxConfig object |
... |
addtional arguments to pass to print (unused currently) |
Value
invisible object
Print pmx_gpar object
Description
Print pmx_gpar object
Usage
## S3 method for class 'pmx_gpar'
print(x, ...)
Arguments
x |
pmx_gpar object |
... |
argument passed to print ( to satisfy generic) |
Value
a character description of graphical parameters
Reads .ext files generated by NONMEM
Description
Reads .ext files generated by NONMEM
Usage
read_extfile(
run = NA_real_,
project = getwd(),
file = paste0(run, ".ext"),
path = NULL,
read_fun = c("data.table", "read.table"),
quiet
)
Arguments
run |
run a run number or run identifier |
project |
project the NONMEM project directory |
file |
file the 'ext' file name |
path |
path full path and file name for 'ext' file |
read_fun |
read_fun function to read the 'ext' file |
quiet |
Logical, if |
Value
A list with param, omega, and sigma in a format ready to be used.
Author(s)
This function is based on read_nmext from mrgsolve, Original Author: Kyle T Baron. This function has some changes to the original code: Addition of param, "quiet", (option of pmx_msg function, from xpose package) (Line: 27) The code was slightly adjusted to check for multiple tables and also extract SE (ITERATION == 1000000001) (Line: 44-58, Line: 86-96, respectively) The output was also slightly adjusted to fit ggPMX output (df and df2) (Line: 105,106) as_bmat was replaced by bmat_like to create the diagonal matrix (Line 116:142)
Examples
#project <- system.file("nonmem", package = "mrgsolve")
#est <- read_nmext(1005, project = project)
Read Modelling input data
Description
Read Modelling input data
Usage
read_input(
ipath,
dv,
dvid,
cats = "",
conts = "",
strats = "",
occ = "",
endpoint = NULL,
id = NULL,
time = NULL
)
Arguments
ipath |
full path of the input file |
dv |
|
dvid |
|
cats |
[Optional] |
conts |
[Optional] |
strats |
[Optional] |
occ |
[Optional] |
endpoint |
|
id |
|
time |
|
Value
data.table well formatted containing modelling input data
Read MONOLIX individual parameters
Description
Read MONOLIX individual parameters
Usage
read_mlx_ind_est(path, x, ...)
Arguments
path |
character path to the file |
x |
dataset object |
... |
extra parameter not used |
Value
data.table object
Read MONOLIX parameter estimation file
Description
Read MONOLIX parameter estimation file
Usage
read_mlx_par_est(path, x, ...)
Arguments
path |
character path to the file |
x |
dataset object |
... |
extra parameter not used |
Value
data.table object
Read MONOLIX model predictions
Description
Read MONOLIX model predictions
Usage
read_mlx_pred(path, x, ...)
Arguments
path |
character path to the file |
x |
dataset object |
... |
extra parameter not used |
Value
data.table object
Read MONOLIX SAEM convergence file
Description
Read MONOLIX SAEM convergence file
Usage
read_mlx_saem_conv(path, ...)
Arguments
path |
string specifying data path folder |
... |
extra parameter not used |
Value
data.table object
Objects exported from other packages
Description
These objects are imported from other packages. Follow the links below to see their documentation.
- magrittr
This function create a residual for each observed value and also generates a residual distribution
Description
This function create a residual for each observed value and also generates a residual distribution
Usage
residual(
x,
y,
labels = NULL,
point = NULL,
is.hline = FALSE,
hline = NULL,
dname = NULL,
facets = NULL,
bloq = NULL,
square_plot = TRUE,
...
)
Arguments
x |
x axis aesthetics |
y |
y axis aesthetics |
labels |
list that contain title,subtitle, axis labels |
point |
geom point graphical parameters |
is.hline |
logical if TRUE add horizontal line y=0 ( TRUE by default) |
hline |
geom hline graphical parameters |
dname |
name of dataset to be used |
facets |
|
bloq |
|
square_plot |
square dv_pred plot (TRUE by default) |
... |
others graphics arguments passed to |
Details
Some parameters are a list of parameters :
point is a list that contains:
-
shape: default to 1
-
color: default to black
-
size: default to 1
labels is a list that contains:
-
title: plot title default to AES_X versus AES_Y
-
subtitle: plot subtitle default empty
-
x: x axis label default to AES_X
-
y: y axis label default to AES_Y
Value
a residual object
See Also
Scatter residual plots
Description
Scatter residual plots
DV vs PRED plot
DV vs IPRED plot
IWRES vs IPRED plot
|IWRES| vs IPRED plot
|IWRES| vs TIME plot
IWRES vs TIME plot
NPDE vs TIME plot
NPDE vs PRED plot
NPD vs TIME plot
NPD vs EPRED plot
NPD vs PRED plot
CWRES vs TIME plot
CWRES vs CPRED plot
CWRES vs PRED plot
Usage
residual_scatter(
sim_blq,
point,
is.hline,
hline,
dname,
bloq,
filter,
strat.facet,
facets,
strat.color,
trans,
pmxgpar,
labels,
axis.title,
axis.text,
ranges,
is.smooth,
smooth,
is.band,
band,
is.draft,
draft,
is.identity_line,
identity_line,
scale_x_log10,
scale_y_log10,
color.scales,
...
)
pmx_plot_dv_pred(ctr, ...)
pmx_plot_dv_ipred(ctr, ...)
pmx_plot_iwres_ipred(ctr, ...)
pmx_plot_abs_iwres_ipred(ctr, ...)
pmx_plot_abs_iwres_time(ctr, ...)
pmx_plot_iwres_time(ctr, ...)
pmx_plot_npde_time(ctr, ...)
pmx_plot_npde_pred(ctr, ...)
pmx_plot_npd_time(ctr, ...)
pmx_plot_npd_epred(ctr, ...)
pmx_plot_npd_pred(ctr, ...)
pmx_plot_cwres_time(ctr, ...)
pmx_plot_cwres_cpred(ctr, ...)
pmx_plot_cwres_pred(ctr, ...)
Arguments
sim_blq |
|
point |
|
is.hline |
|
hline |
|
dname |
|
bloq |
pmx_update parameters |
filter |
|
strat.facet |
|
facets |
|
strat.color |
|
trans |
|
pmxgpar |
a object of class pmx_gpar possibly the output of the pmx_gpar: Shared basic graphics parameters |
labels |
|
axis.title |
|
axis.text |
|
ranges |
|
is.smooth |
|
smooth |
|
is.band |
|
band |
|
is.draft |
|
draft |
|
is.identity_line |
|
identity_line |
|
scale_x_log10 |
|
scale_y_log10 |
|
color.scales |
|
... |
others graphics parameters passed :
residual parameters |
ctr |
pmx controller |
Value
ggplot2 object
Examples
# NOTES ######################
# examples are availables for all residual plots:
# - pmx_plot_abs_iwres_ipred
# - pmx_plot_dv_ipred
# - pmx_plot_dv_pred
# - pmx_plot_iwres_ipred
# - pmx_plot_iwres_time
# - pmx_plot_npde_time
# basic use ---------------------------------------
ctr <- theophylline()
p <- ctr %>% pmx_plot_dv_pred()
## p is a ggplot2 object you can add any layer here
p + ggplot2::theme_minimal()
# update graphical parameter ----------------------
## update labels
ctr %>% pmx_plot_dv_pred(
labels = list(title = "DV versus PRED new title")
)
## remove draft
ctr %>% pmx_plot_dv_pred(is.draft = FALSE)
## remove horizontal line
ctr %>% pmx_plot_dv_pred(is.hline = FALSE)
## custom point aes and static parameters
## we can customize any geom_point parameter
ctr %>% pmx_plot_dv_pred(
point = list(aes(alpha = DV), color = "green", shape = 4)
)
# stratification ----------------------------------
## continuous stratification
ctr %>% pmx_plot_dv_pred(strat.color = ~WT0)
## categorical stratification
ctr %>% pmx_plot_dv_pred(strat.facet = ~SEX)
## using formula notation
ctr %>% pmx_plot_dv_pred(strat.facet = STUD~SEX)
# subsetting --------------------------------------
## we can use any expression involving the data
ctr %>% pmx_plot_dv_pred(filter = DV > mean(DV) & PRED < median(PRED))
## filter and stratify
ctr %>% pmx_plot_dv_pred(filter = SEX == 1, strat.facet = ~SEX)
# transformation --------------------------------------
## apply a log transformation in y
ctr %>% pmx_plot_dv_pred(trans = "log10_y")
update or add a new abbreviation
Description
update or add a new abbreviation
Usage
set_abbrev(ctr, ...)
Arguments
ctr |
|
... |
Options to set or add, with the form |
Examples
ctr <- theophylline()
ctr %>% set_abbrev("new_param" = "new value")
ctr %>% get_abbrev("new_param")
Set a controller data set
Description
Set a controller data set
Usage
set_data(ctr, ..., envir = parent.frame())
Arguments
ctr |
the controller object |
... |
a named list parameters (see example) |
envir |
the |
Details
This function can be used to set an existing data set or to create a new one. The basic idea is to change the built-in data set (change the factor level names, change some rows values or apply any other data set operation) and use the new data set using the dname parameter of pmx_plot family functions.
See Also
Other pmxclass:
get_cats()
,
get_conts()
,
get_covariates()
,
get_data()
,
get_occ()
,
get_plot()
,
get_plot_config()
,
get_strats()
,
plot_names()
,
plots()
,
pmx_update()
,
set_plot()
Examples
ctr <- theophylline()
dx <- ctr %>% get_data("eta")
dx <- dx[, EFFECT := factor(
EFFECT,
levels = c("ka", "V", "Cl"),
labels = c("Concentration", "Volume", "Clearance")
)]
## update existing data set
ctr %>% set_data(eta = dx)
## or create a new data set
ctr %>% set_data(eta_long = dx)
Create a new plot of the desired type
Description
Create a new plot of the desired type
Usage
set_plot(
ctr,
ptype = c("IND", "DIS", "SCATTER", "ETA_PAIRS", "ETA_COV", "PMX_QQ", "VPC", "PMX_DENS",
"PARAM_HISTORY"),
pname,
use.defaults = TRUE,
filter = NULL,
strat.color = NULL,
strat.facet = NULL,
color.scales = NULL,
trans = NULL,
...
)
Arguments
ctr |
|
ptype |
plot type can be:
|
pname |
plot name, if missing it will be created using function aestetics |
use.defaults |
|
filter |
optional filter which will be applied to plotting data |
strat.color |
|
strat.facet |
|
color.scales |
|
trans |
|
... |
other plot parameters to configure |
Value
invisible ctr object
See Also
Other pmxclass:
get_cats()
,
get_conts()
,
get_covariates()
,
get_data()
,
get_occ()
,
get_plot()
,
get_plot_config()
,
get_strats()
,
plot_names()
,
plots()
,
pmx_update()
,
set_data()
Creates pmx controller using theophylline data
Description
Creates pmx controller using theophylline data
Usage
theophylline(settings = NULL, ...)
Arguments
settings |
|
... |
other parameters of pmx_mlx like endpoint |
Value
pmx controller
Examples
## Not run:
theophylline()
## End(Not run)
merge facets formula with new formula
Description
merge facets formula with new formula
Usage
wrap_formula(x, origin = "lfacet")
Arguments
x |
|
origin |
the origin formula default to ~lfacets |
Value
formula
object