simulate_immune_rings.Rd
Based on an existing background image, simulate rings of immune cells that surround tumour clusters. The tumour clusters and immune rings are simulated at the same time. The default values for the arguments give an example of immune ring simulation which enable an automatic simulation of immune rings without the specification of any argument.
simulate_immune_rings(
bg_sample = bg1,
bg_type = "Others",
n_ir = 2,
ir_properties = list(I1 = list(name_of_cluster_cell = "Tumour", size = 600, shape =
"Circle", centre_loc = data.frame(x = 930, y = 1000), infiltration_types =
c("Immune1", "Immune2", "Others"), infiltration_proportions = c(0.15, 0.05, 0.05),
name_of_ring_cell = "Immune1", immune_ring_width = 150,
immune_ring_infiltration_types = c("Others"), immune_ring_infiltration_proportions =
c(0.15)), I2 = list(name_of_cluster_cell = "Tumour", size = 500, shape = "Oval",
centre_loc = data.frame(x = 1330, y = 1100), infiltration_types = c("Immune1",
"Immune2", "Others"), infiltration_proportions = c(0.15, 0.05, 0.05),
name_of_ring_cell = "Immune1", immune_ring_width = 150,
immune_ring_infiltration_types = c("Others"), immune_ring_infiltration_proportions =
c(0.15))),
plot_image = TRUE,
plot_categories = NULL,
plot_colours = NULL
)
(OPTIONAL) A data frame or SpatialExperiment
class object
with locations of points representing background cells. Further cell types
will be simulated based on this background sample. The data.frame or the
spatialCoords()
of the SPE object should have colnames including
"Cell.X.Positions" and "Cell.Y.Positions". By default use the internal
bg1
background image.
(OPTIONAL) String The name of the background cell type. By default is "Others".
Number of immune rings. This must match the arg
length(ir_properties)
.
List of properties of the immune rings. Please refer to
the examples for the structure of ir_properties
.
Boolean. Whether the simulated image is plotted.
String Vector specifying the order of the cell categories to be plotted. Default is NULL - the cell categories under the "Cell.Type" column would be used for plotting.
String Vector specifying the order of the colours that
correspond to the plot_categories
arg. Default is NULL - the predefined
colour vector would be used for plotting.
A data.frame of the simulated image
simulate_background_cells
for all cell simulation,
simulate_mixing
for mixed background simulation,
simulate_clusters
for cluster simulation,
simulate_double_rings
for double immune ring simulation, and
simulate_stripes
for vessel simulation.
Other simulate pattern functions:
simulate_background_cells()
,
simulate_clusters()
,
simulate_double_rings()
,
simulate_mixing()
,
simulate_stripes()
set.seed(610)
# manually define the properties of the immune ring
ir_properties <- list(I1=list(name_of_cluster_cell="Tumour", size=600,
shape="Circle",centre_loc=data.frame("x"=930, "y"=1000),
infiltration_types=c("Immune1", "Immune2", "Others"), infiltration_proportions
=c(0.15, 0.05, 0.05), name_of_ring_cell="Immune1", immune_ring_width=150,
immune_ring_infiltration_types=c("Others"), immune_ring_infiltration_proportions=c(0.15)),
I2=list(name_of_cluster_cell="Tumour", size=500, shape="Oval",
centre_loc=data.frame("x"=1330, "y"=1100), infiltration_types=c("Immune1", "Immune2", "Others"),
infiltration_proportions=c(0.15, 0.05, 0.05), name_of_ring_cell="Immune1",
immune_ring_width=150, immune_ring_infiltration_types=c("Others"),
immune_ring_infiltration_proportions=c(0.15)))
# simulate immune rings (`n_ir` should match the length of `ir_properties`)
immune_ring_image <- simulate_immune_rings(bg_sample=bg1,
n_ir=2, ir_properties=ir_properties)