R/dynamics_addin_functions.R
create_sc_tree_plot.RdCreates a dendrogram visualization of cell lineage data from simulation results, showing the relationships between cells and their clonal evolution over time.
create_sc_tree_plot(
dynamic_sim_ob,
clone_colors,
title = "SC Dynamics Dendrogram"
)A ggraph plot object displaying the cell lineage tree with customized styling
This function creates a dendrogram visualization of cell lineage data where:
The vertical axis represents time
Edges represent cells' lifespans
Edge colors indicate the clone type of each cell
Branch lengths correspond to cell lifetimes
The function first prepares the cell information data using the prepare_tree_data function, then creates a graph object and finally generates a dendrogram visualization using ggraph. The resulting plot has publication-ready styling with customized title, legend, and axis labels.
# Define colors for each clone type
clone_colors <- c(A = "blue", B = "red")
# Create and display the lineage tree
tree_plot <- create_sc_tree_plot(dynamic_sim_ob, clone_colors, "Cell Lineage Evolution")
#> Error: object 'dynamic_sim_ob' not found
print(tree_plot)
#> Error: object 'tree_plot' not found
# Save the plot
ggsave("cell_lineage_tree.png", tree_plot, width = 10, height = 8)
#> Error in ggsave("cell_lineage_tree.png", tree_plot, width = 10, height = 8): could not find function "ggsave"