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

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

Nicolas Luyckx

Last Published

April 12th, 2024

Functions in campsis (1.5.2)

DoseAdaptation

Create a dose adaptation.
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.
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")).
Events

Create a list of interruption events.
EventIteration

Create an event iteration object.
Settings

Create advanced simulation settings.
UniformDistribution

Create an uniform distribution.
SimulationProgress

Create a simulation progress object.
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
PI

Compute the prediction interval summary over time.
Solver

Create solver settings.
applyCompartmentCharacteristics

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

Constant distribution 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.
EtaDistribution

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

Apply scenario to the given model or dataset.
computeIncrementalProgress

Compute incremental progress.
FixedDistribution

Create a fixed distribution. Each sample will be assigned a fixed value coming from vector 'values'.
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).
covariates-class

Covariates class.
checkIIandADDL

Check ii and addl arguments in addition to time.
campsis_handler

Suggested Campsis handler for showing the progress bar.
LogNormalDistribution

Create a log normal distribution.
bootstrap-class

Bootstrap 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.
NOCB

Create NOCB settings.
bootstrap_distribution-class

Bootstrap distribution class.
fixed_covariate-class

Fixed covariate class.
dosingOnly

Filter CAMPSIS output on dosing rows.
dose_adaptations-class

Dose adaptations class.
event_covariate-class

Event covariate 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).
covariate-class

Covariate class.
convertTime

Convert numeric time vector based on the provided units.
fixed_distribution-class

Fixed distribution class.
getEventIterations

Get list of event iterations.
assignDoseNumber

Assign dose number to each treatment entry.
cutTableForEvent

Cut table according to given iteration.
bolus-class

Bolus class.
dataset-class

Dataset class.
getFixedCovariates

Get all fixed covariates.
length,dataset-method

Return the number of subjects contained in this dataset.
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.
dose_adaptation-class

Dose adaptation class.
dataset_config-class

Dataset configuration class.
event-class

Event class.
distribution-class

Distribution class. See this class as an interface.
getOccasions

Get all occasions.
getInitialConditions

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

Get all time-varying covariates.
getSplittingConfiguration

Get splitting configuration for parallel export.
events-class

Events class.
leftJoinIIV

Left-join IIV matrix.
counterBalanceLocfMode

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

Export table delegate.
getColumn

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

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

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

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

Get seed for dataset export.
getSeedForIteration

Get seed for iteration.
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.
isEmptyBootstrap

Is the given bootstrap empty.
getSeedForParametersSampling

Get seed for parameter uncertainty sampling.
getIOVs

Get all IOV objects.
occasion-class

Occasion class.
factorScenarios

Factor scenarios columns if not done yet.
getSimulationEngineType

Get simulation engine type.
fillIOVOccColumns

Fill IOV/Occasion columns.
getFurrrScheduling

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

Occasions class.
infusion-class

Infusion class.
preprocessTSLDAndTDOSColumn

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

Preprocess 'replicates' argument.
importCampsismodToNamespace

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

Progress settings class.
length,arm-method

Return the number of subjects contained in this arm.
processSimulateArguments

Preprocess arguments of the simulate method.
preprocessScenarios

Pre-process scenarios.
sampleTimeVaryingCovariates

Sample time-varying covariates.
observations-class

Observations class.
Scenario

Create an scenario.
observations_set-class

Observations set class.
preprocessArmColumn

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

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

Generate IIV matrix for the given Campsis model.
minutes

Convert minutes to hours.
protocol-class

Protocol class.
getDatasetMaxTime

Get dataset max time.
function_distribution-class

Function distribution class.
getEventCovariates

Get all event-related covariates.
months

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

Convert seconds 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.
setLabel

Set the label.
simulation_engine-class

Simulation engine class.
sampleCovariatesList

Sample covariates list.
sampleDistributionAsTibble

Sample a distribution and return a tibble.
processAllTimeColumns

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

Remove initial conditions.
simulateScenarios

Simulation scenarios.
preprocessDest

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

Unite the given column names.
mrgsolve_engine-class

mrgsolve engine class.
Scenarios

Create a list of scenarios.
reorderColumns

Reorder output columns.
nhanes

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

Arm class.
declare_settings-class

Declare settings class.
arms-class

Arms class.
days

Convert days to hours.
processArmLabels

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

Pre-process events.
scatterPlot

Scatter plot (or X vs Y plot).
setSubjects

Set the number of subjects.
scenarios-class

Scenarios class.
preprocessOutvars

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

Preprocess 'slices' argument.
setSeed

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

Preprocess 'dosing' argument.
scenario-class

Scenario class.
getAvailableTimeUnits

Return the list of available time units.
vpcPlot

VPC plot.
generateIIV_

Generate IIV matrix for the given OMEGA matrix.
preprocessNocbvars

Preprocess 'nocbvars' argument.
splitDataset

Split dataset according to config.
preprocessSettings

Preprocess the simulation settings.
shadedPlot

Shaded plot (or prediction interval plot).
retrieveParameterValue

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

Standardise time to hours.
obsOnly

Filter CAMPSIS output on observation rows.
hardware_settings-class

Hardware settings class.
getRandomSeedValue

Get random seed value.
treatment_iov-class

Treatment IOV class.
hours

Convert hours to hours (do nothing).
getSeed

Get seed value.
nocb_settings-class

NOCB settings class.
simulate

Simulate function.
simulation_progress-class

Simulation progress class.
treatment_iovs-class

Treatment IOV's class.
processDropOthers

Process 'DROP_OTHERS'.
simulateDelegate

Simulation delegate (several replicates).
simulateDelegateCore

Simulation delegate core (single replicate).
weeks

Convert weeks to hours.
preprocessFunction

Pre-process function argument.
preprocessIds

Preprocess subjects ID's.
toDatasetSummary

Convert dataset to dataset summary (internal method).
time_varying_covariate-class

Time-varying covariate class.
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)
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.
rxode_engine-class

RxODE/rxode2 engine class.
sample

Sample generic object.
treatment-class

Treatment class.
simulation_settings-class

Simulation settings class.
setupPlanSequential

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

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

Spaghetti plot.
years

Convert pharma years (1 year = 12*4 weeks) to hours.
Bolus

Create one or several bolus(es).
Bootstrap

Create a bootstrap object.
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.
Arm

Create a treatment arm.
Covariate

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

Create a dataset.
DatasetConfig

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

Create a dataset summary (internal method).
BinomialDistribution

Binomial distribution.
Declare

Create declare settings.
Event

Create an interruption event.
EventCovariate

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

Discrete distribution.