Learn R Programming

GeRnika (version 1.1.0)

combine_trees: Get consensus tree between two phylogenetic trees

Description

Returns a graph representing the consensus tree between two phylogenetic trees.

Usage

combine_trees(
  phylotree_1,
  phylotree_2,
  palette = GeRnika::palettes$Simpsons,
  labels = FALSE
)

Value

a dgr_graph object representing the consensus graph between phylotree_1

phylotree_2.

Arguments

phylotree_1

A Phylotree class object.

phylotree_2

A Phylotree class object.

palette

A vector composed by the hexadecimal code of three colors. "The Simpsons" palette used as default.

labels

A boolean, if TRUE the resulting graph will be plotted with the tags of the genes in the phylogenetic trees instead of their mutation index. FALSE by default.

Examples

Run this code

# Load the predefined B matrices of the package
B_mats <- GeRnika::B_mats


B_real <- B_mats[[2]]$B_real
B_alg1 <- B_mats[[2]]$B_alg1


# Generate the tags for the genes of
# the phyogenetic tree
tags <- LETTERS[1:nrow(B_real)]


# Instantiate two \code{Phylotree} class objects on 
# the basis of the B matrices
phylotree_real <- B_to_phylotree(
                    B = B_real, 
                    labels = tags)
                    
phylotree_alg1 <- B_to_phylotree(
                    B = B_alg1, 
                    labels = tags)


# Create the consensus tree between phylotree_real
# and phylotree_alg1
consensus <- combine_trees(
               phylotree_1 = phylotree_real,
               phylotree_2 = phylotree_alg1)
               
               
# Render the consensus tree
DiagrammeR::render_graph(consensus)


# Load another palette
palette_1 <- GeRnika::palettes$Lancet


# Create the consensus tree between phylotree_real
# and phylotree_alg1 using tags and another palette
consensus_tag <- combine_trees(
                   phylotree_1 = phylotree_real, 
                   phylotree_2 = phylotree_alg1,
                   palette = palette_1,
                   labels = TRUE)


# Render the consensus tree using tags and the
# selected palette
DiagrammeR::render_graph(consensus_tag)

Run the code above in your browser using DataLab