pub struct ParallelSparseReader { /* private fields */ }Expand description
ParallelSparseReader
Implementations§
Source§impl ParallelSparseReader
impl ParallelSparseReader
Sourcepub fn new(f_path: &str) -> Result<Self, ScDataErrors>
pub fn new(f_path: &str) -> Result<Self, ScDataErrors>
Sourcepub fn file_version(&self) -> u32
pub fn file_version(&self) -> u32
Sourcepub fn count_norm_stored_chunks(&self) -> Result<usize, ScDataErrors>
pub fn count_norm_stored_chunks(&self) -> Result<usize, ScDataErrors>
Count the chunks that store their normalised layer verbatim.
Only reads the fixed chunk headers. Such chunks skip the norm recompute on read and are larger on disk.
§Returns
The number of norm-stored chunks, or
ScDataErrors::FileVersionMismatch on a v3 file, which always stores
the layer.
Source§impl ParallelSparseReader
impl ParallelSparseReader
Sourcepub fn read_cells_csr(
&self,
indices: &[usize],
data_layer: &DataLayerReturn,
) -> Result<CsrBatch, ScDataErrors>
pub fn read_cells_csr( &self, indices: &[usize], data_layer: &DataLayerReturn, ) -> Result<CsrBatch, ScDataErrors>
Read a batch of cells straight into CSR, as f32.
SingleCellReading::read_cells_sparse with T = f32, unpacked into
the CsrBatch the Python loader hands to scipy or torch.
§Params
indices- Original cell indices, in the order the batch wants themdata_layer- Which layer(s) to materialise
§Returns
The batch as CSR, or ScDataErrors::ReaderModeMismatch on a
gene-major store.
Trait Implementations§
Source§impl SingleCellReading for ParallelSparseReader
impl SingleCellReading for ParallelSparseReader
Source§fn read_cells_parallel(
&self,
indices: &[usize],
) -> Result<Vec<CsrCellChunk>, ScDataErrors>
fn read_cells_parallel( &self, indices: &[usize], ) -> Result<Vec<CsrCellChunk>, ScDataErrors>
Source§fn read_cells_sparse<T>(
&self,
indices: &[usize],
data_layer: &DataLayerReturn,
) -> Result<CompressedSparseData2<T, f32>, ScDataErrors>where
T: BixverseNumeric + FromPrimitive,
fn read_cells_sparse<T>(
&self,
indices: &[usize],
data_layer: &DataLayerReturn,
) -> Result<CompressedSparseData2<T, f32>, ScDataErrors>where
T: BixverseNumeric + FromPrimitive,
Source§fn read_genes_sparse<T>(
&self,
indices: &[usize],
cells_to_keep: Option<&IndexSet<u32>>,
data_layer: &DataLayerReturn,
) -> Result<CompressedSparseData2<T, f32>, ScDataErrors>where
T: BixverseNumeric + FromPrimitive,
fn read_genes_sparse<T>(
&self,
indices: &[usize],
cells_to_keep: Option<&IndexSet<u32>>,
data_layer: &DataLayerReturn,
) -> Result<CompressedSparseData2<T, f32>, ScDataErrors>where
T: BixverseNumeric + FromPrimitive,
Read a batch of genes straight into CSC, optionally filtering cells
Decompresses each gene into the worker’s scratch buffer and appends
its payload in place, filtering through a dense cell map built once
per call, see [read_fused].
§Params
indices- Gene indices, in output column ordercells_to_keep- Cells to keep, in output row order, orNonedata_layer- Which layer(s) to materialise
§Returns
The batch as CSC.
Source§fn read_gene_parallel(
&self,
indices: &[usize],
) -> Result<Vec<CscGeneChunk>, ScDataErrors>
fn read_gene_parallel( &self, indices: &[usize], ) -> Result<Vec<CscGeneChunk>, ScDataErrors>
Source§fn read_gene_parallel_raw(
&self,
indices: &[usize],
) -> Result<Vec<CscGeneChunk>, ScDataErrors>
fn read_gene_parallel_raw( &self, indices: &[usize], ) -> Result<Vec<CscGeneChunk>, ScDataErrors>
Read genes with raw counts and indices only.
On v4 the norm layer is neither recomputed nor converted, data_norm
comes back empty and the decoded indices move into the chunk. v3 reads
both layers, as Self::read_gene_parallel.
§Params
indices- Slice of index positions of the genes to retrieve
§Returns
Returns an array of CscGeneChunk with an empty data_norm on v4.
Source§fn read_gene_parallel_filtered(
&self,
indices: &[usize],
cells_to_keep: &IndexSet<u32>,
) -> Result<Vec<CscGeneChunk>, ScDataErrors>
fn read_gene_parallel_filtered( &self, indices: &[usize], cells_to_keep: &IndexSet<u32>, ) -> Result<Vec<CscGeneChunk>, ScDataErrors>
Read in genes by indices in a multi-threaded manner
And filter the genes by cells_to_keep in parallel. Overrides the
default so that reading and filtering are fused into a single pass.
§Params
indices- Slice of index positions of the genes to retrievecells_to_keep- Cell index positions to keep, in output order
§Returns
Returns an array of CscGeneChunk.
Source§fn get_header(&self) -> SparseDataHeader
fn get_header(&self) -> SparseDataHeader
Source§fn read_cell_library_sizes(
&self,
indices: &[usize],
) -> Result<Vec<usize>, ScDataErrors>
fn read_cell_library_sizes( &self, indices: &[usize], ) -> Result<Vec<usize>, ScDataErrors>
Read only library sizes for specified cells
More efficient than the default, which parses whole chunks. Files with a library-size index read 8 bytes per cell from it; older files decompress each chunk and read the header bytes (offset 12-19) without deserialising the rest.
§Params
indices- Cell indices
§Returns
Vector of library sizes
Source§fn read_gene_nnz(&self, indices: &[usize]) -> Result<Vec<usize>, ScDataErrors>
fn read_gene_nnz(&self, indices: &[usize]) -> Result<Vec<usize>, ScDataErrors>
Source§fn is_cell_based(&self) -> bool
fn is_cell_based(&self) -> bool
Source§fn target_size(&self) -> Option<f32>
fn target_size(&self) -> Option<f32>
Library size the data_norm layer of this file was scaled to.
§Returns
Some(target_size), or None for raw-only files and for files written
before the field entered the header.
Source§fn is_gene_based(&self) -> bool
fn is_gene_based(&self) -> bool
Source§fn read_cell(&self, index: usize) -> Result<CsrCellChunk, ScDataErrors>
fn read_cell(&self, index: usize) -> Result<CsrCellChunk, ScDataErrors>
Source§fn read_gene(&self, index: usize) -> Result<CscGeneChunk, ScDataErrors>
fn read_gene(&self, index: usize) -> Result<CscGeneChunk, ScDataErrors>
Source§fn read_cells_range(
&self,
start: usize,
end: usize,
) -> Result<Vec<CsrCellChunk>, ScDataErrors>
fn read_cells_range( &self, start: usize, end: usize, ) -> Result<Vec<CsrCellChunk>, ScDataErrors>
Source§fn get_all_cells(&self) -> Result<Vec<CsrCellChunk>, ScDataErrors>
fn get_all_cells(&self) -> Result<Vec<CsrCellChunk>, ScDataErrors>
Source§fn get_all_genes(&self) -> Result<Vec<CscGeneChunk>, ScDataErrors>
fn get_all_genes(&self) -> Result<Vec<CscGeneChunk>, ScDataErrors>
Source§fn get_all_gene_nnz(&self) -> Result<Vec<usize>, ScDataErrors>
fn get_all_gene_nnz(&self) -> Result<Vec<usize>, ScDataErrors>
Auto Trait Implementations§
impl Freeze for ParallelSparseReader
impl RefUnwindSafe for ParallelSparseReader
impl Send for ParallelSparseReader
impl Sync for ParallelSparseReader
impl Unpin for ParallelSparseReader
impl UnsafeUnpin for ParallelSparseReader
impl UnwindSafe for ParallelSparseReader
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.