barcodesToImageAnnotation | R Documentation |
Creates image annotations from a list of barcodes by identifying the spots that outline the area covered by them. See details for more information.
barcodesToImageAnnotation(
object,
barcodes,
id,
tags = NULL,
force1 = FALSE,
concavity = 2,
eps = getCCD(object, unit = "px") * 1.25,
minPts = 3,
sep = "_",
expand_outline = getCCD(object, unit = "px")/2,
overwrite = FALSE,
verbose = NULL
)
object |
A valid |
barcodes |
Character vector. A vector of barcode-spots that cover histological areas that are supposed to annotated as image annotations. |
id |
Name of the created image annotation. If multiple areas are identified (see details) this name is suffixed with a number. |
tags |
Character vector or NULL. If character, the tags for the image annotation selection. See section Selection of image annotation with tags for more information. |
force1 |
Logical value. If |
concavity |
Given to |
eps |
Distance measure. Converted to pixel unit and given to |
minPts |
Given to |
sep |
Character value. The separator between image annotation id and suffix. |
expand_outline |
Distance measure. Defines how much the identified outline of each area is buffered. If 0, no buffering is performed and the outer barcode-spots of each area are representative of the outline. |
overwrite |
Logical. Set to |
verbose |
Logical. If set to |
The functions filters the coordinates data.frame obtained via getCoordsDf()
based on the input of argument barcodes
. If force1
is not TRUE
, the
Density-based Spatial Clustering of Applications with Noise (DBSCAN) is applied
to identify multiple areas covered by the barcodes denoted in barcodes
.
concaveman::concaveman()
creates a polygon for each area identified by
dbscan
that is required to outline the area. Each polygon is used to create
an image annotation combining input for id
with a numeric suffix.
An updated spata2
object
library(SPATA2)
data(spatial_segmentations)
object <- downloadSpataObject("313_T")
# add 'histology' variable
object <-
addFeatures(
object = object,
feature_df = spatial_segmentations[["313_T"]]
)
plotImageGgplot(object) + plotSurface(object, color_by = "histology", pt_alpha = 0.5)
# obtain list of barcodes that cover necrotic areas
necrotic_barcodes <-
getFeatureDf(object) %>%
dplyr::filter(histology == "necrosis") %>%
dplyr::pull("barcodes")
print(necrotic_barcodes)
# convert list of barcodes to image annotations with default setting
object_ex1 <-
barcodesToImageAnnotation(
object = object,
barcodes = necrotic_barcodes,
id = "necrosis",
)
plotImageAnnotations(object_ex1, expand = "1mm")
# skip algorithm to detect multiple areas
object_ex2 <-
barcodesToImageAnnotation(
object = object,
barcodes = necrotic_barcodes,
id = "necrosis",
force1 = TRUE
)
plotImageAnnotations(object_ex2, expand = "1mm")
# manipulate the outline via `expand_outline`
object_ex3 <-
barcodesToImageAnnotation(
object = object,
barcodes = necrotic_barcodes,
id = "necrosis",
expand_outline = getCCD(object)*4.5 # *4.5 is too high, defaults to *1.25
)
plotImageAnnotations(object_ex3, expand = "1mm")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.