Orthology and paralogy constraints: satisfiability and consistency

Background A variety of methods based on sequence similarity, reconciliation, synteny or functional characteristics, can be used to infer orthology and paralogy relations between genes of a given gene family G. But is a given set C of orthology/paralogy constraints possible, i.e., can they simultaneously co-exist in an evolutionary history for G? While previous studies have focused on full sets of constraints, here we consider the general case where C does not necessarily involve a constraint for each pair of genes. The problem is subdivided in two parts: (1) Is C satisfiable, i.e. can we find an event-labeled gene tree G inducing C? (2) Is there such a G which is consistent, i.e., such that all displayed triplet phylogenies are included in a species tree? Results Previous results on the Graph sandwich problem can be used to answer to (1), and we provide polynomial-time algorithms for satisfiability and consistency with a given species tree. We also describe a new polynomial-time algorithm for the case of consistency with an unknown species tree and full knowledge of pairwise orthology/paralogy relationships, as well as a branch-and-bound algorithm in the case when unknown relations are present. We show that our algorithms can be used in combination with ProteinOrtho, a sequence similarity-based orthology detection tool, to extract a set of robust orthology/paralogy relationships.


Introduction
Gene families, usually constructed from sequence similarity, group homologous genes, i.e., genes sharing a common ancestry: starting from a single gene copy, a history of speciations, duplications and losses is assumed to be at the origin of the observed set of extant genes. Deciphering the orthology (divergence following a speciation) and paralogy (divergence following a duplication) relations between pairs of genes inside a gene family is important and lies at the heart of many genomics studies. The reconstruction of species trees for example is usually based on the selection and alignment of orthologous gene copies. From a functional point of view, orthologs are believed to be more likely similar in function than paralogs [1]. Orthology/paralogy information is often derived from a reconciliation approach (first introduced by Goodman in 1979 [2]). A gene tree that best reflects the evolution of the sequences is first constructed for the gene family. Assuming a known phylogeny for the set of taxa, the non-agreement between the two trees is then explained by a set of duplication and loss events (other events such as horizontal gene transfer might also be inferred by reconciliation, although we will ignore them here). Reconciliation leads to a labeling of internal nodes of the gene tree as duplication/speciation nodes, yielding a full orthology/paralogy interpretation for each pair of genes (cf. e.g. TreeFam [3,4] used for constructing the Ensembl Compara gene trees [5], PHOG [6], MetaPHOrs [7]). This approach assumes that an accurate gene tree can be constructed for the gene family. Although inferring phylogenies is a field with a very long history, due to various limitations constructing good gene trees is still challenging. A variety of other methods have been developed for the purpose of orthology/paralogy detection. A well-known class of algorithms is based on clustering genes according to their sequence similarity (cf. e.g. the COG database [8], OrthoMCL [9], InParanoid [10], Proteinortho [11], orthoDB [12], eggNOG [13]). Recently, we investigated another way of detecting orthology/paralogy based on conserved synteny (conservation in gene order) [14,15]. Other initiatives, such as the Gene Ontology project [16], provide functional annotation that can be used as another source of orthology relations. In contrast to the reconciliation approach, only partial relations can be expected from such tree-free methods.
The orthology/paralogy information suggested by gene tree reconciliation may be contradictory with that suggested by an external source. As gene trees are known to be error-prone, more confidence can be given to such homology information when it is well-supported by various genomic observations. This raises the problem of gene tree editing based on a known set C of pairwise orthology/paralogy constraints. But prior to any algorithmic consideration, one should be able to state whether the set C is possible, i.e. whether all constraints can simultaneously co-exist in an evolutionary history of the gene family. In a recent work [14], we showed that a set of orthlogy constraints is always possible and we gave a polynomial-time algorithm for correcting a gene tree in a minimal way according to the Robinson-Foulds distance.
Recent studies have considered the connection of trees and orthology from the angle of reconstructing phylogenies from orthology relations [17][18][19]: How much information about the gene tree, the species tree and their reconciliation is already contained in the orthology relation between genes? In other words, having a set C of full pairwise orthology/paralogy relations (each pair of genes is constrained), can one reconstruct the gene and species trees? Similarly to gene tree editing, the first question to be asked is whether the orthology/paralogy constraints can simultaneously co-exist in a history of the gene family. Interestingly, by making the link with symbolic ultrametrics and co-graphs, a simple characterization of satisfiability (symbolic ultrametric) for full paralogy/ orthology relations is given in [17], where satisfiability relates to the existence of an event-labeled gene tree G (symbolic representation) leading to C. Notice that satisfiability does not mean the possibility for orthology/paralogy relations to co-exist in a true history, as the triplet phylogenies contained in G are not necessarily consistent (included in a species tree). The derivation of a species tree from an event-labeled gene tree is considered in [18]. Finally, the outline of a computational framework for the construction of a least resolved species tree S from a set of orthology/paralogy relations, involving the extraction of maximum satisfiable relations and maximum consistent triple set is given in [19].
Here, we consider the general case for C: in contrast with [17,18], we do not require C to be full, i.e., to involve a constraint for each pair of genes. We introduce the notations and problems in the following section. We then show how previous results on the Graph sandwich problem can be used to solve the problem of satisfiability. The developed algorithm for satisfiability is then adapted to the problem of consistency with a given species tree. In the case of an unknown species tree, we then study the problem of finding a gene tree that is consistent with some species tree. Finally we show in the result section how our methodology can be used, in combination with PROTEINORTHO [11], a sequence similarity-based orthology detection tool, to extract a set of robust orthology/paralogy relationships.

Notations and problem statement
In the rest of this paper, we consider a set Σ of species and a gene family G where each gene x belongs to a species s(x) of Σ. We generalize the notation s to subsets of genes: if U ⊂ G, s(U) = {s(x) : x ∈ U}.
As we only consider rooted trees, we will sometimes omit the word "rooted". Let T be a tree. We denote by r (T) its root and by L(T) its set of leaves. For any internal node x of T, we denote by T x the subtree of T rooted at x. We say that a node y is an ancestor of x if the two nodes belong to the same path from a leaf to the root of T, and y is closer to the root. Two nodes x and y are unrelated if x ≠ y and none is the ancestor of the other. For a set of leaves U ⊆ L(T), we denote by lca T (U) the least common ancestral node of U in T, i.e. the common ancestral node of the elements of U which is the farthest from the root.
Let L ′ be a subset of L(T). The restriction T | L′ of T to L′ is the tree with leaf set L′ obtained from T lcaT (L′) by removing all leaves that are not in L′, and all internal nodes of degree 2, except the root. Let T′ be a tree such that L(T′) = L′ ⊂ L(T). We say that T displays T′ iff T | L′ is label-isomorphic to T′.
A triplet is a binary tree on a set L with |L| = 3. For L = {x, y, z}, we denote by xy|z the unique triplet t on L with root r(t) for which lca t (x, y) ≠ r(t) holds. We denote by tr(T) = {T| L : L ∈ L(T) 3 and T| L is binary} the set of all rooted triplets of a tree T. Evolution of species and genes: A species tree S for Σ is a rooted tree whose leaves are in bijection with Σ, representing the evolutionary relationships between the species: an internal node is an ancestral species at the moment of a speciation event, and its children are the descendants. Although species trees are generally binary, we do not make this assumption here. Genes of G undergo speciation when the species to which they belong do. Within a species, genes can be duplicated or lost. A history H for G is a tree representing the evolution of the gene family through speciations and duplications: each leaf of H is labeled by a gene of G, and each internal node refers to an ancestral gene at the moment of an event (speciation or duplication). Therefore each internal node of H can be labeled as a speciation (Spec) or duplication (Dup) event.
As H is a history "embedded" in the species tree S of Σ, it must reflect a speciation history consistent with S: any speciation node of H should reflect a clustering of species in agreement with S. To formally define consistency, let first introduce a more general set of labeled trees. We call a DS-tree for G a pair (G, ℓ), where G is a tree with L(G) = G, and ℓ is a function ℓ : {Dup, Spec} labeling each internal node of G as a duplication or a speciation node. For simplicity, we often refer to G as the DS-tree for G without explicitly stating ℓ, and assume the internal nodes of G are labeled Dup or Spec. For some X ⊆ L(G), we implicitly assume that the internal nodes of G| X share the same label as in G.
Definition 1 Let G be a DS-tree for G and S be a species tree for Σ. We say that G is consistent with S if and only if, for any speciation node x of G and any two children y, z of x, lca S (s(L y )) and lca S (s(L z )) are unrelated in S, where L y and L z are the leaf-sets of G y and G z respectively. Now a history H for G is simply a DS-tree for G consistent with the species tree S for Σ. Denote tr S (G) = {s(x)s(y)|s(z) : xy|z ∈ tr(G) is rooted at a speciation and s(x) ≠ s(y)} The triplets of tr S (G) are called speciation triplets. The following theorem, which is a reformulation of Theorem 6 in [18], relates consistency to speciation triplets.
Theorem 1 Let G be a DS-tree for G and S be a species tree for Σ. Then G is consistent with S if and only if S displays all triplets of tr S (G).
From the Fitch [20] terminology, two leaves x and y of a history are orthologous if lca H (x, y) is a speciation node, and paralogous otherwise. We extend this terminology to a more general DS-tree.
Definition 2 Let G be a DS-tree for G. Then two genes x, y of G are orthologous with respect to (w.r.t.) G if lca G (x, y) is a speciation node, and paralogous w.r.t. G if lca G (x, y) is a duplication node.
Therefore a DS-tree induces a set of orthology/paralogy relationships between genes.
Constraint graph: A constraint is simply an unordered pair of genes x, y ∈ G 2 . A set of orthology/paralogy constraints on G (or simply a constraint set) is a pair C = C O represents the orthology constraints and C P the paralogy constraints. We say that C is a full constraint set if G. For example, a history H for G induces a full constraint set. We represent a constraint set C = (C O, C P )by an edgebicoloured undirected graph R = (V, E, U), called a constraint graph, with vertex set V = G, and two edge sets genes are linked by an edge of E if they are constrained by orthology, unlinked if they are constrained by paralogy, and linked by a "special" edge of U if the relation between the two genes is unknown. We refer to the edges of E as the orthology edges, to those in U as the unknown edges and we refer to the unlinked pairs of genes as the paralogy non-edges. An example of a partial constraint graph is given in Figure 1.
If C is a full constraint set then U = 0. R is called a full constraint graph in this case. The complement of R is the graphR obtained by the alternative choice of linking paralogs instead of orthologs. Formally,R = (V,Ē\U, U), whereĒ is the complement of E defined by e ∈Ē iff e ∉ E. Notice that R andR share the same set U of unknown edges. We denote by corresponds to the usual definition of the graph induced by X.
Satisfiability and consistency Given a constraint set C (or similarly a constraint graph R), is C possible, i.e. can we find a history for G inducing the orthology and paralogy constraints of C? As an orthology constraint for two genes belonging to the same genome cannot be induced by a history for G, we assume in the rest of this A trivial set of paralogy constraints is a set C P restricted toC P . The question whether C is possible is in two parts: (1) is C satisfiable, i.e. can we find a DS-tree G inducing C and (2) is there such a G which is consistent with a species tree? Formal definitions follow.
Definition 3 Let R = (V, E, U) be a constraint graph and G be a DS-tree with L(G) = V. We say that G satisfies R if for two genes x, y ∈ L(G), if xy ∈ E then they are orthologous w.r.t. G, and if xy ∈ E \ U then they are paralogous w.r.t. G. We say that R is satisfiable if there exist a DS-tree G that satisfies R.
If U = 0, then R being satisfiable means that we can make a choice for the unknown edges as orthology edges and paralogy non-edges to obtain a full constraint graph that is satisfiable. For F ⊂ U, the realization of R by F corresponds to choosing F as orthology edges, and U \ F as paralogy non-edges, leading to the full constraint graph R(F) = (V, E ∪ F, 0). We call R( 0) and R(U) the empty and full realizations, respectively.
As a history is a DS-tree, a set of constraints that is not satisfiable is clearly not possible, i.e. there is no history that depicts the orthology/paralogy relationships given by the constraints. Moreover, satisfiability is not sufficient to ensure the possibility of such an history, as a DS-tree is not always consistent with a species tree. Figure 1 shows an example of a constraint graph R along with two satisfying realizations R 1 and R 2 . However, R 1 cannot be made consistent with a given species S whereas R 2 can.
Definition 4 Let R be a constraint graph for G. We say that R is consistent with a species tree S if and only if there is a realization of R which is satisfiable by a DStree G which is consistent with S. More generally, we say that R is consistent if and only if there is a species tree S such that R is consistent with S.
The three following sections are respectively dedicated to the three following questions: (1) Given a constraint graph R = (V, E, U), is R satisfiable? (2) Given a satisfiable constraint graph R = (V, E, U), and a species tree S, is R consistent with S? (3) Given a satisfiable constraint graph R = (V, E, U), is R consistent, i.e. can we find a species tree S such that R is consistent with S?

Satisfiability of a constraint graph
The problem of constraint graph satisfiability has been addressed in [17] in the restricted case of a full set of constraints. The following theorem is a reformulation of one of the main results of this paper.

Theorem 2 ([17])
A full constraint graph R is satisfiable if and only if R is P 4 -free (or equivalently, iffR is P 4 -free since P 4 is self-complementary), meaning that no four vertices of R induce a path of length 4.
Consider now the general case of a constraint graph R = (V, E, U) with U = 0. Then the problem is to find a realization R(F) that is itself satisfiable, i.e. P 4 -free. It turns out that this problem is a reformulation of the well-known Graph sandwich problem for P 4 -free graphs. It can be stated as follows : given two graphs G 1 = (V, E 1 ) and That is, G must contain every edge of G 1 and every non-edge of G 2 . It is then clear that this is equivalent to finding a P 4 -free [21] to solve this problem. In this section, we restate under our formalism some of the useful results of this paper, and give a modified version of the proposed algorithm that outputs a DStree that satisfies R whenever there is one. We will make use of the following well-known characterization of P 4 -free graphs.
Lemma 1 A graph Γ is P 4 -free if and only if, for any subset X of vertices of Γ with |X| ≥ 2, either Γ[X] or [X] is disconnected. The next lemmata establish an important heritability property on satisfiable graphs: every restriction R[X] of R must be satisfiable for R to be satisfiable.
Lemma 2 Let G be a DS-tree that satisfies a realization R(F), for some F ⊆ U. Let X ⊆ V and let F X = {ab ∈ F : a, b ∈ X}. Then G| X is a realization of R[X](F X ). . The gene names correspond to their respective species in the species tree S. The tree G 1 is a DS-tree that satisfies R 1 while G 2 is a DS-tree that satisfies R 2 . Duplication nodes in G 1 and G 2 are indicated by a green square. G 1 is not consistent with S because for instance, G 1 has the speciation triplet s(a 1 )s(d 1 )|s(e 1 ) = ad|e while S has the de|a triplet. The tree G 2 is consistent with S.
Lafond and El-Mabrouk BMC Genomics 2014, 15(Suppl 6):S12 http://www.biomedcentral.com/1471-2164/15/S6/S12 Proof: Let a, b ∈ X. First observe that a and b have the same orthology/paralogy relationship in R(F) and R[X] (F X ). Let c = lca G (a, b). Now, c is also an internal node of G| X, and moreover c = lca G|X (a, b). As c has the same Dup or Spec label as in G, c correctly displays the relationship between a and b. Thus G| X satisfies every relationship in R[X](F X ).
The heritability property is then immediate. Lemma 3 [21]A constraint graph R = (V, E, U) is satisfiable if and only if for any X ⊆ V, R[X] is satisfiable.
Theorem 3 [21]A constraint graph R is satisfiable if and only if at least one of the two following holds : 1 R( 0) is disconnected, and all of its connected components are satisfiable; 2 R (U) is disconnected, and all of its connected components are satisfiable.
Proof: ⇐ For 1.: Suppose R( 0) is disconnected. Let {R 1 ,..., R k } be the connected components of R( 0) with k >1, all being satisfiable. As each R i is satisfiable, there is a DS-tree G i that satisfies a realization R i (F i ) of R i . Let F = ∪ 1≤i≤k F i . Then the realization R(F) of R is a full constraint graph with k full constraint components R i (F i ) in which no two components share an edge. In other words, there is a paralogy non-edge between each pair of genes from two different components. Therefore, joining the roots of G 1 ,..., G k under a common duplication node yields a DS-tree for R(F), which shows that R is satisfiable. The proof when 2. holds is the same, except that we root G at a speciation node since the components of R (U) are pairwise-complete in R(U).
⇒ Suppose that both conditions do not hold. If R( 0) or R (U) has a component that is not satisfiable, then by Lemma 3, R is not satisfiable. So instead suppose that each of R( 0) and R (U) has a single connected component. Let F ⊆ U. The realization R(F) of R must be connected as R( 0) is already connected and R(F). R(F) must also be connected, as choosing all edges of U leaves R (U) connected and ER (U) ⊆ E(R(E)). Since both R(F) and R(F) are connected, by Lemma 1 R (F) is not P 4 -free, and thus not satisfiable by Theorem 2. As this is true for any realization R(F) of R, i.e. for any F ⊆ U, it follows that R is not satisfiable.
Theorem 3 suggests the recursive algorithm BuildD-STree that begins by finding out if one of R( 0) or R (U) is disconnected. If so, it creates a node of the appropriate type with children being the identified components, and repeats the process on each such component.
Algorithm Consistency with a given species tree Let R = (V, E, U) be a constraint graph for G and S be a species tree for Σ. We want to know whether the orthology/paralogy constraints represented by R can be induced by a history for G consistent with S. More precisely, is there a realization R(F) of R that is satisfiable and such that the DS-tree satisfying R(F) is consistent with S? If R is not satisfiable, then the answer is clearly no. Therefore hereafter we assume that R is satisfiable. We first show that the problem at hand still has the heritability property.

Lemma 4 R is consistent with S if and only if for any X ⊆ V, R[X] is consistent with S.
Proof: The '⇐' part is trivial since we can choose X = V to show that R is consistent with S. Conversely, assume R is consistent with S. Let G be a DS-tree for some realization of R such that G is consistent with S, and let X ⊆ V. By Lemma 2, G| X is a DS-tree for R[X]. Let ab|c ∈ tr S (G| X ). Since going from G| X to G only involves adding subtrees on branches of G| X, it follows that ab|c ∈ tr S (G). Therefore, tr S (G| X ) ⊆ tr S (G). Now, since S displays tr S (G), G| X is a realization of R[X] that is consistent with S.
We need to introduce one last notation before stating the main theorem for characterizing consistency of a constraint graph R with a species tree S. Let R(F) be a realization of R, and let CC = {R 1 ,..., R k } be the connected components of R(F). Notice that the components of CC are pairwise complete in R(F). A speciation partition P = {P 1 ,..., P |P| } is a non-trivial partition of CC (i.e. | P | >1) such that lca S (s(P i )) is unrelated to lca S (s(P j )) whenever i ≠ j.
Theorem 4 R is consistent with S if and only if at least one of the following conditions holds: 1 R( 0) is disconnected and each connected component is consistent with S; 2 R (U) is disconnected, its components admit a speciation partition and each component in this partition is consistent with S.
Proof: ⇐ For 1., Let {R 1 ,..., R k } be the connected components of R( 0), each R i having a DS-tree G i consistent with S. We can then join the roots of G 1 ,..., G k under a common duplication parent. This yields a DS-tree G that satisfies R as each pair of components of R( 0) are related by paralogy. Furthermore, all rooted triplets of G that were not in any G i are rooted at r(G), a Dup node. Therefore, tr S (G) = ∪ 1≤i≤k tr S (G i ), which S displays. ⇐ 2.: Let P = {P 1 ,..., P k } be a non-trivial speciation partition of the connected components of R (U). By assumption every P i ∈ P has a DS-tree G i that is consistent with S, implying that S displays ∪ 1≤i≤k tr S (G i ). Here all elements of P are components of R that are pairwisecomplete, and we obtain a DS-tree G for R by joining G 1 ,..., G k under a common speciation parent. Let T = tr S (G) \ ∪ 1≤i≤k tr S (G i ). Every triplet of T is rooted at r(G). Thus if three genes a, b, c of L(G) form a speciation triplet s(a)s(b)|s(c) ∈ T, then a and b are in some part P i while c is in another part P j . But by the definition of speciation partitions, lca S (s(P i )) is unrelated to lca S (s(P j )), implying that s(a)s(b)|s(c) ∈ tr(S). It follows that S displays T.
⇒ : suppose both conditions are not met, but that R is consistent with S. If R( 0) is disconnected but has an inconsistent component, then R is inconsistent by Lemma 4. So we assume R( 0) is connected. If R (U) is also connected, then we saw in Theorem 3 that R is not even satisfiable. If R (U) is disconnected and admits a speciation partition, but a member of this partition is not consistent, then again by Lemma 4, R is not consistent. So we assume that R( 0) is connected, and R (U) is disconnected but admits no speciation partition. Let G be a DS-tree for R consistent with S. Suppose r(G) is a duplication node and let r 1 , r 2 be two children of r(G). We have that every gene in L(G r 1 ) is paralogous with every gene in L(G r 2 ) and vice-versa. This implies that L (G r 1 ) and L(G r 2 ) are two components of R( 0) that share no edge, a contradiction since we assume R( 0) is connected. So r(G) is a speciation node. Let r 1 ,..., r k be the children of r(G). The sets L(G r 1 ),..., L(G r k ) form a partition P of the connected components of R (U). Since S displays tr S (G), it follows that for two distinct P i , P j ∈ P, lca S (s(P i )) and lca S (s(P j )) are unrelated.
Hence P is a speciation partition, a contradiction. This theorem suggests a small modification to algorithm BuildDSTree. Connected components of R( 0) are handled in the same manner, but in the case of a disconnected R (U), we need to find a speciation partition P after having found its connected components CC. To accomplish this, it suffices to observe that some C 1 , C 2 ∈ CC must be in the same part of P when lca S (s(C 1 )) is on the path from lca S (s(C 2 )) to the root of S (or vice-versa). Thus for each P i ∈ P, we can find the member of C ∈ P i that has lca S (s(C)) the closest to the root of S, then any other component C′ having lca S (s(C′)) in the subtree rooted at lca S (s(C)) will be in P i .
FINDSPECIATIONPARTITION uses that fact to find P through a pre-order traversal of S.
Algorithm FindSpeciationPartition(CC, s, P, Pi) where CC is the set of components to partition, s ∈ V (S) is the current node of S in the pre-order traversal, P is the partition of CC, and Pi is the current part of P we are adding components to FOR C ∈ CC such that lca S (C) = s; IF P i is not set; let P i be a new empty set and add P i to P Add C to P i END FOR FOR s′ ∈ children(s); FindSpeciationPartition(CC, s′, P, P i ) END FOR Assuming constant time for each lca lookup, we can precompute lca S (s(C)) in time |C| for each C ∈ CC. If CC has a total of k nodes, by mapping each s ∈ S to the list of C ∈ CC with lca S (s(C)) = s, the whole algorithm takes time O(k + |S|). We need up to n − 1 calls of BuildDSTree. We argued that one call on a node v of G in BUILDD-

Consistency of a satisfiable constraint graph
Now let R = (V, E, U) be a constraint graph for G and suppose the species tree for Σ is unknown. The question is to know whether the graph R is consistent, and if so to output a species tree S such that R is consistent with S. As above, we assume that R is satisfiable. Note that unlike the two previous problems, we cannot treat each connected component of R( 0) or R (U) independently, as two (or more) components might give gene histories consistent by themselves but not together.
We hereafer begin with two classes of constraint graphs for which consistency always holds.
Orthology constraints only: Suppose R = (V = G, E, U) represents a constraint set restricted to orthology constraints, i.e. C = (C O, C P ), where C P =C is the trivial set of paralogy constraints. For each s i ∈ Σ, let L s i = {x ∈ V : s(x) = s i } and let F s i be the star-tree joining all the leaves of L s i under a single duplication node. Now let G be the star-tree joining all the F s i trees, for all s i ∈ Σ, under a single speciation node. Then G satisfies the full realization R(U) of R and it is consistent with the star-tree for Σ. Therefore any set of orthology constraints is consistent.
Paralogy constraints only: Suppose R = (V = G, E, U) represents a constraint set restricted to paralogy constraints, i.e. C = (C O = 0, C P ). If G is the star-tree joining all the genes of G under a single duplication node, then G satisfies the empty realization R( 0) of R and it is consistent with the star-tree for Σ. Therefore any set of paralogy constraints is consistent.
Consider now a full constraint graph R. The results in [17,18] suggest a polynomial-time algorithm for solving the consistency problem that consists in building a DStree G satisfying R, extracting all speciation triplets of G and checking their consistency with a species tree. Here we propose an alternative polynomial time algorithm for the same problem, avoiding the first step of a DS-tree construction. We first introduce the following subset P 3 (R) of triplets of V 3 inducing a path of size 3 in R: , zx, zy ∈ E and xy / ∈ E ∪ U and s(x) / ∈ s(y)} Notice that s(x)s(y)|s(z) ∈ P 3 (R) implies that any DS-tree G satisfying R has s(x)s(y)|s(z) ∈ tr S (G). Indeed, since xy ∉ E ∪ U, lca G (x, y) is a duplication node. And since both x and y are related to z by speciation, lca G (x, z) = lca G (y, z) and xy|z must be a speciation triplet of G.
For example, consider the vertices b 1 , c 2 , e 1 of the R graph in Figure 1, which form a path of length 3 with e 1 in the center. In the DS-tree G 1 , lca G 1 (b 1 , c 2 ) is a duplication, and lca G 1 (b 1 , c 2 ) ({b 1 , c 2 , e 1 }) is a speciation. Restricting G 1 to the three vertices yields the triplet b 1 c 2 |e 1 rooted at a speciation, and therefore, s(b 1 )s(c 2 )|s(e 1 ) ∈ tr S (G 1 ).
The same holds for the s(c 1 )s(c 2 )|s(e 1 ) triplet implied by the P 3 induced by c 1 , c 2 , e 1 . Notice however that in both DS-trees, s(b 1 )s(c 1 )|s(e 1 ) is a speciation triplet, though b 1 , c 1 , e 1 do not induce a P 3 . We show that this kind of speciation triplet is implied by the other two aforementioned P 3 , and that the P 3 subgraphs actually imply every mandatory speciation triplet.
Theorem 5 Let R = (V, E, U = 0) be a satisfiable full constraint graph. Then R is consistent if and only if there exists a species tree S displaying all the triplets of P 3 (R).
Proof: ⇒ : since s(x)s(y)|s(z) ∈ P 3 (R) implies that s(x)s (y)|s(z) ∈ tr S (G), it follows that any species tree S consistent with R must display every triplet of P 3 (R).
⇐ : we first obtain a least-resolved DS-tree G for R in terms of speciation. Let G′ be a consistent DS-tree satisfying R, and let S be a species tree displaying P 3 (R). If G′ has any speciation node v that has a speciation child w, we obtain G″ by contracting v and w (delete w and give its children to v). Since v and w are both speciations, this operation does not change the label of lca G (x, y) for any two leaves x and y and G″ still satisfies R. Moreover, tr S (G″) ⊂ tr S (G′), so there is no risk of breaking consistency. We obtain a DS-tree G by repeating this operation until we cannot find such a v and w.
Let xy|z be a triplet of G rooted at a speciation node. We have that lca G (z, x) = lca G (z, y) is a speciation, and that zx, zy ∈ E. If lca G (x, y) is a duplication node, then xy ∉ E. So {x, y, z} induces a P 3 in R, and S displays s(x) s(y)|s(z). Suppose instead that lca G (x, y) is a speciation node. Because G is a least resolved DS-tree, there must be a duplication node u on the path between lca G (x, y) and lca G (x, z). This implies there is a leaf d in G u such that x and y are related to d by duplication, but with d and z related by speciation. In R, we then have zd ∈ E, and xd, yd ∉ E. Thus both {x, d, z} and {y, d, z} induce a P 3 in R with z being the middle vertex, and s(x)s(d)|s(z), s(y)s(d)|s(z) ∈ P 3 (R) are both displayed by S. This is only possible if there is a node in S that has all of s(x), s(y), s (d) in one child subtree and s(z) in another. Therefore, S must display s(x)s(y)|s(z). Having taken care of both types of speciation triplets, we deduce that displaying P 3 (R) is sufficient to display tr S (G).
Therefore the consistency problem for a satisfiable full constraint graph reduces to the problem of verifying whether the set P 3 (R) of triples can be displayed in a species tree for Σ. This is in fact a well know problem with a solution presented in [22]: given a triplet set R, there is a polynomial-time algorithm, called BUILD [23], that, when applied to R either outputs a species tree that displays R or recognizes that R is inconsistent. Therefore, in the case of a full constraint graph, the consistency problem is resolved in polynomial time by first constructing the set P 3 (R), and then applying the BUILD algorithm.
Consider now the general case of a constraint graph R = (V, E, U) with U = 0. The branch-and-bound algorithm CHECKCONS iterates over the edges of U, tries to make them edges and non-edges but stops as soon as one decision creates a set of P 4 with no unknowns or a set of P 3 that is inconsistent. Since at worst, every possibility is tested, it follows that this algorithm is exact, though exponential in the worst case. Possible improvements of this algorthm include removing as many edges from U as possible, and choosing an ordering of the edges that may speed up the branch-and-bound process. For instance, it may be worthwhile to first identify every induced P 4 of R( 0). The P 4 subgraphs that admit only one possibility for removal, i.e. the P 4 can only be removed by making a unique edge e ∈ U an orthology edge, can be corrected before entering the algorithm. Note that the same applies for the edges of U that must be edges of R (U). We may then prioritize the handling of the other P 4 by considering the edges that resolve them first. Similarly, it would also be possible to identify edges of U that are mandatory in E by finding the P 3 subgraphs of R( 0) that are not in P 3 (R), but that disagree with a triplet of P 3 (R). For instance, R( 0) might have a P 3 with edges xz, zy, but this P 3 is not in P 3 (R) because xy ∈ U. If say s(y)s(z)|s(x) is in P 3 (R), then xy is forced in E as otherwise the contradictory s(x)s(y)|s(z) triplet would be present.

Experiments
We show how the developed algorithms for checking satisfiability and consistency can be used, in combination with an orthology detection tool such as Protei-nOrtho [11], to infer a robust set of orthology and paralogy constraints. Given a set of protein sequences, Proteinortho infers homologous gene families as well as orthology relationships within these families, based on various similarity scores. Proteinortho does not infer paralogy relationships. However, if we choose a set of parameters leading to a loose characterization of orthologs, then we can assume that unpredicted constraints should represent paralogy. Different combinations of parameters therefore lead to different constraint sets that can be analyzed for sat-isfiability and consistency.
ProteinOrtho has been run on 265 gene families of vertebrates, each representing the leaf-set of an Ensembl [5] gene tree. Trees were chosen randomly among the Ensembl gene trees containing at least 20 leaves. For each family, five different parameter settings, numbered from −2 to +2, were tested, 0 representing the default parameter choice of ProteinOrtho, and the smaller the number, the looser is the induced characterization of orthology. For each parameter setting i, we define the full constraint graph R i where all gene pairs not predicted as orthologs are interpreted as paralogs. Typically, a graph R − for a negative number (−1 or −2) contains more orthology (and thus less paralogy) constraints than R 0 , while the converse is true for a graph R + . Combining two constraint graphs R − and R + consists in keeping only orthology and paralogy edges that are common to both, and completing the graph with unknown edges. Table 1 summarizes the results on satisfiability and consistency with the Ensembl species tree S, obtained for each gene family and each parameter setting or combination. Among the 265 gene families, only 112 (42%) produced at least one satisfiable full constraint graph and only 44 (15%) produced such a graph which is also consistent with the Ensembl species tree. However, combining loose and strict parameter settings lead to much better results with at least 95% satisfiability and 56% consistency with S. The partial orthology/paralogy constraints obtained from combinations correspond to about half of the constraints of a full graph, as illustrated by the last column of the table.
In order to get a rough idea of the accuracy of the obtained partial orthology/paralogy predictions for each gene family G, we compared them with those resulting from the labeling of the Ensembl gene tree nodes as duplication and speciation nodes. An orthology disagreement refers to orthology predictions on the four combined graphs depicted in Table 1, that are rather inferred as paralogs from the Ensembl gene tree labeling. The first five rows correspond to the full constraint sets obtained from PROTEINORTHO for the five classes of parameters. The last four rows correspond to the partial constraint sets obtained after combining two graphs over two types of parameters. The first column is the number of families for which the settings of PROTEINORTHO yielded a satisfiable graph, the second that number consistent with the Ensembl species tree. The last column shows the percentage of constraints that were not unknown when a consistent solution was found (which is 100% for the first five rows).
A paralogy disagreement refers to the reverse situation. Overall, the orthology disagreement percentage is between 15.1% and 15.9% depending on the two classes of parameters combined. For paralogy disagreement, it varies between 11% and 17%, depending on the 2 parameters combined (−2/+1 and −2/+2 were around 11.2% while −1/+1 and −1/+2 were around 17.4%). Notice that Ensembl annotates many duplication nodes as "dubious". If we ignore orthology disagreements caused by a dubious duplication node, the orthology disagreement percentage drops to an average of 5.0%, strengthening the doubts on those duplication nodes.

Conclusion
In this work we have developed methods to assess the plausibility of a partial set of orthology and paralogy relationships between pairs of homologous genes. In particular, we showed how extending algorithms for the Graph sandwich problem can solve, in cubic time, the problems of satisfiability and consistency with a given species tree. In case of an unknown species tree, the complexity of the problem of verifying consistency with some species tree remains open. We have elaborated on the P 3 property of the constraint graph, which leads to an exponential branch-and-bound algorithm. It remains possible that this property could be used to create a more efficient method. While previous work consisted in verifying whether a full set of relationships was satisfiable or consistent, admitting uncertainty within these relationships makes it possible to bring the theory from [18] into practice, as current orthology (or paralogy) inference methods based on sequences cannot guarantee 100% accuracy in their predictions. We show how a confidence set of such predictions can be inferred using our methods and Proteinortho. A promising direction is to use such robust predictions to correct gene trees in case of disagreement.