Skip to content

mianaz/srtdisk

 
 

Repository files navigation

srtdisk v0.3.1

CRAN/METACRAN Lifecycle R-CMD-check Codecov test coverage

Extended implementation of SeuratDisk for Seurat v5 with enhanced support for HDF5-based single cell file formats. The h5Seurat file format is specifically designed for the storage and analysis of multi-modal single-cell and spatially-resolved expression experiments, for example, from CITE-seq or 10X Visium technologies. It holds all molecular information and associated metadata, including (for example) nearest-neighbor graphs, dimensional reduction information, spatial coordinates and image data, and cluster labels. We also support rapid and on-disk conversion between h5Seurat and AnnData objects, with the goal of enhancing interoperability between Seurat and Scanpy. This version includes Seurat v5 Assay5 compatibility and improved spatial data handling.

Installation

srtdisk is not currently available on CRAN. You can install it from GitHub with:

if (!requireNamespace("remotes", quietly = TRUE)) {
  install.packages("remotes")
}
remotes::install_github("mianaz/srtdisk")

What’s New in srtdisk (vs SeuratDisk)

Feature SeuratDisk srtdisk
Seurat v5 Assay5 Not supported Full support
Visium Spatial Not supported Full support
Metadata Partial Numeric, categorical, boolean preserved
Direct Conversion Two-step only SeuratToH5AD() wrapper
h5ad Compatibility Basic Improved scanpy conventions

Quick Start

Seurat to h5ad (Recommended)

library(Seurat)
library(srtdisk)
library(SeuratData)

data("pbmc3k.final", package = "pbmc3k.SeuratData")
pbmc <- UpdateSeuratObject(pbmc3k.final)

# One-step conversion using Convert()
Convert(pbmc, dest = "pbmc3k.h5ad", overwrite = TRUE)

# Or use the convenience wrapper
SeuratToH5AD(pbmc, filename = "pbmc3k.h5ad", overwrite = TRUE)

Seurat to Loom

Convert(pbmc, dest = "pbmc3k.loom", overwrite = TRUE)

Seurat to h5Seurat

# Save as h5Seurat (can also use SaveH5Seurat() directly)
Convert(pbmc, dest = "pbmc3k.h5Seurat", overwrite = TRUE)

h5ad to Seurat

# Using bundled CRC sample
h5ad_path <- system.file("testdata", "crc_sample.h5ad", package = "srtdisk")
Convert(h5ad_path, dest = "h5seurat", overwrite = TRUE)
crc <- LoadH5Seurat("crc_sample.h5seurat")

Multi-assay (e.g. CITE-seq)

# Note: Converts one assay at a time
library(SeuratData)
InstallData("cbmc")
data("cbmc", package = "cbmc.SeuratData")
SeuratToH5AD(cbmc, filename = "cbmc_rna.h5ad", assay = "RNA", overwrite = TRUE)
SeuratToH5AD(cbmc, filename = "cbmc_adt.h5ad", assay = "ADT", overwrite = TRUE)

Visium Spatial Data Conversion

# Seurat Visium to h5ad
library(SeuratData)
InstallData("stxBrain")
brain <- UpdateSeuratObject(LoadData("stxBrain", type = "anterior1"))
SeuratToH5AD(brain, filename = "brain_spatial.h5ad", overwrite = TRUE)

# h5ad to Seurat (preserves spatial coordinates and images)
Convert("brain_spatial.h5ad", dest = "h5seurat", overwrite = TRUE)
brain_rt <- LoadH5Seurat("brain_spatial.h5seurat")

Function Reference

Core Conversion Functions

Function Description
Convert() Unified converter: Seurat/h5Seurat/h5ad/Loom
SeuratToH5AD() Convenience wrapper for Seurat to h5ad
SaveH5Seurat() Save Seurat object to h5Seurat file
LoadH5Seurat() Load Seurat object from h5Seurat file

h5Seurat File Operations

Function Description
Connect() Open connection to h5Seurat file for exploration
AppendData() Add data to existing Seurat object from h5Seurat

Conversion Options

Option Description
standardize = TRUE Convert column names to scanpy conventions
assays = "RNA" Specify which assay(s) to convert
overwrite = TRUE Overwrite existing output files

For detailed documentation, see the vignettes: - Conversions: h5Seurat and AnnData - Saving and Loading h5Seurat Files - h5Seurat File Format Specification

Dependencies

srtdisk depends on the following non-standard packages:

Package CRAN Webpage Source Website
cli CRAN GitHub Website
crayon CRAN GitHub Website
hdf5r CRAN GitHub Website
Matrix CRAN - Website
R6 CRAN GitHub Website
rlang CRAN GitHub Website
Seurat CRAN GitHub Website
SeuratObject CRAN GitHub Website
stringi CRAN GitHub Website

About

Seurat v5 compatible HDF5 converter for single-cell data — h5ad, h5Seurat, h5mu, Loom with full spatial data support

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • R 100.0%