ancIBD.transition
Class for calculating Transition Probabilities, i.e. infitesimal transition Matrices. Contains Sub-Classes, as well as factory Method. @ Author: Harald Ringbauer, 2021, All rights reserved
Module Contents
Classes
Class for transition probabilities. |
|
Implements the Model Transitions [units generally in Morgan] |
|
A transition model for detecting IBD between ancient and modern sample pairs. |
|
Implements the Model Transitions [units generally in Morgan] |
|
Implements the Model Transitions [units generally in Morgan] |
|
Implements the Model Transitions [units generally in Morgan] |
|
A transition model for detecting IBD. Same as FiveStateTransitions, except that the 3x3 speed-up is not implemented here. |
Functions
|
Load the Transition Model |
- class ancIBD.transition.Transitions
Bases:
object
Class for transition probabilities. Has methods to return them
- trans_mat = []
- r_map = []
- output = True
- abstract calc_transition_rate(n=0)
Calulate and return Transition Matrix
- give_transition_rate()
Give the transition_matrix
- set_params(**kwargs)
Set the Values.
- class ancIBD.transition.FiveStateTransitions
Bases:
Transitions
Implements the Model Transitions [units generally in Morgan]
- ibd_in = 0.0005
- ibd_out = 0.001
- ibd_jump = 0.05
- min_gap = 1e-10
- max_gap = 0.05
- calc_transition_rate(submat33=True, n=4)
Return Transition Rate Matrix [k,k] to exponate. n: Number of symetric IBD states. Usually four (2x2 copying possibilities) submat33: Whether to only fill in the first 3 states
- full_transition_matrix(r_vec, t=[], n=4, submat33=True)
Compute and return the full transition Matrix. Calculates the first 3 states (not more needed by symmetry) t full Transition Matrix [k,k]. NO LOG STATE. If not given caluclate r_vec Map Length of Jumps [l] in Morgan n: Number of symmetric, non-background states
- prep_3x3matrix(t, n)
Prepare and return the grouped 3x3 Matrix (grouped 3rd State: Everything in other IBD states) t: Origianl transition matrix (only first three entry important) n: Number of symmetric states
- exponentiate_r(rates, rec_v)
Calculates exponentiation of the rates matrix with rec_v rates: 2D Matrix of transitions rec_v: Array of length l
- rmap_to_gaps(r_map=[], cm=False)
Return the recombination map gaps [in Morgan] Input: Map Positions [l] (units see cm parameter below) Return: Rec. Distance Array [l] cm: Whether input is in centimorgan or morgan min_cap: Minimum Map Gap between Loci to cap max_cap: Maximum Mapg Gap between Loci to cap
- class ancIBD.transition.FiveStateAsymmetric
Bases:
FiveStateTransitions
A transition model for detecting IBD between ancient and modern sample pairs.
- ibd_in = 1
- ibd_out = 20
- ibd_jump = 400
- ibd_jump2 = 0.5
- calc_transition_rate()
Return Transition Rate Matrix [k,k] to exponate.
- full_transition_matrix(r_vec, t=[], n=4, submat33=True)
Compute and return the full transition Matrix. Calculates the first 3 states (not more needed by symmetry) t full Transition Matrix [k,k]. NO LOG STATE. If not given caluclate r_vec Map Length of Jumps [l] in Morgan n: Number of symmetric, non-background states, not used by this method, keeping it here to just keep function signature the same as that of the 5state HMM. submat33: also not used by this function, keeping it here just to keep consistency with the 5 state hmm Note: this is the only function called by outside code
- class ancIBD.transition.SevenStateTransitions
Bases:
FiveStateTransitions
Implements the Model Transitions [units generally in Morgan]
- ibd_in = 1
- ibd_out = 20
- ibd_jump = 500
- exponentiate_r(rates, rec_v)
Calculates exponentiation of the rates matrix with rec_v rates: 2D Matrix of transitions rec_v: Array of length l
- calc_transition_rate()
Return Transition Rate Matrix [k,k] to exponate. n: Number of symetric IBD states. Usually four (2x2 copying possibilities) submat33: Whether to only fill in the first 3 states
- full_transition_matrix(r_vec, t=[], n=4, submat33=True)
Compute and return the full transition Matrix. Calculates the first 3 states (not more needed by symmetry) t full Transition Matrix [k,k]. NO LOG STATE. If not given caluclate r_vec Map Length of Jumps [l] in Morgan n: Number of symmetric, non-background states, not used by this method, keeping it here to just keep function signature the same as that of the 5state HMM. submat33: also not used by this function, keeping it here just to keep consistency with the 5 state hmm Note: this is the only function called by outside code
- class ancIBD.transition.TwoStateTransitions
Bases:
FiveStateTransitions
Implements the Model Transitions [units generally in Morgan]
- ibd_in = 1
- ibd_out = 20
- calc_transition_rate()
Return Transition Rate Matrix [k,k] to exponate. n: Number of symetric IBD states. Usually four (2x2 copying possibilities) submat33: Whether to only fill in the first 3 states
- full_transition_matrix(r_vec, t=[], n=4, submat33=True)
The last two arguments n and submat33 are not used. They are retained just for compatibility with the one Harald wrote.
- class ancIBD.transition.ThreeStateTransitions
Bases:
FiveStateTransitions
Implements the Model Transitions [units generally in Morgan]
- ibd_in = 1
- ibd_out = 20
- ibd_jump = 400
- calc_transition_rate()
Return Transition Rate Matrix [k,k] to exponate. n: Number of symetric IBD states. Usually four (2x2 copying possibilities) submat33: Whether to only fill in the first 3 states
- full_transition_matrix(r_vec, t=[], n=4, submat33=True)
The last two arguments n and submat33 are not used. They are retained just for compatibility with the one Harald wrote.
- class ancIBD.transition.FiveStatGeneric
Bases:
FiveStateTransitions
A transition model for detecting IBD. Same as FiveStateTransitions, except that the 3x3 speed-up is not implemented here.
- ibd_in = 1
- ibd_out = 20
- ibd_jump = 400
- calc_transition_rate()
Return Transition Rate Matrix [k,k] to exponate.
- full_transition_matrix(r_vec, t=[], n=4, submat33=True)
Compute and return the full transition Matrix. Calculates the first 3 states (not more needed by symmetry) t full Transition Matrix [k,k]. NO LOG STATE. If not given caluclate r_vec Map Length of Jumps [l] in Morgan n: Number of symmetric, non-background states, not used by this method, keeping it here to just keep function signature the same as that of the 5state HMM. submat33: also not used by this function, keeping it here just to keep consistency with the 5 state hmm Note: this is the only function called by outside code
- ancIBD.transition.load_transition_model(t_model='standard')
Load the Transition Model