Computes the area of spatial annotations.

getSpatAnnArea(object, ...)

# S4 method for class 'SPATA2'
getSpatAnnArea(
  object,
  ids = NULL,
  unit = "mm2",
  tags = NULL,
  test = "any",
  as_numeric = TRUE,
  verbose = NULL,
  ...
)

# S4 method for class 'SpatialData'
getSpatAnnArea(
  object,
  ids = NULL,
  tags = NULL,
  test = "any",
  unit = "mm2",
  as_numeric = TRUE,
  verbose = NULL,
  ...
)

Arguments

object

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

...

Used to absorb deprecated arguments or functions.

unit

Character value. Specifies the desired unit in which distance measures or area measures are provided. Run validUnitsOfLength() or validUnitsOfArea() for valid input options.

tags

Character vector or NULL. If character, the tags for the image annotation selection. See section Selection of spatial annotations for more information.

test

Character value. One of c('any'. 'all', 'identical', 'not_identical', 'none'). Specifies how input for tags is used to select spatial annotations. See section Selection of spatial annotations for more information.

verbose

Logical. If TRUE, informative messages regarding the computational progress will be printed.

(Warning messages will always be printed.)

Value

Contains the area of the spatial annotations in the unit that is specified in unit. The unit is attached to the output as an attribute named unit. E.g. if unit = *mm2* the output value has the unit mm^2.

Note

The area is computed solely based on the outline of the annotation even if the annotation transgresses the tissue outline! If you only want the area of the annotation on the tissue section adjust the annotation with mergeWithTissueOutline(). See examples.

Examples


library(SPATA2)

object <- loadExampleObject("UKF313T")

ids <- c("necrotic_edge2", "necrotic_edge2_transgr")

plotSpatialAnnotations(object, ids = ids)

getSpatAnnArea(object, ids = ids)