knitr::opts_chunk$set(echo = TRUE)
library(revolver)
#>  [ ctree - Clone Trees in cancer ] 
#> Author :  Giulio Caravagna <gcaravagn@gmail.com> 
#> GitHub :  caravagn/ctree 
#> 
#> Available datasets ~ use data('xxx', package='REVOLVER_datasets') to load dataset 'xxx'
#> 
#> ◉ TRACERx_NEJM_2017 Mutations from TRACERx lung (PMID: 28445112). n = 99 patients, multi-region WES, CCF. 
#> ◉ TRACERx_NEJM_2017_REVOLVER REVOLVER analysis of TRACERx_NEJM_2017. 
#> ◉ YATES_BREAST_NATMED_2015 Mutations from breast cancers (PMID: 26099045). n = 50 patients, multi-region WES, binary. 
#> ◉ CROSS_CRC_ADENOCARCINOMA_NATECOEVO_2018 Mutations from colorectal adenocarcinomas (PMID: 30177804). n = 19 patients, multi-region WES, binary. 
#> ◉ MSEQ_CRC_ADENOCARCINOMA_SET6 Mutations, copy number and purity from the Set6 multi-region colorectal adenocarcinoma sample (doi:10.1101/586560). n = 1 patient, multi-region WGS 
#> ◉ MSEQ_CRC_ADENOCARCINOMA_SET7 Mutations, copy number and purity from the Set7 multi-region colorectal adenocarcinoma sample (doi:10.1101/586560). n = 1 patient, multi-region WGS 
#>  [ Mtree - Mutation Trees in cancer ] 
#> Author :  Giulio Caravagna <gcaravagn@gmail.com> 
#> GitHub :  caravagn/mtree 
#>  [ REVOLVER - Repeated Evolution in Cancer ] 
#> Author :  Giulio Caravagna <gcaravagn@gmail.com> 
#> GitHub :  caravagn/revolver 
#>    WWW :  https://caravagn.github.io/revolver/ 
#> 
#>  > REVOLVER is part of the "evoverse" [https://bit.ly/2orn94e] - a collection of packages to implement Cancer Evolution analyses from cancer sequencing data.

Since the new release of REVOLVER (>= 0.3), we have implemented all plotting functions using ggplot2.

All functions now return either a ggplot object, or a more complext figure obtained by assembling ggplot objects either via ggarrange (package ggpubr) or plot_grid (package cowplot) cowplot. Notice that some functions might be only applicable after fits or clusters have been computed (the package will raise errors if you try to call a function on an object that does not have the required information to create the plot).

In this vignette, we apply the plotting functions to one of the cohort objects released in the evoverse.datasets R package.

# Data released in the 'evoverse.datasets'
data('TRACERx_NEJM_2017_REVOLVER', package = 'evoverse.datasets')

Plotting cohort-level data

You can plot various information about the drivers in the cohort, and the trajectories detected in the cohort. See the manual of each one of these functions to understand non-trivial plots, and how to customize the input parameters.

This graph plot can be simplified reduce the entries used to generate the edges - try for instance using min.occurrences = 5.

You can also plot the penalty of the fit, and the DET index derived from that

Plotting patient’s data and trees

You can plot the data and the trees of a patient.

# Plot the oncoprint for a patient.
plot_patient_oncoprint(TRACERx_NEJM_2017_REVOLVER, 'CRUK0002')

A full profile of the data available for a patient can be print using plot_patient_data. This function uses the above functions in combination with functions that are specific to the packages that implements the trees of the current cohort, in order to create other visualization of the data.

In the case of this cohort, since the patients have CCF-based clone trees, the reference plotting functions are from the ctree package

In a similar way, trees are plot using functions from the ctree package, called by REVOLVER.

# Plot REVOLVER trees for a patient.
plot_patient_trees(TRACERx_NEJM_2017_REVOLVER, 'CRUK0002')

The above function plots the tree score as

# Plot REVOLVER trees for a patient.
plot_patient_trees_scores(TRACERx_NEJM_2017_REVOLVER, 'CRUK0002')

Plotting REVOLVER clusters and jackknife statistics

The results of using REVOLVER to cluster your cohort can be visualised with two functions

The top tile is patients vs trajectories, and bottom is patients vs drivers. For drivers colours reflect mean CCF/ binary values of a driver in every patient, and clonality status. For trajectories colours reflect if they are initiating or progressing, depending on the present of GL in the trajectory (GL stands for germline).

The dendrogram of the clusters can be visualised - notice the colours and patients’ ordering that are matched in these two functions.

After jackknife, you can also plot the co-clustering probability of the patients, the clustering stability and other statistics about the trajectories.

S3 plotting functions

# Plot a summary
plot(TRACERx_NEJM_2017_REVOLVER)