Struct CountMatrix

Source
pub struct CountMatrix<A: Alphabet> { /* private fields */ }
Expand description

A matrix storing symbol occurrences at each position.

Implementations§

Source§

impl<A: Alphabet> CountMatrix<A>

Source

pub fn new(data: DenseMatrix<u32, A::K>) -> Result<Self, InvalidData>

Create a new count matrix from the given data.

The matrix must contain count data, for sequences of the same length, i.e. rows should all sum to the same value.

Source

pub fn from_sequences<I>(sequences: I) -> Result<Self, InvalidData>

Create a new count matrix from the given sequences.

§Errors

This function returns Err(InvalidData) when the sequences do not all have the same length:

let result = CountMatrix::<Dna>::from_sequences([
    EncodedSequence::new(vec![T, T, A, T]),
    EncodedSequence::new(vec![T, C, A]),
]);
assert!(result.is_err());
Source

pub fn to_freq<P>(&self, pseudo: P) -> FrequencyMatrix<A>
where P: Into<Pseudocounts<A>>,

Build a probability matrix from this count matrix using pseudo-counts.

Source

pub fn sequence_count(&self) -> usize

Get the number of sequences used to build the matrix.

Source

pub fn entropy(&self) -> Vec<f32>

Compute the Shannon entropy of each row of the matrix.

The entropy of a row, sometimes refered to as “uncertainty”, is computed by treating each motif position as a random variable taking values in alphabet A.

Source

pub fn consensus(&self) -> String

Build the consensus sequence for the matrix.

For each row of the matrix, the symbol with the highest occurence is extracted. Symbols as position with entropy higher than 1.0 are shown in lowercase.

Source§

impl<A: ComplementableAlphabet> CountMatrix<A>

Source

pub fn reverse_complement(&self) -> Self

Get the reverse-complement of this count matrix.

Source§

impl<A: Alphabet> CountMatrix<A>

Source

pub fn matrix(&self) -> &DenseMatrix<u32, A::K>

The raw data storage for the matrix.

Source

pub fn len(&self) -> usize

Get the length of the motif encoded in this matrix.

Source

pub fn is_empty(&self) -> bool

Check whether the matrix is empty.

Trait Implementations§

Source§

impl<A: Alphabet> AsRef<CountMatrix<A>> for CountMatrix<A>

Source§

fn as_ref(&self) -> &Self

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<A: Alphabet> AsRef<DenseMatrix<u32, <A as Alphabet>::K>> for CountMatrix<A>

Source§

fn as_ref(&self) -> &DenseMatrix<u32, A::K>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<A: Clone + Alphabet> Clone for CountMatrix<A>
where A::K: Clone,

Source§

fn clone(&self) -> CountMatrix<A>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<A: Alphabet> Correlation for CountMatrix<A>

Source§

fn num_rows(&self) -> usize

The number of rows in the matrix.
Source§

fn dot(&self, other: &Self, i: usize, j: usize) -> f32

Compute the dot product between row i of self and row j of other.
Source§

fn norm(&self, i: usize) -> f32

Compute the Euclidean norm of row i.
Source§

fn auto_correlation(&self, delay: usize) -> f32

Compute the auto-correlation with the given delay.
Source§

fn cross_correlation(&self, other: &Self) -> f32

Compute the cross-correlation between two matrices.
Source§

impl<A: Debug + Alphabet> Debug for CountMatrix<A>
where A::K: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<A: Alphabet> Index<usize> for CountMatrix<A>

Source§

type Output = <DenseMatrix<u32, <A as Alphabet>::K> as Index<usize>>::Output

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<A: PartialEq + Alphabet> PartialEq for CountMatrix<A>
where A::K: PartialEq,

Source§

fn eq(&self, other: &CountMatrix<A>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<A: Eq + Alphabet> Eq for CountMatrix<A>
where A::K: Eq,

Source§

impl<A: Alphabet> StructuralPartialEq for CountMatrix<A>

Auto Trait Implementations§

§

impl<A> Freeze for CountMatrix<A>

§

impl<A> RefUnwindSafe for CountMatrix<A>

§

impl<A> Send for CountMatrix<A>
where A: Send,

§

impl<A> Sync for CountMatrix<A>
where A: Sync,

§

impl<A> Unpin for CountMatrix<A>
where A: Unpin, <<A as Alphabet>::K as ArrayLength>::ArrayType<u32>: Unpin,

§

impl<A> UnwindSafe for CountMatrix<A>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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