Skip to contents

This method samples a set of tumour cells.

Arguments

sample_name

The name of the sample.

lower_corner

The lower corner of the sample bounding box (optional in pair with upper_corner).

upper_corner

The upper corner of the sample bounding box (optional in pair with lower_corner).

num_of_cells

The maximum number of tumour cells to collect (optional).

Details

It removes the cells from the simulated tissue and stores them in a sample that can be subsequently retrieved to build a samples forest.

Examples

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

# create a simulation
sim <- SpatialSimulation()
sim$add_mutant(name = "A",
               growth_rate = 0.2,
               death_rate = 0.01)
sim$place_cell("A", 500, 500)

sim$death_activation_level <- 100
sim$run_up_to_size(species = "A", num_of_cells = 50000)
#> 
 [████████████████████████████████████████] 100% [00m:00s] Saving snapshot                                 


# randomly sample 50 tumour cells from the tissue
sim$sample_cells("S1", num_of_cells=50)

# sample the region [450,500]x[475,550]
sim$sample_cells("S2", lower_corner=c(450,475), upper_corner=c(500,550))

# randomly sample 50 tumour cells from the tissue region [500,550]x[500,550]
sim$sample_cells("S3", lower_corner=c(500,500), upper_corner=c(550,550),
                 num_of_cells=50)

sim$get_samples_info()
#>   name xmin ymin xmax ymax tumour_cells tumour_cells_in_bbox     time
#> 1   S1    0    0  999  999           50                50000 215.0761
#> 2   S2  450  475  500  550         3856                 3856 215.0761
#> 3   S3  500  500  550  550           50                 2543 215.0761