Crate distmat

source ·
Expand description

Data types and file formats for distance matrix data.

Distance matrix data types:

  • DistMatrix stores only the lower diagonal so works for symmetric distance measures. It is more memory efficient and is compatible with R’s dist objects.
  • SquareMatrix stores the full matrix and is more efficient to access.

Both matrix types have their data stored in a single Vec<D>, and are generic over D. They provide various iterators and accessors to retrieve elements. They can optionally store labels (e.g. taxon labels from bioinformatic distance matrix formats).

There are different ways to load your data into matrix types:

  • using a pairwise distance measure: from_pw_distances or from_pw_distances_with,
  • from an iterator over pairs of labels and distances with from_labelled_distances,
  • from a vector stored in the correct order with collect,
  • from a file (see formats): tabular (e.g. snp-dists) or PHYLIP,
  • let square: SquareMatrix<D> = dist.into(); where dist: DistMatrix<D>,
  • let dist: DistMatrix<D> = square.lower_triangle(); where square: SquareMatrix<D>.

Re-exports

pub use square::SquareMatrix;
pub use symmetric::DistMatrix;

Modules

Read distance matrix data to different file formats.
An arbitrary square matrix.
A symmetric matrix stored as the lower triangle.

Enums

Error encountered when attempting to build a matrix from labelled distances.

Traits

Implemented for types with an obvious default meaning of absolute distance between points.