Skip to contents

This method searches a rectangular tissue sample.

Arguments

min_num_of_cells

A named integer vector reporting the minimum number of cells per species or mutant.

num_of_cells

The number of cells in the searched sample.

width

The width of the searched sample.

height

The height of the searched sample.

Value

If a rectangular sample satisfying the provided constraints can be found, the corresponding rectangle.

Details

The aimed sample mush satisfy the specified number of cells. The sizes of the samples are also provided a parameter of the method. The complexity of this method is \(O(|\textrm{tissue width}|*|\textrm{tissue height}|)\).

See also

Simulation

Examples

# set the seed of the random number generator
set.seed(0)

# create a simulation
sim <- SpatialSimulation()
sim$death_activation_level <- 50
sim$add_mutant(name = "A", growth_rate = 0.2, death_rate = 0.01)
sim$place_cell("A", 500, 500)
sim$run_up_to_size(species = "A", num_of_cells = 500)
#> 
 [████████████████████████████████████████] 100% [00m:00s] Saving snapshot                                 


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 = 1000)
#> 
 [████------------------------------------] 9% [00m:00s] Cells: 58212                                      

 [███████---------------------------------] 16% [00m:01s] Cells: 97489                                     

 [█████████-------------------------------] 21% [00m:02s] Cells: 127412                                    

 [███████████-----------------------------] 25% [00m:03s] Cells: 152728                                    

 [████████████----------------------------] 29% [00m:04s] Cells: 174769                                    

 [██████████████--------------------------] 33% [00m:05s] Cells: 196798                                    

 [███████████████-------------------------] 36% [00m:06s] Cells: 216623                                    

 [█████████████████-----------------------] 40% [00m:07s] Cells: 235192                                    

 [██████████████████----------------------] 44% [00m:08s] Cells: 252590                                    

 [███████████████████---------------------] 47% [00m:09s] Cells: 269344                                    

 [█████████████████████-------------------] 51% [00m:10s] Cells: 284825                                    

 [██████████████████████------------------] 54% [00m:11s] Cells: 299784                                    

 [████████████████████████----------------] 58% [00m:12s] Cells: 314126                                    

 [█████████████████████████---------------] 62% [00m:13s] Cells: 328299                                    

 [███████████████████████████-------------] 65% [00m:14s] Cells: 341856                                    

 [█████████████████████████████-----------] 70% [00m:15s] Cells: 355040                                    

 [█████████████████████████████-----------] 72% [00m:16s] Cells: 367767                                    

 [██████████████████████████████----------] 74% [00m:17s] Cells: 380094                                    

 [███████████████████████████████---------] 77% [00m:18s] Cells: 391759                                    

 [█████████████████████████████████-------] 81% [00m:19s] Cells: 403843                                    

 [██████████████████████████████████------] 83% [00m:20s] Cells: 415679                                    

 [███████████████████████████████████-----] 86% [00m:21s] Cells: 427030                                    

 [████████████████████████████████████----] 89% [00m:22s] Cells: 438087                                    

 [█████████████████████████████████████---] 92% [00m:23s] Cells: 449210                                    

 [███████████████████████████████████████-] 97% [00m:24s] Cells: 460062                                    

 [████████████████████████████████████████] 99% [00m:25s] Cells: 470992                                    

 [████████████████████████████████████████] 100% [00m:25s] Saving snapshot                                 


# find a 50x50 sample containing 80 "B" cells and 10 "A" cells at least
sim$search_sample(c("A" = 10, "B" = 80), 50, 50)
#> TissueRectangle((413,365),(462,414))