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

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

Nicolas Luyckx

Last Published

February 16th, 2024

Functions in campsis (1.5.1)

EventRelatedObservations

Create an event-related observations list. Please note that the provided 'times' will automatically be sorted. Duplicated times will be removed.
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")).
Declare

Create declare settings.
UniformDistribution

Create an uniform distribution.
DoseAdaptation

Create a dose adaptation.
EtaDistribution

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

Create hardware settings.
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
computeIncrementalProgress

Compute incremental progress.
arms-class

Arms class.
arm-class

Arm class.
campsis_handler

Suggested Campsis handler for showing the progress bar.
constant_distribution-class

Constant distribution class.
ParameterDistribution

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

Create progress settings.
dataset-class

Dataset class.
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.
cutTableForEvent

Cut table according to given iteration.
checkIIandADDL

Check ii and addl arguments in addition to time.
counterBalanceLocfMode

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

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

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

Create NOCB settings.
event-class

Event class.
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.
fixed_distribution-class

Fixed distribution class.
fixed_covariate-class

Fixed covariate class.
covariate-class

Covariate class.
applyCompartmentCharacteristics

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

Create a list of scenarios.
applyScenario

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

Covariates class.
Scenario

Create an scenario.
DiscreteDistribution

Discrete distribution.
NormalDistribution

Create a normal distribution.
Observations

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

Export table delegate.
Settings

Create advanced simulation settings.
getFixedCovariates

Get all fixed covariates.
getTimeVaryingCovariates

Get all time-varying covariates.
event_covariate-class

Event covariate class.
generateIIV_

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

Events class.
getColumn

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

Create one or several infusion(s).
getTimeVaryingVariables

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

Pre-process events.
getFurrrScheduling

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

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

Preprocess 'dosing' argument.
processArmLabels

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

Create solver settings.
SimulationProgress

Create a simulation progress object.
internal_settings-class

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

Get seed for dataset export.
isEmptyBootstrap

Is the given bootstrap empty.
getSeed

Get seed value.
reorderColumns

Reorder output columns.
distribution-class

Distribution class. See this class as an interface.
getOccasions

Get all occasions.
factorScenarios

Factor scenarios columns if not done yet.
assignDoseNumber

Assign dose number to each treatment entry.
getSeedForIteration

Get seed for iteration.
dose_adaptation-class

Dose adaptation class.
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.
bolus-class

Bolus class.
retrieveParameterValue

Retrieve the parameter value (standardized) for the specified parameter name.
setupPlanSequential

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

Get random seed value.
fillIOVOccColumns

Fill IOV/Occasion columns.
shadedPlot

Shaded plot (or prediction interval plot).
getSeedForParametersSampling

Get seed for parameter uncertainty sampling.
occasion-class

Occasion class.
simulateDelegateCore

Simulation delegate core (single replicate).
bootstrap-class

Bootstrap class.
getCovariates

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

Simulation scenarios.
dataset_config-class

Dataset configuration class.
dosingOnly

Filter CAMPSIS output on dosing rows.
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.
dose_adaptations-class

Dose adaptations class.
uniteColumns

Unite the given column names.
bootstrap_distribution-class

Bootstrap distribution class.
declare_settings-class

Declare settings class.
nocb_settings-class

NOCB settings class.
importCampsismodToNamespace

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

Get dataset max time.
infusion-class

Infusion class.
obsOnly

Filter CAMPSIS output on observation rows.
length,dataset-method

Return the number of subjects contained in this dataset.
occasions-class

Occasions class.
progress_settings-class

Progress settings class.
processTSLDAndTDOSColumn

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

Preprocess 'slices' argument.
preprocessSettings

Preprocess the simulation settings.
preprocessIds

Preprocess subjects ID's.
preprocessFunction

Pre-process function argument.
simulation_settings-class

Simulation settings class.
processSimulateArguments

Preprocess arguments of the simulate method.
processDropOthers

Process 'DROP_OTHERS'.
generateIIV

Generate IIV matrix for the given Campsis model.
function_distribution-class

Function distribution class.
mergeTimeVaryingCovariates

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

Get all event-related covariates.
getEventIterations

Get list of event iterations.
solver_settings-class

Solver settings class. See ?mrgsolve::update. See ?rxode2::rxSolve.
mrgsolve_engine-class

mrgsolve engine class.
getSplittingConfiguration

Get splitting configuration for parallel export.
getSimulationEngineType

Get simulation engine type.
nhanes

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

Scatter plot (or X vs Y plot).
spaghettiPlot

Spaghetti plot.
sampleTimeVaryingCovariates

Sample time-varying covariates.
observations-class

Observations class.
observations_set-class

Observations set class.
splitDataset

Split dataset according to config.
getIOVs

Get all IOV objects.
preprocessArmColumn

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

Get initial conditions at simulation start-up.
length,arm-method

Return the number of subjects contained in this arm.
hardware_settings-class

Hardware settings class.
getTimes

Get all distinct times for the specified object.
preprocessDest

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

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

Preprocess 'nocbvars' argument.
leftJoinIIV

Left-join IIV matrix.
treatment_iov-class

Treatment IOV class.
treatment_iovs-class

Treatment IOV's class.
time_varying_covariate-class

Time-varying covariate class.
sampleDistributionAsTibble

Sample a distribution and return a tibble.
sampleCovariatesList

Sample covariates list.
toDatasetSummary

Convert dataset to dataset summary (internal method).
setLabel

Set the label.
treatment-class

Treatment class.
preprocessScenarios

Pre-process scenarios.
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.
setSeed

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

Preprocess 'replicates' argument.
protocol-class

Protocol class.
removeInitialConditions

Remove initial conditions.
rxode_engine-class

RxODE/rxode2 engine class.
sample

Sample generic object.
scenario-class

Scenario class.
scenarios-class

Scenarios class.
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)
simulate

Simulate function.
simulation_engine-class

Simulation engine class.
setSubjects

Set the number of subjects.
simulation_progress-class

Simulation progress class.
simulateDelegate

Simulation delegate (several replicates).
vpcPlot

VPC plot.
Covariate

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

Create a treatment arm.
DatasetConfig

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

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

Create a dataset summary (internal method).
Bolus

Create one or several bolus(es).
ConstantDistribution

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

Create a list of interruption events.
FixedDistribution

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

Create a log normal distribution.
Event

Create an interruption event.
Bootstrap

Create a bootstrap object.
BinomialDistribution

Binomial distribution.
EventCovariate

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

Create a dataset.
EventIteration

Create an event iteration object.
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.
PI

Compute the prediction interval summary over time.