Learn R Programming

⚠️There's a newer version (1.7.0) of this package.Take me there.

campsis

Requirements

  • R package campsismod must be installed beforehand
  • Simulation engine must be installed too (rxode2 or mrgsolve)

Installation

Install the latest stable release using devtools:

devtools::install_github("Calvagone/campsis")

Basic example

Import the campsis package:

library(campsis)

Create your dataset:

ds <- Dataset(50) %>%
  add(Bolus(time=0, amount=1000, ii=12, addl=2)) %>%
  add(Observations(times=seq(0, 36, by=0.5)))

Load your own model or use a built-in model from the library:

model <- model_suite$pk$`2cpt_fo`

Simulate your results with your preferred simulation engine (rxode2 or mrgsolve):

results <- model %>% simulate(dataset=ds, dest="rxode2", seed=1)

Plot your results:

shadedPlot(results, "CONC")

Copy Link

Version

Install

install.packages('campsis')

Monthly Downloads

524

Version

1.5.5

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

Nicolas Luyckx

Last Published

November 26th, 2024

Functions in campsis (1.5.5)

IOV

Define inter-occasion variability (IOV) into the dataset. A new variable of name 'colname' will be output into the dataset and will vary at each dose number according to the given distribution.
Infusion

Create one or several infusion(s).
LogNormalDistribution

Create a log normal distribution.
NOCB

Create NOCB settings.
arms-class

Arms class.
Solver

Create solver settings.
Progress

Create progress settings.
Outfun

Create a new output function
campsis_handler

Suggested Campsis handler for showing the progress bar.
Occasion

Define a new occasion. Occasions are defined by mapping occasion values to dose numbers. A new column will automatically be created in the exported dataset.
bootstrap_distribution-class

Bootstrap distribution class.
SimulationProgress

Create a simulation progress object.
assignDoseNumber

Assign dose number to each treatment entry.
Scenario

Create an scenario.
Event

Create an interruption event.
Observations

Create an observations list. Please note that the provided 'times' will automatically be sorted. Duplicated times will be removed.
NormalDistribution

Create a normal distribution.
EventCovariate

Create an event covariate. These covariates can be modified further in interruption events.
ParameterDistribution

Create a parameter distribution. The resulting distribution is a log-normal distribution, with meanlog=log(THETA) and sdlog=sqrt(OMEGA).
PI

Compute the prediction interval summary over time.
applyScenario

Apply scenario to the given model or dataset.
Scenarios

Create a list of scenarios.
arm-class

Arm class.
fillIOVOccColumns

Fill IOV/Occasion columns.
Settings

Create advanced simulation settings.
bolus-class

Bolus class.
dose_adaptations-class

Dose adaptations class.
Hardware

Create hardware settings.
FunctionDistribution

Create a function distribution. During distribution sampling, the provided function will be responsible for generating values for each sample. If first argument of this function is not the size (n), please tell which argument corresponds to the size 'n' (e.g. list(size="n")).
bootstrap-class

Bootstrap class.
exportTableDelegate

Export table delegate.
cutTableForEvent

Cut table according to given iteration.
dataset-class

Dataset class.
dose_adaptation-class

Dose adaptation class.
fixed_covariate-class

Fixed covariate class.
declare_settings-class

Declare settings class.
function_distribution-class

Function distribution class.
getSeedForIteration

Get seed for iteration.
factorScenarios

Factor scenarios columns if not done yet.
getEventCovariates

Get all event-related covariates.
distribution-class

Distribution class. See this class as an interface.
TimeVaryingCovariate

Create a time-varying covariate. This covariate will be implemented using EVID=2 rows in the exported dataset and will not use interruption events.
fixed_distribution-class

Fixed distribution class.
hours

Convert hours to hours (do nothing).
checkIIandADDL

Check ii and addl arguments in addition to time.
getEventIterations

Get list of event iterations.
getColumn

Get data of given column unless if does not exist (return NULL in that case).
computeIncrementalProgress

Compute incremental progress.
getAvailableTimeUnits

Return the list of available time units.
covariates-class

Covariates class.
covariate-class

Covariate class.
getSimulationEngineType

Get simulation engine type.
getSeedForParametersSampling

Get seed for parameter uncertainty sampling.
dosingOnly

Filter CAMPSIS output on dosing rows.
getSplittingConfiguration

Get splitting configuration for parallel export.
UniformDistribution

Create an uniform distribution.
importCampsismodToNamespace

Import the whole campsismod package into NAMESPACE when parsed by 'roxygen'.
nocb_settings-class

NOCB settings class.
mrgsolve_engine-class

mrgsolve engine class.
nhanes

NHANES database (demographics and body measure data combined, from 2017-2018).
getFixedCovariates

Get all fixed covariates.
applyCompartmentCharacteristics

Apply compartment characteristics from model. In practice, only compartment infusion duration needs to be applied.
getSeed

Get seed value.
constant_distribution-class

Constant distribution class.
event-class

Event class.
convertTime

Convert numeric time vector based on the provided units.
VPC

Compute the VPC summary. Input data frame must contain the following columns: - replicate: replicate number - low: low percentile value in replicate (and in scenario if present) - med: median value in replicate (and in scenario if present) - up: up percentile value in replicate (and in scenario if present) - any scenario column
getTimeVaryingCovariates

Get all time-varying covariates.
preprocessSettings

Preprocess the simulation settings.
getFurrrScheduling

Get scheduling mode for furrr (see argument 'scheduling' available in furrr options).
obsOnly

Filter CAMPSIS output on observation rows.
event_covariate-class

Event covariate class.
events-class

Events class.
getIOVs

Get all IOV objects.
getTimes

Get all distinct times for the specified object.
getTimeVaryingVariables

Get all time-varying variables. These variables are likely to be influenced by the NOCB mode chosen and by the 'nocbvars' vector.
preprocessIds

Preprocess subjects ID's.
dropOthers

Return the 'DROP_OTHERS' string that may be used in the 'outvars' vector for RxODE/mrgsolve to drop all others variables that are usually output in the resulting data frame.
preprocessSlices

Preprocess 'slices' argument.
preprocessNocbvars

Preprocess 'nocbvars' argument.
setSubjects

Set the number of subjects.
simulateDelegate

Simulation delegate (several replicates).
preprocessTSLDAndTDOSColumn

Preprocess TSLD and TDOS columns according to given dataset configuration.
getOccasions

Get all occasions.
mergeTimeVaryingCovariates

Merge time-varying covariates into a single data frame. This last data frame will be merged afterwards with all treatment and observation rows.
length,arm-method

Return the number of subjects contained in this arm.
counterBalanceLocfMode

Counter-balance LOCF mode for occasions & IOV. This function will simply shift all the related occasion & IOV columns to the left (by one).
dataset_config-class

Dataset configuration class.
counterBalanceNocbMode

Counter-balance NOCB mode for occasions & IOV. This function will simply shift all the related occasion & IOV columns to the right (by one).
getDatasetMaxTime

Get dataset max time.
leftJoinIIV

Left-join IIV matrix.
output_function-class

Output function class.
observations-class

Observations class.
hardware_settings-class

Hardware settings class.
progress_settings-class

Progress settings class.
infusion-class

Infusion class.
onCran

Check if the current session is on CRAN. The objective is to potentially suppress long tasks to be run on CRAN (long tests or vignettes).
preprocessArmColumn

Preprocess ARM column. Add ARM equation in model automatically.
preprocessScenarios

Pre-process scenarios.
internal_settings-class

Internal settings class (transient object from the simulation settings).
minutes

Convert minutes to hours.
scatterPlot

Scatter plot (or X vs Y plot).
preprocessReplicates

Preprocess 'replicates' argument.
getInitialConditions

Get initial conditions at simulation start-up.
getRandomSeedValue

Get random seed value.
exportDelegate

Export delegate method. This method is common to RxODE and mrgsolve.
simulation_progress-class

Simulation progress class.
getSeedForDatasetExport

Get seed for dataset export.
processDropOthers

Process 'DROP_OTHERS'.
vpcPlot

VPC plot.
length,dataset-method

Return the number of subjects contained in this dataset.
preprocessDest

Pre-process destination engine. Throw an error message if the destination engine is not installed.
preprocessDosing

Preprocess 'dosing' argument.
months

Convert pharma months (1 month = 4 weeks) to hours.
standardiseTime

Standardise time to hours.
sample

Sample generic object.
sampleDistributionAsTibble

Sample a distribution and return a tibble.
preprocessEvents

Pre-process events.
sampleCovariatesList

Sample covariates list.
processAllTimeColumns

Process time-related columns according to given dataset configuration.
sampleTimeVaryingCovariates

Sample time-varying covariates.
processArmLabels

Process arm labels. Arm identifiers in ARM column are replaced by arm labels as soon as one arm label is provided.
treatment-class

Treatment class.
generateIIV

Generate IIV matrix for the given Campsis model.
getCovariates

Get all covariates (fixed / time-varying / event covariates).
observations_set-class

Observations set class.
occasions-class

Occasions class.
days

Convert days to hours.
occasion-class

Occasion class.
generateIIV_

Generate IIV matrix for the given OMEGA matrix.
simulation_engine-class

Simulation engine class.
isEmptyBootstrap

Is the given bootstrap empty.
onCI

Check if the current session is on CI (e.g. GitHub actions).
setupPlanDefault

Setup default plan for the given simulation or hardware settings. This plan will prioritise the distribution of workers in the following order: 1) Replicates (if 'replicate_parallel' is enabled) 2) Scenarios (if 'scenario_parallel' is enabled) 3) Dataset export / slices (if 'dataset_export' or 'slice_parallel' is enabled)
protocol-class

Protocol class.
setupPlanSequential

Setup plan as sequential (i.e. no parallelisation).
time_varying_covariate-class

Time-varying covariate class.
treatment_iovs-class

Treatment IOV's class.
shadedPlot

Shaded plot (or prediction interval plot).
scenarios-class

Scenarios class.
processSimulateArguments

Preprocess arguments of the simulate method.
preprocessTablefun

Pre-process tablefun argument.
scenario-class

Scenario class.
retrieveParameterValue

Retrieve the parameter value (standardized) for the specified parameter name.
rxode_engine-class

RxODE/rxode2 engine class.
setLabel

Set the label.
toDatasetSummary

Convert dataset to dataset summary (internal method).
setSeed

Set the seed. The goal of this method is to centralize all calls to the R method 'set.seed'.
toExplicitDistribution

Convert user-given distribution to an explicit CAMPSIS distribution. Passed distribution can be: - a NULL value. In that case, it will be converted into an 'UndefinedDistribution'. - a single numeric value. In that case, it will be converted into a 'ConstantDistribution'. - a numeric vector. In that case, it will be converted into a 'FixedDistribution'. - all available types of distribution. In this case, no conversion is applied.
simulateDelegateCore

Simulation delegate core (single replicate).
preprocessOutfun

Pre-process outfun argument.
simulation_settings-class

Simulation settings class.
seconds

Convert seconds to hours.
spaghettiPlot

Spaghetti plot.
solver_settings-class

Solver settings class. See ?mrgsolve::update. See ?rxode2::rxSolve.
simulateScenarios

Simulation scenarios.
preprocessOutvars

Preprocess 'outvars' argument. 'Outvars' is a character vector which tells CAMPSIS the mandatory columns to keep in the output dataframe.
uniteColumns

Unite the given column names.
simulate

Simulate function.
splitDataset

Split dataset according to config.
treatment_iov-class

Treatment IOV class.
weeks

Convert weeks to hours.
years

Convert pharma years (1 year = 12*4 weeks) to hours.
undefined_distribution-class

Undefined distribution class. This type of object is automatically created in method toExplicitDistribution() when the user does not provide a concrete distribution. This is because S4 objects do not accept NULL values.
reorderColumns

Reorder output columns.
removeInitialConditions

Remove initial conditions.
Bolus

Create one or several bolus(es).
ConstantDistribution

Create a constant distribution. Its value will be constant across all generated samples.
BootstrapDistribution

Create a bootstrap distribution. During function sampling, CAMPSIS will generate values depending on the given data and arguments.
Covariate

Create a non time-varying (fixed) covariate.
Dataset

Create a dataset.
BinomialDistribution

Binomial distribution.
DatasetConfig

Create a dataset configuration. This configuration allows CAMPSIS to know which are the default depot and observed compartments.
Bootstrap

Create a bootstrap object.
Arm

Create a treatment arm.
DatasetSummary

Create a dataset summary (internal method).
DoseAdaptation

Create a dose adaptation.
Declare

Create declare settings.
EventRelatedObservations

Create an event-related observations list. Please note that the provided 'times' will automatically be sorted. Duplicated times will be removed.
EventIteration

Create an event iteration object.
FixedDistribution

Create a fixed distribution. Each sample will be assigned a fixed value coming from vector 'values'.
Events

Create a list of interruption events.
EtaDistribution

Create an ETA distribution. The resulting distribution is a normal distribution, with mean=0 and sd=sqrt(OMEGA).
DiscreteDistribution

Discrete distribution.