Merges the spatial extent of two or more spatial annotations into one.

mergeSpatialAnnotations(
  object,
  ids,
  id,
  tags = NULL,
  tags_expand = TRUE,
  concavity = 2,
  remove_old = FALSE,
  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 of ids from spatial annotations to merge.

id

Character value. The ID of the new spatial annotation that results from the merging.

tags

A character vector of tags for the spatial annotation.

tags_expand

Logical value. If TRUE, the tags with which the image annotations are tagged are expanded by the unsuffixed id, the grouping, the group and 'createGroupAnnotations'.

concavity

Numeric value. Given to argument concavity of concaveman::concaveman(). Determines the relative measure of concavity. 1 results in a relatively detailed shape, Infinity results in a convex hull. You can use values lower than 1, but they can produce pretty crazy shapes.

remove_old

Logical value. If TRUE, the old spatial annotations denoted in ids are removed from the object.

overwrite

Logical value. Must be TRUE to allow overwriting.

Value

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

See also

Examples


library(SPATA2)
library(tidyverse)

object <- loadExampleObject("UKF275T")

r <- getSpatAnnRange(object, id = "img_ann_1")

plotImage(object) +
 ggpLayerSpatAnnOutline(object, ids = c("vessel2", "img_ann_1"), use_colors = T)

plotImage(object, xrange = r$x, yrange = r$y) +
 ggpLayerSpatAnnOutline(object, ids = c("vessel2", "img_ann_1"), use_colors = T)

object <-
 mergeSpatialAnnotations(
   object = object,
   ids = c("img_ann_1", "vessel2"),
   id = "new_img_ann",
   )

plotSpatialAnnotations(object)