Edge weights are used in the adjacency matrix. Because most elements of the matrix are 0, using sparse matrix greatly reduces memory use.
Value
A sparse dgCMatrix
, whose row represents each cell or spot and
whose columns represent the neighbors. The matrix does not have to be
symmetric. If region.id
is present in the listw
object, then
it will be the row and column names of the output matrix.
Examples
library(SFEData)
sfe <- McKellarMuscleData("small")
#> see ?SFEData and browseVignettes('SFEData') for documentation
#> loading from cache
g <- findVisiumGraph(sfe)
mat <- listw2sparse(g)
#> Warning: `listw2sparse()` was deprecated in SpatialFeatureExperiment 1.9.0.
#> ℹ Please use `spatialreg::as_dgRMatrix_listw()` instead.