simulate_clusters: Simulate clusters

View source: R/simulate_clusters.R

simulate_clustersR Documentation

Simulate clusters

Description

Based on an existing background image, simulate clusters of cells where the same type of cells aggregate. The default values for the arguments give an example of cluster simulation which enable an automatic simulation of clusters without the specification of any argument.

Usage

simulate_clusters(
  bg_sample = bg1,
  n_clusters = 2,
  bg_type = "Others",
  cluster_properties = list(C1 = list(name_of_cluster_cell = "Tumour", size = 300, shape
    = "Oval", centre_loc = data.frame(x = 500, y = 500), infiltration_types =
    c("Immune1", "Others"), infiltration_proportions = c(0.1, 0.05)), C2 =
    list(name_of_cluster_cell = "Immune1", size = 500, shape = "Irregular", centre_loc =
    data.frame(x = 1500, y = 500), infiltration_types = c("Immune2", "Others"),
    infiltration_proportions = c(0.1, 0.05))),
  plot_image = TRUE,
  plot_categories = NULL,
  plot_colours = NULL
)

Arguments

bg_sample

(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.

n_clusters

Numeric. Number of clusters. This must match the length(cluster_properties).

bg_type

(OPTIONAL) String. The name of the background cell type if the background sample does not have a "Cell.Type" column. By default is "Others".

cluster_properties

List of properties of the clusters. See examples for the format of this arg.

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 plot_categories arg. Default is NULL - the predefined colour vector would be used for plotting.

Value

A data.frame of the simulated image

See Also

simulate_background_cells for all cell simulation, simulate_mixing for mixed background simulation, simulate_immune_rings/simulate_double_rings for immune ring simulation, and simulate_stripes for vessel simulation.

Other simulate pattern functions: simulate_background_cells(), simulate_double_rings(), simulate_immune_rings(), simulate_mixing(), simulate_stripes()

Examples

set.seed(610)
cluster_image <- simulate_clusters(bg_sample = bg1,
n_clusters=2, cluster_properties=list(C1=list(name_of_cluster_cell="Tumour",
size=300, shape="Oval", centre_loc=data.frame("x"=500, "y"=500),
infiltration_types=c("Immune1", "Others"), infiltration_proportions=c(0.1, 0.05)),
C2=list(name_of_cluster_cell="Immune1", size=500, shape="Irregular",
centre_loc=data.frame("x"=1500,"y"=500), infiltration_types=c("Immune2", "Others"),
infiltration_proportions=c(0.1, 0.05))))

TrigosTeam/spaSim documentation built on May 25, 2023, 4:20 p.m.