Skip to main content

ParallelSparseReader

Struct ParallelSparseReader 

Source
pub struct ParallelSparseReader { /* private fields */ }
Expand description

ParallelSparseReader

Implementations§

Source§

impl ParallelSparseReader

Source

pub fn new(f_path: &str) -> Result<Self, ScDataErrors>

Generate a new parallelised streaming reader

§Params
  • f_path - Path to the file
§Returns

Initialised ParallelSparseReader.

Source

pub fn file_version(&self) -> u32

Format version of the file this reader maps.

§Returns

SC_FILE_VERSION_V3 or SC_FILE_VERSION.

Source

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

Source

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 them
  • data_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

Source§

fn read_cells_parallel( &self, indices: &[usize], ) -> Result<Vec<CsrCellChunk>, ScDataErrors>

Read in cells by indices in a multi-threaded manner

§Params
  • indices - Slice of index positions of the cells to retrieve
§Returns

Returns an array of CsrCellChunk.

Source§

fn read_cells_sparse<T>( &self, indices: &[usize], data_layer: &DataLayerReturn, ) -> Result<CompressedSparseData2<T, f32>, ScDataErrors>

Read a batch of cells straight into CSR

Decompresses each cell into the worker’s scratch buffer and appends its payload in place, see [read_fused].

§Params
  • indices - Cell indices, in output row order
  • data_layer - Which layer(s) to materialise
§Returns

The batch as CSR.

Source§

fn read_genes_sparse<T>( &self, indices: &[usize], cells_to_keep: Option<&IndexSet<u32>>, data_layer: &DataLayerReturn, ) -> Result<CompressedSparseData2<T, f32>, ScDataErrors>

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 order
  • cells_to_keep - Cells to keep, in output row order, or None
  • data_layer - Which layer(s) to materialise
§Returns

The batch as CSC.

Source§

fn read_gene_parallel( &self, indices: &[usize], ) -> Result<Vec<CscGeneChunk>, ScDataErrors>

Read in genes by indices in a multi-threaded manner

§Params
  • indices - Slice of index positions of the genes to retrieve
§Returns

Returns an array of CscGeneChunk.

Source§

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>

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 retrieve
  • cells_to_keep - Cell index positions to keep, in output order
§Returns

Returns an array of CscGeneChunk.

Source§

fn get_header(&self) -> SparseDataHeader

Helper to return the header

§Returns

Returns the header file

Source§

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>

Read the NNZ for specific genes

Overrides the default, which parses whole chunks. Reads directly from the chunk header bytes (offset 16-23) instead.

§Params
  • indices - Gene indices
§Returns

Vector of number of NNZ genes.

Source§

fn is_cell_based(&self) -> bool

Is the reader connected to a cell-based file?

§Returns

Bool

Source§

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

Is the store laid out for fast gene retrieval? Read more
Source§

fn read_cell(&self, index: usize) -> Result<CsrCellChunk, ScDataErrors>

Read a single cell by index Read more
Source§

fn read_gene(&self, index: usize) -> Result<CscGeneChunk, ScDataErrors>

Read a single gene by index Read more
Source§

fn read_cells_range( &self, start: usize, end: usize, ) -> Result<Vec<CsrCellChunk>, ScDataErrors>

Read a contiguous range of cells Read more
Source§

fn get_all_cells(&self) -> Result<Vec<CsrCellChunk>, ScDataErrors>

Return all cells in the store Read more
Source§

fn get_all_genes(&self) -> Result<Vec<CscGeneChunk>, ScDataErrors>

Return all genes in the store Read more
Source§

fn get_all_gene_nnz(&self) -> Result<Vec<usize>, ScDataErrors>

Return NNZ for all genes Read more
Source§

fn get_clr_offsets( &self, indices: &[usize], batch_size: Option<usize>, ) -> Result<Vec<f64>, ScDataErrors>

Compute the shifted CLR per-cell offsets freshly from raw counts. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> DistributionExt for T
where T: ?Sized,

Source§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V