Title: | Interactive 'shiny' Dashboard for 'nlmixr2' |
---|---|
Description: | An R shiny user interface for the 'nlmixr2' (Fidler et al (2019) <doi:10.1002/psp4.12445>) package, designed to simplify the modeling process for users. Additionally, this package includes supplementary functions to further enhances the usage of 'nlmixr2'. |
Authors: | Richard Hooijmaijers [aut, cre, cph], Teun Post [aut, cph], LAPP Consultants [fnd, cph], Matthew Fidler [ctb], Veerle van Leemput [ctb] |
Maintainer: | Richard Hooijmaijers <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.5.0 |
Built: | 2024-11-18 06:27:38 UTC |
Source: | https://github.com/richardhooijmaijers/shinymixr |
regular expressions are used to search for meta data inside a model file. This meta data is then updated with the provided new values
adpt_meta(mdl, newvals)
adpt_meta(mdl, newvals)
mdl |
character with the name of the model to adapt |
newvals |
list with characteristics/meta data to adapt |
character vector with model including the adapted meta data
Richard Hooijmaijers
## Not run: adpt_meta("model.r",newvals=list(imp=4,ref="run 1")) ## End(Not run)
## Not run: adpt_meta("model.r",newvals=list(imp=4,ref="run 1")) ## End(Not run)
Creates a new project which basically means that within the specified folder, the necessary folder structure will be created and some example models will be placed in it.
create_proj(loc = ".", overwrite = FALSE)
create_proj(loc = ".", overwrite = FALSE)
loc |
character with the location where the project should be created |
overwrite |
logical indicating if files should be overwritten if already exists |
nothing will be returned by the function (only system commands are issued)
Richard Hooijmaijers
## Not run: create_proj() ## End(Not run)
## Not run: create_proj() ## End(Not run)
This function creates a text string for a ggplot based on an input list. This function is specifically written to be used with the shiny app for data exploration.
exploreplot(inputlist)
exploreplot(inputlist)
inputlist |
list with input items to create a plot |
a character string with the ggplot code
Richard Hooijmaijers
## Not run: exploreplot(input)
## Not run: exploreplot(input)
Creates a fit plot either using the xpose.nlmixr package or using a default ggplot call
fit_plot( dfrm, type = "xpose", by = "ID", idv = "TIME", obs = "DV", pred = "PRED", ipred = "IPRED", grp = "ID", logy = TRUE, scales = "fixed", mdlnm = NULL, outnm = NULL, projloc = ".", ... )
fit_plot( dfrm, type = "xpose", by = "ID", idv = "TIME", obs = "DV", pred = "PRED", ipred = "IPRED", grp = "ID", logy = TRUE, scales = "fixed", mdlnm = NULL, outnm = NULL, projloc = ".", ... )
dfrm |
data frame as created by the nlmixr function |
type |
character defining the type of plot that should be created. currently "xpose" and "user" are supported for xpose or ggplot style of plots |
by |
character vector with variables for facetting |
idv |
independent variable or x variable |
obs |
variable with observed data points |
pred |
variable with predicted data points |
ipred |
variable with individual predicted data points |
grp |
variable for grouping (mainly to draw separate lines) |
logy |
logical if y-axis should be displayed on log scale |
scales |
character of length one defining the scale parameter of ggplot (e.g. "fixed", "free","free_y",etc) |
mdlnm |
character with name of the model |
outnm |
character with name of the output file (see details) |
projloc |
character with the base location of the shinyMixR project |
... |
In case a model is saved, a directory with the name of the model is created within the analysis folder of the current project. Then within this folder the file is saved as outnm. This method was chosen so the interface can easily index applicable files for a certain model. However, this means that output is always saved in this directly regardless of the location of outnm
in case no outnm is defined a ggplot object will be returned otherwise the results are saved to disk
Richard Hooijmaijers
## Not run: fit_plot(res) ## End(Not run)
## Not run: fit_plot(res) ## End(Not run)
This function gets only the meta data from a function
get_meta(mdl)
get_meta(mdl)
mdl |
character with the path of the model function |
A list with the models meta data
## Not run: get_meta("run1.r") ## End(Not run)
## Not run: get_meta("run1.r") ## End(Not run)
This function creates or updates a project object with models and/or results emerged from nlmixr2 runs. A check is performed to see if newer results are present and only updates these.
get_proj(projloc = ".", geteval = TRUE)
get_proj(projloc = ".", geteval = TRUE)
projloc |
character with the base location of the shinyMixR project |
geteval |
logical indicating if the model functions should be evaluated |
A named list with information for each model in the 'projloc'
## Not run: proj <- get_proj() ## End(Not run)
## Not run: proj <- get_proj() ## End(Not run)
Creates goodness of fit plots either using the xpose.nlmixr package or using a default ggplot call
gof_plot( dfrm, type = "xpose", mdlnm = NULL, colby = NULL, ptype = "all", outnm = NULL, projloc = ".", title = NULL, linscale = FALSE, ... )
gof_plot( dfrm, type = "xpose", mdlnm = NULL, colby = NULL, ptype = "all", outnm = NULL, projloc = ".", title = NULL, linscale = FALSE, ... )
dfrm |
data frame as created by the nlmixr function |
type |
character defining the type of plot that should be created. currently "xpose" and "user" are supported for xpose or ggplot style of plots |
mdlnm |
character with name of the model |
colby |
character vector of length one specifying the variable to color on (for now can be only one variable) |
ptype |
The type of plots to create. Currently the following is accepted: "all", "ipred.dv", "pred.dv", "idv.res", "pred.res" |
outnm |
character with name of the output file (see details) |
projloc |
character with the base location of the shinyMixR project |
title |
character with the title to place above the plot |
linscale |
Logical indicating if the scales should be set to linear for DV, PRED and IPRED plots |
... |
In case a model is saved, a directory with the name of the model is created within the analysis folder of the current project. Then within this folder the file is saved as outnm. This method was chosen so the interface can easily index applicable files for a certain model. However, this means that output is always saved in this directly regardless of the location of outnm
in case no outnm is defined a ggplot object will be returned otherwise the results are saved to disk
Richard Hooijmaijers
## Not run: gof_plot(res) ## End(Not run)
## Not run: gof_plot(res) ## End(Not run)
A model name is incremented either by incrementing numerical or alpha numerical. Furthermore it is possible to check the existence of the incremented model and take this into account.
incr_mdl(mod, checkloc = NULL)
incr_mdl(mod, checkloc = NULL)
mod |
character with the model name |
checkloc |
character with the location to check for existence of a file |
character with the incremented name
Richard Hooijmaijers
incr_mdl("run01.r")
incr_mdl("run01.r")
Data exploration module for server
module_dataexplore_server(id, r)
module_dataexplore_server(id, r)
id |
Module id |
r |
reactive values object that is defined top-level |
No return value, called for side effects
Shiny module for data exploration
module_dataexplore_ui(id)
module_dataexplore_ui(id)
id |
Module id |
A list of html tags used for th UI of the app
Editor module for server
module_edit_server(id, r, settings)
module_edit_server(id, r, settings)
id |
Module id |
r |
reactive values object that is defined top-level |
settings |
reactive value with the app settings |
No return value, called for side effects
Shiny module for model editor
module_edit_ui(id)
module_edit_ui(id)
id |
Module id |
A list of html tags used for th UI of the app
Fit plots module for server
module_fitplots_server(id, r, settings)
module_fitplots_server(id, r, settings)
id |
Module id |
r |
reactive values object that is defined top-level |
settings |
reactive value with the app settings |
No return value, called for side effects
Shiny module for fit plots
module_fitplots_ui(id, proj_obj)
module_fitplots_ui(id, proj_obj)
id |
Module id |
proj_obj |
Project object |
A list of html tags used for th UI of the app
GOF plots module for server
module_gof_server(id, r, settings)
module_gof_server(id, r, settings)
id |
Module id |
r |
reactive values object that is defined top-level |
settings |
reactive value with the app settings |
No return value, called for side effects
Shiny module for GOF plots
module_gof_ui(id, proj_obj)
module_gof_ui(id, proj_obj)
id |
Module id |
proj_obj |
Project object |
A list of html tags used for th UI of the app
meta data module for server
module_metadata_server( id, type, selline = NULL, sellmod = NULL, sellcont = NULL, r )
module_metadata_server( id, type, selline = NULL, sellmod = NULL, sellcont = NULL, r )
id |
Module id |
type |
character with the type of action (either "save" or "overview") |
selline |
reactive with the selected line for a model (for type "overview") |
sellmod |
reactive with the selected model (for type "save") |
sellcont |
reactive with the content of the selected model (for type "save") |
r |
reactive values object that is defined top-level |
a reactive with the meta data information
Shiny module for meta data
module_metadata_ui(id, type)
module_metadata_ui(id, type)
id |
Module id |
type |
character with the type of button to present (either "save" or "overview") |
A list of html tags used for th UI of the app
Overview module for server
module_overview_server(id, r)
module_overview_server(id, r)
id |
Module id |
r |
reactive values object that is defined top-level |
No return value, called for side effects
Shiny module for overview
module_overview_ui(id)
module_overview_ui(id)
id |
Module id |
A list of html tags used for th UI of the app
Parameter table module for server
module_pt_server(id, r)
module_pt_server(id, r)
id |
Module id |
r |
reactive values object that is defined top-level |
No return value, called for side effects
Shiny module for parameter table
module_pt_ui(id, proj_obj)
module_pt_ui(id, proj_obj)
id |
Module id |
proj_obj |
Project object |
A list of html tags used for th UI of the app
Reporting module for server
module_reports_server(id, r)
module_reports_server(id, r)
id |
Module id |
r |
reactive values object that is defined top-level |
No return value, called for side effects
Shiny module for reporting
module_reports_ui(id)
module_reports_ui(id)
id |
Module id |
A list of html tags used for th UI of the app
Run model module for server
module_run_server(id, r)
module_run_server(id, r)
id |
Module id |
r |
reactive values object that is defined top-level |
No return value, called for side effects
Shiny module for running models
module_run_ui(id, proj_obj)
module_run_ui(id, proj_obj)
id |
Module id |
proj_obj |
Project object |
A list of html tags used for th UI of the app
Run script module for server
module_scripts_server(id, files = NULL, loc = "temp", r)
module_scripts_server(id, files = NULL, loc = "temp", r)
id |
Module id |
files |
character vector of files to apply the scripts on, usually a reactive |
loc |
character with the location where the temp scripts are saved (created when not existing) |
r |
reactive values object that is defined top-level |
No return value, called for side effects
Shiny module for running scripts
module_scripts_ui(id)
module_scripts_ui(id)
id |
Module id |
A list of html tags used for th UI of the app
Settings module for server
module_settings_server(id)
module_settings_server(id)
id |
Module id |
a reactive with all input elements
Shiny module for settings
module_settings_ui(id)
module_settings_ui(id)
id |
Module id |
A list of html tags used for th UI of the app
This function gets list of widgets to include in run_shinymixr
myalert(text, type, ...)
myalert(text, type, ...)
text |
character with the text to display |
type |
character with the type of alert to display |
... |
other arguments passed to class |
No return value, called for side effects
This function sets significant digits without rounding any numbers
numfmt(x, sdig = 3, snc = 6)
numfmt(x, sdig = 3, snc = 6)
x |
a numerical vector |
sdig |
a single number defining the number of significant digits |
snc |
a single number defining the scientific notation cutoff (higher means notation is only used for very small or very large numbers) |
a character vector with formatted numbers
Richard Hooijmaijers
numfmt(c(0.012,12345,1))
numfmt(c(0.012,12345,1))
Create an overview of the models within a project. This overview includes the meta data of the models and if results are available, also the objective function and run-times
overview(proj_obj, ...)
overview(proj_obj, ...)
proj_obj |
a project object created with |
... |
additional arguments passed to |
a data frame is returned with the overview
Richard Hooijmaijers
## Not run: overview(proj_obj) ## End(Not run)
## Not run: overview(proj_obj) ## End(Not run)
Creates a table with the final estimates and percentage CV for all parameters in an nlmixr output file. This can be done for one or multiple models for easy comparison
par_table( proj, models, outnm = NULL, projloc = ".", bsv = FALSE, shrink = FALSE, backt = FALSE, formatting = FALSE, ... )
par_table( proj, models, outnm = NULL, projloc = ".", bsv = FALSE, shrink = FALSE, backt = FALSE, formatting = FALSE, ... )
proj |
project object |
models |
character vector with model names to create table for |
outnm |
character with name of the output file (see details) |
projloc |
character with the base location of the shinyMixR project |
bsv |
logical indicating if between subject variability (BSV) should be added to table |
shrink |
logical indicating if shrinkage should be added to table |
backt |
logical indicating if the backtransformed parameters should be returned opposed to the original values |
formatting |
logical indicating if the formatting should be applied to present the table (not implemented for latex output) |
... |
In case a model is saved, a directory with the name of the model is created within the analysis folder of the current project. Then within this folder the file is saved as outnm. This method was chosen so the interface can easily index applicable files for a certain model. However, this means that output is always saved in this directly regardless of the location of outnm In case multiple models are selected the result will be written to the name of the first model in the models vector.
in case no outnm is defined a data frame will be returned otherwise the results are saved to disk
Richard Hooijmaijers
## Not run: par_table(proj,"run1") ## End(Not run)
## Not run: par_table(proj,"run1") ## End(Not run)
Runs an nlmixr model from a project object with the possibility to run in an external rsession using a system call (tested within linux only)
run_nmx( mod, proj = proj, ext = TRUE, saverds = TRUE, autoupdate = TRUE, projloc = ".", addcwres = TRUE, addnpde = TRUE )
run_nmx( mod, proj = proj, ext = TRUE, saverds = TRUE, autoupdate = TRUE, projloc = ".", addcwres = TRUE, addnpde = TRUE )
mod |
character with the model file present in project object |
proj |
project object |
ext |
logical indicating if the model should be run external in a separate r session |
saverds |
logical indicating if the model results should be saved in a rds file |
autoupdate |
logical indicating if the project object should automatically update |
projloc |
character with the base location of the shinyMixR project |
addcwres |
logical indicating if CWRES should be added to the output |
addnpde |
logical indicating if NPDE should be added to the output |
the meta data is obtained by compiling the model. The dataset, estimation method and control list are then included in the nlmixr call. Meta data is included in the model function which is comparable with NONMEM. This method was chosen so that all information to run a model is kept together in one function
In case the model is not submitted in a separate R session, the results from nlmixr are returned otherwise the result of the system call will be returned
Richard Hooijmaijers
## Not run: run_nmx("run1",proj) ## End(Not run)
## Not run: run_nmx("run1",proj) ## End(Not run)
Creates and run the interface
run_shinymixr(wd = getwd(), ...)
run_shinymixr(wd = getwd(), ...)
wd |
character with the working directory |
... |
arguments passed to the shiny runApp function |
No return value, runs the shinyMixR interface
Richard Hooijmaijers
## Not run: if (interactive()) run_shinymixr(".") ## End(Not run)
## Not run: if (interactive()) run_shinymixr(".") ## End(Not run)
Rstudio gadget to select project and start app
shinymixr_gadget()
shinymixr_gadget()
No return value, runs a gadget to start the shinyMixR interface
Richard Hooijmaijers
## Not run: if (interactive()) shinymixr_gadget() ## End(Not run)
## Not run: if (interactive()) shinymixr_gadget() ## End(Not run)
This function sets significant digits without rounding any numbers
sigdigs(x, sdig = 3)
sigdigs(x, sdig = 3)
x |
a numerical vector |
sdig |
a single number defining the number of significant digits |
A character vector with formatted numbers
This function provides a custom theme for ggplot output
theme_shinyMixR(fontsize = 12)
theme_shinyMixR(fontsize = 12)
fontsize |
numeric with the default fontsize passed through to theme |
A list with ggplot theme elements
Create a graphical collapsible tree overview of the models within a project. This is mostly relevant in case the reference of models is included to visualise the relationship between models
tree_overview(proj_obj, ...)
tree_overview(proj_obj, ...)
proj_obj |
a project object created with |
... |
additional arguments passed to |
a data frame is returned with the overview
Richard Hooijmaijers
collapsibleTreeNetwork
which does most of the work
## Not run: if (interactive()) tree_overview(proj_obj) ## End(Not run)
## Not run: if (interactive()) tree_overview(proj_obj) ## End(Not run)
This function update the initial estimates from a model using the final estimates from a model result file. Currently this function assumes all models were submitted using shinyMixR opposed to vanilla nlmixr
update_inits(mod, res, out)
update_inits(mod, res, out)
mod |
character with the entire model function included |
res |
character with the path to the model result RDS which holds the final estimated |
out |
character with the path for the updated model to save |
nothing will be returned the function saves the updated model to disk
Richard Hooijmaijers
## Not run: update_inits(readLines("run2.r"),"shinyMixR/run2.res.rds","run3.r") ## End(Not run)
## Not run: update_inits(readLines("run2.r"),"shinyMixR/run2.res.rds","run3.r") ## End(Not run)