Skip to contents

From a simulation object, this function samples bounding boxes of a custom size until a number of cells of a certain species are not sampled. If this never happens, after a fixed number of attempts the best box is returned.

Usage

bbox_sampler(simulation, which, n, n_w, n_h, nattempts = 100)

Arguments

simulation

A simulation object.

which

The species name.

n

The desired number of cells from species which.

n_w

Width of the box.

n_h

Height of the box.

nattempts

The maximum number of attempts.

Value

coordinates for a bounding box.

Examples

sim <- SpatialSimulation()
sim$add_mutant(name = "A", growth_rates = 0.08, death_rates = 0.01)
sim$place_cell("A", 500, 500)
sim$run_up_to_time(60)
#> 
 [████████████████████████████████████████] 100% [00m:00s] Saving snapshot                                 

bbox <- bbox_sampler(sim, "A", n = 15, n_w = 5, n_h = 5)
sim$sample_cells("A", bbox$p, bbox$q)
plot_tissue(sim)