Author: Nan Chen, Brian Hobbs, and Michael J. Kane
Date: 2021-10-14

# Using the basket Package

#### Nan Chen, Brian Hobbs, and Michael J. Kane

#### 2021-10-14

The R `basket` package provides for the designs and analysis of basket trials for multi-source exchangeability models (MEM), which allows arms to “share” power with similar arms in a trial. The package is intended to perform the exact or MCMC computation of the operating characteristics of different scenarios. Calculations derived from these analyses include the posterior probabilities, HPD boundaries, effective sample sizes (ESS), mean and median estimations can be calculated with this package using the MEM method. Along with providing “basketwise” analyses, the package includes similar calculations for “clusterwise” analyses where a cluster a set of similar baskets. In addition plotting tools are provided to visualize basket and cluster density as well as their exchangeability. The package includes the following main functions:

- basket() - Create a basket analysis.
- basket_name() - Get the basket names in an analysis
- basket_pep() - Get the Posterior Exchangeability Probability (PEP) matrix for the arms in the trial.
- basket_map() - Get the Maximum A Posteriori (MAP) matrix for the arms in a trial.
- cluster_pep() - Get the Posterior Exchangeability Probability (PEP) matrix for the arms in the trial.
- cluster_map() - Get the Maximum A Posteriori (MAP) matrix for the arms in a trial.
- sample_posterior() - Sample from the posterior distribution of the arms in the trial.
- summary() - Summarize the results of an analysis.
- update_p0() - Update the null that a basket response rate is above a specified value.
- plot_density() - Plot the estimated densities of arms or clusters.
- plot_pep() - Show the exchangeogram of the PEP matrix.
- plot_mem() - Plot the arm prior, MAP, and PEP of a basket trial.

## The Vemurafenib Study under Multi-source Exchangeability

As a case study, consider the recent vemurafenib study that was performed for multiple nonmelanoma cancers with BRAF V600 Mutations by Hynman et al. This was a basket study to assess the efficacy of vemurafenib for Non-Small Cell Lung Cancer (NSCLC), ColoReCtal (CRC) treated with vemurafenib only, CRC treated with both vemurafenib and cetuximab, cholangiocarcinoma (Bile Duct), Erdheim–Chester disease or Langerhans’-cell histiocytosis (ECD/LCH), and anaplastic thyroid cancer (ATC). The results of the trials are summarized in the following table.

Basket | Enrolled | Evauable | Responders | Prior Thrpy <= 1 | Prior Thrpy = 2 | Prior Thrpy >= 3
--- | --- | --- | --- | --- | --- | ---
NSCLC | 20 | 19 | 8 | 11 | 4 | 5
CRC (vemu) | 10 | 10 | 0 | 1 | 2 | 7
CRC (vemu+cetu) | 27 | 26 | 1 | 5 | 11 | 11
Bile Duct | 8 | 8 | 1 | 2 | 1 | 5
ECD or LCH | 18 | 14 | 6 | 9 | 7 | 2
ATC | 7 | 7 | 2 | 5 | 1 | 1

The table indicates an association between the number of prior therapies and the success of an arm, which suggests heterogeneity in the population of arms. That is some baskets have many enrollees with many prior therapies and others do not. As a result, the response rates arms with favorable enrollment (NSCLC, ECD or LCH, and ATC) are better than those with unfavorable enrollment (CRC (vemu), CRC (vemu+cetu), and Bile Duct). In light of this we may want to allow a favorable-enrollment arm to borrow power from another favorable-enrollment arm depending on how similar they are. This essentially allow arms that are smaller, but similar to other arms to increase their sample size. This combination of actual and borrowed samples is termed the effective sample size (ESS) and is included in the analysis.

An MEM analysis is performed in the `basket` package using the `basket()` function. The exact variation provides results up to numerical precision and is appropriate for trials with few arms. The Markov-chain Monte Carlo (MCMC) variation scales to larger trials with results that are generally within 2-3 significant digits of the exact version (under the default number of iterations). Both the exact and MCMC analyses are performed by specifying the size, number of responders, and null response rate.

    # Load the basket library.
    library(basket)

    # Load the vemurafenib data.
    data(vemu_wide)

    # Perform the analysis.
    vemu_basket <- basket(responses = vemu_wide$responders,
                          size = vemu_wide$evaluable,
                          name = vemu_wide$baskets,
                          cluster_analysis = TRUE,
                          p0 = 0.15)

    # Show the trial diagnostics.
    summary(vemu_basket)

    #>
    #> ── The MEM Model Call ──────────────────────────────────────────────────────────
    #>
    #> mem_mcmc(responses = responses, size = size, name = name, p0 = p0,
    #>     shape1 = shape1, shape2 = shape2, prior = prior, hpd_alpha = hpd_alpha,
    #>     alternative = alternative, mcmc_iter = mcmc_iter, mcmc_burnin = mcmc_burnin,
    #>     initial_mem = initial_mem, seed = seed, cluster_analysis = cluster_analysis,
    #>     call = call, cluster_function = cluster_function)
    #>
    #> ── The Basket Summary ──────────────────────────────────────────────────────────
    #>
    #> The Null Response Rates (alternative is greater):
    #>                NSCLC CRC (vemu) CRC (vemu+cetu) Bile Duct ECD or LCH   ATC
    #> Null            0.15      0.150           0.150      0.15      0.150 0.150
    #> Posterior Prob  1.00      0.026           0.018      0.35      0.999 0.971
    #>
    #> Posterior Mean and Median Response Rates:
    #>        NSCLC CRC (vemu) CRC (vemu+cetu) Bile Duct ECD or LCH   ATC
    #> Mean   0.394      0.054           0.053     0.149      0.393 0.359
    #> Median 0.392      0.046           0.045     0.097      0.391 0.362
    #>
    #> Highest Posterior Density Interval with Coverage Probability 0.95:
    #>             NSCLC CRC (vemu) CRC (vemu+cetu) Bile Duct ECD or LCH   ATC
    #> Lower Bound 0.241      0.000           0.001     0.004      0.237 0.176
    #> Upper Bound 0.548      0.128           0.122     0.404      0.550 0.559
    #>
    #> Posterior Effective Sample Size:
    #>  NSCLC CRC (vemu) CRC (vemu+cetu) Bile Duct ECD or LCH    ATC
    #>  37.45     50.284          54.332    10.581     36.237 22.688
    #>
    #> ── The Cluster Summary ─────────────────────────────────────────────────────────
    #>
    #> Cluster 1
    #>  "CRC (vemu)" "CRC (vemu+cetu)" "Bile Duct"
    #> Cluster 2
    #>  "NSCLC" "ECD or LCH" "ATC"
    #>
    #> The Null Response Rates (alternative is greater):
    #>                            Cluster 1 Cluster 2
    #> Posterior for null of 0.15     0.132      0.99
    #>
    #> Posterior Mean and Median Response Rates:
    #>        Cluster 1 Cluster 2
    #> Mean       0.085     0.382
    #> Median     0.056     0.382
    #>
    #> Highest Posterior Density Interval with Coverage Probability 0.95:
    #>             Cluster 1 Cluster 2
    #> Lower Bound     0.000     0.219
    #> Upper Bound     0.318     0.554
    #>
    #> Posterior Effective Sample Size:
    #>  Cluster 1 Cluster 2
    #>      9.417    30.928

The output of the `summary` is composed of three parts. The first shows the expression that was used to construct the analysis. The second provides information about the trial at the basket level including, the probability each arm is above the specified null response rate, the mean an median response rate for each arm, the Highest Posterior Density (HPD) interval at the significance level (specified by the `hpd_alpha` parameter), and the ESS. Additionally, the arms are clustered and similar diagnostics are reported for the clusters along with the arms that compose each cluster.

The analysis estimates the posterior distribution of the response rate for both the arms and the clusters. Distributions for arms and can be inspected visually via the `plot_density()` with the analysis as the argument. If only the density of the arms should be shown then the `type = "basket"` can be used. The same is true for `type = "cluster"` for the cluster density plot.

    plot_density(vemu_basket$basket)
    #> Warning: It is deprecated to specify `guide = FALSE` to remove a guide. Please
    #> use `guide = "none"` instead.

Along with the densities, the package can show the exchangeability between the individual arms via, what we are terming, an exchangeogram. This is similar to a correlogram but, rather than showing correlations among variables, an exchangeogram shows the exchangeability between arms. Exchangeograms for MEM analyses can be created using the `plot_mem()` function. By default the prior exchangeability, MAP exchangeability, and posterior exchangeability are shown in a single plot, and is controlled by the default parameter `type = c("prior", "map", "pep")`. Along with the visualization, the MAP and PEP matrices can retrieved with the `basket_map()` and `basket_pep()` function for baskets and `cluster_map()` and `cluster_pep()` function for clusters.

    # Move the basket name labels to the left using
    # the basket_name_hoffest option
    plot_mem(vemu_basket, text_size = 1.75, expand = c(0.5, 0.5), basket_name_hjust = 0.85)