knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-"
)

trialr

cran
version

trialr is a collection of Bayesian clinical trial designs implemented in Stan and R. The documentation is available at https://brockk.github.io/trialr/

There are many notable Bayesian designs and methods for clinical trials. However, one of the factors that has constrained their use is the availability of software. We present here some of the most popular, implemented and demonstrated in a consistent style, leveraging the powerful Stan environment for Bayesian computing.

Implementations exist in other R packages. Sometimes authors make available code with their publications. However, challenges to use still persist. Different methods are presented in disparate styles. Features implemented in one package for one design may be missing in another. Sometimes the technology chosen may only be available on a particular operating system, or the chosen technology may have fallen into disuse.

trialr seeks to address these problems. Models are specified in Stan, a state-of-the-art environment for Bayesian analysis. It uses Hamiltonian Monte Carlo to take samples from the posterior distribution. This method is more efficient than Gibbs sampling and reliable inference can usually be performed on a few thousand posterior samples. R, Stan and trialr are each available on Mac, Linux, and Windows, so all of the examples presented here work on each operating system. Furthermore, Stan offers a very simple method to split the sampling across n cores, taking full advantage of the modern multicore processors.

The designs implemented in trialr are introduced briefly below, and developed more fully in vignettes. We focus on real-life usage, including:

Examples

In all examples, we will need to load trialr

library(trialr)

CRM

The Continual Reassessment Method (CRM) was first published by @OQuigley1990. It assumes a smooth mathematical form for the dose-toxicity curve to conduct a dose-finding trial seeking a maximum tolerable dose. There are many variations to suit different clinical scenarios and the design has enjoyed relatively common use, although nowhere near as common as the ubiquitous and inferior 3+3 design.

We will demonstrate the method using a notional trial example. In a scenario of five doses, we seek the dose with probability of toxicity closest to 25% where our prior guesses of the rates of toxicity can be represented:

target <- 0.25
skeleton <- c(0.05, 0.15, 0.25, 0.4, 0.6)

Let us assume that we have already treated 2 patients each at doses 2, 3 and 4, having seen two toxicities at dose-level 4 and none elsewhere. What dose should we give to the next patient or cohort? We fit the data to the popular empiric variant of the CRM model:

fit1 <- stan_crm(outcome_str = '2NN 3NN 4TT', skeleton = skeleton, 
                 target = target, model = 'empiric', beta_sd = sqrt(1.34), 
                 seed = 123)

The parameter outcome_str = '2NN 3NN 4TT' reflects that two patients each have been treated at doses 2, 3, and 4, and that the two patients at dose 4 had toxicity but the other patients did not.

The fitted model contains lots of useful of information:

fit1
library(ggplot2)
library(tidybayes)
library(dplyr)

fit1 %>% 
  spread_draws(prob_tox[Dose]) %>% 
  ggplot(aes(x = Dose, y = prob_tox)) +
  stat_interval(.width = c(.5, .8, .95)) +
  scale_color_brewer() + 
  labs(y = 'Prob(DLT)', title = 'Posterior dose-toxicity beliefs using empiric CRM')

Several variants of the CRM are implemented in 'trialr'. These are demonstrated in the CRM vignette. Several visualisation techniques are illustrated in the Visualisation in CRM vignette. The time-to-event CRM is introduced in the TITE-CRM vignette.

Neuenschwander, Branson & Gsponer

@neuenschwanderCriticalAspectsBayesian2008 introduced a two-parameter logistic model for dose-escalation. It shares many characteristics of the CRM models presented above but instead of a skeleton, it uses as a covariate the doses under investigation divided by some reference dose.

E.g., reproducing one of the analyses in their paper:

dose <- c(1, 2.5, 5, 10, 15, 20, 25, 30, 40, 50, 75, 100, 150, 200, 250)
d_star <- 250
target <- 0.30

outcomes <- '1NNN 2NNNN 3NNNN 4NNNN 7TT'
fit <- stan_nbg(outcome_str = outcomes, real_doses = dose, d_star = d_star,
                target = target, alpha_mean = 2.15, alpha_sd = 0.84,
                beta_mean = 0.52, beta_sd = 0.8, seed = 2020, refresh = 0)

fit

This reproduces the inferences depicted in the lower right pane of Figure 1 in @neuenschwanderCriticalAspectsBayesian2008.

For more, see the Two-parameter logistic model for dose-finding by Neuenschwander, Branson & Gsponer vignette.

EffTox

EffTox by @Thall2004 is a dose-finding design that uses binary efficacy and toxicity outcomes to select a dose with a high utility score. We present it briefly here but there is a much more thorough examination in the EffTox vignette.

For demonstration, we fit the model parameterisation introduced by @Thall2014 to the following notional outcomes:

| Patient | Dose-level | Toxicity | Efficacy | |:-------:|:----------:|:--------:|:--------:| | 1 | 1 | 0 | 0 | | 2 | 1 | 0 | 0 | | 3 | 1 | 0 | 1 | | 4 | 2 | 0 | 1 | | 5 | 2 | 0 | 1 | | 6 | 2 | 1 | 1 |

outcomes <- '1NNE 2EEB'
fit2 <- stan_efftox_demo(outcomes, seed = 123)

In an efficacy and toxicity dose-finding scenario, the number of patient outcomes has increased. It is possible that patients experience efficacy only (E), toxicity only (T), both (B) or neither (N).

fit2

In this example, after evaluation of our six patients, the dose advocated for the next group is dose-level 3. This is contained in the fitted object:

fit2$recommended_dose

This is not surprising because dose 3 has the highest utility score:

fit2$utility

Sometimes, doses other than the maximal-utility dose will be recommended because of the dose-admissibility rules. See the EffTox vignette and the original papers for more details.

Functions are provided to create useful plots. For instance, it is illuminating to plot the posterior means of the probabilities of efficacy and toxicity at each of the doses on the trade-off contours used to measure dose attractiveness. The five doses are shown in red. Doses closer to the lower-right corner have higher utility.

efftox_contour_plot(fit2)
title('EffTox utility contours')

This example continues in the EffTox vignette. There are many publications related to EffTox, including @Thall2004 and @Thall2014.

Hierachical analysis of response in related cohorts

Sticking with Peter Thall's huge contribution to Bayesian clinical trials, @Thall2003 described a method for analysing treatment effects of a single intervention in several sub-types of a single disease.

We demonstrate the method for partially-pooling response rates to a single drug in various subtypes of sarcoma. This example is used in @Thall2003. Fitting the data to the model:

fit3 <- stan_hierarchical_response_thall(
  group_responses = c(0, 0, 1, 3, 5, 0, 1, 2, 0, 0), 
  group_sizes = c(0, 2 ,1, 7, 5, 0, 2, 3, 1, 0), 
  mu_mean = -1.3863,
  mu_sd = sqrt(1 / 0.1),
  tau_alpha = 2,
  tau_beta = 20)

mu and tau are mean and precision parameters for the partially-pooled effects in the model. mu_mean and mu_sd are hyperparameters for a normal prior, and tau_alpha and tau_beta are hyperparameters for an inverse gamma prior. This specification is described in the original model.

The returned object is the same type as the fits returned by rstan:

fit3

So, we can use the underlying plot method in rstan.

library(rstan)
library(ggplot2)

plot(fit3, pars = 'prob_response') + 
  geom_vline(xintercept = 0.3, col = 'orange', linetype = 'dashed') +
  labs(title = 'Partially-pooled response rates in 10 sarcoma subtypes')

The hierarchical model for binary responses is developed in its own vignette.

BEBOP in PePS2

@Thall2008 introduced an extension of EffTox that allows dose-finding by efficacy and toxicity outcomes and adjusts for covariate information. Brock, et al. (manuscript accepted but not yet in press) simplified the method by removing the dose-finding components to leave a design that studies associated co-primary and toxicity outcomes in an arbitrary number of cohorts determined by the basline covariates. They refered to the simplifed design as BEBOP, for Bayesian Evaluation of Bivariate binary Outcomes with Predictive variables.

The investigators implement the design is a phase II trial of pembrolizumab in non-small-cell lung cancer. A distinct feature of the trial is the availability of predictive baseline covariates, the most noteworthy of which is the PD-L1 tumour proportion score, shown by @Garon2015 to be a predictive biomarker for drug efficacy.

This example is demonstrated in the BEBOP vignette.

Installation

You can install the latest trialr commit from github with:

# install.packages("devtools")
devtools::install_github("brockk/trialr")

You can install the latest CRAN release by running:

install.packages("trialr")

It should go without saying that the CRAN release will be older than the github version.

Extending trialr and getting in touch

If there is a published Bayesian design you want implemented in Stan, get in touch. Contact brockk on github.

References



brockk/trialr documentation built on Oct. 19, 2023, 1:45 a.m.