Extracts the barcodes that are covered by the extent of the annotated structures of interest.

getSpatAnnBarcodes(
  object,
  ids = NULL,
  tags = NULL,
  test = "any",
  class = NULL,
  coords_df = getCoordsDf(object),
  simplify = TRUE
)

Arguments

object

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

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.

simplify

Logical. If set to TRUE the output list is simplified to a vector if possible. If set to FALSE a list is returned.

Value

Character vector, if simplify = TRUE. Else a named list of character vectors.

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.

Examples


library(SPATA2)
library(tidyverse)

object <- loadExampleObject("UKF313T", process = T, meta = T)

# show all IDs
getSpatAnnIds(object)

bcs_necr_area <- getSpatAnnBarcodes(object, ids = "necrotic_area")

ids_all <- c("necrotic_area", "necrotic_edge", "necrotic_edge2")
bcs_necr_all <- getSpatAnnBarcodes(object, ids = ids_all)

# plot results as proof of principle
coords_df <- getCoordsDfSA(object, ids = ids_all)

coords_df$necr_area <- coords_df$barcodes %in% bcs_necr_area
coords_df$necr_all <- coords_df$barcodes %in% bcs_necr_all

plotSurface(coords_df, "necr_area")
plotSurface(coords_df, "necr_all")

# work with relative location of observations annotations 'rel_loc'
plotSurface(coords_df, color_by = "id") # closest to which annotation?
plotSurface(coords_df, color_by = "rel_loc")

dplyr::filter(coords_df, rel_loc == "core") %>%
 plotSurface(object = ., color_by = "id")