Skip to contents

Building a system file will produce templates for R and other languages. This function provides a method to make local copies of these templates.

Usage

system_fetch_template(
  cfg,
  template = "Simulation",
  overwrite = FALSE,
  output_directory = getwd()
)

Arguments

cfg

ubiquity system object

template

template type

overwrite

if TRUE the new system file will overwrite any existing files present

output_directory

directory where workshop files will be placed (getwd())

Value

List with vectors of template sources, destinations

and corresponding write success (write_file), also a list element indicating the overall success of the function call (isgood)

Details

The template argument can have the following values for the R workflow:

  • "Simulation" produces analysis_simulate.R: R-Script named with placeholders used to run simulations

  • "Estimation" produces analysis_estimate.R: R-Script named with placeholders used to perform naive-pooled parameter estimation

  • "NCA" produces analysis_nca.R: R-Script to perform non-compartmental analysis (NCA) and report out the results

  • "ShinyApp" produces ubiquity_app.R, server.R and ui.R: files needed to run the model through a Shiny App either locally or on a Shiny Server

  • "Model Diagram" produces system.svg: SVG template for producing a model diagram (Goto https://inkscape.org for a free SVG editor)

  • "Shiny Rmd Report" produces system_report.Rmd and test_system_report.R: R-Markdown file used to generate report tabs for the Shiny App and a script to test it

  • "myOrg" produces myOrg.R: R-Script for defining functions used within your organization

And this will create files to use in other software:

  • "Adapt" produces system_adapt.for and system_adapt.prm: Fortran and parameter files for the currently selected parameter set in Adapt format.

  • "Berkeley Madonna" produces system_berkeley_madonna.txt: text file with the model and the currently selected parameter set in Berkeley Madonna format

  • "nlmixr" produces system_nlmixr.R For the currently selected parameter set to define the system in the `nlmixr` format.

  • "NONMEM" produces system_nonmem.R For the currently selected parameter set as a NONMEM conntrol stream.

  • "Monolix" produces system_monolix.txt For the currently selected parameter set as a NONMEM conntrol stream.

  • "mrgsolve" produces system_mrgsolve.cpp: text file with the model and the currently selected parameter set in mrgsolve format

Examples

# \donttest{
# Creating a system file from the mab_pk example
fr = system_new(file_name        = "system.txt", 
                system_file      = "mab_pk", 
                overwrite        = TRUE, 
                output_directory = tempdir())

# Building the system 
cfg = build_system(system_file  = file.path(tempdir(), "system.txt"),
      output_directory          = file.path(tempdir(), "output"),
      temporary_directory       = tempdir())
#> 
#> ── Building the system: /var/folders/l9/6pm7xq5j1hn6l00zrs22j6mc0000gn/T//RtmpoL
#> → ubiquity:     https://r.ubiquity.tools
#> → Distribution: package (2.0.4)
#> → Compiling C version of system
#> → Loading the shared C library
#>  System built
#>  To fetch a new analysis template use `system_fetch_template`
#>  For example:
#>    fr = system_fetch_template(cfg, template = "Simulation")
#>    fr = system_fetch_template(cfg, template = "Estimation")

# Creating a simulation template
fr =  system_fetch_template(cfg, 
      template         = "Simulation", 
      output_directory = tempdir())
#> → Creating file: /var/folders/l9/6pm7xq5j1hn6l00zrs22j6mc0000gn/T//RtmpoLqbza/analysis_simulate.R
# }