plot_evogram: plot_evogram Plot dendrogram

Description Usage Arguments Value Examples

View source: R/Dendro_funcs.R

Description

plot_evogram Plot dendrogram

Usage

1
2
plot_evogram(dendro_pos_df, link_df, fill_range = NULL, node_size = 5,
  scale_by_node_size = TRUE, orientation = "td", depth = "origin")

Arguments

dendro_pos_df

Position of nodes returned by get_evogram

link_df

Position of edges returned by get_evogram

fill_range

Array containing the minimum and maximum values to set the range of colors. If NULL (the default), the range is determined directly from fill_value.

node_size

Determines the size of nodes if scale_by_node_size is FALSE

scale_by_node_size

Boolean defining if the size of each node should be proportional to its frequency. If FALSE, then all nodes have the same size, determined by node_size

orientation

Defines orientation of the tree: "td" draws it top-down, "lr" draws it left-right

depth

Determines the y-position of the nodes: "level" places the nodes based on how deeply they are nested in the tree, "origin" makes the y-position the same as the clone's origin time, "bottom" positions nodes so that all leaves have the same position, furthest from the root

Value

a ggplot object to plot the tree

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
data("example.easy.wide")
### Split dataframe into clone info and size info using fact timepoint column names can be converted to numeric values
time_col_idx <- suppressWarnings(which(! is.na(as.numeric(colnames(example.easy.wide)))))
attribute_col_idx <- suppressWarnings(which(is.na(as.numeric(colnames(example.easy.wide)))))

size_df <- example.easy.wide[, time_col_idx]
parents <- example.easy.wide$parent
clones <- example.easy.wide$clone

tree_info <- get_evogram(size_df, parents = parents, clones = clones)
tree_pos <- tree_info$dendro_pos
elbow_links <- tree_info$links
tree_p <- plot_evogram(tree_pos, elbow_links)

### Can also plot with elbow links
tree_info <- get_evogram(size_df, parents = parents, clones = clones, link_type = "straight")
tree_pos <- tree_info$dendro_pos
straight_links <- tree_info$links
tree_straight_p <- plot_evogram(tree_pos, straight_links)

### Default is for y to show time of clonal origin , all leaves can be at the highest level
elbow_bottom_p <- plot_evogram(tree_pos, elbow_links, depth = "bottom")
### Can view left to right by changing orientation argument
lr_tree_elbow_p <- plot_evogram(tree_pos, elbow_links, orientation = "lr")
#' ### Can color using attributes
data("example.easy.wide.with.attributes")
### Split dataframe into clone info and size info using fact timepoint column names can be converted to numeric values
time_col_idx <- suppressWarnings(which(! is.na(as.numeric(colnames(example.easy.wide.with.attributes)))))
attribute_col_idx <- suppressWarnings(which(is.na(as.numeric(colnames(example.easy.wide.with.attributes)))))
attr_size_df <- example.easy.wide.with.attributes[, time_col_idx]
attr_parents <- example.easy.wide.with.attributes$parent
attr_clones <- example.easy.wide.with.attributes$clone
fitness <- example.easy.wide.with.attributes$fitness
#' ### Can set color using attributes. Default colormap is viridis, but can be changed to any colormap available in the colormaps package. For a list of available colormaps, see https://github.com/bhaskarvk/colormap
attribute_dendro_df <- get_evogram(attr_size_df, attr_clones, attr_parents, fill_value = fitness)
attribute_tree_pos <- attribute_dendro_df$dendro_pos
attribute_elbow_links <- attribute_dendro_df$links
attribute_tree_elbow_p <- plot_evogram(attribute_tree_pos, attribute_elbow_links)

MathOnco/EvoFreq documentation built on Jan. 26, 2022, 7:31 p.m.