Counting approximate breakpoint medians of random genomes
Poly H. da Silva, Arash Jamshidpey, David Sankoff
Abstract
Unsigned linear unichromosomal genomes with genes labeled 1, ..., n are represented by permutations of these labels, whose adjacencies are the unordered pairs of genes occurring consecutively. The breakpoint distance counts the adjacencies of one genome that are absent from the other, and a breakpoint median minimizes the total breakpoint distance to a given set of genomes. Deciding whether a permutation is a median often requires a minimization over the whole symmetric group, which makes the median set resistant to exact counting. We replace this global condition by a local one: a c-approximate median is a genome having at most c adjacencies absent from all the input genomes. For a fixed genome we introduce its approximate median inverse, the set of ordered k-tuples of genomes admitting it as a c-approximate median, and we construct and count this set explicitly. For k genomes chosen uniformly and independently at random, this gives the probability that a given genome is a c-approximate median and the expected number of such approximate medians. The relaxation is not only technical: approximate medians and near-optimal genomes coincide up to a shift of the tolerance that remains bounded in probability as the number of genes grows. Finally, we derive an explicit upper bound on the probability that a given genome is an exact median, and on the expected number of exact breakpoint medians.
keyword: Random permutation, breakpoint median, median inverse.
1 Introduction
A simple but effective way to measure gene-order dissimilarity between two genomes is to count their breakpoints. A breakpoint of a genome G with respect to another genome G′ is a pair of genes that are adjacent in G but not in G′. For genomes with the same gene content, the breakpoint distance is the number of such breakpoints. Given a distance d on a space of genomes, a median of genomes G1,…,Gk is a genome minimizing the total distance function ∑i=1kd(⋅,Gi). The breakpoint median problem, introduced in [14], is the case in which d is the breakpoint distance.
Medians are often employed to reconstruct gene-order evolutionary histories in the small phylogeny problem, in which ancestral genomes at the internal vertices of a given phylogenetic tree are inferred from genomes observed at its leaves. Under suitable evolutionary conditions, approximate medians, genomes whose total distance to the input genomes is close to the minimum, can provide useful estimates of ancestral gene orders (see [9, 7, 10] for mathematical studies), while also capturing genetic similarities shared among the input genomes. Their reliability for ancestral inference, however, depends on the degree of evolutionary divergence, since the ancestral genome may cease to be an approximate median beyond an initial low-divergence regime [9, 10, 13]. Despite their importance, finding and constructing medians can be challenging [3, 12]. In fact, the median problem is NP-hard for several genomic distances, including the breakpoint distance on unsigned unichromosomal genomes [1, 2, 15, 5]. Moreover, the breakpoint median need not be unique. Simulation studies indicate that distinct median solutions may be widely separated and may tend toward the input genomes as evolutionary divergence among the input genomes increases [6]. Recent algorithmic work [4] further illustrates this multiplicity and diversity through numerical examples in which approximate and exact breakpoint medians of triples of random genomes are enumerated and their distance profiles relative to the input genomes are examined. These observations motivate studying the size and structure of the exact and approximate breakpoint median sets, both as a combinatorial object and in ancestral genome inference.
Motivated by these questions, we formulate the problem in a combinatorial and probabilistic setting. Labeling the genes by [n]:={1,…,n}, we represent a linear unichromosomal genome of size n by a permutation of [n]. We denote by Sn the set of all permutations of [n], or equivalently, the set of all such genomes with gene content [n]. Let ξ1(n),…,ξk(n) be chosen uniformly and independently at random from Sn, and let M denote the set of their breakpoint medians. For a given set A⊆Sn, one may ask for the probability P(A⊆M). For sets A containing more than one genome, this probability depends on their relative configuration, including their mutual breakpoint distances, and the problem becomes considerably more involved. In this paper, we take a first step toward this general problem by focusing on the singleton case A={x}, that is, on the probability that a given permutation x belongs to M. Even the singleton case leads to a substantial combinatorial counting problem. We introduce the median inverse and obtain upper bounds for P(x∈M), x∈Sn, through a tractable relaxation based on approximate medians, which we also show to be the near-optimal solutions of the median problem. By the left-invariance of the breakpoint distance and the uniform distribution of the input permutations, the singleton probability is the same for every x∈Sn. Consequently, E∣M∣=n!P(x∈M), so upper bounds for the singleton probability also yield upper bounds for the expected number of breakpoint medians.
For a fixed k, the median inverse of a permutation π∈Sn is the set of all ordered k-tuples (y1,…,yk) of permutations in Sn for which π is an exact breakpoint median. An exact median may contain adjacencies that are absent from all the input genomes. We show, however, that the number of such adjacencies admits an explicit upper bound and that, for random input genomes, this bound stays bounded in probability, and is therefore negligible compared with the n−1 adjacencies of a genome. This motivates the notion of a c-approximate breakpoint median, defined as a genome having at most c adjacencies absent from all the inputs. For a suitably growing tolerance c=cn, the corresponding approximate median set contains every exact median with high probability and therefore provides an explicitly countable outer approximation of the exact median set. We also show that approximate medians are of interest in their own right: they are precisely the near-optimal solutions of the median problem, up to a shift of the tolerance that is bounded in probability for random genomes. Similarly, for a fixed permutation π, we define its c-approximate median inverse as the set of all ordered k-tuples of genomes for which π is a c-approximate median. We construct and count this set and use it to determine the probability that a given genome is a c-approximate median of k uniformly and independently chosen random genomes and to derive an explicit expression for the expected number of approximate medians. For exact medians we derive an explicit upper bound on the probability that a given genome is an exact median and on the expected number of exact breakpoint medians, which in particular shows that this probability tends to zero faster than any exponential in n, at an explicit rate. Our framework also provides a constructive procedure for generating approximate medians with prescribed breakpoint distances, together with a dynamic-programming procedure for exact evaluation of the counting formula, with complexity bound and numerical illustration.
The paper is organized as follows. Section 2 introduces the main definitions, including the median and segment sets, and Section 3 overviews the main results. Section 4 contains the principal theoretical and counting results. We first consider genomes with maximum or near-maximum pairwise breakpoint distances and count ordered k-tuples for which every adjacency of a given permutation occurs in at least one input genome. This special case motivates the general framework of Theorems 1–5. Theorem 1 bounds the number of adjacencies of an exact median, absent from all inputs, and Theorem 2 gives the asymptotic behavior of this bound for random genomes. Theorem 3 identifies approximate medians with the near-optimal solutions of the median problem. Theorems 4 and 5 give the probability that a fixed permutation is a c-approximate median of k independent uniform random genomes, and the expected number of such approximate medians, and Theorem 6 gives explicit upper bounds for the corresponding quantities for exact medians. Finally, Theorem 7 compares the sizes of the exact and approximate median sets for random genomes. Section 5 concludes the paper with a discussion of the results.
2 Definitions
We assume that there are no duplicated genes. Thus, unsigned linear unichromosomal genomes with n genes or markers labeled by 1,⋯,n are represented by permutations on [n]:={1,⋯,n}. Let Sn denote the group of all permutations on [n], endowed with function composition as the multiplication operation, and denote by id:=id(n) the identity permutation 1 2 3 ... n. For a permutation π:=π1…πn, any unordered pair {πi,πi+1}={πi+1,πi}, for i=1,…,n−1, is called a gene adjacency, or simply an adjacency, of π. The set of all adjacencies of π is denoted by Aπ. Also, Ax1,…,xk denotes the set of all common adjacencies of x1,…,xk∈Sn. The breakpoint distance (bp distance) between x,y∈Sn is defined by
d(x,y)=d(n)(x,y):=n−1−∣Ax,y∣=∣AxΔAy∣/2,
where Δ denotes the symmetric difference of sets. The bp distance is a left-invariant pseudometric on Sn, that is, for any x,y,z∈Sn, d(x,y)=d(zx,zy), where the product is the function composition (zx)(i)=z(x(i)). Indeed, Azx={{z(a),z(b)}:{a,b}∈Ax}, so left multiplication relabels the genes and preserves the number of common adjacencies.
Define the total breakpoint distance of x∈Sn to a set of permutations A⊆Sn by dT(x,A):=∑y∈Ad(x,y). A median of A⊆Sn is a permutation in Sn (not necessarily unique) whose total distance to A takes the minimum value, i.e. it is a permutation x∈Sn such that dT(x,A)=miny∈SndT(y,A). Furthermore, the median value of A, denoted by μn(A), is the minimum value of the total distance function to A. We denote by Mn(A) the set of all breakpoint medians of A⊆Sn. For k∈N, let Snk denote the set of ordered k-tuples of permutations in Sn, with repetitions allowed. For (x1,…,xk)∈Snk, its medians and median value are defined by Mn(x1,…,xk):=Mn({x1,…,xk}) and μn(x1,…,xk):=μn({x1,…,xk}). Note that Mn(A)=∅.
It is not hard to see that z∈Sn is a median of x,y∈Sn iff d(x,y)=d(x,z)+d(z,y). Such a z is called a geodesic point of x,y [8], and the set of all geodesic points is denoted by [x,y].
A segment of Sn is a set of consecutive (gene) adjacencies of a permutation (genome) in Sn. More precisely, a segment of length r∈[n−1] is a set of adjacencies {{n0,n1},{n1,n2},...,{nr−2,nr−1},{nr−1,nr}}, for r+1 distinct numbers (genes) n0,n1,...,nr∈[n]. In particular, the empty set ∅ is regarded as a segment of length 0. We denote by ∣s∣ the length of a segment s. We say two segments s and s′ are strongly disjoint if they share no genes (numbers). They are disjoint if they do not share any common adjacencies. Otherwise, we say they intersect each other.
A segment set I of a permutation π∈Sn is a subset of the gene adjacencies of π, i.e. I⊆Aπ. Alternatively, we say π contains I. Note that a segment set can be contained in more than one permutation. Denote by I(n) the set of all segment sets of Sn. By a segment of a segment set I we mean a maximal nonempty segment contained in I. Also we denote by ∥I∥ the number of segments of I. We emphasize that “| . |” is used for both cardinality of a set and absolute value of a real number. So for a segment set I with segments s1,⋯,s∥I∥, ∣I∣=∑i=1∥I∥∣si∣ counts the number of adjacencies of I. Two segment sets I and J (in particular two segments s and s′, respectively) are said
Iˉπ={u1,u2}={{10,1}{1,2},{7,8}}
Iˉπ~={v1}={{6,1},{1,10},{10,2}}
I={s1,s2}={{2,3},{3,9},{9,4},{4,7},{8,5},{5,6}}
Figure 1: The segment set I is contained in permutations π and π~. As Aπ=Aπ~, the corresponding complement segment sets of I are different, i.e., Iˉπ=Iˉπ~. The segments s1 and s2 are strongly disjoint, s1 and u1 are disjoint, and s1 and s intersect. The segments s and u1 are consistent with union {{10,1},{1,2},{2,3}}, while s and v1 are not consistent.
to be consistent, if their union is contained in Aπ, for some permutation π. We say segment sets I1,...,Im complete each other if there exists a permutation π such that ∪i=1mIi=Aπ. In particular, the complement of a segment set I with respect to π∈Sn is the unique segment set Iˉπ:=Aπ∖I; see Figure 1.
3 Brief description of results
For π∈Sn, we define its k-median inverse by
Mn,k−1(π):={(x1,…,xk)∈Snk:π∈Mn(x1,…,xk)}.
More generally, for a set A⊆Sn, one may define its k-median inverse as the set of all ordered k-tuples (x1,…,xk)∈Snk satisfying A⊆Mn(x1,…,xk). The present paper considers only the singleton case ∣A∣=1. If ξ1(n),…,ξk(n) are chosen uniformly and independently at random from Sn, then
P(π∈Mn(ξ1(n),…,ξk(n)))=(n!)k∣Mn,k−1(π)∣.
By the left-invariance of the breakpoint distance, this probability is the same for every π∈Sn and therefore determines the expected number of exact breakpoint medians.
Our first main result controls the adjacencies of an exact median that are absent from all the input permutations. For X={x1,…,xk}⊆Sn, Theorem 1 gives an explicit upper bound On(X) for maxπ∈Mn(X)∣Aπ∖∪i=1kAxi∣. For independent uniform random permutations ξ1(n),…,ξk(n), Theorem 2 shows that, for every diverging sequence (an)n∈N, On({ξ1(n),…,ξk(n)})/an→0 in probability as n→∞. In intuitive terms, this means that, for large random genomes, an exact median is unlikely to contain more than a small number of adjacencies that are absent from all the input genomes. In particular, by choosing a diverging sequence (an)n∈N satisfying an=o(n), we see that this number is negligible compared with the total number n−1 of adjacencies in the median. This motivates the following relaxation. For c≥0, define the c-approximate median set of X⊆Sn by
Ln,c(X):={π∈Sn:∣Aπ∖∪x∈XAx∣≤c},(1)
and, for π∈Sn, define its c-approximate median inverse by
When X={x1,…,xk}, we also write Ln,c(x1,…,xk):=Ln,c(X).
By Theorem 1, on the event {On(ξ1(n),…,ξk(n))≤an} every exact median is an an-approximate median, and Theorem 2 shows that this event has probability tending to one whenever an→∞. Counting the approximate median inverse therefore controls the exact median set outside an event of vanishing probability; see (7).
Approximate medians are also of interest in their own right. Writing Mnc(X) for the set of permutations whose total distance to X exceeds the median value by at most c, Theorem 3 shows that Ln,c(X)⊆Mnc+Λn(X)(X) and, conversely, Mnc(X)⊆Ln,On(X)+c(X), where Λn(X) and On(X) measure the overlaps among the adjacency sets of the input genomes. Thus approximate medians and near-optimal permutations coincide up to a shift of the tolerance, and by Corollary 1 this shift is bounded in probability for random genomes. Taking c=0 in the second inclusion gives Mn(X)⊆Ln,On(X)(X) for every set of input genomes.
For fixed c≥0, the approximate quantities can be computed exactly. Theorem 4 gives
ELn,c(ξ1(n),…,ξk(n))=(n!)k−1∣Ln,k,c−1(π)∣,
and Theorem 5 provides the combinatorial ingredients needed to evaluate ∣Ln,k,c−1(π)∣. For exact medians, Theorem 6 gives an explicit upper bound for the probability that a given permutation is an exact median and for the expected number of exact medians, valid without any restriction to a favorable event, and shows in particular that this probability tends to zero, faster than any exponential in n. Finally, Theorem 7 compares the exact and approximate median sets of random genomes: ∣Mn∣/∣Ln,On+s∣=OP(n−s) for every fixed integer s≥1. Our framework also gives a constructive procedure for generating approximate medians with prescribed breakpoint distances, and a dynamic-programming procedure for exact evaluation of the counting formula, whose complexity we analyze and illustrate numerically.
4 Results
For n≥2 and a permutation x∈Sn, it is clear that Mn,1−1(x)={x,y}, where y=x is the unique permutation for which d(x,y)=0. For instance, Mn,1−1(id)={id,y}, where y=nn−1⋯2 1. Also, Mn,2−1(x)={(x1,x2)∈Sn2:x∈[x1,x2]}. It is well known that the expected number of common adjacencies of two random permutations is O(1); see Proposition 4. This means that, with high probability, the random permutations are at approximately maximum distance from each other. Hence, to study the median of k random permutations, we need to review some results for the median of k permutations with pairwise maximum distance n−1 from each other. In particular, recall that a permutation π is a median of k permutations with pairwise maximum distance n−1 from each other, if and only if every adjacency of π is an adjacency of at least one of those k permutations. In other words we have the following proposition.
Proposition 1 ([8]). Let ∅=X⊆Sn such that d(x,y)=n−1 for any distinct x,y∈X. Then π is a median of X if and only if Aπ⊆∪x∈XAx.
This is not true in general when the distances of input genomes are not the maximum value n−1. For example, if n=9, x=275683941 and π=689341275, then every adjacency of π is either an adjacency of id=id(n) or an adjacency of x, but d(9)(id,x)=7<d(9)(id,π)+d(9)(π,x)=8. In fact, this happens because all common adjacencies of id and x must be adjacencies of π in order to have π∈id,x as stated in the next proposition.
Proposition 2 ([8]). Let x,y∈Sn. Then z∈[x,y] if and only if Ax,y⊆Az⊆Ax∪Ay.
Proposition 1 implies that, for any X⊆Sn whose elements have pairwise breakpoint distance n−1, Mn(X)=Ln,0(X). Let
Then, for every π∈Sn, Ln,k,0−1(π)∩Vn,k=Mn,k−1(π)∩Vn,k. Thus, for input permutations at pairwise maximum distance, the 0-approximate median inverse coincides with the exact median inverse. This provides a natural starting point for our counting framework. We first study Ln,k,0−1(π), whose decomposition introduces the main combinatorial objects used later for general values of c. The following proposition gives this decomposition according to the adjacencies that each input permutation shares with π.
Proposition 3. Let n,k∈N and π∈Sn. For a segment set I∈I(n) contained in π, define Hπ(n)(I):={x∈Sn:Aπ,x=I}, and let
Proof. Observe first that, for permutations x,y∈Sn and a segment set I, we have x∈Hy(n)(I) if and only if Ax,y=I, which is also equivalent to y∈Hx(n)(I). Moreover, if I and I′ are two distinct segment sets of π∈Sn, then Hπ(n)(I)∩Hπ(n)(I′)=∅. Indeed, if some x∈Sn belonged to this intersection, then Aπ,x=I and Aπ,x=I′, which would imply I=I′, a contradiction.
Now, note that the segment sets J1,…,Jk in the definition of Pk,0(n)(π) are not required to be disjoint and may therefore intersect one another. Let J=(J1,…,Jk) and J′=(J1′,…,Jk′) be two distinct elements of Pk,0(n)(π). Since J=J′, there exists r∈{1,…,k} such that Jr=Jr′. It follows that Hπ(n)(Jr)∩Hπ(n)(Jr′)=∅. Consequently,
Then, there exists (J1,...,Jk)∈Pk,0(n)(π) such that xi∈Hπ(n)(Ji) and Aπ,xi=Ji, for i=1,...,k. Hence
Aπ=i=1⋃kJi=i=1⋃kAπ,xi⊆i=1⋃kAxi.
Therefore, (x1,…,xk)∈Ln,k,0−1(π). The cardinality formula follows from the disjoint-union decomposition and the cardinality of a Cartesian product. □
Thus, determining the cardinalities of the sets Hπ(n)(J~i) plays an important role in counting the elements of Ln,k,0−1(π).
We now consider the case in which the input permutations are chosen uniformly and independently at random from Sn. As n becomes large, this setting resembles the case of permutations at pairwise maximum breakpoint distance, since two independent uniform random permutations typically share only a small number of adjacencies. The following result makes this observation precise. Parts (i) and (ii) give the exact mean and variance; classically, the number of common adjacencies of a uniform random permutation with id converges in distribution to a Poisson random variable with mean 2 [16, 11]; see also [17] for other genome models.
Proposition 4. Let ξ=ξ(n) be a permutation chosen uniformly at random from Sn, and let (an)n∈N be a sequence of real numbers tending to ∞. Then
Proof. It suffices to compute the mean and variance of ζ:=∣Aid,ξ∣. For an adjacency e={j,j+1}∈Aid, the permutations containing e are obtained by treating j,j+1 as a single block in either of its two orientations, so their number is 2(n−1)! and P(e∈Aξ)=2/n. Since ∣Aid∣=n−1,
Eζ=e∈Aid∑P(e∈Aξ)=2(n−1)/n,
which gives (i). For distinct e,e′∈Aid, the same argument applied to the blocks they form gives
since in the first case e∪e′ consists of three consecutive genes, forming one block with two orientations, and in the second case e and e′ form two blocks, each with two orientations. There are n−2 unordered pairs of the first kind and (2n−1)−(n−2)=(n−2)(n−3)/2 of the second, whence
and var(ζ)=E[ζ(ζ−1)]+Eζ−(Eζ)2 gives (ii). Finally, (iii) follows from (i) and Markov's inequality, since P(ζ≥εan)≤2(n−1)/(nεan)→0 as an→∞. □
As mentioned above, when the permutations in X⊆Sn are at pairwise maximum distance n−1, a permutation π is a median of X if and only if each of its adjacencies occurs in at least one permutation in X. This characterization does not hold for a general set X⊆Sn. In particular, a median need not take all of its adjacencies from ∪x∈XAx. It is therefore natural to ask whether one can find a uniform upper bound on ∣Aπ∖∪x∈XAx∣ over all medians π of X. The next theorem provides such a bound. We first introduce the notation needed for its statement.
For distinct x1,…,xk∈Sn, let X={x1,…,xk}⊆Sn, and define BXX=Bx1,…,xkX:=Ax1,…,xk. Let Bx1,…,xj−1,xj+1,…,xkX:=Ax1,…,xj−1,xj+1,…,xk∖Bx1,…,xkX, for each j∈{1,…,k}. More generally, for ∅=U={xi1,…,xir}⊆X, set
BUX=Bxi1,…,xirX:=AU∖U⊆V⊆X⋃BVX.
In other words, BUX includes all adjacencies that are common in every x∈U, but missing from every y∈X∖U. Accordingly, for an adjacency e, let νX(e):=∣{x∈X:e∈Ax}∣ denote its multiplicity, that is, the number of input permutations containing e. Thus νX(e)=∣U∣ for every e∈BUX, and νX(e)=0 if e∈/∪x∈XAx. For y∈Sn and 0≤r≤k, define
ηr(y):=∣{e∈Ay:νX(e)=r}∣.
Thus, for 1≤r≤k, ηr(y) is the number of adjacencies of y that occur in exactly r of the input permutations, while η0(y) is the number of adjacencies of y that occur in none of them. We also define
The quantity Λn(X) counts all adjacencies that occur in at least two input permutations, an adjacency occurring in exactly r inputs being counted with weight r−1. For j∈{1,…,k} and 2≤r≤k−1, let
βr(j)(X)=βr(j):=U⊆X∖{xj}∣U∣=r∑BUX.
Thus, βr(j)(X) is the number of adjacencies occurring in exactly r input permutations, none of which is xj. Also define
with the convention that an empty sum equals zero. In particular, On(j)(X)=0 when k≤2. Thus On(j)(X) collects the terms of Λn(X) coming from adjacencies not contained in xj, and in particular On(j)(X)≤Λn(X) for every j. For y1,…,yk∈Sn, we write On(y1,…,yk):=On({y1,…,yk}).
Theorem 1. Let X={x1,…,xk}⊆Sn, where x1,…,xk are distinct and k≥2. Then, for every m∈Mn(X) and every j∈{1,…,k},
Moreover, for any i,j∈{1,…,k}, On(j)(X)−On(i)(X)=dT(xj,X)−dT(xi,X).
Remark 1. It follows from Theorem 1 that ∣Am∖∪x∈XAx∣≤On(X) for every m∈Mn(X). Moreover, the identity On(j)(X)−On(i)(X)=dT(xj,X)−dT(xi,X) shows that if dT(xj,X)=min1≤i≤kdT(xi,X), then On(X)=On(j)(X). In particular, if the minimum total distance is attained by more than one input permutation, all such minimizers give the same value of On(X). When k=2, the sum defining On(j)(X) is empty, and hence On(X)=0; thus every median of {x1,x2} takes all of its adjacencies from Ax1∪Ax2, in agreement with Proposition 2. When k=3, \mathcal{O}_n^{(j)}(X) = \beta_2^{(j)} = |\mathcal{B}_X^X_{\{x_j\}}|, for j=1,2,3.
Proof of Theorem 1. The quantities η0(y),η1(y),…,ηk(y) partition the n−1 adjacencies of any permutation y∈Sn according to the number of input permutations in which they occur. Therefore,
r=0∑kηr(y)=n−1.(5)
Moreover, an adjacency counted by ηr(y) is shared by y with exactly r input permutations. Hence,
dT(y,X)=j=1∑kd(y,xj)=k(n−1)−r=1∑krηr(y).
Fix j∈{1,…,k}. Since m is a median of X, dT(m,X)≤dT(xj,X), and therefore
r=1∑krηr(m)≥r=1∑krηr(xj).
On the other hand, from (5), we have ∑r=0k(ηr(m)−ηr(xj))=0. Subtracting this equality from the preceding inequality gives
0≤r=0∑k(r−1)(ηr(m)−ηr(xj)).
Since every adjacency of xj occurs in at least one input permutation, namely xj itself, we have η0(xj)=0. Furthermore, the coefficient of the r=1 term is zero. Thus,
η0(m)≤r=2∑k(r−1)(ηr(m)−ηr(xj)).
It remains to bound ηr(m)−ηr(xj). Fix r∈{2,…,k−1}. An adjacency can contribute positively to this difference only if it belongs to m, occurs in exactly r input permutations, and does not occur in xj. All such adjacencies are counted by βr(j). By contrast, an adjacency occurring in xj either belongs to both m and xj, in which case it cancels in the difference, or belongs to xj but not to m, in which case it contributes negatively. Therefore,
ηr(m)−ηr(xj)≤βr(j),2≤r≤k−1.
When r=k, every adjacency occurring in exactly k input permutations necessarily occurs in xj. Hence, there is no positive contribution, and ηk(m)−ηk(xj)≤0. It follows that
η0(m)≤r=2∑k−1(r−1)βr(j)=On(j)(X).
To prove the relationship between On(j)(X) and dT(xj,X), recall from (4) and the definition of On(j)(X) that, for a fixed j, the terms of Λn(X) with xj∈/U add up to On(j)(X). The remaining terms are those for which xj∈U. Every adjacency in such a set BUX is shared by xj with exactly ∣U∣−1 other input permutations. Consequently, Λn(X)−On(j)(X)=∑q=j∣Axj,xq∣. Since dT(xj,X)=(k−1)(n−1)−∑q=j∣Axj,xq∣, we obtain
On(j)(X)=Λn(X)−(k−1)(n−1)+dT(xj,X).
Therefore, for any i,j∈{1,…,k}, On(j)(X)−On(i)(X)=dT(xj,X)−dT(xi,X).
The key feature of Theorem 1 is that adjacencies occurring in exactly one input permutation do not appear in the upper bound: On(j)(X) is a weighted count of the adjacencies shared by at least two input permutations but absent from xj, an adjacency occurring in exactly r inputs having weight r−1. These weights come from the distance comparison in the proof, which gives, for every y∈Sn,
dT(y,X)=(k−1)(n−1)+η0(y)−r=2∑k(r−1)ηr(y).(6)
Applying (6) to y and xj, with η0(xj)=0, shows that the first inequality in Theorem 1, with y in place of m, is equivalent to dT(y,X)≤dT(xj,X). Thus, the bounds of Theorem 1 hold for every y∈Sn satisfying dT(y,X)≤min1≤j≤kdT(xj,X). The second inequality removes the dependence on y.
The smallness of On(X) is not restricted to random inputs. For fixed k, On(X)=o(n) whenever, after removing an input permutation minimizing the total distance to X, only o(n) adjacencies are shared by two or more of the remaining input permutations. For independent uniformly distributed random permutations, these shared-adjacency counts are bounded in probability by Proposition 4; this is used in Theorem 2 below.
Remark 2. If the input permutations are at pairwise maximum breakpoint distance, then On(X)=0, and Theorem 1 shows, in agreement with Proposition 1, that every median takes all of its adjacencies from ∪x∈XAx. The same conclusion holds whenever On(X)=0, which can happen beyond the pairwise-maximum-distance setting. For example, let x1=id(6)=123456, x2=465132, x3=426513 and X={x1,x2,x3}. Then Ax1,x2={{2,3},{5,6}}, Ax1,x3={{5,6}}, Ax2,x3={{5,6},{1,5},{1,3}} and AX={{5,6}}. Moreover, dT(x1,X)=7, dT(x2,X)=5 and dT(x3,X)=6, so O6(X)=O6(2)(X)=∣Bx1,x3X∣=∣Ax1,x3∖AX∣=0.
Remark 3. The bound of Theorem 1 can be attained even when On(X)>0; such examples can be found using the algorithms in [4]. Let x1=123456, x2=124536, x3=145326, and X={x1,x2,x3}. The adjacencies of multiplicity at least two are {4,5}, with νX({4,5})=3, and {1,2}, {2,3}, {3,5}, each of multiplicity two and absent from x3, x2 and x1 respectively; hence O6(j)(X)=1 for every j, and O6(X)=1. Now let m=123546, so that Am={{1,2},{2,3},{3,5},{4,5},{4,6}}. Since {4,6} occurs in none of the input permutations, η0(m)=1=O6(X). By the identity established in the proof of Theorem 1, dT(y,X)=15−∑e∈AyνX(e) for every y∈S6, so dT(m,X)=6. A permutation y with dT(y,X)≤5 would have to contain all four adjacencies of multiplicity at least two together with one further adjacency of positive multiplicity. These four adjacencies form the path 1−2−3−5−4, and no adjacency of positive multiplicity joins the remaining gene 6 to either endpoint. Hence dT(y,X)≥6 for every y∈S6, so m∈M6(X) and the bound is attained.
Recall that Ln,c(X) denotes the set of c-approximate medians of X. Theorem 1 shows that every exact median is a c-approximate median whenever c≥On(X). Equivalently, Mn(X)⊆Ln,c(X), for c≥On(X). In particular, Mn(X)⊆Ln,On(X)(X). Thus, when On(X) is small, Ln,On(X)(X) provides a controlled relaxation of the exact median set: it contains every exact median while allowing only a limited number of adjacencies outside the union of the input adjacency sets. Unlike the exact median condition, which requires minimizing the total distance over all permutations in Sn, membership in Ln,c(X) is determined directly by the number of adjacencies of the candidate permutation that do not appear in any of the inputs; it can therefore be studied through the approximate median inverse introduced in (1) and (2).
Recall also that the left-invariance of the breakpoint distance implies ∣Ax,y∣=∣Aπx,πy∣, for π,x,y∈Sn. Therefore, for any π,x∈Sn and X={x1,…,xk}⊆Sn, dT(x,X)=dT(πx,πX), where πX:={πx1,…,πxk}. It follows that πMn(X)=Mn(πX). Consequently, for any x,y∈Sn, Mn,k−1(x)=Mn,k−1(y). Moreover, μn(X)=μn(πX). The same argument applies to the approximate median inverse: since Aπx∖∪iAπxi=π(Ax∖∪iAxi), we have Ln,k,c−1(πx)=πLn,k,c−1(x), and hence ∣Ln,k,c−1(x)∣=∣Ln,k,c−1(y)∣ for all x,y∈Sn. These probabilities may therefore be analyzed for an arbitrary fixed πn∈Sn, n∈N.
Let (an)n∈N be a sequence of nonnegative real numbers, where an is the approximation threshold, and let ξ1(n),…,ξk(n) be independent uniformly distributed random permutations in Sn. For any sequence (πn)n∈N with πn∈Sn, the uniform distribution of the random k-tuple gives
where all sets are those of ξ1(n),…,ξk(n). By the next theorem the event {On(ξ1(n),…,ξk(n))≤an} has probability tending to one whenever an→∞, so counting the approximate median inverse controls the exact median set outside an event of vanishing probability.
Theorem 2. Fix k≥2, and let (an)n∈N be a sequence of positive real numbers such that an→∞. Let ξ1(n),…,ξk(n) be independent uniformly distributed random permutations in Sn. Then, as n→∞,
Proof. When k=2, we have On(ξ1(n),ξ2(n))=0, and both conclusions follow immediately. We may therefore assume that k≥3. We first establish a deterministic bound. Let X={x1,…,xℓ}⊆Sn, ℓ≥3. From the definition, we have On(X)≤On(ℓ)(X). On the other hand,
Consequently, for every realization of ξ1(n),…,ξk(n),
On(ξ1(n),…,ξk(n))≤1≤i<j≤k∑Aξi(n),ξj(n).
This inequality remains valid when repetitions occur in the random sample, since the left-hand side is computed for the resulting ordinary set by definition, while repeated sampled permutations only add nonnegative terms to the sum on the right-hand side. For every ε>0,
By the left-invariance of the breakpoint distance and Proposition 4, for every fixed i<j, ∣Aξi(n),ξj(n)∣/an converges to zero in probability. Since the number of pairs is fixed, the preceding sum converges to zero. Therefore, (8) is proved. Finally, as n→∞, Theorem 1 implies
Remark 4. Although Theorem 2 holds for every sequence (an)n∈N such that an→∞, the meaningful regime for approximate medians is an=o(n). Indeed, every permutation in Sn has exactly n−1 adjacencies, so if an≥n−1, then every permutation is automatically an an-approximate median. By contrast, when an=o(n), the number of adjacencies of an approximate median that are absent from all input permutations is negligible relative to its total number of adjacencies. Thus, in applications of the theorem, we take an→∞ sufficiently slowly that an/n→0, as n→∞.
Theorem 2 shows that, with high probability, the exact median set is contained in the an-approximate median set for any diverging sequence (an). The next theorem, which is our main motivation for studying approximate medians, shows that approximate medians are near-optimal and, conversely, that near-optimal permutations are approximate medians. For c≥0 write
Mnc(X):={y∈Sn:dT(y,X)≤μn(X)+c}
for the set of c-near medians of X, so that Mn0(X)=Mn(X).
Theorem 3 (Approximate medians are near-optimal). Let X={x1,…,xk}⊆Sn, where x1,…,xk are distinct and k≥2. Then, for every c≥0
that is, approximate medians and near-optimal medians coincide up to a shift of the tolerance by Λn(X)+On(X)≤2Λn(X). This follows on applying (i) and then (ii) with c+Λn(X) in place of c, together with On(X)≤Λn(X).
Proof of Theorem 3. Since ηr(y)≤∑U⊆X,∣U∣=r∣BUX∣ for every 2≤r≤k, we have ∑r=2k(r−1)ηr(y)≤Λn(X), and therefore, by (6), for any y∈Sn,
Taking the minimum over y in the left inequality gives the lower bound in (iii). For the upper bound, the proof of Theorem 1 shows that On(j)(X)=Λn(X)−(k−1)(n−1)+dT(xj,X), whence
1≤j≤kmindT(xj,X)=(k−1)(n−1)−Λn(X)+On(X),(10)
and μn(X)≤minjdT(xj,X).
For (i), let y∈Ln,c(X), so that η0(y)≤c. The right inequality in (9) and the lower bound in (iii) give dT(y,X)≤(k−1)(n−1)+c≤μn(X)+Λn(X)+c.
For (ii), let y∈Mnc(X). By (6) and ∑r=2k(r−1)ηr(y)≤Λn(X),
and dT(y,X)≤μn(X)+c≤minjdT(xj,X)+c, so that (10) gives η0(y)≤On(X)+c.
Corollary 1. Fix k≥2, and let ξ1(n),…,ξk(n) be independent uniformly distributed random permutations in Sn. Then
EΛn({ξ1(n),…,ξk(n)})<k(k−1),
and for every integer b≥0, with probability at least 1−k(k−1)/(b+1),
Ln,c⊆Mnc+b⊆Ln,c+2bforallc≥0,
where all sets are those of {ξ1(n),…,ξk(n)}. In particular, for random genomes, approximate medians and near-optimal medians coincide up to a shift of the tolerance that is bounded in probability.
Proof. Let X′ be the set of distinct elements among ξ1(n),…,ξk(n). If ∣X′∣=1, then μn(X′)=0, Mnc(X′)=Ln,c(X′) for every c≥0 and Λn(X′)=0, so the inclusions hold trivially. If ∣X′∣≥2, then on the event {Λn(X′)≤b}, Theorem 3(i) and (ii), together with On(X′)≤Λn(X′), give
An adjacency occurring in exactly r elements of X′ contributes r−1 to Λn(X′) and (2r)≥r−1 to the sum of ∣Ax,x′∣ over unordered pairs of distinct x,x′∈X′. The latter sum is at most ∑1≤i<j≤k∣Aξi(n),ξj(n)∣. By left-invariance and Proposition 4(i), E∣Aξi(n),ξj(n)∣=2(n−1)/n for i=j, and therefore
EΛn(X′)≤(2k)n2(n−1)<k(k−1).
Since Λn(X′) is integer-valued, Markov's inequality gives P(Λn(X′)>b)=P(Λn(X′)≥b+1)<k(k−1)/(b+1).
When the input permutations have pairwise maximum breakpoint distance, Proposition 1 gives Mn(X)=Ln,0(X). In general, the two families appearing in Theorem 3 play complementary roles. The fixed-tolerance sets Ln,c(X), c≥0, are monotone in c and, by Theorem 3 and Corollary 1, describe the near-optimal solutions at every level, up to a shift of the tolerance that is bounded in probability for random inputs. For any diverging tolerance an, Theorem 2 ensures that Ln,an contains every exact median with probability tending to one.
By left-invariance, E∣Mn(ξ1(n),…,ξk(n))∣=n!P(π∈Mn(ξ1(n),…,ξk(n))) for every fixed π∈Sn, so bounds on this probability translate directly into bounds on the expected number of exact medians.
For k=1 and n≥2, we have P(x∈Mn(ξ1(n)))=2/n!, for any x∈Sn. For k=2, since Mn(y1,y2)=[y1,y2], we obtain
The lower bound counts only the 4n!−4 ordered pairs for which one of y1 and y2 is equal to x or its reversal, and therefore does not include pairs for which x is a non-endpoint element of [y1,y2]. An explicit upper bound valid for every k, together with the convergence to zero of these probabilities, is given in Theorem 6.
For general k, the exact median inverse is considerably more difficult both to count and to construct: deciding whether a given permutation is an exact median of given inputs requires solving a global minimization problem over Sn, and finding medians is NP-hard [1, 14]. Moreover, numerical experiments in [4] show that, over the range considered, the average number of medians of three independent random genomes increases substantially with n. In contrast, whether a permutation is a c-approximate median can be decided directly from its adjacencies and those of the input genomes, and by Theorem 3, approximate medians are the near-optimal solutions up to a bounded shift of the tolerance. Their inverse can be constructed explicitly and admits an explicit counting formula, which we now derive. Exact medians are treated separately, by a factorial-moment argument, in Theorem 6.
For every c≥0 and π∈Sn, the definition of the approximate median inverse gives P(π∈Ln,c(ξ1(n),…,ξk(n)))=Ln,k,c−1(π)/(n!)k. Consequently, by left-invariance,
E∣Ln,c(ξ1(n),…,ξk(n))∣=Ln,k,c−1(π)/(n!)k−1.
The next theorem computes the expected number of c-approximate medians for each fixed c≥0. To state the result, let
For c = 0, this agrees with the definition in Equation (3), so that Theorem 4 below extends Proposition 3 to arbitrary c.
Theorem 4. Let n,k be natural numbers, let c≥0 be a real number, and let π∈Sn. If ξ1(n),…,ξk(n) are independent uniformly distributed random permutations in Sn, then
We must now count the number of elements in Ln,k,c−1(π) in terms of Hπ(n)(Ji), for c>0. As in the proof of Proposition 3, which treats the case c=0, let J=(J1,...,Jk), J′=(J1′,...,Jk′)∈Pk,c(n)(π), such that J=J′, then
Now, if (x1,...,xk)∈Ln,k,c−1(π), then there exist at most c adjacencies of π that are not in ∪i=1kAxi. Therefore, there exists (J1,...,Jk)∈Pk,c(n)(π) such that, for any i=1,...,k, Aπ,xi=Ji implying that (x1,...,xk)∈Hπ(n)(J1)×...×Hπ(n)(Jk). On the other hand, if
then there exists (J1,...,Jk)∈Pk,c(n)(π) such that xi∈Hπ(n)(Ji), for i=1,...,k, and so Aπ,xi=Ji. Thus
Aπ∖i=1⋃kJi=Aπ∖i=1⋃kAπ,xi=Aπ∖i=1⋃kAxi.
Therefore, ∣Aπ∖∪i=1kAxi∣≤c, and thus, (x1,...,xk)∈Ln,k,c−1(π).
Remark 6. An element (J1,…,Jk)∈Pk,c(n)(π) can equivalently be represented by a family (J~A)A⊆[k] of pairwise disjoint subsets satisfying Aπ=⨆A⊆[k]J~A and ∣J~∅∣≤c, where
Thus, J~A consists precisely of those adjacencies of π that belong to Ji for every i∈A and to no Jj for j∈/A. In particular, for i∈[k], Ji=⨆i∈A⊆[k]J~A. Thus, to construct such a family, we first choose the adjacencies assigned to J~∅ and then assign every remaining adjacency independently to one of the 2k−1 nonempty subsets of [k]. Since every subset of Aπ is a segment set, this gives a bijection and hence
Pk,c(n)(π)=j=0∑⌊c⌋(jn−1)(2k−1)n−1−j.
In particular, for fixed k≥2 and c=o(n),
∣Pk,c(n)(π)∣=(2k−1)n+o(n).
The term corresponding to j = 0 gives the lower bound (2k−1)n−1, while
∣Pk,c(n)(π)∣≤(2k−1)n−1j=0∑⌊c⌋(jn−1),
and the sum on the right is exp(o(n)) whenever c=o(n). Thus, allowing a sublinear number of uncovered adjacencies does not change the exponential growth rate of Pk,c(n)(π).
By Theorem 4, computing ∣Ln,k,c−1(π)∣ reduces to computing ∣Hπ(n)(Ji)∣ for the segment sets appearing in the tuples (J1,…,Jk)∈Pk,c(n)(π). The disjoint-union representation above also describes how a given permutation becomes a c-approximate median. Indeed, for (J1,…,Jk)∈Pk,c(n)(π) and any xi∈Hπ(n)(Ji), i∈[k], we have Aπ,xi=Ji, d(π,xi)=n−1−∣Ji∣, and
∣Aπ∖i=1⋃kAxi∣=∣Aπ∖i=1⋃kJi∣≤c.
Consequently, π∈Ln,c(x1,…,xk). This observation also gives the following constructive procedure for generating a tuple having a given permutation π as a c-approximate median with prescribed breakpoint distances, whenever segment sets satisfying the conditions below exist:
Fix or sample a permutation π∈Sn, and fix integers d1,…,dk∈{0,…,n−1} satisfying d1+⋯+dk−(k−1)(n−1)≤c.
Choose, possibly at random, a family (J~A)A⊆[k] of pairwise disjoint subsets such that Aπ=⨆A⊆[k]J~A, ∣J~∅∣≤c, and, for Ji:=∪A⊆[k]J~A, ∣Ji∣=n−1−di and Hπ(n)(Ji)=∅, i∈[k].
For each i∈[k], choose xi∈Hπ(n)(Ji). Concretely, assign orientations to the segments of Ji and arrange the oriented segments together with the elements of [n] not contained in them, subject to the condition that no additional adjacency of π is introduced.
The resulting tuple (x1,…,xk) satisfies d(π,xi)=n−1−∣Ji∣=di, i∈[k], and ∣Aπ∖∪i=1kAxi∣=∣J~∅∣≤c. Therefore, π∈Ln,c(x1,…,xk). The procedure above is constructive, with its cost depending on finding a feasible family (J~A)A⊆[k] and constructing elements of the corresponding Hπ(n)(Ji). By Theorem 3(i), the total distance of π to {x1,…,xk} exceeds the median value by at most c+Λn({x1,…,xk}). The procedure thus generates sets of genomes for which a near-optimal median with prescribed distances to the input genomes is known in advance; such instances can be used, for example, to test exact and heuristic median algorithms.
To apply Theorem 4, it remains to determine ∣Hπ(n)(I)∣ for a segment set I⊆Aπ. For a segment set J, define Rn(J)={x∈Sn:J⊆Ax}. Since Hπ(n)(I) consists of the permutations that contain every adjacency of I and none of the adjacencies in Aπ∖I, the inclusion-exclusion principle gives
Hπ(n)(I)=I⊆J⊆Aπ∑(−1)∣J∖I∣∣Rn(J)∣.(11)
To evaluate this sum, we classify the segment sets J, with I⊆J⊆Aπ, according to their types. Segment sets of the same type have the same number of adjacencies and the same number of segments, and hence give the same value of ∣Rn(J)∣.
Fix I⊆Aπ, let q=∥I∥, and write Aπ∖I=Iˉπ(1)⊔⋯⊔Iˉπ(q+1), where the complementary segments are ordered from left to right along π. The first and last complementary segments may be empty.
For I⊆J⊆Aπ, the global type of J with respect to π and I is λ=(λ1,…,λq+1), where λi=(λi(1),λi(2),λi(3),λi(4)) is the type associated with the complementary segment Iˉπ(i). Here, λi(1)=∣J∩Iˉπ(i)∣ is the number of adjacencies of J contained in Iˉπ(i), and λi(2)=∥J∩Iˉπ(i)∥ is the number of segments of J∩Iˉπ(i). Moreover, λ1(3)=0, and, for i=2,…,q+1, λi(3)=1, if the leftmost adjacency of Iˉπ(i) belongs to J, and λi(3)=0 otherwise. Similarly, λq+1(4)=0, and, for i=1,…,q, λi(4)=1, if the rightmost adjacency of Iˉπ(i) belongs to J, and λi(4)=0 otherwise.
Set ∥∅∥=0, and let λi=(0,0,0,0) when J∩Iˉπ(i)=∅. Put fi=1{i=1}+1{i=q+1}, the number of ends of Iˉπ(i) not adjacent to I. We use (−1−1)=1 and (vu)=0 unless 0≤v≤u or u=v=−1.
The global type determines both the number of adjacencies and the number of segments of J. More precisely,
Indeed, the segments of J are those of I and of the sets J∩Iˉπ(i), except that a segment of J∩Iˉπ(i) containing an end of Iˉπ(i) adjacent to I merges with the neighboring segment of I; each such merge, counted by λi(3) or λi(4), lowers the number of segments by one. Consequently, since ∣Rn(J)∣=2∥J∥(n−∣J∣)!, the value of ∣Rn(J)∣ depends only on the global type of J (see Lemma 1).
For example, let π=12345678 and I={{2,3},{3,4},{5,6}}. Then ∥I∥=2, and the three complementary segments are Iˉπ(1)={{1,2}},Iˉπ(2)={{4,5}}, and Iˉπ(3)={{6,7},{7,8}}. Consider J=I∪{{1,2},{4,5},{6,7}}. Then λ=((1,1,0,1),(1,1,1,1),(1,1,1,0)). For instance, the second component records that J∩Iˉπ(2) is one adjacency forming one segment, incident to the segments of I on both sides. In this case,
Therefore, ∣R8(J)∣=2∥J∥(8−∣J∣)!=4. Since ∣J∖I∣=3, this particular segment set contributes (−1)∣J∖I∣∣R8(J)∣=−4 to the inclusion-exclusion sum in (11). More generally, all segment sets having the same global type as J give the same value of ∣R8(J)∣; Theorem 5 groups the terms in (11) according to their global types.
Theorem 5. Let π be a permutation in Sn, and I∈I(n) be a segment set contained in π. Then
with λi(3),λi(4)∈{0,1}. In addition, λ1(3)=λ∥I∥+1(4)=0.
To prove Theorem 5, we need the following lemmas.
Lemma 1. Let I be a segment set of Sn. Then the number of permutations in Sn containing I is 2∥I∥(n−∣I∣)!.
Proof. As the segment set I has ∣I∣ adjacencies and ∥I∥ segments, each permutation containing I has n−∣I∣−∥I∥ points (genes) which are not used in I. Noting that segments have two directions, we then have 2∥I∥(∥I∥+(n−∣I∣−∥I∥))! permutations containing I.
Lemma 2. Let I,J∈I(n) and π∈Sn, such that I⊆J⊆Aπ. Let λ=(λi)1≤i≤∥I∥+1, with λi=(λi(1),λi(2),λi(3),λi(4)), for i=1,…,∥I∥+1 be the type of J with respect to π and I. Then
Proof. By the definition of the type, J has ∣I∣+∑iλi(1) adjacencies and ∥I∥+∑iλi(2)−∑i(λi(3)+λi(4)) segments, so the claim follows from Lemma 1.
Lemma 3. Let π∈Sn and I⊆Aπ. The number of segment sets J, with I⊆J⊆Aπ and with type λ=(λi)1≤i≤∥I∥+1 with respect to π and I, where λi=(λi(1),λi(2),λi(3),λi(4)) for i=1,…,∥I∥+1, is
Proof. For each i=1,…,∥I∥+1, we count the segment sets J~i=J∩Iˉπ(i) having local type λi. Empty intersections contribute one choice under our binomial convention, including when Iˉπ(i)=∅. We therefore consider nonempty J~i.
Let X1,…,Xλi(2) be the lengths of the selected segments in J~i, and let Y1,…,Yλi(2)+1 be the lengths of the unselected gaps before, between, and after these segments. They satisfy the two independent equations
where all Xj and all internal gaps Y2,…,Yλi(2) are positive.
At an end adjacent to I, the boundary gap is zero if the corresponding indicator λi(3) or λi(4) equals one, and positive otherwise. The initial gap when i=1 and the final gap when i=∥I∥+1 may each be zero or positive; these are precisely the fi free boundary gaps.
Thus, after omitting the gaps forced to be zero, there remain λi(2)+1−λi(3)−λi(4) gap variables, of which fi are nonnegative and the others positive. Adding one to each of the fi nonnegative variables makes all remaining variables positive and increases their total to ∣Iˉπ(i)∣−λi(1)+fi. This gives
choices for J~i. If no gap variables remain, the gap equation has one solution exactly when λi(1)=∣Iˉπ(i)∣, as covered by our binomial convention.
Finally, the local choices determine J=I∪⋃i=1∥I∥+1J~i uniquely. Multiplying the independent local counts over i=1,…,∥I∥+1 yields the result.
Proof of Theorem 5. The proof is a direct application of Lemmas 2 and 3, and (11), the inclusion-exclusion principle.
The global type representation in Theorem 5 already reduces the number of terms relative to direct inclusion–exclusion. A further reduction is possible because distinct global types may produce the same values of ∣J∖I∣ and ∥J∥. Using dynamic programming, we can group all such types and evaluate their combined contribution without enumerating every global type separately.
Let q=∥I∥, m=n−1−∣I∣, and, for each i∈[q+1], let Ti denote the set of admissible local types λi=(λi(1),λi(2),λi(3),λi(4)) in the complementary segment Iˉπ(i). Let wi(λi) denote the number of subsets of Iˉπ(i) having local type λi, as given by Lemma 3. In particular, (0,0,0,0)∈Ti and wi(0,0,0,0)=1. For a global type λ, define
Thus, apart from its multiplicity ∏i=1q+1wi(λi), the contribution of a global type depends on it only through the pair (a(λ),b(λ)). Global types producing the same pair can therefore be combined by dynamic programming.
For a partial choice of local types (λ1,…,λi), define
Note that aq+1=a(λ) and bq+1=b(λ). For any corresponding local choices J~j of types λj, the partial set J(i):=I∪⋃j=1iJ~j satisfies ∣J(i)∖I∣=ai and ∥J(i)∥=bi. In particular, 0≤ai≤m and 0≤bi≤n−1. For i=0,…,q+1, let Di(r,s) be the total multiplicity of the partial choices (λ1,…,λi)∈T1×⋯×Ti for which ai=r and bi=s. More precisely,
For i=0, the empty product is equal to one, hence D0(0,q)=1 and D0(r,s)=0 for (r,s)=(0,q). For i=1,…,q+1, the quantities Di(r,s) satisfy the recurrence
where values with inadmissible indices are interpreted as zero. Indeed, appending a local type λi increases the number of added adjacencies by λi(1) and changes the accumulated number of segments by λi(2)−λi(3)−λi(4). After all complementary segments have been processed,
Accordingly, after processing the first i complementary segments, the dynamic program combines all partial choices producing the same pair (r,s) into the single value Di(r,s), which records their accumulated multiplicity.
The computational costs of the preceding exact evaluations can be summarized as follows. Direct inclusion–exclusion enumerates 2m segment sets, where m=n−1−∣I∣. For the type-based formula, let Ni=∣Ti∣. Direct evaluation enumerates ∏i=1q+1Ni global types and requires O((q+1)∏i=1q+1Ni) arithmetic operations. If si=∣Iˉπ(i)∣, then Ni=O((si+1)2), and hence the cost is at most O((q+1)∏i=1q+1(si+1)2). Thus it is polynomial in n for fixed q=∥I∥, but not uniformly polynomial when q varies with n. The dynamic program avoids this product. Each Di has at most (m+1)n entries, and its update considers the Ni admissible local types. Hence the total cost is O((m+1)n∑i=1q+1Ni)=O((m+1)n∑i=1q+1(si+1)2) arithmetic operations, with O((m+1)n) memory when only two consecutive tables are retained. Since ∑i=1q+1si=m≤n−1, this gives the uniform bound O(n4) on the number of arithmetic operations.
For the computational comparison, we take π=12⋯n, ∣I∣=8, and ∥I∥=4, with each segment of I containing two adjacencies. For each n, we generate 50 random configurations of the m=n−1−∣I∣ complementary adjacencies among the five complementary segments, requiring the three internal segments to be nonempty. In the direct type-based evaluation, the number of global types is the number of summands evaluated in the reformulation of ∣Hπ(n)(I)∣ above. In the dynamic program (DP), a DP update is one application of the recurrence contributing a local type to a state Di(r,s). Thus, the DP replaces the enumeration of global types by these state updates, after which ∣Hπ(n)(I)∣ is obtained from the final table Dq+1. The reported numbers of global types, DP updates, and running times are averaged over these configurations. For each configuration, the type formula is timed in three runs and the dynamic program in three batches of 100 evaluations. Since direct inclusion-exclusion always has 2m terms, independently of the configuration, one reference timing is reported for each n.
Table 1: Comparison of three exact methods for computing ∣Hπ(n)(I)∣ on random segment-set configurations.
n
m
Incl-excl terms
Global types in Theorem 5
DP updates
Incl-excl time (s)
Theorem 5 time (s)
DP time (ms)
21
12
4,096
2,071
422
0.0017
0.00136
0.191
25
16
65,536
15,335
1,097
0.0266
0.00976
0.387
29
20
1,048,576
89,418
2,362
0.4347
0.05867
0.784
33
24
16,777,216
365,167
4,501
7.9661
0.24700
1.359
35
26
67,108,864
755,181
5,886
33.2816
0.52895
1.805
37
28
268,435,456
885,998
7,891
133.1820
0.63079
2.382
Table 1 illustrates the successive reductions obtained from the global-type representation and the dynamic program. Direct inclusion–exclusion exceeds 268 million terms for the largest instance. For n = 37, the Theorem 5 formula involves approximately 886,000 global types on average, while the dynamic program requires approximately 7,891 updates. The corresponding average running times are about 0.63 seconds and 2.4 milliseconds, respectively. Thus, the type representation already provides a substantial computational reduction over direct inclusion-exclusion, while the dynamic program gives a further and much larger improvement.
We finally consider the exact evaluation of the full approximate-median inverse. Although Theorem 4 expresses ∣Ln,k,c−1(π)∣ as a sum over Pk,c(n)(π), direct evaluation quickly becomes impractical. For example, ∣P3,1(10)(π)∣=92,236,816. The same sum can instead be evaluated by subset transforms without enumerating its terms.
For E⊆Aπ, let F(E)=∣{x∈Sn:E∩Ax=∅}∣. By inclusion-exclusion,
F(E)=T⊆E∑(−1)∣T∣2∥T∥(n−∣T∣)!.
Thus all values F(E) can be computed simultaneously by a subset zeta transform. Moreover, F(E)k counts the ordered k-tuples for which every adjacency in E is absent from all input permutations. Let G(M) count the ordered k-tuples whose set of missing adjacencies in Aπ is exactly M. Since F(E)k=∑E⊆M⊆AπG(M), superset Möbius inversion gives
G(M)=M⊆E⊆Aπ∑(−1)∣E∣−∣M∣F(E)k.
Consequently,
∣Ln,k,c−1(π)∣=M⊆Aπ∣M∣≤∣c∣∑G(M).
For fixed k, this requires O(n2n) arithmetic operations and O(2n) memory.
Table 2: Exact computation of the approximate-median inverse for k=3 and c=⌊n/10⌋.
n
c
∣Ln,3,c−1(π)∣
P(π∈Ln,c)
Time (s)
10
1
7.61×1017
1.59×10−2
0.0005
14
1
3.66×1028
5.52×10−5
0.0093
18
1
1.20×1040
4.56×10−8
0.184
22
2
5.61×1053
3.95×10−10
3.63
24
2
1.40×1060
5.87×10−12
15.40
26
2
4.65×1066
7.09×10−14
66.44
28
2
2.02×1073
7.11×10−16
309.64
By left-invariance, we may take π=id. Table 2 reports the computation for k=3 and c=⌊n/10⌋. For independent uniform random permutations ξ1(n),ξ2(n),ξ3(n), the probability column is P(π∈Ln,c(ξ1(n),ξ2(n),ξ3(n)))=∣Ln,3,c−1(π)∣/(n!)3. The probability that a fixed permutation is a c-approximate median decreases sharply over the range considered. In contrast, since E∣Ln,c∣=n!P(π∈Ln,c), the expected number of approximate medians increases from approximately 5.8×104 for n=10 to 2.17×1014 for n=28. The exact inverse count for n=28 is obtained in approximately 5.2 minutes. Computations reported above were performed using Python 3.11.4 on a computer with a 2.3 GHz quad-core Intel Core i7 processor and 32 GB of RAM.
The computations above give exact membership probabilities and expected cardinalities for Ln,c. We next give explicit unconditional upper bounds for these quantities for both Ln,c and Mnc. Since Mn0=Mn, this also bounds the corresponding quantities for Mn without the event restriction in (7). Theorem 7 then compares ∣Mn∣ with ∣Ln,On+s∣.
Theorem 6. For integers k≥2 and c≥0, let ξ1(n),…,ξk(n) be independent uniformly distributed random permutations in Sn, and let ζ1(n),…,ζk(n) be independent copies of ζ(n):=∣Aid,ξ(n)∣, where ξ(n) is uniformly distributed on Sn. Then, for every π∈Sn,
the second inequality holding for n≥2k+c+1. For n≥2k+c+1,
EMnc(ξ1(n),…,ξk(n))≤nc+1(2k)!(2k)n−1−c−2k,
and in particular, for fixed c, P(πn∈Mnc(ξ1(n),…,ξk(n)))→0 as n→∞, for every sequence (πn)n∈N with πn∈Sn. The same bounds hold with Mnc replaced by Ln,c.
Proof. Let X′ be the set of distinct elements among ξ1(n),…,ξk(n) and let k′=∣X′∣. If y∈Mnc(X′), then, for any x′∈X′,
so that ∑i=1k∣Ay,ξi(n)∣≥∑x∈X′∣Ay,x∣≥n−1−c. If y∈Ln,c(X′), then also ∑i=1k∣Ay,ξi(n)∣≥∣Ay∩∪iAξi(n)∣≥n−1−c. Hence both {π∈Mnc(ξ1(n),…,ξk(n))} and {π∈Ln,c(ξ1(n),…,ξk(n))} are contained in {∑i=1k∣Aπ,ξi(n)∣≥n−1−c}. By left-invariance, ∣Aπ,ξi(n)∣=∣Aid,π−1ξi(n)∣, and π−1ξ1(n),…,π−1ξk(n) are independent and uniformly distributed, so the ∣Aπ,ξi(n)∣ are independent copies of ζ(n). This gives the first inequality in (13).
For the closed form, note that (mζ(n)) counts the sets T⊆Aid with ∣T∣=m and T⊆Aξ(n). By Lemma 1 and ∥T∥≤∣T∣, for 0≤m≤n−1,
Finally, since μn(πX)=μn(X) and dT(πy,πX)=dT(y,X), left-invariance gives E∣Mnc(ξ1(n),…,ξk(n))∣=n!P(π∈Mnc(ξ1(n),…,ξk(n))) for every fixed π∈Sn, and similarly for Ln,c. Together with (13) and n!/(n−1−c)!≤nc+1, this gives the bounds on the expectations, and (2k)!(2k)n−1−c−2k/(n−1−c)!→0 as n→∞ for fixed c.
In particular, for fixed c, E∣Mnc(ξ1(n),…,ξk(n))∣ and E∣Ln,c(ξ1(n),…,ξk(n))∣ grow at most exponentially in n. These bounds are explicit but crude: for k=3, the bound on E∣Ln,c∣ exceeds the exact values obtained from Table 2 by a factor growing from about 45 at n=10 to about 4×107 at n=28.
The sets Ln,c grow rapidly with the tolerance: for n=22 and k=3, E∣Ln,c∣≈2.3×108, 1.5×1010 and 4.4×1011 for c=0,1,2. The proof of the next theorem shows that, when k,c=o(n), increasing the tolerance by one increases the cardinality by a factor of at least (1−o(1))n/(c+1). For fixed k, the theorem then uses Mn⊆Ln,On to quantify how much smaller Mn is than Ln,On+s.
Theorem 7 (Exact versus approximate median counts). For fixed k≥2, let Xn={ξ1(n),…,ξk(n)} be a set formed by k independent uniformly distributed random permutations in Sn, and write On=On(Xn). Then
and np∣Mn(Xn)∣/∣Ln,an(Xn)∣→0 in probability for every fixed p≥0 and every an→∞.
Proof. Let X⊆Sn be deterministic with ∣X∣=k≥2, write αr=∣{y∈Sn:η0(y)=r}∣ and abbreviate γc=∣Ln,c(X)∣=∑r=0cαr. We first claim that (r+1)αr+1≥(n−1−2k−r)αr for 0≤r≤n−2. Reversing the prefix y1⋯yi, with 1≤i<n, replaces only {yi,yi+1} by {y1,yi+1}, so it raises η0 by exactly one unless it removes an adjacency absent from all inputs, which happens for at most η0(y)=r values of i, or creates one present in an input, which happens for at most 2k values, since ∪x∈XAx has maximum degree at most 2k. Hence at least n−1−2k−r of the n−1 reversals send y into {η0=r+1}. Conversely, each such image has at most r+1 preimages, since the reversal must be undone at one of its r+1 adjacencies absent from all inputs, and each of these determines the preimage uniquely. Double counting the pairs (y,i) proves the claim, which is immediate when its right-hand side is negative.
Summing the claim over r=0,…,c and using ∑r=0crαr≤cγc gives (c+1)αc+1≥(n−1−2k−2c)γc, hence γc+1/γc≥(n−2k−c)/(c+1) for 0≤c≤n−2. Applying this successively at c,c+1,…,c+s−1 gives, for all integers c,s≥0 with c+s≤n−2k,
Now let X=Xn. The bounds above remain valid for fewer than k distinct inputs, using the same degree bound 2k; the singleton case is immediate. The right-hand side of (15) is nonincreasing in On(X), for all sufficiently large n, so on {On≤K} the ratio in the statement is at most (sK+s)/(sn−2k−K)=O(n−s) for each fixed K; since (On)n is tight, by On≤Λn and Corollary 1, K may be chosen with P(On≤K) arbitrarily close to 1. Given p≥0 and an→∞, choose an integer s>p; then P(an≥On+s)→1, and the last assertion follows from the first together with the monotonicity of c↦∣Ln,c(X)∣.
For fixed k and c, the proof shows that each additional unit of tolerance increases the cardinality by at least a factor of order n, while increasing the near-optimality bound of Theorem 3(i) by one. Although the exact and approximate median sets coincide at zero tolerance when the inputs are at pairwise maximum breakpoint distance (Proposition 1), Theorem 7 shows that the median proportion decays at least polynomially in probability when the tolerance exceeds On by a fixed positive integer. The precise asymptotic order of the expected number of exact medians remains open.
5 Discussion
We introduced the notions of median inverse and approximate median inverse and used them to study the probability that any given permutation x∈Sn is a c-approximate median of k permutations X={ξ1(n),…,ξk(n)} chosen uniformly and independently at random from Sn. Due to the left-invariance of the breakpoint distance, this probability is the same for all permutations in Sn. Consequently, we computed the expected number of c-approximate medians of
X. The key was to observe that any exact median of X can have at most On(X) adjacencies not belonging to ⋃i=1kAξi(n). For random inputs, we showed that On(X)/an→0 in probability as n→∞, for any diverging sequence (an)n∈N. In particular, this is informative when an→∞ with an=o(n).
To determine the probability of a permutation x being a c-approximate median of X, we count the approximate median inverse Ln,k,c−1(x). Splitting Ax into the sets J~A of adjacencies of x present exactly in the inputs indexed by A⊆[k] reduces this count to the numbers ∣Hx(n)(Ji)∣ of permutations sharing exactly Ji=∪A∋iJ~A with x, which Theorem 5 gives explicitly and Theorem 4 combines. As discussed after Remark 6, the same decomposition gives a constructive procedure for generating input genomes that have a given permutation as a c-approximate median at prescribed breakpoint distances, whenever the required segment sets exist.
Our results provide two complementary justifications for considering the c-approximate median set as a relaxation of the exact median set. First, Theorem 2 shows that, for random inputs, the exact median set is contained with high probability in an approximate median set with a suitably growing tolerance. Second, Theorem 3 shows that approximate medians are precisely the near-optimal solutions, up to a shift of the tolerance by Λn(X)+On(X), which by Corollary 1 is bounded in probability for random genomes. Taking the tolerance to be zero, the same theorem also contains the exact median set in Ln,On(X)(X) for every set of input genomes. Separately, Theorem 6 gives explicit upper bounds, with no restriction to a favorable event, on the probability that a given permutation belongs to Mnc and on E∣Mnc∣; the case c=0 concerns exact medians, and the same bounds hold for Ln,c. Theorem 7 quantifies the gap between the exact and approximate median sets: for fixed k and c, each additional unit of tolerance increases the number of approximate medians by at least a factor proportional to n. Moreover, for every fixed integer s≥1, the proportion of exact medians in Ln,On+s is OP(n−s), while, by Remark 3, the tolerance On in the inclusion Mn⊆Ln,On cannot be lowered in general.
In summary, our analysis computes the probability that a given permutation is a c-approximate median of random genomes and the expected number of such approximate medians, provides a systematic procedure for generating them, and yields upper bounds for the corresponding quantities for exact medians. Dynamic programming and subset transforms make these approximate-median quantities exactly computable in practice (Tables 1 and 2). Our findings provide a foundation for algorithmic approaches to counting and constructing median and approximate median genomes.
References
[1] BRYANT, D. The complexity of the breakpoint median problem. Centre de recherches mathematiques (1998).
[2] CAPRARA, A. The reversal median problem. INFORMS Journal on Computing 15, 1 (2003), 93–113.
[3] DA SILVA, P. H., JAMSHIDPEY, A., AND SANKOFF, D. Sampling gene adjacencies and geodesic points of random genomes. In RECOMB International Workshop on Comparative Genomics (2024), Springer, pp. 189–210.
[4] DA SILVA, P. H., JAMSHIDPEY, A., AND SANKOFF, D. Identifying Breakpoint Median Genomes: A Branching Algorithm Approach. In 25th International Conference on Algorithms for Bioinformatics (WABI 2025) (Dagstuhl, Germany, 2025), vol. 344 of Leibniz International Proceedings in Informatics (LIPIcs), Schloss Dagstuhl – Leibniz-Zentrum für Informatik, pp. 18:1–18:18.
[5] FERTIN, G., LABARRE, A., RUSU, I., TANNIER, E., AND VIALETTE, S. Combinatorics of genome rearrangements. The MIT Press, 2009.
[6] HAGHIGHI, M., AND SANKOFF, D. Medians seek the corners, and other conjectures. BMC bioinformatics 13, 19 (2012), S5.
[7] JAMSHIDPEY, A. Population Dynamics in Random Environment, Random Walks on Symmetric Group, and Phylogeny Reconstruction. PhD thesis, Université d'Ottawa/University of Ottawa, 2016.
[8] JAMSHIDPEY, A., JAMSHIDPEY, A., AND SANKOFF, D. Sets of medians in the non-geodesic pseudometric space of unsigned genomes with breakpoints. BMC genomics 15, 6 (2014), S3.
[9] JAMSHIDPEY, A., AND SANKOFF, D. Phase change for the accuracy of the median value in estimating divergence time. BMC bioinformatics 14, 15 (2013), S7.
[10] JAMSHIDPEY, A., AND SANKOFF, D. Asymptotic medians of random permutations sampled from reversal random walks. Theoretical Computer Science (2017).
[11] KAPLANSKY, I. The asymptotic distribution of runs of consecutive elements. Annals of Mathematical Statistics 16, 2 (1945), 200–203.
[12] LARLEE, C. A., ZHENG, C., AND SANKOFF, D. Near-medians that avoid the corners; a combinatorial probability approach. BMC genomics 15, 6 (2014), S1.
[13] MIARDAN, M. M., JAMSHIDPEY, A., AND SANKOFF, D. Escape from parsimony of a double-cut-and-join genome evolution process. Journal of Computational Biology 30, 2 (2023), 118–130.
[14] SANKOFF, D., AND BLANCHETTE, M. The median problem for breakpoints in comparative genomics. In International Computing and Combinatorics Conference (1997), Springer, pp. 251–263.
[15] TANNIER, E., ZHENG, C., AND SANKOFF, D. Multichromosomal median and halving problems under different genomic distances. BMC bioinformatics 10, 1 (2009), 120.
[16] WOLFOWITZ, J. Note on runs of consecutive elements. Annals of Mathematical Statistics 15, 1 (1944), 97–98.
[17] XU, W., ALAIN, B., AND SANKOFF, D. Poisson adjacency distributions in genome comparison: multichromosomal, circular, signed and unsigned cases. Bioinformatics 24, 16 (2008), i146.