dimGeometries | R Documentation |
"Dimension geometry" refers to Simple Feature (sf
) geometries
associated with rows (features, genes) or columns (cells or spots) of the
gene count matrix in the SpatialFeatureExperiment
object. For each
dimension, the number of rows in the sf
data frame specifying the
geometries must match the size of the dimension of interest. For example,
there must be the same number of rows in the sf
data frame describing
cells as there are cells in the gene count matrix. This page documents
getters and setters for the dimension geometries. The getters and setters are
implemented in a way similar to those of reducedDims
in
SingleCellExperiment
.
## S4 method for signature 'SpatialFeatureExperiment'
dimGeometries(x, MARGIN = 2, withDimnames = TRUE)
## S4 replacement method for signature 'SpatialFeatureExperiment'
dimGeometries(x, MARGIN, withDimnames = TRUE, translate = TRUE, ...) <- value
## S4 method for signature 'SpatialFeatureExperiment'
dimGeometryNames(x, MARGIN)
## S4 replacement method for signature 'SpatialFeatureExperiment,numeric,character'
dimGeometryNames(x, MARGIN) <- value
## S4 method for signature 'SpatialFeatureExperiment'
dimGeometry(x, type = 1L, MARGIN, sample_id = 1L, withDimnames = TRUE)
## S4 replacement method for signature 'SpatialFeatureExperiment'
dimGeometry(
x,
type = 1L,
MARGIN,
sample_id = 1L,
withDimnames = TRUE,
translate = TRUE,
...
) <- value
x |
A |
MARGIN |
As in |
withDimnames |
Logical. If |
translate |
Logical. Only used if |
... |
|
value |
Value to set. For |
type |
An integer specifying the index or string specifying the name of the *Geometry to query or replace. If missing, then the first item in the *Geometries will be returned or replaced. |
sample_id |
Sample ID to get or set geometries. |
Getters for multiple geometries return a named list. Getters for names
return a character vector of the names. Getters for single geometries
return an sf
data frame. Setters return an SFE object.
[colGeometries()], [rowGeometries()]
library(SFEData)
sfe <- McKellarMuscleData(dataset = "small")
# Get all column geometries as a named list
# Use MARGIN = 1 or rowGeometry/ies for rowGeometries
cgs <- dimGeometries(sfe, MARGIN = 2)
# Or equivalently
cgs <- colGeometries(sfe)
# Set all column geometries with a named list
dimGeometries(sfe, MARGIN = 2) <- cgs
# Or equivalently
colGeometries(sfe) <- cgs
# Get names of column geometries
cgns <- dimGeometryNames(sfe, MARGIN = 2)
cgns <- colGeometryNames(sfe)
# Set column geometry names
dimGeometryNames(sfe, MARGIN = 2) <- cgns
colGeometryNames(sfe) <- cgns
# Get a specific column geometry by name
spots <- dimGeometry(sfe, "spotPoly", MARGIN = 2)
spots <- colGeometry(sfe, "spotPoly")
# Or equivalently, the wrapper specifically for Visium spot polygons,
# for the name "spotPoly"
spots <- spotPoly(sfe)
# Other colGeometry wrappers for specific names:
# ROIPoly (for LCM and GeoMX DSP), cellSeg and nucSeg (for MERFISH; would
# query annotGeometries for Visium)
# rowGeometry wrappers for specific names: txSpots (MERFISH transcript spots)
# By index
spots <- colGeometry(sfe, 1L)
# Multiple samples, only get geometries for one sample
sfe2 <- McKellarMuscleData("small2")
sfe_combined <- cbind(sfe, sfe2)
spots1 <- colGeometry(sfe, "spotPoly", sample_id = "Vis5A")
spots2 <- spotPoly(sfe_combined, sample_id = "sample02")
# Get geometries for multiple samples
spots3 <- spotPoly(sfe_combined, sample_id = c("Vis5A", "sample02"))
# All samples
spots3 <- spotPoly(sfe_combined, sample_id = "all")
# Set specific column geometry by name
colGeometry(sfe, "foobar") <- spots
# Or use wrapper
spotPoly(sfe) <- spots
# Specify sample_id
colGeometry(sfe_combined, "foobar", sample_id = "Vis5A") <- spots1
# Only entries for the specified sample are set.
foobar <- colGeometry(sfe_combined, "foobar", sample_id = "sample02")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.