#bioinformatics #genomics #command-line-tool #compbio

bin+lib recmap

A library for reading and working with recombination maps in Rust

5 unstable releases

0.3.5 Mar 14, 2024
0.2.3 Feb 9, 2024
0.2.2 Feb 9, 2024
0.1.1 Feb 8, 2024
0.1.0 Feb 8, 2024

#214 in Biology

Download history 2/week @ 2024-02-09 39/week @ 2024-02-23 90/week @ 2024-03-01 81/week @ 2024-03-08 29/week @ 2024-03-15 4/week @ 2024-03-22 6/week @ 2024-03-29

120 downloads per month

MIT license

52KB
890 lines

Crates.io Crates.io docs Rust CI DOI

RecMap library (and command line tool) for reading and working with recombination maps in Rust

A RecMap object can be created from reading in a HapMap-formatted recombination map. Note that since the HapMap recombination format does not include the chromosome lengths, this must be specified too. A convenience function read_seqlens is provided to read in TSV-formatted "genome" files of the chromosome names and lengths.

Here is a example which loads a recombination map from a HapMap-formatted recombination map and calculates the total map lengths.

use recmap::prelude::*;
let seqlens = read_seqlens("hg38_seqlens.tsv")
                  .expect("could not read seqlens");
let rec_map = RecMap::from_hapmap("decode_2019_map.txt", seqlens)
                  .expect("cannot read hapmap");

for (name, rate_map) in rec_map.iter() {
    println!("{}\t{}", name, rate_map.total_map_length().unwrap());
}

This example can be run on the command line with:

cargo run --example  calc_map_lengths --  --seqlens hg38_seqlens.tsv decode_2019_map.txt

One of the most common tasks when working with recombination maps is to estimate the map position of arbitrary markers, which is usually done by linear interpolation. RecMap provides an easy way to do this for one position (RecMap.interpolate_map_position()) and for many positions, with RecMap.interpolate_map_positions():

use recmap::prelude::*;
let seqlens = read_seqlens("hg38_seqlens.tsv")
                  .expect("could not read seqlens");
let rec_map = RecMap::from_hapmap("decode_2019_map.txt", seqlens)
                  .expect("cannot read hapmap");

let positions = vec![11975064, 15007450];
rec_map.interpolate_map_positions("chr1", &positions);

Command line tool

Additionally, recmap had an optional command line tool feature that interpolates recombination map positions and recombination rates, given BED3 input:

$ recmap interp --seqlens hg38_seqlens.tsv --hapmap decode_2019_map.txt \
   hg38_1Mb_windows.bed --output decode_2019_map_1Mb_summaries.tsv --header

Currently the command line tool only has one subcommand, though more features may be added. Please file an issue if there is a feature you'd like!

Installation

To use the library in your own Rust projects, install with:

$ cargo add recmap

To install the command line tool, use:

$ cargo install recmap --features=cli

Dependencies

~4–5MB
~84K SLoC