Extract spatial coordinates and (optionally) cluster assignments from
a Seurat object, a SpatialExperiment object, or a user-supplied
data frame.
Arguments
- data
A
Seuratobject, aSpatialExperimentobject, or a data frame containing spatial coordinates.- cluster_col
Character scalar specifying the metadata column name containing cluster assignments. If
NULL, a default is used depending on the input object type:"seurat_clusters"forSeuratobjects"cluster"forSpatialExperimentobjects
- extract_cluster
Logical indicating whether to extract cluster information. If
FALSE, only spatial coordinates and cell IDs are returned. Default isTRUE.- ...
Additional arguments (unused).
Details
This is an S3 generic with methods implemented for
Seurat, SpatialExperiment, and data.frame.
Examples
coords <- readRDS(system.file(
"extdata", "MouseBrainCoords.rds",
package = "SpNeigh"
))
head(extractCoords(coords))
#> cell x y cluster
#> 1 1 1898.815 2540.963 4
#> 2 2 1895.305 2532.627 4
#> 3 3 2368.073 2534.409 2
#> 4 4 1903.726 2560.010 4
#> 5 5 1917.481 2543.132 4
#> 6 6 1926.540 2560.044 4
head(extractCoords(coords, extract_cluster = FALSE))
#> cell x y
#> 1 1 1898.815 2540.963
#> 2 2 1895.305 2532.627
#> 3 3 2368.073 2534.409
#> 4 4 1903.726 2560.010
#> 5 5 1917.481 2543.132
#> 6 6 1926.540 2560.044