get_evogram: get_evogram Collect information to plot dendrogram

Description Usage Arguments Value Examples

View source: R/Dendro_funcs.R

Description

get_evogram

Collect information to plot dendrogram

Usage

1
2
3
4
5
get_evogram(size_df, clones, parents, fill_value = NULL,
  fill_range = NULL, time_pt = NULL, clone_cmap = NULL,
  threshold = 0.01, data_type = "size", fill_gaps_in_size = FALSE,
  test_links = TRUE, link_type = "elbow",
  rescale_after_thresholding = FALSE, shuffle_colors = FALSE)

Arguments

size_df

Dataframe in a wide format, where each row corrsponds to a single clone, and the columns are the sizes of that clone at each timepoint

clones

Array containing the clone ids. The index of each clone must correspond to the same index of the row in size_df that contains the sizes of that clone over time

parents

Array containing the ids of the parent of each clone in the clones array.

fill_value

Array containing information that can be used to color each clone. If NULL (the default), each clone is assigned a color. If values are a clone attribute, e.g. fitness, then the colors are assigned according to those values. The user can also provide custom colors in 3 ways: 1) hexcode; 2) rgb values as a string, with each value being a the intensity of the color channel, each separated by commas, e.g. "255, 10, 128"; 3) Any of the named in colors in R, which can be found with colors

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.

time_pt

Timepoint with which the dendrgram should be drawn

clone_cmap

Colormap to use for the clones. For a list of available colormaps, see https://github.com/bhaskarvk/colormap.

threshold

The minimum frequency of clones to be plotted. Clones with with a frequency below this value will not be plotted

data_type

String defining what kind of information is in size_df. If "size", then the values in size_df are the population sizes. If "mutation", the values are the frequencies, between 0 and 1, of each mutation in the population over time

fill_gaps_in_size

Boolean defining whether or not missing sizes should be filled in

test_links

Make sure clone does not have the same id as it's parent. If true, it can cause infinite recursion.

link_type

Defines the shape of the edges berween nodes: "straight" draws straight lines between parents and childrend, while "elbow" draws a step from parent to child

rescale_after_thresholding

Boolean determining if frequencies should be rescaled after thresholding, so that frequencies are based on what was above the threshold.

shuffle_colors

Boolean determining if colors should be shuffled before being assigned to each clone. Only applies when fill_value = NULL

Value

List containing two dataframes: "dendro_pos" contains the positions of the nodes, "links" contains the positions of the edges between nodes

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
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 straight 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)

### Can also set nodes to be colored by attribute
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

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, scale_by_node_size = TRUE)

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