Select Page

# R functions to run PKanalix

## On the use of a R-functions

PKanalix can be called via R-functions. It is possible to have access to the project exactly in the same way as you would do with the interface.  All the functions are described below.

## Installation and initialization

All the installation guidelines and initialization procedure can be found here.

## Description of the functions concerning the project management

• getData: Get a description of the data used in the current project.
• getStructuralModel: Get the model file for the structural model used in the current project (CA analysis).
• loadProject: Load a project by parsing the mlxtran-formated file whose path has been given as an input.
• newProject: Create a new empty project providing model and data specification.
• saveProject: Save the current project as an Mlxtran-formated file.
• setData: Set project data giving a data file and specifying headers and observations types.
• setStructuralModel: Set the structural model.

## Description of the functions concerning the scenario

• runCAEstimation: Estimate the CA parameters for each individual of the project.
• runEstimation: Run the NCA analysis and the CA analysis if the structural model for the CA calculation is well defined.
• runNCAEstimation: Estimate the NCA parameters for each individual of the project.
• abort: Stop the current task run.
• getLastRunStatus: Return an execution report about the last run with a summary of the error which could have occurred.
• isRunning: Check if a scenario is currently running.

## Description of the functions concerning the results

• getCAIndividualParameters: Get the estimated values for each subject of some of the individual CA parameters of the current project.
• getNCAIndividualParameters: Get the estimated values for each subject of some of the individual NCA parameters of the current project.

## Description of the functions concerning the compartmental and non compartmental analysis settings

• getCASettings: Get the settings associated to the compartmental analysis.
• getDataSettings: Get the data settings associated to the non compartmental analysis.
• getGlobalObsIdToUse: Get the global observation id used in both the compartmental and non compartmental analysis.
• getNCASettings: Get the settings associated to the non compartmental analysis.
• setCASettings: Get the settings associated to the compartmental analysis.
• setDataSettings: Set the value of one or several of the data settings associated to the non compartmental analysis.
• setGlobalObsIdToUse: Get the global observation id used in both the compartmental and non compartmental analysis.
• setNCASettings: Set the value of one or several of the settings associated to the non compartmental analysis.

## Example

### Example 1 : Setup of a PKanalix project, run and retrieving individual NCA parameters

Below is an example of the functions to call to run an NCA and CA analysis from scratch using one of the demo data sets.

# load library and initialize the API
library(lixoftConnectors)
initializeLixoftConnectors(software="pkanalix")
# create a new project by setting a data set
dataPath = paste0(getDemoPath(),'/2.case_studies/data/M2000_ivbolus_singledose.csv')
newProject(data = list(dataFile = dataPath,
'catcov','contcov','contcov','contcov'),
observationTypes = 'continuous'))

# set the options for the NCA analysis
# run the NCA analysis
runNCAEstimation()

# retrieve the output of interest
indivParams <- getNCAIndividualParameters("AUCINF_pred","Cmax")

The estimated NCA parameters can then be further analyzed using typical R functions, and plotted.

In the code below, the third-party R package flextable is used to generate nice-looking table.

library(flextable)

ft <- flextable(indivParams\$parameters)
ft

### Example 2 : Plotting the individual data as spaghetti plot or with mean per treatment group

This demo dataset corresponds to a 2x2x2 crossover design with a ref and a ref formulation. Using the new (2021 version) “plot” functions, the data can be plotted with individual profiles or with mean profiles calculated for the two different treatments and overlayed on a single plot. As the “plot” functions return a ggplot2 object, additional ggplot2 commands can be used to further customize the plot.

library(lixoftConnectors)
library(ggplot2)
initializeLixoftConnectors(software="pkanalix")

scale_x_continuous(breaks=seq(0, 72, by=12))