| Title: | Flexible Conversion Between Single-Cell Data Objects |
|---|---|
| Description: | Provides conversion among 'Seurat', 'SingleCellExperiment', 'AnnData', and 'Loom' single-cell data representations while preserving expression matrices, cell and feature metadata, and dimensionality reductions when supported by the target format. The package performs alignment and validity checks during conversion and reports unsupported or unavailable components rather than silently reconstructing them. |
| Authors: | Mohamed N. Hassan [aut, cre] |
| Maintainer: | Mohamed N. Hassan <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-09-30 19:39:31 UTC |
| Source: | https://github.com/mohamednhassan/scflex |
Tools for conversion among Seurat, SingleCellExperiment, AnnData, and Loom representations.
Reads an AnnData H5AD file and writes a Loom file using loompy, preserving supported matrices, cell and feature attributes, and reductions where representable.
convert_anndata_to_loom(input, output)convert_anndata_to_loom(input, output)
input |
Path to an input |
output |
Path to the output |
Loom is a more limited interchange format than Seurat, SingleCellExperiment, or AnnData, so only components representable by the current mapping are preserved.
The output path, returned invisibly.
Converts an AnnData H5AD file to a SingleCellExperiment object while preserving counts, normalized expression when available, cell metadata, feature metadata, and dimensional reductions.
convert_anndata_to_sce(input, output)convert_anndata_to_sce(input, output)
input |
Path to an AnnData H5AD file. |
output |
Path where the converted SingleCellExperiment RDS file should be written. |
An explicit layers["counts"] matrix is preferred as the counts assay.
Fractional values are accepted in an explicit counts layer as long as all
values are finite and non-negative. If no explicit counts layer is present,
X is used as counts only when its values are finite, non-negative, and
integer-like.
Normalized expression is optional. If layers["logcounts"] is present it
is stored as the SCE logcounts assay. Otherwise, X is used as
logcounts when it was not already used as the counts matrix.
Invisibly returns the output file path.
Reads an AnnData H5AD file and writes a Seurat RDS object while preserving supported counts, normalized expression, metadata, feature metadata, and dimensional reductions.
convert_anndata_to_seurat(input, output)convert_anndata_to_seurat(input, output)
input |
Path to an input |
output |
Path to the output Seurat |
The output path, returned invisibly.
Reads a Loom file through AnnData and writes the resulting object as H5AD while preserving components supported by the Loom-to-AnnData reader.
convert_loom_to_anndata(input, output)convert_loom_to_anndata(input, output)
input |
Path to an input |
output |
Path to the output |
Loom is a more limited interchange format than Seurat, SingleCellExperiment, or AnnData, so only components representable by the current mapping are preserved.
The output path, returned invisibly.
Reads a Loom file through AnnData and creates a SingleCellExperiment while preserving supported count data, normalized data, metadata, feature metadata, and reductions.
convert_loom_to_sce(input, output)convert_loom_to_sce(input, output)
input |
Path to an input |
output |
Path to the output SingleCellExperiment |
Raw counts are selected conservatively from an explicit counts layer when available or from X when it is non-negative and integer-like. The function does not guess raw counts from arbitrary named layers.
Loom is a more limited interchange format than Seurat, SingleCellExperiment, or AnnData, so only components representable by the current mapping are preserved.
The output path, returned invisibly on success. If suitable raw count data cannot be identified, the function may return NULL invisibly without writing an output object.
Reads a Loom file through AnnData and creates a Seurat object while preserving supported count data, metadata, feature metadata, and reductions.
convert_loom_to_seurat(input, output)convert_loom_to_seurat(input, output)
input |
Path to an input |
output |
Path to the output Seurat |
Raw counts are selected conservatively from an explicit counts layer when available or from X when it is non-negative and integer-like. The function does not guess raw counts from arbitrary named layers.
Loom is a more limited interchange format than Seurat, SingleCellExperiment, or AnnData, so only components representable by the current mapping are preserved.
The output path, returned invisibly on success. If suitable raw count data cannot be identified, the function may return NULL invisibly without writing an output object.
Dispatches a file conversion between Seurat, SingleCellExperiment, AnnData, and Loom using the corresponding scFlex conversion function.
convert_sc(input, source, destination, output)convert_sc(input, source, destination, output)
input |
Character string giving the path to the input file. |
source |
Character string naming the source format. Supported values are |
destination |
Character string naming the destination format. Supported values are |
output |
Character string giving the output file path. |
Source and destination must differ. Unsupported format names or unimplemented conversion paths produce an error.
The result returned by the selected conversion function, invisibly. Current converters normally return the output path invisibly; some conversions may return NULL invisibly when required count data cannot be identified.
Reads a SingleCellExperiment RDS object and writes an H5AD AnnData file, mapping supported assays, metadata, feature metadata, and reduced dimensions.
convert_sce_to_anndata(input, output)convert_sce_to_anndata(input, output)
input |
Path to an input SingleCellExperiment |
output |
Path to the output |
The output path, returned invisibly.
Reads a SingleCellExperiment RDS object and writes a Loom file using loompy, preserving supported assays, attributes, and reductions where representable.
convert_sce_to_loom(input, output)convert_sce_to_loom(input, output)
input |
Path to an input SingleCellExperiment |
output |
Path to the output |
Loom is a more limited interchange format than Seurat, SingleCellExperiment, or AnnData, so only components representable by the current mapping are preserved.
The output path, returned invisibly.
Reads a SingleCellExperiment RDS object and writes a Seurat RDS object while preserving supported counts, normalized expression, metadata, feature metadata, and dimensional reductions.
convert_sce_to_seurat(input, output)convert_sce_to_seurat(input, output)
input |
Path to an input SingleCellExperiment |
output |
Path to the output Seurat |
The output path, returned invisibly.
Converts a selected classic Seurat Assay to a Seurat v5 Assay5
while preserving the supported assay data and object structure.
convert_seu_classic_to_v5(input, output, assay = "RNA")convert_seu_classic_to_v5(input, output, assay = "RNA")
input |
Path to an input Seurat |
output |
Path to the output Seurat |
assay |
Name of the assay to convert. Defaults to |
The output path, returned invisibly.
Converts a selected Seurat v5 Assay5 assay to a classic Seurat Assay
while preserving the supported assay data and object structure.
convert_seu_v5_to_classic(input, output, assay = "RNA")convert_seu_v5_to_classic(input, output, assay = "RNA")
input |
Path to an input Seurat |
output |
Path to the output Seurat |
assay |
Name of the assay to convert. Defaults to |
The output path, returned invisibly.
Reads a Seurat RDS object and writes an H5AD AnnData file while preserving supported counts, normalized expression, metadata, feature metadata, and dimensional reductions.
convert_seurat_to_anndata(input, output, assay = "RNA")convert_seurat_to_anndata(input, output, assay = "RNA")
input |
Path to an input Seurat |
output |
Path to the output |
assay |
Name of the Seurat assay to convert. Defaults to |
The output path, returned invisibly.
Reads a Seurat RDS object and writes a Loom file using loompy, preserving supported expression matrices, attributes, and reductions where representable.
convert_seurat_to_loom(input, output)convert_seurat_to_loom(input, output)
input |
Path to an input Seurat |
output |
Path to the output |
Loom is a more limited interchange format than Seurat, SingleCellExperiment, or AnnData, so only components representable by the current mapping are preserved.
The output path, returned invisibly.
Reads a Seurat RDS object and writes a SingleCellExperiment RDS object while preserving supported counts, normalized expression, metadata, feature metadata, and dimensional reductions.
convert_seurat_to_sce(input, output)convert_seurat_to_sce(input, output)
input |
Path to an input Seurat |
output |
Path to the output SingleCellExperiment |
The output path, returned invisibly.
Inspects the structure and contents of a supported single-cell data file without performing a conversion. Supported inputs include Seurat and SingleCellExperiment objects stored as RDS files, AnnData H5AD files, and Loom files.
inspect_sc(path_to_file)inspect_sc(path_to_file)
path_to_file |
Path to an RDS, H5AD, or Loom file. |
The function reports basic information such as the number of cells and features, available assays or layers, dimensional reductions, metadata, and a sample of cell names. Additional format-specific information is reported when available.
Invisibly returns a list containing information about the inspected object. The contents of the list depend on the input format.
if (requireNamespace("Seurat", quietly = TRUE)) { counts <- matrix( c(1, 0, 3, 0, 2, 1), nrow = 2, dimnames = list( c("Gene1", "Gene2"), c("Cell1", "Cell2", "Cell3") ) ) obj <- Seurat::CreateSeuratObject(counts = counts) path <- tempfile(fileext = ".rds") saveRDS(obj, path) inspect_sc(path) unlink(path) }if (requireNamespace("Seurat", quietly = TRUE)) { counts <- matrix( c(1, 0, 3, 0, 2, 1), nrow = 2, dimnames = list( c("Gene1", "Gene2"), c("Cell1", "Cell2", "Cell3") ) ) obj <- Seurat::CreateSeuratObject(counts = counts) path <- tempfile(fileext = ".rds") saveRDS(obj, path) inspect_sc(path) unlink(path) }