Predicting horizontal gene transfers with perfect transfer networks

Background Horizontal gene transfer inference approaches are usually based on gene sequences: parametric methods search for patterns that deviate from a particular genomic signature, while phylogenetic methods use sequences to reconstruct the gene and species trees. However, it is well-known that sequences have difficulty identifying ancient transfers since mutations have enough time to erase all evidence of such events. In this work, we ask whether character-based methods can predict gene transfers. Their advantage over sequences is that homologous genes can have low DNA similarity, but still have retained enough important common motifs that allow them to have common character traits, for instance the same functional or expression profile. A phylogeny that has two separate clades that acquired the same character independently might indicate the presence of a transfer even in the absence of sequence similarity. Our contributions We introduce perfect transfer networks, which are phylogenetic networks that can explain the character diversity of a set of taxa under the assumption that characters have unique births, and that once a character is gained it is rarely lost. Examples of such traits include transposable elements, biochemical markers and emergence of organelles, just to name a few. We study the differences between our model and two similar models: perfect phylogenetic networks and ancestral recombination networks. Our goals are to initiate a study on the structural and algorithmic properties of perfect transfer networks. We then show that in polynomial time, one can decide whether a given network is a valid explanation for a set of taxa, and show how, for a given tree, one can add transfer edges to it so that it explains a set of taxa. We finally provide lower and upper bounds on the number of transfers required to explain a set of taxa, in the worst case.


Introduction
Evolution has historically been seen as a tree-like process in which genetic material is inherited through vertical descent.However, it is now established that co-existing species from most kingdoms of life, if not all, have exchanged genetic material laterally through hybridation or horizontal gene transfer (HGT).The latter is well-known to occur routinely between procaryotes [35,53], but is believed to have affected eucaryotes as well [34,29].HGT is also known to occur between viruses and their hosts [31], between mitochondria and the nucleus [3], and between tumor cells [55].
Since HGTs play a significant role in shaping evolution, several bioinformatics approaches have been developed to identify them.Most of these can be classified as either parametric or phylogenetic.Parametric methods are based on the sequence of one genome of interest and attempt to find DNA regions that exhibit a signature that is different from the rest of the genome (see [46]).Phylogeny-based methods consist of taking a set of taxa (e.g.genes and/or species), reconstructing their phylogenetic tree, and inferring the unseen transfer locations on the tree.A common way of achieving this is through reconciliation, which aims to explain the discrepancies between a gene tree and a species tree by finding where the gene duplication, loss, or transfer events occurred [6,16,27,14].Finding a most parsimonious reconciliation under this model is NP-hard [54,36,32], mainly because the inferred transfer locations need to be time-consistent, meaning that they must occur between species that may have co-existed.In addition, recent fundamental approaches propose to identify pairwise gene relationships to infer transfers.For instance, irregularities in the pairwise gene distances can pinpoint to possible transfers [51], or predictions of orthlogs, paralogs, and xenologs can help reconstructing a gene tree and a species network that explain these relationships [22,28,37,33].
The above approaches are all based on gene sequences in one way or another, either to reconstruct the phylogenies or to infer pairwise relationships.However, it is well-known that sequences have their limits for predicting HGT, especially in the case of ancient transfers [9].In this work, we ask whether character-based approaches can instead be used to predict HGT on a phylogeny.A character is a generic term to denote a trait that a taxa may possess or not, which can be morphological or molecular.A common example of character-based data is gene expression, where a trait corresponds to whether a species expresses a gene or not in a condition of interest [13,47,44].A major advantage of using gene expression profiles, and possibly other character traits, over sequence data comes when highly divergent sequences are involved.In [1], the authors used expression to recover phylogenetic signals better than using only sequence similarity measures.This could be because the necessary information to coordinate the folding or function of proteins is encoded in a small number of conserved fragments, in which case the two homologous proteins can share a small percentage of sequence similarity.This can be leveraged to detect HGTs that are hard to find using sequences, since one could hypothesize that two clades that started expressing the same gene independently could have acquired this behavior by transfer.
The task in this setting is, given a set of characters C and a set of taxa S that each possess a subset of C, to explain the diversity of S in a phylogeny.Ideally, S can be explained by a tree in which taxa that possess a common character form a clade, in which case the tree is called a perfect phylogeny [7,19,5,30].When no such perfect phylogeny exists, transfers may be required to explain the data.We point out that recently, character-based methods have resurfaced in tumor phylogenetics, where they are used to represent whether a tumor clone has acquired a somatic mutation or not [15,45,38,50].
Before gene expression and other character-based data can be used to predict HGT, appropriate models and algorithmic frameworks need to be devised.To our knowledge, character-based approaches have mostly been used to detect hybridation events, where two or more species recombinate to produce an hybrid offspring.In the most popular models, a set of taxa is explained by an ancestral recombination graph (ARG), which is a acyclic directed graph in which nodes with multiple parents represent hybrids, and nodes with a single parent represent vertical descent [57,26,25].The task of finding recombination events is different from that of finding HGTs.Recombinations create offsprings whose genetic content is merged from the parents without vertical descent being involved directly.As a result, there is no donor/recipient relationship.In the case of transfers, it is important to distinguish which traits were acquired vertically from the parent, and which traits were given by a donor.
Another model called perfect phylogenetic networks (PPN) was also introduced in [41,40] to study the evolution of languages, but can also be used for biological characters.To our knowledge, this is the first model that attempts to extend the notion of perfect phylogenies to networks.PPNs belong to the class of tree-based networks [21,43] which capture the idea of an underlying tree on which a set of transfer highways are "attached".The base tree indicates where vertical descent occurred and the attached transfer edges clearly show where genetic material could have been exchanged.In this model, the characters can have multiple states and a character is compatible if the network contains a tree in which the character is convex (i.e. the subgraph induced by nodes with the same state is connected).
Let us also mention that in [56], the authors propose a framework to explain gene evolution using HGT on general networks, in order to minimize the number of genes present in the same ancestral species.
Our contributions.We introduce perfect transfer networks (PTN), which are tree-based networks that can explain how each character was acquired/transferred in a given set of taxa.Our model is a direct generalization of perfect phylogenies to networks, as we use the same set of evolutionary rules.That is, we require that in the network, a character acquired by an ancestral species is never lost by its vertical descendants as in the Camin-Sokal parsimony model [11], and that each character has a unique origin.Additionally, a character can only be transferred horizontally on the edges that are explicitly labeled as transfers.It is worth mentioning that in [4], the authors study an HGT inference framework in which characters that admit a perfect phylogeny are ignored, whereas characters that do not are treated as evidence of transfers.Our work can be seen as an effort to formalize this idea.
We then study the structural and algorithmic aspects of PTNs.We first show that PTNs have two equivalent definitions that are both generalizations of perfect phylogenies.We then distinguish PTNs from recombination networks and from perfect phylogenetic networks by showing that some taxa sets are explained by different networks depending on the model.
As for the algorithmic aspects, we study three different problems.First, we ask whether a given treebased network can explain the characters of a set of taxa and provide a simple, polynomial-time algorithm for the problem.Second, we study the tree completion problem where, given a tree, we are asked to add transfers to it so that it explains the input taxa.We show that any tree can explain any set of taxa, even if the characters at the ancestral nodes of the tree are constrained by the input.Third, we study the reconstruction problem, where only the taxa are known and we must reconstruct a tree-based network with a minimum number of transfers that explains them.The algorithmic classification of this problem remains open, but we provide nearly exponential lower and upper bounds on the number of transfers required in the worst case, with respect to the number of characters.We then conclude with a discussion on open problems, including the problem of adding a minimum number of transfers to a tree to make it explain a set of taxa.

Preliminaries
In this section, we describe the standard phylogenetic notions used in the paper, and then define our perfect transfer network model.

Phylogenetic Networks and tree-based networks
For an integer n, we use the notation [n] = {1, . . ., n}.All graphs in this work are directed and loopless.A directed graph G is connected if the underlying undirected graph of G is connected.A binary phylogenetic network, or simply a network for short, is a directed acyclic graph G = (V, E) such that either |V | = 1, or such that G satisfies the following conditions: • there is a set of vertices with in-degree 1 and out-degree 0, called leaves.
• there is a unique vertex with in-degree 0 and out-degree 2, called the root.
• every other vertex has either in-degree 1 and out-degree 2 (tree nodes), in-degree 2 and out-degree 1 (reticulation nodes), or in-degree 1 and out-degree 1 (subdivision nodes).
We say that (u, v) ∈ E is a tree edge if v is a tree node or a leaf.Note that the usual definition of a network forbids subdivision nodes.We allow them only because it simplifies some of the definitions and proofs.
For a network G, we write ρ(G) for the root of G and L(G) for the leaves.If |V (G)| = 1, then we define ρ(G) as the single vertex of G and consider that L(G) = {ρ(G)}.If σ is a bijection from L(G) to a set S, we call σ an S-map for G, or just an S-map if G is understood.Now suppose that G is a directed graph, network or not.We say that u ∈ V (G) reaches a node v ∈ V (G) if there exists a directed path from u to v in G.We denote by R u (G) the set of nodes that u reaches in G, and we note that u ∈ R u (G).For a subset W of V (G), we denote by G[W ] the subgraph of G induced by W .We will also denote by G − W the graph obtained by the removal of W from V (G) and all of its incident edges.In other words, A tree T is a network whose underlying undirected graph has no cycles.We say that W ⊆ V (T ) forms a subtree of T if T [W ] is a tree.We say that a vertex v ∈ V (T ) is an ancestor of u ∈ V (T ) if v is on the path from ρ(T ) to u.In this case, we will call u a descendant of v.Note that v is an ancestor and descendant of itself.The ancestor order ⪯ T is a partial order in a tree T .When u ≺ T v we say that v is an ancestor of v and u is considered a descendant of v.In this partial order we have that the root ρ of T is the unique maximal element.We say that two nodes u and v are comparable if u ⪯ T v or v ⪯ T u.We say that they are incomparable otherwise.We will drop the subscript T when T is clear from the context.For v ∈ V (T ), we will use T (v) to refer to the subtree of T rooted at v (that is, T (v) contains v and all of its descendants).
A network G = (V, E) is a tree-based network [42] if G has no subdivision nodes, and there is a partition {E S , E T } of E such that the subgraph T G := (V, E S ) is a tree with the same set of leaves as G, which is called the support tree of G.The edges in E S are called support edges and the edges in E T are called transfer edges.Note that T G contains subdivision nodes, unless E T is empty.The tree obtained from T G by suppressing its subdivision nodes is called the base tree of G (suppressing a subdivision node u with parent p and child v consists of removing u and adding an edge from p to v).Roughly speaking, a tree-based network G can be obtained by starting with a tree and inserting transfer edges into it.Note that in most cases, the partition of the edges into E s and E T will be known (whereas tree-based networks merely require these to exist).When these edge sets are given, the network is sometimes called an LGT network, see [12].
As mentioned in the introduction, networks should be biologically-feasible in terms of time.We define a time consistent map over a tree-based network G with support edges E S and transfer edges E T as a function τ : V → R such that: We say that G is a time-consistent tree-based network if there exists a time consistent map for G [20].Note that the existence of a time-consistent map on a network implies that it is tree-based [39] (but the converse does not necessarily hold).In the following sections, we will assume that all the tree-based networks are time-consistent without explicit mention.

Perfect transfer networks
We now propose to extend the perfect phylogeny model to tree-based networks.Let S = {S 1 , S 2 , . . ., S n } be a set of taxa and C = {c 1 , c 2 , . . ., c m } a set of characters.We view a taxa S i as the set of characters that it possesses, so that for each i ∈ [n], S i is a subset of C. Our goal is to explain the character diversity of S using its evolutionary history.Given a tree-based network G with S-map σ, we want to know where each character appeared in G under the conditions that each character has a single origin, that it cannot be lost once acquired, and that it can be transferred.Throughout the phylogenetic literature, requiring a single origin is called the homoplasy-free assumption (or sometimes the "no parallel evolution" or "no convergent evolution"), which states that characters cannot arise independently in unrelated lineages [49,52].HGT is not considered to be a cause of homoplasy, but of course homoplasy can occur even in the presence of HGT.Nonetheless, this assumption has historically been used as a first step towards more complex models (see e.g.[48]).
To formalize this, given a tree-based network G, a C-labeling of G is a function l : V (G) → 2 C that maps each node of G to the subset of characters that it possesses (here, 2 C represents the powerset of C).For a character c ∈ C, we will denote by V c (l) = {v ∈ V (G) : c ∈ l(v)} the set of nodes that possess character c, and we denote by V c (l) = V (G) \ V c (l) the nodes that do not have it.If l is clear from the context, then we may simply write V c and V c .
Our evolutionary requirements are encapsulated in the following definition.
Definition 1 (Perfect transfer networks).Let S be a set of taxa on characters C, let G = (V, E S ∪ E T ) be a tree-based network, and let σ be an S-map for G.We say that a C-labeling l of G explains S if the following conditions hold: • for each support edge (u, v) ∈ E S , c ∈ l(u) implies that c ∈ l(v) (never lost once acquired); • for each c ∈ C, there exists a unique node v ∈ V c (l) that reaches every node of Furthermore, we call the pair (G, σ) a perfect transfer network (PTN) for S if there exists a C-labeling of G that explains S.
See Figure 1.2 for an example of a PTN.Later on in Theorem 1, we will show that Definition 1 is similar, though slightly different, to a connectedness requirement known as convexity on each character, see [25].Notice that if G is a tree, then every edge is a support edge and Definition 1 coincides with the definition of a perfect phylogeny from [25].If G = (V, E S ∪ E T ) is a tree-based network, the definition does not explicitly state what can or cannot be done with transfer edges.The way to see this is that the definition does not forbid ancestral taxa from using transfer edges.That is, if (u, v) ∈ E T , then u can transmit any subset of its characters to v horizontally.The motivation behind the requirements of Definition 1 is to model the presence and absence of traits that have unique origins and cannot be lost throughout evolutionary processes.Examples of such traits include transposable elements (TEs) which are unique genomic sequences that have integrated into the genome and are rarely lost [10], biochemical markers such as metabolites which are small molecules that function as intermediates and products of metabolic processes [2], and emergence of organelles such as mitochondria or chloroplasts that results from endosymbiotic events and is irreversible [59,3].It is worth highlighting that the horizontal transfer of TEs between species is a prevalent phenomenon that significantly contributes to their sustained viability over time [58].As for metabolites, it has been previously shown that HGT plays a role in the generation of new metabolic pathways in bacteria [23].
We are interested in the following algorithmic problems: • The PTN-recognition problem: given a tree-based network G with S-map σ, is (G, σ) a PTN for S? That is, does there exist a C-labeling of G that explains S? See Figure 1.4 for an example of a network that is not a PTN.
• The tree-completion problem: given a tree T with S-map σ, does there exist a PTN (G, σ) for S such that T is the base tree of G? See Figure 1.2.We are also interested in the minimization variant of this problem, where we require that (G, σ) has a minimum number of transfer edges.See Figure 1.3.
• The PTN-reconstruction problem: given a set of characters C and a set of taxa S, find a PTN (G, σ) for S with a minimum number of transfer edges.
We show that the recognition problem can be solved in time O(|C||V (G)| 2 ).For the tree-completion problem, we provide a more general result: any tree with any given pre-labeling can explain any set of taxa.To be more specific, for any given tree T and any C-labeling of T that satisfies the never lost once acquired condition, one can always explain S by adding transfers in a time-consistent manner while preserving the given labeling.This motivates the need for the minimization variant, which leads to several open problems.For the tree reconstruction problem, we give exponential lower and upper bounds on the number of transfers required by a set of k characters, in the worst case.

Properties of the perfect transfer model
Before delving into the algorithms, we study our model a bit more in-depth.First, we provide an alternate definition of perfect transfer networks in terms of character connectedness.This definition is sometimes easier to deal with in our proofs, and is akin to perfect phylogenies that also admit a similar equivalent definition.Second, we ensure that our model does not reinvent the wheel by explicitly stating its differences with other models.
Theorem 1.Let G = (V, E S ∪ E T ) be a tree-based network with S-map σ.Then a C-labeling l of G explains S if and only if the following conditions hold: ] is connected and contains a unique node of in-degree 0; ] is connected and contains ρ(G).
Proof.(⇒) Suppose that l is a C-labeling of G that explains S, according to Definition 1.We argue that the three conditions stated in the theorem are true.By Definition 1, ] is connected since v reaches all of its nodes.If V c (l) is empty, then the third condition also holds, so assume this is not the case.Let us now focus on T G [V c (l)].Observe that because characters are never lost once acquired, l satisfies the property that for every (u, w) is connected because all of its nodes have a path to ρ(G).
(⇐) Suppose that l satisfies all the conditions of the theorem.We show that all properties of Definition 1 hold.For each v ∈ L(G), we know that l(v) = σ(v).For the other conditions, let c ∈ C. First suppose for contradiction that there is a support edge Thus the condition of never losing acquired characters holds.Now let v be the unique node of ] is acyclic, P u must contain a node w of in-degree 0, contradicting that v is the unique node of in-degree 0. Thus v reaches every node in G[V c (l)] and, because it has in-degree 0, it is the unique such node.Thus the single origin condition is satisfied.

Perfect transfer networks versus perfect phylogenetic networks
Before we move on, it is important to put our model in perspective with Perfect Phylogenetic Networks (PPN), which, to our knowledge, are the closest to our work.The idea of a PPN is that a network contains several evolutionary trees, and a character could evolve in any one of those trees.More specifically, in the PPN model, characters are multi-state, so that a character can be in any of the set of possible states Z.A character c is compatible with a tree T whose leaves are labeled by the states of c if there is a state-labeling of the internal nodes of T such that, for each z ∈ Z, the nodes in state z form a connected subgraph of T .Given a network G and a tree T , we say that T is displayed by G if T can be obtained by successively removing reticulation edges and suppressing subdivision nodes.A tree-based network G is a PPN for a set of characters C if each character is compatible with some tree displayed by G.In terms of character evolution, for PPNs every state is subject to the same evolutionary constraints.In contrast, the character evolution model implied by PTNs represents "presence" and "absence" of a trait, and these two states have different behavior.This difference plays an important role for transfer edges.The PTN model explicitly prohibits the transfer of an "absence" state, whereas for PPNs any state is allowed to be transferred.See Figure 2 for an example of a tree-based network that is a PPN, but not a PTN (if the state 0 is interpreted as absence).A tree displayed by G that admits a labeling such that every state forms a connected component.Note that this tree can be obtained by the removal of the green edge and suppression of the resulting subdivision node.The interpretation of this scenario is that state 0 was transferred using the birectional edge.On the other hand, a solution for PTNs would forbid the transfer of state absence, and would also disregard the removal of the green edge, in which case no C-labeling is possible.
Also note that it is NP-hard to decide whether a given network G is a PPN for a given set of characters C [40].Later on, we will show that the analogous recognition problem for PTNs can be solved in polynomial time.However, our result holds for binary character states and the hardness proof for PPNs relies on the character states being non-binary, and it is unclear whether the hardness is preserved for binary character states.

Perfect transfer networks versus recombination networks
Another model with goals that are similar to ours are recombination networks.In this model, the indices of the characters C = {c 1 , . . ., c m } determine an ordering of the characters.For a string B, B[j] denotes its j-th character and B[i..j] its substrings containing positions from i to j.Each taxa S i ⊆ C can be represented as an m-bit string β(S i ) in which β(S i )[j] = 1 if and only if S i possesses character c j .Given an m-bit string B and an odd integer d, we say that B is a d-crossover of two other m-bit strings X and Y if there are indices i , and the following holds: • for each reticulation node v with parents u and w, f (v) is a d-crossover of f (u) and f (w); • for each tree edge (u, v), f (v) is obtained from f (u) by flipping some 0 positions to 1 (we may decide to flip none); We say that (G, σ) is an ancestral recombination graph (ARG) for S with d-crossovers if there exists a binary C-labeling of G that explains S with d-crossovers.We denote by ARG d (S) the set of all ARGs for S with d-crossovers.We also denote In the literature, single crossovers are modeled with d = 1 and have been studied extensively.The d = 2 case is often referred to as double crossovers and can also model gene conversion.It was stated in [25] that d > 6 is rarely considered in practice.
The most obvious difference between ARGs and PTNs is that ARGs were introduced to model hybridation events, whereas we created PTNs to model horizontal gene transfer.More specifically, ARGs do not differentiate between the two parents of a reticulation node, whereas in our model, one parent only transmits genetic content via vertical descent whereas the other does so via HGT.In fact, ARGs do not need to be tree-based networks.Although this is a fundamental difference, it is also interesting to ask whether, among the class of tree-based networks, the data explanation depends on the model.
To formalize this, we write P T N (S) for the set of perfect transfer networks for S. The next result shows that ARGs with d-crossovers are incomparable with PTNs unless we allow an arbitrary number of crossovers.We emphasize that even though infinite crossovers can emulate transfers, they still cannot distinguish vertical from horizontal inheritance.
(all odd c j 's) Proposition 1.The following relationships between PTNs and ARGs hold: • for any fixed d ≥ 1, there exists a set of taxa S on d + 2 characters such that P T N (S) \ ARG d (S) is non-empty; • there exists a set of taxa S on two characters such that ARG 1 (S) \ P T N (S) is non-empty; • for any set of taxa S, P T N (S) ⊆ ARG ∞ (S).
Proof.For (1), consider the network G in Figure 3.1.For any C, the labeled network shows that (G, σ) is in P T N (S).Put C = {c 1 , . . ., c d+2 }.We argue that (G, σ) is not in ARG d (S).Note that in any binary C-labeling of G that explains S, the parent of each ∅ leaf taxa must be the string 00 . . .0, as otherwise they would need to transmit a 1 to these leaves.Likewise, the parent of the upper C leaf taxon must be 11 . . . 1.If not, there would be a 0 − 1 flip on the edge leading to the upper C. But, we would also need another 0 − 1 flip somewhere on the path to the lower C taxon, which is not allowed in ARGs.So, the parents of the single reticulation have labels 00 . . .0 and 11 . . . 1.Moreover, the root is labeled 00 . . .0, and thus all the possible 0 − 1 flips occur between the root and its right child.We cannot have any new 0 − 1 flip, and so the reticulation must be labeled 0101 . . .01 to be able to transmit the required characters to the odd-characters leaf (or the last character is 0 if d is even).Whether d is odd or even, there are d + 2 characters and we must alternate each of them between the parents.This requires d + 1 crossovers, and so (G, σ) / ∈ ARG d (S).For (2), consider the network G in Figure 3.2.There are only two characters c 1 , c 2 .The right side of the figure shows that G can be explained under single crossovers.However, we can argue that (G, σ) is not a perfect transfer network.This is because if there is a C-labeling l that explains the taxa at the leaves, the parent of each c 1 leaf must contain c 1 .But by the never lose once acquired condition, c 1 should then be transmitted vertically to the leaf that has no character, a contradiction.Thus (G, σ) / ∈ P T N (S).For (3), let (G, σ) ∈ P T N (S).Let l be a C-labeling of G that explains S. To show that (G, σ) ∈ ARG ∞ (S), we need to modify l slightly.Specifically, we ensure that characters never have their firstappearance on a reticulation node.Let v be a reticulation node of G with parents u, w such that (u, v) is a support edge and (w, v) is a transfer edge.Suppose that there is c j ∈ C such that c j / ∈ l(u), c j / ∈ l(w), but c j ∈ l(v).It follows from Theorem 1 that v is the unique node of in-degree 0 in G[V cj (l)].Consider the labeling l ′ obtained by taking l, but applying l ′ (v) = l(v) \ {c j }.Let v ′ be the unique child of v.One can easily see that G[V cj (l ′ )] is connected and that v ′ is its unique node of in-degree 0.Moreover, and it still contains the root.Hence by Theorem 1, l ′ also explains S.
By applying the above argument to every character, we obtain a labeling l that explains S such that for any character c j , the first-appearance of c j under l does not occur at a reticulation node.Assume that l has this property.
Consider the binary C-labeling f of G in which, for each v ∈ V (G), we put f (v)[j] = 1 if and only if c j ∈ l(v).We claim that f explains S with m-crossovers, where m = |C|.First consider a reticulation node v with parents u and w, where (u, v) is a support edge and (w, v) is a transfer edge.We must argue that f (v) is an m-crossover of f (u) and f (w).Because under l, no character first-appears on a reticulation, we have that for each c j ∈ l(v), either c j ∈ l(u) or c j ∈ l(w).Moreover, for each c j / ∈ l(v), we must have c j / ∈ l(u) (by the never lost once acquired condition).In terms of f , this means that for each j ∈ [m], if f (v)[i] = 1 then one of u or w also has a 1 in position j, and if f (v) = 0, then f (u)[j] = 0.It follows that f (v) can be obtained with at most m crossovers from its parents.
Next, we argue that for each character c j , there is at most one tree edge (u, v) that flips c j from 0 to 1 under f .If there were two such edges, then under l, there would be two trees nodes that possess c j but not their (unique) parent.Thus G[V cj (l)] would have two nodes of in-degree 0, contradicting Theorem 1. Third, the condition that characters are not lost after being acquired implies that, for every tree edge (u, v), f (v) can be obtained from f (u) by flipping 0s to 1s, but not vice-versa (this follows from the fact that tree edges are support edges).Thus, f explains S and we conclude that (G, σ) ∈ ARG ∞ (S).

Algorithmic Problems
We now study the algorithmic aspects of recognition, completion, and reconstruction of PTNs.

Recognizing perfect transfer networks
The first problem in this section is analogous to the perfect phylogeny problem, where we must find a labeling of all the inner nodes so that the network correctly represents the evolution of a given set of species.This is not as trivial as in the tree case, since their may be multiple options for the originator of a character c ∈ C.

The PTN recognition problem
Input.A set of taxa S on characters C and a tree-based network G = (V, E S ∪ E T ) with S-map σ.Output.A C-labeling of G that explains S, if one exists.Importantly, the above problem formulation lets us assume that we have knowledge of support and transfer edges.We first need some intermediate results (recall that T G is the support tree of G).
Lemma 1.Let G = (V, E S ∪ E T ) be a tree-based network with S-map σ, and let l be a C-labeling of G that explains S. Let u ∈ V c (l).Then for each ancestor v of u in T G , we have v ∈ V c (l) as well.
Proof.Suppose that u ∈ V c (l) has an ancestor v in T G such that v ∈ V c (l).Consider the unique path of T G from v to u, namely the sequence (v, v 1 , v 2 , . . ., v k , u).Due to the never lost once acquired requirement of Definition 1 {v 1 , v 2 , . . ., v k } ⊆ V c (l).In this way the edge (v k , u) will represent the loss of character c, a contradiction.
In other words, any node that has at least one descendant in V c (l) should be in V c (l) in every possible C−labeling l that explains S. Since we must have l(v) = σ(v) for each leaf v, we can already deduce that if v is a leaf such that c / ∈ σ(v), then no ancestor of v in the support tree can possess c.This is a property similar to character state changes in the Camin-Sokal parsimony method [18].We thus define the following subset of nodes that are forced to not have c: If G and σ are clear from the context, we will write F c instead of F c (G, σ).Recall that for a network G, R v (G) denotes the set of nodes reachable from v. The following characterization of PTNs will let us recognize them easily.
Lemma 2. Let G be a tree-based network with S-map σ.Then (G, σ) is a perfect transfer network for S if and only if for every character Proof.(⇒) Let l be a C−labeling of G that explains S, and let c ∈ C. By Lemma 1, we must have F c ⊆ V c (l).The resulting graph G − F c thus contains all the nodes in V c (l). Due to the single origin requirement of our definition, G − F c contains a node v that is able to reach all the leaves in V c (l), which includes all the leaves of G − F c .
(⇐) To show the converse, we build a C−labeling l in the following way: for every c ∈ C, let v be a node such that its reachable set in G − F c contains every leaf in L(G − F c ), and let us call v the origin of c.Then for u ∈ V (G), we put c ∈ l(u) if and only if u ∈ R v (G − F c ).That is, the origin of c is v and it is transmitted to every node that v reaches in G − F c .We claim that l satisfies all the conditions of Theorem We now argue on the connectedness requirements of the G[V c (l)] subgraphs.Again, let c ∈ C and let v be the chosen origin of c in l.Since V c (l) consists of nodes reachable from v, it is evident that v will be the only node in ] is also connected, since we cannot disconnect the V c (l) subgraph by putting back the nodes of F c .
It remains to argue the third condition of Theorem 1.First assume that the origin v of c is equal to ρ(G).Then every leaf must possess c, as otherwise if some leaf u would satisfy c / ∈ σ(c), then u ∈ F c and the root would also be in F c , by its definition.It follows that F c is empty.Then our construction puts V c (l) = V (G) since ρ(G) reaches every node in G − F c = G.In this case, the third condition of the theorem holds.So we may assume that v ̸ = ρ(G).In this case, v does not reach ρ(G) in G − F c since no node reaches the root (except the root itself).Thus we may assume that V c (l) ̸ = ∅ and contains the root.Suppose for a contradiction that . Then in T G , u has an ancestor w ∈ V c (l), which implies that the origin, v, can reach w in G − F c .This implies that w / ∈ F c , which in turn implies that no node from w to u in T G can be in F c .This means that the path from w to u exists in G − F c .Thus in G − F c , v reaches u through w, and so our construction of l would have put c ∈ l(u), a contradiction.Hence, T G [V c (l)] is connected and contains ρ(G).
The proof of the previous lemma implies the following verification algorithm: while l not NULL and C is not empty do Pick a character c ∈ C.
Let X be the set of all nodes in G c with in-degree 0.  Proof.We first argue that the algorithm is correct.By Lemma 2, it suffices to check, for every c ∈ C, that some node v reaches every leaf in G − F c .Moreover, when this is the case, the proof of Lemma 2 shows that we can add c to every node in R v (G − F c ) to obtain a labeling that explains S. If the algorithm finds such a v, this is exactly the labeling that it applies.So we must argue that when such a v exists, the algorithm will find it.
For that, we claim that the verification in line 12 of Algorithm 1 is enough to find the node required by Lemma 2. That is, we do not need to check every node v of G c = G − F c , but only those in the set X, i.e. the nodes of in-degree 0. Suppose that there is y ∈ V ( G c ) that reaches every leaf in L( G c ).If y ∈ X, we are done.Otherwise, because G c is acyclic, there must be v ∈ X that reaches y (it can be found by following by iteratively following in-neighbors starting from y until such a node is reached).It follows that R y ( G c ) ⊆ R v ( G c ) and that v also reaches every leaf.Thus, it suffices to check every source in G c .
Let us now argue the complexity.

The tree-completion problem
We now turn to the problem of predicting transfer locations on a given species tree.As mentioned in [42], species trees depict vertical inheritance and thus serve as basis for our networks, and HGT events can be seen as additional evolutionary events that happen on the way.This motivates the feasibility question: given a set of taxa S and a species tree T on S, can we add transfer arcs to T so that the resulting network explains S? Moreover, can we do this so that the resulting network is time-consistent?One possibility is that a universal tree-based network, which contains all phylogenetic trees on a given set of n leaves [8], could explain any set of characters.However, a base tree needs to be specified in our model, and it is not clear that such a choice always exists in a universal network.
Nevertheless, it turns out that there is no feasibility problem.Indeed, it is relatively easy to show that, for a set of taxa S, any tree T on S can be complemented with transfers to become a PTN.One way to achieve this is to add a transfer edge between the parent edge of every pair of leaves, from which point it can be argued that the network is a PTN.In fact, we can show a stronger statement: if T is "pre-labeled" in any way that acquired characters are never lost, then we can add transfers to T to explain S while preserving the given pre-labeling.
Formally, for a tree T , a C-labeling λ of T is called a no-loss C-labeling if, for any edge (u, v) ∈ E(T ) and any c ∈ C, it holds that c ∈ l(u) implies c ∈ l(v).Recall that if G is a tree-based network, then the base tree T of G is obtained by removing transfer arcs and suppressing subdivision nodes.Hence, V (T ) ⊆ V (G), and we use V (G) ∩ V (T ) to explicitly refer to the nodes of G that are also in the base tree.We have the following problem.
The Pre-labeled Tree Completion problem Input.A set of taxa S on characters C, a tree T with S-map σ, and a no-loss C−labeling λ of T such that λ(v) = σ(v) for each v ∈ L(T ).Output.A time-consistent tree-based network G such that T is the base tree of G, and a C-labeling l of G that explains S and such that l(v) = λ(v) for every v ∈ V (G) ∩ V (T ).
We will now prove that this is always possible, even with the time-consistency constraint.One interest of allowing a pre-labeling is that one can start with any hypothesis on where the characters appeared on a tree, and transfers can explain that hypothesis.Perhaps the most natural pre-labeling is the Fitch-like labeling where, for each character c, we add c in every maximal subtree whose leaves have the character.To be more specific, if v is a leaf, λ(v) = σ(v) and otherwise, let u, w be the children of v, then λ(v) = λ(u) ∩ λ(w).This corresponds to the reasonable hypothesis that characters always appear at maximal clades that have it, and we provide and algorithm that can explain this.Again, this is one example of a possible pre-labeling, and our algorithm can explain any other that has the no-loss property, even if characters are again after the lowest common ancestor of the leaves that have this character.
We define a transfer operation between two nodes u and v on a tree-based network G.We write G▲(u, v) to denote the tree-based network obtained by subdividing the respective incoming edges of u and v in T G , thereby creating new parent u ′ for u and v ′ for v, and adding the transfer edge (u ′ , v ′ ).
It is important to point out that in a no-loss labeling, there can be multiple ancestral species that acquire a specific character that for the first time.In our algorithm, this property will also be maintained in the constructed network, and we will use the following notion: Definition 2. Let G be a tree-based network with a no-loss C−labeling λ.Let (u, v) be an edge of T G .We will say that v is a first-appearance node for c under λ if it holds that u ∈ V c (l) and every descendant of v in T G belongs to V c (l).
We may say first-appearance for c if λ is clear from the context.Note that if λ is a no-loss labeling, a first-appearance node for c cannot have a first-appearance node for c as a descendant, and hence firstappearance nodes are pairwise incomparable.
We can now describe our algorithm.The first step is to make G a copy of the given tree T , and then we add transfer edges to G. Note that in our problem, the given tree has no time map, and deciding where to put the transfers on T in a time-consistent manner becomes surprisingly complicated.For this reason, before adding any transfer, we start by constructing a time consistent map τ for G.It is easy to do this in such a way that no two vertices have the same time.
From that point, we look at each character c and their set of first-appearance nodes a 1 , . . ., a k , ordered in decreasing order of age, and we greedily connect them using transfers.The τ that we constructed dictates the order of connections, in the sense that each a i is assumed to transfer c to the younger a i+1 node.This is achieved by finding a descendant of a i that could have co-existed between a i+1 and its parent.The τ map is also used to assign a time to the nodes created by transfers.
Let τ be a time-consistent map for G in which every leaf v has τ (v) = 0 and every internal node has a distinct time.Compute A c , the set of first-appearance nodes of character c in T G . 7 Let X c = (a 1 , a 2 , . . ., a k ) be the ordering of Apply the transformation G▲(w, a i+1 ).
Let ŵ and âi+1 be the new parents of w and a i+1 , respectively, in Algorithm 2: Place an edge between all the first-appearance trees.
Lemma 3. The network returned by Algorithm 2 is time-consistent under the time map τ .
Proof.We argue that at any moment during the execution of the algorithm, τ is a time-consistent map of G.We prove this by induction on the number of iterations undertaken.Notice that as a base case, the statement is initially true before entering the main for loop.Now assume that we have inserted j − 1 transfer edges and that τ is time-consistent for G after these insertions.Consider the j-th transfer edge inserted into G.This transfer edge is ( ŵ, âi+1 ), which are created between w and its parent w ′ in the support tree T ′ , and between a i+1 and its parent a ′ i+1 in T ′ , respectively.We first claim that (w ′ , w) as used in the algorithm exists in the subtree T (a i ), where a i is the node that precedes a i+1 in X c .We know that τ (a i ) ≥ τ (a i+1 ).Suppose that τ (a i ) = τ (a i+1 ).Let a ′ i be the parent of a i , then by induction hypotesis, since the network is time consistent we have that τ (a ′ i ) > τ (a i ) = τ (a i+1 ) and so w ′ = a ′ i and w = a i .In this case, we do have τ (w ′ ) > τ (a i+1 ) and τ (w) ≤ τ (a i+1 ).Now, suppose that τ (a i ) > τ (a i+1 ).Note that we can always order the vertices of T (a i ) with respect to τ in such a way that τ (a i ) ≥ v for all v ∈ V (T (a i )).By induction hypothesis, every time we pick a descendant y of a i , τ (y) < τ (a i ), so w can be found by iteratively following the descendants of a i and choosing the first one whose time is at most τ (a i+1 ) (which exists since all leaves have the same timing).Note that by adding the transfer edge ( ŵ, âi+1 ), the times τ of every edge have remained unchanged and still satisfy the time-consistency definition, with the exception of the edges linking w ′ , ŵ, and w, those linking a ′ i+1 , âi+1 , and a i+1 , as well as the new transfer edge.Since τ ( ŵ) = τ (â i+1 ) is made explicit on line 16, to conclude the proof it suffices to show that τ (w ′ ) > τ ( ŵ) > τ (w) and that τ (a ′ i+1 ) > τ (â i+1 ) > τ (a i+1 ).By induction we know that τ (w ′ ) > τ (w) and that τ (a ′ i+1 ) > τ (a i+1 ) (this holds before and after the transfer insertion because they were not changed).Using these inequalities we have that: since min(τ (w ′ ), τ (a ′ i+1 )) ≤ τ (w ′ ) and τ (a i+1 ) < τ (w ′ ) both hold.Note that it is also true that ) and τ (a ′ i+1 ) > τ (a i+1 ) both hold).Using the same arguments, we have and Let G and l be the network and C-labeling returned by Algorithm 2, respectively, on input T, S, and λ.Then T is the base tree of G. Furthermore, l explains S and satisfies l Proof.Let G = (V, E S ∪ E T ) be the network returned by the algorithm and let l be the returned labeling.
To see that l(v) = λ(v) for every node v in the base tree, it suffices to note that the algorithm never changes the labeling of a node initially present in T : it only assigns sets of characters to nodes created by transfer insertion operations.It is also easy to see that T is the base tree of G, since we start with a copy of T and only attach transfer edges to it.We will argue that the returned C−labeling l explains S using the conditions required by Definition 1. First, by requirement on the input λ, we know that for every Let us next show that for every character c ∈ C there exists a unique node v ∈ V c (l) that reaches every node in G[V c (l)].It is not hard to see that after handling a particular c ∈ C in the algorithm, this property will be satisfied for V c (l).However, it is not obvious that the subsequent iterations on other characters will not "break" this property for c.We thus prove the following statement.Assume that the algorithm handles the characters of C in order c 1 , . . ., c m in the main while loop.Then we claim that in the network G obtained after finishing the i-th iteration and handling c 1 , c 2 , . . ., c i , for every j ≤ i, there exists a unique node v ∈ V cj (l) that reaches every node in G[V cj (l)].This shows the desired property since it will hold for j = m, i.e. for every character.As a base case, consider i = 0. Then it is true that for j ≤ i, the desired node v exists (because there is no c j to satisfy).Now, assume that i > 0 and that before entering the i-th iteration, the statement holds for every c j with j ≤ i − 1.After we are done handling c i on the i−th iteration we know that there exists a vertex a 1 ∈ X ci such that τ (a 1 ) ≥ τ (a h ) for all a h ∈ X ci .In particular, when equality holds for some a h , it must be that τ (a 1 ) = τ (a 2 ).In this case, when the algorithm iterates on a 1 , we get (w ′ , w) = (a ′ 1 , a 1 ) and the corresponding transformation yields G▲(a 1 , a 2 ).In this case, we claim that the vertex â1 created by the subdivision of the edge (a ′ 1 , a 1 ) ∈ E s will remain as the unique source for V ci (l).To see this first note that a 1 has no incoming edge from V c (l) at the start of the iteration, because if that was not the case then c ∈ l(a ′ 1 ) and so a 1 would not have been a first-appearance node in the first place.This in turn implies that â1 has no incoming edge after the i-th iteration, since all other transfer heads are added above a 2 , . . ., a k .Additionally, â1 will become the first-appearance node for its corresponding subtree.After applying G▲(a 1 , a 2 ), â1 now reaches the new parent â2 of a 2 and all its descendants in T G .Subsequently, we will now choose a descendant w of a 2 from which we will add a new transfer to the parent node â3 of a 3 .In this way, â1 will also reach a 3 and all of its descendants.We will continue adding transfer operations in this way so that finally â1 will be able to reach the last vertex of X cj , a k and all of its descendants.Note that any node of V ci (l) is reachable by an element of A ci , thus after the i−th iteration â1 reaches every node in the G[V ci (l)] subgraph.
On the other hand, when we have the strict inequality, i.e. when τ (a 1 ) > τ (a 2 ), then the first chosen w is distinct from a 1 , and using the same arguments, we see that a 1 is the unique origin for V ci (l).
We must also argue that the i-th iteration does not "break" a c j with j < i.Consider such a c j .By induction, before the i-th iteration, G[V cj (l)] had a unique origin v. Suppose that during the i−th iteration of the main loop we created some transformation G▲(w, a h ) after which some node, say z, that possesses c j cannot be reached by v in the transformed graph.Let w ′ , a ′ h be the parents of w and a h , respectively, before the addition of the transfer.Also let ŵ and âh be the nodes which were created by this transformation.
First assume that z = ŵ.Then c j / ∈ l(w ′ ), as otherwise if c j ∈ l(w ′ ), by induction, v would reach w ′ and thus also reach ŵ = z.But because c j / ∈ l(w ′ ), c j / ∈ l(w ′ ) ∩ l(w) and so the algorithm would not have put c j in ŵ = z, a contradiction.By the same argument, z ̸ = âh .Thus, z was present in G before the insertion of the transfer.
Next, assume that c j / ∈ l( ŵ) and c j / ∈ l(â h ).If v cannot reach z anymore, every path from v to z in G[V cj (l)] must have been going through (w ′ , w) or (a ′ h , a h ) before the transfer insertion.But then, c j ∈ l(w ′ ) ∩ l(w) and c j ∈ l(a ′ h ) ∩ l(a h ), and the algorithm would have put c j ∈ l( ŵ) and c j ∈ l(â h ), a contradiction.
Then either c j ∈ l( ŵ), c j ∈ l(â h ) or c j ∈ l( ŵ) ∩ l(â g ).Assume c j ∈ l( ŵ).By line 15, we know that this would only be possible if c j ∈ l(w ′ ) ∩ l(w).So any path from v to z in V cj (l) that used the (w ′ , w) edge can now use the edges (w ′ , ŵ), ( ŵ, w) to reach z.If c j ∈ l(â h ) as well, the same idea applies, and we get that any path from v to z is still usable, albeit with either ŵ or âh as an additional vertex.So it must be that c j / ∈ l(â h ), and that all paths used (a ′ h , a h ).As before, this means that c j ∈ l(a ′ h ) ∩ l(a h ) and that we should have c j ∈ l(â h ), a contradiction.This covers the case c j ∈ l( ŵ).The case c j ∈ l(â h ) can be handled in the same manner.
We then show that for each support edge (u, v) ∈ E S , c ∈ l(u) implies that c ∈ l(v).We argue that this property holds before and after any transfer edge is inserted.Notice that initially, when G is just a copy of T and l a copy of λ, c ∈ l(u) implies c ∈ l(v) because λ is a no-loss labeling.Now suppose inductively that the property holds before we insert some transfer ( ŵ, âi+1 ) by line 13.It suffices to argue that the property holds on the support edges (w ′ , ŵ), ( ŵ, w), (a ′ i+1 , âi+1 ), and (â i+1 , a i+1 ), as defined in the algorithm, because no other support edge is modified.Let c ′ ∈ l(w ′ ) (we distinguish c ′ from c, the latter being the c the algorithm is currently iterating on).Then by assumption that the property held before the transfer addition, we must have c ′ ∈ l(w) and, because c ′ ∈ l(w)∩l(w ′ ), c ′ will be added to l( ŵ), as desired.The same argument holds for c ′ ∈ l(a ′ i+1 ) and the fact that c ′ ∈ l(â i+1 ).Now let c ′ ∈ l( ŵ).We want to argue that c ′ ∈ l(w).If c ′ ∈ l(w ′ ), then again by assumption we have c ′ ∈ l(w) as well and our property holds.So suppose that c ′ / ∈ l(w ′ ).The algorithm puts l( ŵ) = (l(w) ∩ l(w ′ )) ∪ {c} where c is the character of the current iteration, which means that only c = c ′ is possible.Notice that the algorithm chooses the edge (w, w ′ ) in the subtree T G (a ′ i ), where a ′ i has child a i that is a first-appearance node for c.By assumption, every descendant of a i in the support tree possesses c, so only w ′ = a ′ i is possible.Thus w = a i and c ∈ l(a i ) = l(w), as desired.Finally, let c ′ ∈ l(â i+1 ).If c ′ ∈ a ′ i+1 , by assumption c ′ ∈ l(a i+1 ) and we are done.Otherwise, as the previous case we must have c ′ = c and, since a i+1 is a first-appearance for c, we have c ∈ l(a i+1 ) as desired.Proof.By Lemma 3, the network G output by the algorithm has T as its base tree and is time-consistent.Then by Lemma 4, the output labeling l preserves the pre-labeling λ and explains S. Thus, the output is correct.
As for the running time, the complexity is dominated by the main while loop over c ∈ C. Note that first-appearance nodes partition the leaves of G[V c (l)], and so each A

On minimizing the number of transfers in a completion
We have shown that any tree whose leaves are mapped to S can explain S. The tree completion therefore becomes more interesting in the minimization variant: The Minimum Perfect Transfer Completion problem Input.A set of taxa S on characters C, a tree T with S-map σ.Output.A PTN (G, σ) for S whose base tree is T that contains a minimum number of transfer edges.Note that the above problem does not impose a pre-labeling of T .However, one such labeling λ that is natural is the one where maximal subtree containing a character are assigned that character, which we call the Fitch labeling.(2) One possible solution output by Algorithm 2. The left clade is chosen to originate a and a transfer is greedily added above all the a's on the right side.Then, the left clade is also chosen to originate b, but for that two more separate transfers are added.(3) A solution that is somewhat less natural, but with one less transfer.
The cases in which Algorithm 2 is suboptimal appear to have a common cause.The algorithm tends to add transfers as high as possible in the tree, whereas the optmal solution would add more transfers lower in the tree, but with the advantage of being reusable by more characters.For instance in Figure 5, a is greedily transferred by itself and two more separate transfers are required for b, whereas the optimal solution reuses the same transfers for both a and b.It appears difficult to determine when to add more transfers lower and when not to, which leads us conjecture that the Minimum Perfect Transfer Completion is NP-hard.
We must reckon that a |C|-approximation is far from interesting.We conclude by suggesting a candidate approximation algorithm that combines both algorithms presented here.Suppose that, given T and Fitchlabeling λ, we obtain G and l from Algorithm 2. A simple heuristic post-processing step can then be applied to detect unneeded transfers.That is, for each transfer edge (u, v) of G, consider the network G − (u, v) obtained by removing (u, v) and the resulting subdivision nodes.Then, run Algorithm 1 to check if G − (u, v) is a PTN for S. If so, we know that (u, v) can safely be removed and we repeat.We try every such transfer edge until all of them are necessary.With this modified algorithm, we were unable to generate instances with more than twice as many transfers as the optimal solution.This suggests that it might not be far from optimal.We conjecture that Algorithm 2, combined with the above post-processing step, achieves a constant factor approximation.

The PTN reconstruction problem
We now study the variant in which only S and C are known, and no tree is given.Note that by Theorem 3, there is no feasibility problem, since a solution always exists.That is, we can take any tree T with any S-map σ, run Algorithm 2 using the Fitch-labeling, and obtain a PTN for S. The minimization variant has more appeal.
The Minimum Perfect Transfer Reconstruction problem Input.A set of taxa S on characters C; Output.A PTN (G, σ) for S with a minimum number of transfer edges.This does not appear to be an easy algorithmic problem.Proposition 2 suggests a (seemingly) simple approach: find a tree that minimizes the total number of first-appearance nodes, over all characters.This does not guarantee that the resulting network will minimize transfers, and even finding a tree that minimizes the number of first-appearance nodes appears hard to find.We conjecture that both problems are NP-hard, i.e. finding a PTN (G, σ) for S with a minimum number of transfers, and finding a tree with S-map σ with a minimum number of first-appearance nodes.
In the following, we instead focus on providing bounds on the number of transfers required if k := |C| characters are present, in the worst case.It should be intuitive that the taxa set that will require the most transfers is when S = 2 C , i.e. S is the power set of C. When this is the case, we show that, up to a linear factor, an exponential number of transfers (with respect to k) is required and sufficient.Lemma 5. Any set of taxa S on a character set C of k characters can be explained by a tree-based network G that has at most 2 k − (k − 1) transfers.
Proof.Let S be a set of taxa on characters C = {c 1 , c 2 , . . ., c k }.We will assume that no two elements of S are identical (as two identical taxa can use the same transfers).We will further assume that S = 2 C contains every subset of C. Note that if we can explain S with at most 2 k − (k − 1) transfers, then we can explain any S ′ ⊆ S with at most that many transfers.We will first show how to construct a base tree T 0 1 0 0 0 0 0 0 for G from which we will then derive G. Let T be a rooted complete binary tree with exactly 2 k leaves and root ρ.Let l b : V (T ) → {0, 1} be a labeling such that for every inner node u ∈ V (T ) with v, w as children we have that l b (v) = 0 and l b (w) = 1 (the label of the root is not important).For an example of this construction, see Figure 6.
if and only if the unique path from u to the root contains exactly i edges.We will call each L i a level of T .
Consider the C-labeling l such that, for each i ∈ [k] and u ∈ L i with l b (u) = 1, u is a first-appearance of c i .Note that such a C-labeling can be achieved by adding character c i to each node descending from every such u, and not adding c i to any other node.For each c i ∈ C, we denote by A i its set of first-appearance nodes under l.Notice that |A i | = 2 i−1 , since L i has exactly 2 i nodes and, by definition, there exist 2 i−1 nodes labeled as 1.
We argue that under l, the leaves of T are in bijection with S, and that l can serve as the S-map for T .There are 2 k = |S| leaves, so it suffices to show that for any distinct u, v ∈ L(T ), l(u) ̸ = l(v).Let z = lca T (u, v) and let z 1 , z 2 be the two children of z.Note that z 1 , z 2 are in the same level, say L i for some i ∈ [k].Moreover, l b (z 1 ) ̸ = l b (z 2 ), implying that one of u has c i and the other does not.Then l(u) ̸ = l(v).Finally, we will create a set of transfer edges E T for T in the following way: we use Algorithm 2 and give it l as a pre-labeling.Recall that for each character c i , the algorithm adds at most |A i | − 1 = 2 i−1 − 1 transfer edges.Since 2 i−1 − 1 transfers will be added to T per level L i with i ∈ {1, 2, . . ., k}, this results in at most Lemma 6.Let C be a set of k characters.Then there exists a set of taxa S on characters C such that any PTN for S has at least 2 k /(3k) − 1 transfer edges.
Proof.Let S = 2 C be the power set of C. Let (G, σ) be a PTN for S and let T be the base tree of G. Let λ be Fitch-labeling of T .In what follows, all first-appearance nodes of T are assumed to be with respect to λ.
Let A(T ) be the set of nodes of T that are a first-appearance node of at least one character of C. We argue that |A(T )| ≥ 2 k /3.To achieve this, we describe a partial injective function f : L(T ) → A(T ) that maps some leaves of T to a first-appearance node.By partial injective function, we mean that perhaps not all leaves are mapped, but no two mapped leaves map to the same node.A cherry of T is a pair of leaves that have the same parent.A non-cherry leaf is a leaf that is not in a cherry.Note that since L(T ) is in bijection with S we will refer to the leaves of T as taxa, with the understanding that leaves are subsets of C.
First let x, y be leaves that form a cherry in T .Then since all taxa are distinct, x, y disagree on at least one character c, and hence one of x or y is a first-appearance node of c, let us say x without loss of Here, the characters of x must be a subset of the characters of y, as otherwise x would be a first appearance.We can then argue that a character of y \ x has its first appearance between px and py.
generality.Then we put f (x) = x (and leave f (y) undefined).Now let N ′ be the set of non-cherry leaves of T .For each x ∈ N ′ such that x is a first-appearance node for some character, put f (x) = x.
Next let N = N ′ \ A(T ), i.e.N contains non-cherry leaves that are not a first-appearance node, for any character.For x ∈ N , denote by p x the parent of x in T .Let us denote the set of nodes {p x : x ∈ N } as marked nodes.For two distinct marked nodes p x , p y , we say that p y is a closest marked descendant of p x if p y ≺ p x and there is no marked node on the path between p x and p y , except p x and p y themselves.Suppose that x ∈ N is such that p x has at least one closest marked descendant, say p y .We argue that there is a first-appearance node z satisfying p y ⪯ z ≺ p x .This situation is illustrated in Figure 7.
To see this, notice that p x is marked because x is not a first-appearance.This means that for every c in x, all descending leaves of p x contain c.This includes y, and so x ⊆ y.Since x and y have distinct characters, there must be a character c ′ such that c ′ is in y but c ′ is not in x.Since y is not a firstappearance of c ′ , all descendants of p y have c ′ .Hence, there is a first-appearance node z of c ′ that is an ancestor of p y , but a strict descendant of p x (because not all descendants of p x have c ′ ).We put f (x) = z.Note that there may be multiple choices for z, in which case we choose arbitrarily.The important property is that whichever choice is made, z is a strict descendant of p x , and not a strict descendant of any marked p y ≺ p x .This completes the description of f .Suppose that p x , p x ′ are distinct marked nodes that both have a closest marked descendant.Notice that f (x) and f (x ′ ) must be distinct.Indeed, if p x and p x ′ are incomparable, this is obvious since f (x) and f (x ′ ) are strict descendants of p x and p x ′ , respectively.If instead p x ≺ p x ′ , then f (x) is a strict descendant of p x , whereas f (x ′ ) is either a closest marked descendant of p x ′ , or an ancestor of one of those nodes, implying that f (x ′ ) cannot be a strict descendant of p x .One can thus see that f is injective, since it either maps leaves to themselves, or children of marked nodes to distinct internal nodes.Now consider the set of leaves x ∈ N such that p x has no marked descendants.Note that all these marked p x nodes are pairwise incomparable.Moreover, any such p x has a leaf child x, and another child with at least two leaves (if the other child was a single leaf, p x would form a cherry and x would not be in N ′ ).Since any tree with at least two leaves has a cherry, p x has a descending cherry, and in fact each p x is the ancestor of a distinct cherry.It follows that the number of p x with no marked descendant is at most the number of cherries.
We can finally relate the number of first-appearances to the number of taxa as follows.Let C be the number of cherries of T ; let N A be the number of non-cherry leaves that are first-appearances; let N M be the number of leaves in N whose parent has a marked descendant; and let N X be the number of leaves in N whose parent has no marked descendant.Then

Open problems
We conclude this section with some open problems regarding all problems mentioned in this paper.

Conclusion
In this contribution, we have introduced perfect transfer networks (PTNs) as a model that aims to combine the structural properties of tree-based networks with the classical notion of perfect characters.In the absence of HGT events, PTNs coincide with the notion of perfect phylogenies.To better understand these, we studied their properties, stated the main differences between them and recombination networks as well as perfect phylogeny networks which is to our knowledge the closest model related to ours.Additionally, we explored several algorithmic challenges that result from this model with potential applications for HGT inference methods using character-based information that does not rely on sequence similarities.To the best of our knowledge, this is the initial theoretical endeavor employing the "once acquired never lost" principle through tree-based networks for inferring HGT events.While we acknowledge the simplicity of this model, it represents an initial stride towards incorporating additional conditions.Our intention is to develop more intricate models that better align with the complexity of biological systems.Although widely used throughout the literature, perfect characters impose strong restrictions for our model, since each character is allowed to change of state at most once.A potential extension of our model would be to include different models for character state changes as in Dollo parsimony [17].This model allows losing an acquired character but not gaining it twice.This assumption has been shown to be more suitable for complex characters such as restriction sites and introns [18].Another possible extension of our model would be to include expression levels of the different characters instead of discrete changes which is a problem similar to that of multi-state perfect phylogenies [24].Several other questions seem to be appealing for future work.Most importantly, since finding experimental datasets that use gene expression seems like a challenging task, the generation of in-silico datasets to test our algorithms seems to be a pertinent solution.Nevertheless, to our knowledge there is no simulation framework that combines evolutionary histories with gene expression data.Therefore, a future direction for this project could also be the design of a simulation environment that is able to generate this type of data.

Figure 1 :
Figure 1: (1) A species tree T with a set of taxa S on characters C = {a, b, c}.(2) A PTN with T as base tree that explains S. Red arrows represent transfer edges.(3) Another PTN with T as base tree that also explains S. Note that this PTN requires two less transfers.(4) A tree-based network G with S−map σ for which no labeling can explain S.

Figure 2 :
Figure 2: (a) A PPN network with one character c with two states {0, 1}.(b)A tree displayed by G that admits a labeling such that every state forms a connected component.Note that this tree can be obtained by the removal of the green edge and suppression of the resulting subdivision node.The interpretation of this scenario is that state 0 was transferred using the birectional edge.On the other hand, a solution for PTNs would forbid the transfer of state absence, and would also disregard the removal of the green edge, in which case no C-labeling is possible.

Figure 3 :
Figure 3: (1) Left: a network G with 5 taxa at the leaves.The fat red edge is a transfer edge.Two taxa have no character, two have all characters of C, and one has only the odd numbered taxa (we assume odd d in the figure).Right: a C-labeling that explains G (the reticulation receives the odd characters from the transfer edge).This network has no explanation with d-crossovers.(2) Left: a network G with 5 taxa on character set C = {c1, c2}.Right: a binary C-labeling with single crossovers that explains G.This network is not a PTN.

1 .
Let u ∈ L(G) and let us first argue that l(u) = σ(u).Let c ∈ C and let v be the chosen origin of c in l.If c / ∈ σ(u), then u ∈ F c and v does not reach u in G − F c (because u is simply not in G − F c ), and by our construction, c / ∈ l(u).If c ∈ σ(u), then u / ∈ F c and v reaches u in G − F c , in which case we put c ∈ l(u).It follows that l(u) = σ(u).

14 else 15
Set l = NULL.Remove c from C return l.Algorithm 1: Check if a given tree-based network G explains S.
For a character c ∈ C, computing F c can be done in a post-order traversal of T G in time O(|V (G)|).Checking whether the resulting network is connected or not can be done in linear time too.Finding the nodes of in-degree 0 takes linear-time and, for each O(|V (G)|) of these nodes, computing R v ( G c ) takes time O(|V (G)|).Thus each character requires time O(|V (G)| 2 ), and thus our algorithm solves the problem in O(|C||V (G)| 2 ).

Figure 4 :
Figure 4: An example of a solution that will be given by our greedy algorithm(1) The given instance T with C = {a, b, c}.Triangles represent subtrees and colors represent the characters that can be found on them (2) One possible solution output by Algorithm 2. The green arrow joins the first two subtrees that contain {a, b}, the yellow arrows joins the second subtree with the subtree that contains only {a} and the final arrow connects two subtrees that contain only {c}.
c has at most |S| elements and, for each c we add at most |S| transfers.It follows that the final network G output by the algorithm has at most O(|C||S| + |V (T )|) nodes.Let us denote n = |V (G)| ≤ |C||S| + |V (T )|.For a given c ∈ C, computing the first-appearance nodes can be done in time O(n) and sorting them takes time O(n log n).Then for each of the O(n) nodes in X c , we must find a descendant w in time O(n).The other operations take constant time.Thus, each iteration of the main loop takes time O(n log n + n 2 ) = O(n 2 ).This is repeated O(|C|) times, and thus the complexity is O(|C|n 2 ) = O(|C| • (|C||S| + |V (T )|)).The claimed complexity follows from |V (T )| ∈ O(|S|) since T is a tree on leafset S.

Definition 3 .Corollary 1 .
Let T be a tree with S-map σ, where S are on characters C. The Fitch-labeling of T is the labeling λ of T such that, for each c ∈ C, we put c ∈ λ(v) if and only if all leaves descending from v contain c.The Fitch-labeling can be combined with Algorithm 2 to obtain basic bounds on the number of transfers required.Proposition 2. Let T be a tree with S-map σ, where S is on characters C. Let λ be the Fitch labeling for T , and for c ∈ C, let A c be the set of first-appearance nodes of c under λ.Then• any PTN for S with base tree is T requires at least max c∈C (|A c | − 1) transfer edges;• there exists a PTN for S with base tree T with at most c∈C (|A c | − 1) transfer edges.Moreover, Algorithm 2 returns such a PTN when given pre-labeling λ.Proof.Let (G, σ) be a PTN for S with base tree T .Let c ∈ C be such that the number of first-appearance nodes in A c is maximum.Notice that all nodes of V (G)∩V (T ) that do not descend from a first-appearance node in A c cannot contain c in any labeling of G by Lemma 1 (since they have a descendant not possessing c, such a node is in F c ).Therefore, any solution for T must add at least |A c | − 1 transfers to T to be able to connect the first-appearance subtrees.Thus G requires at least |A c | − 1 transfers.Now consider the output of Algorithm 2 on pre-labeling λ.For each c ∈ C, the algorithm adds at most |A c | − 1 transfer arcs when it considers c in its while loop (noting that the number of first-appearance nodes for c never increases in the algorithm).By Theorem 3, the algorithm correctly returns a PTN, which has at most c∈C (|A c | − 1) transfers.Suppose that Algorithm 2 is given T, S, and the Fitch-labeling λ.Then it is a |C|approximation, i.e. it outputs a PTN with at most |C| times more transfers than an optimal solution.Proof.Using the notation of Proposition 2, it states that an optimal PTN needs at least |A c | − 1, and Algorithm 2 adds at most |C|(|A c | − 1) transfers.Do note that Algorithm 2 does not always output an optimal solution to the Minimum Perfect Transfer Completion problem.To see that Algorithm 2 can be suboptimal, consider Figure5and the explanation in the caption.

Figure 5 :
Figure 5: The greedy Algorithm 2 can add more transfers than the minimum.(1) A network G whose leaves are on two characters a and b.(2)One possible solution output by Algorithm 2. The left clade is chosen to originate a and a transfer is greedily added above all the a's on the right side.Then, the left clade is also chosen to originate b, but for that two more separate transfers are added.(3) A solution that is somewhat less natural, but with one less transfer.

Figure 6 :
Figure 6: An illustration of T with k = 3 and |S| = 8.Each color corresponds to a distinct character.Each node labeled as 1 is a first-appearance of the character associated with that color.Notice that each level has its corresponding character.

Figure 7 :
Figure7: An illustration of f (x) = z for a marked node px that has a closest marked descendant py.Here, the characters of x must be a subset of the characters of y, as otherwise x would be a first appearance.We can then argue that a character of y \ x has its first appearance between px and py.

3 ≥ 2C 3 + 3 ≥ 1 3 (
|L(T )| = 2C + NA + N M + N Xand, owing to our partial injection f ,|A(T )| ≥ C + N A + N MWe have argued just above that N X ≤ C, and so we can infer the chain of inequalitiesC + N A + N M = 2C 3 + N A + N M + C N A + N M + N X 2C + N A + N M + N X ) |A(T )| ≥ |L(T )|/3 = 2 k /3.Each node of A(T ) is a first-appearance of some c ∈ C. Therefore, by the generalized pigeonhole principle, some character c of C must have at least |A(T )|/|C| ≥ 2 k /(3k) first-appearance nodes in T .By Proposition 2, at least that many transfers, minus 1, need to be added to T to explain S.

•
Our algorithm for the recognition problem takes time O(|C||V (G)| 2 ).Can this be improved to O(|C||V (G)|), or even O(|C| + |V (G)|)?•Is the minimum tree completion problem NP-hard?•Does the greedy Algorithm 2 achieve a constant factor approximation, with the post-processing mentioned in the tree completion section?• Is the minimum perfect transfer reconstruction NP-hard?• Suppose that the taxa set is S = 2 C for characters C. Then what exactly is the minimum number of transfers of a PTN for S? • How can our model be extended to characters with multiple states?And would the underlying recognition problem be easy?