1 unstable release
0.1.0 | Aug 31, 2023 |
---|
#13 in #spectrum
Used in sfs-cli
165KB
4.5K
SLoC
sfs
sfs
is a tool for creating and working with the site frequency spectra.
The README is currently under construction. Usage and examples will be added soon.
Contents
Installation
From source
A recent Rust toolchain is required to build sfs
from source. Currently, the Rust toolchain can be installed by running:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
See instructions for more details.
sfs
can now be build from source, using either the latest released version, or the current git head, as described below.
Latest release
The following will install the latest released version of sfs
:
cargo install sfs-cli
This will install the sfs
binary to $HOME/.cargo/bin
by default, which should be in the $PATH
after installing cargo
. Alternatively:
cargo install sfs-cli --root $HOME
Will install to $HOME/bin
.
Current git
The latest git version may include more (potentially experimental) features, and can be installed using:
cargo install --git https://github.com/malthesr/sfs
Pre-built
Pre-built binaries are available from the releases page (linux, mac, windows).
For a one-liner, something like the following should work in a UNIX environment:
curl -s -L $url | tar xvz -O > $dest
Where $url
is chosen from above, and $dest
is the resulting binary, e.g. $HOME/bin/sfs
.
Conda
sfs
is available via conda
on the BioConda channel:
conda install -c bioconda sfs
Docker
A docker image is automatically built by BioContainers from the BioConda recipe and hosted on Quay.io:
docker pull quay.io/biocontainers/sfs:$tag
With $tag
chosen among the available tags.
lib.rs
:
Tools for working with site frequency spectra.
This serves as the core library implementation for the sfs
CLI, but can also be used as a
free-standing library for working with frequency spectra.
Overview
The core struct is a Spectrum
, which is backed by an N-dimensional Array
.
A spectrum may either be a frequency spectrum ([Sfs
]), in which case we say that it is
normalized, or it may be a count spectrum ([Scs
]).
Example
As a very brief introduction to the API, let's create a count spectrum, and then normalize it to obtain a per-base estimate of θ using Watterson's estimator.
use sfs_core::Scs;
// Create a 1-dimensional SCS from some data
let scs = Scs::from_vec([25., 8., 4., 2., 1., 0.]);
// Normalize the spectrum to frequencies
let sfs = scs.into_normalized();
// Calculate θ
let theta = sfs.theta_watterson().expect("θ only defined in 1D");
assert!((theta - 0.18).abs() < 1e-16);
Dependencies
~4MB
~80K SLoC