Skip to main content

Module import

Module import 

Source
Expand description

Build a backend from the formats single-cell tools write.

  • from_mtx: a MatrixMarket file with its feature and barcode TSVs, such as a 10x Cell Ranger MEX triplet (MtxImport).
  • [from_h5ad] (feature hdf5): an AnnData .h5ad file ([H5adImport]), its obs written beside the backend as {stem}.cell_metadata.tsv.gz.
  • [from_10x_matrix] (feature hdf5): a Cell Ranger feature-barcode matrix .h5 ([TenxMatrixImport]).
  • [from_10x_molecule] (feature hdf5): a Cell Ranger molecule_info.h5, counted as Cell Ranger counts it ([TenxMoleculeImport]).

Each writes the backend Output names, squeezed when it asks, and returns the path of the file written: {output}.zarr.zip by default. The stage_* functions stop short of the last step and return a Staged build, for a caller that looks at the backend before keeping it (as the CLI’s import preview does). These are what data-beans from-mtx, from-h5ad, from-10x-matrix and from-10x-molecule run.

use data_beans::import::{self, MtxImport, Output};

let mtx = MtxImport {
    row: Some("filtered/features.tsv.gz".into()),
    col: Some("filtered/barcodes.tsv.gz".into()),
    ..MtxImport::new("filtered/matrix.mtx.gz")
};
let backend = import::from_mtx(&mtx, &Output::new("pbmc"))?; // "pbmc.zarr.zip"

#[cfg(feature = "hdf5")]
let backend = import::from_h5ad(&import::H5adImport::new("pbmc.h5ad"), &Output::new("pbmc"))?;

Structs§

MtxImport
A MatrixMarket matrix and its name files, as from_mtx reads them.
Output
Where an import writes its backend.
Squeeze
A squeeze: the rows and columns with fewer non-zeros than these go.
Staged
A backend written but not yet in place: for a .zarr.zip output, the .zarr directory it is zipped from. finish puts it in place; discard deletes it.

Functions§

from_mtx
Build the backend out names from the matrix mtx; the path written.
stage_mtx
from_mtx short of squeezing and putting the backend in place.