Learn R Programming

cvasi: Calibration, Validation, and Simulation of TKTD models in R

The cvasi package aims to ease the use of ecotox effect models by providing an intuitive workflow. Model inputs and parameters are encapsulated in scenario objects which can be piped to other functions. Operations can be chained using the tidyr syntax. The most time-consuming processes can be run in parallel if requested.

The package provides facilities to

  • simulate effect models such as GUTS-RED, DEB, Lemna, Myriophyllum, and Algae
  • calculate effect endpoints
  • derive effect profiles (EPx values)
  • import exposure time-series from FOCUS TOXSWA
  • import fitted parameters from morse
  • and more

A graphical user interface implemented in Shiny is also available, see the cvasi.ui package. Please have a look at the Changelog for an overview of user-facing updates and changes.

Installation

Install the package from CRAN:

install.packages("cvasi", dependencies=TRUE)

Or install the newest development version from GitHub:

install.packages("remotes", dependencies=TRUE)
remotes::install_github("cvasi-tktd/cvasi", dependencies=TRUE)

For installing cvasi from GitHub on Windows computers, please make sure that you also have Rtools installed on your machine. Rtools are required to compile the package’s C code.

Documentation

The package contains the following vignettes

They can also be accessed locally by executing an R statement such as:

vignette("cvasi-1-manual", package="cvasi")

Usage

Basic usage:

library(cvasi)

# create and parameterize a GUTS-RED-IT scenario
GUTS_RED_IT() %>%
  set_param(c(kd=0.0005, hb=0, alpha=0.4, beta=1.5)) %>%
  set_exposure(data.frame(time=c(0, 100, 101, 200, 201, 400),
                          conc=c(0, 0, 0.1, 0.1, 0, 0))) %>%
  set_times(1:400) -> scenario

# simulate scenario
results <- scenario %>% simulate()
tail(results)
#>     time           D H        S
#> 395  395 0.004429420 0 0.998655
#> 396  396 0.004427206 0 0.998655
#> 397  397 0.004424993 0 0.998655
#> 398  398 0.004422781 0 0.998655
#> 399  399 0.004420570 0 0.998655
#> 400  400 0.004418360 0 0.998655

# ... and plot simulation results
plot(results)

Calculation of effects:

# calculate effect level
scenario %>% effect()
#> # A tibble: 1 x 4
#>   scenario         L L.dat.start L.dat.end
#>   <list>       <dbl>       <dbl>     <dbl>
#> 1 <GutsRdIt> 0.00135           1       400

# create a dose-response curve
scenario %>% dose_response() -> drc
head(drc)
#>   endpoint        mf      effect
#> 1        L  3.812500 0.009915394
#> 2        L  4.799653 0.013954569
#> 3        L  6.042405 0.019597765
#> 4        L  7.606938 0.027459877
#> 5        L  9.576567 0.038357524
#> 6        L 12.056184 0.053336214

# plot the dose-response curve
plot(drc)

# derive EPx values
scenario %>% epx()
#> # A tibble: 1 x 3
#>   scenario   L.EP10 L.EP50
#>   <list>      <dbl>  <dbl>
#> 1 <GutsRdIt>   19.0   82.1

Multiple scenarios can be processed in parallel without modifications to the workflow:

# enable parallel processing
future::plan(future::multisession)

# derive EPx for a list of 100 scenarios in parallel
rep(c(scenario), 100) %>% epx()

# disable parallel processing
future::plan(future::sequential)

License

The package and its source code is free and open-source software available under the GPL-3.0 license.

Issues

If you find any issues or bugs within the package, please create a new issue on GitHub.

Contributing

Contributions to the project are welcome! Please have a look at the Contribution Guidelines before submitting a Pull Request.

Acknowledgements

Financial support for creation and release of this software project was provided by Bayer Crop Science. This R package started as an internal project at Bayer Crop Science and the project owners would like to thank the people who have contributed (in no particular order):

Nils Kehrein, Johannes Witt, André Gergs, Thomas Preuss, Julian Heinrich, Zhenglei Gao, Tjalling Jager, Dirk Nickisch, Torben Wittwer, and Peter Vermeiren.

Copy Link

Version

Install

install.packages('cvasi')

Monthly Downloads

322

Version

1.4.0

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

Nils Kehrein

Last Published

February 28th, 2025

Functions in cvasi (1.4.0)

CalibrationSet

Calibration set
DEB-models

Dynamic Energy Budget (DEB) models
GUTS-RED-models

GUTS-RED models
ExposureSeries

Exposure time-series
DEB_abj

DEB_abj
Algae_Simple

Algae model with exponential growth but without additional forcings
DEBtox

DEBtox model
Algae-models

Algae models
Algae_TKTD

Algae model with exponential growth, forcings (P, I) and scaled damage
Algae_Weber

Algae model with exponential growth and forcings (I, T)
GUTS_RED_IT

GUTS-RED-IT scenario
GUTS_RED_SD

GUTS-RED-SD scenario
Rsubcapitata

An algae scenario
Lemna-models

Lemna models
Myrio

Myriophyllum model with exponential growth
Myriophyllum-models

Myriophyllum models
Lemna_SETAC

Lemna model (Klein et al. 2021)
Myrio_log

Myriophyllum model with logistic growth
Macrophyte-models

Macrophyte models
Lemna_Schmitt

Lemna model (Schmitt et al. 2013)
Scenarios

Effect scenario classes
cache_controls

Cache control simulations
Transferable

Biomass transfer class
americamysis

A DEB abj scenario of Americamysis bahia
calibrate

Fit model parameters to experimental data
dose_response

Calculate a dose response curve
batch

Batch simulation of multiple exposure levels
dmagna

A DEBtox scenario of Daphnia magna
Schmitt2013

A Lemna data set with multiple treatment levels
epx

Effect profiles (EPx values)
explore_space

Explore parameter space
effect

Effect level
epx_mtw

Calculate EPx values for a series of moving time window
import_swash

SWASH project exposure profile import
get_tag

Get scenario tag
fx

Generic to calculate effects for a particular scenario
get_model

Get model name
is_DEB

Test if argument is a DEB model
%>%

Pipe operator
log_msg

Add a log message
log_lik

Calculate log likelihood
pll_debug

Disable parallelization for debugging
lik_profile

Likelihood profiling
is_scenario

Test if argument is an effect scenario
import_toxswa

Import TOXSWA exposure series
minnow_it

A fitted GUTS-RED-IT scenario of the fathead minnow
plot

S3 plotting functions
set_bounds

Set boundaries of model parameters
set_endpoints

Set effect endpoints
plot_ppc_combi

Create PPC plot for one or more datasets
set_noexposure

Set zero exposure
is_GUTS

Test if argument is a GUTS model
plot_epx

Plot EPx values
import_morse

Import morse model parameters
is_LemnaThreshold

Test if argument is a LemnaThreshold model
focusd1

A Lemna_SETAC scenario with variable environment
is_Lemna

Test if argument is a Lemna model
log_enable

Start and stop logging
plot_ppc

Creates a PPC plot for a single dataset
set_param

Set model parameters
no_exposure

Zero exposure
minnow_sd

A fitted GUTS-RED-SD scenario of the fathead minnow
parameter_set

Set of model parameters
simulate

Simulate an effect scenario
pull_metadata

Pull metadata from scenarios
plot_lik_profile

Plot likelihood profiles or all profiled parameters
sequence

Sequence of scenarios
plot_param_space

Plot likelihood profiles or all profiled parameters
solver

Calls ODE solver for a particular model
set_init

Set initial state
set_mode_of_action

Set mode of action
log_envir

Log R environment properties
metsulfuron

Lemna data published by Schmitt (2013)
survival

Survival rate
log_scenarios

Log scenario properties
plot_scenario

Creates a prediction plot for one effect scenario
plot_sd

Creates plot of model results (uncertainties optional)
set_exposure

Set exposure time-series
simulate_batch

Batch simulation using multiple exposure series
set_tag

Set a tag
set_forcings

Set time-dependent parameters
set_times

Set output times
set_transfer

Set transfer events
set_window

Set window length