Generate a Kimura 2-Parameter (K2P) Transition Matrix

This function generates a 5x5 transition probability matrix based on the Kimura 2-Parameter (K2P) model. The matrix includes transition rates for nucleotides (A, C, G, T) and an additional state (N), where transitions and transversions are governed by the parameters alpha and beta.

generate_K2P_matrix(alpha, beta)

Arguments

alpha

Numeric value representing the transition rate (rate of A<->G and C<->T mutations)

beta

Numeric value representing the transversion rate (rate of all other mutations between A, C, G, T)

Value

A 5x5 matrix with row and column names (A, C, G, T, N) containing substitution probabilities. The matrix entries represent the probability of transitioning from the row nucleotide to the column nucleotide.

Details

The K2P model assumes:

  • Different rates for transitions (alpha) and transversions (beta)

  • Equal base frequencies

  • The 'N' state can only transition to itself

  • No transitions are allowed between any nucleotide and 'N'

Matrix entries are normalized by (2*beta + alpha) to ensure proper probability distribution.

Examples

# Generate K2P matrix with transition rate 0.3 and transversion rate 0.1
K2P <- generate_K2P_matrix(alpha = 0.3, beta = 0.1)
#> Warning: restarting interrupted promise evaluation
#> Warning: internal error -3 in R_decompress1
#> Error: lazy-load database '/Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/library/cancerSimCraft/R/cancerSimCraft.rdb' is corrupt