Skip to content

Commit

Permalink
Merge pull request #81 from guiastrennec/master
Browse files Browse the repository at this point in the history
Updates for 0.4.1 submission
  • Loading branch information
Benjamin authored Dec 28, 2017
2 parents a641178 + 787ce36 commit 420e09c
Show file tree
Hide file tree
Showing 114 changed files with 733 additions and 277 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.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
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
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: 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
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
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
60 changes: 60 additions & 0 deletions ROADMAP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# xpose development roadmap

## New features
- [ ] Add outliers labeling features e.g. `aes(color = outlier(CWRES, ±6))`
- [ ] Add feature to exp-transform plot scales as `exp = "xy"`
- [ ] Add reference distribution in eta_distrib when `guide = TRUE`
- [ ] Add data checkout diagnostics
- [ ] Add support for time-to-event (TTE) data
- [ ] Add support for categorical data
- [ ] Add gam and diagnostics
- [ ] Add diagnostics for bootstrap, nonpb
- [ ] Add diagnostics for cdd
- [ ] Add diagnostics for frem
- [ ] Add diagnostics for lasso
- [ ] Add diagnostics for llp
- [ ] Add diagnostics for mcmp
- [ ] Add diagnostics for mimp
- [ ] Add diagnostics for npc
- [ ] Add diagnostics for npde
- [ ] Add diagnostics for randtest
- [ ] Add diagnostics for resmod
- [ ] Add diagnostics for scm, boot_scm, xv_scm
- [ ] Add diagnostics for simeval
- [ ] Add diagnostics for sir
- [ ] Add diagnostics for sse
- [ ] Add diagnostics to compare several runs e.g. `compare(xpdb1, xpdb2)`


## Improvements
### High priority
- [ ] Update xpose functions to use rlang instead of the standard evaluation version of tidyverse functions (e.g. `mutate_()`)
- [ ] Collect (from the lst file) and make use of parameter labels and units in plot labels
- [ ] Get shrinkage in summary from PsN shrinkage and .shk file
- [ ] Improve `get_file()` to handle 2x same method, same issue with all file dependent functions
- [ ] Improve integration of additional modeling tools by using more generic functions
- [ ] Improve plotting of single line point when surrounded by NA (vpc/ind_plots):

1. Identify line points that are "alone"
1. Have a special `geom_point()` mapped after the line aesthetics that is only plotted if single points are required?


### Low priority
- [ ] Improve the use of color, shape scales in `ind_plots()` and `vpc()`, e.g. add color scale options to the xp_theme
- [ ] Find a way to add doses (bolus and infusion) to individual plots (shaded areas and/or vertical lines)
- [ ] Improve `xp_theme()` use with a + method as in ggplot2 (e.g. [here](https://github.com/tidyverse/ggplot2/blob/master/R/theme.r>))
- [ ] Allow `eta_*()` functions to read ETA values from table data or .phi file?
- [ ] Should `@nobs` `@nsim` `@nind` values be updated when using filtering of the data?
- [ ] Use the `kappa()` function to calculate the condition number directly?


## Satelite packages development
- [ ] *xpose_shiny*: a click based shiny interface for xpose
- [ ] *xpose_monolix*: add support for monolix *[help wanted]*
- [ ] others ...


## Will not do
- [x] Use [delayed assignment](https://github.com/hadley/pryr/blob/master/R/assign-delayed.r) for data importation
- [x] Use general `aes` assignment (e.g. `color =` will impact point + lines) targeting `ggplot()`

2 changes: 1 addition & 1 deletion docs/articles/about.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 420e09c

Please sign in to comment.