Skip to content

Commit

Permalink
Merge pull request #82 from guiastrennec/master
Browse files Browse the repository at this point in the history
Update master to 0.4.1
  • Loading branch information
Benjamin authored Dec 28, 2017
2 parents 72b7c15 + e5e407d commit a6f0224
Show file tree
Hide file tree
Showing 121 changed files with 786 additions and 282 deletions.
22 changes: 14 additions & 8 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
^\.travis\.yml$
^_config\.yml$
^_pkgdown\.yml$
^.*\.Rproj$
^\.Rprofile$
^\.Rproj\.user$
^\.travis\.yml$
^appveyor\.yml$
^CODE_OF_CONDUCT\.md$
^CONTRIBUTING\.md$
^data-raw$
^docs$
^inst/models$
^LICENSE$
^pkgdown$
^README\.Rmd$
^ROADMAP\.md$
^temporary$
^inst/models$
^data-raw$
^\.Rprofile$
^docs$
^appveyor\.yml$
^vignettes/interactive_plots.*$
^vignettes/about.*$
^vignettes/bestiarium.*$
^pkgdown$
^vignettes/cheatsheet.pdf$
^vignettes/faq.*$
^vignettes/interactive_plots.*$
46 changes: 46 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at guiastrennec@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
44 changes: 44 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Contributing to xpose

We are happy that you are willing to help us out with the development of xpose. Before get started please take some time to read the following guidelines.

## Submitting issues

Before posting a new issue, please check that it has not already been posted nor is listed in our [road-map](https://github.com/UUPharmacometrics/xpose/blob/master/ROADMAP.md).

* For **feature requests** make sure to include sufficient information, such as a proposed workflow, plots images, links to posters or publications describing a method, etc.
* For **reporting a bug**, the most important thing is to include a minimal reproducible example so that we can quickly verify your problem, and figure out how to fix it. To make your example reproducible:

+ Attach files such as the NONMEM output files or an xpdb saved as *.Rdata* (i.e. `save(xpdb, "xpdb_error.Rdata")`). Note, you can use the arguments `ignore` and/or `extra_files` of `xpose_data()` to reduce the size of the xpdb whenever needed.
+ Include the R code that created the error. Ensure that your code is clear, well commented and as small as necessary to reproduce the error.
+ Include the error message.
+ Include information on your R session using `sessionInfo()`.

## Submitting pull requests

To contribute code to xpose please carefully follow the steps listed below.

*Note 1: before getting started with a pull request, we strongly encourage you follow the procedure described above for **feature requests** and/or **reporting a bug** to ensure that your project is compatible with the our xpose [road-map](https://github.com/UUPharmacometrics/xpose/blob/master/ROADMAP.md).*

*Note 2: if you are unfamiliar with the development of R packages, please take some time to read the [R packages](http://r-pkgs.had.co.nz) book by Hadley Wickham.*

1. [Fork](https://github.com/UUPharmacometrics/xpose/fork) the xpose repository.
1. Make the changes to the code on your fork.

+ Use the [coding style](http://r-pkgs.had.co.nz/style.html) recommended by Hadley Wickham.
+ Any new function should have [Roxygen](http://r-pkgs.had.co.nz/man.html) documentation. Internal functions should contain `#' @keywords internal`. Add examples to new functions. Make sure to update the documentation with `devtools::document()` before submitting the pull request.
+ [Tests](http://r-pkgs.had.co.nz/tests.html) should be added under *tests/testthat/* to ensure for proper code coverage.
+ New plots should be created using the generic `xplot_scatter()`, `xplot_distrib()` or `xplot_qq()`. Check for example the code of *R/plot_gof.R* to see how it should be done.
+ General utility functions should be added under *R/utils.R* and plot utility functions under *R/xplot_helpers.R*.
+ Use functions from the tidyverse (e.g. dplyr, tidyr, stringr, etc.) whenever possible.
+ Add a brief description of your contribution to *NEWS.md* using bullets. Make sure to list it under the most recent xpose version and to add your name as (`@<your_github_username>`). e.g. `* Added support for multiple pages plots (@guiastrennec)`. In addition, if your pull request addresses one or several issues, please reference them using the # sign e.g. `* Added support for multiple pages plots (@guiastrennec, #3)`

1. Run `devtools::check()` on your fork and ensure the absence of any errors, warnings and notes.
1. Create a pull request to the **dev branch** of the **UUPharmacometrics/xpose** repository.

+ Provide a good description of your pull request. Add examples, function outputs and plots images illustrating the new features.
+ Make sure that travis-ci, appveyor and codecov tests are all sucessfull

1. Address all comments until the pull request is either merged or closed.

All of this may seem complicated at first, but you can contact one of the core developers to assist you throughout the process.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: xpose
Type: Package
Title: Diagnostics for Pharmacometric Models
Version: 0.4.0
Version: 0.4.1
Authors@R: c(
person('Benjamin', 'Guiastrennec',
role = c('aut', 'cre', 'cph'),
Expand Down Expand Up @@ -50,7 +50,6 @@ Imports:
dplyr (>= 0.7.0),
ggforce,
grDevices,
gridExtra,
purrr (>= 0.2.0),
readr,
rlang (>= 0.1.2),
Expand All @@ -61,6 +60,7 @@ Imports:
stats,
vpc (>= 1.0.0)
Suggests:
gridExtra,
rmarkdown,
knitr,
testthat,
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export(set_var_labels)
export(set_var_types)
export(set_var_units)
export(slice)
export(software)
export(summarise)
export(summarize)
export(theme_bw2)
Expand Down
12 changes: 12 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# xpose 0.4.1
### General
* Improved integration of the xpose.nlmixr package
* Prevented a problem in the `print()` function with the upcoming ggplot2 version
* Fixed bug in `summary()` where missing estimation method was reported if NM code written as METH=... instead of METHOD=...
* Fixed bug where labels in `prm_table()`, `get_prm()` were missing with a commented row in $THETA, $OMEGA or $SIGMA
* Fixed bug in `prm_table()`, `get_prm()` where only `NA` would be reported when missing the -1000000006 record in the .ext file (i.e. NM <7.3)
* Improved description of the `prm_table()` output
* Fixed bug in `ind_plots()` where the aesthetics would get mixed up if the variable names were changed
* Small fixes to vignettes, documentations and website


# xpose 0.4.0
### General
* Added xpdb memory usage to `print.xpose_data()`
Expand Down
8 changes: 7 additions & 1 deletion R/plot_distibution.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,17 @@ eta_distrib <- function(xpdb,
stop('No eta column found in the xpdb data index.', call. = FALSE)
}

if (software(xpdb) == 'nonmem') {
post_processing_eta <- reorder_factors(prefix = 'ETA(', suffix = ')')
} else {
post_processing_eta <- NULL
}

xplot_distrib(xpdb = xpdb, quiet = quiet,
opt = data_opt(.problem = .problem,
filter = only_distinct(xpdb, .problem, facets, quiet),
tidy = TRUE, value_col = eta_col,
post_processing = reorder_factors(prefix = 'ETA(', suffix = ')')),
post_processing = post_processing_eta),
mapping = aes_c(aes_string(x = 'value'), mapping),
type = type, guide = guide, facets = facets,
xscale = check_scales('x', log),
Expand Down
8 changes: 6 additions & 2 deletions R/plot_individuals.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,17 @@ ind_plots <- function(xpdb,
warning('In ind_plots the argument `color` should be used instead of `line/point/text_color`.', call. = FALSE)
}

variable_names <- xp_var(xpdb, .problem, type = c('dv', 'pred', 'ipred'))$col

do.call('xplot_scatter',
c(extra_args,
list(xpdb = xpdb, group = group, quiet = quiet,
opt = data_opt(.problem = .problem, tidy = TRUE,
filter = only_obs(xpdb, .problem, quiet),
value_col = xp_var(xpdb, .problem,
type = c('dv', 'pred', 'ipred'))$col),
value_col = variable_names,
post_processing = function(x) {
dplyr::mutate(.data = x, variable = factor(x$variable, levels = variable_names))
}),
mapping = aes_c(aes_string(x = xp_var(xpdb, .problem, type = 'idv')$col,
y = 'value', line_color = 'variable', text_color = 'variable',
line_linetype = 'variable', point_color = 'variable',
Expand Down
7 changes: 6 additions & 1 deletion R/plot_qq.R
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,16 @@ eta_qq <- function(xpdb,
stop('No eta column found in the xpdb data index.', call. = FALSE)
}

if (software(xpdb) == 'nonmem') {
post_processing_eta <- reorder_factors(prefix = 'ETA(', suffix = ')')
} else {
post_processing_eta <- NULL
}
xplot_qq(xpdb = xpdb, quiet = quiet,
opt = data_opt(.problem = .problem,
filter = only_distinct(xpdb, .problem, facets, quiet),
tidy = TRUE, value_col = eta_col,
post_processing = reorder_factors(prefix = 'ETA(', suffix = ')')),
post_processing = post_processing_eta),
mapping = aes_c(aes_string(sample = 'value'), mapping),
type = type, guide = guide, facets = facets,
xscale = check_scales('x', log),
Expand Down
37 changes: 32 additions & 5 deletions R/print_xpose_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ print.xpose_plot <- function(x, page, ...) {
if (class(x$facet)[1] %in% c('FacetWrapPaginate', 'FacetGridPaginate')) {

# Get total number of pages
page_tot <- ggforce::n_pages(repair_facet(x))
page_tot <- n_pages(repair_facet(x))

# Get and check the page number to be drawn
if (!missing(page)) {
Expand Down Expand Up @@ -102,11 +102,10 @@ print.xpose_plot <- function(x, page, ...) {
if (!missing(page)) warning('Faceting not set. Ignoring `page` argument.', call. = FALSE)

# Warn for big plots
n_panels <- ggplot2::ggplot_build(x) %>%
{nrow(.$layout$panel_layout)}
panel_tot <- n_panels(x)

if (n_panels > 20) {
msg(c('The faceting resulted in ', n_panels,
if (panel_tot > 20) {
msg(c('The faceting resulted in ', panel_tot,
' panels. The plot may take a while to render.'),
quiet = x$xpose$quiet)
}
Expand Down Expand Up @@ -143,3 +142,31 @@ repair_facet <- function(x) {
}
x
}

# Calculate the total number of pages
n_pages <- function(plot) {
if (utils::packageVersion('ggplot2') <= '2.2.1') {
page <- ggplot_build(plot)$layout$panel_layout$page
} else {
page <- ggplot_build(plot)$layout$layout$page
}
if (!is.null(page)) {
max(page)
} else {
0L
}
}

# Calculate the total number of panels
n_panels <- function(plot) {
if (utils::packageVersion('ggplot2') <= '2.2.1') {
page <- ggplot_build(plot)$layout$panel_layout
} else {
page <- ggplot_build(plot)$layout$layout
}
if (!is.null(page)) {
nrow(page)
} else {
0L
}
}
5 changes: 2 additions & 3 deletions R/prm_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ prm_table <- function(xpdb,
show_all = show_all, quiet = TRUE)

if (transform) {
cat('\nThe relative standard errors for omega and sigma are reported on the approximate
standard deviation scale (SE/variance estimate)/2.\n')
cat('\nReporting transformed parameters:\nFor the OMEGA and SIGMA matrices, values are reported as standard deviations for the diagonal elements and as correlations for the off-diagonal elements. The relative standard errors (RSE) for OMEGA and SIGMA are reported on the approximate standard deviation scale (SE/variance estimate)/2. Use `transform = FALSE` to report untransformed parameters.\n')
} else {
cat('\nReporting untransformed parameters.\n')
cat('\nReporting untransformed parameters:\nFor the OMEGA and SIGMA matrices, values are reported as variances for the diagonal elements and as covariances for the off-diagonal elements.\n')
}

# Convert single prm_df to list
Expand Down
4 changes: 2 additions & 2 deletions R/summarise_nm_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -506,12 +506,12 @@ sum_method <- function(model, software) {
if (software == 'nonmem') {
x <- model %>%
dplyr::filter(.$subroutine %in% c('sim', 'est')) %>%
dplyr::filter(stringr::str_detect(.$code, 'METHOD|NSUB'))
dplyr::filter(stringr::str_detect(.$code, 'METH|NSUB'))

if (nrow(x) == 0) return(sum_tpl('method', 'na'))

x %>%
dplyr::mutate(value = stringr::str_match(.$code, 'METHOD\\s*=\\s*([^\\s]+)')[, 2],
dplyr::mutate(value = stringr::str_match(.$code, 'METH[OD]*\\s*=\\s*([^\\s]+)')[, 2],
inter = stringr::str_detect(.$code, '\\sINTER'),
lapl = stringr::str_detect(.$code, '\\sLAPLA'),
like = stringr::str_detect(.$code, '\\sLIKE')) %>%
Expand Down
18 changes: 18 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,21 @@ make_extension <- function(x) {
update_extension <- function(x, ext) {
stringr::str_replace(x, '\\.[[:alnum:]]+$', ext)
}


#' Get software from the xpdb
#'
#' @description Get the name of the modeling softwre on which the xpdb was created
#'
#' @param xpdb An xpose database object.
#'
#' @return The name of a modeling tool.
#'
#' @keywords internal
#' @export
software <- function(xpdb) {
x <- get_summary(xpdb)
x <- x$value[x$label == 'software']
if (is.null(x)) x <- 'na'
x
}
9 changes: 7 additions & 2 deletions R/xpdb_access.R
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ get_summary <- function(xpdb,
#' @param .subprob The subproblem to be used, by default returns the last one for each file.
#' @param .method The estimation method to be used, by default returns the last one for each file
#' @param digits The number of significant digits to be displayed.
#' @param transform Should diagonal OMEGA and SIGMA elements be transformed to coeficient of variation,
#' @param transform Should diagonal OMEGA and SIGMA elements be transformed to standard deviation and
#' off diagonal elements be transformed to correlations.
#' @param show_all Logical, whether the 0 fixed off-diagonal elements should be removed from the output.
#' @param quiet Logical, if \code{FALSE} messages are printed to the console.
Expand Down Expand Up @@ -342,7 +342,7 @@ get_prm <- function(xpdb,
dplyr::mutate(prm_names = purrr::map(.x = as.list(.$problem), .f = function(x, code) {

# Collect parameter names from the model code
code <- code[code$problem == x,]
code <- code[code$problem == x & nchar(code$code) > 0,]
list(theta = code$comment[code$subroutine == 'the'],
omega = code[code$subroutine == 'ome', ] %>%
dplyr::filter(!(stringr::str_detect(.$code, 'BLOCK\\(\\d+\\)(?!.*SAME)') & .$comment == '')) %>%
Expand All @@ -356,6 +356,11 @@ get_prm <- function(xpdb,
prm_se <- grab_iter(ext = data$ext, iter = -1000000001)
prm_fix <- grab_iter(ext = data$ext, iter = -1000000006)

if (all(is.na(prm_fix))) {
warning('Iteration `-1000000006` not found in the `.ext` file. Assuming no fixed parameters, check the output carefully.', call. = FALSE)
prm_fix[is.na(prm_fix)] <- 0
}

if (transform) {
if (!is.null(data$cov)) {
# build covariance matrix from `.cov` file
Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ knitr::opts_chunk$set(fig.path = 'man/figures/',
[![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)

[![downloads](https://cranlogs.r-pkg.org/badges/grand-total/xpose)](http://cran.rstudio.com/web/packages/xpose/index.html)

### 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.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xpose <a href="https://UUPharmacometrics.github.io/xpose/"><img src="man/figures/logo.png" align="right" /></a>
===============================================================================================================

[![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)
[![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) [![downloads](https://cranlogs.r-pkg.org/badges/grand-total/xpose)](http://cran.rstudio.com/web/packages/xpose/index.html)

### Overview

Expand Down
Loading

0 comments on commit a6f0224

Please sign in to comment.