library(knitr) opts_chunk$set(fig.width=6, fig.height=6)
rspeaksnonmem
is designed to allow the user to craft workflows based on a
given NONMEM model.
rspeaksnonmem
allows the user to run NONMEM models from R either directly
running the nmfe.bat or by
calling Perl speaks NONMEM (PsN) functions like
"execute". Other PsN functions can be run from R - VPC (Visual Predictive Check),
bootstrap, SSE (Stochastic Simulation and Estimation).
This allows the user to define sequences of pharmacometrics workflow tasks via R within a single R script. This increases traceability and reproducibility of workflow.
devtools::load_all(pkg=".") devtools::load_all(pkg = "C:\\Users\\smith_mk\\Documents\\Working documents\\RNMImport") getwd() file.copy(from = file.path(system.file("inst/exdata/", package="rspeaksnonmem"), "warfarin_conc_pca.csv"), to = getwd(), overwrite = T ) file.copy(from = file.path(system.file("inst/exdata", package="rspeaksnonmem"), "warfarin.ctl"), to = getwd(), overwrite = T )
estimate_NM
runs NONMEM for a given model file. Note
that in the command
argument to the function we specify the complete path to the
NONMEM executable .bat file. This allows you to be very precise about which
version of NONMEM you use. If the clean
argument is non-zero it cleans up the
working directory deleting all of the temporary NONMEM files, leaving only the
output.
estimate_NM(modelFile = "warfarin.ctl", command = "c:/nm72/run/nmfe72.bat", clean = 1)
We can now use PsN command sumo
to summarise the output. Note that here we
are not using the command
argument, but instead we specify the installation
directory for Perl / PsN and which PsN version we are using. rspeaksnonmem
will then create a command based on the directory, sumo
and version information.
sumo_PsN(installPath = "c:/strawberry/perl", version = "4.6.0", lstFile = "warfarin.lst")
The defineExecutable
function used by estimate_NM
and PsN calling
functions can search for user-specified command to find valid executables at
the system prompt. If you supply the command with no file path with
searchCommand=T then the function uses Sys.which
or Sys.which2
(depending
on OS) to search the system PATH or shortcut definitions for executables.
defineExecutable(command = "R", searchCommand = T)
If you specify the tool
and the installPath
, then defineExecutables
looks
within the installPath
directory for executables that match the tool name.
defineExecutable(tool = "nonmem", installPath = "c:/nm72", searchCommand = T)
Note that for PsN there could are a few ways of invoking the routine.
defineExecutable(tool = "vpc", installPath = "c:/strawberry/perl", searchCommand = T)
In the rspeaksnonmem
calls to PsN routines we explicitly tie the Perl script
to the "parent" Perl executable. We use the version number Perl script so that
it's clear to anyone looking at the command which version of the Perl script
has been used and the Perl executable associated with it.
defineExecutable(tool = "vpc", installPath = "c:/strawberry/perl", version = "4.7.0")
rspeaksnonmem
has functionality to check that the name-value pairs specified
in the psnOpts arguments of the PsN calling functions are appropriately named
and have valid argument types for use with PsN. We do this by checking against
the routines' -h
help files.
psnOpts <- list(picky = "yes", ## retries option should be numeric auto_bin = 4, ## auto_bin is not a valid option for execute dir = getwd()) validate_PsN_options(tool = "execute", installPath = "c:/strawberry/perl", version = "4.6.0", psnOpts = psnOpts)
rspeaksnonmem
has PsN call functions for the following routines:
execute
sumo
vpc
bootstrap
sse
runrecord
Although functions have been provided as wrappers to the PsN functions, it is easy to extend these to any other PsN function using the function callPsN.
linearize-4.7.0 warfarin.ctl -dir=linearize
callPsN(tool = "linearize", installPath = "c:/strawberry/perl", version = "4.7.0", file = "warfarin.ctl")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.