Skip to contents

This function converts a loaded object to a `SingleCellExperiment` object if necessary. It first attempts to use Seurat's built-in conversion function. If this fails (e.g., due to multiple layers), it performs a custom conversion, preserving multiple assays, paired data (such as distance matrices), and handling mismatches appropriately. It also attempts to transfer unstructured data by storing it in the `metadata` slot of the SingleCellExperiment object. If the input object is already a `SingleCellExperiment`, it is returned as is.

Usage

convert_seurat_to_sce(data)

Arguments

data

The loaded object to be converted.

Value

A `SingleCellExperiment` object.

Details

For assays with multiple layers (e.g., `Assay5` in Seurat v5), the function processes split layers, combines them where necessary, and records their names in the metadata. Layers with mismatched sizes or dimensions are moved to `altExps`, with name collisions resolved by appending unique suffixes.

Dimensional reductions, graphs, feature metadata, and unstructured data are also transferred to ensure compatibility with `SingleCellExperiment`.