This function uses the output fit of VIBER
to create a call to ctree (https://caravagn.github.io/ctree/),
a package to create clone trees for cancer evolution models.
Creation of a clone tree requires annotations that are not usually
necessary for just a plain VIBER analyses. These annotations report the status of driver
and gene for each one of the input datapoints; the annotations should
have been passed when calling the variational_fit function, and stored
inside the data field of the VIBER object.
The clonal cluster is estimated from the cluster with the highest parameter values in most of the input dimensions (Binomial peaks).
The output is the result of calling the constructor ctree::cetrees
on the input clustering results x.
get_clone_trees(x, ...)The output of the constructor ctree::cetrees.
data(mvbmm_example)
# We create annotation data assigning dummy names
# and picking 10 events to be drivers (randomly chosen)
data_annotations = data.frame(
gene = paste0("G", 1:nrow(mvbmm_example$trials)),
driver = FALSE
)
data_annotations$driver[sample(1:nrow(data_annotations), 10)] = TRUE
# Compared to the main variational_fit, we use the same call but add data
f = variational_fit(mvbmm_example$successes, mvbmm_example$trials, data = data_annotations)
#> [ VIBER - variational fit ]
#>
#> ℹ Input n = 231, with k < 10. Dirichlet concentration α = 1e-06.
#> ℹ Beta (a_0, b_0) = (1, 1); q_i = prior. Optimise: ε = 1e-10 or 5000 steps, r = 10 starts.
#>
#> ✔ VIBER fit completed in 0.04 mins (status: converged)
#>
#> ── [ VIBER ] My VIBER model n = 231 (w = 2 dimensions). Fit with k = 10 clusters
#> • Clusters: π = 45% [C8], 28% [C7], 20% [C4], and 7% [C10], with π > 0.
#> • Binomials: θ = <0.5, 0.49> [C8], <0, 0.2> [C7], <0.25, 0.25> [C4], and <0.22,
#> 0> [C10].
#> ℹ Score(s): ELBO = -47073.33. Fit converged in 18 steps, ε = 1e-10.
print(f)
#> ── [ VIBER ] My VIBER model n = 231 (w = 2 dimensions). Fit with k = 10 clusters
#> • Clusters: π = 45% [C8], 28% [C7], 20% [C4], and 7% [C10], with π > 0.
#> • Binomials: θ = <0.5, 0.49> [C8], <0, 0.2> [C7], <0.25, 0.25> [C4], and <0.22,
#> 0> [C10].
#> ℹ Score(s): ELBO = -47073.33. Fit converged in 18 steps, ε = 1e-10.
trees = get_clone_trees(f)
#> Estimated clonal cluster C8 from VIBER fit.
#> Found 4 driver event(s) in VIBER fits.
#> [ ctree ~ clone trees generator for VIBER_dataset ]
#>
#> # A tibble: 4 × 6
#> cluster S1 S2 nMuts is.clonal is.driver
#> <chr> <dbl> <dbl> <int> <lgl> <lgl>
#> 1 C4 0.251 0.254 47 FALSE TRUE
#> 2 C7 0.000155 0.203 65 FALSE TRUE
#> 3 C8 0.498 0.493 103 TRUE TRUE
#> 4 C10 0.217 0.000658 16 FALSE TRUE
#>
#> ✔ Trees per region 2, 2
#> ℹ Total 4 tree structures - search is exahustive
#>
#> ── Ranking trees
#> ✔ 4 trees with non-zero score, storing 4
ctree::print.ctree(trees[[1]])
#> [ ctree - ctree rank 1/4 for VIBER_dataset ]
#>
#> # A tibble: 4 × 6
#> cluster S1 S2 nMuts is.clonal is.driver
#> <chr> <dbl> <dbl> <int> <lgl> <lgl>
#> 1 C4 0.251 0.254 47 FALSE TRUE
#> 2 C7 0.000155 0.203 65 FALSE TRUE
#> 3 C8 0.498 0.493 103 TRUE TRUE
#> 4 C10 0.217 0.000658 16 FALSE TRUE
#>
#> Tree shape (drivers annotated)
#>
#> \-GL
#> \-C8 :: G47, G63
#> |-C4 :: G111, G173
#> | \-C10 :: G151, G201
#> \-C7 :: G102, G159, G196, G204
#>
#> Information transfer
#>
#> G47 ---> G111
#> G47 ---> G173
#> G63 ---> G111
#> G63 ---> G173
#> G47 ---> G102
#> G47 ---> G159
#> G47 ---> G196
#> G47 ---> G204
#> G63 ---> G102
#> G63 ---> G159
#> G63 ---> G196
#> G63 ---> G204
#> GL ---> G47
#> GL ---> G63
#> G111 ---> G151
#> G111 ---> G201
#> G173 ---> G151
#> G173 ---> G201
#>
#> Tree score 0.25
#>
ctree::plot.ctree(trees[[1]])