Skip to contents

Converts a Seurat object directly to an H5AD file, handling the intermediate h5Seurat file automatically. The intermediate file is created in a temporary location and removed after conversion.

Usage

SeuratToH5AD(
  object,
  filename = NULL,
  assay = DefaultAssay(object = object),
  overwrite = FALSE,
  verbose = TRUE,
  standardize = FALSE,
  ...
)

Arguments

object

A Seurat object to convert

filename

Output H5AD filename. If not specified, uses the project name with .h5ad extension.

assay

Name of assay to convert. Default is the default assay.

overwrite

Logical; overwrite existing file. Default FALSE.

verbose

Logical; show progress messages. Default TRUE.

standardize

Logical; convert Seurat metadata names to scanpy conventions. Default FALSE.

...

Additional arguments passed to SaveH5Seurat and Convert.

Value

Invisibly returns the path to the created H5AD file.

Details

This function provides a convenient one-step conversion from Seurat objects to H5AD format (used by Python's scanpy/anndata). Internally, it:

  1. Saves the Seurat object to a temporary h5Seurat file

  2. Converts the h5Seurat file to H5AD format

  3. Removes the intermediate h5Seurat file

This is useful when you want to export data for Python analysis without keeping the intermediate h5Seurat file.

Examples

if (FALSE) { # \dontrun{
library(Seurat)
library(srtdisk)

# Load or create a Seurat object
pbmc <- pbmc_small

# Convert directly to H5AD
SeuratToH5AD(pbmc, filename = "pbmc.h5ad")

# The file can now be loaded in Python:
# import scanpy as sc
# adata = sc.read_h5ad("pbmc.h5ad")
} # }