diff --git a/.Rbuildignore b/.Rbuildignore
index 7952602f..4021ef36 100644
--- a/.Rbuildignore
+++ b/.Rbuildignore
@@ -3,7 +3,7 @@
^_pkgdown\.yml$
^.*\.Rproj$
^\.Rproj\.user$
-^logo\.png$
+^LICENSE$
^README\.Rmd$
^temporary$
^inst/models$
diff --git a/DESCRIPTION b/DESCRIPTION
index 6188355e..82ee59fd 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,6 +1,6 @@
Package: xpose
Type: Package
-Title: Diagnostics for pharmacometric models
+Title: Diagnostics for Pharmacometric Models
Version: 0.4.0
Authors@R: c(
person('Benjamin', 'Guiastrennec',
@@ -18,6 +18,10 @@ Authors@R: c(
person('Ron', 'Keizer',
role = 'aut',
email = 'ronkeizer@gmail.com'),
+ person('Nick', 'Solomon',
+ role = 'ctb',
+ comment = 'Wrote the geom_qq_line function',
+ email = 'nick@nicksolomon.me'),
person('Kajsa', 'Harling',
role = 'ctb',
email = 'kajsa.harling@pharmetheus.com'),
@@ -34,7 +38,11 @@ Authors@R: c(
role = 'ctb',
email = 'info@pharmetheus.com'),
person('Pfizer', role = 'ctb'))
-Description: Automated generation of graphical diagnostics for non-linear mixed effect models.
+Description: Diagnostics for non-linear mixed-effects (population)
+ models from 'NONMEM' .
+ 'xpose' facilitates data import, creation of numerical run summary
+ and provide 'ggplot2'-based graphics for data exploration and model
+ diagnostics.
Depends:
R (>= 3.1.2),
ggplot2 (>= 2.2.1)
@@ -59,7 +67,7 @@ Suggests:
plotly,
webshot,
mvtnorm
-License: LGPL-3 + file LICENSE
+License: LGPL-3
URL: https://github.com/UUPharmacometrics/xpose
BugReports: https://github.com/UUPharmacometrics/xpose/issues
Encoding: UTF-8
diff --git a/R/xpose_save.R b/R/xpose_save.R
index 868ef05e..6fc5a6c8 100644
--- a/R/xpose_save.R
+++ b/R/xpose_save.R
@@ -1,16 +1,15 @@
#' Save xpose plot
#'
-#' @description Automatically save xpose plots to files.
-#'
-#' This function was inspired by the \link[ggplot2]{ggsave}. If no arguments are provided,
-#' the function will automatically name and save a plot after its run number and the plotting
-#' function name by using the metadata attached to the plot.
+#' @description Inspired by the \link[ggplot2]{ggsave}, this function
+#' facilitates the export of xpose plots.
#'
#' @param plot A xpose plot object.
-#' @param file An optional name to be given to the file. Template variables such as @run
-#' can be used to generate template names.
-#' @param dir Directory under which the xpose plot will be saved. Template variables such as @dir
-#' can be used to generate template names.
+#' @param file A name with file extension (if device is \code{NULL}) to be given to the
+#' output file. Template variables such as \code{@run} (run number) and \code{@plotfun}
+#' (plot function) can be used to automatically name files e.g.
+#' \code{file = '@run_@plotfun.pdf'}.
+#' @param dir Directory under which the xpose plots will be saved. Template variables
+#' such as \code{@dir} can be used to generate template names.
#' @param device Graphical device to use. Can be either be a device function
#' (e.g. \code{\link{png}}), or one of 'eps', 'ps', 'tex' (pictex),
#' 'pdf' (default), 'jpeg', 'tiff', 'png', 'bmp', 'svg' or 'wmf' (windows only).
@@ -23,11 +22,11 @@
#' \dontrun{
#' xpdb_ex_pk %>%
#' dv_vs_ipred() %>%
-#' xpose_save()
+#' xpose_save(file = file.path(tempdir(), "dv_vs_ipred_example.pdf"))
#' }
#' @export
xpose_save <- function(plot = last_plot(),
- file = '@run_@plotfun.pdf',
+ file = NULL,
dir = NULL,
device = NULL,
width = 7,
@@ -37,9 +36,9 @@ xpose_save <- function(plot = last_plot(),
...) {
if (is.null(plot)) {
- stop('The `plot` argument is NULL.')
+ stop('Argument `plot` required.', call. = FALSE)
} else if (is.null(file)) {
- stop('The `file` argument is NULL.')
+ stop('Argument `file` required.', call. = FALSE)
}
# Parse the dir and file arguments for keywords
diff --git a/README.Rmd b/README.Rmd
index 695db0af..a272ff37 100644
--- a/README.Rmd
+++ b/README.Rmd
@@ -2,11 +2,7 @@
output: github_document
---
-# xpose
-
-[![travis_status](https://travis-ci.org/UUPharmacometrics/xpose.svg?branch=master)](https://travis-ci.org/UUPharmacometrics/xpose)
-[![appveyor status](https://ci.appveyor.com/api/projects/status/f6k09rf2cfi3vcs2?svg=true)](https://ci.appveyor.com/project/guiastrennec/xpose)[![cran_version](http://www.r-pkg.org/badges/version/xpose)]()
-[![codecov](https://codecov.io/gh/UUPharmacometrics/xpose/branch/master/graph/badge.svg)](https://codecov.io/gh/UUPharmacometrics/xpose)
+
```{r, include = FALSE}
library(xpose)
@@ -14,14 +10,21 @@ library(xpose)
xpdb <- xpdb_ex_pk
xpdb$options$quiet <- TRUE
-knitr::opts_chunk$set(fig.path = 'inst/img/',
- fig.dpi = 96,
+knitr::opts_chunk$set(fig.path = 'man/figures/',
+ fig.dpi = 96,
fig.height = 4,
- fig.width = 4,
- out.width = '50%',
- fig.align = 'center')
+ fig.width = 4,
+ out.width = '50%',
+ fig.align = 'center')
```
+# xpose
+
+[![travis_status](https://travis-ci.org/UUPharmacometrics/xpose.svg?branch=master)](https://travis-ci.org/UUPharmacometrics/xpose)
+[![appveyor status](https://ci.appveyor.com/api/projects/status/f6k09rf2cfi3vcs2?svg=true)](https://ci.appveyor.com/project/guiastrennec/xpose)[![cran_version](http://www.r-pkg.org/badges/version/xpose)]()
+[![codecov](https://codecov.io/gh/UUPharmacometrics/xpose/branch/master/graph/badge.svg)](https://codecov.io/gh/UUPharmacometrics/xpose)
+
+
### Overview
[xpose](https://UUPharmacometrics.github.io/xpose/) was designed as a [ggplot2](https://github.com/tidyverse/ggplot2)-based alternative to [xpose4](http://xpose.sourceforge.net). xpose aims to reduce the post processing burden and improve diagnostics commonly associated the development of non-linear mixed effect models.
diff --git a/README.md b/README.md
index 89a5e432..7f42401d 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,7 @@
-xpose
-===================================================================================================
+
+xpose
+===============================================================================================================
[![travis\_status](https://travis-ci.org/UUPharmacometrics/xpose.svg?branch=master)](https://travis-ci.org/UUPharmacometrics/xpose) [![appveyor status](https://ci.appveyor.com/api/projects/status/f6k09rf2cfi3vcs2?svg=true)](https://ci.appveyor.com/project/guiastrennec/xpose)[![cran\_version](http://www.r-pkg.org/badges/version/xpose)]() [![codecov](https://codecov.io/gh/UUPharmacometrics/xpose/branch/master/graph/badge.svg)](https://codecov.io/gh/UUPharmacometrics/xpose)
@@ -100,7 +101,7 @@ summary(xpdb, problem = 1)
dv_vs_ipred(xpdb)
```
-
+
##### Individual plots
@@ -108,7 +109,7 @@ dv_vs_ipred(xpdb)
ind_plots(xpdb, page = 1)
```
-
+
##### Visual predictive checks
@@ -118,7 +119,7 @@ xpdb %>%
vpc()
```
-
+
##### Distribution plots
@@ -126,7 +127,7 @@ xpdb %>%
eta_distrib(xpdb, labeller = 'label_value')
```
-
+
##### Minimization diagnostics
@@ -134,7 +135,7 @@ eta_distrib(xpdb, labeller = 'label_value')
prm_vs_iteration(xpdb, labeller = 'label_value')
```
-
+
##### And many other features!
diff --git a/docs/articles/about.html b/docs/articles/about.html
index 07df824b..a7ecc969 100644
--- a/docs/articles/about.html
+++ b/docs/articles/about.html
@@ -110,7 +110,7 @@
The ggplot2 object is now automatically converted to a plotly graph. The scales can now be changed interactively, groups can be hidden by clicking on the legend
The xpose_save function was designed automatically save plots according to their run number (@run) and the plotting function (@plotfun) using keywords preceded by a @. You can learn more about these keywords using help('template_titles'). The file extension is guessed from the file name and must match one of .pdf, .jpeg, .png, .bmp or .tiff, if missing a pdf will be generated by default. Finally, if the plot argument is left empty xpose_save will automatically save the last plot that was created or modified.
The xpose_save function was designed to facilitate the export of xpose plots. The file extension is guessed from the file name and must match one of .pdf (default), .jpeg, .png, .bmp or .tiff. If no extension is provided as part of the file name a .pdf will be generated. Finally, if the plot argument is left empty xpose_save will automatically save the last plot that was created or modified.
+
The xpose_save() function is compatible with templates titles and keywords such as @run for the run number and @plotfun for the name of the plotting function can be used to automatically name files. Learn more about the template titles keywords using help('template_titles').
+
# Save the last generated plot
+dv_vs_ipred(xpdb)
+xpose_save(file ='run001_dv_vs_ipred.pdf')
-# Change file name and extension
-xpose_save(file ='@run_@plotfun_[@ofv].jpeg', dir ='pk/diagnostics')
+# Template titles can also be used in filename and the directory
+xpdb %>%
+dv_vs_ipred() %>%
+xpose_save(file ='@run_@plotfun_[@ofv].jpeg', dir ='@dir')
By default plots are saved as pdf which conveniently can store multiple pages within a single document. However other graphical devices (e.g. 'png', 'jpg') can also be used, simply ensure to have a page counter (i.e. '%03d') added the file name.
The pdf format can conveniently store multiple pages within a single document. However other graphical devices (e.g. 'png', 'jpg') can also be used, simply ensure to have a page counter (i.e. '%03d') added the file name.
The VPC functionality in xpose is build around the vpc R package. For more details about the way the vpc package works, please check the documentation website.
+
The VPC functionality in xpose is build around the vpc R package. For more details about the way the vpc package works, please check the documentation website.
This function was inspired by the ggsave. If no arguments are provided,
-the function will automatically name and save a plot after its run number and the plotting
-function name by using the metadata attached to the plot.
+
Inspired by the ggsave, this function
+facilitates the export of xpose plots.
An optional name to be given to the file. Template variables such as @run
-can be used to generate template names.
+
A name with file extension (if device is NULL) to be given to the
+output file. Template variables such as @run (run number) and @plotfun
+(plot function) can be used to automatically name files e.g.
+file = '@run_@plotfun.pdf'.
dir
-
Directory under which the xpose plot will be saved. Template variables such as @dir
-can be used to generate template names.
+
Directory under which the xpose plots will be saved. Template variables
+such as @dir can be used to generate template names.
device
@@ -189,7 +188,7 @@
Examp
# NOT RUN {xpdb_ex_pk%>%dv_vs_ipred() %>%
- xpose_save()
+ xpose_save(file=file.path(tempdir(), "dv_vs_ipred_example.pdf"))
# }
diff --git a/man/figures/logo.png b/man/figures/logo.png
new file mode 100644
index 00000000..dfb6803b
Binary files /dev/null and b/man/figures/logo.png differ
diff --git a/man/figures/readme_example_figure_1-1.png b/man/figures/readme_example_figure_1-1.png
new file mode 100644
index 00000000..884a09e2
Binary files /dev/null and b/man/figures/readme_example_figure_1-1.png differ
diff --git a/man/figures/readme_example_figure_2-1.png b/man/figures/readme_example_figure_2-1.png
new file mode 100644
index 00000000..89020bea
Binary files /dev/null and b/man/figures/readme_example_figure_2-1.png differ
diff --git a/man/figures/readme_example_figure_3-1.png b/man/figures/readme_example_figure_3-1.png
new file mode 100644
index 00000000..53602228
Binary files /dev/null and b/man/figures/readme_example_figure_3-1.png differ
diff --git a/man/figures/readme_example_figure_4-1.png b/man/figures/readme_example_figure_4-1.png
new file mode 100644
index 00000000..25b521fa
Binary files /dev/null and b/man/figures/readme_example_figure_4-1.png differ
diff --git a/man/figures/readme_example_figure_5-1.png b/man/figures/readme_example_figure_5-1.png
new file mode 100644
index 00000000..c2024a23
Binary files /dev/null and b/man/figures/readme_example_figure_5-1.png differ
diff --git a/man/xpose-package.Rd b/man/xpose-package.Rd
index ad8baaa0..ed8e1dc3 100644
--- a/man/xpose-package.Rd
+++ b/man/xpose-package.Rd
@@ -33,6 +33,7 @@ Authors:
Other contributors:
\itemize{
+ \item Nick Solomon \email{nick@nicksolomon.me} (Wrote the geom_qq_line function) [contributor]
\item Kajsa Harling \email{kajsa.harling@pharmetheus.com} [contributor]
\item Mike K. Smith \email{mike.k.smith@pfizer.com} [contributor]
\item Elodie Plan \email{elodie.plan@pharmetheus.com} [contributor]
diff --git a/man/xpose_save.Rd b/man/xpose_save.Rd
index ade523bd..ee3a4674 100644
--- a/man/xpose_save.Rd
+++ b/man/xpose_save.Rd
@@ -4,18 +4,19 @@
\alias{xpose_save}
\title{Save xpose plot}
\usage{
-xpose_save(plot = last_plot(), file = "@run_@plotfun.pdf", dir = NULL,
- device = NULL, width = 7, height = 6, units = c("in", "cm", "mm"),
- dpi = 200, ...)
+xpose_save(plot = last_plot(), file = NULL, dir = NULL, device = NULL,
+ width = 7, height = 6, units = c("in", "cm", "mm"), dpi = 200, ...)
}
\arguments{
\item{plot}{A xpose plot object.}
-\item{file}{An optional name to be given to the file. Template variables such as @run
-can be used to generate template names.}
+\item{file}{A name with file extension (if device is \code{NULL}) to be given to the
+output file. Template variables such as \code{@run} (run number) and \code{@plotfun}
+(plot function) can be used to automatically name files e.g.
+\code{file = '@run_@plotfun.pdf'}.}
-\item{dir}{Directory under which the xpose plot will be saved. Template variables such as @dir
-can be used to generate template names.}
+\item{dir}{Directory under which the xpose plots will be saved. Template variables
+such as \code{@dir} can be used to generate template names.}
\item{device}{Graphical device to use. Can be either be a device function
(e.g. \code{\link{png}}), or one of 'eps', 'ps', 'tex' (pictex),
@@ -30,16 +31,13 @@ can be used to generate template names.}
\item{...}{Additional arguments passed on to \link[ggplot2]{ggsave} or graphics \code{device}.}
}
\description{
-Automatically save xpose plots to files.
-
-This function was inspired by the \link[ggplot2]{ggsave}. If no arguments are provided,
-the function will automatically name and save a plot after its run number and the plotting
-function name by using the metadata attached to the plot.
+Inspired by the \link[ggplot2]{ggsave}, this function
+facilitates the export of xpose plots.
}
\examples{
\dontrun{
xpdb_ex_pk \%>\%
dv_vs_ipred() \%>\%
- xpose_save()
+ xpose_save(file = file.path(tempdir(), "dv_vs_ipred_example.pdf"))
}
}
diff --git a/tests/testthat/test-xpose_save.R b/tests/testthat/test-xpose_save.R
index 5206b700..335666d5 100644
--- a/tests/testthat/test-xpose_save.R
+++ b/tests/testthat/test-xpose_save.R
@@ -10,24 +10,28 @@ plot_multiple <- dv_vs_ipred(xpdb = xpdb_ex_pk, quiet = TRUE, facet = c('SEX', '
# Tests start here --------------------------------------------------------
test_that('errors are returned for bad plot input', {
- expect_error(xpose_save(plot = NULL), regexp = 'The `plot` argument is NULL')
+ expect_error(xpose_save(plot = NULL), regexp = 'Argument `plot` required')
})
test_that('errors are returned for bad filename input', {
paths_1 <- file.path(tempdir(), paste0('test_plot', c('.abcd', '.bcde', '')))
on.exit(unlink(paths_1))
+ # Missing filename
+ expect_error(xpose_save(plot = plot),
+ regexp = 'Argument `file` required')
+
# Unrecognized extension
- expect_error(xpose_save(plot = plot, file = paths_1[1]))
+ expect_error(xpose_save(plot = plot, file = paths_1[1]),
+ regexp = 'Unknown graphics device \'abcd\'')
# Missing extension
- expect_error(xpose_save(plot = plot, file = paths_1[3]))
-
- # Missing filename
- expect_error(xpose_save(plot = plot, file = NULL))
+ expect_error(xpose_save(plot = plot, file = paths_1[3]),
+ regexp = 'Unknown graphics device \'\'')
# Length filename > 1
- expect_error(xpose_save(plot = plot, file = paths_1))
+ expect_error(xpose_save(plot = plot, file = paths_1),
+ regexp = '`device` must be NULL, a string or a function.')
})
diff --git a/vignettes/cheatsheet.pdf b/vignettes/cheatsheet.pdf
index ddef7e6b..250dc90d 100644
Binary files a/vignettes/cheatsheet.pdf and b/vignettes/cheatsheet.pdf differ
diff --git a/vignettes/introduction.Rmd b/vignettes/introduction.Rmd
index fca37b1e..b0e35235 100644
--- a/vignettes/introduction.Rmd
+++ b/vignettes/introduction.Rmd
@@ -74,7 +74,7 @@ list_vars(xpdb)
```{r, eval = FALSE}
xpose_data(runno = '001') %>%
dv_vs_ipred() %>%
- xpose_save()
+ xpose_save(file = 'run001_dv_vs_ipred.pdf')
```
### Editing the xpdb
@@ -103,12 +103,18 @@ res_vs_pred(xpdb, res = 'CWRES')
### Saving plots
-The `xpose_save` function was designed automatically save plots according to their run number (`@run`) and the plotting function (`@plotfun`) using keywords preceded by a `@`. You can learn more about these keywords using `help('template_titles')`. The file extension is guessed from the file name and must match one of .pdf, .jpeg, .png, .bmp or .tiff, if missing a pdf will be generated by default. Finally, if the `plot` argument is left empty `xpose_save` will automatically save the last plot that was created or modified.
+The `xpose_save` function was designed to facilitate the export of xpose plots. The file extension is guessed from the file name and must match one of .pdf (default), .jpeg, .png, .bmp or .tiff. If no extension is provided as part of the file name a .pdf will be generated. Finally, if the `plot` argument is left empty `xpose_save` will automatically save the last plot that was created or modified.
+
+The `xpose_save()` function is compatible with templates titles and keywords such as `@run` for the run number and `@plotfun` for the name of the plotting function can be used to automatically name files. Learn more about the template titles keywords using `help('template_titles')`.
+
```{r, eval = FALSE}
-# Save the last plot
-xpose_save()
+# Save the last generated plot
+dv_vs_ipred(xpdb)
+xpose_save(file = 'run001_dv_vs_ipred.pdf')
-# Change file name and extension
-xpose_save(file = '@run_@plotfun_[@ofv].jpeg', dir = 'pk/diagnostics')
+# Template titles can also be used in filename and the directory
+xpdb %>%
+ dv_vs_ipred() %>%
+ xpose_save(file = '@run_@plotfun_[@ofv].jpeg', dir = '@dir')
```
diff --git a/vignettes/multiple_pages.Rmd b/vignettes/multiple_pages.Rmd
index 9ffe7fa1..091eb798 100644
--- a/vignettes/multiple_pages.Rmd
+++ b/vignettes/multiple_pages.Rmd
@@ -86,10 +86,10 @@ Multiple pages graphs can simply be saved by using the `xpose_save()` function.
```{r, eval = FALSE}
dv_vs_ipred(xpdb_numbered, facets = c('SEX', 'MED1'), ncol = 2, nrow = 1) %>%
-xpose_save()
+xpose_save(file = 'dv_vs_ipred_multiple.pdf')
```
-By default plots are saved as `pdf` which conveniently can store multiple pages within a single document. However other graphical devices (e.g. `'png'`, `'jpg'`) can also be used, simply ensure to have a page counter (i.e. `'%03d'`) added the file name.
+The `pdf` format can conveniently store multiple pages within a single document. However other graphical devices (e.g. `'png'`, `'jpg'`) can also be used, simply ensure to have a page counter (i.e. `'%03d'`) added the file name.
```{r, eval = FALSE}
dv_vs_ipred(xpdb_numbered, facets = c('SEX', 'MED1'), ncol = 2, nrow = 1) %>%
diff --git a/vignettes/vpc.Rmd b/vignettes/vpc.Rmd
index f09be342..d09f8217 100644
--- a/vignettes/vpc.Rmd
+++ b/vignettes/vpc.Rmd
@@ -30,7 +30,7 @@ VPC can be created either by:
1. Using an xpdb containing a simulation and an estimation problem
2. Using a [PsN](https://uupharmacometrics.github.io/PsN/) generated VPC folder
-The VPC functionality in xpose is build around the [vpc R package](https://cran.r-project.org/web/packages/vpc/index.html). For more details about the way the vpc package works, please check the [documentation website](http://vpc.ronkeizer.com).
+The VPC functionality in xpose is build around the [vpc R package](https://cran.r-project.org/package=vpc). For more details about the way the vpc package works, please check the [documentation website](http://vpc.ronkeizer.com).
### Workflow
The VPC computing and plotting parts have been separated into two distinct functions: `vpc_data()` and `vpc()` respectively. This allows to: