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

About xpose

Benjamin Guiastrennec

-

03 November, 2017

+

14 November, 2017

diff --git a/docs/articles/access_xpdb_data.html b/docs/articles/access_xpdb_data.html index 4da13ef7..2f79a3a8 100644 --- a/docs/articles/access_xpdb_data.html +++ b/docs/articles/access_xpdb_data.html @@ -110,7 +110,7 @@

Access the xpdb data

Benjamin Guiastrennec

-

03 November, 2017

+

14 November, 2017

diff --git a/docs/articles/bestiarium.html b/docs/articles/bestiarium.html index 8a7bf593..daa5ea18 100644 --- a/docs/articles/bestiarium.html +++ b/docs/articles/bestiarium.html @@ -110,7 +110,7 @@

The xpose plots

Benjamin Guiastrennec

-

03 November, 2017

+

14 November, 2017

diff --git a/docs/articles/cheatsheet.pdf b/docs/articles/cheatsheet.pdf index ddef7e6b..250dc90d 100644 Binary files a/docs/articles/cheatsheet.pdf and b/docs/articles/cheatsheet.pdf differ diff --git a/docs/articles/customize_plots.html b/docs/articles/customize_plots.html index 006818b0..dbb05369 100644 --- a/docs/articles/customize_plots.html +++ b/docs/articles/customize_plots.html @@ -110,7 +110,7 @@

Customize plots

Benjamin Guiastrennec

-

03 November, 2017

+

14 November, 2017

diff --git a/docs/articles/faq.html b/docs/articles/faq.html index 10ea95be..00c51330 100644 --- a/docs/articles/faq.html +++ b/docs/articles/faq.html @@ -110,7 +110,7 @@

Frequently Asked Questions

Benjamin Guiastrennec

-

03 November, 2017

+

14 November, 2017

diff --git a/docs/articles/import_model_outputs.html b/docs/articles/import_model_outputs.html index 42c49c5a..0631eff2 100644 --- a/docs/articles/import_model_outputs.html +++ b/docs/articles/import_model_outputs.html @@ -110,7 +110,7 @@

Import model outputs

Benjamin Guiastrennec

-

03 November, 2017

+

14 November, 2017

diff --git a/docs/articles/interactive_plots.html b/docs/articles/interactive_plots.html index 700bfe69..f502cbc4 100644 --- a/docs/articles/interactive_plots.html +++ b/docs/articles/interactive_plots.html @@ -112,7 +112,7 @@

Creating interactive plots

Benjamin Guiastrennec

-

03 November, 2017

+

14 November, 2017

@@ -153,8 +153,8 @@

Convert the plot from ggplot2 to plotly

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

plotly::ggplotly(gof_plot)
-
- +
+

@@ -165,8 +165,8 @@

xpdb_ex_pk %>% 
   eta_distrib(title = 'Eta distribution') %>% 
   plotly::ggplotly()
-
- +
+

@@ -175,8 +175,8 @@

vpc_data() %>% vpc(title = 'Visual predictive checks', type = 'alpr') %>% plotly::ggplotly()

-
- +
+ diff --git a/docs/articles/introduction.R b/docs/articles/introduction.R index b5e1777e..a6614c6d 100644 --- a/docs/articles/introduction.R +++ b/docs/articles/introduction.R @@ -27,7 +27,7 @@ list_vars(xpdb) ## ---- eval = FALSE------------------------------------------------------- # xpose_data(runno = '001') %>% # dv_vs_ipred() %>% -# xpose_save() +# xpose_save(file = 'run001_dv_vs_ipred.pdf') ## ---- change idv--------------------------------------------------------- # With the TIME default @@ -47,9 +47,12 @@ dv_vs_ipred(xpdb) res_vs_pred(xpdb, res = 'CWRES') ## ---- 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/docs/articles/introduction.html b/docs/articles/introduction.html index 9b35a45a..d6219b81 100644 --- a/docs/articles/introduction.html +++ b/docs/articles/introduction.html @@ -110,7 +110,7 @@

Introduction

Benjamin Guiastrennec

-

03 November, 2017

+

14 November, 2017

@@ -247,7 +247,7 @@

xpose makes use of the pipe operator %>% from the package dplyr. Pipes can be used to generate clear workflow.

xpose_data(runno = '001') %>% 
   dv_vs_ipred() %>% 
-  xpose_save()
+ xpose_save(file = 'run001_dv_vs_ipred.pdf')

@@ -277,12 +277,16 @@

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.

-
# Save the last plot
-xpose_save()
+

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')

diff --git a/docs/articles/multiple_pages.R b/docs/articles/multiple_pages.R index d33ce241..8ab6dfcf 100644 --- a/docs/articles/multiple_pages.R +++ b/docs/articles/multiple_pages.R @@ -42,7 +42,7 @@ dv_vs_ipred(xpdb_numbered, facets = c('SEX', 'MED1'), ncol = 2, nrow = 1, page = ## ---- 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') ## ---- eval = FALSE-------------------------------------------------------------------------------- # dv_vs_ipred(xpdb_numbered, facets = c('SEX', 'MED1'), ncol = 2, nrow = 1) %>% diff --git a/docs/articles/multiple_pages.html b/docs/articles/multiple_pages.html index 64bf6b9b..deef30a7 100644 --- a/docs/articles/multiple_pages.html +++ b/docs/articles/multiple_pages.html @@ -110,7 +110,7 @@

Plots with multiple pages

Benjamin Guiastrennec

-

03 November, 2017

+

14 November, 2017

@@ -175,8 +175,8 @@

Saving multiple pages plots

Multiple pages graphs can simply be saved by using the xpose_save() function.

dv_vs_ipred(xpdb_numbered, facets = c('SEX', 'MED1'), ncol = 2, nrow = 1) %>% 
-xpose_save()
-

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.

+xpose_save(file = 'dv_vs_ipred_multiple.pdf') +

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.

dv_vs_ipred(xpdb_numbered, facets = c('SEX', 'MED1'), ncol = 2, nrow = 1) %>% 
 xpose_save(file = '@run_@plotfun_%03d.png')
diff --git a/docs/articles/vpc.html b/docs/articles/vpc.html index dd03a0f9..1d6b61ec 100644 --- a/docs/articles/vpc.html +++ b/docs/articles/vpc.html @@ -110,7 +110,7 @@

Visual Predictive Checks (VPC)

Benjamin Guiastrennec

-

03 November, 2017

+

14 November, 2017

@@ -129,7 +129,7 @@

  • Using an xpdb containing a simulation and an estimation problem
  • Using a PsN generated VPC folder
  • -

    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.

    diff --git a/docs/authors.html b/docs/authors.html index cac00316..2cc9c652 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -153,6 +153,10 @@

    Authors

    Ron Keizer. Author.

    +
  • +

    Nick Solomon. Contributor. +
    Wrote the geom_qq_line function

    +
  • Kajsa Harling. Contributor.

    diff --git a/docs/index.html b/docs/index.html index 477d113a..c09d38f7 100644 --- a/docs/index.html +++ b/docs/index.html @@ -5,7 +5,7 @@ -Diagnostics for pharmacometric models • xpose +Diagnostics for Pharmacometric Models • xpose @@ -113,9 +113,10 @@
    +
    @@ -207,13 +208,13 @@

    Standard goodness-of-fit plots
    -

    +

    Individual plots
    ind_plots(xpdb, page = 1)
    -

    +

    @@ -221,19 +222,19 @@
    xpdb %>% 
       vpc_data(stratify = 'SEX', opt = vpc_opt(n_bins = 7, lloq = 0.1)) %>% 
       vpc()
    -

    +

    Distribution plots
    eta_distrib(xpdb, labeller = 'label_value')
    -

    +

    Minimization diagnostics
    prm_vs_iteration(xpdb, labeller = 'label_value')
    -

    +

    @@ -268,7 +269,7 @@

  • License

    -

    LGPL-3 + file LICENSE

    +

    LGPL-3

    Developers

    • diff --git a/docs/man/figures/readme_example_figure_1-1.png b/docs/man/figures/readme_example_figure_1-1.png new file mode 100644 index 00000000..d935e912 Binary files /dev/null and b/docs/man/figures/readme_example_figure_1-1.png differ diff --git a/docs/man/figures/readme_example_figure_2-1.png b/docs/man/figures/readme_example_figure_2-1.png new file mode 100644 index 00000000..276118cc Binary files /dev/null and b/docs/man/figures/readme_example_figure_2-1.png differ diff --git a/docs/man/figures/readme_example_figure_3-1.png b/docs/man/figures/readme_example_figure_3-1.png new file mode 100644 index 00000000..ebac3a1f Binary files /dev/null and b/docs/man/figures/readme_example_figure_3-1.png differ diff --git a/docs/man/figures/readme_example_figure_4-1.png b/docs/man/figures/readme_example_figure_4-1.png new file mode 100644 index 00000000..b9b52b67 Binary files /dev/null and b/docs/man/figures/readme_example_figure_4-1.png differ diff --git a/docs/man/figures/readme_example_figure_5-1.png b/docs/man/figures/readme_example_figure_5-1.png new file mode 100644 index 00000000..b8c67398 Binary files /dev/null and b/docs/man/figures/readme_example_figure_5-1.png differ diff --git a/logo.png b/docs/reference/figures/logo.png similarity index 100% rename from logo.png rename to docs/reference/figures/logo.png diff --git a/inst/img/readme_example_figure_1-1.png b/docs/reference/figures/readme_example_figure_1-1.png similarity index 100% rename from inst/img/readme_example_figure_1-1.png rename to docs/reference/figures/readme_example_figure_1-1.png diff --git a/inst/img/readme_example_figure_2-1.png b/docs/reference/figures/readme_example_figure_2-1.png similarity index 100% rename from inst/img/readme_example_figure_2-1.png rename to docs/reference/figures/readme_example_figure_2-1.png diff --git a/inst/img/readme_example_figure_3-1.png b/docs/reference/figures/readme_example_figure_3-1.png similarity index 100% rename from inst/img/readme_example_figure_3-1.png rename to docs/reference/figures/readme_example_figure_3-1.png diff --git a/inst/img/readme_example_figure_4-1.png b/docs/reference/figures/readme_example_figure_4-1.png similarity index 100% rename from inst/img/readme_example_figure_4-1.png rename to docs/reference/figures/readme_example_figure_4-1.png diff --git a/inst/img/readme_example_figure_5-1.png b/docs/reference/figures/readme_example_figure_5-1.png similarity index 100% rename from inst/img/readme_example_figure_5-1.png rename to docs/reference/figures/readme_example_figure_5-1.png diff --git a/docs/reference/xpose-package.html b/docs/reference/xpose-package.html index 453dd7d9..c235eb96 100644 --- a/docs/reference/xpose-package.html +++ b/docs/reference/xpose-package.html @@ -170,6 +170,7 @@

      Author

      Other contributors:
    -

    Automatically save xpose plots to files.

    -

    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.

    -
    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

    @@ -152,13 +149,15 @@

    Ar

    - + - + @@ -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"))
     # }

    file

    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