1,713
Views
2
CrossRef citations to date
0
Altmetric
Bayesian Computation

Zig-Zag Sampling for Discrete Structures and Nonreversible Phylogenetic MCMC

ORCID Icon
Pages 684-694 | Received 08 Apr 2020, Accepted 14 Dec 2021, Published online: 02 Mar 2022

Abstract

We construct a zig-zag process targeting a posterior distribution defined on a hybrid state space consisting of both discrete and continuous variables. The construction does not require any assumptions on the structure among discrete variables. We demonstrate our method on two examples in genetics based on the Kingman coalescent, showing that the zig-zag process can lead to efficiency gains of up to several orders of magnitude over classical Metropolis–Hastings algorithms, and that it is well suited to parallel computation. Our construction resembles existing techniques for Hamiltonian Monte Carlo on a hybrid state space, which suffers from implementationally and analytically complex boundary crossings when applied to the coalescent. We demonstrate that the continuous-time zig-zag process avoids these complications. Supplementary materials for this article are available online.

1 Introduction

The zig-zag process is a nonreversible, piecewise deterministic Markov process introduced by Bierkens and Roberts (Citation2017); Bierkens, Fearnhead, and Roberts (Citation2019b) for continuous-time MCMC. It has several advantages over reversible methods such as Metropolis–Hastings (Hastings Citation1970) and Gibbs sampling (Gelfand and Smith Citation1990): it avoids diffusive backtracking which slows their mixing, and is rejection-free so that no computation is wasted on rejected moves.

In brief, the generator of the zig-zag process (xt,vt)t0 targeting the probability density (with respect to the product of the Lebesgue and counting measures) π˜(x,v):=π(x)/2d on a state space X×{1,1}dRd×{1,1}d isLf(x,v)=i=1dviif(x,v)+i=1dλi(x,v)(f(x,Fiv)f(x,v)),where i is the derivative with respect to xi , and Fi flips the sign of vi . The flip rates(1) λi(x,v):=(viilog(π˜(x,v)))+(1) with (x)+:=max{x,0}, ensure that (xt,vt)t0 leaves π˜(x,v) invariant (Bierkens, Fearnhead, and Roberts Citation2019b, theorem 2.2). In words, the coordinates of xt move at constant velocities vt until a flip at coordinate i, when the corresponding velocity changes sign.

To date, the zig-zag processes have been applied to targets such as the Curie–Weiss model (Bierkens and Roberts Citation2017) and logistic regression (Bierkens, Fearnhead, and Roberts Citation2019b), whose state spaces have simple geometric structures with natural notions of direction and velocity. Discrete variables (other than the velocities) have been restricted to cases with simple partial orders, such as model selection (Chevalier, Fearnhead, and Sutton Citation2020; Gagnon and Doucet Citation2021). We construct a zig-zag process on a general hybrid state space with both continuous and discrete coordinates, without imposing any structure on discrete coordinates. This is done by introducing a separate space of continuous variables for each value of the discrete variable, introducing boundaries into the continuous spaces, and updating the discrete variable when boundaries are hit. The strategy takes advantage of the full generality of piecewise-deterministic Markov processes (Davis Citation1993, sec. 24), and is resembles similar work for Hamiltonian Monte Carlo (HMC) (Dinh et al. Citation2017; Nishimura, Dunson, and Lu Citation2020). Our method can also been seen of as a generalization of the zig-zag process on a restricted domain (Bierkens et al. Citation2018) to a union of many restricted sub-domains, with jumps between sub-domains at boundary hitting events. We illustrate our method with an application to the coalescent (Kingman Citation1982): a tree-valued target with continuous branch lengths, discrete tree topologies with no natural partial order, and no canonical geometric structure.

The coalescent examples illustrate the need for methods which are implementable on complex state spaces. They are also of interest because existing MCMC algorithms for coalescents tend to mix slowly. The key difficulty lies in designing Metropolis–Hastings proposal distributions which combine efficient exploration with a high acceptance rate (Mossel and Vigoda Citation2005; Höhna, Defoin-Platel, and Drummond Citation2008; Lakner et al. Citation2008). Workarounds consist of empirical searches for efficient proposals (Höhna and Drummond Citation2012; Aberer, Stamatakis, and Ronquist Citation2016) or Metropolis-coupled MCMC (Geyer Citation1992). The former does not scale to problems for which empirical optimization is infeasible. The latter helps mixing between modes, but does not overcome low acceptance rates or the backtracking behavior of reversible MCMC.

The zig-zag process has some similarities with HMC (Neal Citation2010), which augments the state space with momentum and uses Hamiltonian dynamics to propose large steps which are accepted with high probability, though they are not rejection-free. Like the zig-zag process, HMC requires gradient information and a suitable geometric embedding of the target. Dinh et al. (Citation2017) provided those for the coalescent using an orthant complex construction of phylogenetic tree space (Billera, Holmes, and Vogtmann Citation2001). Our examples differ from the method of Dinh et al. (Citation2017) in three ways. First, we replace the embedding of Billera, Holmes, and Vogtmann (Citation2001) with τ-space (Gavryushkin and Drummond Citation2016), which is better suited to ultrametric trees. Second, the zig-zag process is readily implementable on τ-space via Poisson thinning without a numerical integrator such as leap-prog (Dinh et al. Citation2017, algorithm 1). Finally, the zig-zag process has simple boundary behavior between orthants and does not require boundary smoothing (Dinh et al. Citation2017, sec. 3.3), chiefly because discontinuous gradients are easier to handle on continuous rather than discretized paths.

The rest of the paper is structured as follows. Section 2 defines the zig-zag algorithm with discrete and continuous variables, and proves that it has the desired invariant distribution. Section 3 recalls the coalescent and the τ-space embedding. In Sections 4 and 5 we recall the popular infinite and finite sites models of mutation, derive zig-zag processes for each, and demonstrate their performance via simulation studies. Section 6 concludes with a discussion. The algorithms and datasets used in the simulation studies are available at https://github.com/JereKoskela/tree-zig-zag.

2 Zig-zag on Hybrid Spaces

The definition of our zig-zag process follows (Davis Citation1993, sec. 24). Let F be a countable set. For each mF, let Ωmo be an open subset of Rd,Ωmo¯ be its closure, and Ωm*:=Ωmo¯Ωmo be its boundary. We assume that {Ωm*}mF are piecewise Lipschitz and denote by Ωm the restriction of Ωm* to noncorner points. Let Ωo:=mFΩmo={(m,x):mF,xΩmo} and Ω:=mFΩm. For a point (m,x)Ωm, let n(m,x) be the outward unit normal, and let Γ±(m,x):={v{1,1}d:±(v·n(m,x))>0} be the sets of velocities with which a zig-zag process can exit (+) or enter (–) Ωmo at x. Zig-zag dynamics imply vΓ+(m,x)vΓ(m,x). We also define Γ±(Ω):=(m,x)Ω({(m,x)}×Γ±(m,x)) and Ω*:=(Ωo×{1,1}d)Γ(Ω). Integrals over Ωo and Ω, or subsets thereof, are taken to incorporate discrete sums in the mF coordinate.

The zig-zag process (mt,xt,vt)t0 is defined on Ω*, with target π˜(m,x,v):=π(m,x)/2d on Ω*Γ+(Ω) for a given density π(m,x). At (m,x,v)Ω*, the process moves with velocity v and each coordinate vi flips at rate λ(m,x,v), defined as in (1) since m is fixed between boundary hitting events. When (m,x,v)Γ+(Ω), the process jumps according to a Markov kernel Q:Γ+(Ω)P(Γ(Ω)), where P(A) denotes the set of probability measures on (A,B(A)). We assume that Q and π˜ satisfy the skew-detailed balance condition(2) π˜(m,x,v)Q(m,x,v;j,dy,w)dx=π˜(j,y,w)Q(j,y,w;m,dx,v)dy(2) for any (m,x,v)Γ+(Ω) and (j,y,w)Γ(Ω), as well as(3) (j,y)ΩwΓ(j,y)(w·n(j,y))Q(m,x,v;j,dy,w)=v·n(m,x),(3) for any (x,v)Γ+(Ω), and exclude jumps to paths pointing into corners by assuming(4) (m,x)ΩvΓ+(m,x)(j,y)ΩwΓ(j,y)1(mFΩ*)Ω(j,y+TΓ+(Ω)(j,y,w)w)×Q(m,x,v;j,dy,w)dx=0,(4) where TΓ+(Ω)(j,y,w) is the time the line (j,y+tw)t0 hits Γ+(Ω). We will abuse notation and use π˜(m,x,v)dx as the target density and Lebesgue measure on Ωo, and as their restrictions to the surface Ω, on which π˜ is not a probability density.

By Davis (Citation1993, theorem 26.14), the zig-zag process with dynamics defined above is a piecewise-deterministic Markov process with extended generator(5) Lf(m,x,v)=i=1dviif(m,x,v)+i=1dλi(m,x,v)(f(m,x,Fiv)f(m,x,v)),(5) whose domain D(L) consists of measurable functions f(m,x,v) on Ω* satisfying:

  1. For each (m,x,v)Γ+(Ω), the limit limt0f(m,xtv,v)=:f(m,x,v) exists.

  2. For each (m,x,v)Ω*, the function tf(m,x+tv,v) is absolutely continuous on t[0,TΓ+(Ω)(m,x,v)).

  3. For (m,x,v)Γ+(Ω),(6) f(m,x,v)=(j,y)ΩwΓ(y)f(j,y,w)Q(m,x,v;j,dy,w).(6)

  4. The random variable k=1nf(mTk,xTk,vTk)f(mTk,xTk,vTk) is integrable for each nN, where {Tk}k1 are the successive jump times (both velocity flips and jumps due to hitting a boundary) of (mt,xt,vt)t0.

For a set A, let B(A) and C1(A) be the respective spaces of bounded and continuously differentiable functions on A. Let Cb1(A):=B(A)C1(A). For t > 0, we defineNt:=#{velocity flips and boundary jumps in (ms,xs,vs)s=0t}.

Theorem 1.

Suppose F is finite, π˜(m,·,v)C1(Ωmo) for each v{1,1}d and mF,π˜>0 on Ωo×{1,1}d, that Q(m,x,v;·) has compact support for each (m,x,v)Γ+(Ω), and for each t > 0 and (m,x,v)Ω*,(7) E[Nt|(m0,x0,v0)=(m,x,v)]<.(7)

Suppose the initial distribution of (m,x) has a density on Ω* and that (2)–(4) hold. Then the zig-zag process with generator (5) and domain D(L) as described above has stationary distribution π˜.

Proof.

Provided in the supplementary materials. □

Remark 1.

In addition to having the right invariant distribution, a practical algorithm needs to be ergodic. To discuss ergodicity of the zig-zag process (mt,xt,vt)t0 from Theorem 1, let {(mtj,xtj,vtj)t0}jF be zig-zag processes restricted to respective spaces Ωjo by boundary jump kernels Qj:xΩj[(j,x)×Γ+(j,x)]P(xΩj[(j,x)×Γ(j,x)]), each with target proportional to π˜(j,·,·). When F is finite, a sufficient condition for ergodicity of the global process (mt,xt,vt)t0 is that {(mtj,xtj,vtj)t0}jF are all ergodic, and that(8) xΩmvΓ+(m,x)yΩjwΓ(j,y)Q(m,x,v;j,dy,w)π˜(m,x,v)dx>0,(8) for ordered pairs (m,j)F2 which form a cycle spanning the support of π˜. Bierkens, Roberts, and Zitt (Citation2019) provide conditions for ergodicity of single-domain zig-zag processes.

We conclude this section with a pseudocode specification of our zig-zag algorithm.

Algorithm 1 Simulation the zig-zag process targeting π˜

Require: Initial condition (m,x0,v0), target π˜, jump kernel Q, terminal time tend

  1. Set t0,m0m,xx0,vv0

  2. while t<tend do

  3. Set τTΓ+(Ω)(m,x,v) and I0. ⊳ I=0 boundary hit.

  4. for i{1,2,,d1,d} do

  5. Sample UExp(1).

  6. Set ρ to be the solution of 0ρλi(m,x+sv,v)ds=U.

  7. if ρ<τ then

  8. Set τρ and Ii

  9. Set tt+τ,xx+τv

  10. if I > 0 then

  11. Set vIvI

  12. else

  13. Set (m,x,v)(j,y,w)Q(m,x,v;·,·,·)

3 The Coalescent and a Geometric Embedding

An ultrametric binary tree with n labeled leaves is a rooted binary tree in which each leaf is an equal graph distance away from the root. We follow Gavryushkin and Drummond (Citation2016) and encode such a tree with leaf labels {1,,n} as the pair (En,tn), where En is a ranked topology and tn(0,)n1. The continuous variables tn encode times between mergers. The time from the leaves to the first merger is t1, and subsequent ti variables are times between successive mergers. The ranked topology En is an (n1)-tuple of pairs of labels, where the ith pair specifies the two child nodes of the ith merger. Nonleaf nodes are labeled by the leaves they subtend. For example, the ranked topologyE4=(E4,1,E4,2,E4,3):=({1,2},{{1,2},3},{{1,2,3},4})encodes the four leaf caterpillar tree depicted in and with nodes labeled left to right. We order the two entries of En,i by their least element for definiteness.

The coalescent (Kingman Citation1982) is a seminal model for the genetic ancestry of samples from large populations. Under the coalescent, a tree (En,tn) has probability density(9) π(En,tn)dtn:=exp(i=1n1(n+1i2)ti)dtn,(9) which arises as the law of a tree constructed by starting a lineage from each leaf, and merging each pair of lineages at rate 1 until the most recent common ancestor (MRCA) is reached. The success of the coalescent is due to robustness: distributions of ancestries of a large class of individual-based models converge to the coalescent in the infinite population limit under suitable rescalings of time. For details, see, for example, Wakeley (Citation2009).

We define swap operators si for i{2,,n2}:En,i1En,i viasi(En):=(En,1,,En,n1) where En,k:={En,k for k<i1 or k>i,En,i for k=i1,En,i1 for k=i.

In words, si swaps the order of the (i1)th and ith mergers. We also define pivot operators pi and pi for i{2,,n1}:En,i1En,i as(10) pi(En):=(En,1,,En,n1) withEn,k:={En,k for k{i1,i},{En,i1,En,is} for k=i1,{En,i1,En,i1} for k=i,(10) where En,i (resp. En,i) is the entry of En,i with the higher (resp. lower) least element, and En,is is the sibling: the entry of En,i that is not En,i1. Pivot pi is defined by interchanging ↓ and ↑ in (10). The pivots are the two nearest neighbor interchanges between the ith merger and the merger involving its nearest child. illustrates all three operators.

Fig. 1 Operators p2,p2, and s2. The horizontal arrangement of leaves is arbitrary throughout this article; only vertical distance is meaningful.

Fig. 1 Operators p2↑, p2↓, and s2. The horizontal arrangement of leaves is arbitrary throughout this article; only vertical distance is meaningful.

Next we describe τ-space, which gives a geometric structure to the set of pairs (En,tn). For fixed En , the space of tn-vectors is the orthant [0,)n1. Each boundary point with ti = 0 corresponds to a degenerate tree in which one of three things happens:

  1. The two leaves of En,1 merge at time 0 if i = 1.

  2. There are two simultaneous mergers if En,i1En,i.

  3. There is a simultaneous merger of three lineages if En,i1En,i.

Type 1 boundaries are boundaries of the whole τ-space. Type 2 boundaries separate orthants corresponding to two ranked topologies separated by an si -step. Trajectories crossing the boundary move from one ranked topology to the other. Type 3 boundaries separate the three orthants which resolve the triple merger into two binary mergers, which differ by a pi or pi-step. A trajectory that crosses the boundary visits a tree with the triple merger. depicts the τ-space with three leaves, and a type 2 boundary in a general τ-space. An example with five leaves is depicted in (Gavryushkin and Drummond Citation2016, ), and the tn variables are illustrated in and in Sections 4 and 5.

Fig. 2 (Left) τ-space with n = 3 embedded into R3. Each square is a copy of [0,)2 associated with the given topology. The coordinates (t1,t2) are the respective time of the first merger, and the time between the first and second merger. The dot is the origin, and the line on which all three orthants intersect is a type 3 boundary consisting of trees in which all three leaves merge simultaneously at time t1. The dashed lines are boundaries at . (Right) A segment of τ-space depicting a type 2 boundary, in which each square represents [0,)n1. Only the two orthants adjacent to the boundary are shown.

Fig. 2 (Left) τ-space with n = 3 embedded into R3. Each square is a copy of [0,∞)2 associated with the given topology. The coordinates (t1,t2) are the respective time of the first merger, and the time between the first and second merger. The dot is the origin, and the line on which all three orthants intersect is a type 3 boundary consisting of trees in which all three leaves merge simultaneously at time t1. The dashed lines are boundaries at ∞. (Right) A segment of τ-space depicting a type 2 boundary, in which each square represents [0,∞)n−1. Only the two orthants adjacent to the boundary are shown.

Fig. 3 A realization of the infinite sites model with n = 4, two mutations, three types, and Dn=({0.7},{0.7},{},{0.2}). The holding times t3 are shown on the left.

Fig. 3 A realization of the infinite sites model with n = 4, two mutations, three types, and Dn=({0.7},{0.7},{},{0.2}). The holding times t3 are shown on the left.

We will use τ-space to construct zig-zag processes whose state spaces consist of tree topologies, branch lengths, and a scalar parameter introduced in the next section. The discrete variables F will be the ranked topologies, with the boundary crossings described above defining the boundary jump kernel Q. For more on τ-space, for example, existence and uniqueness of geodesics and Fréchet means, we refer to Gavryushkin and Drummond (Citation2016).

4 The Infinite Sites Model

The infinite sites model (Watterson Citation1975) connects the coalescent tree to DNA sequence data by associating the MRCA with the unit interval (0, 1). Mutations with independent, U(0,1)-distributed locations accrue along branches of the tree (with branch lengths as specified by tn) at rate θ/2. The type of a leaf consist of the mutations along branches separating it from the MRCA. We denote the resulting list of types of the leaves by Dn . A realization of a coalescent tree and associated Dn is shown in . The typical task is to sample from the conditional law (En,tn,θ)|Dn corresponding to observing Dn , but not the tree which gave rise to it.

To handle mutations, we define Fn as the rooted graphical tree with 2n1 nodes, the first n of which are leaves labeled 1,,n, while the remaining n1 are labeled as in En . Edges connect children to their parents, and edge lengths are determined by tn. For an edge γFn, we denote by cγ and pγ the respective labels of the child and parent nodes of γ, by mγ the number of mutations on γ, and by lγ:=tjγtj the edge length, where we write tiγ if ti contributes to the length of γ in which case we say γ spans ti .

Given a prior density π0(θ) for θ, the posterior distribution of (En,tn,θ)|Dn follows from (9), the fact that the number of mutations on branch γFn is Poisson(θlγ/2)-distributed given lγ, and that mutations on distinct branches are independent. In particular,(11) π(En,tn,θ|Dn){γFn(θlγ2)mγ}exp(i=1n1(n+1i)(n+θi)2ti)π0(θ)(11) provided En is consistent Dn , and π = 0 otherwise. This distribution can be sampled using a zig-zag algorithm by taking F to be the set of ranked topologies on n leaves which are consistent with Dn , as well as ΩEno:={(tn,θ)(0,)n} and ΩEn:={(tn,θ)[0,)n:ti=0 for one i{1,,n1} or θ=0} for each EnF. In the boundary classification of Section 3, θ = 0 is another type 1 boundary. For (tn,θ)Ω, we define k(tn,θ) as the index of the zero variable, taken to be n in the case of θ.

We augment the state space with n zig-zag velocities vn, of which (v1,,vn1) drive tn and vn drives θ. For γFn, we also define vγ:=j:tjγvj as the rate of change of lγ. The boundary kernel Q is defined separately on each boundary type:(12) Q(En,(tn,θ),vn;·,·,·):={​​​δ{En}(·)δ{(tn,θ)}(·)δ{Fk(tn,θ)(vn)}(·)for type 1,δ{sk(tn,θ)(En)}(·)δ{(tn,θ)}(·)δ{Fk(tn,θ)(vn)}(·)for type 2,(δ{pk(tn,θ)(En)}(·)2+δ{pk(tn,θ)(En)}(·)2)δ{(tn,θ)}(·)δ{Fk(tn,θ)(vn)}(·)for type 3.(12)

At a type 1 boundary the process reflects back into ΩEno via a velocity flip. At a type 2 boundary it undergoes an si -step and a velocity flip to pass through the boundary. For type 3 boundaries it chooses an adjacent orthant uniformly at random.

In the interiors of orthants, velocity flip rates are(13) λi(En,tn,θ;vn):=[vi((n+1i)(n+θi)2γFn:tiγmγlγ)]+,(13) (14) λθ(En,tn,θ;vn):=[vn(i=1n1n+1i2ti1θγFnmγθlog(π0(θ)))]+.(14)

Simulating holding times with these rates is difficult due to the time intervals during which they vanish. One strategy is Poisson thinning via dominating rates consisting of only those terms in the round brackets in (13) and (14) whose sign matches that of the corresponding velocity vi , but these can result in loose bounds and inefficient algorithms. Instead, we define tn:=θ for brevity, and for i{1,,n1} define γ(En,i):=argmin{lγ:pγ=En,i} as the shorter child branch from parent node En,i. For i{1,n} we adopt the short-handsmγ(En,n):=γFnmγandmγ(En,1):=γFn:pγ=En,1mγ,and finally define the time localization TT(En,tn,θ;vn) as(15) T:=min{mini{1,,n}:vi<0{ti{1+c[ 1En,i(En,i1)+ 1{1,n}(i)] 1Z+(mγ(En,i))}vi},K},(15) where min=, and K0 is a maximum increment for the case when all velocities are positive. The indicator functions in the denominator pick out boundaries where (11) vanishes: type 1 or 3 boundaries corresponding to length 0 branches which carry at least one mutation, and the θ = 0 boundary if there is at least one mutation in total. The parameter c > 0 ensures that, when the current process time is t, such boundaries cannot be hit on [t,t+T], and at most one other boundary can be reached. We found c = 4 gave good performance across our tests in Sections 4 and 5. A larger value results in tighter bounds on (13) and (14), but wastes more computation as t + T is hit more often before an accepted velocity flip.

On time interval [t,t+T], flip rates (13) and (14) are bounded above by constant ratesλi*:=[vi((n+1i)(n+θ+(vnT)±i)2γFn:tiγmγlγ+(vγT)±})]+,λθ*:=[vθ(i=1n1n+1i2[ti+(viT)±]1θ+vnTγFnmγinfs[0,T]{θlog(π0(θ+vθs))})]+,where, for each λi*,i{1,,n1,θ},(x)±:=(x)+ if vi>0 and (x)±:=(x):=min{x,0} if vi<0. Algorithms S1 and S2 in the supplementary materials give pseudocode for simulating holding times, velocity flips, and boundary crossings as outlined above.

Proposition 1.

Suppose that the initial condition (En,tn,θ) has a positive density on F×(0,)n, that π0>0, and that θlog(π0(θ)) is bounded on compact subsets of (0,). Then (11) is stationary under the dynamics simulated by Algorithm S1 and S2, given in the supplementary materials.

Proof.

Provided in the supplementary materials. □

We compared the zig-zag process to a Metropolis–Hastings algorithm by reanalyzing the data of Ward et al. (Citation1991) with n = 55, 14 distinct types, and 18 mutations. We used the improper prior [t,t+T], set vi=±2/[(n+1i)(ni)], and set vn from trial runs to cross the θ-mode in unit time. in the supplementary materials details the Metropolis–Hastings algorithm, and other tuning parameters. We compared both methods to a hybrid combining zig-zag dynamics with continuous time Metropolis–Hastings moves at rate κ = 10. Performance was insensitive to κ provided it was not extreme: small values resemble a zig-zag process, while large values resemble Metropolis–Hastings.

Table 1 Effective sample sizes and run times for all three methods and datasets for the infinite sites model.

shows that the zig-zag and hybrid methods mix visibly better than Metropolis–Hastings over the latent tree, as measured by the tree height Hn:=t1++tn1. However, they are not as effective at exploring the upper tail of the θ-marginal, likely because they do not stay in regions of short trees for long enough for θ to increase into the tail.

Fig. 4 Trace plots under the infinite sites model and the dataset of Ward et al. (Citation1991).

Fig. 4 Trace plots under the infinite sites model and the dataset of Ward et al. (Citation1991).

To assess scaling, we simulated two datasets: one of size n = 550 with mutation rate θ=5.5 (the approximate posterior mean in ) and one with n = 55 and θ = 55, which models a segment of DNA 10 times longer. and demonstrate that the zig-zag and hybrid processes scale far better than Metropolis–Hastings, particularly when θ = 55. Estimates in quantify the improvement to 1–3 orders of magnitude.

Fig. 5 Trace plots for the infinite sites model and the dataset with n = 550, θ=5.5, 30 distinct types, and 38 mutations.

Fig. 5 Trace plots for the infinite sites model and the dataset with n = 550, θ=5.5, 30 distinct types, and 38 mutations.

Fig. 6 Trace plots for the infinite sites model and the dataset with n = 55, θ = 55, 40 distinct types, and 252 mutations.

Fig. 6 Trace plots for the infinite sites model and the dataset with n = 55, θ = 55, 40 distinct types, and 252 mutations.

5 The Finite Sites Model

The finite sites model (Jukes and Cantor Citation1969) is more detailed than the infinite sites model, but has greater computational cost. Consider a finite set of sites S with a finite number of possible types H per site; for example H={0,1} or H={A,T,C,G}. Mutations occur along branches of the coalescent tree at each site with rate θ/(2|S|), and the type of a mutant child is drawn from stochastic matrix P with unique stationary distribution ν. We denote the transition matrix of the H-valued compound Poisson process with jump rate θ/(2|S|) and jump transition matrix P by (Qhgθ(t))h,gH;t0. depicts a realization of the finite sites coalescent.

Fig. 7 A realization of the finite sites model with n = 4, S=H={0,1}, three mutations, three types, and Dn=(#00,#10,#01,#11)=(2,1,1,0).

Fig. 7 A realization of the finite sites model with n = 4, S=H={0,1}, three mutations, three types, and Dn=(#00,#10,#01,#11)=(2,1,1,0).

As in Section 4, we denote the configuration of types at the leaves by Dn , and seek to sample from the posterior π(En,tn,θ|Dn), which can be written as a sum over the types of internal nodes:(16) π(En,tn,θ|Dn){sSfor γFn:|cγ|>1h(s,cγ)HγFnQh(s;pγ)h(s;cγ)θ(lγ)}×exp(i=1n1(n+1i2)ti)π0(θ),(16) where h(s;η)H is the type at site sS on the node with label ηEn, and γFn:|cγ|>1 denotes edges which do not end in a leaf. The target (16) can be evaluated efficiently using the pruning algorithm of Felsenstein (Citation1981).

The posterior (16) can be sampled using zig-zag dynamics with the same construction as in Section 4. Velocity flip rates can be written in terms of branch-specific gradients as(17) λi(En,tn,θ;vn)=[vi((n+1i2)sS for γFn:|cγ|>1h(s,cγ)HδFn:tiδ[iQh(s;pδ)h(s;cδ)θ(lδ)]γFn:γδQh(s;pγ)h(s;cγ)θ(lγ) for γFn:|cγ|>1h(s,cγ)HγFnQh(s;pγ)h(s;cγ)θ(lγ))]+,(17) (18) λθ(En,tn,θ;vn)=[vn(θlog(π0(θ))+sS forγFn:|cγ|>1h(s,cγ)HδFn[θQh(s;pδ)h(s;cδ)θ(lδ)]γFn:γδQh(s;pγ)h(s;cγ)θ(lγ) forγFn:|cγ|>1h(s,cγ)HγFnQh(s;pγ)h(s;cγ)θ(lγ))]+,(18) which can be evaluated using the linear-cost method of Ji et al. (Citation2020).

We show that events with rates (17) and (18) can be simulated using the example of (Griffiths and Tavaré Citation1994, sec. 7.4), in which S={1,,20},H={0,1} and P is the 2 × 2 matrix which always changes state, corresponding to ν=(1/2,1/2) and(19) π˜(19)

As (19) is not bounded away from 0 when hg, (17) and (18) lack simple bounds for Poisson thinning. As in (15), bounds can be obtained by time localization usingTT(En,tn,θ;vn):=min{mini{1,,n}:vi<0{ti[1+c 1{1,θ}(i) 1Z+(mγ(En,i))]vi},K},where K0 is a default increment in case all velocities are positive. The variable T localizes the next zig-zag time step beginning at time t so that at most one branch can shrink to length zero on [t,t+T], θ can fall by at most 1/(1+c) of its present value, and t1 can fall by at most 1/(1+c) of its present value if the first two leaves to merge are of distinct types. This treatment of θ and t1 is needed as (17) and (18) diverge in these cases, rendering the θ = 0 and t1=0 boundaries inaccessible.

Given T(0,), we have the following bounds on (19) on the time interval [t,t+T]:Qhhθ(lγ)12{1+exp([θ+(vnT)][lγ+(vγT)])},Qhgθ(lγ)12{1exp([θ+(vnT)+][lγ+(vγT)+])},Qhhθ(lγ)12{1+exp([θ+(vnT)+][lγ+(vγT)+])},Qhgθ(lγ)12{1exp([θ+(vnT)][lγ+(vγT)])},where hg. Substituting these bounds into (Ji et al. Citation2020, Equationeq. (9)) provides bounds on flip rates that can be evaluated with O(|S|n) cost.

demonstrates that the zig-zag process again mixes over latent trees faster than Metropolis–Hastings, but struggles to explore the upper tail of the θ-marginal. The hybrid method was run with κ = 100 to compensate for shorter run lengths than in Section 4, and thus, resembles Metropolis–Hastings rather than the zig-zag process.

Fig. 8 Trace plots for the finite sites model and data from Griffiths and Tavaré (Citation1994).

Fig. 8 Trace plots for the finite sites model and data from Griffiths and Tavaré (Citation1994).

and show results for two further simulated datasets: one with n = 500 and S = 20, and one with n = 50 and S = 200. The superior mixing of the zig-zag process over the latent tree is clear, as quantified by effective sample sizes in . The lack of mixing in the upper tail of the θ-marginal is also stark, particularly in where zig-zag significantly underestimates posterior variance. The estimated posterior means of all three methods coincide in all cases (results not shown).

Fig. 9 Trace plots for the finite sites model and dataset with n = 500 and S = 20 consisting of five distinct sequences.

Fig. 9 Trace plots for the finite sites model and dataset with n = 500 and S = 20 consisting of five distinct sequences.

Fig. 10 Trace plots for the finite sites model and dataset with n = 50 and S = 200 consisting of 18 distinct sequences.

Fig. 10 Trace plots for the finite sites model and dataset with n = 50 and S = 200 consisting of 18 distinct sequences.

Table 2 Effective sample sizes and run times for all three methods and datasets.

6 Discussion

We have presented a general method for using zig-zag processes to sample targets defined on hybrid spaces consisting of discrete and continuous variables. This was done by introducing boundaries into the state space of continuous variables and updating discrete components via a Markov jump kernel Q whenever a boundary was hit. The resulting algorithm remains a piecewise-deterministic Markov processes in the sense of (Davis Citation1993, sec. 24), and generalizes existing zig-zag processes for restricted domains (Bierkens et al. Citation2018). Crucially, no assumptions of structure among the discrete variables are required. The key conditions on Q are the skew-detailed balance (2), which is local, and (3), which involves an integral with respect to Q but not the target π˜. Both are verifiable in applications, and do not require π˜ to be normalized. Our method is reminiscent of discrete Hamiltonian Monte Carlo (Dinh et al. Citation2017; Nishimura, Dunson, and Lu Citation2020), but the lack of time discretization simplifies boundary crossings (though see Nishimura, Dunson, and Lu Citation2020, sec. S6.4).

We have demonstrated the method on two examples involving the coalescent, which is a gold-standard model in phylogenetics. It is defined on the space of binary trees consisting of discrete tree topologies and continuous branch lengths, which lacks a simple geometric structure, for example, a partial order or a tractable norm. We have also shown that the zig-zag process can improve mixing over trees relative to Metropolis-Hastings, particularly under the infinite sites model. This model is widely used to analyze ever larger datasets, and the zig-zag process shows promise for expanding the scope of feasible MCMC computations.

The zig-zag process was more efficient than Metropolis–Hastings under the infinite sites model in terms of effective sample size, but struggled to explore the tails of the θ-marginal. A likely reason is correlation in the target: high mutation rates are only be attainable when branch lengths are short. A Metropolis–Hastings algorithm can jump to a high mutation rate as soon as the latent tree has short branches, while the zig-zag process must traverse all intervening mutation rates before branch lengths grow. The speed up zig-zag method of Vasdekis and Roberts (Citation2021) has state-dependent velocities, and could provide further improvement. The hybrid method with both zig-zag motion and Metropolis-Hastings updates interpolated between the two algorithms.

All three algorithms exhibited much longer run times under the finite sites model than under infinite sites. For the zig-zag and hybrid methods, that is due to the O(|S|n) cost per evaluation of (17) and (18), of which there are O(n). However, flip times for different velocities are conditionally independent given the current state and can be generated in parallel, unlike steps of the Metropolis–Hastings algorithm. Hence, the zig-zag process is well suited to parallel architectures.

Acknowledgments

The author is grateful to Jure Vogrinc and Andi Wang for productive conversations on MCMC for coalescent processes, and nonreversible MCMC in general.

Supplementary Materials

The supplementary materials contains the proofs of Theorem 1 and Proposition 1, as well as details of the zig-zag and Metropolis–Hastings algorithms used in Sections 4 and 5.

Additional information

Funding

The author was supported by ESPRC grant EP/R044732/1.

References

  • Aberer, A. J., Stamatakis, A., and Ronquist, F. (2016), “An Efficient Independence Sampler for Updating Branches in Bayesian Markov Chain Monte Carlo Sampling of Phylogenetic Trees,” Systematic Biology, 65, 161–176. DOI: 10.1093/sysbio/syv051.
  • Bierkens, J., Bouchard-Côte, A., Doucet, A., Duncan, A. B., Fearnhead, P., Lienart, T., Roberts, G., and Vollmer, S. J. (2018), “Piecewise Deterministic Markov Processes for Scalable Monte Carlo on Restricted Domains,” Statistics & Probability Letters, 136, 148–154.
  • Bierkens, J., Fearnhead, P., and Roberts, G. (2019a), “Supplement to ‘The Zig-zag Process and Super-Efficient Sampling for Bayesian Analysis of Big Data’,” Annals of Statistics, 47.
  • Bierkens, J., Fearnhead, P., and Roberts, G. (2019b), “The Zig-zag Process and Super-Efficient Sampling for Bayesian Analysis of Big Data,” Annals of Statistics, 47, 1288–1320.
  • Bierkens, J., and Roberts, G. (2017), “A Piecewise Deterministic Scaling Limit of Lifted Metropolis-Hastings for the Curie-Weiss Model,” Annals of Applied Probability, 27, 846–882.
  • Bierkens, J., Roberts, G., and Zitt, P.-A. (2019), “Ergodicity of the Zigzag Process,” Annals of Applied Probability, 29, 2266–2301.
  • Billera, L. J., Holmes, S. P., and Vogtmann, K. (2001), “Geometry of the Space of Phylogenetic Trees,” Advances in Applied Mathematics, 27, 733–767. DOI: 10.1006/aama.2001.0759.
  • Chevalier, A., Fearnhead, P., and Sutton, M. (2020), “Reversible Jump PDMP Samplers for Variable Selection,” preprint, arXiv:2010.11771.
  • Davis, M. (1993), Markov Models and Optimization, Boca Raton, FL: Chapman Hall.
  • Dinh, V., Bilge, A., Zhang, C., and Matsen, F. A., IV. (2017), “Probabilistic Path Hamiltonian Monte Carlo,” in Proceedings of the 34th International Conference on Machine Learning, Sydney, Australia.
  • Felsenstein, J. (1981), “Evolutionary Trees from DNA Sequences: A Maximum Likelihood Approach,” Journal of Molecular Evolution, 17, 368–376. DOI: 10.1007/BF01734359.
  • Flegal, J. M., Hughes, J., Vats, D., and Dai, N. (2017), mcmcse: Monte Carlo Standard Errors for MCMC.
  • Gagnon, P., and Doucet, A. (2021), “Nonreversible Jump Algorithms for Bayesian Nested Model Selection,” Journal of Computational and Graphical Statistics, 30, 312–323. DOI: 10.1080/10618600.2020.1826955.
  • Gavryushkin, A., and Drummond, A. J. (2016), “The Space of Ultrametric Phylogenetic Trees,” Journal of Theoretical Biology, 403, 197–208. DOI: 10.1016/j.jtbi.2016.05.001.
  • Gelfand, A. E., and Smith, A. F. M. (1990), “Sampling-Based Approaches to Calculating Marginal Densities,” Journal of the American Statistical Association, 85, 398–409. DOI: 10.1080/01621459.1990.10476213.
  • Geyer, C. J. (1992), “Practical Markov Chain Monte Carlo,” Statistical Science, 7, 473–483. DOI: 10.1214/ss/1177011137.
  • Griffiths, R. C., and Tavaré, S. (1994), “Simulating Probability Distributions in the Coalescent,” Theoretical Population Biology, 46, 131–159. DOI: 10.1006/tpbi.1994.1023.
  • Hastings, W. K. (1970), “Monte Carlo Sampling Methods Using Markov Chains and their Applications,” Biometrika, 57, 97–109. DOI: 10.1093/biomet/57.1.97.
  • Höhna, S., Defoin-Platel, M., and Drummond, A. J. (2008), “Clock-Constrained Tree Proposal Operators in Bayesian Phylogenetic Inference,” in 8th IEEE International Conference on BioInformatics and BioEngineering, pp. 1–7.
  • Höhna, S., and Drummond, A. J. (2012), “Guided Tree Topology Proposals for Bayesian Phylogenetic Inference, Systematic Biology, 61, 1–11. DOI: 10.1093/sysbio/syr074.
  • Ji, X., Zhang, Z., Holbrook, A., Nishimura, A., Baele, G., Rambaut,A., Lemey, P., and Suchard, M. A. (2020), “Gradients Do Grow on Trees: A Linear-time O(N)-Dimensional Gradient for Statistical Phylogenetics,” Molecular Biology and Evolution, 37, 3047–3060. DOI: 10.1093/molbev/msaa130.
  • Jukes, T. H., and Cantor, C. R. (1969), “Evolution of Protein Molecules,” in Mammalian protein metabolism, ed. H. N. Munro, pp. 21–132, New York: Academic Press.
  • Kingman, J. F. C. (1982), “The Coalescent,” Stochastic Processes and Their Applications, 13, 235–248. DOI: 10.1016/0304-4149(82)90011-4.
  • Lakner, C., Van Der Mark, P., Huelsenbeck, J. P., Larget, B., and Ronquist, F. (2008), “Efficiency of Markov Chain Monte Carlo Tree Proposals in Bayesian Phylogenetics,” Systematic Biology, 57, 86–103. DOI: 10.1080/10635150801886156.
  • Mossel, E., and Vigoda, E. (2005), “Phylogenetic MCMC Algorithms are Misleading on Mixtures of Trees,” Science, 309, 2207–2209. DOI: 10.1126/science.1115493.
  • Neal, R. M. (2010), “MCMC Using Hamiltonian Dynamics,” in Handbook of Markov Chain Monte Carlo, S. Brooks, A. Gelman, G. Jones, and X.-L. Meng, Boca Raton, FL: CRC Press.
  • Nishimura, A., Dunson, D. B., and Lu, J. (2020), “Discontinuous Hamiltonian Monte Carlo for Discrete Parameters and Discontinuous Likelihoods,” Biometrika, 107, 365–380. DOI: 10.1093/biomet/asz083.
  • Vasdekis, G., and Roberts, G. O. (2021), “Speed Up Zig-zag,” preprint, arXiv:2103.16620.
  • Wakeley, J. (2009), Coalescent Theory: An Introduction, Greenwood Village, CO: Roberts & Co.
  • Ward, R. H., Frazier, B. L., Dew, K., and Pääbo, S. (1991), “Extensive Mitochondrial Diversity Within a Single Amerindian Tribe,” Proceedings of the National Academy of Sciences of the United States of America, 88, 8720–8724. DOI: 10.1073/pnas.88.19.8720.
  • Watterson, G. A. (1975), “On the Number of Segregating Sites in Genetical Models Without Recombination,” Theoretical Population Biology, 7, 256–276. DOI: 10.1016/0040-5809(75)90020-9.