Convert Seurat or Other Object to SingleCellExperiment
Source:R/convert_seurat_to_sce.R
convert_seurat_to_sce.Rd
This function determines the class of a loaded object and converts it to a SingleCellExperiment object if necessary. It handles Seurat objects, updating old Seurat v2 objects if detected, and converts them to SingleCellExperiment. If the input object is already a SingleCellExperiment, it is returned as is. For other object types, an attempt is made to convert them to SingleCellExperiment.
Details
The function first checks if the input object is a Seurat object. If it is, it prints a summary of the object and checks for indicators of Seurat v2, updating the object if necessary. It then converts the Seurat object to a SingleCellExperiment. If the object is already a SingleCellExperiment, it is returned directly. For other object types, an attempt is made to convert them to SingleCellExperiment.
Examples
if (FALSE) { # \dontrun{
library(Seurat)
library(SingleCellExperiment)
seurat_obj <- CreateSeuratObject(counts = matrix(1:4, ncol = 2))
sce <- convert_seurat_to_sce(seurat_obj)
} # }