knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(mobster)
library(tidyr)
library(dplyr)

Clone trees from mobster fits can be computing using the internal interface with ctree.

You need to have drivers annotated your object if you want to use ctree, and every driver_label has to be unique, as it will be used as the variantID column to identify the driver event.

We show the analysis with a synthetic dataset.

# Example data where we annotate 3 events as drivers
example_data = Clusters(mobster::fit_example$best)
example_data = example_data %>% dplyr::select(-cluster, -Tail, -C1, -C2)

# Drivers annotation
drivers_rows = c(2239, 3246, 3800)

example_data$is_driver = FALSE
example_data$driver_label = NA

example_data$is_driver[drivers_rows] = TRUE
example_data$driver_label[drivers_rows] = c("DR1", "DR2", "DR3")

# Fit and print the data
fit = mobster_fit(example_data, auto_setup = 'FAST')

best_fit = fit$best
print(best_fit)

Tree computation

Tree computation removes any mutation that is assigned to a Tail cluster because the clone tree represents the clones.

# Get the trees, select top-rank
trees = get_clone_trees(best_fit)

The top-rank tree is in position 1 of trees; ctree implements S3 object methods to print an plot a tree.

top_rank = trees[[1]]

# Print with S3 methods from ctree
ctree:::print.ctree(top_rank)

We can plot the top tree, aggregating different ctree plots.

# 1) Clone tree
# 2) Input ctree data (here adjusted VAF)
# 3) Clone size barplot
ggpubr::ggarrange(
  ctree::plot.ctree(top_rank),
  ctree::plot_CCF_clusters(top_rank),
  ctree::plot_clone_size(top_rank),
  nrow = 1,
  ncol = 3
)


caravagnalab/mobster documentation built on March 25, 2023, 3:40 p.m.