View source: R/simulate_background_cells.R
| simulate_background_cells | R Documentation |
Simulate cell locations. The 2D locations of the cells are simulated and plotted in a rectangular window. Users can specify the window size, cell number and the minimum distance between two cells. All cells have the same cell type, specified by the "Cell.Type" param.
simulate_background_cells(
n_cells,
width,
height,
method = "Hardcore",
min_d,
oversampling_rate = 1.2,
jitter = 0.3,
Cell.Type = "Others",
plot_image = TRUE
)
n_cells |
Numeric. Number of cells to simulate in the background. |
width, height |
Numeric. The width and height of the image. |
method |
String. The distribution model for the background cells. Options are "Hardcore" for tumour tissues and "Even" for normal tissues. Default is "Hardcore". |
min_d |
(OPTIONAL) Numeric. Use when |
oversampling_rate |
(OPTIONAL) Numeric. Use when |
jitter |
(OPTIONAL) Numeric. Use when |
Cell.Type |
(OPTIONAL) String. The name of the background cell type. Default is "Others" since there shouldn't be any identity of the background cells. |
plot_image |
(OPTIONAL) Boolean. Default is TRUE. |
There are two options for the background cell distribution model. 1)
Hardcore model for tumour tissues. This model uses rHardcore
spatstat.random. Since rHardcore deletes cells that are within the
distance of min_d to another cell, resulting in fewer cell specified by
users, we here introduce parameter oversampling_rate to generate more
cells than specified. 2) Normal tissues use an evenly-spaced model where
the cells are distributed approximately according to the vertices of a
hexagon. The function accomplishes this by generating cells on a hexagonal
grid and individually applying a bounded uniform random jitter. In our
algorithm, jitter is the parameter to define the uniform distribution of
the jitter of the cells from the hexagon vertices. If there is a reference
image, jitter can be estimated by comparing the average minimum distance
between cells of the simulated image and the reference image. If without a
reference image, We suggest 0.3 as the default value of jitter as this
gives a sensible outcome.
A data.frame of the simulated background image
simulate_mixing for mixed background simulation,
simulate_clusters for cluster simulation,
simulate_immune_rings/simulate_double_rings for
immune ring simulation, and simulate_stripes for vessel
simulation.
Other simulate pattern functions:
simulate_clusters(),
simulate_double_rings(),
simulate_immune_rings(),
simulate_mixing(),
simulate_stripes()
set.seed(610) # set seed for this background image simulation for reproducibility
background_image <- simulate_background_cells(n_cells = 5000, width = 2000,
height = 2000, method = "Hardcore",
min_d = 10,
oversampling_rate = 1.5,
Cell.Type = "Others",
plot_image = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.