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: 58028                                             

 [███████---------------------------------] 15% [00m:01s] Cells: 93144                                            

 [████████--------------------------------] 19% [00m:02s] Cells: 120575                                           

 [██████████------------------------------] 23% [00m:03s] Cells: 144193                                           

 [███████████-----------------------------] 27% [00m:04s] Cells: 165049                                           

 [█████████████---------------------------] 31% [00m:05s] Cells: 183318                                           

 [██████████████--------------------------] 34% [00m:06s] Cells: 200960                                           

 [███████████████-------------------------] 36% [00m:07s] Cells: 217753                                           

 [█████████████████-----------------------] 40% [00m:08s] Cells: 233391                                           

 [██████████████████----------------------] 43% [00m:09s] Cells: 248295                                           

 [███████████████████---------------------] 45% [00m:10s] Cells: 262271                                           

 [████████████████████--------------------] 49% [00m:11s] Cells: 276242                                           

 [█████████████████████-------------------] 52% [00m:12s] Cells: 289242                                           

 [███████████████████████-----------------] 55% [00m:13s] Cells: 302357                                           

 [████████████████████████----------------] 58% [00m:14s] Cells: 314760                                           

 [█████████████████████████---------------] 62% [00m:15s] Cells: 327113                                           

 [███████████████████████████-------------] 65% [00m:16s] Cells: 339014                                           

 [████████████████████████████------------] 68% [00m:17s] Cells: 350607                                           

 [█████████████████████████████-----------] 71% [00m:18s] Cells: 362062                                           

 [██████████████████████████████----------] 74% [00m:19s] Cells: 373024                                           

 [███████████████████████████████---------] 75% [00m:20s] Cells: 383847                                           

 [████████████████████████████████--------] 78% [00m:21s] Cells: 394580                                           

 [█████████████████████████████████-------] 81% [00m:22s] Cells: 404843                                           

 [██████████████████████████████████------] 83% [00m:23s] Cells: 415321                                           

 [███████████████████████████████████-----] 86% [00m:24s] Cells: 425448                                           

 [████████████████████████████████████----] 88% [00m:25s] Cells: 435690                                           

 [█████████████████████████████████████---] 91% [00m:26s] Cells: 445703                                           

 [██████████████████████████████████████--] 94% [00m:27s] Cells: 455336                                           

 [████████████████████████████████████████] 99% [00m:28s] Cells: 465120                                           

 [████████████████████████████████████████] 100% [00m:28s] 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))