Module bustools::iterators

source ·
Expand description

Advanced iterators over busrecords, grouping records by cell or molecule.

Allows to iterate over

  • cells (CB)
  • mRNAs (CB+UMI)
  • CB+UMI+gene: in case some CB/UMI collision

To iterate over a sorted busfile, grouping all records by CB:

use bustools::iterators::CellGroupIterator; //need to bring that trait into scope
 
let breader = BusReader::new("/path/to/some.bus");
for (cb, vector_of_records) in breader.groupby_cb() {
    // Example: the number of records in that cell
    let n_molecules: usize = vector_of_records.len();
}

To iterate over a sorted busfile, grouping all records by CB+UMI:

use bustools::iterators::CbUmiGroupIterator; //need to bring that trait into scope
 
let breader = BusReader::new("/path/to/some.bus");
for ((cb, umi), vector_of_records) in breader.groupby_cbumi() {
    // Example: the number of reads of that molecule (CB/UMI)
    let n_reads: u32 = vector_of_records.iter().map(|r| r.COUNT).sum();
}

Structs§

Traits§

  • gets iterator chaining working! Just a wrapper around CbUmiGroupIterator::new()
  • gets iterator chaining working! Just a wrapper around CellGroupIterator::new()
  • gets iterator chaining working! Just a wrapper around GroupbyGene::new()