The split
methods for SFE split an SFE object into multiple SFE
objects by geometries (all cells/spots intersecting with each geometry will
become a separate SFE object). The splitSamples
function splits the
SFE object by sample_id
so each sample will become a separate SFE
object. The splitContiguity
function splits the SFE object by
contiguity of an annotGeometry
, which by default is "tissueBoundary".
Usage
# S4 method for class 'SpatialFeatureExperiment,sf'
splitByCol(x, f, sample_id = "all", colGeometryName = 1L, cover = FALSE)
# S4 method for class 'SpatialFeatureExperiment,sfc'
splitByCol(x, f, sample_id = 1L, colGeometryName = 1L, cover = FALSE)
# S4 method for class 'SpatialFeatureExperiment,list'
splitByCol(x, f, sample_id = "all", colGeometryName = 1L, cover = FALSE)
splitSamples(x)
splitContiguity(
x,
colGeometryName = 1L,
annotGeometryName = "tissueBoundary",
min_area = 0,
cover = FALSE
)
Arguments
- x
An SFE object
- f
It can be a
sf
data frame orsfc
to split by geometry. Each row of thesf
data frame or each element in thesfc
will correspond to a new SFE object. Thesf
data frame must have a columnsample_id
when splitting multiple samples. Can also be a list ofsfc
whose names correspond tosample_id
s to split.- sample_id
Which samples to split.
- colGeometryName
Which
colGeometry
to use to determine which cells or spots should belong to which new SFE object when splitting bysf
orsfc
. Default to the first one.- cover
Logical, whether the geometries in
x
must be entirely covered byy
ifop = st_intersection
or whetherx
must be entirely outsidey
ifop = st_difference
. Only relevant whenkeep_whole != "none"
.- annotGeometryName
Name of
annotGeometry
to use to split by contiguity.- min_area
Minimum area in the same unit as the geometry coordinates (squared) for each piece to be considered a separate piece when splitting by contiguity. Only pieces that are large enough are considered.