Converts one or more spatial annotations to a binary segmentation variable in the feature data.frame.

spatialAnnotationToGrouping(
  object,
  ids,
  grouping_name,
  inside = "inside",
  outside = "outside",
  overwrite = FALSE
)

Arguments

object

An object of class SPATA2 or, in case of S4 generics, objects of classes for which a method has been defined.

ids

Character vector. Specifies the spatial annotation(s) of interest. data points that fall into the area of these annotations are labeled with the input for argument inside.

grouping_name

Character value. The name of the new segmentation variable.

inside

Character value. The group name for the data points that are located inside the area of the spatial annotation(s).

outside

Character value. The group name for the data points that are located outside the area of the spatial annotation(s).

overwrite

Logical. Set to TRUE to overwrite existing variables with the same name.

Value

The updated input object, containing the added, removed or computed results.

Examples


library(SPATA2)
library(patchwork)

data("example_data")

object <- example_data$object_UKF313T_diet

ids <- getSpatAnnIds(object, tags = c("necrotic", "compr"), test = "all")

plotSpatialAnnotations(object, ids = ids)

object <-
  spatialAnnotationToGrouping(
    object = object,
    ids = ids,
    grouping_name = "histology",
    inside = "necrotic",
    outside = "vivid"
    )

plotSurface(object, color_by = "histology", clrp_adjust = c("necrotic" = "black", "vivid" = "forest_green"))