Skip to contents

The method for SFE reconstructs the spatial graphs when the SFE object is subsetted as the listw objects encodes the nodes with indices which are no longer valid after subsetting as some nodes are no longer present.

Usage

# S4 method for class 'SpatialFeatureExperiment,ANY,ANY,ANY'
x[i, j, ..., drop = FALSE]

Arguments

x

A SpatialFeatureExperiment object.

i

Row indices for subsetting.

j

column indices for subsetting.

...

Passed to the SingleCellExperiment method of [.

drop

Logical. If FALSE, then a warning will be issued that the node indices in the graphs are no longer valid so the row and col graphs affected by subsetting are dropped. At present, this only works with the wrapper functions in this package that take in SFE objects and records the info required to reconstruct the graphs. While this argument is ignored for SummarizedExperiment

Value

A subsetted SpatialFeatureExperiment object.

Examples

# Just like subsetting matrices and SingleCellExperiment
library(SFEData)
sfe <- McKellarMuscleData(dataset = "small")
#> see ?SFEData and browseVignettes('SFEData') for documentation
#> loading from cache
sfe_subset <- sfe[seq_len(10), seq_len(10), drop = TRUE]
#> Node indices in the graphs are no longer valid after subsetting. Dropping all row and col graphs.
# Gives warning as graph reconstruction fails
# \donttest{
sfe_subset <- sfe[seq_len(10), seq_len(10)]
# }