Learn R Programming

GeRnika (version 1.1.0)

plot_proportions: Plot a phylogenetic tree with proportional node sizes and colors

Description

This function plots a phylogenetic tree with nodes sized and colored according to the proportions of each clone. If a matrix of proportions is provided, multiple phylogenetic trees will be plotted, each corresponding to a row of proportions.

Usage

plot_proportions(phylotree, proportions, labels = FALSE)

Value

A graph representing the phylogenetic tree, with node sizes and colors reflecting clone proportions.

Arguments

phylotree

A Phylotree class object representing the phylogenetic tree to be plotted.

proportions

A numeric vector or matrix representing the proportions of each clone in the phylogenetic tree. If a matrix is provided, each row should represent the proportions for a separate tree.

labels

A logical value indicating whether to label the nodes with gene tags (if TRUE) or gene indices (if FALSE). Default is FALSE.

Examples

Run this code
# Create an instance
# composed by 5 subpopulations of clones
# and 4 samples
instance <- create_instance(
       n = 5, 
       m = 4, 
       k = 1, 
       selection = "neutral")
       
# Extract its associated B matrix
B <- instance$B

# Create a new 'Phylotree' object
# on the basis of the B matrix
phylotree <- B_to_phylotree(B = B)

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

# Plot the phylogenetic tree taking
# into account the proportions of the
# previously generated instance
plot_proportions(phylotree, instance$U, labels=TRUE)

Run the code above in your browser using DataLab