Skip to contents

This method computes the forest sticks.

Arguments

birth_threshold

The maximum birth time for the cells associated to the returned sticks (optional).

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 return 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 <- SpatialSimulation()
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 = 100)
#> 
 [████████████████████████████████████████] 100% [00m:00s] Saving snapshot                                        


sim$get_clock()
#> [1] 26.09398

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 = 120)
#> 
 [████████████████████████████████████████] 100% [00m:00s] Saving snapshot                                        


sim$get_clock()
#> [1] 50.39379

sim$add_mutant(name = "C", growth_rate = 0.3, death_rate = 0.01)
sim$mutate_progeny(sim$choose_cell_in("B"), "C")
sim$run_up_to_size(species = "C", num_of_cells = 200)
#> 
 [████████████████████--------------------] 48% [00m:00s] Cells: 58601                                            

 [████████████████████████████------------] 69% [00m:01s] Cells: 94849                                            

 [█████████████████████████████████-------] 80% [00m:02s] Cells: 122476                                           

 [███████████████████████████████████-----] 86% [00m:03s] Cells: 144555                                           

 [███████████████████████████████████████-] 97% [00m:04s] Cells: 166350                                           

 [████████████████████████████████████████] 100% [00m:04s] 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 samples forest
forest <- sim$get_samples_forest()

# search for the forest sticks
forest$get_sticks()
#> [[1]]
#>  [1]  199  256  369  461  489  656  670  768 1019 1057 1104 1110 1176 1264 1274
#> [16] 1279 1493 1586 1805
#> 
#> [[2]]
#> [1]   0   2   5  10  60  71 195 199
#> 

# search for the forest sticks whose corresponding cells have
# birth times 40 time units at most
forest$get_sticks(40)
#> [[1]]
#> [1]   0   2   5  10  60  71 195 199
#>