Given an STGrid object and a Connected Component (see connected_components()) find the neighboring bins.

cc_neighborhood(object, feature = NULL)

Arguments

object

An STGrid object containing the spatial expression data.

feature

A character string specifying the feature of interest.

Value

The input STGrid object with additional fields (in meta slot) indicating the satellite bins for the specified feature at each neighborhood size.

Examples

library(patchwork)
example_dataset()
#> |-- INFO :  Dataset 11284233/files/Xenium_Mouse_Brain_Coronal_7g was already loaded. 
xen <- Xenium_Mouse_Brain_Coronal_7g
p1 <- spatial_image(xen, feat="Necab2")
xen <- connected_components(xen, feat_list = "Necab2", threshold = 5, min_size = 30)
head(meta(xen))
#>                               count_sum Necab2_cpt
#> [1.01e+03,1.03e+03)~[22,47)           0          0
#> [1.01e+03,1.03e+03)~[47,72)           0          0
#> [1.01e+03,1.03e+03)~[72,97)           0          0
#> [1.01e+03,1.03e+03)~[97,122)          0          0
#> [1.01e+03,1.03e+03)~[122,147)         0          0
#> [1.01e+03,1.03e+03)~[147,172)         0          0
p2 <- spatial_image(xen, feat="Necab2_cpt", as_factor=TRUE, colors = c("black", rainbow(9)))
hull_1 <- create_hull(xen, feat="Necab2_cpt", color="red", linew=0.3)
#> |-- INFO :  Creating segments 
p3 <- p2 + hull_1
p4 <- spatial_image(xen, feat="Nwd2") + hull_1
(p1 | p2 ) / (p3 | p4)