View source: R/simulate_immune_rings.R
simulate_immune_rings | R Documentation |
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
)
bg_sample |
(OPTIONAL) A data frame or |
bg_type |
(OPTIONAL) String The name of the background cell type. By default is "Others". |
n_ir |
Number of immune rings. This must match the arg
|
ir_properties |
List of properties of the immune rings. Please refer to
the examples for the structure of |
plot_image |
Boolean. Whether the simulated image is plotted. |
plot_categories |
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. |
plot_colours |
String Vector specifying the order of the colours that
correspond to the |
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.