rowGeometries: Row geometry getters and setters

View source: R/dimGeometries.R

rowGeometriesR Documentation

Row geometry getters and setters

Description

rowGeometries are geometries that corresponding to rows of the gene count matrix, such as smFISH transcript spots. The txSpots() function is a convenience wrapper for transcript spots, although this entirely depends on the rowGeometry being named txSpots.

Usage

rowGeometry(x, type = 1L, sample_id = 1L, withDimnames = TRUE)

rowGeometry(
  x,
  type = 1L,
  sample_id = 1L,
  withDimnames = TRUE,
  partial = FALSE,
  translate = TRUE
) <- value

rowGeometries(x, sample_id = "all", withDimnames = TRUE)

rowGeometries(
  x,
  sample_id = "all",
  withDimnames = TRUE,
  partial = FALSE,
  translate = TRUE
) <- value

rowGeometryNames(x)

rowGeometryNames(x) <- value

txSpots(x, sample_id = 1L, withDimnames = TRUE)

txSpots(
  x,
  sample_id = 1L,
  withDimnames = TRUE,
  partial = FALSE,
  translate = TRUE
) <- value

Arguments

x

A SpatialFeatureExperiment object.

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.

withDimnames

Logical. If TRUE, then the dimnames (colnames or rownames) of the gene count matrix should correspond to row names of the sf data frames of interest.

partial

In setters, if a rowGeometry of the same name exists, whether to only replace the rows present in value.

translate

Logical. Only used if removeEmptySpace has been run of the SFE object. If that's the case, this argument indicates whether the new value to be assigned to the geometry is in the coordinates prior to removal of empty space so it should be translated to match the new coordinates after removing empty space. Default to TRUE.

value

Value to set. For dimGeometry, must be a sf data frame with the same number of rows as size in the dimension of interest, or an ordinary data frame that can be converted to such a sf data frame (see df2sf). For dimGeometries, must be a list of such sf or ordinary data frames.

Details

When there are multiple samples in the SFE object, rowGeometries for each sample has the sample_id appended to the name of the geometry. For example, if the name is txSpots and the sample ID is sample01, then the actual name of the rowGeometry is txSpots_sample01. In the getter, one can still specify rowGeometry(sfe, "txSpots", sample_id = "sample01").

Appending the sample_id is unnecessary when there is only one sample, but sample_id will be appended when to SFE objects are combined with cbind. It is necessary to distinguish bewteen different samples because they can have overlapping coordinate values.

See Also

[dimGeometries()], [colGeometries()]

Examples

library(SFEData)
library(RBioFormats)
fp <- tempdir()
dir_use <- XeniumOutput("v2", file_path = file.path(fp, "xenium_test"))
# RBioFormats issue
try(sfe <- readXenium(dir_use, add_molecules = TRUE))
sfe <- readXenium(dir_use, add_molecules = TRUE)
rowGeometries(sfe)
rowGeometryNames(sfe)
tx <- rowGeometry(sfe, "txSpots")
txSpots(sfe)
unlink(dir_use, recursive = TRUE)

pachterlab/SpatialFeatureExperiment documentation built on Aug. 23, 2024, 11:38 p.m.