createGroupAnnotations | R Documentation |
Creates spatial annotations based on the spatial extent of a group of data points (spots or cells). See details for more information.
createGroupAnnotations(
object,
grouping,
group,
id,
tags = NULL,
tags_expand = TRUE,
use_dbscan = TRUE,
inner_borders = TRUE,
eps = recDbscanEps(object),
minPts = recDbscanMinPts(object),
min_size = nObs(object) * 0.01,
force1 = FALSE,
method_outline = "concaveman",
alpha = recAlpha(object),
concavity = 2,
overwrite = FALSE,
verbose = NULL
)
object |
An object of class |
grouping |
Character value. The grouping variable containing the group of interest. |
group |
Character value. The group of interest. |
id |
Character value. The ID of the spatial annotation. If |
tags |
A character vector of tags for the spatial annotation. |
tags_expand |
Logical value. If |
use_dbscan |
Logical value. If |
inner_borders |
Logical value. If |
eps |
Distance measure. Given to |
minPts |
Numeric value. Given to |
min_size |
Numeric value. The minimum number of data points a dbscan cluster must have in order not to be discarded as a spatial outlier. |
force1 |
Logical value. If |
method_outline |
Character value. The method used to create the outline of the spatial annotations. Either 'concaveman' or 'alphahull'.
|
alpha |
Numeric value. Given to |
concavity |
Numeric value. Given to argument |
overwrite |
Logical value. Must be |
verbose |
Logical. If (Warning messages will always be printed.) |
The functions filters the coordinates data.frame obtained via getCoordsDf()
based on the input of argument grouping
and group
.
Following filtering, if use_dbscan
is TRUE
, the DBSCAN algorithm
identifies spatial outliers, which are then removed. Furthermore, if DBSCAN
detects multiple dense clusters, they can be merged into a single group
if force1
is also set to TRUE
.
It is essential to note that bypassing the DBSCAN step may lead to the inclusion
of individual data points dispersed across the sample. This results in an image
annotation that essentially spans the entirety of the sample, lacking the
segregation of specific variable expressions. Similarly, enabling force1
might unify multiple segregated areas, present on both sides of the sample, into one
group and subsequently, one spatial annotation encompassing the whole sample.
Consider to allow the creation of multiple spatial annotations (suffixed with an index)
and merging them afterwards via mergeSpatialAnnotations()
if they are too
close together.
Lastly, the remaining data points are fed into either the concaveman or the alphahull algorithm on a
per-group basis. The algorithm calculates polygons outlining the groups
of data points. If dbscan_use
is FALSE
, all data points that remained after the
initial filtering are submitted to the algorithm. Subsequently, these polygons are
integrated into addSpatialAnnotation()
along with the unsuffixed id
and
tags
input arguments. The ID is suffixed with an index for each group.
The updated input object, containing the added, removed or computed results.
The vignette on distance measures in SPATA2 has been replaced. Click
here
to read it.
P. J. de Oliveira and A. C. P. F. da Silva (2012). alphahull: Generalization of the convex hull of a sample of points in the plane. R package version 2.1. https://CRAN.R-project.org/package=alphahull
Graham, D., & Heaton, D. (2018). concaveman: A very fast 2D concave hull algorithm. R package version 1.1.0. https://CRAN.R-project.org/package=concaveman
recDbscanEps()
, recDbscanMinPts()
library(SPATA2)
library(tidyverse)
data("example_data")
object <- example_data$object_UKF275T_diet
object <-
createGroupAnnotations(
object = object,
grouping = "bayes_space",
group = "1",
id = "bspace1",
tags = "bspace_ann"
)
plotSurface(object, color_by = "bayes_space") +
ggpLayerSpatAnnOutline(object, tags = "bspace_ann")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.