Skip to contents

Write a Seurat object to a SOMA

Usage

# S3 method for class 'Seurat'
write_soma(
  x,
  uri,
  ...,
  ingest_mode = "write",
  platform_config = NULL,
  tiledbsoma_ctx = NULL
)

Arguments

x

A Seurat object

uri

URI for resulting SOMA object

...

Arguments passed to other methods

ingest_mode

Ingestion mode when creating the SOMA; choose from:

  • write”: create a new SOMA and error if it already exists

  • resume”: attempt to create a new SOMA; if it already exists, simply open it for writing

platform_config

Optional platform configuration

tiledbsoma_ctx

Optional SOMATileDBContext

Value

The URI to the resulting SOMAExperiment generated from the data contained in x

Writing Cell-Level Metadata

Cell-level metadata is written out as a data frame called “obs” at the experiment level

Writing v3 Assays

Seurat Assay objects are written out as individual measurements:

  • the “data” matrix is written out as a sparse array called “data” within the “X” group

  • the “counts” matrix, if not empty, is written out as a sparse array called “counts” within the “X” group

  • the “scale.data” matrix, if not empty, is written out as a sparse array called “scale_data” within the “X” group

  • feature-level metadata is written out as a data frame called “var

Expression matrices are transposed (cells as rows) prior to writing. All other slots, including results from extended assays (eg. SCTAssay, ChromatinAssay) are lost

Writing v5 Assays

Seurat v5 Assayss are written out as individualmeasurements:

  • the layer matrices are written out as sparse arrays within the “X” group

  • feature-level metadata is written out as a data frame called “var

Expression matrices are transposed (cells as rows) prior to writing. All other slots, including results from extended assays (eg. SCTAssay, ChromatinAssay) are lost
The following bits of metadata are written in various parts of the measurement

  • soma_ecosystem_seurat_assay_version”: written at the measurement level; indicates the Seurat assay version. Set to “v5

  • soma_ecosystem_seurat_v5_default_layers”: written at the “X” group level; indicates the default layers

  • soma_ecosystem_seurat_v5_ragged”: written at the “X/<layer>” array level; with a value of “ragged”, indicates whether or not the layer is ragged

  • soma_r_type_hint”: written at the “X/<layer>” array level; indicates the R class and defining package (for S4 classes) of the original layer

Writing DimReducs

Seurat DimReduc objects are written out to the “obsm” and “varm” groups of a measurement:

  • cell embeddings are written out as a sparse matrix in the “obsm” group

  • feature loadings, if not empty, are written out as a sparse matrix in the “varm” groups; loadings are padded with NAs to include all features

Dimensional reduction names are translated to AnnData-style names (eg. “pca” becomes X_pca for embeddings and “PCs” for loadings). All other slots, including projected feature loadings and jackstraw information, are lost

Writing Graphs

Seurat Graph objects are written out as sparse matrices to the “obsp” group of a measurement

Writing SeuratCommands

Seurat command logs are written out as data frames to the “seurat_commands” group of a collection