Minimac4
|
Provides utilities for handling recombination rates and genetic maps. More...
#include <recombination.hpp>
Classes | |
struct | map_file_line |
Representation of a single line from a genetic map file. More... | |
Static Public Member Functions | |
static bool | parse_map_file (const std::string &map_file_path, std::vector< target_variant > &sites, float recom_min) |
Parse and align a genetic recombination map file to a set of target variants. | |
static double | haldane (double cm) |
Haldane’s mapping function. | |
static double | cm_to_switch_prob (double cm) |
Convert genetic distance to switch probability (default decay rate). | |
static double | cm_to_switch_prob (double cm, double decay_rate) |
Convert genetic distance to switch probability with a custom decay rate. | |
static double | haldane_inverse (double recom_prob) |
Inverse Haldane’s mapping function. | |
static double | switch_prob_to_cm (double recom_prob) |
Convert switch probability to genetic distance. | |
Provides utilities for handling recombination rates and genetic maps.
The recombination
class is responsible for parsing genetic map files, interpolating recombination rates across target variant sites, and converting between genetic map units (centiMorgans) and switch probabilities used in haplotype inference.
struct map_file_line
: Represents a single line in the map file, including chromosome, base-pair position, and map value.parse_map_file()
: Aligns recombination map data with target variants and computes switch probabilities.read_entry()
: Reads a line from the map file (supports both old and new formats).haldane()
and haldane_inverse()
for recombination ↔ cM conversions.cm_to_switch_prob()
and switch_prob_to_cm()
for cM ↔ switch probability conversions.
|
inlinestatic |
Convert genetic distance to switch probability (default decay rate).
cm | Genetic distance in centiMorgans. |
\[ p = 1 - e^{-d/100} \]
|
inlinestatic |
Convert genetic distance to switch probability with a custom decay rate.
cm | Genetic distance in centiMorgans. |
decay_rate | Custom decay factor scaling the conversion. |
\[ p = 1 - e^{-\lambda d/100} \]
where \(\lambda\) is the decay rate.
|
inlinestatic |
Haldane’s mapping function.
Converts a genetic distance (in centiMorgans) into the probability of recombination between two loci.
cm | Genetic distance in centiMorgans. |
\[ r = \frac{1 - e^{-d/50}}{2} \]
where \(d\) is the distance in cM.
|
inlinestatic |
Inverse Haldane’s mapping function.
Converts a recombination probability back into genetic distance (in cM).
recom_prob | Recombination probability. |
\[ d = 50 \cdot \ln\left(\frac{1}{1 - 2r}\right) \]
where \(r\) is the recombination probability.
|
static |
Parse and align a genetic recombination map file to a set of target variants.
This function reads a genetic map file and assigns recombination rates (in cM) to each target variant in the provided vector. It aligns the genetic map to the given chromosome, interpolates recombination values between map positions, and converts the aligned genetic map into switch probabilities for HMM traversal.
The recombination probability at each site is computed based on the genetic distance between consecutive variants and is adjusted to ensure non-negative values, respecting the provided minimum recombination threshold.
map_file_path | Path to the genetic map file. Must contain either standard format or a header-prefixed "new" format (three tab-delimited columns). |
sites | Vector of target variants (with chromosome, position, and recombination fields). The recombination field (recom ) is updated in-place. |
recom_min | Minimum recombination probability to enforce for each site. |
sites
is sorted by position and belongs to a single chromosome.\[ \text{recom} = \max\left(\frac{1 - e^{-\Delta / 50}}{2}, \text{recom_min}\right) \]
where \(\Delta\) is the genetic distance between consecutive variants.
|
inlinestatic |
Convert switch probability to genetic distance.
recom_prob | Switch probability. |
\[ d = 100 \cdot \ln\left(\frac{1}{1 - p}\right) \]
where \(p\) is the switch probability.