Yang & Rannala
[

1] described a method for estimating the posterior distribution of a phylogenetic tree conditional on an alignment of genetic data using a Markov chain Monte Carlo (MCMC) approach. The method involves proposing small, successive changes in the structure of the tree and evaluating the likelihood that the tree produced the observed data using a Felsenstein pruning algorithm
[

9]. Proposed changes are accepted or rejected according to the Metropolis-Hastings criterion, which is an increasing function of the ratio of the likelihood of the proposed vs. current state. While originally proposed as a method of tree estimation, minor modifications of the algorithm allow for inference of additional model parameters, such as properties of the nucleotide substitution model, lineage birth and death rates (in the case of phylogenetic estimation), or population size (in the case of coalescent models). The basic approach described has experienced relatively wide adoption, with software tools such as MrBayes
[

4], LAMARC
[

7], and BEAST
[

5], applying, extending, and optimizing the algorithm. ACG continues to build upon this fundamental algorithm and, in a manner similar to the tools mentioned above, estimates the probability of an evolutionary model conditional on observation of an alignment of homologous nucleotide sequences. In mathematical terms, ACG produces an estimate of

where D is the input alignment and M is an evolutionary model containing parameters that are estimated from the data. At minimum, the model includes a description of how nucleotide sequences change over time (for instance, the Felsenstein 1984 or Timura-Nei 1993 model), a structure describing the ancestral relationships among the samples, and a function describing population size. Each of these sub-models may in turn encapsulate one or more parameters that are estimated from the data. For instance, the Timura-Nei 1993 model of nucleotide substitution involves two parameters that affect the transition-to-transversion ratio in addition to a vector describing stationary state nucleotide frequencies. As in LAMARC, the ancestry of the samples is represented by an Ancestral Recombination Graph (ARG), which is estimated from the data simultaneously with other model parameters.

To estimate the probability of the model given the data, ACG constructs and executes a Markov chain whose stationary state is the desired distribution (eq. 1). Generation of new states involves proposing a new value for a selected parameter, calculating the likelihood of the newly proposed state as well as the Hastings ratio associated with the proposal, and accepting or rejecting the state based on the Metropolis-Hastings-Green criterion
[10, 11]. A typical run involves repeating this procedure for some tens of millions of steps. States are sampled periodically and properties of model parameters are recorded by a variety of data collection utilities. If the chain has reached stationarity, the sampled parameters may be assumed to be correlated draws from the posterior density Pr{Model | Data}.

While the above scheme is similar to that used in other genealogy samplers, several aspects of the implementation are worthy of note. Most importantly, ACG implements data structures and MCMC proposal kernels that allow ARGs to be sampled from the data, where the probability of a particular ARG being sampled is proportional to its full likelihood under the data and some model of nucleotide substitution. Currently, the Felsenstein '84 (F84) and Timura-Nei '93 (TN93) substitution models are supported. Seven different proposal kernels operate on ARGs, these include some previously described and two novel kernels. ARG proposal kernels are detailed in the Additional file
1: Appendix A: ARG proposal kernels.

ARGs are a complex and rich source of information regarding the history of populations, and ACG provides several novel features that aid in interpreting the collection of ARGs sampled by the Markov chain. First, ACG by default tracks many of the bulk properties of ARGs, such as the number of recombination breakpoints and height of the deepest accessible nodes. In addition, ACG records the locations of all recombination breakpoints as well as the TMRCA across the sequence. ACG also provides utilities to examine the consensus tree at individual sites. These consensus trees are familiar, non-recombining trees ancestral to a single site only. Such trees may be useful when the ancestry in a small region is of particular interest, or when several such regions are to be compared. Further, ACG provides a companion utility (the *argutils* tool) that is capable of examining a single ARG and collecting information from it, such as the positions and heights of all recombination breakpoints, a list of all of the marginal trees contained in the ARG, or a plot of the TMRCA across the length of the sequence subtended by the ARG.

Users may interact with ACG in several ways. ACG features a simple command-line interface suitable for batch processing, but also provides a rich graphical user interface (GUI). The GUI allows users to both construct an analysis by selecting parameters, proposal kernels, and model priors, as well as to observe selected parameters and likelihoods as they change in real time as the chain progresses. Observed parameters and likelihoods can be viewed in trace or histogram form, and allow for rapid assessment of MCMC characteristics and convergence. Input files may also be saved and reloaded from within the GUI, and saved input can be executed from the command line.

A primary design goal of ACG is efficient computational performance and several techniques are used to speed calculations. First, every MCMC state involves calculation of new likelihoods followed by acceptance of rejection of the proposed state. If the state is accepted, the entire proposed proposed state must be moved to the current state before the next step can be initiated. In contrast to some other algorithms, ACG does not perform a full copy of the data and instead uses a reference-swapping technique to move the information to the desired location. Because the state data may be quite large and must be updated with every MCMC step, reference swapping results in a significant performance increase compared to copying. A second optimization technique involves identification of all identical alignment columns and computation of the data likelihood only once for each unique column. While many implementations involve some degree of alignment column ‘aliasing’, ACG performs this aliasing at every node where sites coalesce, again substantially reducing the number of likelihood calculations performed. Finally, ACG tracks which ARG nodes are affected by various proposals, and recomputes likelihoods only for the nodes and sites ranges affected.