This method computes the forest sticks.
Value
The list of the forest sticks whose associated cells have
birth time smaller than or equal to birth_threshold. Each stick is
represented as the list of cell identifiers labelling the nodes in the
stick from the higher to the deeper in the forest.
Details
A crucial node of a forest is a root of the forest, a node whose parent belongs to a different species, or the most recent common ancestor of two crucial nodes.
A stick is a path of the forest in which the only crucial nodes are the first and the last one.
This method returns the list of the forest sticks. Each stick is represented by the sequence of cell identifiers labelling the nodes in the stick.
Examples
# set the seed of the random number generator
set.seed(0)
# create a simulation
sim <- TissueSimulation()
sim$add_mutant(name = "A", growth_rate = 0.2,
death_rate = 0.01)
sim$place_cell("A", 500, 500)
sim$death_activation_level <- 100
sim$run_up_to_size(species = "A", num_of_cells = 15)
#>
[████████████████████████████████████████] 100% [00m:00s] Saving snapshot
sim$get_clock()
#> [1] 14.53053
sim$add_mutant(name = "B", growth_rate = 0.3, death_rate = 0.01)
sim$mutate_progeny(sim$choose_cell_in("A"), "B")
sim$run_up_to_size(species = "B", num_of_cells = 100)
#>
[████████████████████████████████████████] 100% [00m:00s] Saving snapshot
sim$get_clock()
#> [1] 36.98803
sim$add_mutant(name = "C", growth_rate = 0.4, death_rate = 0.01)
sim$mutate_progeny(sim$choose_cell_in("B"), "C")
sim$run_up_to_size(species = "C", num_of_cells = 2000)
#>
[████████████████████████████████████████] 100% [00m:00s] Saving snapshot
# search for a 33x33 region containing 50 cells in A and
# 50 cells in B at least and sample it
region <- sim$search_sample(c(A = 50, B = 50), 33, 33)
sim$sample_cells("S1", region$lower_corner, region$upper_corner)
# search for a 33x33 region containing 50 cells in B and
# 50 cells in C at least and sample it
region <- sim$search_sample(c(B = 50, C = 50), 33, 33)
sim$sample_cells("S2", region$lower_corner, region$upper_corner)
# build the sample forest
forest <- sim$get_sample_forest()
# search for the forest sticks
forest$get_sticks()
#> [[1]]
#> [1] 29 64 126 180 183 284 454 653 885
#>
#> [[2]]
#> [1] 0 2 5 9 18 29
#>
# search for the forest sticks whose corresponding cells have
# birth times 40 time units at most
forest$get_sticks(40)
#> [[1]]
#> [1] 29 64 126 180 183 284 454 653 885
#>
#> [[2]]
#> [1] 0 2 5 9 18 29
#>
