Minimac4
Loading...
Searching...
No Matches
recombination Class Reference

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.
 

Detailed Description

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.

Responsibilities

  • Parse and align genetic map files to variant sites.
  • Interpolate recombination map values for variants without direct entries.
  • Convert between genetic distances (cM) and recombination/switch probabilities using models such as Haldane’s map function.

Key Components

  • 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).
  • Utility functions:

Notes

  • The last recombination probability in the sequence is always set to zero to ensure proper backward traversal during haplotype inference.
  • Supports both the old PLINK-style map format and new three-column format.

Member Function Documentation

◆ cm_to_switch_prob() [1/2]

static double recombination::cm_to_switch_prob ( double cm)
inlinestatic

Convert genetic distance to switch probability (default decay rate).

Parameters
cmGenetic distance in centiMorgans.
Returns
Switch probability.

\[ p = 1 - e^{-d/100} \]

Here is the caller graph for this function:

◆ cm_to_switch_prob() [2/2]

static double recombination::cm_to_switch_prob ( double cm,
double decay_rate )
inlinestatic

Convert genetic distance to switch probability with a custom decay rate.

Parameters
cmGenetic distance in centiMorgans.
decay_rateCustom decay factor scaling the conversion.
Returns
Switch probability.

\[ p = 1 - e^{-\lambda d/100} \]

where \(\lambda\) is the decay rate.

◆ haldane()

static double recombination::haldane ( double cm)
inlinestatic

Haldane’s mapping function.

Converts a genetic distance (in centiMorgans) into the probability of recombination between two loci.

Parameters
cmGenetic distance in centiMorgans.
Returns
Recombination probability.

\[ r = \frac{1 - e^{-d/50}}{2} \]

where \(d\) is the distance in cM.

◆ haldane_inverse()

static double recombination::haldane_inverse ( double recom_prob)
inlinestatic

Inverse Haldane’s mapping function.

Converts a recombination probability back into genetic distance (in cM).

Parameters
recom_probRecombination probability.
Returns
Genetic distance (cM).

\[ d = 50 \cdot \ln\left(\frac{1}{1 - 2r}\right) \]

where \(r\) is the recombination probability.

◆ parse_map_file()

bool recombination::parse_map_file ( const std::string & map_file_path,
std::vector< target_variant > & sites,
float recom_min )
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.

Parameters
map_file_pathPath to the genetic map file. Must contain either standard format or a header-prefixed "new" format (three tab-delimited columns).
sitesVector of target variants (with chromosome, position, and recombination fields). The recombination field (recom) is updated in-place.
recom_minMinimum recombination probability to enforce for each site.
Returns
true if parsing and recombination assignment succeeded, false if the map file was malformed, empty, or chromosome mismatch occurred.
Note
  • Assumes sites is sorted by position and belongs to a single chromosome.
  • Sites before the first map entry and after the last entry are extrapolated linearly.
  • The last site’s recombination probability is always set to zero.
  • Uses an exponential model for recombination probability conversion:

    \[ \text{recom} = \max\left(\frac{1 - e^{-\Delta / 50}}{2}, \text{recom_min}\right) \]

    where \(\Delta\) is the genetic distance between consecutive variants.
Warning
Assertions are used to check for invalid map entries (duplicate positions, overflow). These should be handled gracefully in production code.

◆ switch_prob_to_cm()

static double recombination::switch_prob_to_cm ( double recom_prob)
inlinestatic

Convert switch probability to genetic distance.

Parameters
recom_probSwitch probability.
Returns
Genetic distance (cM).

\[ d = 100 \cdot \ln\left(\frac{1}{1 - p}\right) \]

where \(p\) is the switch probability.

Here is the caller graph for this function:

The documentation for this class was generated from the following files: