Skip to contents
add_covariates_to_model()
Wrapper function to add covariates to a pharmpy model
add_table_to_model()
Add new $TABLE record to output variables
calc_condition_number()
Calculate the condition number given a matrix
call_nmfe()
Call nmfe
call_pharmpy_fit()
Run model with pharmpy
call_pharmpy_tool()
Generic function for running a pharmpy tool, like bootstrap, or modelsearch. A separate function is available for fit()
call_psn()
Call PsN
change_nonmem_dataset()
Change $DATA in NONMEM model code
check_llm_key()
Check presence of LLM API key
clean_modelfit_data()
Clean / check the dataset before passing to model fitting tool
clean_nonmem_folder()
Remove temporary files from NONMEM run
clean_pharmpy_runfolders()
Clean pharmpy run folders like modelfit1 etc
combine_info_columns()
Combine columns with run info into a data.frame and make sure that rows match (e.g. parameters)
compare_nlme_fit()
Compare fit of two or more NLME fits
create_cache()
Create a cache environment to store settings for project and system
create_covariate_search_space()
Create covariate search space definition for pharmpy covsearch
create_model()
Create model
create_model_nlmixr()
Temporary function that returns a hardcoded nlmixr2 model
create_modelfit_info_table()
Create a data.frame with basic model fit info
create_modelfit_parameter_table()
Create a data.frame with parameter estimates
create_pkmodel_search_space()
Create PK mmodel search space definition for pharmpy modelsearch
create_run_folder()
Create a folder for a run
create_vpc_data()
Run a simulation based on supplied parameters estimates, and combine into proper format for VPC
detect_nmfe_version()
get nmfe file name from a NONMEM installation folder
estimation_options_defaults
List of default options for estimation method.
extract()
Helper function for read_ini
find_file_with_fallback()
Find a file(s) from a model run with a potential fallback
fit_model()
Fit model using NONMEM or nlmixr2
fit_model_nlmixr()
Fit model using nlmixr2
fit_model_nonmem()
Fit model using NONMEM
get_condition_number_for_fit()
Calculate the condition number for a model fit object Performs some safety checks
get_defined_pk_parameters()
Get all parameters that are defined (from a predefined vector of possible parameters)
get_estimation_options()
Helper function to combine default estimation options with user-specified, and ensure correct format.
get_fit_info()
Get fit info from NONMEM run
get_initial_estimates_from_data()
Get a very crude estimate for V to serve as initial estimate for CL and V, without performing an NCA. The calculation is based on the assumption that often in clinical trial data, there is at least a peak and a trough (and likely other samples) taken, hence it's possible to get a crude estimate for CL and V from that. For 2-compartment models we just set Q and V to half and twice the size of CL and V, which is often a good starting point. In most scenarios this is sufficiently close to the final estimates that estimation methods will be able to find the global minimum.
get_initial_estimates_from_individual_data()
Core function to get parameter estimates from individual data
get_luna_config()
Get luna config, either from global config file, or from project config
get_new_run_number()
Get new run number for model fit
get_nmfe_location_for_run()
Helper function to determine nmfe location from various sources The order is as follows:
get_nmfe_output()
Get output from NMFE
get_parameters_with_iiv()
Get a character vector with all parameters on which IIV is present
get_pharmpy_conf()
Get pharmpy configuration, as an R object (list)
get_pharmpy_runfolders()
Find last pharmpy run folder
get_route_from_data()
Get route from data. If dose and observation events all happen in the same compartment, then assume IV administration, else oral absorption (or sc, im, etc).
get_shrinkage_summary()
Parses a NONMEM output file and extracts shrinkage
get_shrinkage_values()
Get shrinkage values from a single line in NONMEM output
get_status()
Get the status of a run
get_tables_from_fit()
Read tables created in model run and return as a list of data.frames
get_tables_from_folder()
Get tables from a folder, by table_names
get_tables_in_model_code()
extract FILE names from $TABLE using simple regex. For some reason the tables are not (yet?) available in pharmpy
get_time_ago()
Get time to now since a given date, in character
get_time_last_updated_file()
Get date/time stamp for last update to file
get_time_last_updated_folder()
Get a timestamp for when the last update was made to any file in a folder Will look only 1 level deep.
get_tool_from_model()
Get estimation/simulation engine from pharmpy model
get_tools_info()
For a given run, get info on what folders are available for selected Pharmpy or PsN tools
ifelse0()
ifelse function but then based on whether value is NULL or not
insert_entry()
The reverse of pluck_entry, insert_entry() inserts an entry into an unnamded outer list, based on an element in the inner list.
is_luna_cache_available()
Check if luna cache is available / loaded
log_add()
Add event to log
log_get_last_event()
Get last event from log, as list object
luna_cache_get()
Get element from active project Just a convenience wrapper with error checking
luna_compare()
Compare basic run info for 2 or more model runs
luna_config()
Edit luna config file in editor, e.g. RStudio
luna_dataset()
Get data from a model
luna_edit()
Edit model in editor, e.g. RStudio
luna_edit_project()
Edit luna config file in editor, e.g. RStudio
luna_gof()
Creates a ggplot2 panel object with basic goodness of fit plots
luna_help()
Ask AI agent to help
luna_info()
Show info for a model run
luna_list()
List runs in current project
luna_load_project()
Load a project from yaml and gather results. Project is then stored/updated in .luna_cache
luna_log()
Show a log of events (actions and errors)
luna_new_project()
Create a new project folder with template YAML project file
luna_note()
Annotate a run Either add a note or clear notes from a run
luna_project_templates()
Show available templates
luna_run()
Run a NONMEM model
luna_sync()
Synchronize (re-load) luna project
luna_tables()
Get tables from a model / run
luna_tag()
Add a tag to a run Either add a tag or clear tags from a run
luna_tool()
Run external tools (e.g. diagnostics) on models or run outputs This can be used e.g. for bootstraps and VPCs. The function is implemented in a modular way so that it can be easily extended.
luna_xpose()
Read tables for a model and parse into an Xpose database
new_project_from_template()
Create a new project object based on a predefined template
nm_read_model()
Parse NONMEM model file into a list containing blocks of code
nm_save_dataset()
Save an R data.frame to a NONMEM-style dataset as CSV
nm_save_model()
Write a NONMEM model object to file
nm_update_dataset()
Update $DATA in NONMEM model with new dataset
parse_psn_args()
Parse tool options specified in YAML into PsN commandline args
pluck_entry()
Pluck an inner list element from an unnamed outer list, where an element matches (default name is "id") a specific value. Analogue to _.pluck() in JS/underscore
print(<luna.run_table> )
Prints a list of models / runs in project
print(<pharmpy.workflows.results.ModelfitResults> )
Print function that provides basic run information for a pharmpy modelfit
print_nmfe_output()
Print nmfe output (stdout and stderr) from a run folder
read_ini()
Read ini file core function
read_table_nm()
NONMEM output table import function
read_yaml_safe()
Safe way to read YAML
remove_table_from_model()
Remove all $TABLE records from a model
remove_table_sections()
Function to remove all $TABLE sections
remove_tables_from_model()
Remove all $TABLE records from a model
run_nlme()
Run model in NONMEM
run_psn()
Run a PsN tool
runs_as_table()
Convert runs in a project object to a data.frame
save_model_code()
Save model code to a markdown file
save_project()
Save a project to a YAML file
set_iiv()
Set inter-individual variability on parameters
set_residual_error()
Logic to set the residual error model structure for the model
stack_encounters()
Stack encounters when data from multiple encounters is available for the same ID, and TIME is starting at 0 for each encounter.
truncate_columns()
Apply column width truncation based on console width and relative width specs
update_cache()
Update luna project cache
validate_id()
Validate id
validate_model()
Validate the specified model, ensure it's valid Pharmpy model