SpatialExperiment-subset {SpatialExperiment} | R Documentation

## Subsetting SpatialExperiment objects

### Description

The subsetting method for `SpatialExperiment` objects ensures that spatial data attributes (`spatialData`, `spatialCoords`, `imgData`) are subsetted correctly to match rows and columns with the remainder of the object.

### Arguments

`x` | a `SpatialExperiment` object
`i` | row indices for subsetting
`j` | column indices for subsetting

### Value

a `SpatialExperiment` object

### subset

`[`:

  subsetting method

### Examples

    example(read10xVisium)

    dim(spe)

    set.seed(123)
    idx <- sample(ncol(spe), 10)
    sub <- spe[, idx]
    dim(sub)
    spatialData(sub, spatialCoords = TRUE)

[Package SpatialExperiment version 1.4.0 Index]