pub enum RawCounts {
U16(Vec<u16>),
U32(Vec<u32>),
}Expand description
Wrapper enum for raw counts that supports both u16 and u32 storage.
Most single cell data sets have counts well within the u16 range (0-65,535). The u32 variant exists for edge cases such as mixed-omics data where counts can exceed this limit. The variant is selected automatically at construction time based on the data, and is encoded as a discriminant byte in the binary chunk format.
Variants§
U16(Vec<u16>)
Stores u16 values
U32(Vec<u32>)
Stores u32 values (for the rare case where a single gene exceeds the counts here)
Implementations§
Source§impl RawCounts
impl RawCounts
Sourcepub fn iter(&self) -> RawCountsIter<'_> ⓘ
pub fn iter(&self) -> RawCountsIter<'_> ⓘ
Sourcepub fn write_bytes(&self, writer: &mut impl Write) -> Result<()>
pub fn write_bytes(&self, writer: &mut impl Write) -> Result<()>
Sourcepub fn read_from_buffer(
buffer: &[u8],
count: usize,
elem_size: u8,
) -> Result<Self, ScDataErrors>
pub fn read_from_buffer( buffer: &[u8], count: usize, elem_size: u8, ) -> Result<Self, ScDataErrors>
Read raw counts from a buffer given element size and count
§Params
buffer- The byte buffer to read from (must be positioned at the start of the raw count data)count- Number of elements to readelem_size- Element size in bytes (2 for u16, 4 for u32)
§Returns
The RawCounts, or ScDataErrors::RawElemSizeInvalid if the
discriminant is unrecognised, or ScDataErrors::ChunkPayloadTruncated
if the buffer is shorter than count * elem_size.
Sourcepub fn from_u32_auto(data: &[u32]) -> Self
pub fn from_u32_auto(data: &[u32]) -> Self
Build RawCounts from a u32 slice, auto-selecting the variant.
If all values fit in u16, stores as U16 for better compression. Otherwise stores as U32.
Trait Implementations§
Source§impl<'__de, __Context> BorrowDecode<'__de, __Context> for RawCounts
impl<'__de, __Context> BorrowDecode<'__de, __Context> for RawCounts
Source§fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>(
decoder: &mut __D,
) -> Result<Self, DecodeError>
fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>( decoder: &mut __D, ) -> Result<Self, DecodeError>
Source§impl<'de> Deserialize<'de> for RawCounts
impl<'de> Deserialize<'de> for RawCounts
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for RawCounts
impl RefUnwindSafe for RawCounts
impl Send for RawCounts
impl Sync for RawCounts
impl Unpin for RawCounts
impl UnsafeUnpin for RawCounts
impl UnwindSafe for RawCounts
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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.