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, RxODE 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, RxODE or mrgsolve at your choice!):

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.0

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

Nicolas Luyckx

Last Published

October 13th, 2023

Functions in campsis (1.5.0)

Arm

Create a treatment arm.
DatasetConfig

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

Check ii and addl arguments in addition to time.
BinomialDistribution

Binomial distribution.
DatasetSummary

Create a dataset summary (internal method).
obsOnly

Filter CAMPSIS output on observation rows.
Events

Create a list of interruption events.
FixedDistribution

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

Fill IOV/Occasion columns.
Event

Create an interruption event.
dose_adaptations-class

Dose adaptations class.
function_distribution-class

Function distribution class.
Infusion

Create one or several infusion(s).
Covariate

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

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

Setup default plan for the given simulation or hardware settings. This plan will prioritise the ditribution 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)
EventCovariate

Create an event covariate. These covariates can be modified further in interruption events.
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.
NOCB

Create NOCB settings.
LogNormalDistribution

Create a log normal distribution.
fixed_distribution-class

Fixed distribution class.
bootstrap_distribution-class

Bootstrap distribution class.
DoseAdaptation

Create a dose adaptation.
campsis_handler

Suggested Campsis handler for showing the progress bar.
simulate

Simulate function.
dosingOnly

Filter CAMPSIS output on dosing rows.
Dataset

Create a dataset.
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.
dose_adaptation-class

Dose adaptation class.
Scenario

Create an scenario.
preprocessOutvars

Preprocess 'outvars' argument. 'Outvars' is a character vector which tells CAMPSIS the mandatory columns to keep in the output dataframe.
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.
vpcPlot

VPC plot.
scatterPlot

Scatter plot (or X vs Y plot).
getEventIterations

Get list of event iterations.
getSeedForDatasetExport

Get seed for dataset export.
UniformDistribution

Create an uniform distribution.
Scenarios

Create a list of scenarios.
declare_settings-class

Declare settings class.
Settings

Create advanced simulation settings.
NormalDistribution

Create a normal distribution.
counterBalanceNocbMode

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

Export table delegate.
applyScenario

Apply scenario to the given model or dataset.
infusion-class

Infusion class.
getSeedForIteration

Get seed for iteration.
arm-class

Arm class.
applyCompartmentCharacteristics

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

Compute incremental progress.
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.
Observations

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

Get initial conditions at simulation start-up.
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
time_varying_covariate-class

Time-varying covariate class.
event-class

Event class.
nocb_settings-class

NOCB settings class.
arms-class

Arms class.
Declare

Create declare settings.
getOccasions

Get all occasions.
simulateScenarios

Simulation scenarios.
assignDoseNumber

Assign dose number to each treatment entry.
covariate-class

Covariate class.
ConstantDistribution

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

Get random seed value.
event_covariate-class

Event covariate class.
preprocessIds

Preprocess subjects ID's.
solver_settings-class

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

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

Dataset class.
scenario-class

Scenario class.
uniteColumns

Unite the given column names.
shadedPlot

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

Fixed covariate class.
distribution-class

Distribution class. See this class as an interface.
preprocessReplicates

Preprocess 'replicates' argument.
processTSLDAndTDOSColumn

Process TSLD and TDOS columns according to given dataset configuration.
preprocessArmColumn

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

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

Internal settings class (transient object from the simulation settings).
constant_distribution-class

Constant distribution class.
getFixedCovariates

Get all fixed covariates.
spaghettiPlot

Spaghetti plot.
generateIIV

Generate IIV matrix for the given Campsis model.
generateIIV_

Generate IIV matrix for the given OMEGA matrix.
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")).
treatment-class

Treatment class.
getTimeVaryingVariables

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

Factor scenarios columns if not done yet.
preprocessTSLDAndTDOSColumn

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

Create a bootstrap object.
getSeed

Get seed value.
Bolus

Create one or several bolus(es).
cutTableForEvent

Cut table according to given iteration.
retrieveParameterValue

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

Dataset configuration class.
preprocessNocbvars

Preprocess 'nocbvars' argument.
getSeedForParametersSampling

Get seed for parameter uncertainty sampling.
mrgsolve_engine-class

mrgsolve engine class.
getDatasetMaxTime

Get dataset max time.
getTimes

Get all distinct times for the specified object.
getSplittingConfiguration

Get splitting configuration for parallel export.
getTimeVaryingCovariates

Get all time-varying covariates.
DiscreteDistribution

Discrete distribution.
preprocessDest

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

Simulation progress class.
length,arm-method

Return the number of subjects contained in this arm.
sampleDistributionAsTibble

Sample a distribution and return a tibble.
length,dataset-method

Return the number of subjects contained in this dataset.
simulateDelegateCore

Simulation delegate core (single replicate).
EventIteration

Create an event iteration object.
ParameterDistribution

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

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

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

Sample time-varying covariates.
protocol-class

Protocol class.
SimulationProgress

Create a simulation progress object.
rxode_engine-class

RxODE/rxode2 engine class.
setupPlanSequential

Setup plan as sequential (i.e. no parallelisation).
setSubjects

Set the number of subjects.
preprocessDosing

Preprocess 'dosing' argument.
treatment_iov-class

Treatment IOV class.
simulation_settings-class

Simulation settings class.
PI

Compute the prediction interval summary over time.
Hardware

Create hardware settings.
getFurrrScheduling

Get scheduling mode for furrr (see argument 'scheduling' available in furrr options).
covariates-class

Covariates class.
bolus-class

Bolus class.
preprocessEvents

Pre-process events.
treatment_iovs-class

Treatment IOV's class.
scenarios-class

Scenarios class.
splitDataset

Split dataset according to config.
getEventCovariates

Get all event-related covariates.
hardware_settings-class

Hardware settings class.
Solver

Create solver settings.
sample

Sample generic object.
sampleCovariatesList

Sample covariates list.
reorderColumns

Reorder output columns.
bootstrap-class

Bootstrap class.
toDatasetSummary

Convert dataset to dataset summary (internal method).
preprocessSettings

Preprocess the simulation settings.
counterBalanceLocfMode

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

Occasions class.
events-class

Events class.
exportDelegate

Export delegate method. This method is common to RxODE and mrgsolve.
preprocessScenarios

Pre-process scenarios.
preprocessFunction

Pre-process function argument.
getIOVs

Get all IOV objects.
importCampsismodToNamespace

Import the whole campsismod package into NAMESPACE when parsed by 'roxygen'.
isEmptyBootstrap

Is the given bootstrap empty.
getCovariates

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

Occasion class.
getColumn

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

Set the label.
observations-class

Observations class.
leftJoinIIV

Left-join IIV matrix.
getSimulationEngineType

Get simulation engine type.
preprocessSlices

Preprocess 'slices' argument.
observations_set-class

Observations set class.
processDropOthers

Process 'DROP_OTHERS'.
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.
simulateDelegate

Simulation delegate (several replicates).
setSeed

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

Preprocess arguments of the simulate method.
simulation_engine-class

Simulation engine class.
removeInitialConditions

Remove initial conditions.
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.