Package 'pmxcode'

Title: Create Pharmacometric Models
Description: Provides a user interface to create or modify pharmacometric models for various modeling and simulation software platforms.
Authors: Sebastien Bihorel [cre, aut]
Maintainer: Sebastien Bihorel <[email protected]>
License: MIT + file LICENSE
Version: 0.1.4
Built: 2024-11-20 06:23:21 UTC
Source: CRAN

Help Index


Auto indent mrgsolve code

Description

Auto indent mrgsolve code

Usage

align_annotations(code)

Arguments

code

Code lines containing comments to align across


Auto indent NONMEM code tags

Description

Auto indent NONMEM code tags

Usage

align_tags(code)

Arguments

code

Code lines containing comments to align across


Multi-argument version of isTruthy

Description

See shiny::isTruthy for details.

Usage

areTruthy(...)

Arguments

...

Any object

Value

TRUE if all objects are "truthy", FALSE if at least one is not.


Check covariate definition table

Description

Check covariate definition table

Usage

check_covariate_table(table = NULL, check_step = FALSE)

Arguments

table

a data.frame with expected columns

check_step

a logical indicator to check content of Step column or not


Check if covariate definition table contains rows with incomplete data

Description

Check if covariate definition table contains rows with incomplete data

Usage

check_incomplete_covariate_table(table)

Arguments

table

a data.frame with expected columns


Convert reference code for univariate model creation

Description

Convert reference code for univariate model creation

Usage

convert_reference_code(code)

Arguments

code

A character string containing NONMEM code


Generate univariate model code

Description

Generate univariate model code

Usage

create_univariate_models(
  code,
  referenceName,
  nThetas,
  table,
  style,
  prefix,
  startNumber,
  path
)

Arguments

code

A character string containing the code of the reference NONMEM model

referenceName

The name of the reference model file

nThetas

The number of THETA parameters in the reference NONMEM model

table

The table of covariate relationship definition

style

Either PsN or standard

prefix

If standard style, the prefix to start the name of the univariable model file with

startNumber

If PsN style, the number to start univariate model run files

path

The directory in which the univariate models will be saved and run


Determines if a file path exists

Description

Determines if a file path exists

Usage

file_exists(file)

Arguments

file

a path to a file


Creation of model code

Description

Creation of model code

Usage

get_code(
  input = NULL,
  template = NULL,
  vars,
  advan,
  trans,
  isPRED,
  isODE,
  isLINMAT,
  isPREDPP,
  varianceTable,
  covarianceBlock,
  rvTable,
  parm_lib,
  model_lib,
  rv_lib,
  scaling,
  replacement = TRUE
)

Arguments

input

Internal parameter for shiny

template

Text template

vars

Reactive object - List of variables in data file

advan

Reactive object - NONMEM ADVAN value

trans

Reactive object - NONMEM TRANS value

isPRED

Reactive object - is model coded with $PRED?

isODE

Reactive object - is model coded with ODEs?

isLINMAT

Reactive object - is model coded as linear matrix?

isPREDPP

Reactive object - is mode coded with $PK?

varianceTable

Variance- table

covarianceBlock

Variance-covariance matrix

rvTable

Reactive object - residual variability matrix

parm_lib

Library of parameters

model_lib

Library for $MODEL replacement

rv_lib

Library for residual variability replacement

scaling

Library for scaling

replacement

Logical value indicating with replacement is required


Convert of covariance matrix into a 0/1 correlation map table

Description

Convert of covariance matrix into a 0/1 correlation map table

Usage

get_correlation_table(x, na_zero = FALSE)

Arguments

x

A covariance matrix

na_zero

Logical indicating whether NA should be replaced by 0's

Value

A matrix of 0 and 1


Get lines of code for derived parameters

Description

Get lines of code for derived parameters

Usage

get_derived_parms_code(
  input,
  advan,
  trans,
  isPRED,
  isODE,
  isLINMAT,
  parms,
  parm_lib
)

Arguments

input

Internal parameter for shiny

advan

Reactive object - NONMEM ADVAN value

trans

Reactive object - NONMEM TRANS value

isPRED

Reactive object - is model coded with $PRED?

isODE

Reactive object - is model coded with ODEs?

isLINMAT

Reactive object - is model coded as linear matrix?

parms

Parameter selection

parm_lib

Library of parameters


Get line of code for individual parameter value

Description

Get line of code for individual parameter value

Usage

get_individual_parm_code(parms, varianceTable, iparm, ieta, mu)

Arguments

parms

Parameter selection

varianceTable

Variability selection

iparm

Index of parameter in parms data frame

ieta

Index of ETA associated with parameter

mu

A logical indicator for mu transformation


Get compartment intialization block

Description

Get compartment intialization block

Usage

get_init_code(input, advan, trans, nPKcmts, nPDcmts, parm_lib)

Arguments

input

Internal parameter for shiny

advan

Reactive object - NONMEM ADVAN value

trans

Reactive object - NONMEM TRANS value

nPKcmts, nPDcmts

Number of compartments for PK and PD model components

parm_lib

Library of parameters


Get line of code for individual parameter value

Description

Get line of code for individual parameter value

Usage

get_mrg_individual_parm_code(parms, iparm, eparm)

Arguments

parms

Parameter selection

iparm

Index of parameter in parms data frame

eparm

Parameter associated with IIV in ordered categorical models


Get mrgsolve model parameter code lines as list

Description

Get mrgsolve model parameter code lines as list

Usage

get_mrg_parms_code(input, parms, mu)

Arguments

input

Internal parameter for shiny

parms

Parameter selection

mu

A logical indicator for mu transformation


Creation of mrgsolve code

Description

Creation of mrgsolve code

Usage

get_mrgsolve_code(
  input = NULL,
  template = NULL,
  advan,
  trans,
  isPRED,
  isODE,
  isLINMAT,
  isPREDPP,
  varianceTable,
  covarianceBlock,
  rvTable,
  parm_lib,
  model_lib,
  rv_lib,
  scaling,
  replacement = TRUE
)

Arguments

input

Internal parameter for shiny

template

Text template

advan

Reactive object - NONMEM ADVAN value

trans

Reactive object - NONMEM TRANS value

isPRED

Reactive object - is model coded with $PRED?

isODE

Reactive object - is model coded with ODEs?

isLINMAT

Reactive object - is model coded as linear matrix?

isPREDPP

Reactive object - is mode coded with $PK?

varianceTable

Variance- table

covarianceBlock

Variance-covariance matrix

rvTable

Reactive object - residual variability matrix

parm_lib

Library of parameters

model_lib

Library for $MODEL replacement

rv_lib

Library for residual variability replacement

scaling

Library for scaling

replacement

Logical value indicating with replacement is required


Get the number of PK and PD compartments

Description

Get the number of PK and PD compartments

Usage

get_ncmts(input, new, model_lib, isPRED, isPREDPP)

Arguments

input

Internal parameter for shiny

new

Text template

model_lib

Library for $MODEL replacement

isPRED

Reactive object - is model coded with $PRED?

isPREDPP

Reactive object - is mode coded with $PK?


Get NONMEM code blocks

Description

Process a character string containing NONMEM model code and returns a character vector in which each element contain a particular $ block

Usage

get_nonmem_blocks(code)

Arguments

code

A character string containing the control stream


Creation of NONMEM code

Description

Creation of NONMEM code

Usage

get_nonmem_code(
  input = NULL,
  template = NULL,
  vars,
  advan,
  trans,
  isPRED,
  isODE,
  isLINMAT,
  isPREDPP,
  varianceTable,
  covarianceBlock,
  rvTable,
  parm_lib,
  model_lib,
  rv_lib,
  scaling,
  replacement = TRUE
)

Arguments

input

Internal parameter for shiny

template

Text template

vars

Reactive object - List of variables in data file

advan

Reactive object - NONMEM ADVAN value

trans

Reactive object - NONMEM TRANS value

isPRED

Reactive object - is model coded with $PRED?

isODE

Reactive object - is model coded with ODEs?

isLINMAT

Reactive object - is model coded as linear matrix?

isPREDPP

Reactive object - is mode coded with $PK?

varianceTable

Variance- table

covarianceBlock

Variance-covariance matrix

rvTable

Reactive object - residual variability matrix

parm_lib

Library of parameters

model_lib

Library for $MODEL replacement

rv_lib

Library for residual variability replacement

scaling

Library for scaling

replacement

Logical value indicating with replacement is required


Get NONMEM model parameter code lines as list

Description

Get NONMEM model parameter code lines as list

Usage

get_parms_code(input, parms, varianceTable, mu)

Arguments

input

Internal parameter for shiny

parms

Parameter selection

varianceTable

Variability selection

mu

A logical indicator for mu transformation


Get lines of preamble code for transit compartment absorption model and delayed dosing records

Description

Get lines of preamble code for transit compartment absorption model and delayed dosing records

Usage

get_preamble_code(input, parms, vars)

Arguments

input

Internal parameter for shiny

parms

Parameter selection

vars

Character vector of variable names


Get code lines for scaling and bioavailability

Description

Get code lines for scaling and bioavailability

Usage

get_scaling_code(input, advan, trans, parm_lib, scaling)

Arguments

input

Internal parameter for shiny

advan

Reactive object - NONMEM ADVAN value

trans

Reactive object - NONMEM TRANS value

parm_lib

Library of parameters

scaling

Library for scaling


Get number of THETA parameters

Description

Get number of THETA parameters

Usage

get_theta_number(code)

Arguments

code

A character string containing the control stream


Convert covariate handsontable data to R data.frame without factor

Description

Convert covariate handsontable data to R data.frame without factor

Usage

hot_to_r_raw(...)

Arguments

...

passed to rhandsontable::hot_to_r


Determine if a square matrix is of type block, band or error

Description

Determine if a square matrix is of type block, band or error

Usage

is_EDB(x)

Arguments

x

A square matrix

Value

Either "error", "band", or "block"


New model module

Description

New model module

Usage

new_model_server(session, input, output, resources)

Arguments

input, output, session

Internal parameters for shiny.

resources

A list of internal resources


Opposite of areTruthy

Description

Opposite of areTruthy

Usage

notTruthy(...)

Arguments

...

Any object

Value

TRUE if at least one object is not "truthy", FALSE if all are.


Replacement of @ABBREVIATED tag

Description

Replacement of @ABBREVIATED tag

Usage

replace_abbreviated(input, new, vars)

Arguments

input

Internal parameter for shiny

new

Text template

vars

Character vector of variable names


Replacement of @DATA tag

Description

Replacement of @DATA tag

Usage

replace_data(input, new)

Arguments

input

Internal parameter for shiny

new

Text template


Replace @DES tag

Description

Replace @DES tag

Usage

replace_des(input, new, advan, trans, isODE, vars, nPKcmts, nPDcmts, parm_lib)

Arguments

input

Internal parameter for shiny

new

Text template

advan

Reactive object - NONMEM ADVAN value

trans

Reactive object - NONMEM TRANS value

isODE

Reactive object - is model coded with ODEs?

vars

Reactive object - List of variables in data file

nPKcmts

Number of PK compartments in the model

nPDcmts

Number of PD compartments in the model

parm_lib

Library of parameters


Replace @ERROR tag

Description

Replace @ERROR tag

Usage

replace_error(
  input,
  new,
  advan,
  trans,
  isPRED,
  nPKcmts,
  nPDcmts,
  parm_lib,
  rv_lib
)

Arguments

input

Internal parameter for shiny

new

Text template

advan

Reactive object - NONMEM ADVAN value

trans

Reactive object - NONMEM TRANS value

isPRED

Reactive object - is model coded with $PRED?

nPKcmts

Number of PK compartments in the model

nPDcmts

Number of PD compartments in the model

parm_lib

Library of parameters

rv_lib

Library for residual variability replacement


Replacement of @INPUT tag

Description

Replacement of @INPUT tag

Usage

replace_input(input, new, vars)

Arguments

input

Internal parameter for shiny

new

Text template

vars

Character vector of variable names


Replace @MODEL tag

Description

Replace @MODEL tag

Usage

replace_model(input, new, model_lib, isPRED, isPREDPP)

Arguments

input

Internal parameter for shiny

new

Text template

model_lib

Library for $MODEL replacement

isPRED

Reactive object - is model coded with $PRED?

isPREDPP

Reactive object - is mode coded with $PK?


Replacement of @CAPTURE tag

Description

Replacement of @CAPTURE tag

Usage

replace_mrg_capture(input, new, parms)

Arguments

input

Internal parameter for shiny

new

Text template

parms

Parameter selection


Replacement of @CMT tag

Description

Replacement of @CMT tag

Usage

replace_mrg_cmt(input, new, model_lib, isPRED)

Arguments

input

Internal parameter for shiny

new

Text template

model_lib

Library for $MODEL replacement

isPRED

Reactive object - is model coded with $PRED?


Replacement of @GLOBAL tag

Description

Replacement of @GLOBAL tag

Usage

replace_mrg_global(input, new, advan, trans, nPKcmts, parm_lib)

Arguments

input

Internal parameter for shiny

new

Text template

advan

Reactive object - NONMEM ADVAN value

trans

Reactive object - NONMEM TRANS value

nPKcmts

Number of compartments for PK

parm_lib

Library of parameters


Replace @MAIN or @PRED tags

Description

Replace @MAIN or @PRED tags

Usage

replace_mrg_main_pred(
  input,
  new,
  preamble_code,
  parms_code,
  derived_parms_code,
  scaling_code,
  init_code,
  isPRED,
  parms,
  parm_lib,
  rv_lib
)

Arguments

input

Internal parameter for shiny

new

Text template

preamble_code

Preamble code

parms_code

Typical and individual parameter code

derived_parms_code

Derived parameter code

scaling_code

Dose scaling and bioavailability code

init_code

Compartment initialization code

isPRED

Reactive object - is model coded with $PRED?

parms

Parameter selection

parm_lib

Library of parameters

rv_lib

Library for residual variability replacement


Replacement of @ODE tag

Description

Replacement of @ODE tag

Usage

replace_mrg_ode(input, new, advan, trans, isODE, nPKcmts, nPDcmts, parm_lib)

Arguments

input

Internal parameter for shiny

new

Text template

advan

Reactive object - NONMEM ADVAN value

trans

Reactive object - NONMEM TRANS value

isODE

Reactive object - is model coded with ODEs?

nPKcmts

Number of PK compartments in the model

nPDcmts

Number of PD compartments in the model

parm_lib

Library of parameters


Replacement of @OMEGA tag

Description

Replacement of @OMEGA tag

Usage

replace_mrg_omega(input, new, parms, blocks, nmextImport)

Arguments

input

Internal parameter for shiny

new

Text template

parms

Parameter selection

blocks

Variance - covariance matrix

nmextImport

A logical indicating whether NONMEM ext file content should be imported


Replacement of @PARAM tag

Description

Replacement of @PARAM tag

Usage

replace_mrg_param(input, new, parms, nmextImport)

Arguments

input

Internal parameter for shiny

new

Text template

parms

Parameter selection

nmextImport

A logical indicating whether NONMEM ext file content should be imported


Replacement of @PLUGIN tag

Description

Replacement of @PLUGIN tag

Usage

replace_mrg_plugin(input, new)

Arguments

input

Internal parameter for shiny

new

Text template


Replacement of @SIGMA tag

Description

Replacement of @SIGMA tag

Usage

replace_mrg_sigma(input, new, rvTable, nmextImport)

Arguments

input

Internal parameter for shiny

new

Text template

rvTable

Residual variability selection

nmextImport

A logical indicating whether NONMEM ext file content should be imported


Replacement of @TABLE tag

Description

Replacement of @TABLE tag

Usage

replace_mrg_table(
  input,
  new,
  advan,
  trans,
  isPRED,
  nPKcmts,
  nPDcmts,
  parm_lib,
  rv_lib
)

Arguments

input

Internal parameter for shiny

new

Text template

advan

Reactive object - NONMEM ADVAN value

trans

Reactive object - NONMEM TRANS value

isPRED

Reactive object - is model coded with $PRED?

nPKcmts

Number of PK compartments in the model

nPDcmts

Number of PD compartments in the model

parm_lib

Library of parameters

rv_lib

Library for residual variability replacement


Replacement of @NMEXT tag

Description

Replacement of @NMEXT tag

Usage

replace_nmext(input, new, nmextImport = FALSE)

Arguments

input

Internal parameter for shiny

new

Text template

nmextImport

A logical indicating whether NONMEM ext file content should be imported


Replacement of @OMEGA tag

Description

Replacement of @OMEGA tag

Usage

replace_omega(new, parms, varianceTable, blocks)

Arguments

new

Text template

parms

Parameter selection

varianceTable

Variability selection

blocks

Variance - covariance matrix


Replacement of @PATH tag

Description

Replacement of @PATH tag

Usage

replace_path(input, new)

Arguments

input

Internal parameter for shiny.

new

Text template


Replace @PK and @PRED tags

Description

Replace @PK and @PRED tags

Usage

replace_pk_pred(
  input,
  new,
  preamble_code,
  parms_code,
  derived_parms_code,
  scaling_code,
  init_code,
  isPRED,
  parms,
  varianceTable,
  parm_lib,
  rv_lib,
  mu
)

Arguments

input

Internal parameter for shiny

new

Text template

preamble_code

Preamble code

parms_code

Typical and individual parameter code

derived_parms_code

Derived parameter code

scaling_code

Dose scaling and bioavailability code

init_code

Compartment initialization code

isPRED

Reactive object - is model coded with $PRED?

parms

Parameter selection

varianceTable

Variability selection

parm_lib

Library of parameters

rv_lib

Library for residual variability replacement

mu

A logical indicator for mu transformation


Replacement of @PRIOR tag

Description

Replacement of @PRIOR tag

Usage

replace_prior(input, new, parms, varianceTable, estimations)

Arguments

input

Internal parameter for shiny

new

Text template

parms

Parameter selection

varianceTable

Variability selection

estimations

Table of estimation tasks


Replacement of @PROB1 and @PROB2 tags

Description

Replacement of @PROB1 and @PROB2 tags

Usage

replace_problem(input, new)

Arguments

input

Internal parameter for shiny

new

Text template


Replacement of @PURPOSE tag

Description

Replacement of @PURPOSE tag

Usage

replace_purpose(input, new, varianceTable)

Arguments

input

Internal parameter for shiny.

new

Text template

varianceTable

Variance- table


Replacement of @SIGMA tag

Description

Replacement of @SIGMA tag

Usage

replace_sigma(new, input, rvTable)

Arguments

new

Text template

input

Internal parameter for shiny

rvTable

Residual variability selection


Replacement of @SUBROUTINE tag

Description

Replacement of @SUBROUTINE tag

Usage

replace_subroutine(input, new, advan, trans, isPRED, isODE, isLINMAT)

Arguments

input

Internal parameter for shiny

new

Text template

advan

Reactive object - NONMEM ADVAN value

trans

Reactive object - NONMEM TRANS value

isPRED

Reactive object - is model coded with $PRED?

isODE

Reactive object - is model coded with ODEs?

isLINMAT

Reactive object - is model coded as linear matrix?


Replace @TABLE tag

Description

Replace @TABLE tag

Usage

replace_table(input, new, vars)

Arguments

input

Internal parameter for shiny

new

Text template

vars

Reactive object - List of variables in data file


Replace $TAGs tag

Description

Replace $TAGs tag

Usage

replace_tags(input, new)

Arguments

input

Internal parameter for shiny

new

Text template


Replace @TASK tag

Description

Replace @TASK tag

Usage

replace_task(input, new, estimations, isODE)

Arguments

input

Internal parameter for shiny

new

Text template

estimations

Table of estimation tasks

isODE

Reactive object - is model coded with ODEs?


Replacement of @THETA tag

Description

Replacement of @THETA tag

Usage

replace_theta(new, parms)

Arguments

new

Text template

parms

Parameter selection


Load resource files

Description

Load resource files

Usage

resources()

Run the Shiny Application

Description

Run the Shiny Application

Usage

run_app(
  onStart = NULL,
  options = list(launch.browser = TRUE),
  enableBookmarking = NULL,
  uiPattern = "/",
  ...
)

Arguments

onStart

A function that will be called before the app is actually run. This is only needed for shinyAppObj, since in the shinyAppDir case, a global.R file can be used for this purpose.

options

Named options that should be passed to the runApp call (these can be any of the following: "port", "launch.browser", "host", "quiet", "display.mode" and "test.mode"). You can also specify width and height parameters which provide a hint to the embedding environment about the ideal height/width for the app.

enableBookmarking

Can be one of "url", "server", or "disable". The default value, NULL, will respect the setting from any previous calls to enableBookmarking(). See enableBookmarking() for more information on bookmarking your app.

uiPattern

A regular expression that will be applied to each GET request to determine whether the ui should be used to handle the request. Note that the entire request path must match the regular expression in order for the match to be considered successful.

...

arguments to pass to golem_opts. See '?golem::get_golem_options' for more details.

Value

Starts the PMXcode Shiny application

Examples

## Not run: 
if( interactive() ){
  pmxcode::run_app()
}

## End(Not run)

Format variables by lines of 10.

Description

Format variables by lines of 10.

Usage

tenvars(x)

Arguments

x

Character vectors of variables