Extracts spatial annotation IDs as a character vector.

getSpatAnnIds(object, ...)

# S4 method for class 'ANY'
getSpatAnnIds(object, ids = NULL, tags = NULL, test = "any", class = NULL)

# S4 method for class 'SpatialData'
getSpatAnnIds(
  object,
  ids = NULL,
  tags = NULL,
  test = "any",
  class = NULL,
  error = FALSE
)

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.

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.

class

Character vector or NULL. If character, defines the subtypes of spatial annotations to consider. Must be a combination of c('Group', 'Image' 'Numeric').

error

Logical. If TRUE and the input is invalid the function throws an error.

Value

Character vector. If no spatial annotations are returned the character vector is of length 0. If this is because no spatial annotations have been stored yet, the functions remains silent. If this is due to the selection options, the function throws a warning.

Selection of spatial annotations

Selection of spatial annotations via the arguments ids, class, tags and test works in three steps:

First, if ids is a character it prefilters the annotations by ID and only the specified ones are submitted to the next steps. If it is NULL, all annotations are submitted to the next steps.

Secondd, if class is a character it filters the annotations remaining after the first step by their class. If NULL, the step is skipped.

Third, if tags is a character it is used in combination with test to select from the spatial annotations that remain after the second step based on the meta data they are tagged with. There are multiple options:

  1. Argument test set to 'any' or 1: To be included, an image annotation must be tagged with at least one of the input tags.

  2. Argument test set to 'all' or 2: To be included, an image annotation must be tagged with all of the input tags. Can contain tags that are not specified.

  3. Argument test set to 'identical' or 3: To be included, an image annotation must be tagged with all of the input tags. Can not be tagged with anything else.

  4. Argument test set to not_identical or 4: To be included, an image annotation must not be tagged with the combination of input tags.

  5. Argument test set to 'none' or 5: To be included, an image annotation must not contain any of the input tags.

If tags is NULL, the step is skipped. Therefore, if ids, class and tags are all NULL, which is the default, all annotations are selected as all subsetting steps are skipped. Eventually, the remaining spatial annotations are submitted to whatever the respective function does.