convert

convert(
    input,
    output,
    *,
    dtype='f32',
    assay=None,
    layer='counts',
    x_slot='X',
    chunk_size=5000,
    gene_major=False,
    transpose_mem=4.0,
    where=None,
)

Convert a single-cell dataset to .h5ad, .h5seurat or .zarr.

The input format is detected from the file (H5AD, H5Seurat, BPCells, 10x HDF5, MatrixMarket, AnnData Zarr). The output format is chosen by the extension of output; .zarr is an AnnData Zarr v3 store. The matrix is streamed in chunks of chunk_size cells, so peak memory does not grow with the cell count.

Parameters

Name Type Description Default
input Pathish Source and destination paths. required
output Pathish Source and destination paths. required
dtype str Value type of the written matrix: "f32", "f64", "i32" or "u32". 'f32'
assay str | None Seurat assay and layer to read from Seurat input. assay=None reads "RNA" from H5Seurat and the object’s active assay from a .rds. From MuData .h5mu assay names the modality (default: the only one, else "rna"). assay is also the assay name written to H5Seurat output ("RNA" when None). None
layer str | None Seurat assay and layer to read from Seurat input. assay=None reads "RNA" from H5Seurat and the object’s active assay from a .rds. From MuData .h5mu assay names the modality (default: the only one, else "rna"). assay is also the assay name written to H5Seurat output ("RNA" when None). None
x_slot str Where the matrix goes in .h5ad output: "X" (default) or "layers/<name>", which writes it there and leaves X absent. A source layer of that name is dropped. Applies to .h5ad and .zarr output; ignored for .h5seurat. 'X'
chunk_size int Cells per streamed chunk. 5000
gene_major bool Write X stored by gene (CSC), so :func:open_stream with axis="var" reads blocks of whole genes; .h5ad output only. The same as scx convert --gene-major. anndata reads it as a csc_matrix. False
transpose_mem float With gene_major: GB of transposed nonzeros held at a time. Less memory means more passes over the input. 4.0
where Mapping[str, object] | None Write only the cells matching {column: value} or {column: [values]} over obs, matched as in :func:open_stream: every column must hold one of its values, compared as text (str(v), booleans as True/False); NA never matches. X, layers, raw.X, obs and obsm keep the matching rows, obsp those rows and columns; var, varm and uns are unchanged. The matrix still streams. h5ad, Zarr, h5seurat (dgCMatrix) and 10x HDF5 input read only the matching rows of X. No match writes a file with 0 cells; an unknown column raises. The same as scx convert --where col=value. None

Returns

Name Type Description
Path output.