Learn R Programming

morseTKTD

Advanced methods for a valuable quantitative environmental risk assessment using Bayesian inference of Survival TKTD models (like the Generalized Unified Threshold model of Survival (GUTS)).

Submission

Before a submission, you can look at prepare-for-cran , which is an open and collaborative list of things you have to check before submitting your package to the CRAN.

Otherwise, check "as-cran"" using the source package:

library(devtools)
# create documentation
devtools::document(roclets = c('rd', 'collate', 'namespace'))

Once the archive is done, check that .Rbuildignore was applied. Try to have a low size archive (< 2Mb)

Either directly

# build and check the archive
devtools::check()

Or in 2 steps:

# 1. build the package. 
devtools::build()
# 2. check the archive. 
devtools::check_built("../morseTKTD_0.1.0.tar.gz")

See the CRAN status of your sumbmission:

Install from gitlab repository

library('remotes')
remotes::install_gitlab("mosaic-software/morsetktd", host = "gitlab.in2p3.fr")

Build the manual and vignettes

library('devtools')
devtools::document(roclets = c('rd', 'collate', 'namespace'))
devtools::build_manual()
devtools::build_vignettes()

building the package

Note add to .buildignore

# remove files .rds in fixtures
rds_files <- list.files(path = "tests/testthat/fixtures", pattern = "\.rds$", full.names = TRUE)
use_build_ignore(rds_files, escape = TRUE)
library(devtools)
devtools::build()

Add dependencies

usethis::use_package("ggplot2")

Coverage

From R session

library(covr)
cov <- package_coverage("morseTKTD")

Style of process

The succession of steps

  1. data: load the data set.
  2. BinaryData, CountData or ContinuousData: make a ModelData object for binary, count and quantitative continuous data, respectively.
  3. The above-mentioned objects inherit of data.frame
  4. plot: plot a ModelData object.
  5. summary: provides a summary of a ModelData object.
  6. doseResponse: return a DoseResponse object.
  7. plot: plot a DoseResponse object.
  8. fit: fit a ModelData object and return a Fit object.
  9. plot: plot a Fit object.
  10. ppc: return a PPC object.
  11. plot: plot a PPC object.

Coding Style

Object: BigCamelCase

class(x) <- append("ObjectCamelCase", class(x))

Methods: small_snake_case

methods_snake_case <- function(object, ...){
  UseMethod("methods_snake_case")
}
methods_snake_case.ObjectCamelCase <- function(...){}

Function (no methods - not linked to object): smallCamelCase

smallCamelCase <- function(...){}

Copy Link

Version

Install

install.packages('morseTKTD')

Version

0.1.3

License

AGPL (>= 3)

Maintainer

Virgile Baudrot

Last Published

June 4th, 2025

Functions in morseTKTD (0.1.3)

SurvFit

Fits a TKTD model for survival analysis using Bayesian inference
PlotLPxt

Plot of the LPxt object
group_array

build array with indices of rows
PlotPPC

Plot an object PPC
dichromate

Survival data set of chronic laboratory toxicity tests of dichromate with Daphnia
morseTKTD-package

The 'morseTKTD' package.
PriorPosterior

Return Prior and Posterior density of parameters of SurvFit object
PredictSurvFit

Prediction base on SurvFit objects
propiconazole

Survival data set of chronic laboratory toxicity tests of propiconazole with Gammarus pulex
copper

Reproduction and survival data sets of chronic laboratory toxicity tests of copper on Daphnia
SurvIT_cst

Internal predict function
FOCUSprofile

A simulated exposure profile with 11641 time points using FOCUS model.
propiconazole_pulse_exposure

Survival data set of chronic laboratory toxicity tests of propiconazole with Gammarus pulex
SurvIT_var

Internal predict function
SurvSD_cst

Internal predict function
cadmium2

Reproduction and survival data sets of chronic laboratory toxicity tests of cadmium with snails
SurvData

Creates a data set for survival analysis
chlordan

Reproduction and survival data sets of chronic laboratory toxicity tests of chlordan with Daphnia
survFit_TKTD_params

Table of posterior estimated parameters
SurvDataCheck

Checks if an object can be used to perform survival analysis
zinc

Reproduction and survival data sets of a chronic laboratory toxicity tests of zinc with Daphnia
PlotPredictSurvFit

Plotting method for SurvPredict objects
PlotPriorPosterior

Plot of Prior and Posterior distributions
build_dX

build sub-dataframe of concentration without NA
SurvSD_var

Internal predict function
cadmium1

Reproduction and survival data sets of chronic laboratory toxicity tests of cadmium with Daphnia
build_dN

build sub-dataframe of Nsurv without NA
ComputePredictSurvFit

Compute post value on object
PlotData

Plotting method for survDataVar objects
PPC

Posterior predictive check methods
Extract

Extraction methods to recover output of fit object.
PlotLCxt

Plot of the LCxt object
LPxt

Lethal Profile calculation
LCxt

Predict Lethal Concentration at any specified time point.
ModelData

Create a list giving data to use in Bayesian inference.
CheckData

Set of function to test conformity of data