Labels data points as spatial outliers depending on certain criteria with a new meta variable called sp_outlier. See details for more.

Requires the results of identifyTissueOutline().

identifySpatialOutliers(
  object,
  method = "obs",
  img_name = activeImage(object),
  buffer = 0,
  eps = recDbscanEps(object),
  minPts = recDbscanMinPts(object),
  min_section = nObs(object) * 0.05,
  test = "any",
  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.

method

Character vector. The method(s) to use. A combination of 'obs' and/or 'image'. Defaults to 'obs'. See details for more.

img_name

Character value. The name of the image whose tissue outline is used if method contains 'image'.

buffer

Numeric value. Expands the tissue outline to include observations that lie on the edge of the outline and are mistakenly removed.

eps, minPts

Given to the corresponding arguments of dbscan::dbscan() if method contains 'obs'.

min_section

Numeric value. The minimum number of observations a spatial cluster must contain such that the whole cluster is identified as a contiguous tissue section.

test

Character value. Only required if method = c('obs', 'image'). If 'any', spots are labeled as outliers if at least one method identifies them as outliers. If 'all', spots are labeled as outliers if both methods identify them as outliers.

verbose

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

(Warning messages will always be printed.)

Value

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

Details

In case of method = 'obs', the results from identifyTissueOutline(object, method = 'obs') are directly transferred to the new meta feature sp_outlier, which declares whether an observation is a spatial outlier or not.

In case of method = 'image', the image based tissue outline from the identifyTissueOutline() function is used. This function has created polygons that outline the tissue or tissue sections identified in the image. For each data point, the function checks which polygon it falls within and assigns it to the corresponding group. If an observation does not fall within any of the tissue polygons, it is considered a spatial outlier.

If method = c('obs', 'image'), the results of both methods are used Whether a data point is considered a spatial outlier depends on the test argument:

  • test = 'any': The data point is considered a spatial outlier if either of the two tests classifies it as an outlier.

  • test = 'all': The data point is considered a spatial outlier only if both tests classify it as an outlier.

The results can be visualized using plotSurface(object, color_by = "sp_outlier"). In case of bad results the function can be run over and over again with changing parameters as the results are simply overwritten.