From 96e54339157a0758726f5a6836dc394b73affefb Mon Sep 17 00:00:00 2001 From: "Matthew L. Fidler" Date: Tue, 28 Nov 2023 20:37:38 -0600 Subject: [PATCH] Grab missing 1.2.10 release and add 1.2.11 info & fix man --- DESCRIPTION | 2 +- NEWS.md | 13 ++++-- R/ggPMX-options.R | 2 +- R/plot-density.R | 24 +++++----- R/plot-distribution.R | 22 ++++----- R/plot-eta-cov.R | 6 +-- R/plot-qq.R | 12 ++--- R/plot-residual.R | 14 +++--- R/plot-vpc.R | 44 +++++++++--------- R/pmx_read_nm_model.R | 98 ++++++++++++++++++++-------------------- R/read_extfile.R | 74 ++++++++++++++---------------- man/distrib.Rd | 18 ++++---- man/eta_cov.Rd | 6 +-- man/pmxOptions.Rd | 2 +- man/pmx_dens.Rd | 24 +++++----- man/pmx_qq.Rd | 12 ++--- man/pmx_read_nm_model.Rd | 18 ++++---- man/pmx_vpc_ci.Rd | 16 +++---- man/pmx_vpc_pi.Rd | 28 ++++++------ man/read_extfile.Rd | 6 +-- man/residual.Rd | 14 +++--- 21 files changed, 228 insertions(+), 227 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 52f8ff8e..629028f4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -11,7 +11,7 @@ Description: At Novartis, we aimed at standardizing the set of diagnostic plots . When 'lixoftConnectors' is available, 'R' can use 'Monolix' directly to create the required Chart Data instead of exporting it from the 'Monolix' gui. -Version: 1.2.10 +Version: 1.2.11 Authors@R: c( person("Amine", "Gassem", email="contact@ag-study.com", role=c("aut")), person("Bruno", "Bieth", email="biethb@hotmail.com", role="aut"), diff --git a/NEWS.md b/NEWS.md index 93e03c13..3fd82a4d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,11 +1,16 @@ -# ggPMX 1.2.10 +# ggPMX 1.2.11 -- Fix bug so that reading monolix works on R devel (as requested by CRAN) +* Fix bug so that reading monolix works on R devel (as requested by CRAN) -- Change defaults so that scientific notation is not enabled by default +* Change defaults so that scientific notation is not enabled by default and title is also not added by default -- Monolix 2023 can now be read by ggPMX +* Monolix 2023 can now be read by ggPMX + +# ggPMX 1.2.10 + +* Skip draft parameter template creation test on CRAN, on some systems + it doesn't seem to work correctly. # ggPMX 1.2.9 diff --git a/R/ggPMX-options.R b/R/ggPMX-options.R index c3e2eb89..5c561103 100755 --- a/R/ggPMX-options.R +++ b/R/ggPMX-options.R @@ -56,7 +56,7 @@ getPmxOption <- function(name, default = NULL) { #' @section Options used in ggPMX: #' #' \itemize{ -#' \item {\strong{template_dir:}} {path to template directory} +#' \item \strong{template_dir:} path to template directory #' } #' #' @examples diff --git a/R/plot-density.R b/R/plot-density.R index a7a6fbc9..487305e8 100644 --- a/R/plot-density.R +++ b/R/plot-density.R @@ -19,30 +19,30 @@ #' #' \strong{labels} is a list that contains: #' \itemize{ -#' \item {\strong{title:}} {plot title default "IWRES density plot"} -#' \item {\strong{x:}} {x axis label default to "Etas"} -#' \item {\strong{y:}} {y axis label default to empty} +#' \item \strong{title:} plot title default "IWRES density plot" +#' \item \strong{x:} x axis label default to "Etas" +#' \item \strong{y:} y axis label default to empty #' } #' #' \strong{var_line} is a list that contains: #' \itemize{ -#' \item {\strong{linetype:}} {default to 1} -#' \item {\strong{color:}} {default to black} -#' \item {\strong{linewidth:}} {default to 1} +#' \item \strong{linetype:} default to 1 +#' \item \strong{color:} default to black +#' \item \strong{linewidth:} default to 1 #' } #' #' \strong{snd_line} is a list that contains: #' \itemize{ -#' \item {\strong{linetype:}} {default to 2} -#' \item {\strong{color:}} {default to black} -#' \item {\strong{linewidth:}} {default to 1} +#' \item \strong{linetype:} default to 2 +#' \item \strong{color:} default to black +#' \item \strong{linewidth:} default to 1 #' } #' #' \strong{vline} is a list that contains: #' \itemize{ -#' \item {\strong{linetype:}} {default to 3} -#' \item {\strong{color:}} {default to black} -#' \item {\strong{linewidth:}} {default to 1} +#' \item \strong{linetype:} default to 3 +#' \item \strong{color:} default to black +#' \item \strong{linewidth:} default to 1 #' } #' pmx_dens <- function( diff --git a/R/plot-distribution.R b/R/plot-distribution.R index 51b2e7af..df2b40de 100755 --- a/R/plot-distribution.R +++ b/R/plot-distribution.R @@ -19,18 +19,18 @@ #' #' \strong{labels} is a list that contains: #' \itemize{ -#' \item {\strong{title:}} {plot title default "EBE distribution"} -#' \item {\strong{subtitle:}} {plot subtitle default empty} -#' \item {\strong{x:}} {x axis label default to "Etas"} -#' \item {\strong{y:}} {y axis label default to empty} -#' \item {\strong{legend:}} {legend title default to "random Effect"} +#' \item \strong{title:} plot title default "EBE distribution" +#' \item \strong{subtitle:} plot subtitle default empty +#' \item \strong{x:} x axis label default to "Etas" +#' \item \strong{y:} y axis label default to empty +#' \item \strong{legend:} legend title default to "random Effect" #' } #' \strong{shrink} is a list that contains: #' \itemize{ -#' \item {\strong{fun:}} {shrinkage function can be \code{sd} or \code{var}} -#' \item {\strong{size:}} {shrinkage text size} -#' \item {\strong{color:}} {shrinkage text color} -#' \item {\strong{vjust:}} {shrinkage position vertical adjustment} +#' \item \strong{fun:} shrinkage function can be \code{sd} or \code{var} +#' \item \strong{size:} shrinkage text size +#' \item \strong{color:} shrinkage text color +#' \item \strong{vjust:} shrinkage position vertical adjustment #' } distrib <- function( labels, @@ -109,11 +109,11 @@ wrap_formula <- function(x, origin = "lfacet") { } jitter_layer <- function(jitter, strat.color) { - + if (is.null(jitter)){ stop("jitter cannot be null") } - + if (is.null(strat.color)) { jitter$height <- 0 #no jitter in height (y-axis required) do.call(geom_jitter, jitter) diff --git a/R/plot-eta-cov.R b/R/plot-eta-cov.R index 9b006e80..8d8b3601 100644 --- a/R/plot-eta-cov.R +++ b/R/plot-eta-cov.R @@ -50,9 +50,9 @@ is_pmxcov <- function(x) #' #' \strong{labels} is a list that contains: #' \itemize{ -#' \item {\strong{title:}} {plot title default "EBE vs. covariates"} -#' \item {\strong{x:}} {x axis label default to "Etas"} -#' \item {\strong{y:}} {y axis label default to empty} +#' \item \strong{title:} plot title default "EBE vs. covariates" +#' \item \strong{x:} x axis label default to "Etas" +#' \item \strong{y:} y axis label default to empty #' } eta_cov <- function( labels, diff --git a/R/plot-qq.R b/R/plot-qq.R index 6e608247..516bc752 100644 --- a/R/plot-qq.R +++ b/R/plot-qq.R @@ -42,16 +42,16 @@ pmx_qq_stats <- function(points) { #' #' \strong{labels} is a list that contains: #' \itemize{ -#' \item {\strong{title:}} {plot title default "EBE vs. covariates"} -#' \item {\strong{x:}} {x axis label default to "Etas"} -#' \item {\strong{y:}} {y axis label default to empty} +#' \item \strong{title:} plot title default "EBE vs. covariates" +#' \item \strong{x:} x axis label default to "Etas" +#' \item \strong{y:} y axis label default to empty #' } #' #' \strong{point} is a list that contains: #' \itemize{ -#' \item {\strong{shape:}} {default to 1} -#' \item {\strong{color:}} {default to black} -#' \item {\strong{size:}} {default to 1} +#' \item \strong{shape:} default to 1 +#' \item \strong{color:} default to black +#' \item \strong{size:} default to 1 #' } #' @param is.hline logical if TRUE add horizontal line y=0 ( TRUE by default) #' @param hline geom hline graphical parameters diff --git a/R/plot-residual.R b/R/plot-residual.R index aa68c101..133f004e 100755 --- a/R/plot-residual.R +++ b/R/plot-residual.R @@ -20,17 +20,17 @@ #' #' \strong{point} is a list that contains: #' \itemize{ -#' \item {\strong{shape:}} {default to 1} -#' \item {\strong{color:}} {default to black} -#' \item {\strong{size:}} {default to 1} +#' \item \strong{shape:} default to 1 +#' \item \strong{color:} default to black +#' \item \strong{size:} default to 1 #' } #' #' \strong{labels} is a list that contains: #' \itemize{ -#' \item {\strong{title:}} {plot title default to AES_X versus AES_Y} -#' \item {\strong{subtitle:}} {plot subtitle default empty} -#' \item {\strong{x:}} {x axis label default to AES_X} -#' \item {\strong{y:}} {y axis label default to AES_Y} +#' \item \strong{title:} plot title default to AES_X versus AES_Y +#' \item \strong{subtitle:} plot subtitle default empty +#' \item \strong{x:} x axis label default to AES_X +#' \item \strong{y:} y axis label default to AES_Y #' } residual <- function(x, y, labels = NULL, point = NULL, is.hline = FALSE, hline = NULL, dname = NULL, facets = NULL, bloq = NULL, diff --git a/R/plot-vpc.R b/R/plot-vpc.R index 5dedbbfc..0c804771 100644 --- a/R/plot-vpc.R +++ b/R/plot-vpc.R @@ -65,10 +65,10 @@ pmx_vpc_obs <- #' #' @param show \code{charcater} how lines are displayed: #' \itemize{ -#' \item {\strong{show=all}} {lines will be displayed for each of -#' the 3 percentiles. with a shaded area.} -#' \item {\strong{show=median}} {Show only median line.} -#' \item {\strong{show=area}} {Show only median line and the shaded area} +#' \item \strong{show=all} lines will be displayed for each of +#' the 3 percentiles. with a shaded area. +#' \item \strong{show=median} Show only median line. +#' \item \strong{show=area} Show only median line and the shaded area #' } @@ -76,23 +76,23 @@ pmx_vpc_obs <- #' to \code{c(.05,.95)} #' @param median \code{list} containing: \cr #' \itemize{ -#' \item {\strong{color}} {\code{charcater} Color of the median percentile line. Default: "#000000". } -#' \item {\strong{linewidth}} {\code{numeric} Thickness of the median percentile line. Default: 1.} -#' \item {\strong{alpha}} {\code{numeric} Transparency of the median percentile line. Default: 0.7.} -#' \item {\strong{linetype}} {\code{charcater} Linetype of the median percentile line. Default: "solid".} +#' \item \strong{color} \code{charcater} Color of the median percentile line. Default: "#000000". +#' \item \strong{linewidth} \code{numeric} Thickness of the median percentile line. Default: 1. +#' \item \strong{alpha} \code{numeric} Transparency of the median percentile line. Default: 0.7. +#' \item \strong{linetype} \code{charcater} Linetype of the median percentile line. Default: "solid". #' } #' @param extreme \code{list} containing: \cr #' \itemize{ -#' \item {\strong{color}} {\code{charcater} Color of the median percentile line. Default: "#000000". } -#' \item {\strong{linewidth}} {\code{numeric} Thickness of the median percentile line. Default: 1.} -#' \item {\strong{alpha}} {\code{numeric} Transparency of the median percentile line. Default: 0.7.} -#' \item {\strong{linetype}} {\code{charcater} Linetype of the median percentile line. Default: "solid"} +#' \item \strong{color} \code{charcater} Color of the median percentile line. Default: "#000000". +#' \item \strong{linewidth} \code{numeric} Thickness of the median percentile line. Default: 1. +#' \item \strong{alpha} \code{numeric} Transparency of the median percentile line. Default: 0.7. +#' \item \strong{linetype} \code{charcater} Linetype of the median percentile line. Default: "solid" #' } #' @param area \code{list} containing: \cr #' \itemize{ -#' \item {\strong{fill}} {\code{charcater} Color of the shaded area. Default: "blue". } -#' \item {\strong{alpha}} {\code{numeric} Transparency of the sahded area. Default: 0.1.} +#' \item \strong{fill} \code{charcater} Color of the shaded area. Default: "blue". +#' \item \strong{alpha} \code{numeric} Transparency of the sahded area. Default: 0.1. #' } #' #' @family vpc @@ -142,27 +142,27 @@ pmx_vpc_pi <- #' @param show \code{charcater} how areas are displayed: #' \itemize{ -#' \item {\strong{show="all"}} {areas will be displayed for each of the 3 percentiles. } -#' \item {\strong{show="median"}} {Show only median area.} +#' \item \strong{show="all"} areas will be displayed for each of the 3 percentiles. +#' \item \strong{show="median"} Show only median area. #' } #' @param interval \code{numeric} quantiles values default to \code{c(.05,.95)} #' @param method \code{charcater} which areas are displayed: #' \itemize{ -#' \item {\strong{method="ribbon"}} {areas are ribbons.} -#' \item {\strong{method="rectangle"}} {ares are horizontal rectangles.} +#' \item \strong{method="ribbon"} areas are ribbons. +#' \item \strong{method="rectangle"} areas are horizontal rectangles. #' } #' @param median \code{list} containing: \cr #' \itemize{ -#' \item {\strong{fill}} { \code{character} Color of the area representing the CI for the median. Default: "#3388cc".} -#' \item {\strong{alpha}} {\code{numeric} Transparency of the area representing the PI for the median. Default=0.3.} +#' \item \strong{fill} \code{character} Color of the area representing the CI for the median. Default: "#3388cc". +#' \item \strong{alpha} \code{numeric} Transparency of the area representing the PI for the median. Default=0.3. #' } #' @param extreme \code{list} containing: \cr #' \itemize{ -#' \item {\strong{fill}} {\code{character} Color of the area representing the CI for the extreme percentiles. Default: "#3388cc".} -#' \item {\strong{alpha}} {\code{numeric} Transparency of the area representing the PI for the extreme percentiles. Default=0.3.} +#' \item \strong{fill} \code{character} Color of the area representing the CI for the extreme percentiles. Default: "#3388cc". +#' \item \strong{alpha} \code{numeric} Transparency of the area representing the PI for the extreme percentiles. Default=0.3. #' } #' #' @export diff --git a/R/pmx_read_nm_model.R b/R/pmx_read_nm_model.R index bd1d3b8b..0e182535 100644 --- a/R/pmx_read_nm_model.R +++ b/R/pmx_read_nm_model.R @@ -2,48 +2,48 @@ #' NONMEM model file parser #' #' @description Parse NONMEM model files in R format -#' +#' #' @seealso \code{\link{pmx_read_nm_tables}} -#' @return A \code{\link[dplyr]{tibble}} of class \code{model} containing the following columns: +#' @return A \code{\link[dplyr]{tibble}} of class \code{model} containing the following columns: #' \itemize{ -#' \item{\strong{problem}}{: a numeric identifier for the $PROBLEM associated with the code.} -#' \item{\strong{level}}{: a unique numeric identifier to each subroutine block associated with the code.} -#' \item{\strong{subroutine}}{: a character identifier named after the 3 first letters of the subroutine name e.g. '$THETA' and -#' '$TABLE' will become 'the' and 'tab' respectively. In addition all output from the .lst is labeled 'lst', the general nonmem -#' output e.g. NM-TRAN messages are labelled 'oth'. With priors thp, tpv, omp, opd, sip, spd abbreviations are given to the THETAP, -#' THETAPV, OMEGAP, etc.} -#' \item{\strong{code}}{: the code without comments or subroutine names e.g. '$THETA 0.5 ; TVCL' will return '0.5'.} -#' \item{\strong{comment}}{: the last comment of a record e.g. '0.5 ; Clearance (L/h) ; TVCL' will return 'TVCL'.} +#' \item \strong{problem}: a numeric identifier for the $PROBLEM associated with the code. +#' \item \strong{level}: a unique numeric identifier to each subroutine block associated with the code. +#' \item \strong{subroutine}: a character identifier named after the 3 first letters of the subroutine name e.g. '$THETA' and +#' '$TABLE' will become 'the' and 'tab' respectively. In addition all output from the .lst is labeled 'lst', the general nonmem +#' output e.g. NM-TRAN messages are labelled 'oth'. With priors thp, tpv, omp, opd, sip, spd abbreviations are given to the THETAP, +#' THETAPV, OMEGAP, etc. +#' \item \strong{code}: the code without comments or subroutine names e.g. '$THETA 0.5 ; TVCL' will return '0.5'. +#' \item \strong{comment}: the last comment of a record e.g. '0.5 ; Clearance (L/h) ; TVCL' will return 'TVCL'. #' } -#' +#' #' @param runno run number which is used for generating the model file name #' @param prefix Prefix to be used to generate model file name. Used in combination with \code{runno} and \code{ext}. #' @param ext Extension to be used to generate model file name. Should be one of'.lst' (default), '.out', '.res', '.mod' or '.ctl' for NONMEM. #' @param file A character vector of path to the files or a \code{nm_table_list} object created with \code{list_nm_tables}. #' @param dir directory of the model files. -#' +#' #' @examples #' \dontrun{ #' # Using the `file` argument to import a model file: #' nm_model <- pmx_read_nm_model(file = 'run001.lst', dir = 'models') -#' +#' #' # Using the `runno` argument to import a model file: #' nm_model <- pmx_read_nm_model(runno = '001', ext = '.lst', dir = 'models') #' } -#' +#' pmx_read_nm_model <- function(runno = NULL, prefix = 'run', ext = '.lst', file = NULL, dir = NULL) { - + . <- NULL - + if (is.null(runno) && is.null(file)) { stop('Argument `runno` or `file` required.', call. = FALSE) } - + if (!is.null(runno)) { ext <- pmx_make_extension(ext) full_path <- pmx_file_path(dir, stringr::str_c(prefix, runno, ext)) @@ -51,92 +51,92 @@ pmx_read_nm_model <- function(runno = NULL, ext <- pmx_get_extension(file) full_path <- pmx_file_path(dir, file) } - + if (!ext %in% c('.lst', '.out', '.res', '.mod', '.ctl')) { - stop('NONMEM model file extension should be one lst, out, res, mod or ctl.', call. = FALSE) + stop('NONMEM model file extension should be one lst, out, res, mod or ctl.', call. = FALSE) } - - if (!file.exists(full_path)) { - stop('Model file ', basename(full_path), ' not found.', call. = FALSE) + + if (!file.exists(full_path)) { + stop('Model file ', basename(full_path), ' not found.', call. = FALSE) } - + model <- readr::read_lines(full_path) - + if (!any(stringr::str_detect(model, '^\\s*\\$PROB.+')) && ext %in% c('.lst', '.out', '.res')) { # Attempts to recover the model code from model file rather than in the nonmem output file full_path <- pmx_update_extension(full_path, c('.mod', '.ctl')) full_path <- full_path[file.exists(full_path)] - + if (any(file.exists(full_path))) { - warning(c('No model code found in `', ext, '` NONMEM output file importing `', + warning(c('No model code found in `', ext, '` NONMEM output file importing `', pmx_get_extension(full_path)[1], '` instead.'), call. = FALSE) model <- readr::read_lines(full_path[1]) } } - + # Return error if input is bad if (!any(stringr::str_detect(model, '^\\s*\\$PROB.+'))) { stop(basename(full_path), ' is not a NONMEM model.', call. = FALSE) } - - model <- dplyr::tibble(code = model) %>% - dplyr::filter(!stringr::str_detect(.$code, '^;[^;]*$|^$')) %>% - dplyr::mutate(code = stringr::str_replace_all(.$code, '\\t+|\\s{2,}', ' ')) %>% + + model <- dplyr::tibble(code = model) %>% + dplyr::filter(!stringr::str_detect(.$code, '^;[^;]*$|^$')) %>% + dplyr::mutate(code = stringr::str_replace_all(.$code, '\\t+|\\s{2,}', ' ')) %>% dplyr::mutate( problem = findInterval(seq_along(.$code), which(stringr::str_detect(.$code, '^\\s*\\$PROB.+'))), level = findInterval(seq_along(.$code), which(stringr::str_detect(.$code, '^\\s*\\$.+'))), - subroutine = stringr::str_match(.$code, '^\\s*\\$(\\w+)')[, 2]) %>% + subroutine = stringr::str_match(.$code, '^\\s*\\$(\\w+)')[, 2]) %>% tidyr::fill(dplyr::one_of('subroutine')) - + # Generate abbreviated subroutine names special <- c('THETAI', 'THETAR', 'THETAP', 'THETAPV', 'OMEGAP', 'OMEGAPD', 'SIGMAP', 'SIGMAPD') match_special <- match(model$subroutine[model$subroutine %in% special], special) - model$subroutine[model$subroutine %in% special] <- c('thi', 'thr', 'thp', 'tpv', + model$subroutine[model$subroutine %in% special] <- c('thi', 'thr', 'thp', 'tpv', 'omp', 'opd', 'sip', 'spd')[match_special] model$subroutine <- stringr::str_extract(tolower(model$subroutine), '[a-z]{1,3}') - + # Format lst part if (any(stringr::str_detect(model$code, 'NM-TRAN MESSAGES'))) { lst_rows <- which(stringr::str_detect(model$code, 'NM-TRAN MESSAGES')):nrow(model) - model[lst_rows,] <- model %>% - dplyr::slice(lst_rows) %>% - dplyr::mutate(problem = findInterval(seq_along(.$problem), - which(stringr::str_detect(.$code, '^\\s*PROBLEM NO\\.:\\s*\\d+$')))) %>% + model[lst_rows,] <- model %>% + dplyr::slice(lst_rows) %>% + dplyr::mutate(problem = findInterval(seq_along(.$problem), + which(stringr::str_detect(.$code, '^\\s*PROBLEM NO\\.:\\s*\\d+$')))) %>% dplyr::mutate(level = 1 + .$level[1] + .$problem, subroutine = 'lst') } - + # Handle other special cases if (any(stringr::str_detect(model$code, '#CPUT'))) { cput_row <- which(stringr::str_detect(model$code, '#CPUT')) model[cput_row, 'problem'] <- 0 model[cput_row:nrow(model), 'level'] <- model[cput_row:nrow(model), ]$level + 1 } - + if (any(stringr::str_detect(model$code, 'Stop Time'))) { end_rows <- which(stringr::str_detect(model$code, 'Stop Time')):nrow(model) model[end_rows, 'problem'] <- 0 model[end_rows, 'level'] <- model[end_rows[1], ]$level + 1 } - + model[is.na(model$subroutine) | (model$problem == 0 & model$subroutine == 'lst'), 'subroutine'] <- 'oth' - + # Remove subroutine names from the code model$code <- stringr::str_replace(model$code, '^\\s*\\$\\w+\\s*', '') - + # Remove empty rows but $PROBLEM model <- model[!stringr::str_detect(model$code, '^(\\s|\\t)*$') | model$subroutine == 'pro', ] - + # Create comment column code_rows <- !model$subroutine %in% c('lst', 'oth') | model$level == 0 model[code_rows, 'comment'] <- stringr::str_match(model[code_rows, ]$code, ';\\s*(.*)\\s*$')[, 2] model[code_rows, 'code'] <- stringr::str_replace(model[code_rows, ]$code, '\\s*;.*$', '') - + # Remove na values and output - tidyr::replace_na(model, replace = list(code = '', comment = '')) %>% - dplyr::select(dplyr::one_of(c('problem', 'level', 'subroutine', 'code', 'comment'))) %>% + tidyr::replace_na(model, replace = list(code = '', comment = '')) %>% + dplyr::select(dplyr::one_of(c('problem', 'level', 'subroutine', 'code', 'comment'))) %>% dplyr::mutate(problem = as.integer(.$problem), - level = as.integer(.$level)) %>% + level = as.integer(.$level)) %>% structure(file = basename(full_path), dir = dirname(full_path), software = 'nonmem', diff --git a/R/read_extfile.R b/R/read_extfile.R index adcbf59e..88e15e2d 100755 --- a/R/read_extfile.R +++ b/R/read_extfile.R @@ -1,4 +1,3 @@ -# This code is strongly based on the read_nmext function of mrgsolve (nmxml.R) (Thanks to Kyle T Baron) #' Reads .ext files generated by NONMEM @@ -9,7 +8,7 @@ #' @param path path full path and file name for `ext` file #' @param read_fun read_fun function to read the `ext` file #' @param quiet Logical, if \code{FALSE} messages are printed to the console. -#' +#' #' @author This function is based on read_nmext from mrgsolve, Original Author: Kyle T Baron. #' This function has some changes to the original code: #'Addition of param, "quiet", (option of pmx_msg function, from xpose package) (Line: 27) @@ -17,41 +16,41 @@ #'The output was also slightly adjusted to fit ggPMX output (df and df2) (Line: 105,106) #'as_bmat was replaced by bmat_like to create the diagonal matrix (Line 116:142) #' -#' @return A list with param, omega, and sigma in a format -#' ready to be used. +#' @return A list with param, omega, and sigma in a format +#' ready to be used. #' @export #' #' @examples -#' #project <- system.file("nonmem", package = "mrgsolve") -#' #est <- read_nmext(1005, project = project) +#' #project <- system.file("nonmem", package = "mrgsolve") +#' #est <- read_nmext(1005, project = project) -read_extfile <- function(run=NA_real_, project = getwd(), file=paste0(run,".ext"), +read_extfile <- function(run=NA_real_, project = getwd(), file=paste0(run,".ext"), path=NULL, read_fun = c("data.table","read.table"),quiet) { - + if(is.character(path)) { - extfile <- path + extfile <- path } else { extfile <- file.path(project,run,file) } - + if(!file.exists(extfile)) { - stop("[read_nmext] could not find the requested 'ext' file ", + stop("[read_nmext] could not find the requested 'ext' file ", shQuote(basename(extfile))) } - + read_fun <- match.arg(read_fun) - + use_dt <- requireNamespace("data.table",quietly=TRUE) & read_fun=="data.table" - + ## Check for multiple tables/problems - + ext_tmp <- readLines(extfile) inds <- grep("TABLE",ext_tmp) last_table <- 0 ## Check if multiple Problems are found in .ext file - + if (length(inds)!=1){ last_table <- inds[length(inds)] colon <- regexpr(":",ext_tmp[last_table])[1] @@ -59,13 +58,13 @@ read_extfile <- function(run=NA_real_, project = getwd(), file=paste0(run,".ext" last_table <- last_table-1 pmx_msg(paste("Multiple Problems found in",file,"only using",last_table_name,"\n"),quiet) #multiple problems not currently supported, only using last table } - + ## Read .ext file - + if(use_dt) { df <- data.table::fread( - file=extfile, - na.strings = '.', + file=extfile, + na.strings = '.', data.table=FALSE, skip=last_table+1 ) @@ -74,25 +73,25 @@ read_extfile <- function(run=NA_real_, project = getwd(), file=paste0(run,".ext" file=extfile, na.strings='.', stringsAsFactors=FALSE, - skip=last_table+1, + skip=last_table+1, header=TRUE ) } - + ## Get parameters and standard errors - + #get parameters ans <- "" ans <- df[df[["ITERATION"]] == -1E9,] bmat_ans <- ans #in order to use bmat_like function df_ans <- ans - - + + #get standard erros ans_se <- "" ans_se <- df[df[["ITERATION"]] == -1000000001,] df_ans_se <- ans_se - + if(nrow(ans)==0) { stop( "[read_nmext] could not find final estimates", @@ -102,18 +101,18 @@ read_extfile <- function(run=NA_real_, project = getwd(), file=paste0(run,".ext" #get numbers of "OMEGA" or "SIGMA" used in bmat_like get_num <- function(x,string){ #last_om = x - + nums <- gsub(paste0(".*",string,"|[()]"), "", x) - + num1 <- as.numeric(gsub(",.*", "", nums)) num2 <- as.numeric(gsub(".*,", "", nums)) - + num_vec <- c(num1,num2) - + return(num_vec) - + } - + #uses bmat_ans as an input and gives out diagonal matrix bmat_like <- function(x,string) { y <- x[grep(string,names(x))] @@ -124,7 +123,7 @@ read_extfile <- function(run=NA_real_, project = getwd(), file=paste0(run,".ext" pre_mat <- matrix(nrow = num, ncol = num) mat <- pre_mat mat[] <- 0 - + i <- 1 for (i in i:len_y) { om <- y[i] @@ -132,15 +131,15 @@ read_extfile <- function(run=NA_real_, project = getwd(), file=paste0(run,".ext" pos <- get_num(nam_om,string) mat[pos[1],pos[2]] <- om[[1]] } - + return(mat) } - + ans <- as.list(ans) names(ans) <- gsub("[[:punct:]]", "", names(ans)) ans <- list( param = ans[grepl("THETA", names(ans))], - omega = bmat_like(bmat_ans, "OMEGA"), + omega = bmat_like(bmat_ans, "OMEGA"), sigma = bmat_like(bmat_ans, "SIGMA"), raw = ans, df = df_ans, @@ -148,6 +147,3 @@ read_extfile <- function(run=NA_real_, project = getwd(), file=paste0(run,".ext" ) return(ans) } - - - diff --git a/man/distrib.Rd b/man/distrib.Rd index 5f171aa9..38bdd3e3 100644 --- a/man/distrib.Rd +++ b/man/distrib.Rd @@ -48,18 +48,18 @@ creates a graphic distribution object \details{ \strong{labels} is a list that contains: \itemize{ -\item {\strong{title:}} {plot title default "EBE distribution"} -\item {\strong{subtitle:}} {plot subtitle default empty} -\item {\strong{x:}} {x axis label default to "Etas"} -\item {\strong{y:}} {y axis label default to empty} -\item {\strong{legend:}} {legend title default to "random Effect"} +\item \strong{title:} plot title default "EBE distribution" +\item \strong{subtitle:} plot subtitle default empty +\item \strong{x:} x axis label default to "Etas" +\item \strong{y:} y axis label default to empty +\item \strong{legend:} legend title default to "random Effect" } \strong{shrink} is a list that contains: \itemize{ -\item {\strong{fun:}} {shrinkage function can be \code{sd} or \code{var}} -\item {\strong{size:}} {shrinkage text size} -\item {\strong{color:}} {shrinkage text color} -\item {\strong{vjust:}} {shrinkage position vertical adjustment} +\item \strong{fun:} shrinkage function can be \code{sd} or \code{var} +\item \strong{size:} shrinkage text size +\item \strong{color:} shrinkage text color +\item \strong{vjust:} shrinkage position vertical adjustment } } \seealso{ diff --git a/man/eta_cov.Rd b/man/eta_cov.Rd index eb32306f..c737262d 100644 --- a/man/eta_cov.Rd +++ b/man/eta_cov.Rd @@ -49,9 +49,9 @@ its shrinkage.. \details{ \strong{labels} is a list that contains: \itemize{ -\item {\strong{title:}} {plot title default "EBE vs. covariates"} -\item {\strong{x:}} {x axis label default to "Etas"} -\item {\strong{y:}} {y axis label default to empty} +\item \strong{title:} plot title default "EBE vs. covariates" +\item \strong{x:} x axis label default to "Etas" +\item \strong{y:} y axis label default to empty } } \seealso{ diff --git a/man/pmxOptions.Rd b/man/pmxOptions.Rd index 6b25af91..874d91de 100644 --- a/man/pmxOptions.Rd +++ b/man/pmxOptions.Rd @@ -21,7 +21,7 @@ There is a global option set, which is available by default. \itemize{ -\item {\strong{template_dir:}} {path to template directory} +\item \strong{template_dir:} path to template directory } } diff --git a/man/pmx_dens.Rd b/man/pmx_dens.Rd index cb955ba5..844c3b1b 100644 --- a/man/pmx_dens.Rd +++ b/man/pmx_dens.Rd @@ -41,29 +41,29 @@ Creates a density plot object \details{ \strong{labels} is a list that contains: \itemize{ -\item {\strong{title:}} {plot title default "IWRES density plot"} -\item {\strong{x:}} {x axis label default to "Etas"} -\item {\strong{y:}} {y axis label default to empty} +\item \strong{title:} plot title default "IWRES density plot" +\item \strong{x:} x axis label default to "Etas" +\item \strong{y:} y axis label default to empty } \strong{var_line} is a list that contains: \itemize{ -\item {\strong{linetype:}} {default to 1} -\item {\strong{color:}} {default to black} -\item {\strong{linewidth:}} {default to 1} +\item \strong{linetype:} default to 1 +\item \strong{color:} default to black +\item \strong{linewidth:} default to 1 } \strong{snd_line} is a list that contains: \itemize{ -\item {\strong{linetype:}} {default to 2} -\item {\strong{color:}} {default to black} -\item {\strong{linewidth:}} {default to 1} +\item \strong{linetype:} default to 2 +\item \strong{color:} default to black +\item \strong{linewidth:} default to 1 } \strong{vline} is a list that contains: \itemize{ -\item {\strong{linetype:}} {default to 3} -\item {\strong{color:}} {default to black} -\item {\strong{linewidth:}} {default to 1} +\item \strong{linetype:} default to 3 +\item \strong{color:} default to black +\item \strong{linewidth:} default to 1 } } diff --git a/man/pmx_qq.Rd b/man/pmx_qq.Rd index c4804b26..32464803 100644 --- a/man/pmx_qq.Rd +++ b/man/pmx_qq.Rd @@ -63,16 +63,16 @@ This function creates a qq plot object \details{ \strong{labels} is a list that contains: \itemize{ -\item {\strong{title:}} {plot title default "EBE vs. covariates"} -\item {\strong{x:}} {x axis label default to "Etas"} -\item {\strong{y:}} {y axis label default to empty} +\item \strong{title:} plot title default "EBE vs. covariates" +\item \strong{x:} x axis label default to "Etas" +\item \strong{y:} y axis label default to empty } \strong{point} is a list that contains: \itemize{ -\item {\strong{shape:}} {default to 1} -\item {\strong{color:}} {default to black} -\item {\strong{size:}} {default to 1} +\item \strong{shape:} default to 1 +\item \strong{color:} default to black +\item \strong{size:} default to 1 } } \concept{qq_plot} diff --git a/man/pmx_read_nm_model.Rd b/man/pmx_read_nm_model.Rd index 75438afb..ac33cfb1 100644 --- a/man/pmx_read_nm_model.Rd +++ b/man/pmx_read_nm_model.Rd @@ -24,16 +24,16 @@ pmx_read_nm_model( \item{dir}{directory of the model files.} } \value{ -A \code{\link[dplyr]{tibble}} of class \code{model} containing the following columns: +A \code{\link[dplyr]{tibble}} of class \code{model} containing the following columns: \itemize{ - \item{\strong{problem}}{: a numeric identifier for the $PROBLEM associated with the code.} - \item{\strong{level}}{: a unique numeric identifier to each subroutine block associated with the code.} - \item{\strong{subroutine}}{: a character identifier named after the 3 first letters of the subroutine name e.g. '$THETA' and - '$TABLE' will become 'the' and 'tab' respectively. In addition all output from the .lst is labeled 'lst', the general nonmem - output e.g. NM-TRAN messages are labelled 'oth'. With priors thp, tpv, omp, opd, sip, spd abbreviations are given to the THETAP, - THETAPV, OMEGAP, etc.} - \item{\strong{code}}{: the code without comments or subroutine names e.g. '$THETA 0.5 ; TVCL' will return '0.5'.} - \item{\strong{comment}}{: the last comment of a record e.g. '0.5 ; Clearance (L/h) ; TVCL' will return 'TVCL'.} + \item \strong{problem}: a numeric identifier for the $PROBLEM associated with the code. + \item \strong{level}: a unique numeric identifier to each subroutine block associated with the code. + \item \strong{subroutine}: a character identifier named after the 3 first letters of the subroutine name e.g. '$THETA' and + '$TABLE' will become 'the' and 'tab' respectively. In addition all output from the .lst is labeled 'lst', the general nonmem + output e.g. NM-TRAN messages are labelled 'oth'. With priors thp, tpv, omp, opd, sip, spd abbreviations are given to the THETAP, + THETAPV, OMEGAP, etc. + \item \strong{code}: the code without comments or subroutine names e.g. '$THETA 0.5 ; TVCL' will return '0.5'. + \item \strong{comment}: the last comment of a record e.g. '0.5 ; Clearance (L/h) ; TVCL' will return 'TVCL'. } } \description{ diff --git a/man/pmx_vpc_ci.Rd b/man/pmx_vpc_ci.Rd index 532d223f..58ff0377 100644 --- a/man/pmx_vpc_ci.Rd +++ b/man/pmx_vpc_ci.Rd @@ -15,28 +15,28 @@ pmx_vpc_ci( \arguments{ \item{show}{\code{charcater} how areas are displayed: \itemize{ -\item {\strong{show="all"}} {areas will be displayed for each of the 3 percentiles. } -\item {\strong{show="median"}} {Show only median area.} +\item \strong{show="all"} areas will be displayed for each of the 3 percentiles. +\item \strong{show="median"} Show only median area. }} \item{interval}{\code{numeric} quantiles values default to \code{c(.05,.95)}} \item{method}{\code{charcater} which areas are displayed: \itemize{ -\item {\strong{method="ribbon"}} {areas are ribbons.} -\item {\strong{method="rectangle"}} {ares are horizontal rectangles.} +\item \strong{method="ribbon"} areas are ribbons. +\item \strong{method="rectangle"} areas are horizontal rectangles. }} \item{median}{\code{list} containing: \cr \itemize{ -\item {\strong{fill}} { \code{character} Color of the area representing the CI for the median. Default: "#3388cc".} -\item {\strong{alpha}} {\code{numeric} Transparency of the area representing the PI for the median. Default=0.3.} +\item \strong{fill} \code{character} Color of the area representing the CI for the median. Default: "#3388cc". +\item \strong{alpha} \code{numeric} Transparency of the area representing the PI for the median. Default=0.3. }} \item{extreme}{\code{list} containing: \cr \itemize{ -\item {\strong{fill}} {\code{character} Color of the area representing the CI for the extreme percentiles. Default: "#3388cc".} -\item {\strong{alpha}} {\code{numeric} Transparency of the area representing the PI for the extreme percentiles. Default=0.3.} +\item \strong{fill} \code{character} Color of the area representing the CI for the extreme percentiles. Default: "#3388cc". +\item \strong{alpha} \code{numeric} Transparency of the area representing the PI for the extreme percentiles. Default=0.3. }} } \description{ diff --git a/man/pmx_vpc_pi.Rd b/man/pmx_vpc_pi.Rd index 29587819..975c9de2 100644 --- a/man/pmx_vpc_pi.Rd +++ b/man/pmx_vpc_pi.Rd @@ -15,10 +15,10 @@ pmx_vpc_pi( \arguments{ \item{show}{\code{charcater} how lines are displayed: \itemize{ -\item {\strong{show=all}} {lines will be displayed for each of -the 3 percentiles. with a shaded area.} -\item {\strong{show=median}} {Show only median line.} -\item {\strong{show=area}} {Show only median line and the shaded area} +\item \strong{show=all} lines will be displayed for each of +the 3 percentiles. with a shaded area. +\item \strong{show=median} Show only median line. +\item \strong{show=area} Show only median line and the shaded area }} \item{interval}{\code{numeric} quantiles values default @@ -26,24 +26,24 @@ to \code{c(.05,.95)}} \item{median}{\code{list} containing: \cr \itemize{ -\item {\strong{color}} {\code{charcater} Color of the median percentile line. Default: "#000000". } -\item {\strong{linewidth}} {\code{numeric} Thickness of the median percentile line. Default: 1.} -\item {\strong{alpha}} {\code{numeric} Transparency of the median percentile line. Default: 0.7.} -\item {\strong{linetype}} {\code{charcater} Linetype of the median percentile line. Default: "solid".} +\item \strong{color} \code{charcater} Color of the median percentile line. Default: "#000000". +\item \strong{linewidth} \code{numeric} Thickness of the median percentile line. Default: 1. +\item \strong{alpha} \code{numeric} Transparency of the median percentile line. Default: 0.7. +\item \strong{linetype} \code{charcater} Linetype of the median percentile line. Default: "solid". }} \item{extreme}{\code{list} containing: \cr \itemize{ -\item {\strong{color}} {\code{charcater} Color of the median percentile line. Default: "#000000". } -\item {\strong{linewidth}} {\code{numeric} Thickness of the median percentile line. Default: 1.} -\item {\strong{alpha}} {\code{numeric} Transparency of the median percentile line. Default: 0.7.} -\item {\strong{linetype}} {\code{charcater} Linetype of the median percentile line. Default: "solid"} +\item \strong{color} \code{charcater} Color of the median percentile line. Default: "#000000". +\item \strong{linewidth} \code{numeric} Thickness of the median percentile line. Default: 1. +\item \strong{alpha} \code{numeric} Transparency of the median percentile line. Default: 0.7. +\item \strong{linetype} \code{charcater} Linetype of the median percentile line. Default: "solid" }} \item{area}{\code{list} containing: \cr \itemize{ -\item {\strong{fill}} {\code{charcater} Color of the shaded area. Default: "blue". } -\item {\strong{alpha}} {\code{numeric} Transparency of the sahded area. Default: 0.1.} +\item \strong{fill} \code{charcater} Color of the shaded area. Default: "blue". +\item \strong{alpha} \code{numeric} Transparency of the sahded area. Default: 0.1. }} } \description{ diff --git a/man/read_extfile.Rd b/man/read_extfile.Rd index d3d8d535..6338d149 100644 --- a/man/read_extfile.Rd +++ b/man/read_extfile.Rd @@ -27,15 +27,15 @@ read_extfile( \item{quiet}{Logical, if \code{FALSE} messages are printed to the console.} } \value{ -A list with param, omega, and sigma in a format +A list with param, omega, and sigma in a format ready to be used. } \description{ Reads .ext files generated by NONMEM } \examples{ -#project <- system.file("nonmem", package = "mrgsolve") -#est <- read_nmext(1005, project = project) +#project <- system.file("nonmem", package = "mrgsolve") +#est <- read_nmext(1005, project = project) } \author{ This function is based on read_nmext from mrgsolve, Original Author: Kyle T Baron. diff --git a/man/residual.Rd b/man/residual.Rd index 20278095..3b2abd20 100644 --- a/man/residual.Rd +++ b/man/residual.Rd @@ -54,17 +54,17 @@ Some parameters are a list of parameters : \strong{point} is a list that contains: \itemize{ -\item {\strong{shape:}} {default to 1} -\item {\strong{color:}} {default to black} -\item {\strong{size:}} {default to 1} +\item \strong{shape:} default to 1 +\item \strong{color:} default to black +\item \strong{size:} default to 1 } \strong{labels} is a list that contains: \itemize{ -\item {\strong{title:}} {plot title default to AES_X versus AES_Y} -\item {\strong{subtitle:}} {plot subtitle default empty} -\item {\strong{x:}} {x axis label default to AES_X} -\item {\strong{y:}} {y axis label default to AES_Y} +\item \strong{title:} plot title default to AES_X versus AES_Y +\item \strong{subtitle:} plot subtitle default empty +\item \strong{x:} x axis label default to AES_X +\item \strong{y:} y axis label default to AES_Y } } \seealso{