Skip to contents

This method builds a subforest using as leaves some of the original samples.

Arguments

sample_names

The names of the samples whose cells will be used as leaves of the new forest

Value

A samples forest built on the samples mentioned in sample_names

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


# sample the region [450,500]x[475,550]
sim$sample_cells("S1", lower_corner=c(450,475), upper_corner=c(500,550))

sim$run_up_to_size(species = "A", num_of_cells = 60000)
#> 
 [████████████████████████████████████████] 100% [00m:00s] Saving snapshot                                        


# sample again the same region
sim$sample_cells("S2", lower_corner=c(450,475), upper_corner=c(500,550))

# build the samples forest
forest <- sim$get_samples_forest()

forest$get_subforest_for("S2")
#> SamplesForest
#>   # of trees: 1
#>   # of nodes: 9477
#>   # of leaves: 2378
#>   samples: {"S2"}
#>