SeuratDisk Not Working? Common Errors and Alternatives for Seurat v5

Updated

SeuratDisk is still the first result in many tutorials for moving data between Seurat and Scanpy, but it predates both Seurat v5 and the current AnnData on-disk format. If Convert() or LoadH5Seurat() is throwing errors, this page explains why and what to use instead.

TL;DR: replace SeuratDisk with anndataR: write_h5ad(obj, "out.h5ad") and read_h5ad("in.h5ad", as = "Seurat"). Or skip the setup with the SingleCellConvert online converter.

Why SeuratDisk breaks

1. Seurat v5 Assay5 objects

Seurat v5 introduced Assay5 with named layers (and split layers after integration). SeuratDisk's SaveH5Seurat() expects the older Assay class with counts/data/scale.data slots, so it errors or silently drops data. Workaround if you must keep SeuratDisk:

obj <- JoinLayers(obj)
obj[["RNA"]] <- as(obj[["RNA"]], "Assay")
SaveH5Seurat(obj, "out.h5Seurat", overwrite = TRUE)
Convert("out.h5Seurat", dest = "h5ad", overwrite = TRUE)

2. Newer h5ad categorical encoding

anndata 0.8 changed how categorical columns are stored on disk. SeuratDisk looks for the old layout, which produces errors such as Missing required datasets 'levels' and 'values' when converting h5ad → h5Seurat. A Python-side workaround:

import anndata as ad
adata = ad.read_h5ad("in.h5ad")
for col in adata.obs.select_dtypes("category"):
    adata.obs[col] = adata.obs[col].astype(str)
adata.write_h5ad("in_fixed.h5ad")

3. Installation

Because it's GitHub-only and depends on hdf5r, installs often fail on HPC clusters without system HDF5 libraries, or on newer R versions.

Alternatives compared

ToolDirectionsPython neededSeurat v5Maintained by
anndataRBothNoYesscverse
zellkonverterBoth (via SCE)Auto-managed (basilisk)Via SCEBioconductor
sceasyBothYes (reticulate)Partialcellgeni
SeuratDiskBothNoWorkaroundLittle activity
SingleCellConvertBothNo (web)YesHosted service

Migrating from SeuratDisk to anndataR

# Before (SeuratDisk)
SaveH5Seurat(obj, "data.h5Seurat"); Convert("data.h5Seurat", dest = "h5ad")
Convert("data.h5ad", dest = "h5seurat"); obj <- LoadH5Seurat("data.h5seurat")

# After (anndataR)
library(anndataR)
write_h5ad(JoinLayers(obj), "data.h5ad")
obj <- read_h5ad("data.h5ad", as = "Seurat")

Step-by-step guides for each direction: Seurat → AnnData and AnnData → Seurat.

Frequently asked questions

Is SeuratDisk still maintained?

SeuratDisk was never released on CRAN and receives very few updates. It was built for Seurat v3/v4 objects and older anndata file layouts, which is why it breaks on Seurat v5 and recent h5ad files.

What is the best SeuratDisk alternative?

anndataR, maintained by scverse, converts both directions (write_h5ad for Seurat → h5ad, read_h5ad(..., as = "Seurat") for h5ad → Seurat) without Python or intermediate files. zellkonverter is a good choice for Bioconductor workflows.

How do I fix "Missing required datasets 'levels' and 'values'"?

That error comes from SeuratDisk reading categorical columns written by anndata 0.8+. Switch to anndataR, or in Python convert categorical obs columns to strings before saving the h5ad.

Related guides