int_get_joint_prob_mat module

itrails.int_get_joint_prob_mat.divide_starting_probs(ordered_pi_ABC, state_space_ABC)[source]

This function divides the starting probabilities of the three-sequence CTMC according to the path taken, i.e., it identifies the states where sequences have already coalesced at the left and/or the right sites, and it divides their starting probabilities based on this.

Parameters:
  • ordered_pi_ABC (list of floats) – The starting probabilities of the three-sequence CTMC

  • state_space_ABC (list of lists of tuples) – The ordered state space of the three-sequence CTMC

itrails.int_get_joint_prob_mat.get_joint_prob_mat_introgression(t_A, t_B, t_AB, t_C, t_m, rho_A, rho_B, rho_AB, rho_C, rho_ABC, coal_A, coal_B, coal_AB, coal_BC, coal_C, coal_ABC, m, n_int_AB, n_int_ABC, cut_AB, cut_ABC, tmp_path='./')[source]

This is a wrapper function that unifies all the CTMCs to get a matrix of joint probabilities for the HMM.

Parameters:
  • t_A (float) – Time for the one-sequence CTMC of the first sequence (A)

  • t_B (float) – Time for the one-sequence CTMC of the second sequence (B)

  • t_AB (float) – Time for the two-sequence CTMC (AB)

  • t_C (float) – Time for the one-sequence CTMC of the third sequence (C)

  • t_m (float) – Time from the migration event to the first speciation event

  • rho_A (float) – Recombination rate for the one-sequence CTMC of the first sequence (A)

  • rho_B (float) – Recombination rate for the one-sequence CTMC of the second sequence (B)

  • rho_AB (float) – Recombination rate for the two-sequence CTMC (AB)

  • rho_C (float) – Recombination rate for the one-sequence CTMC of the third sequence (C)

  • rho_ABC (float) – Recombination rate for the three-sequence CTMC (ABC)

  • coal_A (float) – Coalescent rate for the one-sequence CTMC of the first sequence (A)

  • coal_B (float) – Coalescent rate for the one-sequence CTMC of the second sequence (B)

  • coal_AB (float) – Coalescent rate for the two-sequence CTMC (AB)

  • coal_BC (float) – Coalescent rate for the two-sequence CTMC (BC)

  • coal_C (float) – Coalescent rate for the one-sequence CTMC of the third sequence (C)

  • coal_ABC (float) – Coalescent rate for the three-sequence CTMC (ABC)

  • m (float) – Probability that an individual migrates from B to C (backwards in time)

  • n_int_AB (integer) – Number of intervals of the two-sequence CTMC (AB)

  • n_int_ABC (integer) – Number of intervals of the three-sequence CTMC (ABC)

itrails.int_get_joint_prob_mat.load_trans_mat_miss()[source]

This function defines the state space and transition rate matrix for the right path when lineages are missing, i.e., when only the right or the left site of species B are mixed with the two sites of species C.

itrails.int_get_joint_prob_mat.split_migration(state_space, prob_vec, m, direction)[source]

This function splits the vector of final probabilities for species B given a certain migration rate m. Based on the direction of choice, the resulting probabilities will correspond to the left path (where lineages do not migrate and will later mix with species A), or the right path (where lineages migrate and are instantly mixed with species C).

Parameters:
  • state_space (list of lists of tuples) – The state space for a one-sequence CTMC

  • prob_vec (numpy array) – The end probabilities of the one-sequence CTMC at the time of migration

  • m (float) – Probability that a sequence migrates

  • direction (string) – Left or right path