Takes in an image in SpatialExperiment format, splits the image into specified sections and returns a list of SpatialExperiment objects. Users can choose to plot the cell positions in each sub image. Note that this function does not split the assay.

image_splitter(
  spe_object,
  number_of_splits,
  plot = FALSE,
  cut_labels = TRUE,
  colour_vector = NULL,
  minX = NULL,
  maxX = NULL,
  minY = NULL,
  maxY = NULL,
  feature_colname = "Phenotype"
)

Arguments

spe_object

`SpatialExperiment` object in the form of the output of format_image_to_spe.

number_of_splits

Numeric. specifying the number of segments (e.g. 2 = 2x2, 3 = 3x3).

plot

Boolean. Specifies whether the splitted images should be printed in a pdf.

cut_labels

Boolean. Specifies whether to plot where the image had been segmented.

colour_vector

String Vector. If specified, the colours will be used for plotting. If NULL, colors will be generated automatically.

minX

Integer used to specify the minimum x boundary to be splitted.

maxX

Integer used to specify the maximum x boundary to be splitted.

minY

Integer used to specify the minimum y boundary to be splitted.

maxY

Integer used to specify the maximum y boundary to be splitted.

feature_colname

String specifying which column the colouring should be based on. Specify when `plot` is TRUE. Default is "Phenotype".

Value

A list of spe objects is returned. Each data frame represents an image without assay data.

Examples

split_image <- image_splitter(SPIAT::simulated_image, number_of_splits=3, 
plot = FALSE)