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

TissueSimulation

Examples

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

# create a simulation
sim <- TissueSimulation()
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)
#> 
 [███-------------------------------------] 7% [00m:00s] Cells: 42445                                                                                                                  

 [█████-----------------------------------] 11% [00m:00s] Cells: 75767                                                                                                                 

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

 [████████--------------------------------] 18% [00m:03s] Cells: 113010                                                                                                                

 [████████--------------------------------] 19% [00m:04s] Cells: 119621                                                                                                                

 [█████████-------------------------------] 22% [00m:05s] Cells: 132129                                                                                                                

 [██████████------------------------------] 23% [00m:06s] Cells: 142108                                                                                                                

 [███████████-----------------------------] 25% [00m:07s] Cells: 151000                                                                                                                

 [████████████----------------------------] 28% [00m:08s] Cells: 168797                                                                                                                

 [█████████████---------------------------] 31% [00m:09s] Cells: 182952                                                                                                                

 [██████████████--------------------------] 33% [00m:10s] Cells: 195718                                                                                                                

 [███████████████-------------------------] 36% [00m:11s] Cells: 207958                                                                                                                

 [███████████████-------------------------] 37% [00m:12s] Cells: 221903                                                                                                                

 [█████████████████-----------------------] 41% [00m:13s] Cells: 237867                                                                                                                

 [██████████████████----------------------] 43% [00m:14s] Cells: 249513                                                                                                                

 [███████████████████---------------------] 45% [00m:15s] Cells: 259506                                                                                                                

 [████████████████████--------------------] 48% [00m:16s] Cells: 270723                                                                                                                

 [█████████████████████-------------------] 50% [00m:17s] Cells: 282065                                                                                                                

 [██████████████████████------------------] 52% [00m:18s] Cells: 292527                                                                                                                

 [███████████████████████-----------------] 56% [00m:19s] Cells: 304040                                                                                                                

 [████████████████████████----------------] 58% [00m:20s] Cells: 314879                                                                                                                

 [█████████████████████████---------------] 61% [00m:21s] Cells: 323999                                                                                                                

 [██████████████████████████--------------] 63% [00m:22s] Cells: 333626                                                                                                                

 [███████████████████████████-------------] 66% [00m:23s] Cells: 343080                                                                                                                

 [████████████████████████████------------] 68% [00m:24s] Cells: 350944                                                                                                                

 [█████████████████████████████-----------] 70% [00m:25s] Cells: 356523                                                                                                                

 [█████████████████████████████-----------] 71% [00m:26s] Cells: 361936                                                                                                                

 [██████████████████████████████----------] 73% [00m:27s] Cells: 370036                                                                                                                

 [██████████████████████████████----------] 73% [00m:28s] Cells: 374999                                                                                                                

 [██████████████████████████████----------] 74% [00m:29s] Cells: 383004                                                                                                                

 [███████████████████████████████---------] 77% [00m:30s] Cells: 391502                                                                                                                

 [█████████████████████████████████-------] 80% [00m:31s] Cells: 400148                                                                                                                

 [█████████████████████████████████-------] 82% [00m:32s] Cells: 408865                                                                                                                

 [██████████████████████████████████------] 83% [00m:33s] Cells: 416756                                                                                                                

 [███████████████████████████████████-----] 85% [00m:34s] Cells: 424941                                                                                                                

 [███████████████████████████████████-----] 87% [00m:35s] Cells: 432071                                                                                                                

 [█████████████████████████████████████---] 90% [00m:36s] Cells: 439654                                                                                                                

 [█████████████████████████████████████---] 90% [00m:37s] Cells: 441020                                                                                                                

 [█████████████████████████████████████---] 91% [00m:38s] Cells: 442775                                                                                                                

 [█████████████████████████████████████---] 91% [00m:39s] Cells: 445496                                                                                                                

 [██████████████████████████████████████--] 94% [00m:40s] Cells: 453375                                                                                                                

 [████████████████████████████████████████] 98% [00m:41s] Cells: 462703                                                                                                                

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