Expand description
Write a backend out to the interchange formats scanpy and Seurat read.
to_mtx: a 10x Genomics Cell Ranger MEX triplet directory (matrix.mtx,features.tsv,barcodes.tsv, gzipped by default), loaded byscanpy.read_10x_mtx(dir)and SeuratRead10X(dir).- [
to_h5ad] (featurehdf5): an AnnData.h5adfile, loaded byanndata.read_h5ad, with optionalobs/varmetadata tables.
Both take a backend already open, so a caller holding one does not open
it again; open_sparse_matrix_by_path
opens one from its file. These are what data-beans to-mtx and
data-beans to-h5ad run, and write the same bytes.
use data_beans::export::{self, MtxExport};
use data_beans::sparse_io::open_sparse_matrix_by_path;
let data = open_sparse_matrix_by_path("sim.zarr.zip")?;
// sim_mtx/{matrix.mtx.gz, features.tsv.gz, barcodes.tsv.gz}
export::to_mtx(data.as_ref(), "sim_mtx", &MtxExport::default())?;
#[cfg(feature = "hdf5")]
{
let mut data = data;
let out = export::h5ad_path("sim.zarr.zip", None); // "sim.h5ad"
export::to_h5ad(data.as_mut(), &out, &export::H5adExport::default())?;
}Structs§
Functions§
- to_mtx
- Export
datato a 10x Genomics MEX (MatrixMarket) triplet in the directoryout_dir, created if missing, readable by scanpy / Seurat. This is the inverse ofcrate::import::from_mtx; the directory is returned.