Simulation of coding sequence evolution
This protocol is extracted from research article:
Amino acid exchangeabilities vary across the tree of life
Sci Adv, Dec 4, 2019; DOI: 10.1126/sciadv.aax3124

All simulations followed the Markovian codon substitution model specified in Eq. 1 (43). To simulate a clade with a pair of taxa, a 61 × 61 transition matrix P(t) was first derived. For each pair of codons, the instantaneous substitution rate q was set as in Eq. 1, according to the REs, ω, π, and κ specified. The rate matrix Q was normalized to have a total rate of 1, and the transition matrix P(t) was equal to eQt (43). For each codon to be simulated, an ancestral codon was chosen randomly according to the equilibrium codon frequencies and then was subject to evolution under a Markov process xt = x0 · P(t), based on the specified genetic distance t and the transition matrix P(t). Two descendant codons were generated respectively for the pair of taxa, sampled from the “evolved” probability distribution xt. Parameters REs, ω, π, and κ used in the simulations of Fig. 1 were estimated from either the primate clade (parameter set A) or the fruitfly clade (set B). In Figs. 1 and 3, the sequence length was 5,000,000 codons, and the genetic distance between the sequences was 0.1 substitution per codon. The real sequence lengths and inferred genetic distances were used in simulations related to Figs. 2 (D and E) and 4B and figs. S2 and S4. All codons had the same evolutionary rate in simulation unless mentioned. When site-specific relative evolutionary rates were used (fig. S1), the relative rates were sampled from a gamma distribution with the shape parameter of 1. Parameters REs, ω, π, κ, genetic distance, and coding sequence length estimated for each of the 90 clades are listed in data file S1 and were used in the aforementioned simulations. Python scripts for deriving the transition matrix and for sequence simulation can be accessed from GitHub (

Note: The content above has been extracted from a research article, so it may not display correctly.

Please log in to submit your questions online.
Your question will be posted on the Bio-101 website. We will send your questions to the authors of this protocol and Bio-protocol community members who are experienced with this method. you will be informed using the email address associated with your Bio-protocol account.

We use cookies on this site to enhance your user experience. By using our website, you are agreeing to allow the storage of cookies on your computer.