lightmotif-tfmpvalue

Crates.iolightmotif-tfmpvalue
lib.rslightmotif-tfmpvalue
version0.9.1
sourcesrc
created_at2023-06-25 21:50:18.036064
updated_at2024-09-02 22:46:45.795116
descriptionRust reimplementation of TFMPvalue for the lightmotif crate.
homepagehttps://github.com/althonos/lightmotif
repositoryhttps://github.com/althonos/lightmotif
max_upload_size
id899836
size69,336
Martin Larralde (althonos)

documentation

README

🎼🧬 lightmotif-tfmpvalue Star me

A Rust port of the TFMPvalue algorithm for the lightmotif crate..

Actions Coverage License Crate Docs Source Mirror GitHub issues Changelog

🗺️ Overview

TFMPvalue is an algorithm proposed by Touzet & Varré[1] for computing a p-value from a score obtained with a position weight matrix. It uses discretization to compute an approximation of the score distribution for the position weight matrix, iterating with growing levels of accuracy until convergence is reached. This approach outperforms dynamic-programming based methods such as LazyDistrib by Beckstette et al.[2].

lightmotif-tfmpvalue provides an implementation of the TFMPvalue algorithm to use with position weight matrices from the lightmotif crate.

💡 Example

Use lightmotif to create a position specific scoring matrix, and then use the TFMPvalue algorithm to compute the exact P-value for a given score, or a score threshold for a given P-value:

extern crate lightmotif;
extern crate lightmotif_tfmpvalue;

use lightmotif::pwm::CountMatrix;
use lightmotif::abc::Dna;
use lightmotif::seq::EncodedSequence;
use lightmotif_tfmpvalue::TfmPvalue;

// Use a ScoringMatrix from `lightmotif`
let pssm = CountMatrix::<Dna>::from_sequences(&[
        EncodedSequence::encode("GTTGACCTTATCAAC").unwrap(),
        EncodedSequence::encode("GTTGATCCAGTCAAC").unwrap(),
    ])
    .unwrap()
    .to_freq(0.25)
    .to_scoring(None);

// Initialize the TFMPvalue algorithm for the given PSSM
// (the `pssm` reference must outlive `tfmp`).
let mut tfmp = TfmPvalue::new(&pssm);

// Compute the exact p-value for a given score
let pvalue = tfmp.pvalue(19.3);
assert_eq!(pvalue, 1.4901161193847656e-08);

// Compute the exact score for a given p-value
let score = tfmp.score(pvalue);
assert_eq!(score, 19.3);

Note that in the example above, the computation is not bounded, so for certain particular matrices the algorithm may require a large amount of memory to converge. Use the TfmPvalue::approximate_pvalue and TfmPvalue::approximate_score methods to obtain an iterator over the algorithm iterations, allowing you to stop at any given time based on external criterion such as total memory usage.

💭 Feedback

⚠️ Issue Tracker

Found a bug ? Have an enhancement request ? Head over to the GitHub issue tracker if you need to report or ask something. If you are filing in on a bug, please include as much information as you can about the issue, and try to recreate the same bug in a simple, easily reproducible situation.

📋 Changelog

This project adheres to Semantic Versioning and provides a changelog in the Keep a Changelog format.

⚖️ License

This library is provided under the open-source GNU General Public License v3.0. The original TFMPvalue implementation was written by the BONSAI team of CRISTaL, Université de Lille and is available under the terms of the GNU General Public License v2.0.

This project is in no way not affiliated, sponsored, or otherwise endorsed by the original TFMPvalue authors. It was developed by Martin Larralde during his PhD project at the European Molecular Biology Laboratory in the Zeller team.

📚 References

  • [1] Touzet, Hélène and Jean-Stéphane Varré. ‘Efficient and accurate P-value computation for Position Weight Matrices’. Algorithms for Molecular Biology 2, 1–12 (2007). doi:10.1186/1748-7188-2-15.
  • [2] Beckstette, Michael, Robert Homann, and Robert Giegerich. ‘Fast index based algorithms and software for matching position specific scoring matrices’. BMC Bioinformatics 7, 389 (2006). doi:10.1186/1471-2105-7-389.
Commit count: 393

cargo fmt