Part of #20. Depends on #21. Equivalent of scanpy.read_10x_mtx / read_mtx.
Import
- 10x folders:
matrix.mtx[.gz] + barcodes.tsv[.gz] + features.tsv[.gz] (or genes.tsv for Cell Ranger 2).
- STARsolo
Solo.out/Gene/{filtered,raw} (same layout; features.tsv without the feature-type column).
- STARsolo velocyto output (
Solo.out/Velocyto/raw/{spliced,unspliced,ambiguous}.mtx) → layers.
- A bare
.mtx file, with optional --obs-names-file / --var-names-file.
- Orientation: 10x/STARsolo are genes × cells (transposed on read);
--transpose / --no-transpose override.
Make it streaming. formats/sparse._read_mtx currently builds a Python list of every entry — unusable for large files. Replace with:
- pass 1: stream the file (gzip as a stream), count nnz per output row →
indptr
- pass 2: scatter entries into preallocated on-disk
indices/data, buffered in chunks
- sort indices within rows only if the file isn't already ordered
The same reader should back adata import sparse, which benefits too.
Export
h5ad → 10x v3 folder with gzipped files: extend formats/sparse.export_mtx and write barcodes.tsv.gz / features.tsv.gz from obs / var. --layer picks the matrix.
Tests
- Fixtures for Cell Ranger 2, Cell Ranger 3, STARsolo (incl. velocyto) and a bare mtx.
- Compare with
scanpy.read_10x_mtx / read_mtx (integration marker).
- Perf guard bounding reads/writes for the two-pass import.
Part of #20. Depends on #21. Equivalent of
scanpy.read_10x_mtx/read_mtx.Import
matrix.mtx[.gz]+barcodes.tsv[.gz]+features.tsv[.gz](orgenes.tsvfor Cell Ranger 2).Solo.out/Gene/{filtered,raw}(same layout;features.tsvwithout the feature-type column).Solo.out/Velocyto/raw/{spliced,unspliced,ambiguous}.mtx) →layers..mtxfile, with optional--obs-names-file/--var-names-file.--transpose/--no-transposeoverride.Make it streaming.
formats/sparse._read_mtxcurrently builds a Python list of every entry — unusable for large files. Replace with:indptrindices/data, buffered in chunksThe same reader should back
adata import sparse, which benefits too.Export
h5ad → 10x v3 folder with gzipped files: extend
formats/sparse.export_mtxand writebarcodes.tsv.gz/features.tsv.gzfromobs/var.--layerpicks the matrix.Tests
scanpy.read_10x_mtx/read_mtx(integrationmarker).