
Searching for a rectangular tissue sample
Source:R/RcppExports.R
TissueSimulation-cash-search_sample.Rd
This method searches a rectangular tissue sample.
Value
If a rectangular sample satisfying the provided constraints can be found, the corresponding rectangle.
Details
The aimed sample must satisfy the specified number of cells. The size of the sample is also provided a parameter of the method. The complexity of this method is \(O(|\textrm{tissue width}|*|\textrm{tissue height}|)\).
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)
#>
[████------------------------------------] 9% [00m:00s] Cells: 63927
[███████---------------------------------] 16% [00m:00s] Cells: 104484
[█████████-------------------------------] 22% [00m:01s] Cells: 136669
[███████████-----------------------------] 27% [00m:02s] Cells: 161748
[█████████████---------------------------] 31% [00m:03s] Cells: 181561
[██████████████--------------------------] 34% [00m:04s] Cells: 202504
[███████████████-------------------------] 37% [00m:05s] Cells: 221407
[█████████████████-----------------------] 41% [00m:06s] Cells: 239482
[██████████████████----------------------] 44% [00m:07s] Cells: 257017
[████████████████████--------------------] 48% [00m:08s] Cells: 272846
[█████████████████████-------------------] 51% [00m:09s] Cells: 287740
[███████████████████████-----------------] 56% [00m:10s] Cells: 302493
[████████████████████████----------------] 58% [00m:11s] Cells: 316782
[██████████████████████████--------------] 63% [00m:12s] Cells: 329663
[███████████████████████████-------------] 65% [00m:13s] Cells: 341697
[████████████████████████████------------] 69% [00m:14s] Cells: 353548
[█████████████████████████████-----------] 72% [00m:15s] Cells: 365755
[██████████████████████████████----------] 74% [00m:16s] Cells: 378032
[███████████████████████████████---------] 77% [00m:17s] Cells: 390049
[█████████████████████████████████-------] 80% [00m:18s] Cells: 401566
[█████████████████████████████████-------] 82% [00m:19s] Cells: 413432
[███████████████████████████████████-----] 85% [00m:20s] Cells: 424842
[████████████████████████████████████----] 88% [00m:22s] Cells: 435706
[█████████████████████████████████████---] 91% [00m:23s] Cells: 446403
[███████████████████████████████████████-] 95% [00m:24s] Cells: 456619
[████████████████████████████████████████] 99% [00m:25s] Cells: 466834
[████████████████████████████████████████] 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))