SpatialFeatureExperiment | R Documentation |
Create a SpatialFeatureExperiment
object.
SpatialFeatureExperiment(
assays,
colData = DataFrame(),
rowData = NULL,
sample_id = "sample01",
spatialCoordsNames = c("x", "y"),
spatialCoords = NULL,
colGeometries = NULL,
rowGeometries = NULL,
annotGeometries = NULL,
spotDiameter = NA_real_,
annotGeometryType = "POLYGON",
spatialGraphs = NULL,
unit = c("full_res_image_pixel", "micron"),
BPPARAM = deprecated(),
...
)
assays |
A |
colData |
An optional DataFrame describing the samples. Row names, if present, become the column names of the RangedSummarizedExperiment. |
rowData |
A DataFrame object describing
the rows. Row names, if present, become the row names of the
SummarizedExperiment object. The number of rows of the
DataFrame must equal the number of rows of the
matrices in |
sample_id |
A |
spatialCoordsNames |
A |
spatialCoords |
A numeric matrix containing columns of spatial
coordinates, as in |
colGeometries |
Geometry of the entities that correspond to the columns of the gene count matrix, such as cells and Visium spots. It must be a named list of one of the following:
In all cases, the data frame should specify
the same number of geometries as the number of columns in the gene count
matrix. If the column "barcode" is present, then it will be matched to
column names of the gene count matrix. Otherwise, the geometries are
assumed to be in the same order as columns in the gene count matrix. If the
geometries are specified in an ordinary data frame, then it will be
converted into |
rowGeometries |
Geometry associated with genes or features, which correspond to rows of the gene count matrix. |
annotGeometries |
Geometry of entities that do not correspond to columns
or rows of the gene count matrix, such as tissue boundary and pathologist
annotations of histological regions, and nuclei segmentation in a Visium
dataset. Also a named list as in |
spotDiameter |
Spot diameter for technologies with arrays of spots of fixed diameter per slide, such as Visium, ST, DBiT-seq, and slide-seq. The diameter must be in the same unit as the coordinates in the *Geometry arguments. Ignored for geometries that are not POINT or MULTIPOINT. |
annotGeometryType |
Character vector specifying geometry type of each
element of the list if |
spatialGraphs |
A named list of |
unit |
Unit the coordinates are in, either microns or pixels in full resolution image. |
BPPARAM |
Deprecated. The 'sfheaders' package is used in
|
... |
Additional arguments passed to the |
A SFE object. If neither colGeometries
nor spotDiameter
is specified, then a colGeometry
called "centroids" will be made,
which is essentially the spatial coordinates as sf POINTs. If
spotDiameter
is specified, but not colGeometries
, then the
spatial coordinates will be buffered by half the diameter to get spots with
the desired diameter, and the resulting colGeometry
will be called
"spotPoly", for which there's a convenience getter and setter,
spotPoly
.
library(Matrix)
data("visium_row_col")
coords1 <- visium_row_col[visium_row_col$col < 6 & visium_row_col$row < 6, ]
coords1$row <- coords1$row * sqrt(3)
cg <- df2sf(coords1[, c("col", "row")], c("col", "row"), spotDiameter = 0.7)
set.seed(29)
col_inds <- sample(seq_len(13), 13)
row_inds <- sample(seq_len(5), 13, replace = TRUE)
values <- sample(seq_len(5), 13, replace = TRUE)
mat <- sparseMatrix(i = row_inds, j = col_inds, x = values)
colnames(mat) <- coords1$barcode
rownames(mat) <- sample(LETTERS, 5)
rownames(cg) <- colnames(mat)
sfe <- SpatialFeatureExperiment(list(counts = mat),
colData = coords1,
spatialCoordsNames = c("col", "row"),
spotDiameter = 0.7
)
sfe2 <- SpatialFeatureExperiment(list(counts = mat),
colGeometries = list(foo = cg)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.