AddAdj | R Documentation |
Calculate the adjacency matrix given a spatial coordinate matrix with 2-dimension or 3-dimension or more.
AddAdj(
pos,
type = "fixed_distance",
platform = c("Others", "Visium", "ST"),
neighbors = 6,
...
)
pos |
a matrix object, with columns representing the spatial coordinates that can be any diemsion, i.e., 2, 3 and >3. |
type |
an optional string, specify which type of neighbors' definition. Here we provide two definition: one is "fixed_distance", the other is "fixed_number". |
platform |
a string, specify the platform of the provided data, default as "Others". There are more platforms to be chosen, including "Visuim", "ST" and "Others" ("Others" represents the other SRT platforms except for 'Visium' and 'ST') The platform helps to calculate the adjacency matrix by defining the neighborhoods when type="fixed_distance" is chosen. |
neighbors |
an optional postive integer, specify how many neighbors used in calculation, default as 6. |
... |
Other arguments passed to |
When the type = "fixed_distance", then the spots within the Euclidean distance cutoffs from one spot are regarded as the neighbors of this spot. When the type = "fixed_number", the K-nearest spots are regarded as the neighbors of each spot.
return a sparse matrix, representing the adjacency matrix.
None
None
data(CosMx_subset)
pos <- as.matrix(CosMx_subset@meta.data[,c("x", "y")])
Adj_sp <- AddAdj(pos)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.