diff --git a/R/nlmixr.R b/R/nlmixr.R
index d5efdb6c..571e7be0 100644
--- a/R/nlmixr.R
+++ b/R/nlmixr.R
@@ -1,3 +1,5 @@
+
+
#' Creates pmx controller from an nlimxr fit object
#'
#' @param fit nlmixr object
@@ -117,7 +119,12 @@ pmx_nlmixr <- function(fit, dvid, conts, cats, strats, endpoint, settings, vpc =
}
}
}
- input <- as.data.table(fit$dataMergeInner)
+ # use the fit DV because it simulates censoring
+ # $fitMergeInner prefers the DV from the fit, so preserve it here
+ input <- fit$fitMergeInner
+ # if it hasn't been implemented use dataMergeInner instead
+ if (is.null(input)) input <- fit$dataMergeInner
+ input <- as.data.table(input)
for (v in conts) {
if (v != "") {
class(input[[v]]) <- "double"
diff --git a/R/plot-individual.R b/R/plot-individual.R
index 5ac560ea..7004ea6b 100755
--- a/R/plot-individual.R
+++ b/R/plot-individual.R
@@ -111,7 +111,7 @@ plot_pmx.individual <-
point$shape <- NULL
max_y <- aggregate(TIME ~ ID, data=dx, max)
colnames(max_y) <- c("ID", "maxValue")
- dx <- base::merge(dx, max_y, by="ID", all.x = T)
+ dx <- base::merge(dx, max_y, by="ID", all.x = TRUE)
# Rounding because "predictions" data are rounded:
dx$isobserv <- with(dx, round(TIME) <= maxValue)
point$data <- base::merge(point$data, max_y, by="ID")
@@ -139,20 +139,23 @@ plot_pmx.individual <-
}
}
}
-
if (!is.null(point)) {
- n <- ifelse(any(point$data$isobserv == "ignored"), 3, 2)
+ n <- ifelse(any(point$data$isobserv == "ignored"), 3,
+ ifelse(length(point$data$isobserv) == 0L, 1, 2))
linetype_values <- c(rep("solid", n), "dashed")
- if (any(point$data$isobserv == "ignored"))
+ if (any(point$data$isobserv == "ignored")) {
linetype_labels <- c("accepted",
"ignored",
"individual predictions",
"population predictions")
- else
+ } else if (length(point$data$isobserv) == 0L) {
+ linetype_labels <- c("individual predictions",
+ "population predictions")
+ } else {
linetype_labels <- c("accepted",
"individual predictions",
"population predictions")
-
+ }
} else {
n <- 2
linetype_labels <- c("accepted",
diff --git a/README.md b/README.md
index d5bf4506..fbb048bc 100755
--- a/README.md
+++ b/README.md
@@ -33,6 +33,10 @@ diagnostics such as: - residual- and empirical Bayes estimate
(EBE)-based plots, - distribution plots, - prediction- and
simulation-based diagnostics (visual predictive checks).
+ggPMX creates plot objects which can be further customized and extended
+using the extensive [ggplot2
+syntax](https://ggplot2.tidyverse.org/reference/gg-add.html).
+
In addition, shrinkage and summary parameters tables can be also
produced. By default, the PDF- or Word-format diagnostic report contains
essential goodness-of-fit plots. However, these can be adapted to
@@ -756,7 +760,9 @@ ctr %>% pmx_plot_eta_matrix
In order to generate VPCs a simulation dataset is requried. Creation of
VPC is slightly different dependening on the fitting software used
-(Monolix, NONMEM or nlmixr).
+(Monolix, NONMEM or nlmixr). Make sure to use the same name for the dv
+column in the simulation file as the one used in the input (modeling
+dataset).
### Models fitted with Monolix (versions 2016 and later)
@@ -896,21 +902,29 @@ ctr %>% pmx_plot_vpc(bin=pmx_vpc_bin(style = "kmeans",n=5))
-### Stratification
+### Set custom x- and/or y-axis labels
``` r
-ctr %>% pmx_plot_vpc(strat.facet="SEX",facets=list(nrow=2))
+ctr %>% pmx_plot_vpc(labels = c(x = "DV axis", y = "TIME axis"))
```
+### Stratification
+
+``` r
+ctr %>% pmx_plot_vpc(strat.facet=~SEX,facets=list(nrow=2))
+```
+
+
+
### Monolix-like customisation
User can customize the options to get a Monolix-like display.
``` r
ctr %>% pmx_plot_vpc(
- strat.facet="SEX",
+ strat.facet=~SEX,
facets=list(nrow=2),
type="percentile",
is.draft = FALSE,
@@ -923,24 +937,25 @@ ctr %>% pmx_plot_vpc(
)
```
-
+
# Diagnostics report
A report (in pdf and docx format) containing all default diagnostic
-plots can be created using the *pmx\_report* function. The *format* can
+plots can be created using the *pmx\_report* function. The *output* can
take three different values:
- “report”: produces a pdf and a docx file (named `name.pdf` and
`name.png` specified in argument *name*, located in *save\_dir*)
with default diagnostic plots
- - “plots”: produces a folder named after *plots_subdir* parameter `ggpmx_GOF` located in *save\_dir*
- that contains all default diagnotic plots, each in a pdf and png
- file. The different plots are numerated in order to have an unique
- identifier for each plot (ex: ebe\_box-1.pdf). This is necessary for
- having correct footnotes that indicated the path to the source file
- (for submission reports).
- - “both”: is a combination of both options above.
+ - “plots”: produces a folder named after *plots\_subdir* parameter
+ (`ggpmx_GOF` by default, if parameter is not specified) located in
+ *save\_dir* that contains all default diagnostic plots, each in a
+ pdf and png file. The different plots are numerated in order to have
+ an unique identifier for each plot (ex: ebe\_box-1.pdf). This is
+ necessary for having correct footnotes that indicated the path to
+ the source file (for submission reports).
+ - “all”: is a combination of both options above.
Example:
@@ -948,11 +963,11 @@ Example:
ctr %>% pmx_report(name='Diagnostic_plots2',
save_dir = work_dir,
plots_subdir = "ggpmx_report",
- format='both')
+ output='all')
```
Note that running the same command first with the option
-“format=‘plots’” and then with the option “format=‘report’” will
+“output=‘plots’” and then with the option “output=‘report’” will
remove the *ggpmx\_GOF* folder.
Note also that by default, the report will have the DRAFT label on all
@@ -967,7 +982,7 @@ the following command:
ctr %>% pmx_report(name='Diagnostic_plots1',
save_dir = work_dir,
plots_subdir = "ggpmx_report",
- format='report')
+ output='report')
```
The Rmarkdown (.Rmd) file is the “template”. The user can modify the
@@ -979,7 +994,7 @@ command:
ctr %>% pmx_report(name='Diagnostic_plots3',
save_dir = work_dir,
plots_subdir = "ggpmx_report",
- format='report',
+ output='report',
template=file.path(work_dir,'Diagnostic_plots1.Rmd'))
```
@@ -1084,6 +1099,7 @@ all plots. In order to switch this label off, the user sets the
`is.draft` option of `pmx_settings()` to `FALSE`.
``` r
+
ctr <- theophylline(settings = pmx_settings(is.draft = FALSE))
```
@@ -1371,10 +1387,10 @@ plot types.
``` r
args(pmx_gpar)
-#> function (labels, axis.title, axis.text, ranges, is.smooth, smooth,
-#> is.band, band, is.draft, draft, discrete, is.identity_line,
-#> identity_line, scale_x_log10, scale_y_log10, color.scales,
-#> is.legend, legend.position)
+#> function (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)
#> NULL
```
@@ -1447,11 +1463,16 @@ ctr %>% pmx_comp_shrink( fun = "var")
```
``` r
-ctr %>% pmx_plot_eta_box( shrink=list(fun = "var"))
+ctr %>% pmx_plot_eta_box( shrink=pmx_shrink(fun = "var"))
```
+Note that for plotting functions which take a shrink parameter, this can
+be created using the `pmx_shrink` function to create a `pmxShrinkClass`
+object (or it can be a list which can be converted into such an object
+using `pmx_shrink`).
+
## Shrinkage and stratification
Shrinkage can be applied after stratification :
@@ -1494,4 +1515,4 @@ ctr %>% pmx_plot_eta_box(is.shrink = TRUE, strat.facet = "SEX",
facets=list(scales="free_y",ncol=2))
```
-
+
diff --git a/man/figures/README-illustrate_diagnostic-3.png b/man/figures/README-illustrate_diagnostic-3.png
index 035428c4..d74211ea 100644
Binary files a/man/figures/README-illustrate_diagnostic-3.png and b/man/figures/README-illustrate_diagnostic-3.png differ
diff --git a/man/figures/README-illustrate_diagnostic-4.png b/man/figures/README-illustrate_diagnostic-4.png
index 812e94b3..22aaa1db 100644
Binary files a/man/figures/README-illustrate_diagnostic-4.png and b/man/figures/README-illustrate_diagnostic-4.png differ
diff --git a/man/figures/README-illustrate_diagnostic-5.png b/man/figures/README-illustrate_diagnostic-5.png
index 8a3f5731..74f6ef7d 100644
Binary files a/man/figures/README-illustrate_diagnostic-5.png and b/man/figures/README-illustrate_diagnostic-5.png differ
diff --git a/man/figures/README-settings_cat_labels3-1.png b/man/figures/README-settings_cat_labels3-1.png
index a13a27c8..f6d310a4 100644
Binary files a/man/figures/README-settings_cat_labels3-1.png and b/man/figures/README-settings_cat_labels3-1.png differ
diff --git a/man/figures/README-settings_color_scales_local-1.png b/man/figures/README-settings_color_scales_local-1.png
index c8459a0d..6c40e829 100644
Binary files a/man/figures/README-settings_color_scales_local-1.png and b/man/figures/README-settings_color_scales_local-1.png differ
diff --git a/man/figures/README-settings_solor_scales-1.png b/man/figures/README-settings_solor_scales-1.png
index ea756885..d28da319 100644
Binary files a/man/figures/README-settings_solor_scales-1.png and b/man/figures/README-settings_solor_scales-1.png differ
diff --git a/man/figures/README-settings_solor_scales_a-1.png b/man/figures/README-settings_solor_scales_a-1.png
index b8ed590e..c3efcefc 100644
Binary files a/man/figures/README-settings_solor_scales_a-1.png and b/man/figures/README-settings_solor_scales_a-1.png differ
diff --git a/man/figures/README-settings_use.finegrid-1.png b/man/figures/README-settings_use.finegrid-1.png
index 1c1bef7d..dd55535e 100644
Binary files a/man/figures/README-settings_use.finegrid-1.png and b/man/figures/README-settings_use.finegrid-1.png differ
diff --git a/man/figures/README-shrink_plot_box-1.png b/man/figures/README-shrink_plot_box-1.png
index 1b53294c..a5c0ce81 100644
Binary files a/man/figures/README-shrink_plot_box-1.png and b/man/figures/README-shrink_plot_box-1.png differ
diff --git a/man/figures/README-shrink_plot_hist-1.png b/man/figures/README-shrink_plot_hist-1.png
index 52d6fecd..70c9c47d 100644
Binary files a/man/figures/README-shrink_plot_hist-1.png and b/man/figures/README-shrink_plot_hist-1.png differ
diff --git a/man/figures/README-shrink_plot_no-1.png b/man/figures/README-shrink_plot_no-1.png
index c8feda8c..19b00ba2 100644
Binary files a/man/figures/README-shrink_plot_no-1.png and b/man/figures/README-shrink_plot_no-1.png differ
diff --git a/man/figures/README-shrink_plot_strat-1.png b/man/figures/README-shrink_plot_strat-1.png
index c6396f14..d5b4da18 100644
Binary files a/man/figures/README-shrink_plot_strat-1.png and b/man/figures/README-shrink_plot_strat-1.png differ
diff --git a/man/figures/README-shrink_plot_var-1.png b/man/figures/README-shrink_plot_var-1.png
index e55db93c..86d37a1d 100644
Binary files a/man/figures/README-shrink_plot_var-1.png and b/man/figures/README-shrink_plot_var-1.png differ
diff --git a/man/figures/README-unnamed-chunk-26-1.png b/man/figures/README-unnamed-chunk-26-1.png
index e57660bd..a7bb5c5c 100644
Binary files a/man/figures/README-unnamed-chunk-26-1.png and b/man/figures/README-unnamed-chunk-26-1.png differ
diff --git a/man/figures/README-unnamed-chunk-27-1.png b/man/figures/README-unnamed-chunk-27-1.png
index fd0b3762..5d5b4d84 100644
Binary files a/man/figures/README-unnamed-chunk-27-1.png and b/man/figures/README-unnamed-chunk-27-1.png differ
diff --git a/man/figures/README-unnamed-chunk-28-1.png b/man/figures/README-unnamed-chunk-28-1.png
index fd7120e7..63463dd7 100644
Binary files a/man/figures/README-unnamed-chunk-28-1.png and b/man/figures/README-unnamed-chunk-28-1.png differ
diff --git a/man/figures/README-unnamed-chunk-29-1.png b/man/figures/README-unnamed-chunk-29-1.png
index 9a8bb527..6108d085 100644
Binary files a/man/figures/README-unnamed-chunk-29-1.png and b/man/figures/README-unnamed-chunk-29-1.png differ
diff --git a/man/figures/README-unnamed-chunk-30-1.png b/man/figures/README-unnamed-chunk-30-1.png
index e1cfe6f8..3d071cfc 100644
Binary files a/man/figures/README-unnamed-chunk-30-1.png and b/man/figures/README-unnamed-chunk-30-1.png differ
diff --git a/man/figures/README-unnamed-chunk-31-1.png b/man/figures/README-unnamed-chunk-31-1.png
new file mode 100644
index 00000000..479640eb
Binary files /dev/null and b/man/figures/README-unnamed-chunk-31-1.png differ
diff --git a/man/figures/README-unnamed-chunk-45-1.png b/man/figures/README-unnamed-chunk-45-1.png
new file mode 100644
index 00000000..67586fac
Binary files /dev/null and b/man/figures/README-unnamed-chunk-45-1.png differ