Skip to content

5. Using custom trees

Giulio Caravagna edited this page Jun 16, 2018 · 8 revisions

You can integrate REVOLVER with your favorite tool for phylogenetic inference, if its trees have the same nodes used by REVOLVER.

Besides matching REVOLVER's format, your trees should also have a score associated that you seek to maximize (e.g., a likelihood).

Automatic construction

To use your trees you can the two functions, according to the input data:

  • revolver_compute_phylogenies for CCF data;
  • revolver_compute_CLtrees for binary data.

Both functions accept precomputed arguments that should store your trees:

  1. precomputed.trees: the list of adjacency matrices;
  2. precomputed.scores: the vector of scores (not NAs).

The positions will be matched (i.e., the 1st adjacency matrix has score precomputed.scores[1] etc.). Equivalent-scoring trees will be shuffled, to avoid biases related to the order in which downstream analysis processes the trees.

Alternative (step-by-step) construction

If you do not want to use built-in functions you can exploit the revolver_phylogeny constructor, but you have to work out some more code. Here is a step-by-step example.

Take data from CRC, inspect sample and dataset

> library(revolver)
> data("CRC")
> dataset = CRC[CRC$patientID == 'adenoma_3', ]
> print(dataset)
  patientID variantID                      CCF is.clonal is.driver    Misc cluster
9  adenoma_3    PIK3CA R1:0;R2:0;R3:0;R4:1;R5:1     FALSE      TRUE NOTHING       1
10 adenoma_3     FBXW7 R1:1;R2:1;R3:1;R4:1;R5:1      TRUE      TRUE NOTHING       2
11 adenoma_3       APC R1:1;R2:1;R3:1;R4:1;R5:1      TRUE      TRUE NOTHING       2
13 adenoma_3     AKAP9 R1:0;R2:0;R3:1;R4:0;R5:0     FALSE      TRUE NOTHING       3
14 adenoma_3     KMT2C R1:1;R2:1;R3:1;R4:1;R5:1      TRUE      TRUE NOTHING       2
15 adenoma_3    TCF7L2 R1:1;R2:1;R3:1;R4:1;R5:1      TRUE      TRUE NOTHING       2
16 adenoma_3      KRAS R1:1;R2:1;R3:1;R4:1;R5:1      TRUE      TRUE NOTHING       2
17 adenoma_3      GNAS R1:0;R2:1;R3:0;R4:0;R5:0     FALSE      TRUE NOTHING       4

Define samples and extract CCF values

> samples = paste('R', 1:5, sep = '')
> CCF = sapply(dataset$CCF, revolver:::CCF.parser)
> CCF = t(apply(CCF, 2, as.numeric))
> rownames(CCF) = rownames(dataset)
> colnames(CCF) = samples
> CCF
   R1 R2 R3 R4 R5
9   0  0  0  1  1
10  1  1  1  1  1
11  1  1  1  1  1
13  0  0  1  0  0
14  1  1  1  1  1
15  1  1  1  1  1
16  1  1  1  1  1
17  0  1  0  0  0

Bind a dataset with explicit CCF values. Now you have to create your adjacency matrix m for the tree; in this dummy example we make it empty (which does not make much sense).

> dataset = cbind(dataset, CCF)
> m = matrix(0, ncol = 4, nrow = 4)
> colnames(m) = rownames(m) = 1:4

To build a rev_phylo object you use revolver_phylogeny, here we obtain a GL (germline) node attached to the root of the tree (in this case all nodes are roots, as their only incoming edge is from "GL", germline).

> r = revolver_phylogeny(m, 'adenoma_1', dataset, samples, 52)

The output of print(r) will be (see Screenshots)

REVOLVER -- Phylogeny for patient adenoma_1 

	Nodes    : 5 with GL 
	Edges    : 4 
	Samples  : R1, R2, R3, R4, R5 (Multi-region) 

	Phylogeny:			 Annotation:  
		   \-GL
		    |-1 :: PIK3CA
		    |-2 :: FBXW7, APC, KMT2C, TCF7L2, KRAS
		    |-3 [R3] :: AKAP9
		    \-4 [R2] :: GNAS

	Transfer:
		   GL ---> PIK3CA 
		   GL ---> FBXW7 
		   GL ---> APC 
		   GL ---> KMT2C 
		   GL ---> TCF7L2 
		   GL ---> KRAS 
		   GL ---> AKAP9 
		   GL ---> GNAS 

	Score    : 52 
Clone this wiki locally