Description Usage Arguments Examples
update_colors
Update the colors of clones in the frequency dynamics dataframe or dendrogram plot dataframe
1 2 3 |
evo_freq_df |
Dataframe returned by |
clones |
Array containing the clone ids. The index of each clone must correspond to the same index of the row in |
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 |
clone_cmap |
String defining which colormap should be used to color the clones (nodes) if no attributes to color by. For a list of available colormaps, see https://github.com/bhaskarvk/colormap |
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_name |
String defining the name of the attribute used for coloring. If NULL, the default, the name will be inferred from the |
shuffle_colors |
Boolean determining if colors should be shuffled before being assigned to each clone. Only applies when fill_value = NULL |
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 39 40 41 42 43 44 | 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)))))
size_df <- example.easy.wide[, time_col_idx]
parents <- example.easy.wide$parents
clones <- example.easy.wide$clones
### Setting of colors can be done when getting the freq_frame, or by updating the color later using \code{\link{update_colors}}. For a list of available colormaps, see https://github.com/bhaskarvk/colormap.
### Default colormap is rainbow_soft, but this can be changed using the \code{clone_cmap} argument.
freq_frame <- get_evofreq(size_df, clones, parents)
evo_p <- plot_evofreq(freq_frame)
### Can color each clone by an attribute by providing a \code{fill_value}. Default colormap is viridis, but this can be changed using the \code{clone_cmap} argument. There is also the option to set the color range using the \code{fill_range} argument
fitness <- runif(length(clones),0, 100)
fitness_freq_frame <- update_colors(freq_frame, clones = clones, fill_value = fitness, fill_range= c(0, 100))
fitness_evo_p <- plot_evofreq(fitness_freq_frame, fill_range = c(0, 100))
### The user can also provide custom colors for each clone, which will need to be passed into the \code{fill_value} argument
### Custom colors can be defined using RGB values. Each color should be a string specifying the color channel values, separated by commas.
rgb_clone_colors <- sapply(seq(1, length(clones)), function(x){paste(sample(0:255,size=3,replace=TRUE),collapse=",")})
rgb_freq_frame <- update_colors(freq_frame, clones = clones, fill_value = rgb_clone_colors)
rgb_evo_p <- plot_evofreq(rgb_freq_frame)
### Custom colors can also be any of the named colors in R. A list of the colors can be found with \code{colors()}
named_clone_colors <- sample(colors(), length(clones), replace = FALSE)
named_freq_frame <- update_colors(freq_frame, clones = clones, fill_value = named_clone_colors)
named_evo_p <- plot_evofreq(named_freq_frame)
### Custom colors can also be specified using hexcode
hex_clone_colors <- c("#614099ff", "#1d347eff", "#94558aff", "#c96872ff", "#f1884dff", "#e8fa5bff", "#042333ff","#f9bb41ff")
hex_freq_frame <- update_colors(freq_frame, clones = clones, fill_value = hex_clone_colors)
hex_evo_p <- plot_evofreq(hex_freq_frame)
### Method can also be used to update node colors of the dendrograms
dendro_df <- get_evogram(size_df, clones, parents)
tree_pos <- dendro_df$dendro_pos
tree_links <- dendro_df$links
tree_p <- plot_evogram(tree_pos, tree_links)
### Color node by fitness
tree_pos_fitness_color <- update_colors(evo_freq_df = tree_pos, clones = clones, fill_value = fitness)
tree_p_fitness <- plot_evogram(tree_pos_fitness_color, tree_links)
### Color node using custom colors in hexcode format
tree_info_custom_color <- update_colors(evo_freq_df = tree_pos, clones = clones, fill_value = hex_clone_colors)
tree_p_custom_color <- plot_evogram(tree_info_custom_color, tree_links)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.