listw2sparse: Convert listw into sparse adjacency matrix

View source: R/listw2sparse.R

listw2sparseR Documentation

Convert listw into sparse adjacency matrix

Description

Edge weights are used in the adjacency matrix. Because most elements of the matrix are 0, using sparse matrix greatly reduces memory use.

Usage

listw2sparse(listw)

Arguments

listw

A listw object for spatial neighborhood graph.

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")
g <- findVisiumGraph(sfe)
mat <- listw2sparse(g)

pachterlab/SpatialFeatureExperiment documentation built on Nov. 9, 2024, 10:22 p.m.