Quelqu'un tisse de l'eau (avec des motifs d'arbres en filigrane). Mais j'ai beau regarder, je ne vois pas la tisserande, ni ses mains même, qu'on voudrait toucher Quand toute la chambre, le métier, la toile se sont évaporés, on devrait discerner des pas dans la terre humide...

Philippe Jaccottet

On voit, in Pensées sous les nuages nrf, Éditions Gallimard (1976Gallimard ( -1983Gallimard ( -1994) )

Introduction

Evolutionary ecology is interested with the astonishing diversity of life forms on Earth. Not mentioning the immeasurable gap that might exist between, for instance, Pyrolobus fumarii, a thermophilic archeal species that lives around the very hot hydrothermal vents of the Atlantic mid-ocean ridge [START_REF] Blöchl | Pyrolobus fumarii , gen. and sp. nov., represents a novel group of archaea, extending the upper temperature limit for life to 113°C[END_REF] and Cypripedium calceolus, a "dainty and charming, trembling and delicate" orchid species [START_REF] Huysmans | SURFACE: Detecting convergent evolution from comparative data by fitting Ornstein-Uhlenbeck models with stepwise Akaike Information Criterion[END_REF], diversity can be seen at every scale of the tree of life, from the domain to the family or genus level. Coccinellidae (lady bugs) are for example known to wear a great variety of body patterns, from the common Europeans Coccinella septempunctata, red with seven black dots, and Psyllobora vigintiduopunctata, yellow with twenty two black dots, to the American Brachiacantha ursina, black with ten yellow dots 1 .

When observing a set of species, it is natural to wonder how a given trait pattern arose in the population. How much of it can be explained by external causes, such as climate or habitat? Is it possible that some of it is just the result of "chance"? The answers to these questions highly depend on the meaning one puts behind this word. Using a very narrow definition of chance, 18 th centuries philosophers famously concluded in the necessary existence of a "watchmaker" that shaped every life form (see e.g. Rousseau, 1762b;[START_REF] Paley | Natural Theology or Evidences of the Existence and Attributes of the Deity[END_REF]. If not convinced by this "Intelligent Design" theory, one might assume that all the traits of the species arose randomly, independently from one another. Although simple and quite intuitive, such an assumption is often wrong, and can lead to misleading conclusions. Indeed, it completely ignores the fact that living species are not independent. According to the theory of evolution (see e.g. [START_REF] Darwin | On the Origin of Species[END_REF], for an introduction), these species are linked by a phylogenetic tree, that represents the family relationships between them. When looking at species traits, it is then natural to expect that two closely related species, i.e. species that diverged only a short time ago, should look more alike than two distantly related species. Making explicit what a trait distribution produced by chance alone looks like is one of the goals of Phylogenetic Comparative Methods, the framework we use in this thesis to study trait evolution. It can be seen as a way to specify a correct null model.

Introduction

Phylogenetic Comparative Methods

Phylogenetic Comparative Methods (PCM) stem from the idea that, if we know, first, a dated phylogenetic tree between species, that tells us when speciation events took place, and, second, a dynamic model of quantitative trait evolution that describes how the traits change in time, then we should be able to find the expected current trait distribution in the species population we are studying. In this framework, assuming that the phylogenetic tree is known, "chance" is then entirely defined by the model of trait evolution, usually chosen in a family of stochastic processes. Such a model allows us to quantify the variations of the modeled traits. The simplest stochastic process one might use is the Brownian Motion (BM). Under this model of evolution, trait values have no trend, with independent and Gaussian increments.

The global model is then obtained by putting together the dated phylogenetic tree and the process of evolution in the following way. The trait of a given ancestral species evolves in time on a branch of the tree according to a BM. When a speciation event occurs, the two children species inherit their mother's trait, and then carry on evolving independently as a two BM. Note that, even though the two children species are supposed to evolve independently, the simple fact that they inherited their trait from the same species introduces some correlations between them. To see this, assume for instance that, by chance, their mother species deviated to extremely large values of the trait. Then, the two children species will start their evolution time with very large values, and hence are likely to look alike for a while, being larger than most of the other species. If the process is a BM, then these correlations can be quantified easily: the covariance between the traits of two extant species is proportional to their time of shared evolution (i.e. the time elapsed between the root of the tree and their most recent common ancestor). Realization of a univariate BM process on a dated phylogenetic tree. The colors of the branches (left) match with the colors of the distinct processes (right). For instance, the ancestral red species has a trait that evolves from 0 (node R, time -200) to around 2.6 (node S, time -100). Only tip values are observed (at time t = 0). Purple and blue species (A and B) inherited their trait values quite recently from the green species (U ). They had little time to diverge away from this value, so they are likely to have similar trait values. Their trait values are marginally correlated (but not anymore when conditioning on U ).

The art of PCM is then to define processes that correctly describe the dynamic evolution of the trait, and then to study the kind of trait distribution it produces at the tips of the tree, for living, observed species.

Shift Detection

This resulting trait distribution at the tips can be seen as a null model, that describes the correlations between species, and the ranges of variations of the traits, that can be expected by "chance". If the observed trait distribution significantly differs from the expected one, then it might be the clue that some special events shaped the history of the trait.

In this thesis, we are particularly interested in shifts that might happen on the trait at some points of species histories. Such a shift might happen for several biological reasons, such as a migration to a new environment, or a rapid climate change. When a species experiences such a shift, then it passes along its new value to its offspring, so that all its descending species inherit from this change. Such a situation is shown in the next figure.

Of course, several shifts can happen on the tree. The main goal of this thesis is to find their number and location on the tree. Both questions raise serious statistical issues, as shown in the next two paragraphs. Same process, but with a shift on the light green branch (between S and T ). Tips D and E are affected by the ancestral shift: their trait value is much larger than the one expected without any shift (in grey).

Identifiability

It is important to bear in mind that, even if we defined a dynamic model of trait evolution in time, we only have access to the state of the system today, for extant species. The stochastic process is hence only seen through its last values on the tree, at only one time point. Such a situation is bound to produce identifiability issues.

Adding shifts to the process only makes the problem worse. As shown in the next figure, it is easy to see that two different scenarios, with shifts of different values happening on different branches, can produce the exact same trait distribution at the tips of the tree. Such scenarios, although biologically distinct, cannot be distinguished from data collected only at the tips. They are not identifiable. Quantifying such identifiability problems is important both from a statistical point of view, as ignoring these problems would lead to ill-defined models, and from a biological point of view, as it allows us to know what the collected data can -and cannot -say about the past history of the trait.

Introduction A B C D E S T U R δ 2 δ 1 0 0 δ 1 δ 2 δ 2 A B C D E S T U R δ 2 ′ = δ 2 -δ 1 δ 1 0 0 δ 1 δ 2 δ 2
Two equivalent scenarios. The trait is assumed to evolve as a shifted BM, with ancestral value 0, and shifts marked on the branches. Expectations at the tips are indicated in blue. Both scenarios produce the same trait distribution, but they tell a different biological story. On the left one, the two children species of S went through independent traumatic events that led to shifted trait values.

On the right one, ancestors of S first went through a shift, that is passed along to its first child C directly, while its second child experiences another compensatory shift.

Model Selection

After addressing the identifiability problem, we will show how we can find the best scenario, for a given number K of shifts. Among all the models with K shifts, we are able to find the one with the highest likelihood. However, the best fitting model with K + 1 shifts, as it has more parameters, is known to have a better likelihood score. Following the same logic, the scenario with the best likelihood will always be the one with one shift per species, defining a special regime for each of them. This is a problem, as we would like to keep only significant shifts, that are typically rather scarce.

One common way to solve this problem is to use a criterion based on penalized likelihood, with a penalty that increases with the number of shifts. The penalty needs to be carefully crafted, so that it only compensates the increase of the likelihood due to overfitting. The next figure shows the principle of this method. It also stresses out the importance of the choice of the penalty to use: on the simple example presented, both AIC and BIC, two very commonly used penalized criteria, clearly fail to correct for over-fitting. A theoretically sound penalty, that takes into account the true size of usable models for a given number of shifts, will be derived. Typical profile for a maximum likelihood inference of parameters for a dataset simulated using a BM on a tree with 64 taxa, and K true = 5 shifts. In red, each dot is the maximum likelihood obtained for a model with a given number K of shifts allowed. This likelihood is always increasing, as expected. A penalized criterion that is correctly working should have a maximum in K = 5 (vertical line), allowing us to infer the true number of shifts. Standard penalized criterion AIC and BIC (green and blue) fail to recover this true number of shifts (they are increasing). In contrast, the proposed model selection method (LINselect, purple) behaves correctly: it has a clear maximum for K = 5.

These models and broad statistical methods are at the core of this thesis. In the main text, we explain them in more details (Chapter 1), develop and extend them to other stochastic processes (Chapter 2 and Chapter 3), and to other kinds of species relationships (Chapter 4).

Outline

Chapter 1: Background

The first chapter aims at presenting in a structured way all the tools and concepts used in the rest of the manuscript, both from a biological and a statistical point of view. We start by reviewing some structural results that have to do with the combinatorial nature of the space of objects we consider: traits mapped on phylogenetic trees. We then introduce several explicit models of trait evolution, both discrete and continuous. Finally, we give a brief overview of some statistical methods for model selection based on penalized likelihood. So as to present the reader with a coherent overview of the problems at stake, some of the results presented in this chapter are also developed further in the next two chapters, which correspond to published or submitted journal articles.

Chapter 2: Shift Detection for Univariate Processes

In this chapter, we set up the entire method for shift detection in the univariate case. We start by defining a rigorous statistical framework to model shifts on the tree, for both the Brownian Motion and the Ornstein-Uhlenbeck processes. Building on the combinatorial results exposed in the previous chapter, and thanks to a careful analysis of the models, we give an extensive solution to the identifiability problem. This implies two different questions. First, given a shift scenario, we are able to enumerate and count all the different scenarios that produce the same trait distribution at the tips, i.e. that are equivalent. Second, given a fixed number of shifts K, we can compute the number of equivalent classes of models with K shifts, that is the number of truly different models, that give different trait distribution structures at the tips of the tree. Except for binary trees (i.e. a tree where all internal nodes have exactly two children), this number depends on the topology of the tree at hand.

We then describe a statistical inference method, that relies on a two steps strategy. First, for any given number K of shifts, we implement an Expectation Maximization (EM) algorithm that allows us to find the maximum likelihood solution. Second, given all the solutions found over a range of values of K, we derive a model selection penalty to choose the right number of shifts. This penalty is based on the LINselect procedure, and inherits some of its properties and theoretical guaranties. In particular, the penalty can be used directly, without the need to calibrate a multiplying constant, and an oracle inequality can be derived in some particular cases.

The method is efficiently implemented in an R package PhylogeneticEM. Its accuracy is assessed through a set of extensive simulation scenarios. It is then used to study the evolutionary history of the Chelonians, a family containing all living turtles and tortoises.

Chapter 3: Shift Detection for Multivariate Processes

In this chapter, we build upon the univariate case to address multivariate traits. We introduce a new set of assumptions on the Ornstein-Uhlenbeck process, that allows us to explicitly deal with correlated traits, while still being able to conduct shift detection in an efficient way. Compared to previous state-of-the art methods, that all assumed independent traits, this is a salient feature of our framework. It is all the more important as we show that a common method to de-correlate traits measured at the tips of a tree, called phylogenetic PCA (pPCA) actually fails to do so when there are some shifts in the traits evolution.

The EM likelihood maximization is made efficient thanks to a new"upward-downward" algorithm, that can compute all the quantities needed at the E step with only two traversals of the tree, and can cope with missing data. This algorithm is implemented in C++, and the method is integrated in the R package PhylogeneticEM.

The efficiency and accuracy of the method is assessed through an extensive set of simulations, designed to test the behavior of the framework when its assumptions are violated. The method is then used to study the evolutionary history of new world monkeys and anolis lizards.

Chapter 4: Trait Evolution on Phylogenetic Networks

In this chapter, we explore a new paradigm for species evolution: phylogenetic networks. Compared to phylogenetic trees, phylogenetic networks can have some hybridization events. Instead of being always vertical (i.e. from a species to its offspring), the genetic transmission can sometimes be horizontal (i.e. between two contemporary species). Such events are known to happen from time to time in every families of species, and are even quite common in some, such as bacterial organisms or plants.

We start by giving a swift overview of state of the art methods to reconstruct such networks from DNA sequences. They are all quite recent, and promised to a bright future. We then show how these newly inferred structures can be used to describe trait evolution. A simple BM model is fully described, and an efficient algorithm to compute the trait distribution structure it induces at the tips is derived.

From this first null model of trait evolution on a network, we again study the impact that shifts might have on the trait distribution. Here, we limit ourselves to very particular shifts, that follow hybridization events. Such shifts can model heterosis (hybrid vigor or depression). This phenomenon is well known by agronomists, who for instance use it to improve cultivated lineages of crops. It describes the fact that, sometimes, a hybrid individual exhibits a trait with an outstanding value, that is outside of the range of its two parents trait values. The shifts used to model heterosis have a fixed and known position (on branches just below hybrid nodes), so that, contrary to the previous problem, we do not need to search the entire tree to find potential shifts. We show how a classical linear regression framework, along with a standard Fisher test for the coefficients, can inform us on the presence or absence of heterosis.

The methods developed in this chapter are integrated in the Julia package PhyloNetworks. Julia is a new programming language, that aims at combining the ease of use of R, and the speed of C. The PhyloNetworks package has for ambition to become the standard tool for inferring, analyzing, and manipulating phylogenetic networks on Julia.

Chapter 5: Extensions and Perspectives

In this last chapter, we browse some of the extensions that could be interesting to study in future work. Models are only sketched in this chapter, that aims at providing the main ideas behind each extension possibility.

We first study the impact of uncertainties on our framework. Indeed, in all our developments, we always assumed that the data at the tips was measured without error, and that the underlying tree was perfectly known. Both these assumptions are erroneous, and we show that ignoring these sources of uncertainties can bias our analysis. A simple method to deal with measurement error is described. Interestingly, we show how this same framework could be used to conduct a factor analysis of the traits.

We then see how the framework could be adapted to include two desirable features: convergence, and shift trait sparsity. Structural penalties can allow us to deal with these new constraints. Two distinct sets of species are said to be convergent if they developed the same trait features independently. This is not allowed in our previous framework, and we propose to include it using a fused-ANOVA penalty. In the multivariate case, for simplicity reasons, we assumed that when a shift occurred, it affected all traits at once. This is a strong assumption, that makes the analysis highly dependent on the set of traits included in -or excluded from -the analysis. A sparse group sparse lasso penalty is proposed to tackle this issue, and impose a sparse number of traits to change at each shift.

Another strong assumption we made was that the trees we considered were ultrametric: we assumed that all the trait measurements we had were coming from contemporary, presently living species. This excludes for instance any kind of fossil measurement. Although rare, these fossils provide us with unique insights into the evolution process, and should not be ignored. Alleviating the ultrametry assumption is however not straightforward. First, it breaks our careful identifiability study. Biologically, this is a good thing, as previously un-distinguishable scenarios can become identifiable again. Mathematically, however, it makes the space of models more difficult to study, and highly dependent on the tree topology. Second, it prevents us from using a re-scaling trick, that allowed us to carry efficient computations on the Ornstein-Uhlenbeck. Some new heuristics are proposed to deal with this issue.

Finally, the last section presents a method to deal with missing data in a more satisfying way. Indeed, we assumed in our framework that data were missing completely at random, i.e. that the sampling was uniform over all traits and species, with missingness happening randomly from time to time. However, the actual sampling might sometimes have a specific structure, that depends on the very data being measured. A simple example of this would be for an experimenter to be more likely to "miss" a small trait value than a larger one. Such sampling scheme can be explicitly incorporated in the statistical analysis, and we sketch the changes that would be needed in our framework to include them.

Chapitre 6: Résumé substantiel Ce dernier court chapitre, en français, décrit le contexte et les résultats principaux présentés dans ce document. Il peut être lu de manière autonome, et est fortement redondant avec la présente introduction, qui s'achève sur ces mots. In this chapter, we introduce some of the theoretical results that are at the root of the developments exposed in the following of this document. We try to provide the interested reader with a coherent overview of both the biological and statistical literature, and to stress the important questions faced by the field.

Background

Three main points are covered in this introduction. This manuscript is concerned with trait evolution on phylogenetic tree. Before describing any model, we first give a rigorous definition of phylogenetic trees as a mathematical object, and describe how a character can be mapped on it (Section 1.1). This allows us to study some of the combinatorial properties of the space of problems we will be navigating through.

In the next three sections, we introduce some dynamic models of trait evolution on a tree. We first show how a generic model can be defined, and display some of its global properties (Section 1.2). We then describe in more depths two important instances of this model, for discrete (Section 1.3) and continuous (Section 1.4) traits. We gave a special care to that last section, that is at the core of our work.

Finally, we recall some important results about model selection (Section 1.5), that will be useful in the statistical analysis of the problem. This section can be read independently.

Space of Convex Characters on Phylogenies

In this section, we give a definition of phylogenetic trees, and show how to track and count the changes of a discrete character state evolving on the tree. The exposition and theorems are inspired from these two landmark books: [START_REF] Felsenstein | Inferring Phylogenies[END_REF] and [START_REF] Semple | Phylogenetics[END_REF]. The combinatorial results recalled in this section are at the root of our attempts to assess the identifiability of the models we considered in this thesis.

Phylogenetic Tree

We formally introduce here phylogenetic trees, that are one of the central objects of this thesis. Trees are often used in evolutionary biology to describe the relationships between extant species. They can be defined as follow (we assume in this definition that the reader is familiar with the basics of graph theory, and refer to Giraud 2014, Chap. 7, for a brief introduction of the notions needed).

Definition 1.1.1 (Tree). A tree T = (V , E) with a set of vertices (or nodes) V and edges E is a connected acyclic graph.

The leaves (or tips) of the tree are the vertices of degree one, and all the other nodes are said to be interior or ancestral.

A binary or fully resolved tree is a tree where every interior node has degree exactly 3, except for at most one with degree 2 (the root, if any). In non-binary trees, a node with degree more than 3 is called a polytomy.

Binary trees are preferred, when possible, as they represent a situation where, taking any extant species, we can sort out all the others, from the most closely related, to the most distant one. In many applications, we want the tree to give us information not only on the relationships between species, but also on the relative position of their ancestors. Specifically, we often need a rooted tree, where an interior node is marked to be the ancestor of all other nodes. An example of such a tree is given Figure 1.1.1. Definition 1. 1.2 (Rooted Tree). A tree can be rooted if one interior node is distinguished as the root. On a binary tree, the root is the only node with degree 2.

A rooted tree can be oriented from the root to the leaves. For any node a ∈ V , we then denote by anc(a) the set of all ancestors of a: b ∈ anc(a) if and only if b = a or there is an oriented path b → a. The direct parent of a is the unique node pa(a) such that pa(a) ∈ anc(a), and (pa(a), a) ∈ E.

Similarly, we define the set des(a) of descendants of a: b ∈ des(a) if and only if a ∈ anc(b). The set of direct descendants of a are the children of a: b ∈ child(a) if and only if a = pa(b).

On rooted trees, several natural orders of the nodes can be defined. These orders are useful to compute some quantities iteratively and efficiently on the tree.

Definition 1.1.3 (Pre and Post Orders). The nodes of the tree are said to be sorted in a preorder if any node comes after all its parents: for any two nodes numbered i and j, if there is an oriented path going from i to j, then i ≤ j. This corresponds to a numbering of the tree from the root to the leaves. A preorder is a particular case of topological sorting when the graph is a tree, and can be obtained in linear time [START_REF] Kahn | Topological sorting of large networks[END_REF].

A preorder can be turned into a postorder by reversing it. A postorder can also be called a pruning order, as it is used in the well known Felsenstein pruning algorithm (see Section 1.2.3). When visiting the nodes in this order, we know when we see a new node that we already visited all its ancestors. A postorder is obtained by reversing this order.

As stated above, trees are used in evolutionary biology to represent the relationships between a set of extant species, that are typically found at the tips. We hence need a map linking the observed species (each identified by a label), and the tips of a tree. Following Semple & Steel (2003, def. 2.1.2), we define a phylogenetic tree as a pair of a tree, and a set of associated labels. Definition 1. 1.4 (Phylogenetic Tree). A phylogenetic tree (on X) T is a pair (T , φ), where T = (V , E) is a tree, and φ : X → L is a bijection between a set of labels X and the set L of the leaves of T .

Background

The set X can be viewed as a set of labels that uniquely define the leaves of the tree. In the context of evolutionary biology, these can be thought as the names of the extant species studied. For each species, we can then measure a set of discrete traits, such as the presence of absence of a given feature, or, more commonly, a molecular sequence. The distribution of these characters, that are the result of evolution for all extant species, are likely to be constrained by the tree. In the following section, we recall some classical results on the class of convex characters, that are characters that can be seen as the result of a homoplasy-free evolution along the tree (see definitions below).

Convex Characters

These notions and properties are analysed in Chapter 4 of [START_REF] Semple | Phylogenetics[END_REF]. We recall here some of the main definitions and results, that will be useful in Section 2.3 of Chapter 2, to characterize the set of equivalent solutions.

Definition 1.1.5 (Character). A discrete full character χ : X → C is an application mapping the leaves (identified by their labels) of a phylogenetic tree T = (T , φ) on X to a character or state set C. If |χ(X)| = r, then χ is an r-state character.

Definition 1.1.6 (Extension). An extension of a character χ to T is an application χ : V → C such that χ•φ = χ. We denote by Ex(χ, T ) the set of all extensions of a character χ on T .

On a rooted phylogenetic tree, an extension can be seen as an ancestral state reconstruction of the character: it describes a possible state for un-observed characters at the ancestral nodes of the tree. See Figure 1.1.2 for an example of a convex character, along with an associated extension.

Definition 1.1.7 (Convex Character). A character χ : X → C is said to be convex on a phylogenetic tree T = (T , φ) on X with T = (V , E) if there is an extension χ : V → C of χ such that, for any c ∈ C, the sub-graph of T induced by {v ∈ V | χ(v) = c} is connected.

(To be consistent with the literature, we use here the terminology defined in Steel 1992. "Convex" is here to be understood as "connex": a set of nodes is convex if any two of its elements can be linked by a path on the tree staying inside the said set.) If we consider a rooted phylogenetic tree, then we can study the evolution of a character from the root to the tips. Each node can then pass along its character value to its children, and, sometimes, the character might shift, going from one state to another. If those shifts can only lead to novel states, then we have a homoplasy free evolution process, as defined below.

Definition 1.1.8 (Homoplasy-free evolution). Let B : V → C be an application associating each node of a rooted phylogenetic tree T = (T , φ), with T = (V , E), to a state in C. We define the following properties of B:

(i) B is said to exhibit a reverse transition if, on a lineage, a character goes back to a previous state, i.e. if there exists a path (v 1 , . . . , v k ) in T going away from the root, such that B(v 1 ) = B(v k ), and that, for some

i ∈ 2 , k -1 , B(v 1 ) B(v i ).
(ii) B is said to exhibit a convergent transition if two separate lineages converge independently to the same state, i.e. if there exists two paths (a, v 1 , . . . , v k ) and (a, w 1 , w 2 , . . . , w l ) starting from node a and going away from the root, such that v k w l , B(v k ) = B(w l ), and B(a) B(v k ). For the convex character, "white" and "grey" are unique innovations of the two tips on the left. For the non-convex one, the "grey" innovation appears twice: this is an example of convergent evolution. There are several possible extension of the character on the internal node (see Section 1.1.3), but none is homoplasy free for the non-convex character.

(iii) If B does not exhibit any reverse or convergent transition, then B is said to be homoplasy free.

The two notions of homoplasy-free evolution and convex characters are in fact two representations of the same concept, as we can see with the following proposition, extracted from Semple & Steel (2003) (Chap. 4).

Proposition 1.1.1 (Link between convex and homoplasy-free characters). An homoplasy free map on a rooted tree and a convex character on an un-rooted tree are linked by the following transformations:

(i) Let B : V → C be a homoplasy free application on a rooted phylogenetic tree T = (T , φ), with T = (V , E), and let T the un-rooted phylogenetic tree associated with

T . Then the character χ = B•φ : X → C is convex on T , with associated extension χ = B.
(ii) Reciprocally, let χ : X → C be a convex character on an un-rooted tree T = (T , φ), with T = (V , E), and let χ : V → C be its associated extension. Choose ρ and consider the tree T associated to T and rooted at ρ. Then the map B :

V ∪ {ρ} → C such that B(v) = χ(v)
for any v ∈ V and B(ρ) = χ(w) for an arbitrary fixed w ∈ child(ρ), is homoplasy-free.

Associating a color to each state of a character, it is possible to count the number of convex colorings on a binary tree. This is given by [START_REF] Steel | The complexity of reconstructing trees from qualitative characters and subtrees[END_REF] (Proposition 1, item 4) and proposition 4.1.4 in [START_REF] Semple | Phylogenetics[END_REF].

Background

Proposition 1.1.2 (Semple & Steel (2003), proposition 4.1.4). Let T be a binary phylogenetic tree on X, and let C be a set of c ≥ r states. Then the number of full r-states characters χ :

X → C that are convex on T is c! (c -r)! 2n -r -1 r -1 ,
where n = |X| and c = |C|.

Corollary 1.1.1 [START_REF] Steel | The complexity of reconstructing trees from qualitative characters and subtrees[END_REF], proposition 1, item 4). If the arranging order of the state does not matter, then the above formula simplifies to

2n -r -1 r -1 .
Example 1.1.1. On the tree with n = 5 tips with r = 3 characters presented Figure 1.1.2, there are 10-3-1

3-1 = 15 coloring of the tips that induce convex characters, i.e. that can be obtained with an homoplasy free evolution.

In Section 2.3 of Chapter 2, we derive this formula using the homoplasy-free evolution formalism, and extend it to any tree (not necessarily binary).

Parsimony

Among all extensions of a character to ancestral nodes, some require less shifts between states than the others. In the following, we study the extensions that are parsimonious, in that they induce the less possible shifts.

Definition 1.1.9 (Parsimony Score, Semple & Steel, 2003, Definition 5.1.1). Let χ be a character on a phylogenetic tree T , and χ ∈ Ex(χ, T ) an extension of χ. The changing number ( χ, T ) of χ is the number of characters shifts induced by the reconstruction χ:

( χ, T ) = |{(u, v) ∈ E | χ(u) χ(v) }| .
The parsimony score (χ, T ) of χ on T is then the minimum number of shifts required to produce χ:

(χ, T ) = min χ∈Ex(χ,T ) ( χ, T ).

An extension reaching the minimum above is a minimum extension of χ.

For a character following a homoplasy free evolution, as each shift induces a new state, the number of changes needed to get r states at the tips is exactly r -1. The link between convex characters and parsimony scores can be summarized by the following proposition:

Proposition 1.1.3 (Semple & Steel, 2003, Proposition 5.1.3). Let χ be an r-state character on a phylogenetic tree T . Then:

(χ, T ) ≥ r -1,
and the equality is reached if and only if χ is convex on T .

In the following, we describe two classical dynamic programming algorithms to find a minimum extension of a given, not necessarily convex, character on a rooted phylogenetic tree. The goal of Section 2.3 in Chapter 2 is to enumerate or count the set of all minimum extensions of a given character.

The Fitch Algorithm. We only give a brief description of the algorithm here, but see [START_REF] Felsenstein | Inferring Phylogenies[END_REF], chapter 2, or [START_REF] Semple | Phylogenetics[END_REF], section 5.2, for a more formal approach. For this algorithm, we assume that we have a character χ on a rooted phylogenetic tree T , and that the nodes of the tree are in a postorder (from the tips to the root). We propagate two quantities: at node numbered i, ψ i ⊂ C is a set of acceptable states, and i is the parsimony score associated with those states. See Algorithm 1.1.1 for a formal description of the upward phase propagation, and Figure 1.1.3 for an example. At the root ρ of the tree, we get ρ the parsimony score of the character, and ψ ρ the set of characters that might enter in the composition of an associated minimal extension of the character.

From this set ψ ρ , it is possible to start a downward phase, traversing the tree in a preorder, in order to define a minimal extension at all the nodes of the tree.

Algorithm 1.1.1 Fitch Algorithm

for i ∈ 1 , |V | do if i is a tip then ψ i ← {χ • φ(i)} i ← 0 else {i is an internal node} E ← j∈des(i) ψ j if E = ∅ then ψ i ← j∈des(i) ψ j i ← j∈des(i) j + 1 else ψ i ← E i ← j∈des(i) j end if end if end for
The upward phase of this algorithm has a complexity linear both in the number of tips and the number of characters (i.e. in O(|X| × |C|)). The Sankoff Algorithm described below is slightly less efficient, but can be generalized more easily.

The Sankoff Algorithm. This algorithm is more formally based on a Dynamic Programming approach. As previously, we assume that we have an r-state character χ : X → C on a rooted phylogenetic tree T = (T , φ), with T = (V , E). Here, we also assume that the cost of going from one state to the other is not always 1: for any two states a, b ∈ C, the cost of the transition a → b is denoted by c ab . Those costs are assumed to be known. We still assume that all the nodes V are numbered in a postorder (from the tips to the root). For convenience, we identify V with its numbering, so that, for any node v numbered i, φ(i) = φ(v). The goal of the algorithm is then to compute, for any node numbered i and any state a ∈ C, the minimum cost S i (a) for node i to be in state a. This is obtained by taking the sum, over all its descending nodes j, of the minimum over all the states b of the minimum cost S j (b) for node j to be in state b, plus the cost of going from state a to state b. See Algorithm 1.1.2 for a formal description, and Figure 1.1.4 for an example.

At the root node (numbered |V |), we get the minimal cost of the character on the tree c(χ, T ) = min a∈C S |V | (a). If all the transition costs are set equal to 1, then we get

1. Background { , , } +1 { , } +1 { , } +1 { , } Figure 1.1.
3 -Example of the Fitch algorithm on a tree with 5 tips and 3 states (showed in black, gray and white). The states of the tips are showed by a big colored circle. The set ψ i is shown at each node i. When the union is taken, the increment of the score is shown by a +1 sign. Here, the parsimony score is equal to 3. Note that the character represented is not convex.

Algorithm 1.1.2 Sankoff Algorithm

for i ∈ 1 , |V | do if i is a tip then for a ∈ C do if χ • φ(i) = a then S i (a) ← 0 else S i (a) ← 1 end if end for else {i is an internal node} for a ∈ C do S i (a) ← j∈des(i) min b∈C [c ab + S j (b)] end for end if end for the parsimony cost: (χ, T ) = c(χ, T ).
As such, the algorithm only provides us with the parsimony cost, and not with a minimal extension of χ. As previously, such a minimal extension can be obtained by a downward phase, selecting at each node a state that realizes the minimum cost, and choosing the state that is identical to its parent's state when possible.

The upward phase of this algorithm is in O(|X| × |C| 2 ): it is linear in the number of tips in the tree, and quadratic in the number of states.

0 1 1 1 0 1 1 1 0 1 1 0 1 0 1 2 2 2 1 1 2 2 1 1 4 3 3 Figure 1.1.4 -
Example of the Sankoff algorithm on a tree with 5 tips and 3 states (showed in black, gray and white). The states of the tips are showed by a big colored circle. The vector S i for the three states is shown at each node i as a box with associated states below. The transition costs are all set to 1. Again, the parsimony score is equal to 3 (minimum of S ρ at the root).

Latent Variable Models of Character Evolution

When studying a discrete trait, parsimony provides us with a first and simple criterion. It is based on the "Occam's Razor" principle, that states that between two equivalent solutions, one should always choose the simplest one. However, evolution is a dynamic process, and it is not clear at all that it actually follows a parsimony principle. Instead of looking at the trait a posteriori and try to explain it using parsimony, we can try to model directly the dynamic evolution of the character through time. Defining such a model has two main advantages. First, it makes all the assumptions used in the model explicit, which makes its limitations more obvious, and can help us choose between various models, depending on the organism or biological process studied. Second, with a model, comes a natural way to evaluate it, in light of the data: likelihood. This continuous score can replace advantageously the discrete parsimony score, that has some identifiability issues, and the statistical properties of which are hard to study.

In this section, we describe a popular model for trait evolution on a tree. Under some broad assumptions, we show that this model can be casted into the framework of latent graphical models. We recall some well known properties of these models, that will be useful when studying particular instances of trait evolution models (in Sections 1.3 and 1.4).

A Generic Model for Trait Evolution on a Tree

We describe here a very generic model of trait evolution on a tree. We start by making the assumption that the tree is calibrated in time, i.e. that the branch lengths represent units of times elapsed between a node and its child. The idea is then to assume that one or several traits, that can be discrete or continuous, evolve in time according to a given process, left unspecified here, but assumed to model the dynamics of trait evolution through time, on a given branch and for a given species. When there is a speciation event, at a node of the tree, this process splits up into two independent instances of this same process, starting at the same value. We describe in the following definition such a branching process, where branching times are fixed by an underlying known phylogenetic tree.

Definition 1. 2.1 (Generic Trait Evolution). Let T = (E, V ) be a rooted tree, with root ρ, oriented from the root to the tips. Assume that each edge e ∈ E of the tree has an associated branch length e . Given a preorder numbering of the vertices, denote by (X i ) 1≤i≤|V | the sequence of random variables, taking its values in an arbitrary character space C (that can be discrete or continuous, and possibly multidimensional), describing the trait of each node. The law of (X i ) 1≤i≤|V | is defined by: X 1 ∼ D(θ 1 ): the root follows a given law D, with parameters θ 1 .

Let e ∈ E be a branch, with child node i, and parent node pa(i). On this branch, the trait evolve according to a stochastic process (W e t , 0 ≤ t ≤ e ) with law P (θ e ), independently from other species, conditionally on W e 0 = X pa(i) .

At node i, define

X i = W e e .
Iterate down the tree.

One strong assumption that is made here is that, conditionally on their ancestors, species evolve independently. This is a key assumption, that we cannot alleviate easily. It will be essential in our approach of the problem, as shown below. It is however not very realistic, as it excludes any kind of interactions, such as competition, predation or mutualism, between species living at the same period of time. Some attempts have recently been made to introduce interactions for some classes of Gaussian processes (see e.g. [START_REF] Drury | Estimating the Effect of Competition on Trait Evolution Using Maximum Likelihood Inference[END_REF][START_REF] Manceau | A unifying comparative phylogenetic framework including traits coevolving across interacting lineages[END_REF][START_REF] Bartoszek | The Ornstein-Uhlenbeck process with migration: evolution with interactions[END_REF]. In the rest of this thesis, we don't question this assumption anymore. Some more assumptions need to be made on the evolution process P itself. These assumptions depend on the trait studied, and on the species considered. In Sections 1.3 and 1.4, we describe in details some of them for discrete or continuous traits. One generic assumption that is almost always made however, for mathematical convenience, is that the process has the Markov property: if (W t , 0 ≤ t) follows P , then, for any 0 ≤ s < t, the law of W t given (W u , 0 ≤ u ≤ s) is the same as the law of W t given W s . In other words, the state of the traits depends on its previous states only through the last one known. This is another essential assumption, that we will not try to alleviate in the rest of this manuscript.

Under those two assumptions (conditional independence, and Markov property), we show in the next section how this generic model can be casted in a useful statistical framework.

Observe that in the definition, the process can have different parameters θ e on each branch e. Going further, each branch could even have its own process P e . However, in most applications, the process, as well as the parameters, are taken constant for all the branches (i.e. θ e = θ, ∀e ∈ E). If it is the case, then from the definition above it follows that, for any node i, X i = W t i , where t i is the time elapsed between the root and node i, and (W t , 0 ≤ t ≤ t i ) follows the law P (θ), conditionally on W 0 = X 1 .

One of the major goal of this thesis is, for some particular processes P , to relax this assumptions of uniformity, and to assume that the parameters are only constant by part, shifting only a few times on the tree.

Directed Graphical Models and Latent Variables

We introduce here directed graphical models and latent variable models, and show how the generic model presented in the previous section can be casted in this statistical framework. We then recall some of their useful properties, as well as inference procedures, such as the Expectation Maximization algorithm, a popular algorithm for the inference of the parameters of these models through likelihood maximization.

Definition 1.2.2 (Directed Graphical Model). A set X = (X 1 , . . . , X |V | ) of random variables on an arbitrary state space C follows a Directed Graphical Model if it lies at the vertices of a directed acyclic graph G = (V , E), and is such that its joint distribution can be factorized as:

p θ (X) = i∈V p θ X i X pa(i)
where pa(i) is the set of all direct parents of i in the graph G, and θ is the vector of parameters of the distribution. Note that one may have pa(i) = ∅ (e.g. at the root of a tree), in which case p θ X i X pa(i) = p θ (X i ) by convention. Equivalently, X follows a Directed Graphical Model if, for any two nodes i and j such that j is not a descendant of i in the graph, then X i is independent of X j conditionally on X pa(i) .

When the underlying graph is a tree, each node has only one parent, and the formula above means that we can express the joint distribution as the product over all branches of the laws of each node knowing its parent. Hence, in such a model, we just need a transmission rule for the trait from a parent node to its children to know the entire distribution of the tree.

This formalism is quite fruitful, and can encompass the generic model of trait evolution described in the previous section: Proposition 1.2.1. Let (X i ) 1≤i≤|V | be some random variables on a rooted and directed tree T = (E, V ), generated according to a process of trait evolution described in Definition 1.2.1, with a process P that has the Markovian property. Then (X i ) 1≤i≤|V | follows a graphical model on the tree T .

Proof. The proof relies essentially on the two assumptions that we stressed above: conditional independence and Markov property. Using the second definition, take i and j two nodes of T , such that j is not a descendant of i, and show that:

p X i , X j X pa(i) = p X i X pa(i) p X j X pa(i) . Writing p X i , X j X pa(i) = p X i X j , X pa(i) p X j X pa(i) , this amounts to prove that p X i X j , X pa(i) = p X i X pa(i) .
If j is an ancestor of i, then this is true thanks to the Markov property. Otherwise, let k be the most recent common ancestor of i and j. As j is not a descendant of i, k is distinct from i and j. Then as k is an ancestor of i, by the Markov property, we get p X i X j , X pa(i) = p X i X j , X pa(i) , X k . From the conditional independence of X i and X j given X k , this is equal to p X i X pa(i) , X k . We then conclude using the Markov property one more time.

Background

Once the model is defined, to do some statistical inference, we need to know which nodes are observed, and which ones are hidden. For a phylogenetic tree, representing the evolutionary history of species, we typically only have access to traits that can be observed today, at the tips of the tree. Apart from fossils, that can provide us with some insight on ancestral traits, internal nodes remain mostly unobserved.

Definition 1.2.3 (Latent Variable Model on a Tree). A set of variables Z is said to be latent, or hidden if it is un-observed, but has a direct effect on a set of observed variables Y. If the set X = (Y, Z) is such that:

X follows a directed graph model on a tree T , Y are observed variables at the leaves of the tree, Z are latent variables at the internal nodes of the tree, then Y is said to follow a latent variable model on the tree T .

Intuitively, this class of models corresponds to a case where the law of a node given its parents is known, and defined by a model of trait evolution, that can be discrete or continuous, and where only extant species (at the tips of the tree) are observed. See Figure 1.2.1 for a simple example of such a setting.

Y 5 Y 6 Y 7 Y 8 Y 9 Z 1 Z 2 Z 3 Z 4 Figure 1.2.1 -Latent Variable Tree Model.
The observed variables are shown in white, and the latent variables in gray. The variables are numbered in a preorder. The likelihood of the completed dataset can be factorized on the edges, with terms of the form p X i X pa(i) , such as e.g. p (Y 5 | Z 3 ).

These models appear naturally in phylogeny, and, thanks to the underlying tree, have some nice hierarchical properties that can help us speed up many computations, including the likelihood one.

Pruning Algorithm

When we have a latent variable model on a tree, the likelihood of the data can be computed thanks to a pruning algorithm, that goes up the tree from the tips to the root, similarly to the Sankoff algorithm. The idea relies on the conditional independence of daughter nodes given a parent node in the tree graphical model. It has been exposed and studied in some particular examples of evolution model by Felsenstein (Felsenstein, 1973b[START_REF] Felsenstein | Evolutionary trees from DNA sequences: A maximum likelihood approach[END_REF][START_REF] Felsenstein | Inferring Phylogenies[END_REF].

Proposition 1.2.2 (Pruning-like Propagation). Denote by Y i the set of all the traits for tips that are below a given node i (i.e. all tips j ∈ des(i)). Then the conditional likelihood of Y i given X i can be written as:

p θ Y i X i = x = j∈child(i) u∈X p θ Y j X j = u .p θ X j = u X i = x du (1.1)
If the nodes of the tree are in a postorder, then this equation makes it possible to propagate the information from the tips of the tree to the root. When some assumptions are made on the space C or on the law p θ , then some explicit formulas can be derived. For instance, if C is discrete, then the integrals are just sums, and the formula can be handled more easily (see Section 1.3). Similarly, if the law studied are Gaussian, then all the integrals can be solved analytically, and we get actualization formulas similar to the ones in a Kalman filter (see Section 1.4, and Chapters 2 and 3).

Expectation Maximization

Instead of trying to integrate out the marginal distribution of the observed trait values Y directly, it can be better to work with the likelihood of the completed dataset X = (Z, Y), that is in many cases easier to compute. The well known Expectation Maximization (EM) algorithm is designed to exploit this feature. It was introduced by [START_REF] Dempster | Maximum likelihood from incomplete data via the EM algorithm[END_REF], and relies on the following decomposition of the likelihood of the observed data: Proposition 1. 2.3 (Marginal Likelihood Decomposition).

log p θ (Y) = E θ [ log p θ (Y, Z) | Y] -E θ [ log p θ (Z | Y) | Y ]
See e.g. Robin (2014) for a proof of this proposition and the following one. The EM algorithm is then an iterative algorithm that maximizes the marginal log-likelihood log p θ (Y ), that is deemed intractable, through the conditional expectation of the com-

pleted log likelihood E θ [ log p θ (Y, Z) | Y],
that is supposed to be easier to handle. Informally, the algorithm can be stated as follow:

Algorithm 1.2.1 (Expectation Maximization). Repeat until convergence: E step Given a current estimate θ h of the vector of parameters θ, compute the moments of log

p θ h (Z | Y) needed to compute E θ h [ log p θ (Y, Z) | Y ] (as a function of θ).
M step Update the estimate of θ as:

θ h+1 = argmax θ E θ h [ log p θ (Y, Z) | Y] .

Background

In general, there are no guarantees for this algorithm to converge to the global maximum of the marginal likelihood. However, we are guaranteed to converge to a local maximum, thanks to the following property, that states that the likelihood is increasing at each step of the algorithm: Proposition 1.2.4 (Increase of the Likelihood). If θ h and θ h+1 are estimates obtained by the EM algorithm described above, then:

log p θ h+1 (Y ) ≥ log p θ h (Y ).
This algorithm is quite general, and can be used both for discrete and continuous models of evolution. It is at the core of our inference strategy in Chapters 2 and 3 of this thesis. For the situations we are looking at, one of the key points is to efficiently compute the E step. As our latent observations are linked by a directed tree, this can be done thanks to pruning-like algorithms, using the formula shown above (Proposition 1.2.2). These algorithms, that can also be called "forward-backward", are designed to compute all the needed quantities in just two traversals of the tree, from the tips to the root, and back.

Discrete Models of Evolution and Tree Reconstruction

The first application of the above formalism are discrete models of trait evolution. As they encompass models of DNA or protein evolution, for which a great amount of data has become available over the last few decades, these models have received a lot of attention. They are often at the core of phylogenetic inference strategies to reconstruct the tree between a set of species. It is hence important to understand how they work, and on which modeling assumptions they are based. We refer the interested reader to O'Meara (2012) and [START_REF] Felsenstein | Inferring Phylogenies[END_REF] for a more comprehensive review of these models and associated methods.

Continuous Time Markov Chains

If the studied trait is discrete, it is natural to model its evolution as a Continuous Time Markov Chain (CTMC). The Markov property of this process P ensures that the resulting random variables follow a latent graphical model on the phylogenetic tree, as defined in 1.2.3 (see Proposition 1.2.1). We start by defining a general CTMC and explore a few of its properties. We then show how it can be used to model trait evolution on a tree. Finally, we give some classical models of trait evolution based on this formalism, along with their assumptions.

A General Model. We start by defining the general model, with its core assumptions.

Definition 1.3.1 (Continuous Time Markov Chain (CTMC)). A continuous time Markov chain (X t ; t ≥ 0) is a random process taking its values in a discrete finite set C, and that is such that, for any 0 < s < t, the conditional law of X t given (X u ; u ≤ s) only depends on the last known value X s , i.e. for all n ∈ N, 0 ≤ t 0 < t 1 < • • • < t n < s and x 0 , x 1 , . . . , x n , x, y ∈ C, we have:

P X t = y X t 0 = x 0 , X t 1 = x 1 , . . . , X t n = x n , X s = x = P X t = y X s = x .
The process is said to be homogeneous if P X t = y X s = x depends on t and s only through the difference ts. In that case, for any time t, we define the transition matrix P(t) on C 2 that is such that:

P X t = y X s = x = P xy (t -s).
This matrix expresses the probability, starting from a state x at time s, to be in state y at time s + (ts). For such a process, we can easily compute the probability µ x (t) of the chain to be in state x ∈ C at time t from the initial state:

µ(t) = µ(0)P(t),
where µ(t) is seen as a row-vector on C.

For any time t, the transition matrix P(t) defines the macro state of the process. However, thanks to the Markovian nature of the process, it is possible to reconstruct the states from the infinitesimal rate of transition from one state to another on a very short time scale. That is the goal of the instantaneous rate matrix, as defined below.

Proposition 1.3.1 (Instantaneous Rate Matrix). Given a CTMC with a transition probability matrix function (P(t); t ≥ 0), there is a rate r > 0 and a matrix Q on C 2 such that:

           Q xy ≥ 0 ∀(x, y) ∈ C 2 , x y Q xx = - y∈C,y x Q xy ≤ 0 (1.2)
and, for h → 0:

P xy (h) = hrQ xy + o(h) P xx (h) = 1 + hrQ xx + o(h). (1.3)
And we have the following relationship:

P(t) = e Qrt .
Equations (1.3) justify that we see Q as an instantaneous rate matrix: on a short time scale h, the probability of going from a state x to a state y is h × rQ xy , i.e. the time elapsed times the rate of change.

Remark that the rate r that multiplies the time is not identifiable from Q. It can be seen as a scaling parameter, that accelerates or decelerates time for the process evolution. In order to make it identifiable, we need some kind of normalization on Q. This will be achieved by normalizing the expectation of the time needed between two events (i.e. the expected time before a transition, see Proposition 1.3.2).

Stationarity. In the following, we make the assumption that the process has a stationary state, as defined below.

Definition 1.3.2 (Stationary State). A vector π of states probability on C is said to describe a stationary state of a CTMC if it is not affected by the transition matrix of the process at any time t: π = πP(t).

Background

Equivalently, π is a stationary state iff πQ = 0.

If it exists and is unique, the stationary state is also the asymptotic state of the chain:

lim t→+∞ P xy (t) = π y ∀(x, y) ∈ C.
In other words, π represents the equilibrium frequencies of each state, that are not affected by the dynamical model of evolution. In the following, we only consider chains that have a stationary state, and often assume that the equilibrium has been reached, i.e. that the chain starts with initial distribution π. As the equilibrium is also the asymptotic state of the chain, this amounts to assuming that, before we started looking at it, the chain has been running for "a large amount of time", and has already reached equilibrium.

Normalization of Q. For a stationary CTMC, we can normalize the instantaneous rate matrix Q, so that the parameter r becomes identifiable. To do that, we normalize the expectation of T 1 the random variable giving the time of the first event of the chain. From the standard properties of a CTMC recalled below, we know the conditional law of T 1 given the initial state of the chain.

Proposition 1.3.2 (Law of T 1 ). Conditionally to the initial state of the CTMC X 0 = x, the time of the first event T 1 and the state Z 1 = X T 1 are two independent random variables, with T 1 following an exponential law with parameter rq x = -rQ xx , and Z 1 a multinomial on C with probabilities given by Q xy q x , y x . For a stationary CTMC, with stationary distribution π, the expectation of T 1 is then given by:

E [T 1 ] = x∈C P [X 0 = x] E [ T 1 | X 0 = x ] = r x∈C π x q x
Imposing E [T 1 ] = r imposes some constraints on Q. As all subsequent times between events have the same law as T 1 , this amounts to imposing a basal rate, given by Q, of one event for every unit of time. The true rate is then controlled by the parameter r. Time Reversibility. It is often convenient to assume that the CTMC is time reversible, meaning that, when played backward, the chain has the same distribution. For a stationary process, this amounts to the following definition.

Definition 1.3.3 (Time Reversibility). A stationary CTMC is said to be time reversible if, for any two states (x, y) ∈ C 2 and any time t:

π x P xy (t) = π y P yx (t)
Equivalently, the stationary CTMC is time reversible iff, for any two states (x, y) ∈ C 2 and any time t:

π x Q xy = π y Q yx
Since it implies that Diag(π)Q is symmetric, it makes Q easier to diagonalise, which is useful when trying to compute P(t) = e Qrt . (Where Diag(π) is the diagonal matrix with the diagonal vector of values equal to π.) On a Tree. We described above the properties of one CTMC running in time. When applied to trait modeling, we need to show how this process can be applied on a tree. The idea is to use the process defined in Section 1.2.1, taking for the process P a CTMC. Definition 1.3.4 (CTMC on a tree). Let T = (E, V ) be a rooted tree, with root ρ, oriented from the root to the tips. Assume that each edge e ∈ E of the tree has an associated branch length e . Given a preorder numbering of the vertices, denote by (X i ) 1≤i≤|V | the sequence of random variables, taking its values in an arbitrary character space C, describing the character of each vertex. Denote by CT MC(Q, r, π) the stationary CTMC with instantaneous rate matrix Q, rate r, and stationary frequencies π. Then a stationary CTMC model of evolution on the tree can be defined as:

X 1 ∼ π: the root is in the stationary state of the CT MC(Q, r, π).
On a given branch e, the character evolves as a CT MC(Q, r, π) for a time e .

At a given node i, the process splits up into two independent CTMCs with the same initial state.

From this definition, each node X i is the result of the CT MC(Q, r, π), running for a time t i , the distance on the tree between node i and the root.

Thanks to Proposition 1.2.1, the model obtained follows the properties of a graphical tree model, as defined in 1.2.3. In particular, the probabilities needed for the factorization described in Definition 1.2.2 are exactly given by matrix P(t): for a node i with parent edge e and parent node pa(i), and any two states (x, y) ∈ C,

P X i = y X pa(i) = x = P xy ( e ).
An example of such a model on a small tree is presented Figure 1.3.1. This is the first example of a process evolving on a tree as defined in Section 1.2.1, for a discrete trait. It will be used again in the Section 1.4 for continuous traits. We stress here again that this construction makes the strong assumptions that all species evolve independently from one another, and that the process has the same parameters on all the branches, meaning that evolution is supposed to follow the same rules over the whole tree. This last assumption will be partly relaxed in Section 1.3.3.

Models of DNA Evolution

The general CTMC framework described above can be applied to any discrete trait, such as the color of a flower, or the absence or presence of a given morphological character. It is however important to check that the assumptions we made are compatible with the evolutionary mechanisms of the studied trait. One of the most fruitful example of traits these models can be applied on are DNA sequences. In the following, we study this particular example in more depth.

Discussion of the Assumptions. We recall here all the assumptions made in the construction above, and see how they can relate to DNA sequence evolution.

Background

800 600 400 200 0 Time before present A G C T X 5 X 6 X 7 X 8 X 9 X 2 X 3 X 4 X 1 Figure 1.3.
1 -Example of a CTMC process evolving on a phylogenetic tree with five tips to model DNA evolution of one site. The states are mapped on the tree using a color code for nucleotide bases: purines (A, G) are in red tones, and pyrimidines (C, T ) are in green tones. We can see the states changing on the branches of the tree, following the branching process. The CTMC is a Kimura model (see Section 1.3.2), with rate r = 0.1 and ratio of transition to transversions R = α 2β = 10 (transitions happen more easily than transversion). The figure was generated using function sim.history of R package phytools [START_REF] Revell | phytools: An R package for phylogenetic comparative biology (and other things)[END_REF].

Independence of Sites: First, we need to define the state space C. Here, we are studying a sequence, that contains m sites, each exhibiting one of the four nucleotide base (A, G, C, T). The state space is hence {A, G, C, T } m . As the length of the sequence m can be large, one way of reducing the state space is to assume that all the sites are independent from one another. In that case, instead of studying the sequence as a whole, we can study each site independently, and we only need to deal with a state space with four elements. This assumption is very convenient, and makes the model tractable, but might not be very realistic. Indeed, at least for a coding sequence, one might think that the sites are somehow related. Following this assumption, from now on we will only consider the evolution of one site, with state space {A, C, T , G}.

Independence of Species: Similarly, at least for coding sequences, it is not clear that this assumption is justified. It is however essential in our modeling approach. As pointed out above, alleviating this assumption would require a completely new model, and is outside of the scope of this manuscript.

Markovian Property: As before, this assumption states that the evolutionary process has "no memory", and is made for mathematical convenience.

Stationarity and Time Reversibility: As pointed out before, these are technical assumptions, that simplify the computations. They have no real biological ground, and some work has already been done to alleviate them [START_REF] Galtier | Inferring pattern and process: maximum-likelihood implementation of a nonhomogeneous model of DNA sequence evolution for phylogenetic analysis[END_REF][START_REF] Boussau | Efficient Likelihood Computations with Nonreversible Models of Evolution[END_REF].

The General Time-Reversible (GTR) Model. Applying the assumptions above, we can derive a general formulation for a CTMC on a tree. Thanks to the independence of sites, we can restrict to a model with 4 states, which has in general 4 2 +4 parameters, for matrix Q and stationary distribution π (the evolution rate r will be treated separately).

The following constraints apply to these parameters:

Constraint Equation Number Instantaneous Rate Matrix (Def. (1.2)) ∀x ∈ C, y∈C Q xy = 0 4 Probability Distribution x∈C π x = 1 1 Normalization (Prop. 1.3.2) -x∈C π x Q xx = 1 1 Time Reversible (Def. 1.3.3) Diag(π)Q symmetric 4 × 3/2 = 6 Total 12
Hence, there are only 20-12 = 8 free parameters in the model, and the instantaneous rate matrix can be written as [START_REF] Lanave | A new method for calculating evolutionary substitution rates[END_REF][START_REF] Felsenstein | Inferring Phylogenies[END_REF]:

Q =              A G C T A - απ G βπ C γπ T G απ A - δπ C π T C βπ A δπ G - ηπ T T γπ A π G ηπ C -             
where the diagonal elements are such that each row sums to zero. This model is a good compromise between complexity and tractability, and is routinely used [START_REF] Bc | Evolutionary Inferences from Phylogenies: A Review of Methods[END_REF].

If the researcher has a better idea of the biological process, it is possible to make extra assumptions. We list here the most common ones, from the least to the most complex. [START_REF] Jukes | Evolution of protein molecules[END_REF]: This model assumes that the instantaneous rate for going from any base to any other is just 1/3. It has only one parameter, the evolution rate r. [START_REF] Kimura | A simple method for estimating evolutionary rates of base substitutions through comparative studies of nucleotide sequences[END_REF] This models distinguishes "transitions" from "transversions", based on the distinction between purines (A, G) and pyrimidines (C, T). Because of some structural constraints, a change within the same group, or transition, happens easily, with rate α. A cross-group change, or transversion, is less frequent, and happens with a rate β. It has two free parameters: the rate r, and the ratio of transitions to transversions α/2β. See Figure 1.3.1 for an example of this process.

Jukes

Tamura & Nei (1993): This model does not assume that the equilibrium frequencies π are all equal to 1/4. In addition, it distinguishes transitions within purines or pyrimidines, with respective rates α 1 and α 2 , and transversions, with rate β. It has 6 free parameters (the rate r, three for the vector π, and two for the transition/transvertion rates). There are two common independent simplifications of this model. If α 1 = α 2 , this model is also known as the HKY model [START_REF] Hasegawa | Dating of the human-ape splitting by a molecular clock of mitochondrial DNA[END_REF]. [START_REF] Kishino | Evaluation of the maximum likelihood estimate of the evolutionary tree topologies from DNA sequence data, and the branching order in hominoidea[END_REF][START_REF] Felsenstein | Inferring Phylogenies[END_REF].

If the extra constraint α 1 -α 2 = α( 1 π A +π G -1 π C +π T ) is imposed, this model is called the F84 model

Molecular Clocks

It follows from the normalization defined in Proposition 1.3.2 that the time rt of the evolution process is expressed in expected number of mutation, rather than real time. However, for some downstream analysis, including the modelling of continuous characters on phylogenies, the main focus of this thesis, it is important that the tree should be 1. Background calibrated in real time t. In particular, this implies that the tree is ultrametric, i.e. that all the tips are synchronized in the present. To be able to do that, we need to make extra assumptions about the mutation rate r. The simplest one is to assume that it is constant across the whole tree, and homogeneous across all the sites studied. For models of DNA evolution, this is known as the molecular clock assumption [START_REF] Zuckerkandl | Molecules as documents of evolutionary history[END_REF], and amounts to assuming that all sites always evolve at the same pace (i.e. mutations are running like clockwork). These two assumptions (steadiness and homogeneity) are quite strong and rather un-realistic. They can be relaxed in several ways.

Gamma Distribution of Rates. One way to relax the homogeneity assumption is to assume that the rates are different at each site, but all drawn from a common probability distribution. This was first proposed by [START_REF] Yang | Maximum-likelihood estimation of phylogeny from DNA sequences when substitution rates differ over sites[END_REF], who used a Γ (α, 1/α) distribution for the rates across the sites. This parametrization using the "shape parameter" α ensures that the expectation of the distribution is 1, and the variance 1/α. A discretization of this distribution is needed to make the computations tractable [START_REF] Yang | Maximum likelihood phylogenetic estimation from DNA sequences with variable rates over sites: Approximate methods[END_REF].

Spatial

Autocorrelation. Under the previous Gamma distribution, the sites are still supposed to be independent. To model the correlation of sites across the DNA molecule, we can use a Hidden Markov Model (HMM). This model assumes that the rate of evolution of one site only depends on its neighbors [START_REF] Yang | A space-time process model for the evolution of DNA sequences[END_REF][START_REF] Felsenstein | A hidden Markov Model approach to variation among sites in rate of evolution[END_REF].

"No Common Mechanism". One radical way to solve the problem of heterogeneity of rates is to assume that each site has its own rate on each branch of the tree. This amounts to adding a matrix (r e,i ) e∈E,1≤i≤m of |E| × m extra parameters. This is called the "no common mechanism" model, and has been developed by [START_REF] Tuffley | Links between maximum likelihood and maximum parsimony under a simple model of site substitution[END_REF]. Even though this model might have too many parameters to be biologically relevant [START_REF] Huelsenbeck | Biologically inspired phylogenetic models strongly outperform the no common mechanism model[END_REF], it is quite important from a theoretical point of view, as it makes the link between maximum parsimony and maximum likelihood methods of tree reconstruction [START_REF] Tuffley | Links between maximum likelihood and maximum parsimony under a simple model of site substitution[END_REF], see next section).

Relaxed Molecular Clocks. The rates can also vary in time for one single site. HMMs can also be used to model a changing pace of evolution, with periods of times where the site evolves rapidly, and others where the evolution is slower. Such models are called covarions models [START_REF] Fitch | An improved method for determining codon variability in a gene and its application to the rate of fixation of mutations in evolution[END_REF][START_REF] Galtier | Maximum-Likelihood Phylogenetic Analysis Under a Covarion-like Model[END_REF], and are discrete (i.e. the rate can change between two branches, but is steady on one branch). Other models assume a Poissonian distribution of changes of rates on the tree, such as [START_REF] Huelsenbeck | A compound poisson process for relaxing the molecular clock[END_REF]. It is however difficult to take both space and time autocorrelations into account in the same model.

We only browsed some of the most used models of DNA sequence evolution, but the field is still active, and many refinements can be made [START_REF] Bc | Evolutionary Inferences from Phylogenies: A Review of Methods[END_REF]. One of the most commonly used model is the "GTR+Γ with clocks" model, that assumes a GTR CTMC, a (discrete) Γ distribution for spatial distribution of rates, and a relaxed molecular clock for the evolution of the rates in time.

Tree Reconstruction

All the models described above assumed that the tree was already known, and were simply describing how the character evolves on it. In this section, we briefly recall how these models can be used for tree reconstruction from trait data for a set of extant species that are to be related by the phylogeny. Here, the trait studied will mostly be a set of aligned DNA sequences. Getting these sequences, and preparing them to be analysed, is a difficult question in itself, that we won't cover here (see e.g. Li & Homer, 2010, for a review). The basic strategy to infer a tree from a set of traits is two fold:

1. Explore the space of phylogenetic trees, to propose some candidates.

2. Rate these candidates with a common score, that can be likelihood, or parsimony.

Thanks to all the models and notions we introduced above, we have all the background needed to handle point 2. Point 1 is out of the scope of this introduction, and we will only sketch some strategies to tackle it.

Computing a Score. Depending on the model chosen, the score is either parsimony or likelihood. We reviewed in Section 1.1.3 two efficient algorithms to compute the parsimony score of a given tree topology. From the "no common mechanism" model mentioned in section 1.3.3, finding a minimum parsimony score can actually be re-framed into a maximum likelihood problem, although in practice this is not efficient. Depending on the model for character evolution chosen, the computation of the likelihood is more or less computationally intensive. In any case, it benefits from the tree-structured model defined in Section 1.2.3, and some pruning algorithms can be used. We refer to the papers describing the models for more information about each model inference strategy.

Exploring the Tree Space. The problem of efficiently searching the tree space is difficult, mostly because this space is large, growing as n n , if n is the number of tips. Restricting ourselves to binary trees, the exact number T n of different topologies linking a set of n species can be easily computed [START_REF] Cavalli-Sforza | Phylogenetic Analysis: Models and Estimation Procedures[END_REF][START_REF] Felsenstein | Inferring Phylogenies[END_REF] as:

T n = n-2 i=1 (2i + 1).
Hence, an extensive search of the space is not possible, and we have to resort to heuristics to explore the space the best we can. Many strategies can be imagined, and we refer to Felsenstein (2004, Chap. 4) for a review of the main approaches used. Most of them rely on a "hill climbing" strategy, trying to improve the score by exploring the "neighborhood" of a candidate tree. Such strategies are only guaranteed to converge to local extrema, and choice of the starting point is often crucial. They each rely on their own metric on the tree space, that defines which trees are close from one another (see St. John, 2016, for a review).

Continuous Models of Evolution

In the previous section, we applied the generic model of trait evolution described in Section 1.2.1 to discrete traits. In this section, we show how to model the evolution of 1. Background a set of continuous traits, using a continuous state space Markov process P . We first describe the two processes we use in the rest of the manuscript, before showing some already existing methods for their inference. This will lead us to review the state of the art on the question of automatic shift detection, the main subject of this manuscript.

Models of Evolution

The two processes we are going to study in more depths are Gaussian processes, namely, the Brownian Motion and the Ornstein-Uhlenbeck. We review them both in this section, along with their assumptions. Thanks to the definition we gave of a stochastic process on a tree (Def. 1.2.1), we only need to describe the process used P , and the law of the root trait.

Brownian Motion

Definition of the Process. The Brownian Motion (BM) is the simplest Gaussian process that can be used, and it was the first one introduced to model trait evolution on a tree, with the seminal articles of [START_REF] Cavalli-Sforza | Phylogenetic Analysis: Models and Estimation Procedures[END_REF][START_REF] Felsenstein | Phylogenies and the Comparative Method[END_REF]. A multivariate BM (W t , 0 ≤ t) of dimension p, with variance R = ΣΣ T and expectation µ is defined by the following Stochastic Differential Equation (SDE):

W 0 = µ dW t = ΣdB t , ∀t ≥ 0,
where B t is the multivariate BM with variance I p , uniquely defined as the process with independent and stationary increments, almost surely continuous, and such that B t ∼ N (0, tI p ) for any t ≥ 0. We show Figure 1.4.1 one realization of this process for a simple tree.

X 5 X 6 X 7 X 8 X 9 X 2 X 3 X 4 X 1 t 4 = t 56 h (a) A phylogenetic tree -4 -2 0 2 4 6 time phenotype -200 -150 -100 -50 0 X 5 X 6 X 7 X 8 X 9 X 1 X 2 X 3 X 4
(b) BM on the branches of the tree Induced Data Structure. Once the model is defined, we need to explore its consequences on the structure of the traits observed at the tips of the tree. Let Y be the n × p matrix of the observed p traits at the n tips of the tree. Then, if Y is the result of a BM evolution on the tree, with root node randomly distributed as a multivariate Gaussian N (µ, Γ), it follows the distribution [START_REF] Felsenstein | Inferring Phylogenies[END_REF][START_REF] Clavel | mvmorph : an r package for fitting multivariate evolutionary models to morphometric data[END_REF]: 4) where C n = [t ij ] 1≤i,j≤n , with t ij the time of shared evolution of tips i and j, i.e. the time elapsed between the root and the most recent common ancestor (mrca) of i and j, and 1 n is the vector of ones. The operator vec is the vectorization operator, that constructs a vector by "stacking" all the columns of a matrix, and ⊗ denotes the Kronecker product (see Appendix 1.B for a definition and some properties of these operators).

vec(Y) ∼ N (vec(1 n µ T ), R ⊗ C n + Γ ⊗ (1 n 1 T n )) (1.
The formula above entirely defines the law of the matrix of observed traits at the tips, given the law of the root and the variance matrix R of the BM, sometimes called the rate matrix. Another way to describe the covariance structure is to write the covariance Cov Y ik ; Y jl between trait k at tip i, and trait l at tip j (with 1 ≤ i, j ≤ n and 1 ≤ k, l ≤ p):

Cov Y ik ; Y jl = t ij R kl + Γ kl .
(1.5)

In other words, the covariance between Y ik and Y jl only depends on the product of the time of shared evolution t ij between the tips, and the variance R kl between the traits (plus the residual variance of the root traits). This factorization of the total variance in a product of the variance induced by the tree structure and the variance induced by the process is a direct consequence of the independence of increments of the BM, and will be very useful in the following. Note that often, the model is described conditionally to the root, so that the root variance Γ is reduced to the null matrix.

Ornstein-Uhlenbeck

Definition of the Process. The Ornstein-Uhlenbeck (OU) is a simple refinement over the BM. In addition to a Brownian, stochastic part, it has a deterministic call-back component, that pulls the modeled traits back to a central parameter, β. Its SDE can be written as:

W 0 = µ dW t = -A(W t -β) + ΣdB t , ∀t ≥ 0,
where A is the selection strength matrix, that describes how the modeled traits W go back to their optima β. This process was introduced in the field of phylogenetic comparative methods by [START_REF] Hansen | Translating Between Microevolutionary Process and Macroevolutionary Patterns: The Correlation Structure of Interspecific Data[END_REF]; [START_REF] Hansen | Stabilizing Selection and the Comparative Analysis of Adaptation[END_REF]. See Section 1. 4.1.3 (below) for a biological interpretation of this process to model stabilizing selection.

Properties. Contrary to the BM, and because of the call-back term of the equation, the increments of the OU are no longer independent and stationary. This makes its distribution more complex to write (see next paragraph below), and will make its inference more difficult (see Section 2.4.1 and Appendix 2.C.3). However, contrary to the BM, the OU has a bounded variance, and admits a stationary state, provided that all the eigenvalues of the selection strength matrix A are positive. When the process is univariate, the selection strength reduces to a positive scalar α, and the distribution of the stationary state can be easily expressed as a Gaussian with mean β the optimal value, and variance σ 2 /(2α). Often, it is easier to express the selection strength as a "phylogenetic half-life" t 1/2 = ln(2)/α [START_REF] Hansen | Stabilizing Selection and the Comparative Analysis of Adaptation[END_REF]. It is defined as the time needed by the process to cover half the distance from its current value to the optimum. Being homogeneous to a time, it can be handily compared with the total height h of the tree. If t 1/2 is small compared to h, it means that the process has enough time to reach its equilibrium during its time course on the tree. On the contrary, if t 1/2 is large compared to h, then the process will never reach its optimal state before present. See Figure 1.4.2 for a simple illustration of a univariate OU process (non branching).

Induced Data Structure. The distribution induced by such a multivariate OU at the tips of the tree is slightly more complex than in the Brownian case. It can be showed [START_REF] Bartoszek | A phylogenetic comparative method for studying multivariate adaptation[END_REF][START_REF] Clavel | mvmorph : an r package for fitting multivariate evolutionary models to morphometric data[END_REF], and see Section 1.A) that the distribution of the matrix Y of observed traits at the tips is Gaussian, and we can express its moments as follows. For 1 ≤ i, j ≤ n two tips, let Y i = (Y i1 , . . . , Y ip ) T the (transpose) row-vector of the traits at tip i. Then:

E Y i = e -At i µ + (I -e -At i )β Cov Y i ; Y j =        e -At i Γe -A T t j -e -At i Se -A T t j + e -A(t i -t ij ) Se -A T (t j -t ij ) general case e -A(t i -t ij ) Γe -A T (t j -t ij )
stationary root (1.6) where root node is randomly distributed as a multivariate Gaussian N (µ, Γ), and S is the stationary variance matrix of the OU (see Equations (1.30) and (1.32) in Section 1.A for a general expression of S). The second formula for the variance is obtained when the root is drawn with the stationary variance, i.e. if Γ = S.

Remark that this expression implies that the initial value µ and the optimum value β are not identifiable if the tree is ultrametric, i.e. if t i = h for any 1 ≤ i ≤ n, where h is the height of the tree. Indeed, in this case, we only observe the combination λ = e -Ah µ+(I-e -Ah )β at all the tips, and only this parameter is identifiable. This was pointed out in the univariate case by [START_REF] Ho | Intrinsic inference difficulties for trait evolution with Ornstein-Uhlenbeck models[END_REF]. To circumvent this problem, we often make the assumption that the root mean value is the ancestral stationary state. In that case, we get µ = β = λ. See Figure 1.4.3 for a simple illustration of this phenomenon.

1 1 10 Trait Value (a) λ = µ = β = 1 1 1 10 Trait Value (b) λ = 1, µ = 10, β = -2
Figure 1.4.3 -Representation of the trait evolution of a univariate OU, with fixed root (γ 2 = 0), and recall parameter α chosen such that t 1/2 = 50% of the tree height. All the tips have the same expectation value, equal to λ = e -αh µ + (1e -αh )β = 1. The ancestral expectations at the internal nodes of the tree are indicated by a color. On the first scenario (left), the trait starts with a value µ = 1 equal to its optimum value β, and hence never moves away from it. In the second scenario (right), the trait starts with a value µ = 10, far away from the optimum value β = -2. Hence, in the times allowed for its evolution, its expectation tries to move from 10 to -2, but when time stops, all the tips have reached the (out of equilibrium) value of λ = 1. The two scenarios give the exact same observed distribution at the tips, and hence are not identifiable from one another.

Note that these expressions simplify greatly when A is scalar (i.e. when A = αI), and a fortiori when the trait is univariate. See Section 1.A and the Chapters 2 and 3 of this thesis for exact expressions.

Biological Interpretation

It is important to understand that the BM and OU used to model trait evolution at an evolutionary time-scale are distinct from models of phenotype evolution used in Quantitative Genetics, that describe evolution on a much shorter time-scale. Depending on the type of genetic variation and influence of the environment, many models of microevolution can be developed. [START_REF] Lande | Natural Selection and Random Genetic Drift in Phenotypic Evolution[END_REF] famously showed how constant additive genetic drift under a static adaptive landscape could give rise to trait evolution following either a BM (for a flat adaptive landscape) or an OU (for a landscape with a single peak). These processes are however valid only on a very short time-scale, ranging from 10 3 to 10 5 years [START_REF] Hunt | Phenotypic Evolution in Fossil Species: Pattern and Process[END_REF]. A good example of an OU evolution from an optimum to another was observed on the particularly rich fossil record of the armor development in a lineage of stickleback fish [START_REF] Hunt | Evolution toward a New Adaptive Optimum: Phenotypic Evolution in a Fossil Stickleback Lineage[END_REF][START_REF] Hunt | Phenotypic Evolution in Fossil Species: Pattern and Process[END_REF]. Even if the selection strength for this group is quite weak, only a few thousands years were needed for the adaptation to happen. If the selection is high, this phenomenon can even be observed empirically, in real-times studies. Evidences of adaptation could hence be found for an arboreal niche in native Anolis species carolinensis after the introduction of an invasive species sagrei from Cuba to small islands off Florida in only 15 years [START_REF] Yang | A space-time process model for the evolution of DNA sequences[END_REF][START_REF] Fitzjohn | Quantitative traits and diversification[END_REF][START_REF] Stuart | Rapid evolution of a native species following invasion by a congener[END_REF].

Background

Those time scales are to be compared with the height of a typical phylogenetic tree, ranging between 10 7 to 10 8 years (e.g. around 2.5 • 10 7 years for New World Monkeys Aristide et al., 2016, 1.1 • 10 8 years for birds Jetz et al., 2012, and 2.1 • 10 8 years for Chelonians, [START_REF] Jaffe | The evolution of island gigantism and body size variation in tortoises and turtles[END_REF]. On such long stints, the assumptions used by [START_REF] Lande | Natural Selection and Random Genetic Drift in Phenotypic Evolution[END_REF] do not hold anymore. It indeed has been observed that the rate of phenotypic change inferred from fossil records was much lower than expected from these models, which has been referred to as "the paradox of stasis" [START_REF] Hansen | Phenotypic integration: studying the ecology and evolution of complex phenotypes[END_REF]. The interpretation of the use of BM and OU processes in this context hence need to be adapted.

The BM used does not represent the plain consequences of a genetic drift, but rather the random evolution of adaptive niches. The assumption is that the traits are going to their optimal values very quickly (compared to the total height of the tree), and hence that what we are tracking down are the successive optima, rather than the bare trait. The BM would hence represent the stochastic evolution of the ecological niche in time, or secondary optimum, to follow the nomenclature of [START_REF] Hansen | Stabilizing Selection and the Comparative Analysis of Adaptation[END_REF]. That would explain why the rate of evolution measured on macro-evolutionary time scales is not the same as the rate measured for microevolution. It is also worth noting that, using this interpretation, the BM can be used to model adaptive traits on phylogenies, provided they adapt to a random environment (Felsenstein, 2004, Chap. 24).

The interpretation of the OU in this context is then similar, except that the secondary optimum itself is converging toward another primary optimum [START_REF] Hansen | Stabilizing Selection and the Comparative Analysis of Adaptation[END_REF]. It expresses the idea that the adaptive landscape usually goes through many local, stochastic changes, but sometimes shifts drastically, due to a major environmental event, such as migration, or climate change (see e.g. [START_REF] Jaffe | The evolution of island gigantism and body size variation in tortoises and turtles[END_REF]. The OU has in addition the advantage over the BM that its variance is bounded, and that it has a stationary state, which can make it more suitable to study stabilizing selection [START_REF] Hansen | Assessing Current Adaptation and Phylogenetic Inertia as Explanations of Trait Evolution: The Need for Controlled Comparisons[END_REF].

Following the interpretation given above, we will always assume in the following that we are studying the secondary optimum, rather than the traits, of the species at hand. This secondary optimum is approached by the empirical mean of the traits within all the individuals measured for a given species. Doing that, we completely ignore the intraspecific variations, as well as measurement errors, that are often not very well known. There are however several methods to take them into account, and ignoring them can lead to severe biases in the analysis. See Section 1.4.5.1 of this introduction for a brief review of these methods, and Perspective Section 5.1 for a study of the impact of these errors on shift detection, and ways to explicitly model them in our framework.

Phylogenetic Comparative Methods

Phylogenetic Comparative Methods are the tools used to study continuous traits of related species. It relies on models of evolution such as the ones presented above, and aims at finding patterns in the traits studied, while taking into account the relatedness of the species at hand. We will see how this problem can be recasted as a general linear model, i.e. a linear model where the residual errors are not independent. This formulation leads us to see the tree as a "nuisance" structure parameter, that can be taken into account in several ways. Using the regression term of the model, we also see how some fixed shifts can be introduced in the processes described above.

Felsenstein's Phylogenetic Contrasts

Until now, we have been looking at the problem in a dynamic fashion, trying to model the evolution of one or several traits in time, on a phylogenetic tree. However, the data accessible to researchers are only traits measured on extant species, in the present. Hence, apart from some rare cases where good fossil records are available, inference on the dynamic component of the problem is bound to be quite limited, and interest in this topic quite recent. Historically, the questions yielded by this kind of data were more ecological, and the focus was on trying to infer some correlations between several observed traits.

Let's follow [START_REF] Felsenstein | Phylogenies and the Comparative Method[END_REF] original example, and assume that we measured two traits (say, traits A and B) for 32 species of a same phylogenetic group (see also Felsenstein, 2004, Chap. 25). This kind of data is abundant in the literature (see e.g. [START_REF] Pennell | An integrative view of phylogenetic comparative methods: connections to population genetics, community ecology, and paleobiology[END_REF]. Suppose that we make a scatter plot of the two traits, for all species, as shown Figure 1.4.4. On this figure, there seems to be a clear trend, and it is tempting to conclude that the two traits A and B are indeed biologically correlated. However, this analysis does not take the phylogenetic tree into account. In other words, it assumes that all the species are independent, where in fact they are all related. Indeed, two species that are close parents in the tree are bound to have a more similar trait than two distantly related ones, since they had less time to diverge away. We can see the influence of the tree by plotting the tree along with the scatter plot, as shown Figure 1. 4.5. Figure 1.4.5 shows us that ignoring the tree can be misleading on the actual biological process going on. Indeed, the traits plotted were actually simulated according to two independent BM on the tree, so, in contradiction with the conclusion of our first naive regression, there are no biological correlation between traits A and B.

One first way to deal with this structure induced by the phylogenetic tree is to use the so-called phylogenetic contrasts [START_REF] Felsenstein | Phylogenies and the Comparative Method[END_REF]. In this model, we assume that 1. Background (a) The phylogenetic tree linking the 32 species. There are two well formed clades, showed in white and black.

A B (b) The same scatter plot as before, but with species colored according to their clade. (Arbitrary scales omitted.)

Figure 1.4.5 -When the species are colored according to their clades, we can see that they are two clearly formed groups. The correlation seems to be entirely driven by this distinction. Within each group, the correlation is not obvious.

the traits observed at the tips were generated according to a multivariate BM on the (known) phylogenetic tree, and we take advantage of the independent increments of the BM to construct new variables, or contrasts that are independent from each other. We describe the procedure in the pseudo-algorithm below for a univariate trait, the extension to multivariate being straightforward.

Algorithm 1.4.1 (Phylogenetic Contrasts [START_REF] Felsenstein | Phylogenies and the Comparative Method[END_REF]). Assume that we have a latent tree model as defined in Definition 1.2.3 on a rooted phylogenetic tree T = (E, V ), with the characters (X 1 , • • • , X |V | ) following a BM model of evolution on the tree, with variance σ 2 . We assume that the tree is bifurcating, and that each branch e has length e . Iterate the following steps:

1. Find two adjacent tips on the tree, numbered i and j, with common ancestor node k.

2. Compute the contrast C a = X i -X j , and update the ancestral trait value of node k to:

X k = j X i + i X i i + j .
The two new quantities have the following properties:

E [C a ] = 0 Var [C a ] = σ 2 ( i + j ) Cov C a ; X k = 0 Cov X k ; X l = Cov [X i ; X l ] = Cov X j ; X l , ∀l {i, j, k} Var X k = σ 2 i j j + j + Var [X k ]
3. Drop the two tips i and j from the tree, and replace their ancestor X k by X k . Add an extra length δ k = i j j + j to the branch going to node k (so that k = k + δ k ).

4. Go back to step 1 if the output tree has more that 3 nodes.

After this iteration, starting with n measures at the tips, we end up with n -1 contrasts (the tree is bifurcating), each independent, and with a known variance.

If we apply this method to our toy-dataset, we get the scatter plot presented Figure 1.4.6. The spurious correlation effect does not appear anymore, and the traits, that were indeed simulated to be independent, are not seen as correlated anymore. et al., 2004) function pic). A Pearson correlation test between the two traits gives a p-value of 0.88: there is no significant correlation between the two traits. (Arbitrary scales omitted.) Algorithm 1.4.1 is quite efficient, as it only needs one tree traversal. However, it is not very flexible, and models other that the BM cannot be used. The general framework of the phylogenetic regression will allow us to extend this approach to a more general class of models.

The Phylogenetic Regression Framework

The idea of Phylogenetic regression is to recast the problem in the framework of a generalized linear model. If Y is an n × p matrix of p traits measured at the n tips of a phylogenetic tree, we write:

Y = Xθ + E (1.7)
where X is an n × q matrix of regressors, θ a q × p matrix of coefficients, and E an n × p error vector, that is such that vec(E) ∼ N (0, S )

with S an np × np variance matrix given by the model of trait evolution used. Note that this can also be seen as a mixed model, as the errors are not independent identically distributed (i.i.d.). This formalism was introduced by [START_REF] Grafen | The Phylogenetic Regression[END_REF][START_REF] Grafen | The uniqueness of the phylogenetic regression[END_REF] for the Brownian Motion, and has been extended to fit a myriad of other phylogenetic models of trait evolution. The main idea is that the model of evolution will induce different kinds 1. Background of correlations between the species, and hence induce a different form for the variance matrix S . We give here a couple of examples for S .

Brownian Motion. Taking the notations of Section 1.4.1.1, if the root is assumed to be fixed (or if inference is done conditionally to the root's value), then a set of traits resulting from a BM can be written as:

Y = 1 n µ T + E with vec(E) ∼ N (0, R ⊗ C n ) (1.8)
and this fits model (1.7), with X = 1 n , θ = µ T , and S = R ⊗ C n . In that case, this model is the same as the one used for the phylogenetic contrasts method, that can be seen as an efficient way deal with this regression problem. The strength of this new formulation is to recast the problem in a well known statistical framework, and hence to benefit from all the classical inference and analysis tools available in the literature (see, e.g. [START_REF] Mardia | Multivariate analysis. Probability and mathematical statistics[END_REF], for multivariate regression models). Note that in the Brownian case, some explicit maximum likelihood estimators can be exhibited, although their naive computation require the inversion of matrix C n , which can be computationally intensive for large trees. We refer to Section 1.4.4 for some computational tools to make these computations more light-weight. This model can be easily enriched by adding some covariates in the regression matrix X. This can for instance allow us to explore the direct links between a trait and an environmental predictor [START_REF] Grafen | The Phylogenetic Regression[END_REF].

Ornstein-Uhlenbeck. Similarly, using the developments of Section 1.4.1.2, we can cast the multivariate OU on an ultrametric tree in this framework. The expressions of matrices X and S directly follows from Equation (1.6). Note that the expression of S is a bit tedious in the general case, and cannot be nicely factorized as in the BM case.

The univariate OU, with selection strength α, variance σ 2 , and initial variance at the root γ 2 is easier to write:

Y = 1λ + E with E ∼ N (0, S(α))
with λ = e -αh µ + (1e -αh )β, and for 1 ≤ i, j ≤ n two tips,

S(α) ij = e -2αh γ 2 + e -2αh (e 2αt ij -1) σ 2 2α
(1.9)

The two cases where the root variance is either null or equal to the stationary variance are often considered, in which case the expression simplifies to:

S(α) ij =        e -2αh (e 2αt ij -1) σ 2 2α fixed root e 2αd ij σ 2 2α
stationary root where d ij = 2(ht ij ) is the phylogenetic distance between i and j. Note that, when α goes to zero, we recover the variance structure of a simple BM, as expected (e.g. for a fixed root):

S(α) ----→ α→0 σ 2 C n 1.4.2

.3 Some Tree Transformations

Once recasted in this linear regression framework, we can see that the model of trait evolution on the tree only impacts the problem through the variance matrix S . Forgetting for a moment the mechanistic model, the biological interpretation of which might be dubious, as seen in Section 1.4.1.3, it can be tempting to see the tree only as a measure of correlation between traits, whose strength needs to be adjusted. Restricting ourselves to the univariate case for the sake of clarity, recall that the Brownian model can be written as:

Y = Xθ + E with E ∼ N (0, σ 2 C n ) (1.10)
and the tree structure of the data is entirely represented by matrix C n = [t ij ] 1≤i,j≤n . The idea originally presented in [START_REF] Pagel | Inferring the historical patterns of biological evolution[END_REF] is to take this model as a base scenario, and to alter it in several ways in order to weaken the Brownian-induced structure, that might be ill suited to some traits. It is a very pragmatic view of the problem, as it introduces an ad hoc parameter that is chosen in order to fit the data at best. We review here some of these classical tree transformations.

Pagel's λ [START_REF] Pagel | Inferring the historical patterns of biological evolution[END_REF]. This first and most popular transformation introduces a new parameter λ, that alters the variance matrix in the following way:

C(λ) ij = λC ij ∀i j C(λ) ii = C ii ∀1 ≤ i ≤ n (1.11)
The parameter λ only affects the covariances between tips, and leave their variances unchanged. This modified variance matrix can be seen as resulting from a BM evolving on a tree with modified branch lengths, in the following way:

i (λ) =        λ i if i is an internal node i + (1 -λ)t pa(i) = λ i + (1 -λ)t i if i is an external node (tip)
(1.12)

This amounts to multiplying all the internal branch lengths by λ, and then lengthening the external branch lengths so that the resulting tree keeps its original height. When λ = 1, the model reduces to a BM on the original tree. When λ = 0, all the tips are independent, and the model is equivalent to a BM on a star tree (see Fig. 1.4.7). This parameter λ is hence sometimes seen as a measure of the phylogenetic signal exhibited by the data Note that this extra parameter λ needs to be fitted along with θ and σ 2 . There are no explicit estimator for this parameter, and it needs to be optimized numerically. It is then common to design a likelihood ratio test to test λ = 0 against λ > 0, in order to test 1. Background the heritability of the trait at hand, i.e. whether the trait is impacted by the phylogeny or not. (Note that as the null hypothesis lies at the boundary of the domain, one must be cautious in defining the asymptotic distribution of the statistic, see e.g. [START_REF] Self | Asymptotic Properties of Maximum Likelihood Estimators and Likelihood Ratio Tests Under Nonstandard Conditions[END_REF]).

Pagel's κ [START_REF] Pagel | Inferring the historical patterns of biological evolution[END_REF]. In this model, all the branch lengths are set up to the power κ:

i (κ) = ( i ) κ ∀1 ≤ i ≤ n
When κ > 1.0, more change is expected on long branches, while short branches are even shortened. On the contrary, if κ < 1.0, then short branches are made longer, while long branch are shortened. Note that the resulting tree is not ultrametric anymore (see Fig. 1.4.8). The variance matrix C is obtained by running a BM on the re-scaled tree. Pagel's δ [START_REF] Pagel | Inferring the historical patterns of biological evolution[END_REF]. In this model, the node depths are all set up to the power δ:

t i (δ) = (t i ) δ • h 1-δ ∀1 ≤ i ≤ n
where the factor h 1-δ ensures that the resulting tree keeps the same total height h. When δ > 1.0, more change is expected toward the end of the tree, i.e. the evolution of the character happened late in time. On the contrary, if δ < 1.0, then most of the trait evolution is expected to happen near the root, and the trait stays stable later in time (see Fig. 1.4.9).

The OU as a Tree Transformation

In the previous section, we have given a mechanistic interpretation of the OU to model trait evolution. However, looking at Equation (1.9), we can see that the variance structure induced by the OU can be obtained by running a BM on a tree with branch lengths modified as follow:

i (α) = 1 2α e -2αh (e -2αt i -e -2αt j ) (1.13)
To yield exactly the same distribution, the BM used must be taken with a root variance of e -2αh γ 2 , where γ 2 is the root variance of the original OU. Note that this only holds for ultrametric trees, and that this branch lengths transformation is similar but distinct from the classical time transformation used to get a Brownian solution to the OU SDE (see Section 1.A, Lemma 1.A.1 for a recall of this unused transformation). This branch lengths transformation has been described and used several times in the literature, under different forms [START_REF] Blomberg | Testing for Phylogenetic Signal in Comparative Data: Behavioral Traits Are More Labile[END_REF]Ho & Ané, 2013a;[START_REF] Pennell | Model Adequacy and the Macroevolution of Angiosperm Functional Traits[END_REF]. It is at the core of our inference strategy in Chapter 3.

The induced tree transformation is presented Figure 1.4.10. The effects on the tree are similar to Pagel's δ transformation when δ > 1.0: the higher α is, the more evolution happens toward the present. In the limit α → +∞, the tree tends to a star tree.

Other Models of Evolution

We have been focusing until now on only two models of evolution, namely, the BM and the OU, but the flexibility of the phylogenetic regression framework allows for many more models. When crafting a model, the only limits are tractability and identifiability. Indeed, the model needs to be summarized in the variance matrix S , so that, first, one needs to be able to carry the computations out to get the form of the matrix, and then ensure that no other common process could result in the same variance structure. To give the reader an idea of this mechanism, we give some details of two other popular models.

ACDC. The Accelerating / Decelerating (ACDC) model, sometimes also called the Early Burst (EB) model, was first introduced in [START_REF] Blomberg | Testing for Phylogenetic Signal in Comparative Data: Behavioral Traits Are More Labile[END_REF], and further developed in [START_REF] Harmon | Early Burst of Body Size and Shape Evolution are Rare in Comparatice Data[END_REF]. Using the same notations as before, the SDE describing the trait evolution in time can be written as:

W 0 = µ dW t = σ 2 (t)dB t , ∀t ≥ 0, with σ 2 (t) = σ 2 0 e rt
The variance matrix of the traits at the tips of the tree can then easily be derived as [START_REF] Blomberg | Testing for Phylogenetic Signal in Comparative Data: Behavioral Traits Are More Labile[END_REF][START_REF] Uyeda | Comparative Analysis of Principal Components Can be Misleading[END_REF]:

S(r) ij = σ 2 0 e rt ij -1 r 1. Background
The trait is hence assumed to follow a BM on the tree, but with a variance that is changing in time, either increasing (r > 0, AC) or decreasing (r < 0, DC). The effect is hence similar to Pagel's δ transform described above. It indeed can also be seen as a tree transformation, just like the OU. In fact, it is easy to see from Equation (1.9) showing the variance matrix of the OU that the AC model (r > 0) is equivalent to the OU in some cases, as expressed by the following proposition, first proved in the Appendix of [START_REF] Uyeda | Comparative Analysis of Principal Components Can be Misleading[END_REF]:

Proposition 1.4.1 (Equivalence of OU and ACDC [START_REF] Uyeda | Comparative Analysis of Principal Components Can be Misleading[END_REF]). The OU with a fixed root (γ 2 = 0), such that the initial value is equal to the optimal value (µ = β), with selection strength α and variance σ 2 , on an ultrametric tree, yields the same covariance matrix than an AC with parameters:

σ 2 0 = σ 2 e -2αh r = 2α
OUBM and OUOU. To explore situations where the optimum value β of an OU varies in time, [START_REF] Hansen | A Comparative Method for Studying Adaptation to a Randomly Evolving Environment[END_REF]; [START_REF] Bartoszek | A phylogenetic comparative method for studying multivariate adaptation[END_REF] introduced the "OUBM" and "OUOU" models of phenotypic evolution. In these models, the primary optimum β(x) is explicitly modeled as a BM or an OU process, while the secondary optimum y is selectively called back to it following an OU. In its simplest form, the OUBM model can be expressed by the set of equations [START_REF] Hansen | A Comparative Method for Studying Adaptation to a Randomly Evolving Environment[END_REF]:

dy = -α(y -β(x))dt + σ y dB y with β(x) = b 0 + b 1 x dx = σ x dB x
where B x and B y are independent BMs with variances σ 2 x and σ 2 y , α is the selection strength, y is the response variable following an OU, and x a predictor variable determining the evolution of the primary optimum β(x). It is possible to derive the variance matrix at the tips induced by such a model [START_REF] Hansen | A Comparative Method for Studying Adaptation to a Randomly Evolving Environment[END_REF]:

S ij = b 2 1 σ 2 x + σ 2 y 2α (1 -e -2αt ij )e -αd ij + b 2 1 σ 2 x t ij       1 -e -αh αh 2 -2 1 -e -αh αh 1 -e -αt ij αt ij e -αt ij /2       .
The OUOU model is similar, except that the second equation is replaced by an OU (see [START_REF] Bartoszek | A phylogenetic comparative method for studying multivariate adaptation[END_REF] for a study of this model in a multivariate setting). Similar expressions for the distribution of the traits at the tips of the tree can be obtained.

Detecting Shifts

In all the models described above, we assumed that there were only one set of parameters controlling the process on the entire tree. When the species linked by the tree are heterogeneous (for instance, if the tree is big and spans over a long period of time), then this assumption is likely to be false, and one might want to define regions in the tree, each with its own "regime", i.e. allowing some parameters to differ from one region to another. Looking at the process dynamically, this amounts in considering parameters that are piecewise constants, and experience some shifts in their history. When having an effect on the expectation, we will show how these shifts can easily be included in the linear regression framework, provided their position is known a priori. The main focus of this thesis is to automatically detect the position of those shifts. We first review some methods in the literature trying to tackle this issue, before presenting models putting shifts in other parameters of the process (such as variance or selection strength).

Including Shifts in the Regressors

The problem of adding shifts in the optimal value of an OU was first tackled by the seminal article of [START_REF] Butler | Phylogenetic Comparative Analysis: A Modeling Approach for Adaptive Evolution[END_REF] for the OU. We do not expose the specifics of their method here, but instead show how this problem can be recast in the linear model framework. We only sketch here the main results, but this problem is carefully exposed in Section 2.2.3 for the univariate process, and Section 3.2 for the multivariate one. Although quite simple, this new parametrization of the problem is very powerful, as it allows us to benefit from the proficient literature on linear models.

In this section, we assume that we have an ultrametric tree T = (E, V ), with all nodes numbered from 1 to |V | = m + n, with n tips and m internal nodes. We give to each branch the number of its daughter node (including a fictive branch associated with the root). We study a multivariate BM or OU on the tree, with dimension p. We assume that, for the BM, the mean parameter µ, and, for the OU, the primary optimum β can shift on the phylogeny. Denote by ∆ the (m + n) × p matrix of those shifts: line j takes the p values of the shifts on each traits if there is indeed a shift on the branch leading to node j, and is null otherwise. We further define the incidence matrix as follow.

Definition 1.4.1 (Incidence Matrix). The incidence matrix U associated with the tree is the matrix of size (m + n) × (m + n) defined by the formula:

U ij =        1 if j is an ancestor of i 0 else.
Denote further by T the n × (m + n) sub-matrix of U with only lines corresponding to tips.

We refer to Example 1.4.1 for an example of such a matrix on the small tree presented Figure 1.4.1. (See also Example 2.2.1 in Section 2.2.3 of Chapter 2).

Example 1.4.1. The incidence matrix of the tree presented below is:

X 5 X 6 X 7 X 8 X 9 X 2 X 3 X 4 X 1 δ U =                                    X 1 X 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9
X 1 1 0 0 0 0 0 0 0 0 X 2 1 1 0 0 0 0 0 0 0 X 3 1 1 1 0 0 0 0 0 0 X 4 1 0 0 1 0 0 0 0 0 X 5 1 0 0 1 1 0 0 0 0 X 6 1 0 0 1 0 1 0 0 0 X 7 1 1 0 0 0 0 1 0 0 X 8 1 1 1 0 0 0 0 1 0 X 9 1 1 1 0 0 0 0 0 1

                                                   

T

If we model a shifted BM, with a shift on the branch before (tip) node 7, and ancestral Using this, we get the two following propositions (See Section 2.2.3 for the derivation in the univariate case):

Proposition 1.4.2 (Shifts in the Expectation -BM). Assume that there are some shifts in the mean parameter µ of the BM on the K branches leading to nodes j 1 , . . . , j K . Then the model reduces to:

Y = T∆ + E
where E is the error vector with a structure induced by the BM (see Equation (1.4)), and ∆ is the matrix of shifts with all lines except (j 1 , . . . , j K ) equal to zero.

Proposition 1.4.3 (Shifts in the Optimal Value -OU). Assume that there are some shifts in the optimal value parameter β of the OU on the K branches leading to nodes j 1 , . . . , j K .

Then the model reduces to:

vec(Y T ) = (T ⊗ I p )W(A) vec(∆ T ) + vec(E T )
where E is the error vector with a structure induced by the OU (see Equation (1.6)), and W(A) is the bloc-diagonal matrix of size (m + n)p × (m + n)p: 2) ) . . .

W(A) =                 I p I p -e -A(h-t pa(
I p -e -A(h-t pa(m+n) )                
Thanks to these propositions, including shifts in parameters µ (BM) or β (OU) reduces to including the columns corresponding to the branches where the shifts occur in the regression matrix X of the linear regression framework. The only thing to be careful about are identifiability problems, as the full matrix T is not of full rank. These questions are carefully studied in Section 2.3 of this document.

Automatic Shift Detection

When the position of the shifts is unknown, using the linear model written above, the problem of finding the branches where to add shifts reduces to a problem of variable selection: we need to find the lines of the coefficient matrix ∆ that are non-zero. We will exploit this vision of the problem in our methods, developed in Chapters 2 and 3. Very recent work by [START_REF] Khabbazian | Fast and accurate detection of evolutionary shifts in Ornstein-Uhlenbeck models[END_REF] also used this formalism, using a lassobased penalty [START_REF] Tibshirani | Regression Selection and Shrinkage via the Lasso[END_REF] to select for the non-zero lines of ∆, for a multivariate OU with independent traits. We will discuss this method further in Chapter 3.

Before that, a first method was designed by [START_REF] Mahler | Exceptional Convergence on the Macroevolutionary Landscape in Island Lizard Radiations[END_REF] (called SURFACE) to find shifts in the optimal parameter of an OU with independent traits. It is similar to a step-wise model selection procedure. This method has two phases. In the first, forward phase, some shifts are added one by one on the tree, until the AIC score does not improve anymore. The model is however parametrized in term of regimes, rather than in shifts, so that each regime has its own optimum value. In the second, backward phase, we try to merge some of the regimes together, in order to improve the AIC score by reducing the number of parameters. This backward phase is very interesting, as it tries to find some convergent regimes (see Section 1.1.2), i.e. species in different parts of the tree that reached a similar ecological niche, although through different historical paths. This is a question of interest to biologists, that can not be treated easily with our formalism in terms of a linear model. That is why, despite its flaws (it is quite slow, and this stepwise procedure does not guaranty any kind of optimal solution to the initial problem) SURFACE is widely used. In a Bayesian framework, other methods have been developed to find shifts on a univariate BM [START_REF] Eastman | Simpsonian 'Evolution by Jumps' in an Adaptive Radiation of Anolis Lizards[END_REF] or OU (Uyeda & Harmon, 2014). We refer to Chapter 2 for a brief description of these methods.

Other Kind of Shifts

Other than the mean or primary optimum values, some authors have considered shifts in the variance or selection strength. For the OU, [START_REF] Beaulieu | Modeling stabilizing selection: Expanding the Ornstein-Uhlenbeck model of adaptive evolution[END_REF] and [START_REF] Clavel | mvmorph : an r package for fitting multivariate evolutionary models to morphometric data[END_REF] considered fixed, user defined shifts in all the parameters, respectively for an univariate or multivariate process. For the BM, [START_REF] Eastman | A Novel comparative method for identifying shifts in the rate of character evolution on trees[END_REF] considered a Bayesian method to automatically detects some shifts in the variance σ 2 . BaMM [START_REF] Rabosky | Rates of speciation and morphological evolution are correlated across the largest vertebrate radiation[END_REF]; [START_REF] Rabosky | Automatic detection of key innovations, rate shifts, and diversitydependence on phylogenetic trees[END_REF]; [START_REF] Rabosky | Analysis and Visualization of Complex Macroevolutionary Dynamics: An Example from Australian Scincid Lizards[END_REF]; [START_REF] Shi | Speciation dynamics during the global radiation of extant bats[END_REF] is an other rather popular software to detect shifts in the variance parameter. It is also designed to detect shifts in the speciation parameter, using a birth-death model of evolution, to explain the shape of the tree. The model used is rather complex, and has been criticized as possibly flawed by [START_REF] Moore | Critically evaluating the theory and performance of Bayesian analysis of macroevolutionary mixtures[END_REF]. Those critics have been recently addressed by [START_REF] Rabosky | Is BAMM Flawed? Theoretical and Practical Concerns in the Analysis of Multi-Rate Diversification Models[END_REF]. We only point these models to the interested reader, but we did not study them in depth as they use a different formalism.

Algorithms for Likelihood Computation

As pointed out in the previous section, the generality of the linear model framework is nice from a theoretical point of view, but does not solve the inference problem. We describe here a few methods that can be used to speed up the computations.

The Pruning Algorithm

We already described the principles of the pruning algorithm in Section 1.2.3. In the particular case where the process is Gaussian, all the integrals written in Proposition 1.2.2 can be solved analytically, and hence the likelihood of a model can be computed in a single traversal of the tree, with a complexity of the order of n inversions of matrices of size p (the number of traits). We refer to Section 3.C.2 (upward step) for a comprehensive description of such an algorithm in a multivariate framework, with missing data.

Background

The pruning algorithm can be seen as an adaptation on a tree of the "forwardbackward" algorithm (used for instance in segmentation, see e.g. [START_REF] Rabiner | A tutorial on hidden Markov models and selected applications in speech recognition[END_REF]. From its original description in phylogeny by Felsenstein (1973b), variants of this algorithm have been flowering in the literature, under different names: [START_REF] Hadfield | General quantitative genetic methods for comparative biology: phylogenies, taxonomies and multi-trait models for continuous and categorical characters[END_REF], [START_REF] Fitzjohn | Diversitree: Comparative phylogenetic analyses of diversification in R[END_REF] (Gaussian Elimination Method), [START_REF] Freckleton | Fast likelihood calculations for comparative analyses[END_REF], [START_REF] Lartillot | A phylogenetic Kalman filter for ancestral trait reconstruction using molecular data[END_REF] (phylogenetic Kalman filter), [START_REF] Pybus | Unifying the spatial epidemiology and molecular evolution of emerging epidemics[END_REF]; [START_REF] Cybis | Assessing phenotypic correlation through the multivariate phylogenetic latent liability model[END_REF] (in a Bayesian setting). In a non-Gaussian setting, [START_REF] Landis | Phylogenetic analysis using Lévy processes: Finding jumps in the evolution of continuous traits[END_REF] and [START_REF] Duchen | Inference of Evolutionary Jumps in Large Phylogenies using Lévy Processes[END_REF] adapted the algorithm to Lévy processes, while [START_REF] Hiscott | Efficient Recycled Algorithms for Quantitative Trait Models on Phylogenies[END_REF] proposed an extension of this algorithm for a broad class of processes, based on some efficient numeric integral approximations.

The "3-Point Structure" Algorithm

Another approach to likelihood computation was taken by Ho & Ané (2013a). For a linear (univariate) regression model as described in Section 1.4.2.2 (see Eq. (1.7)), the likelihood of the observed vector Y at the tips can be written as:

-2 log p(Y) = n log(2π) + log |S| + (Y -Xθ) T S -1 (Y -Xθ),
and the maximum likelihood estimator of the coefficients is given by: θ

= (X T S -1 X) -1 X T S -1 Y.
Computing these quantities requires two potentially time-consuming tasks: inverting matrix S, and computing its determinant. When the tree is large (i.e. the dimension n of S is large), these tasks might become overwhelming. However, Ho & Ané (2013a) noticed that S -1 only appears in the likelihood as products of the form A T S -1 B, with A and B vector or matrices of adequate size. They hence designed an algorithm to compute these quantities efficiently, recalling that S is a tree variance matrix, and hence has a special structure, as defined below.

Definition 1.4.2 (3-point structure). A matrix S has a 3-point structure if it is symmetric, with non-negative entries, and satisfies the following 3-point condition: for any i, j, k (not necessarily distinct), the two smallest of V ij , V ik and V jk are distinct.

It stems from the following theorem that all the models presented above that can be seen as a BM on a re-scaled tree, including the OU on an ultrametric tree, have the 3-point structure.

Theorem 1.4.1 (BM on a re-scaled tree). S is 3-point structured if and only if it is the covariance matrix of a random variable at the tips of some rooted tree under a BM model.

The OU on a non-ultrametric tree can be shown to have a generalized 3-point structure, and the algorithm can be extended to this case. For the sake of simplicity, we only present it here for the canonical 3-point structure. The algorithm uses a preorder of the tree, computing the needed quantities at each node, going from the tips to the root.

Algorithm 1.4.2. We assume that we are in the setting presented above, with a variance matrix S having the 3-point structure. Assuming that the root has k child branches, this ensures that S can be decomposed in the following way:

S = t1 T 1 + A with A =           S 1 0 . . . 0 S k          
where t ≥ 0, and A is a block-diagonal matrix with each diagonal block matrix S s being the variance matrix induced by the sub-tree starting from child s, 1 ≤ s ≤ k.

The goal of the algorithm is then to compute the following quantities :

d = log |S| Q = X T S -1 Y and            p = 1 T S -1 1 μY = 1 T S -1 Y/p μT X = X T S -1 1/p
Initialization For a tree with a single tip of length t, we get:

d = t Q = x T y/t and            p = 1/t μY = y μT X = x T
where x and y are the rows of X and Y corresponding to the current tips.

Propagation Recall the Woodbury formula and Sylvester's determinant for matrices of the form M = A + UCV:

M -1 = A -1 -A -1 U(C -1 + VA -1 U) -1 VA -1 |M| = |A| |C| C -1 + VA -1 U
These formulas applied to our case give:

S -1 = A -1 - t 1 + tp A A -1 11 T A -1 where p A = 1 T A -1 1 = k s=1 p s
and:

                   d = k s=1 log |S s | + log(1 + tp A ) Q = k s=1 Q s - tp 2 A 1 + tp A μT X μY and                              p = p A 1 + tp A μY = k s=1 p s p A μY,s μT X = k s=1 p s p A μY,s
Finalization At the root of the full tree, return log |V| and Q.

Extensions

We browse here a few models and methods that extend the setting studied here, in one or several ways.

Measurement Errors and Intraspecific Variations

In all the methods presented in this manuscript, we assume that the variance structure is entirely dictated by the tree structure, and that there is only one observation per trait and per species. Indeed, in the regression model (1.7), the variance structure of the error vector E is completely defined by the evolution model on the tree. This amounts to make 1. Background the strong assumption that the evolution process is the only source of variation in the trait dataset. Using the interpretation given in Section 1. 4.1.3, this also means that we identify the mean value of a trait observed on several individuals of a given species with the secondary optimum of this species in the present. We make this assumption for the sake of simplicity. It ignores at least two important sources of variations: measurement error and intraspecific variations. Measurement error can be a real issue, especially for large datasets, where the trait measurements are obtained from diverse sources, that sometimes lack precision (for instance, in [START_REF] Rose | Shape analysis of moss (Bryophyta) sporophytes: Insights into land plant evolution[END_REF], most of the 1090 moss shapes used are obtained through botanical drawings found in a vast and heterogeneous literature). Intraspecific variation is a more biological source of variation, and cannot be avoided, even assuming a perfect sampling. Several recent empirical and simulation studies found that these two phenomena could have a strong deleterious impact on phylogenetic comparative methods [START_REF] Silvestro | Measurement errors should always be incorporated in phylogenetic comparative analysis[END_REF][START_REF] Cooper | A cautionary note on the use of Ornstein Uhlenbeck models in macroevolutionary studies[END_REF].

Using a mixed model framework such as the one presented in Section 1.4.2.2, these errors can be easily taken into account [START_REF] Lynch | Methods for the Analysis of Comparative Data in Evolutionary Biology[END_REF][START_REF] Ives | Within-Species Variation and Measurement Error in Phylogenetic Comparative Methods[END_REF][START_REF] Felsenstein | Comparative Methods with Sampling Error and Within-Species Variation: Contrasts Revisited and Revised[END_REF]. We present here the main features of the model, and refer to Section 5.1 in Chapter 5 for a brief presentation of how this feature could be added to our framework. The formalism we use here is derived from [START_REF] Felsenstein | Comparative Methods with Sampling Error and Within-Species Variation: Contrasts Revisited and Revised[END_REF]. We first assume that several individuals can be sampled independently for a given species. To cast this situation in the phylogenetic comparative methods framework, we can artificially mark each of the individuals of a given species A as separate "species", numbered A1, . . . , An A , but with a zero length phylogenetic distance from one another: d Ai,Aj = 0 for any two individuals of the same species (1 ≤ i, j ≤ n A ), and d Ai,Bj = d A,B for any two individuals of two different species. Using this convention, we can restrict ourselves without loss of generality to the situation described in Section 1.4.2.2, where p traits are measured on n species (where each species is in fact a couple "individual-species"). The intraspecific or measurement error is then obtained by adding a p-dimensional error vector term ∼ N (0, Q) to the observed vector of traits for each species: for any two species 1 ≤ i, j ≤ n and two traits 1 ≤ k, l ≤ p, the covariance between trait k of species i and trait l of species j is given by:

Cov Y ik ; Y jl = E ijkl + δ ij kl
where δ ij = 0 if i j, and δ ij = 1 if i = j; and E is defined as in Section 1.4.2.2 by the evolution model used on the tree: vec(E) ∼ N (0, S ). Writing I n the n×n identity matrix, we get a generalization of Equation (1.7):

vec(Y) ∼ N (vec(Xθ), S + Q ⊗ I).
Note that, in the univariate BM case, this is equivalent to adding a terminal tip branch length τ = q 2 /σ 2 to all the species. This makes this model close to Pagel's λ transform [START_REF] Pagel | Inferring the historical patterns of biological evolution[END_REF] exposed in Section 1.4.2.3: if the intraspecific variations are much larger than the phylogenetic ones, then the phylogenetic signal is weak, and vice versa. See Section 5.1 of Chapter 5 for another interpretation in terms of phylogenetic signal, but with the α parameter of an OU.

For a BM model of evolution, this model was treated by [START_REF] Ives | Within-Species Variation and Measurement Error in Phylogenetic Comparative Methods[END_REF] with a known measurement error, and [START_REF] Felsenstein | Comparative Methods with Sampling Error and Within-Species Variation: Contrasts Revisited and Revised[END_REF] proposed an extended phylogenetic contrasts method to directly infer this error from the data. [START_REF] Goolsby | Rphylopars : fast multivariate phylogenetic comparative methods for missing data and within-species variation[END_REF] further extended the method to deal with missing data, and to allow for an OU model of evolution on an ultrametric tree. This implementation, available as the R package Rphylopars, is quite fast, and relies on an adapted version of the 3-point structure algorithm (Ho & Ané, 2013a) presented in Section 1.4.4.2. In both articles, the estimation of the covariances matrices is done thanks to an EM algorithm. This EM algorithm, that is written in a matrix form, and uses E and as hidden variables, is different from the one we develop in Chapters 2 and 3 (even with no shift).

In practice, we saw in Section 1.4.2.2 that the predictor variables could themselves be traits, that can also be measured with errors. Hansen & Bartoszek (2012) proposed an extended (univariate) OU framework to deal with the uncertainty associated with all the measured traits, whether they are considered as observations or predictors.

xxSSE Methods

One of our core assumption is that the trait evolves on a fixed tree, that is supposed to be known a priori. Implicitly, this amounts to assuming that the trait and the tree are independent, so that the trait has no influence on speciation. Note that, using the interpretation described in Section 1.4.1.3, the stochastic process models the secondary optima, and not the trait directly, so that this assumption can be justified.

Some methods were developed to model the very interactions between the trait and speciation rate. [START_REF] Maddison | Estimating a binary character's effect on speciation and extinction[END_REF] first described a popular method to deal with binary traits, called BiSSE (for Binary State Speciation Extinction). In this model, a single binary trait evolves on a rooted ultrametric phylogenetic tree with branch lengths, that is assumed to be known and complete, i.e. all extant species have been sampled. The trait can take two values, 0 or 1. It follows a CTMC on the tree, with transition rates given by q 01 and q 10 . In addition, a given lineage with trait i (i ∈ {0, 1}) has a speciation rate λ i , and an extinction rate µ i . Conditionally on these parameters, the speciations and trait transitions are assumed to be independent.

Within this model, [START_REF] Maddison | Estimating a binary character's effect on speciation and extinction[END_REF] are able to compute the likelihood of a set of parameters, using a postorder traversal of the tree (from tips to root) to update D n0 (t) and D n1 (t) the probabilities that a lineage beginning at time t with state 0 or 1 evolves into the clade observed from node n. Their approach relies on the numerical integration of a system of differential equations on each branch of the tree.

Several extensions of this model have been proposed. [START_REF] Fitzjohn | Estimating trait-dependent speciation and extinction rates from incompletely resolved phylogenies[END_REF] completed the BiSSE framework, allowing the tree to be incompletely sampled. To deal with discrete traits with more than two states, [START_REF] Fitzjohn | Diversitree: Comparative phylogenetic analyses of diversification in R[END_REF] developed the MuSSE model. A quantitative trait, evolving according to any diffusion process with a known transition density, can also be used in the QuaSSE model developed again by [START_REF] Fitzjohn | Quantitative traits and diversification[END_REF]. This last extension requires the numerical computation of non-explicit integrals along the tree, and is reported to be quite slow. Finally, an adaptation of this framework to biogeographic models, coined GeoSSE, has been proposed by [START_REF] Goldberg | Phylogenetic Inference of Reciprocal Effects between Geographic Range Evolution and Diversification[END_REF].

Bayesian Methods

In all the methods presented above, the tree is supposed to be known and fixed, and the trait is modeled conditionally to it. However, the phylogenetic tree is itself the result of a complex statistical inference procedure, as we saw in Section 1.3.4. This two steps framework is not really satisfying, as it implies that we completely ignore the information we have about the uncertainty of the reconstructed tree, which can lead to several bias 1. Background in downstream analysis (see Section 5.1 for a study of the impact of for example, branch lengths misspecifications on the shifts detection analysis).

One way to alleviate this problem is to integrate both the tree reconstruction and the trait analysis in a single unified statistical framework. Because they are quite flexible, Bayesian methods can be well suited to conduct such a task. The idea was first exposed in [START_REF] Huelsenbeck | Detecting Correlation between Characters in a Comparative Analysis with Uncertain Phylogeny[END_REF], and refined in [START_REF] Lemey | Phylogeography takes a relaxed random walk in continuous space and time[END_REF]; [START_REF] Pybus | Unifying the spatial epidemiology and molecular evolution of emerging epidemics[END_REF]; [START_REF] Cybis | Assessing phenotypic correlation through the multivariate phylogenetic latent liability model[END_REF]; [START_REF] Gill | A Relaxed Directional Random Walk Model for Phylogenetic Trait Evolution[END_REF]; [START_REF] Tolkoff | Phylogenetic Factor Analysis[END_REF], to allow for more complex models of trait evolution and introduce some efficient likelihood computation algorithms. We briefly recall the main idea behind these methods, and refer the interested reader to these articles for more details on each model.

Assume that we have access to two different sources of data for a set of n species: a set of n aligned sequences S and a n × p matrix Y of p continuous traits. We take two different models of evolution to model both data sets. S is the result of a given process (typically, a CTMC, see Section 1.3.4) on a tree τ, with parameters ν. Y is modeled by another process (such as a BM) on the same tree τ, with parameters θ. So that all the computations can be carried out, we make the crucial assumption that, conditionally on the phylogenetic tree τ, the sequences S and the traits Y are independent:

p (S, Y | τ, ν, θ ) = p( S | τ, ν )p (Y | τ, θ ) .
The joint posterior distribution of the parameters given the data can hence be decomposed as:

p (τ, ν, θ | S, Y) ∝ p (Y | τ, θ ) p(θ)p(S, τ, ν)
where p(θ) is a prior distributions on the parameters. The two problems of sequence and trait modelling can hence be handled separately. The sequence study can be done with classical Bayesian inference tools (see e.g. [START_REF] Drummond | Bayesian Phylogenetics with BEAUti and the BEAST 1.7[END_REF], while the trait study benefits from many of the likelihood computation algorithms developed above. The methods mentioned above are implemented in the BEAST software [START_REF] Drummond | Bayesian Phylogenetics with BEAUti and the BEAST 1.7[END_REF].

Model Selection

We have seen in Section 1.4.3 that the problem of shift detection could be recast into a problem of variable selection in a linear model framework. We review here some important results for model selection in this setting, that will be useful in the next chapters of this thesis. The exposition of this section is highly inspired from Giraud (2014) and [START_REF] Massart | Concentration Inequalities and Model Selection[END_REF], and we refer the interested reader to these two books for a more complete presentation of the topic.

Penalized Likelihood

Statistical Setting

In this section, unless otherwise stated, we consider the following standard statistical setting:

Y = µ + σ 2 E with E ∼ N (0, I n ) (1.14)
where Y is a vector of n iid Gaussian observations, with unknown mean µ and variance σ 2 . We focus here on the univariate Gaussian case for the clarity of exposition. Not all the methods presented here have a natural extension to the multivariate setting, we will study some of them in Chapter 3. We further assume that we have a collection of models S = {S η , η ∈ M} that are linear subspaces S η of R n indexed by a finite or countable set M. We assume that for each model η ∈ M, we have a maximum likelihood estimator μη of µ. The following straightforward proposition allows us to see this estimator as a projection of Y on S η .

Proposition 1.5.1 (Likelihood, Least-squares, and Projection). The log-likelihood of a Gaussian vector Y ∼ N (µ, σ 2 I n ) is given by:

log p(Y; µ, σ 2 ) = - n 2 log(2πσ 2 ) - 1 2σ 2 Y -µ 2 .
When σ 2 is known, the maximum likelihood estimator of μη in model η ∈ M is given by:

μη = argmax s∈S η log p(Y; s, σ 2 ) = argmin s∈S η Y -s 2 = Proj η Y.
When σ 2 is unknown, its maximum likelihood estimate in model η ∈ M is given by:

ML σ 2 η = 1 n Y -μη 2
hence, injecting this expression in the likelihood, we get:

μη = argmax s∈S η - n 2 log 1 n Y -s 2 = argmin s∈S η Y -s 2 = Proj η Y.
Hence, for each η ∈ M, whether σ 2 is known or not, the maximum likelihood estimator of µ in model η is given by the least square estimator, and is the projection of Y on S η . We denote further by µ η = Proj η µ the projection of the unknown mean µ on model S η .

Note that the setting presented above includes the linear regression setting:

Y = Xβ + σ 2 E with E ∼ N (0, I n )
where, instead of estimating μη ∈ R n living in some linear space S η , we try to estimated βη ∈ R p as being sparse, i.e. having a small number of non-zero coefficients (here, p is the number of regressors, and X is an n×p matrix). A model η is then defined by the position of the non-zero coefficients, and the associated linear subspace for the expectation of Y is then given by the associated columns of the regression matrix X: S η = Span X j : j ∈ η .

In the rest of this section, we will stick to setting (1.14) for simplicity reasons, but it is worth keeping in mind that all the results presented here can also be applied to this linear regression framework. The goal of model selection is to select a model η among the collection M, according to some criterion, and to study the properties of such a choice.

Risk and Oracle

Denote by D η the dimension of model S η , for η ∈ M. It is straightforward to see that the higher the dimension of a model is, the better its likelihood or least-square score.

Background

Indeed, when projecting on a space with a higher dimension, one gets more degree of freedom to adjust to the data, hence obtaining a better fit. Just taking the likelihood as a model selection criterion would therefore be inefficient, as it would amount in always choosing the model with the highest dimension.

The criterion that we would like to use is the risk of an estimator, as defined below:

Definition 1.5.1 (Risk of an estimator). The risk of an estimator μη for η ∈ M is given by:

R( μη ) = E µ -μη 2 = µ -µ η 2 + D η σ 2
where we recognize in the second inequality the famous bias-variance decomposition of the risk.

When given a collection S of models, the "best" model in term of risk is called the oracle estimator, defined as: Definition 1.5.2 (Oracle). The oracle estimator μ0 is defined as the estimator minimizing the risk:

μ0 = argmin η∈M R( μη ).
The oracle risk is a benchmark, as it is the best we can ever achieve using our collection of model S. Note that, if the collection is poorly chosen, this oracle risk is not necessarily small.

Akaike's Final Prediction Error (FPE)

Unfortunately, as µ is unknown, this oracle cannot be computed directly from the data. One natural approach is then to use an estimator of the risk. This is the path taken to derive Akaike's Final Prediction Error (FPE Akaike, 1969), that uses the following unbiased estimator of the risk: Proposition 1.5.2 (FPE). Given a model η ∈ M, the expected least squares is:

E Y -μη 2 = E (I -Proj η )(µ + E) 2 = R( μη ) -D η σ 2 + (n -D η )σ 2 .
As the term nσ 2 is identical for all models, it won't play a role in the model selection.

We hence use the following unbiased estimator of R( μη )nσ 2 :

Y -μη 2 + 2D η σ 2 η where σ 2 η = Y -μη 2 /(n -D η
) is an unbiased estimator of the variance. The FPE estimator is then given by:

ηFPE = argmin η∈M Y -μη 2 1 + 2D η n -D η
When the variance σ 2 is known, this criterion is equivalent to the famous Akaike Information Criterion, that we introduce in the next section. It is only guaranteed to work in expectation, or in the limit case where n goes to +∞. When the number of models grows exponentially with the dimension d (i.e. the set of models S η with dimension D η = d grows very fast), then this criterion cannot handle the variance of the estimated risks: just by chance, a bad model with a high dimension is likely to have a small risk, and hence be favored against the oracle. This criterion has hence a tendency to select models with a high dimension (Giraud, 2014, Chap. 2).

Penalized Likelihood and Least Squares

The criterion we derived above has the form of a penalized least-squares, with penalty 2D η /(n -D η ): when the dimension of the model D η raises, then the least squares will go down, but the penalty will raise. This criterion on the least squares can be re-written in term of a penalty on the log-likelihood, using Proposition 1.5.1. In the following, we will use the following equivalent criteria, on the least-squares or the likelihood:

Crit lsq (η) = Y -μη 2 1 + pen(η) n -D η (1.15) Crit ll (η) = n 2 log         Y -μη 2 n         + 1 2 pen (η) (1.16) pen (η) = n log 1 + pen(η) n -D η (1.17)
This equivalency between criteria on the least-squares and the log-likelihood allows us to see the problem of model selection using two complementary approaches. However, this does not hold anymore in the multivariate setting, and we will see in Chapter 3 that only the formulation in term of least squares has a natural extension.

Akaike's Information Criterion (AIC)

The Akaike's Information Criterion (AIC) can be seen as a criterion on the likelihood, approximately equivalent to the FPE for n large, using Equation (1.17):

pen AIC (η) = n log 1 + pen FPE (η) n -D η = n log 1 + 2D η n -D η ≈ n 2D η n -D η ≈ 2D η .
This famous and widely used criterion inherits the flaws described for the FPE, and is only valid asymptotically. It can also be seen as an approximation for a Kullback-Leibler based Information criterion (hence its name). In the next sections, we describe some other criteria that try to alleviate these flaws. But first, let's recall another famous information criterion, based on a Bayesian paradigm.

Bayesian Information Criterion (BIC)

The Bayesian Information Criterion (BIC) can be expressed in our framework, taking in (1.16):

pen

BIC (η) = D η log(n).
Its derivation relies on a Laplace approximation of the Bayes factors. We briefly recall here the construction, for a finite collection of models M (see [START_REF] Lebarbier | Une introduction au critère BIC : fondements théoriques et interprétation[END_REF] for a thorough introduction to the BIC construction and properties). In a Bayesian paradigm, each model η has a prior probability π η to be chosen, and then the parameters θ = (µ, σ 2 ) of the distribution are drawn from an a priori distribution p θ η . The where we used Bayes formula, and assumed a uniform prior π η = 1/ |M| on all models η ∈ M. To estimate the marginal likelihood of the data given the model, we write:

p Y η = θ∈S η p Y θ, η p θ η dθ,
and assume that p Y θ, η is concentrated around its maximum p Y θ * η , η . The Laplace approximation, recalled below, then allows us to find the penalty stated above, dropping all the terms that are constant with n, and approximating θ * η by the maximum likelihood estimator θη .

Proposition 1.5.3 (Laplace Approximation). Let L : R q → R be a twice differential function on R q , with a unique maximum u * . Then:

R q e nL(u) du ≈ 2π n q/2 -L (u * ) -1/2 e nL(u * ) for n → ∞.
1.5.2 Model selection à la [START_REF] Birgé | Gaussian model selection[END_REF] In this section, we offer a first alternative to the well known but limited model selection criteria we recalled above. Assuming that the variance σ 2 is known, we are able to exhibit a model selection criterion with non-asymptotic guaranties, in the form of an oracle inequality. We then present a famous heuristic to extend the penalty to a case where the variance is not known.

A non-asymptotic Oracle inequality

In this section, we restrict ourselves to the setting presented in Equation (1.14), with a known variance σ 2 . In that case, we do not need to control for the extra variation induced by the estimation of the variance, and the criterion on the least squares can be written as:

Crit(η) = Y -μη 2 + σ 2 pen(η).
(1.18)

The following theorem can be proven using some concentration inequalities, i.e. inequalities that control the dispersion of a random variable around its expectation (see [START_REF] Massart | Concentration Inequalities and Model Selection[END_REF] for an introduction to classical concentration inequalities).

Theorem 1.5.1 [START_REF] Birgé | Gaussian model selection[END_REF][START_REF] Massart | Concentration Inequalities and Model Selection[END_REF]. Assume that the model is defined as in (1.14), and that η is a minimizer of criterion (1.18). Let {L η } η∈M be some family of positive numbers such that

η∈M e -L η D η = Ω < ∞ (1.19)
Let A > 1 and further assume that:

σ 2 pen(η) ≥ Aσ 2 D η + 2L η D η 2 .
(1.20)

Then the selected least-square estimator μ η satisfies the following risk bound:

E μ η -µ 2 ≤ C(A) inf η∈M µ -µ η 2 + σ 2 pen(η) + (1 + Ω)σ 2 (1.21)
where C(A) depends only on A.

Inequality (1.21) is an oracle risk bound on the risk of the selected estimator. It means that the selected estimator almost performs as well as the best model in term of compromise between the bias ( µµ η

2 ) and the model complexity dependent variance (σ 2 pen(η)). Note that constant C(A) is not made explicit here, and can be quite large.

Finding the constant that is closest to 1 (finding a so called "sharp" risk bound) is an active field of research in its own. Note that this inequality in non-asymptotic: it is true even for a small number of observations n, even though the infimium on the right hand side might not be small enough in this case. What makes this approach working better than the FPE or AIC criterion, is that the penalty takes into account the possible growing complexity of the collection of models with a given dimension D, through the weights (L η ) η∈M . When facing a problem with its associated collection of models M, one needs, in order to apply this inequality, to craft the right set of weights satisfying inequality (1.19). We show in Section 1.5.2.2 an example of such a derivation in the setting of coordinate sparsity, that looks like the one we will face in the next chapters.

Finally, remark that the condition (1.20) on the penalty depends on the variance σ 2 , that is, in practice unknown. It is then tempting to apply this criterion with a constant κ = Aσ 2 , getting rid of the unknown variance. Doing that, we loose the natural scale that was imposed on A (A > 1), and we need to calibrate the constant κ correctly. We will briefly present some heuristics to do that in the last subsection on this method (Section 1.5.2.3).

Derivation in the Coordinate Sparse Setting

In the coordinate sparse setting, we assume that the true model has only a few non-zero coordinates. The associated collection of models can be defined as follow:

Definition 1.5.3 (Coordinate-Sparse Setting). Let (e i ) 1≤i≤n be the canonical basis of R n . The collection of models {S η , η ∈ M} is indexed by P ( 1 , n ) the set of all the subsets of 1 , n , and for any η ∈ M, the linear subspace S η is defined by the vectors s in R n such that s i = 0 for any i η, i.e. S η = Span{e j , j ∈ η}. Note that the complexity of the models with dimension D is: {η ∈ M : η = D} = n D . In this setting the sum featured in inequality (1.19) can be written as:

Ω = η∈M e -L η D η = D≥0 n D e -L D D .
Assuming that L η depends only on the dimension of S η (i.e. L η = L D , ∀ η = D), a natural choice of weights could then be:

L D = n D log 1 + 1 n + log(n),
1. Background leading to a sum controlled by:

Ω = D≥0 n D 1 + 1 n -n 1 n D = 1 + 1 n -n 1 n + 1 n = 1.
Using the inequality n log 1 + 1 n ≤ 1, this would lead to the penalty:

AD 1 + 2L D 2 ≤ AD       1 + √ 2 1 D + log(n)       2 =: pen(D), (1.22)
that complies with inequality (1.20).

Another natural choice of weights might be, for B > 0:

L D = B + 1 D log n D
allowing us to control the sum:

Ω = D≥0 exp -L D D + log n D ≤ 1 1 -e -B .
To comply with inequality (1.20), we can then use:

AD 1 + 2L D 2 ≤ AD       1 + √ 2 B + 1 + log n D       2 =: pen(D), (1.23)
where we used the classical inequality:

log n D ≤ D 1 + log n D .
This choice gives us another "degree of freedom" B that might be calibrated to improve the efficiency of the penalty.

Depending on the collection of models at hand, such a derivation needs to be adapted. We refer to [START_REF] Lebarbier | Detecting multiple change-points in the mean of Gaussian process by model selection[END_REF] for an example of application in the model selection problem associated with segmentation.

Unknown Variance: the Slope Heuristic

As pointed out above, when σ 2 is unknown, the penalty can be written as κ pen sh (η), where pen sh is the penalty shape, defined by inequality (1.20) (dropping the constants), and κ = Aσ 2 is the constant that needs to be calibrated. One popular approach is to use the slope heuristic, developed by [START_REF] Birgé | Minimal Penalties for Gaussian Model Selection[END_REF]; [START_REF] Arlot | Data-driven calibration of penalties for least-squares regression[END_REF]; [START_REF] Baudry | Slope heuristics: overview and implementation[END_REF]. We roughly explains the idea behind this heuristic here, and refer the interested reader to the papers cited for a description of the theoretical foundation, and the practical computability of such a method.

Putting together Definition 1.5.2 and Equation (1.18), an oracle penalty, defined for η ∈ M as R( μη ) -Yμη , would always select for the oracle estimator. This can be decomposed as:

pen opt (η) = R( μη ) -Y -μη 2 = E µ -μη 2 -µ -µ η 2 = v η + µ -µ η 2 -Y -µ η 2 + Y -µ 2 = δ η + Y -µ η 2 -Y -µ 2 -Y -μη 2 = vη
Note that E δ η = 0, and E vη = v η = D η , so that the FPE penalty is obtained by taking the expectation of this optimal penalty. The slope heuristic then stems from the following observations:

pen min (η) = vη can be seen as a "minimal" penalty, as the associated criterion is

Crit min (η) = Y -µ η 2 -Y -µ 2 ,
and would select for a model simply minimizing the bias, hence always selecting the model with the highest dimension. The penalty is then minimal, as any larger penalty would result in selecting a model with possibly a smaller dimension.

pen opt (η) ≈ 2 vη : because one can expect that v η ≈ vη , and that δ η ≈ 0 (provided these quantities concentrate around their expectations). Hence, the optimal penalty is about twice the minimal penalty.

pen opt (η) = κ opt pen sh (η): according to our assumption, the optimal penalty can be expressed as a constant times our penalty shape. Putting this together with the previous remarks, we get:

-Y -μη 2 ≈ -Y -µ η 2 -Y -µ 2 + κ opt 2 pen sh (η) But, for large dimensions, Y -µ η 2 -Y -µ 2 should be approximately constant, as
the bias is expected to be constant for most complex models. Hence, asymptotically, the least squares scores should grow linearly with pen sh (η), with a slope approximately equal to

κ opt 2 .
Hence, an estimator κ can be obtained as half the asymptotic slope when plotting the least squares scores against the value of the penalty shape.

This heuristic can be applied to any relevant contrast (e.g. least squares or loglikelihood), and gives some good results in practice, when a theoretical penalty shape can be derived. It is implemented in the R-package capushe [START_REF] Brault | capushe: Capushe, Data-Driven Slope Estimation and Dimension Jump[END_REF].

The Lasso Penalty

The very popular Lasso regularization procedure was introduced by [START_REF] Tibshirani | Regression Selection and Shrinkage via the Lasso[END_REF], and is based on an 1-norm penalty of the least squares. It can be seen as a convex relaxation of the previous penalty, making it particularly efficient. We sketch here the main steps of its derivation in our setting, and show how it can be used to get several sparsity settings. The exposition adopted here is highly inspired from Giraud (2014), and we refer to this book for a deeper introduction of the method, including some geometrical and algebraic insights.

A convex relaxation

For the coordinate-sparse setting defined in 1.5.3, we saw in Equation (1.22) that the penalized criterion (1.18) was of the order of:

Crit(η) = Y -μη 2 + λ η with λ = Aσ 2 1 + 2 log(n) 2 .
Denote by Supp(x) = {j : µ j 0} the support of a vector x ∈ R n . Then, for η ∈ M, the linear subspace S η of Definition 1.5.3 can be written as S η = {x : Supp(x) = η}. Hence,

1. Background the least squares estimator for model η is equal to μη = argmin x∈R n :Supp(x)=η Y -x 2 .
The selected model minimizing the criterion can hence be written as:

η = argmin η∈M min x∈R n :Supp(x)=η Y -x 2 + λ x 0 ,
where x 0 is the 0-norm of x, defined as the number of non-zero coordinate of x (i.e.

x 0 = |Supp(x)|). This leads to the following definition of the selected estimator:

μ η = argmin x∈R n Y -x 2 + λ x 0 .
Because of the term in x 0 , the minimization of the previous criterion is hard, and one might need to test all the possible models, yielding a combinatorial complexity, that can swiftly become overwhelming for large dimensions. One way to circumvent this problem is to replace this non-convex 0-norm by a 1-norm, defined as x 1 = n j=1 x j for x ∈ R n . For λ > 0, define the lasso estimator as:

μλ = argmin x∈R n Y -x 2 + λ x 1 .
(1.24)

Thanks to this new penalty based on the convex 1-norm, the criterion to optimize is itself convex, and hence can benefit from all the standard minimization techniques, that are known to be fast and efficient in this convex setting.

In addition to this nice computational feature, it can be shown that, choosing λ opt = 3σ 2 log(n) + 2L (for any L > 0), the estimator μλ opt defined by Equation (1.24) satisfies an oracle inequality (see Cor. 4.3 in Giraud, 2014). This property gives us some guaranties on the theoretical behavior of μλ , even though, as the variance is unknown, λ opt cannot be used in practice. The problem of selecting λ is not easy, and can be solved with cross validation, or with an estimator selection procedure [START_REF] Baraud | Estimator selection in the Gaussian setting[END_REF].

The 1-norm penalty allows us to select a sparse model, but, as it changes the criterion to optimize, it introduces a bias in the estimation of the coefficients, that appears shrinked in the standard lasso solution. One way to circumvent this problem is to use the so-called Gauss-lasso estimator of the coefficient, defined as:

μλ = Proj Ŝλ Y where Ŝλ = S ηλ .
In other words, the lasso penalty is used to select a model, defined by the non-zero components of the estimator, and then we use the standard least-square estimator in this model.

Sparsity Patterns

The lasso penalty above was derived in the context of coordinate sparsity. To deal with other kinds of sparsity patterns, it needs to be adapted. We present here some classical penalties to achieve group, sparse-group, and variation sparsity.

Group Sparsity. Here, we assume that the coordinates of µ are separated into meaningful groups. The group-sparsity is designed to select for groups of coefficients that are simultaneously non-zeros, rather than single coefficients one by one. As an example, we show below how re-framing a multivariate regression to a univariate one using the vectorization can lead to such a sparsity pattern.

Assume that the coordinates of µ are split into p groups {G k } 1≤k≤p that form a partition of 1 , n . For λ = (λ k ) 1≤k≤p a vector of positive coefficients, the group-lasso estimator μλ is defined by [START_REF] Yuan | Model selection and estimation in regression with grouped variables[END_REF]:

μλ = argmin x∈R n        Y -x 2 + p k=1 λ k x G k       
, where • represents the euclidean norm, and x G k the vector with coefficients of x that are in G k . Some theoretical properties can also be shown on this estimator (see Giraud, 2014). Let's now give an example of such a setting, considering the multivariate regression framework. Assume that Y is now a n×p matrix, with all its coefficients i.i.d. Taking the setting of Proposition 1.4.2 (on a star-tree, with R = σ 2 I p ), this model can be written as:

Y = T∆ + E
where E is an error vector, T is a regression matrix (size n × (m + n)) that represents the tree-structure, and ∆ is the matrix of shifts (size (m + n) × p), each line ∆ j representing the vector of shifts values of the p traits on branch j. To select for a small number of shifts in this setting, we need to select for a small number of non-zero lines of ∆. Writing the vectorized form of the problem, we get:

vec(Y) = (I p ⊗ T) vec(∆) + vec(E) with E ∼ N (0, σ 2 I np ).
To select for the non-zero lines of matrix ∆, we need to group the coefficients of vector vec(∆) according to their original line, so that they are all set to zero at the same time when needed. For 1 ≤ i ≤ n, the group G i = {kn + i : 0 ≤ k ≤ p -1} represents the coordinates of the elements of line i in the vectorized space (with dimension np). See Figure 1.5.1 for a graphical representation of this group. The group-sparsity constraint would hence try to select for such non-zero groups, hence selecting for non-zeros lines.

Note that here, to frame the model into the correct framework (i.i.d. vector), we had to assume a star tree, and an independent BM model. We show in Section 3.C.3 how to deal with the correlations induced by a real tree and a multivariate BM.

Sparse Group Sparsity. In this setting, we further assume that only a few coefficients in each of the selected groups are non-zeros. The associated estimator is obtained with a similar penalty, just adding an overall sparsity constraint [START_REF] Simon | A Sparse-Group Lasso[END_REF]:

μλ,δ = argmin x∈R n        Y -x 2 + p k=1 λ k x G k + δ x 1       
, Fused Lasso: Variation Sparsity. In this setting, we assume that coefficients are in a meaningful order and do not change a lot, i.e. that the difference µ iµ i+1 is often equal to 0. This leads to the following criterion [START_REF] Tibshirani | Sparsity and smoothness via the fused lasso[END_REF]:

μλ = argmin x∈R n          Y -x 2 + λ n-1 j=1 x j+1 -x j          .
Up to a re-parametrization, this problem is equivalent to the standard lasso.

Model selection with LINselect

We go back to the setting stated in (1.14), with unknown variance, and criterion as defined in (1.15) or (1.16). The goal here is to derive a penalty that does not depend on the unknown variance. Note that criterion (1.15) can be re-written as:

Crit lsq (η) = Y -μη 2 + σ 2 η pen(η)
so that it is similar to criterion (1.18) used in the previous section, only replacing the unknown variance σ 2 by an unbiased estimator σ 2 η = Yμη 2 /(n -D η ).

A non-asymptotic Oracle inequality

Baraud et al. ( 2009) derived an oracle inequality in this Gaussian setting with unknown variance. The penalty they used is designed to control exactly the extra variations induced by the plug-in of the variance estimator in the criterion. It relies on the following function:

Definition 1.5.4 (Baraud et al., 2009, Def. 2 and 3). Let D, N be two positive numbers, and X D , X N be two independent ξ 2 random variables with degrees of freedom D and N respectively. For x ≤ 0, we define

Dkhi[D, N , x] = 1 E [X D ] E X D -x X N N +
And, for 0 < q ≤ 1 we define EDkhi[D, N , q] as the unique solution of the equation

Dkhi[D, N , EDkhi[D, N , q]] = q .
Theorem 1.5.2 (Baraud et al. 2009, Th. 2 and Cor. 1). In the setting defined above, assume that n -D η ≥ 2 for any η ∈ M, and let η be a minimizer of (1.15) or (1.16). Let {L η } η∈M be some family of positive numbers such that:

η∈M (D η + 1)e -L η = Ω < +∞.
(1.25)

Let A > 1 and further assume that

pen(η) = pen A,L (η) = A n -D η n -D η -1 EDkhi[D η + 1, n -D η -1, e -L η ].
Then the selected estimator μ η satisfies the following risk bound:

E         µ -μ η 2 σ 2         ≤ A A -1 inf η∈M        µ -µ η 2 σ 2 1 + pen(η) n -D η + pen(η) -D η        + 2A 2 Ω A -1 . In addition, if κ < 1, n -D η ≥ 7 and max(L η , D η ) ≤ κn for any η ∈ M, then: E         µ -μ η 2 σ 2         ≤ C(A, κ)         inf η∈M        µ -µ η 2 σ 2 + max(L η , D η )        + Ω         . (1.26)
This theorem looks like Theorem 1.5.1 that we recalled above. Note that the condition on the weights (1.25) is similar but not identical to previous condition (1.19). Inequality (1.26) is an oracle inequality as soon as the weights L η can be taken of the order of D η for all η ∈ M. As previously, those weights need to be calibrated for each model collection one considers (see below for an example). Contrary to Theorem 1.5.1, the choice of the penalty is explicit, and does not depend on any unknown parameter beside the normalizing constant A > 1. This makes the choice of this constant much more robust, and [START_REF] Baraud | Gaussian model selection with an unknown variance[END_REF] advise to take A ≈ 1.1.

Derivation in the Coordinate Sparse Setting

We go back to the coordinate-sparse setting of Definition 1.5.3, and derive the penalty in this framework, as we did in Section 1.5.2.2 for the Birgé-Massart criterion. Suppose that we look at models of dimensions no greater that p ≤ n -7. Then:

Ω = η∈M (D η + 1)e -L η = p D=0 n D (D + 1)e -L D = p D=0 1 D + 1 ≤ 1 + log(p) ≤ 1 + log(n)
where we took weights L D = log n D + 2 log(D + 1). We get the following control of the weights, using the classical bounds log n D ≤ D log(n) and log(1 + D) ≤ D:

L D ≤ D log(n) + 2D ≤ p(2 + log(n)).
Finally, taking

p ≤ min κn 2 + log(n) , n -7 ,
1. Background we get the following oracle inequality, for some constant C (A, κ):

E         µ -μ η 2 σ 2         ≤ C (A, κ) inf η∈M        µ -µ η 2 σ 2 + (D η + 1) log(n)       
Remark that we miss the oracle estimator up to a log(n) term, that is known to be un-avoidable in this setting [START_REF] Baraud | Gaussian model selection with an unknown variance[END_REF][START_REF] Donoho | Ideal spatial adaptation by wavelet shrinkage[END_REF].

Appendix

1.A The Ornstein-Uhlenbeck Process

1.A.1 Stochastic Differential Equation and General Solution

Let W(t) be the vector of the p traits values on one lineage, A a squared p × p matrix of strength of selections, Σ a diffusion matrix, with R = ΣΣ T the rate matrix, β(t) a vector of optimal values, and B t the standard multi-variate Brownian motion. Then the OU process is defined by the following Stochastic Differential Equation (SDE):

dW(t) = -A(W(t) -β(t))dt + ΣdB t
The solution of which is given by:

W(t) = e -At W(0) + t 0 e -A(t-v) Aβ(v)dv + t 0 e -A(t-v) ΣdB v (1.27)
Writing this between one node j and its parent, we get:

W(t j ) = e -A j W(t pa(j) ) + t j t pa(j) e -A(t j -v) Aβ(v)dv + t j t pa(j) e -A(t j -v) ΣdB v (1.28)
For a univariate OU with a constant central parameter β, we can get an explicit solution, that can be expressed as a Brownian Motion re-scaled by an exponential transformation of the time, as shown in the next lemma.

Lemma 1.A.1 (Brownian Solution for the OU). The stochastic process defined by:

X t = X 0 e -αt + β(1 -e -αt ) + σ √ 2α e -αt B e 2αt -1
is an OU, solution of the EDS dX t = α(β -X t ) + σ dB t .

1.A.2 Induced Variance Structure

We first need to compute the variance covariance matrix of the observations. Let i and j be two nodes. Then, from equation (1.27), we get:

Cov X i ; X j = Cov e -At i W(0); e -At j W(0) + Cov t i 0 e -A(t i -v) ΣdB v ; t j 0 e -A(t j -v) ΣdB v = e -At i Var [W(0)] e -A T t j + E       t i 0 e -A(t i -v) ΣdB v t j 0 e -A(t j -v) ΣdB v T       = e -At i Γe -A T t j + t ij 0 e -A(t i -v) ΣΣ T e -A T (t j -v) dv = e -At i Γe -A T t j V OU r + e -A(t i -t ij ) t ij 0 e -Av ΣΣ T e -A T v dv e -A T (t j -t ij ) V OU p
where Γ is the variance-covariance matrix of the traits vector at the root.

1. Background

1.A.2.1 Using an Eigendecomposition of A

General Expression. We further assume that A has an eigendecomposition with only real eigenvalues: A = PDP -1 , with P invertible, and D = Diag(λ q , 1 ≤ q ≤ p). Then, demoting by the Hadamard product (coefficient-wise multiplication of matrices, see Section 1.B.2), the second term of the equation above becomes [START_REF] Bartoszek | A phylogenetic comparative method for studying multivariate adaptation[END_REF][START_REF] Clavel | mvmorph : an r package for fitting multivariate evolutionary models to morphometric data[END_REF]:

V OU p = P        1 λ q + λ r e -λ q t i e -λ r t j e (λ q +λ r )t ij -1 1≤q,r≤p P -1 RP -T        P T (1.29)
In order to get a stationary state, we also assume that A has only positive eigenvalues. The stationary variance-covariance matrix is then given by (taking t i and t j to +∞):

S = P        1 λ q + λ r 1≤q,r≤p P -1 RP -T        P T (1.30)
and the variance matrix due to the process can be re-written as:

V OU p = e -A(t i -t ij ) Se -A T (t j -t ij ) -e -At i Se -A T t j (1.31)
and we get:

Cov X i ; X j = e -At i Γe -A T t j -e -At i Se -A T t j + e -A(t i -t ij ) Se -A T (t j -t ij )
Root in Stationary State. If S = Γ, then the expression simplifies as:

Cov X i ; X j = P        1 λ q + λ r e -λ q (t i -t ij ) e -λ r (t j -t ij )
1≤q,r≤p

P -1 ΣΣ T P -T        P T
or, in a matricial form:

Cov X i ; X j = e -A(t i -t ij ) Γe -A T (t j -t ij )
Scalar Case. If A is scalar, i.e. A = αI, then the stationary variance is equal to:

S = 1 2α R
and the expressions above simplify to:

Cov X i ; X j = e -α(t i +t j ) Γ + e -α(t i +t j ) (e 2αt ij -1)S general case = e -α(t i +t j -2t ij ) Γ stationary root
And we recover the known expressions of the univariate case (see e.g. [START_REF] Hansen | Stabilizing Selection and the Comparative Analysis of Adaptation[END_REF]Ho & Ané, 2013b) by taking R = σ 2 . These expression will be used in the next two chapters.

1.A.2.2 Using the Kronecker Sum

Using the same method as in [START_REF] Meucci | Review of Statistical Arbitrage, Cointegration, and Multivariate Ornstein-Uhlenbeck[END_REF], we can derive the formulas above without using the diagonalization of matrix A. To do that, we need the following result:

Lemma 1.A.2. For any two matrices M, N, with M invertible, we have:

vec t 0 e -Mv Ne -M T v dv = t 0 vec e -Mv Ne -M T v dv = t 0 e -Mv ⊗ e -Mv vec(N)dv = t 0 e -(M⊕M)v vec(N)dv = (M ⊕ M) -1 I -e -(M⊕M)t vec(N)
(using the first formula of Proposition 1.B.2, and the last of Proposition 1.B.1).

This lemma can be used to derive the following expression for vec(V OU p ):

vec(V OU p ) = vec e -A(t i -t ij ) t ij 0 e -Av ΣΣ T e -A T v dv e -A T (t j -t ij ) = e -(A(t i -t ij )⊕A(t j -t ij )) vec t ij 0 e -Av ΣΣ T e -A T v dv = e -(At i ⊕At j ) e (A⊕A)t ij (A ⊕ A) -1 (I p 2 -e -(A⊕A)t ij ) vec(R) = e -(At i ⊕At j ) e (A⊕A)t ij (I p 2 -e -(A⊕A)t ij )(A ⊕ A) -1 vec(R)
(as (A ⊕ A) commutes with e -(A⊕A)t ij ). Sending as previously t i and t j to +∞, we get the stationary variance:

vec(S) = (A ⊕ A) -1 vec(R) (1.32)
and we get:

vec(V OU p ) = e -(At i ⊕At j ) e (A⊕A)t ij vec(S) -e -(A⊕A)t ij vec(S) = e -(A(t i -t ij )⊕A(t j -t ij )) vec(S) -e -(At i ⊕At j ) vec(S)
which simplifies to the same formula as above:

vec(V OU p ) = vec(e -A(t i -t ij ) Se -A T (t j -t ij ) -e -At i Se -A T t j )
which lead to the same expressions for the variance.

1.A.3 Incomplete Data Formulation

Using equation (1.28), we get, for j ∈ 2 , m + n :

X j X pa(j) ∼ N e -A j X pa(j) + (I p -e -A j )β j , Υ i = i 0 e -Au ΣΣ T e -A T u du
with, using lemma 1.A.2 and the commutation:

vec(Υ j ) = (A ⊕ A) -1 I -e -(A⊕A)t vec(R) = I -e -(A⊕A)t vec(S)
Hence:

Υ i = S -e -A j Se -A T j
And, if A is diagonalizable in R:

Υ i = P        1 λ q + λ r 1 -e -(λ q +λ r ) i 1≤q,r≤p P -1 ΣΣ T P -T        P T Remark 1.A.1.
If A is scalar, the formula above simplifies to:

X j X pa(j) ∼ N e -α j X pa(j) + (I p -e -α j )β j , (1 -e -2α j ) 1 2α R

1.B Multivariate Analysis Tools

In this section, we recall some classical mathematical tools used in multivariate analysis.

Those will be useful mainly in Chapter 3. For an extensive view of these tools, we refer to [START_REF] Mardia | Multivariate analysis. Probability and mathematical statistics[END_REF].

1.B.1 Kronecker Product and Vectorization

The Kronecker product and the vectorization operation appear naturally in multivariate analysis, to describe the distribution of a matrix for instance.

1.B.1.1 Kronecker Product

Definition 1.B.1. Let A and B be two matrices of size m × n and p × q. Their Kronecker product A ⊗ B is the mp × nq matrix defined by:

A ⊗ B =           A 11 B . . . A 1n B . . . . . . . . . A m1 B . . . A mn B           Proposition 1.B.1. Let A, B
and C be matrices of size m × n, p × q and k × l respectively.

The following properties hold:

⊗ is distributive over +, associative, and is not commutative.

(A ⊗ B)(C ⊗ D) = (AC) ⊗ (BD) (when it makes sense) (A ⊗ B) T = A T ⊗ B T Rank(A ⊗ B) = Rank(A) Rank(B)
If A and B are rectangular with singular values (λ 1 , . . . , λ r A ) and (µ 1 , . . . , µ r B ), then A ⊗ B has singular values (λ j µ l ) 1≤j≤r A ;1≤l≤r B .

In addition, for squared matrices A and B sizes m × m and p × p: The vectorization operation and the Kronecker product work particularly well together, as shown by the following proposition.

(A ⊗ B) -1 = A -1 ⊗ B -1 (if A
Proposition 1.B.2 (Vectorization and Kronecker product). Let A, B and C be matrices of size m × n, n × p and p × q respectively. Then the following identities hold:

vec(ABC) = (C T ⊗ A) vec(B) = (I q ⊗ AB) vec(C) = (C T B T ⊗ I m ) vec(A).
In particular:

vec(AB) = (I p ⊗ A) vec(B) = (B T ⊗ I m ) vec(A).
Vectorization can also be used in cooperation with Kronecker products to write Mahalanobis norms. These quantities naturally appear in the density of matrix normal distributions.

Proposition 1.B.3 (Vectorization and Mahalanobis Norm). Let A and B be two symmetric matrices of size n × n and m × m respectively. Let X be a matrix of size m × n. Then:

vec(X) 2 (A⊗B) -1 = vec(X T ) 2 (B⊗A) -1 . Proof. vec(X) 2 (A⊗B) -1 = vec(X) T (A -1/2 ⊗ B -1/2 ) T (A -1/2 ⊗ B -1/2 ) vec(X) = vec((B -1/2 )X(A -1/2 ) T ) 2 = vec((A -1/2 )X T (B -1/2 ) T ) 2 = vec(X T ) 2 (B⊗A) -1

Foreword

This chapter has been published under the title Detection of adaptive shifts on phylogenies by using shifted stochastic processes on a tree in the Journal of the Royal Statistical Society: Series B (Statistical Methodology). Bastide et al. (2017b).

Abstract. Comparative and evolutive ecologists are interested in the distribution of quantitative traits among related species. The classical framework for these distributions consists of a random process running along the branches of a phylogenetic tree relating the species. We consider shifts in the process parameters, which reveal fast adaptation to changes of ecological niches. We show that models with shifts are not identifiable in general. Constraining the models to be parsimonious in the number of shifts partially alleviates the problem but several evolutionary scenarios can still provide the same joint distribution for the extant species. We provide a recursive algorithm to enumerate all the equivalent scenarios and to count the number of effectively different scenarios. We introduce an incomplete-data framework and develop a maximum likelihood estimation procedure based on the EM algorithm. Finally, we propose a model selection procedure, based on the cardinal of effective scenarios, to estimate the number of shifts and for which we prove an oracle inequality.

Introduction

Motivations: Environmental Shifts

An important goal of comparative and evolutionary biology is to decipher the past evolutionary mechanisms that shaped present day diversity, and more specifically to detect the dramatic changes that occurred in the past (see for instance [START_REF] Losos | Concordant evolution of locomotor behaviour, display rate and morphology in Anolis lizards[END_REF][START_REF] Mahler | Exceptional Convergence on the Macroevolutionary Landscape in Island Lizard Radiations[END_REF][START_REF] Davis | Floral Gigantism in Rafflesiaceae[END_REF][START_REF] Jaffe | The evolution of island gigantism and body size variation in tortoises and turtles[END_REF]. It is well established that related organisms do not evolve independently [START_REF] Felsenstein | Phylogenies and the Comparative Method[END_REF]: their shared evolutionary history is well represented by a phylogenetic tree. In order to explain the pattern of traits measured on a set of related species, one needs to take these correlations into account. Indeed, a given species will be more likely to have a similar trait value to her "sister" (a closely related species) than to her "cousin" (a distantly related species), just because of the structure of the tree. On top of that structure, when considering a functional trait (i.e. a trait directly linked to the fitness of its bearer), such as shell size for turtles [START_REF] Jaffe | The evolution of island gigantism and body size variation in tortoises and turtles[END_REF], one needs to take into account the effect of the species environment on its traits. Indeed, a change in the environment for a subset of species, like a move to the Galàpagos Islands for turtles, will affect the observed trait distribution, here with a shift towards giant shell sizes compared to mainland turtles. The observed present-day trait distribution hence contains the footprint of adaptive events, and should allow us to detect unobserved past events, like the migration of one ancestral species to a new environment. Our goal here is to devise a statistical method based on a rigorous maximum likelihood framework to automatically detect the past environmental shifts that shaped the present day trait distribution.

Stochastic Process on a tree

We model the evolution of a quantitative adaptive trait using the framework of stochastic processes on a tree. Specifically, given a rooted phylogenetic tree, we assume that the trait evolves according to a given stochastic process on each branch of the tree. At each speciation event, or equivalently node of the tree, one independent copy with the same initial conditions and parameters is created for each daughter species, or outgoing branches.

Tree Structure. This model is our null model: it accounts for the tree-induced distribution of trait values in the absence of shifts. Depending on the phenomenon studied, several stochastic processes can be used to capture the dynamic of the trait evolution. In the following, we will use the Brownian Motion (BM) and the Ornstein-Uhlenbeck (OU) processes. Brownian Motion. Since the seminal article of [START_REF] Felsenstein | Phylogenies and the Comparative Method[END_REF], the BM has been used as a neutral model of trait evolution. If (B t ; t ≥ 0) is the Brownian motion, a character (W t ; t ≥ 0) evolves on a lineage according the the stochastic differential equation: dW t = σ dB t , σ 2 being a variance parameter. If µ is the ancestral value at the root of the tree (t = 0), then W t ∼ N (µ, σ 2 t). The variance σ 2 t of the trait is proportional to the time of evolution and the covariance σ 2 t ij between two species i and j is proportional to their time of shared evolution.

Ornstein-Uhlenbeck Process. An unbounded variance is quite unrealistic for adaptive traits [START_REF] Butler | Phylogenetic Comparative Analysis: A Modeling Approach for Adaptive Evolution[END_REF]. For that reason, the OU process, that models stabilizing selection around an adaptive optimum [START_REF] Hansen | Stabilizing Selection and the Comparative Analysis of Adaptation[END_REF] is usually preferred to the BM. It is defined by the stochastic differential equation dW t = -α(W tβ)dt + σ dB t , and has stationary distribution N (β, σ 2 /2α). In this equation, W t is the secondary optimum of a species, a trade-off between all selective constraints -e.g. ecological -on the trait and can be approached by the population mean of that species. The term -α(W t -β)dt of the equation represents the effects of stabilizing selection towards a primary optimum β, that depends only on the ecological niche of the species. The selection strength is controlled by the call-back parameter α. For interpretation purpose, we will use the phylogenetic half-life t 1/2 = ln(2)/α, defined as the time needed for the expected trait value to move half the distance from the ancestral state to the primary optimum [START_REF] Hansen | Stabilizing Selection and the Comparative Analysis of Adaptation[END_REF]. The term σ dB t represents the random effects of uncontrolled factors, ranging from genetic drift to environmental fluctuations. We refer to [START_REF] Hansen | Stabilizing Selection and the Comparative Analysis of Adaptation[END_REF]; [START_REF] Hansen | A Comparative Method for Studying Adaptation to a Randomly Evolving Environment[END_REF] for further discussion and deeper biological interpretations of the hypothesis underlying this model of evolution. The aim of our work is to detect environmental shifts.

Environmental Shifts. In addition to the previous mechanisms, we assume that abrupt environmental changes affected the ecological niche of some ancestral species. We model these changes as instantaneous shifts in the parameters of the stochastic process. Shifted parameters are inherited along time and thus naturally create clusters of extant species that share the same parameters trajectories. In the BM process, shifts affect the mean value of the trait and are thus instantaneously passed on to the trait itself (see Figure 2.1.1) whereas in the OU process, shifts affect the primary optimum β. In this case, the trait converges to its new stationary value with an exponential decay of half-life t 1/2 inducing a lag that makes recent shifts harder to detect (Hansen & Bartoszek, 2012). In the remainder, we assume that all other parameters (σ 2 for the BM and σ 2 , α for the OU) are fixed and constant (but see [START_REF] Beaulieu | Modeling stabilizing selection: Expanding the Ornstein-Uhlenbeck model of adaptive evolution[END_REF][START_REF] Rabosky | Automatic detection of key innovations, rate shifts, and diversitydependence on phylogenetic trees[END_REF] for partial relaxations of this hypothesis).

Scope of this article

State of the Art. Phylogenetics Comparative Methods (PCM) are an active field that has seen many fruitful developments in the last few years (see [START_REF] Pennell | An integrative view of phylogenetic comparative methods: connections to population genetics, community ecology, and paleobiology[END_REF], for an extensive review). Several methods have been specifically developed to study adaptive evolution, starting with the work of [START_REF] Butler | Phylogenetic Comparative Analysis: A Modeling Approach for Adaptive Evolution[END_REF]. [START_REF] Butler | Phylogenetic Comparative Analysis: A Modeling Approach for Adaptive Evolution[END_REF] only consider shifts in the optimal value β whereas Beaulieu et al. ( 2012) also allow for shifts in the selection strength α and the variance σ 2 . Both have in common that shift locations are assumed to be known. Several extensions of the model without or with known shifts have also been proposed: [START_REF] Hansen | A Comparative Method for Studying Adaptation to a Randomly Evolving Environment[END_REF] extended the original work of [START_REF] Hansen | Stabilizing Selection and the Comparative Analysis of Adaptation[END_REF] on OU processes to a two-tiered model where β(t) is itself a stochastic process (either BM or OU). [START_REF] Bartoszek | A phylogenetic comparative method for studying multivariate adaptation[END_REF] extended it further to multivariate traits whereas Hansen & Bartoszek (2012) introduced errors in the observations. Expanding upon the BM, [START_REF] Landis | Phylogenetic analysis using Lévy processes: Finding jumps in the evolution of continuous traits[END_REF] replaced fixed shifts, known or unknown, by random jump processes using Levy processes. Non-Gaussian models of trait evolution were also recently considered by [START_REF] Hiscott | Efficient Recycled Algorithms for Quantitative Trait Models on Phylogenies[END_REF], who adapted Felsenstein's pruning algorithm for the likelihood computation of these models, using efficient integration techniques. Finally, Ho & Ané (2013b) derived consistency results for estimation of the parameters of an OU on a tree and [START_REF] Bartoszek | Phylogenetic confidence intervals for the optimal trait value[END_REF]; [START_REF] Sagitov | Interspecies correlation for neutrally evolving traits[END_REF] computed confidence intervals of the same parameters by assuming an unknown random tree topology and averaging over it.

The first steps toward automatic detection of shifts, which is the problem of interest in this paper, have been done in a Bayesian framework, for both the BM [START_REF] Eastman | Simpsonian 'Evolution by Jumps' in an Adaptive Radiation of Anolis Lizards[END_REF] and the OU (Uyeda & Harmon, 2014). Using RJ-MCMC, they provide the user with the posterior distribution of the number and location of shifts on the tree. Convergence is however severely hampered by the size of the search space. The growing use of PCM in fields where large trees are the norm makes maximum likelihood based point estimates of the shift locations more practical. A stepwise selection procedure for the shifts has been proposed in Ingram & Mahler (2013). The procedure adds shifts one at the time and is therefore rather efficient but the selection criterion is heuristic and has no theoretical grounding for that problem, where observations are correlated through the tree structure. These limitations have been pointed out in [START_REF] Ho | Intrinsic inference difficulties for trait evolution with Ornstein-Uhlenbeck models[END_REF]. In this article, the authors describe several identifiability problems that arise when trying to infer the position of the shifts on a tree, and propose a different stepwise algorithm based on a more stringent selection criterion, heuristically inspired by segmentation algorithms.

To rigorously tackle this issue, we introduced a framework where a univariate trait evolves according to an OU process with stationary root state (S) on an Ultrametric tree (U). Furthermore, as the exact position of a shift on a branch is not identifiable for an ultrametric tree, we assume that shifts are concomitant to speciation events and only occur at Nodes (N) of the tree. We refer to this model as OUsun hereafter.

Our Contribution. In this work, we make several major contributions to the problem at hand. First, we derive a statistical method to find a maximum likelihood estimate of the parameters of the model. When the number of shifts is fixed, we work out an Expectation Maximization (EM) algorithm that takes advantage of the tree structure of the data to efficiently maximize the likelihood. Second, we show that, given the model used and the kind of data available, some evolutionary scenarios remain indistinguishable. Formally, we exhibit some identifiability problems in the location of the shifts, even when their number is fixed, and subsequently give a precise characterization of the space of models that can be inferred from the data on extant species. Third, we provide a rigorous model selection criterion to choose the number of shifts needed to best explain the data. Thanks to our knowledge of the structure of the spaces of models, acquired through our identifiability study, we are able to mathematically derive a penalization term, together with an oracle inequality on the estimator found. Fourth and finally, we implement the method on the statistical software R (R Core Team, 2017), and show that it correctly recovers the structure of the model on simulated datasets. When applied to a biological example, it gives results that are easily interpretable, and coherent with previously developed methods. All the code used in this article is publicly available on GitHub (https://github.com/pbastide/PhylogeneticEM).

Outline. In Section 2.2, we present the model, using two different mathematical point of views, that are both useful in different aspects of the inference. In Section 2.3, we tackle the identifiability problems associated with this model, and describe efficient algorithms to enumerate, first, all equivalent models within a class, and, second, the number of truly different models for a given number of shifts. These two sections form the foundation of Section 2.4, in which we describe our fully integrated maximum likelihood inference procedure. Finally, in Sections 2.5 and 2.6, we conduct some numerical experiments on simulated and biological datasets.

Statistical Modeling

Probabilistic Model

Tree Parametrization. As shown in Figure 2.2.1, we consider a rooted tree T with n tips and m internal nodes (m = n -1 for binary trees). The internal nodes are numbered from 1 (the root) to m, and the tips from m+1 to m+n. Let i be an integer, i ∈ 2 , m+n . Then pa(i) is the unique parent of node i. The branch leading to i from pa(i) is noted b i and has length i = t it pa(i) where t i is the time elapsed between the root and node i. By convention, we set t 1 = 0 and t pa(1) = -∞ for the root. The last convention ensures that the trait follows the stationary distribution (if any) of the process at the root. We denote anc(i) = {pa r (i) : r ≥ 0} the set composed of node i and of all its ancestors up to the root. For a couple of integers (i, j), (i, j) ∈ 1 , m + n 2 , nodes i and j are at phylogenetic distance d ij and the time of their most recent common ancestor (mrca) is t ij . We consider ultrametric trees, for which t m+1 = • • • = t m+n =: h and note h the tree height. In the following, the tree is fixed and assumed to be known.

Y 5 Y 4 Y 3 = W 3 (t 4+3 ) Y 2 Y 1 Z 1 Z 4 = W 1 (t 4 ) Z 2 Z 3 2 4+2 t 3 = t 4 ,5 d 4 ,5 τ k = b 4 ν k 4
Trait Values. We denote by X the vector of size m + n of the trait values at the nodes of the tree. We split this vector between non-observed values Z (size m) at the internal nodes, and observed values Y (size n) at the tips, so that X T = (Z T , Y T ). According to our model of trait evolution, the random variable X i , i ∈ 1 , m + n , is the result of a stochastic process stopped at time t i . In the following, we assume that the inference in the BM case is done conditionally to a fixed root value X 1 = µ. In the OUsun case, we assume that the root trait value is randomly drawn from the stationary distribution:

X 1 ∼ N (µ = β 1 , γ 2 = σ 2 2α )
, where β 1 is the ancestral optimal value.

Shifts. We assume that K shifts occur on the tree, K ∈ N. The k th shift, k ∈ 1 , K , occurs at the beginning of branch τ k , τ k ∈ {b i , i ∈ 2 , m+n }, and has intensity δ k , δ k ∈ R.

The interpretation of this intensity depends on the process. In the following, we use the vector ∆ of shifts on the branches, of size m + n, with K + 1 non-zero entries, and defined as follows (see example 2.2.1):

∆ 1 = µ (= β 1 for an OUsun) and ∀i ∈ 2 , n + m , ∆ i =        δ k if τ k = b i 0 otherwise.
Note that no proper shift occurs on the root branch, but that the root trait value or mean, µ, is formalized as an initial fictive shift on this fictive branch.

Parameters. The parameters needed to describe an OUsun (respectively, a BM) are θ = (γ, α, ∆) (resp. θ = (σ , ∆)). Note that, as σ 2 = 2αγ 2 , only the two parameters α and γ are needed to describe the OUsun. We denote by OUsun(θ) (resp. BM(θ)) the OUsun (resp. BM) process running on the tree with parameters θ.

Incomplete Data Model Point of View

If the trait values were observed at all nodes of the tree, including ancestral ones, shifts would be characterized by unexpectedly large differences between a node and its parent.

A way to mimic this favorable case is to use an incomplete data model, as described below. This representation of the model will be useful for the parametric inference using an EM algorithm (Section 2.4.1).

Brownian Motion. As the shifts occur directly in the mean of the process, we get:

X 1 = µ and ∀i ∈ 2 , m + n , X i |X pa(i) ∼ N X pa(i) + ∆ i , i σ 2 (2.1)
The trait value at node i, i ∈ 2 , m+n , is centered on the value of its parent node X pa(i) , with a variance proportional to the evolution time i between i and pa(i). The effect of a non-zero shift ∆ i on branch b i is simply to translate the trait value by ∆ i .

Ornstein-Uhlenbeck. The shifts occur on the primary optimum β, which is piecewise constant. As the shifts are assumed to occur at nodes, the primary optimum is entirely defined by its initial value β 1 and its values β 2 , . . . , β n+m on branches of the tree, where β i is the value on branch b i leading to node i.

β 1 ∈ R (= µ for an OUsun) and ∀i ∈ 2 , m + n , β i = β pa(i) + ∆ i (2.2)
Assuming that the root node is in the stationary state, we get:

       X 1 ∼ N (µ = β 1 , γ 2 = σ 2 2α ) X i |X pa(i) ∼ N X pa(i) e -α i + β i (1 -e -α i ), σ 2 2α (1 -e -2α i ) ∀i ∈ 2 , m + n (2.
3)

The trait value at node i depends on both the trait value at the father node X pa(i) and the value β i of the primary optimum on branch b i . Contrary to the BM case, the shifts only appear indirectly in the distributions of X i s, through the values of β, and with a shrinkage of 1e -αd for shifts of age d, which makes recent shifts (d small compared to 1/α) harder to detect.

Linear Regression Model Point of View

A more compact and direct representation of the model is to use the tree incidence matrix to link linearly the observed values (at the tips) with the shift values, as explained below. We will use this linear regression framework for the Lasso [START_REF] Tibshirani | Regression Selection and Shrinkage via the Lasso[END_REF] initialization of the EM (Section 2.4.1) and the model selection procedure (Section 2.4.2). It will also help us to explore identifiability issues raised in the next section.

Matrix of a Tree. It follows from the recursive definition of X that it is a Gaussian vector. In order to express its mean vector given the shifts, we introduce the tree squared matrix U, of size (m + n), defined by its general term:

U ij = I{j ∈ anc(i)}, ∀(i, j) ∈ 1 , m + n 2 .
In other words, the j th column of this matrix, j ∈ 1 , m + n , is the indicator vector of the descendants of node j. To express the mean vector of the observed values Y, we also need the sub-matrix T, of size n × (m + n), composed of the bottom n rows of matrix U, corresponding to the tips (see example 2.2.1 below). Likewise, the i th row of T, i ∈ 1 , n , is the indicator vector of the ancestors of leaf m + i.

Shift Detection for Univariate Processes

Brownian Motion. From the tree structure, we get:

X = U∆ + E X and Y = T∆ + E Y (2.4)
Here, E X ∼ N (0, Σ XX ) is a Gaussian error vector with co-variances [Σ XX ] ij = σ 2 t ij for any 1 ≤ i, j ≤ m + n, and E Y is the vector made of the last n coordinates of E X .

Ornstein-Uhlenbeck. For the OUsun, shifts occur on the primary optimum, and there is a lag term, so that:

β = U∆ and X = (U -AUB)∆ + E X (2.5)
where

A = Diag(e -αt i , 1 ≤ i ≤ m + n) and B = Diag(0, e αt pa(i) , 2 ≤ i ≤ m + n) are diagonal matrices of size m+n. As previously, E X ∼ N (0, Σ XX ), but Σ XX = γ 2 [e -αd ij ] 1≤i,j≤m+n .
As the tree is ultrametric, this expression simplifies to the following one when considering only observed values:

Y = TW(α)∆ + E Y (2.6)
where E Y is the Gaussian vector made of the last n coordinates of E X , and

W(α) = Diag(1, 1 -e -α(h-t pa(i) ) , 2 ≤ i ≤ m + n) is a diagonal matrix of size m + n. Note that if α is positive, then α(h -t pa(i) ) > 0 for any i ∈ 1 , m + n , and W(α) is invertible.
Example 2.2.1. The tree presented in Figure 2.2.1 has five tips and one shift on branch 4 + 3 = 7, so:

U =                                    Z 1 Z 2 Z 3 Z 4 Y 1 Y 2 Y 3 Y 4 Y 5 Z 1 1 0 0 0 0 0 0 0 0 Z 2 1 1 0 0 0 0 0 0 0 Z 3 1 1 1 0 0 0 0 0 0 Z 4 1 0 0 1 0 0 0 0 0 Y 1 1 0 0 1 1 0 0 0 0 Y 2 1 0 0 1 0 1 0 0 0 Y 3 1 1 0 0 0 0 1 0 0 Y 4 1 1 1 0 0 0 0 1 0 Y 5 1 1 1 0 0 0 0 0 1                                                     T and ∆ =                                    µ 0 0 0 0 0 δ 1 0 0                                   
And, respectively, for a BM or an OUsun (µ = β 1 ):

E [Y] = T∆ = (µ, µ, µ + δ 1 , µ, µ) T (BM) E [Y] = TW(α)∆ = (β 1 , β 1 , β 1 + δ 1 (1 -e -α(h-t 2 ) ), β 1 , β 1 ) T (OU)
Space of Expectations. Expressions (2.4) and (2.6) allow us to link the parameter θ to the probability distribution of observations Y and to explore identifiability issues. In this linear formulation, detecting shifts boils down to identifying the non-zero components of ∆. The following lemma highlights the parallels between solutions of the BM and OUsun processes:

Lemma 2.2.1 (Similar Solutions). Let m Y ∈ R n be a vector, T an ultrametric tree, α a positive real number, and σ , γ non-negative real numbers. Then there exists at least one vector ∆ BM , ∆ BM ∈ R m+n (respectively, ∆ OU ∈ R m+n ), such that the vector of expectations at the tips of a BM(σ , ∆ BM ) (respectively, an OUsun(γ, α, ∆ OU )) running on the tree T is exactly m Y . Furthermore, ∆ BM is a solution to this problem for the BM if and only if ∆ OU = W(α) -1 ∆ BM is a solution for the OUsun, and ∆ BM and W(α) -1 ∆ BM have the same support. These two vectors are said to be similar.

Proof. The first part of this lemma follows directly from formulas (2.4) (BM) and (2.6) (OU). Indeed, the maps ∆ → T∆ and ∆ → TW(α)∆ both span R n . The second part of the lemma is a consequence of W(α) being diagonal and invertible (for α > 0). Remark 2.2.1. Lemma 2.2.1 shows that the OUsun and BM processes that induce a given m Y use shifts located on the same branches, although they may differ on other parameters.

Identifiability and Complexity of a Model

Identifiability Issues

As we only have access to Y, and not X, we only have partial information about the shifts occurrence on the tree. In fact, several different allocations of the shifts can produce the same trait distribution at the tips, and hence are not identifiable. In other words, there exists parameters θ θ with the same likelihood function: p θ (•) = p θ (•). Note that the notion of identifiability is intrinsic to the model and affects all estimation methods. Restricting ourselves to the parsimonious allocations of shifts only partially alleviates this issue, and, using a "random cluster model" representation of the problem, we are able to enumerate, first, all the equivalent solutions to a given problem, and, second, all the equivalence classes for a given number of shifts. No Homoplasy Assumption. We assume in the following that there is no convergent evolution. This means that each shift creates a new (and unique) mean trait value for extant species that are below it. This assumption is reasonable considering that shifts are real valued and makes the model similar to "infinite alleles" models in population genetics. This assumption confines but does not eliminate the identifiability issue, as seen in Figure 2.3.1. Here, four distinct allocations give the same mean values (µ + δ 1 , µ + δ 2 ) at the tips. The lack of identifiability is due to the non-invertibility of the tree matrix T.

µ δ 1 δ 2 µ+δ 2 µ+δ 1 µ δ 2 -δ 1 δ 1 µ + δ 1 δ 1 -δ 2 µ + δ 2 µ+δ 2 µ+δ 1 δ 2 -δ 1

Definition of the problem

Proposition 2.3.1 (Kernel of the Tree Matrix T). Let i be an internal node, i ∈ 1 , m , with L i children nodes (d 1 , • • • , d L i ) ∈ 2 , m + n L i . Then the vector K i defined as follow: ∀j ∈ 1 , m + n , K i j =            1 if j = i -1 if j ∈ (d 1 , • • • , d L i ) 0 otherwise
is in the kernel of T. In addition, the m vectors constructed this way form a basis of the kernel space of T.

These kernel vectors effectively "cancel out" a shift on a branch by balancing it with the opposite shift on all immediate child branches. Note that the root mean value is treated as a shift.

Proof of Proposition 2.3.1. Let i ∈ 1 , m be an internal node with L i children nodes

(d 1 , • • • , d L i
) and K i the corresponding vector, defined as in the proposition. Then, for any j ∈ 1 , m + n :

(UK i ) j = U ji K i i + L i l=1 U jd l K i d l = I{i ∈ anc(j)} - L i l=1
I{d l ∈ anc(j)}

We can then distinguish three possibilities:

If i anc(j), then d l anc(j) for all l ∈ 1 , L i and (TK i ) j = 0.

If j = i, then i ∈ anc(j), and, by definition, d l anc(j) for any l ∈ 1 , L , so

(UK i ) i = 1.
Else, if i is an ancestor of j, with i j, then, as i is internal, one (and only one) of its child d l is also an ancestor of j (potentially j itself), so that the sum cancels out.

This proves that

∀i ∈ 1 , m , UK i = (δ ij ) 1≤j≤m+n (2.7)
In particular, as TK i is the vector of the last n coordinates of UK i , this shows that the vectors

(K 1 , • • • , K m ) are in the kernel of T.
Then, as we found m independent vectors in the kernel of T, which is a space of dimension lower than m (as the n columns of T representing tips are linearly independent, and by the rank theorem), this family of vectors is a basis of the kernel space.

The following lemma describes the relationships that exist between these kernel vectors and the tree matrix U defined in Section 2.2.3. Let "Random Cluster Model" Representation. When inferring the shifts, we have to keep in mind this problem of non-identifiability, and be able to choose, if necessary, one or several possible allocations among all the equivalent ones. In order to study the properties of the allocations, we use a random cluster model, as defined in [START_REF] Mossel | A phase transition for a random cluster model on phylogenetic trees[END_REF]. The following definition states the problem as a node coloring problem. Definition 2.3.1 (Node Coloring). Let C K be a set of K arbitrary "colors", K ∈ N * . For a given shift allocation, the color of each node is given by the application B : 1 , m+n → C K recursively defined in the following way:

i ∈ 1 , m + n . Let's show that Ub i = b i . If m + 1 ≤ i ≤ m + n, then b i = b i , and Ub i = b i is the i th column of U. Otherwise, if 1 ≤ i ≤ m, then b i = K i ,
Choose a color c ∈ C K for the root:

B(1) = c. For a node i, i ∈ 2 , m + n , set B(i) to B(pa(i)) if there is no shift on branch i, otherwise choose another color c, c ∈ C K \ {B(pa(i))}, and set B(i) to c.
Hereafter, we identify (C K ) 1,m+n with (C K ) m+n and refer to a node coloring indifferently as an application or a vector.

As the shifts only affect E [X] and we only have access to E [Y], we identify colors with the distinct values of E [Y]: Definition 2.3.2 (Adapted Node Coloring). A node coloring is said to be adapted to a shifted random process on a tree if two tips have the same color if and only if they have the same mean value under that process.

Proposition 2.3.2 (Adapted Coloring for BM and OUsun). Let σ and γ be two nonnegative real numbers, and α a positive real number. Then: (i) In the BM case, if C is the set of possible mean values taken by the nodes of the tree, then the knowledge of the node colors is equivalent to the knowledge of ∆. Furthermore, the associated node coloring is adapted to the original BM.

(ii) In the OUsun case, from lemma 2.2.1, we can find a similar BM process, i.e. with shifts on the same branches. Then the knowledge of the node coloring associated to this similar BM process is equivalent to the knowledge of the vector of shifts of the OUsun, and the node coloring obtained is adapted to the original OUsun.

Proof of Proposition 2.3.2. The proof of (i) relies on expression (2.4), that states that

E [X] = U∆. Defining C as the set off all distinct values of E [X], we can identify E [X]
with the node coloring application that maps any node i with E [X] i . Since U is invertible (see lemma 2.3.1 above), we can go from one formalism to the other. For (ii), we use lemma 2.2.1 to find a similar BM, and then use (i).

From now on, we will study the problem of shifts allocation as a discrete-state coloring problem.

2. Shift Detection for Univariate Processes

Parsimony

As we saw on Figure 2.3.1 there are multiple colorings of the internal nodes that lead to a given tips coloring. Among all these solutions, we choose to study only the parsimonious ones. This property can be seen as an optimality condition, as defined below:

Definition 2.3.3 (Parsimonious Allocation). Given a vector of mean values at the tips produced by a given shifted stochastic process running on the tree, an adapted node coloring is said to be parsimonious if it has a minimum number of color changes. We denote by S P K the set of parsimonious allocations of K shifts on the (m + n -1) branches of the tree (not counting the root branch).

As K shifts cannot produce more than K + 1 colors, we can define an application φ : S P K → (C K+1 ) n that maps a parsimonious allocation of shifts to its associated tip partition.

Definition 2.3.4 (Equivalence). Two allocations are said to be equivalent (noted ∼) if they produce the same partition of the tips and are both parsimonious. Mathematically:

∀s 1 , s 2 ∈ S P K , s 1 ∼ s 2 ⇐⇒ φ(s 1 ) = φ(s 2 )
In other words, two allocations are equivalent if they produce the same tip coloring up to a permutation of the colors. Given d ∈ (C K+1 ) n a coloring of the tips of T with K + 1 colors, φ -1 (d) is the set of equivalent parsimonious node coloring that coincide with d (up to a permutation of the colors) on the tree leaves.

Several dynamic programming algorithms already exist to compute the minimal number of shifts required to produce a given tips coloring, and to find one associated parsimonious solution (see [START_REF] Fitch | Toward Defining the Course of Evolution: Minimum Change for a Specific Tree Topology[END_REF][START_REF] Sankoff | Minimal Mutation Trees of Sequences[END_REF][START_REF] Felsenstein | Inferring Phylogenies[END_REF]. Here, we need to be a little more precise, as we want to both count and enumerate all possible equivalent node colorings associated with a tip coloring. For the sake of brevity, we only present the algorithm that counts φ -1 (d) , for d ∈ (C K ) n . This algorithm can be seen as a corollary of the enumeration algorithm (presented and proved in Appendix 2.A) and an extension of Fitch algorithm where we keep track of both the cost of an optimal coloring and the number of such colorings. It has O(K 2 Ln) time complexity where L is the maximal number of children of the nodes of the tree.

Proposition 2.3.3 (Size of an equivalence class). Let d be a coloring of the tips, d ∈ (C K ) n , and let i be a node of tree T with L i daughter nodes

(i 1 , • • • , i L i ), L i ≥ 2. Denote by T i the sub-tree rooted at node i. For k ∈ C K , S i (k)
is the cost of starting from node i with color k, i.e. the minimal number of shifts needed to get the coloring of the tips of T i defined by d, when starting with node i in color k. Denote by T i (k) the number of allocations on T i that achieve cost S i (k).

If i is a tip (m + 1 ≤ i ≤ m + n), then, S i (k) =        0 if d(i) = k +∞ otherwise T i (k) =        1 if d(i) = k 0 otherwise
Otherwise, if i is a node, for 1 ≤ l ≤ L i , define the set of admissible colors for daughter i l :

K l k = argmin p∈C K S i l (p) + I{p k} As these sets are not empty, let (p 1 , . . . p L ) ∈ K 1 k × . . . × K L k . Then: S i (k) = L l=1 S i l (p l ) + I{p l k} and T i (k) = L l=1 p l ∈K l k T i l (p l ) At the root, if L = argmin k∈C K S 1 (k), then φ -1 (d) = k∈L T 1 (k).
OU Practical Case. We can illustrate this notion on a simple example. We consider an OUsun on a random tree of unit height (total height h = 1). We put three shifts on the tree, producing a given trait distribution. Then, using proposition 2.3.2 and our enumeration algorithm, we can reconstruct the 5 possible allocations of shifts that produce the exact same distribution at the tips. These solutions are shown in Figure 2.3.2.

Note that the colors are not defined by the values of the optimal regime β, but by the mean values E [Y] of the process at the tips. As a result, the groups shown in blue and red in the first solution have the same optimal value in this configuration, but not in any other. The second solution shown illustrates the fact that all the shifts values are inter-dependent, as changing the position of only one of them can have repercussions on all the others. Finally, the third solution shows that the timing of shifts matters: to have the same impact as an old shift, a recent one must have a much higher intensity (under constant selection strength such as in the OUsun). Possible Relaxation of the No-homoplasy Assumption. Note that the algorithms used for counting and enumerating the configurations of an equivalence class are valid even without the no-homoplasy hypothesis. The no-homoplasy hypothesis is however crucial in the next Section to establish a link between the number of shifts and the number of distinct tips colors.

Complexity of a Collection of Models

Number of Different Tips Colors. As we make the inference on the parameters with a fixed number of shifts K (see Section 2.4.1), we need a model selection procedure to choose K. This procedure depends on the complexity of the collection of models that use K shifts, defined as the number of distinct models. To do that, we count the number of tree-compatible partitions of the tips into K +1 groups, as defined in the next proposition:

Proposition 2.3.4. Under the no homoplasy assumption, an allocation of K shifts on a tree is parsimonious if and only if it creates exactly K + 1 tip colors. The tip partition into K + 1 groups associated with this coloring is said to be tree-compatible. The set D K+1 ⊂ (C K+1 ) n of such partitions is the image of S P K by the map φ defined in the previous section.

Proof of Proposition 2.3.4. First, note that K shifts create at most K + 1 colors. If each shift produces a new tip mean value (no homoplasy), the only way to create K or less colors is to "forget" one of the shifts, i.e. to put shifts on every descendant of the branch where it happens. Such an allocation is not parsimonious, as we could just add the value of the forgotten shift to all its descendant to get the same coloring of the tips with one less shift. So a parsimonious allocation cannot create less than K + 1 colors, and hence creates exactly K + 1 colors.

Reciprocally, if an allocation with K shifts that produces p groups is not parsimonious, then we can find another parsimonious one that produces the same p groups with p -1 shifts, with p -1 < K, i.e. p < K + 1. So, by contraposition, if the allocation produces K + 1 groups, then it is parsimonious.

Using the equivalence relation defined in Definition 2.3.4, we can formally take the quotient set of S P K by the relation ∼ to get the set of parsimonious allocations of K shifts on the m + n -1 branches of the tree that are identifiable: S P I K = S P K / ∼. In other words, the set S P I K is constituted of one representative of each equivalence class. Under the no homoplasy assumption, there is thus a bijection between identifiable parsimonious allocations of K shifts and tree-compatible partitions of the tips in K + 1 groups:

S P I K → ∼ D K+1 .
The number N (T ) K+1 = |D K+1 | is the complexity of the class of models with K shifts defined as the number of distinct identifiable parsimonious possible configurations one can get with K shifts on the tree. To compute N (T ) K , we will need M (T ) K the number of marked tree-compatible partitions in K groups. These are composed of all the treecompatible partitions where one group, among those that could be in the same state as the root, is distinguished with a mark (see example 2.3.1 below). If we consider only unmarked partitions, then colorings 1, 2 and 3 induce the same partitions as, respectively, colorings 4, 5 and 6, and

N (T ) 2 = 3.
For marked partitions, fix the root state to an arbitrary color, for instance white, and consider the white group as marked. Then colorings 5 and 6 are not tree-compatible (they require two shifts). And although they induce the same partition, colorings 1 and 4 correspond to different marked partitions: each marks a different group of leaves. Therefore M If i is a tip, then N

(T i ) K = M (T i ) K = I{K = 1}. Else, if i is a node with L i daughter nodes (i 1 , • • • , i L i ), L i ≥ 2, then:                            N (T i ) K = I⊂ 1,L i |I|≥2 k 1 +•••+k L i =K+|I|-1 k 1 ,...,k L i ≥1 l∈I M (T i l ) k l l I N (T i l ) k l + k 1 +•••+k L i =K k 1 ,...,k L i ≥1 L i l=1 N (T i l ) k l M (T i ) K = I⊂ 1,L i |I|≥1 k 1 +•••+k L i =K+|I|-1 k 1 ,...,k L i ≥1 l∈I M (T i l ) k l l I N (T i l ) k l (2.8)
In the binary case, this relation becomes, if i has two daughters i and i r :

                       N (T i ) K = k 1 +k 2 =K k 1 ,k 2 ≥1 N (T i ) k 1 N (T i r ) k 2 + k 1 +k 2 =K+1 k 1 ,k 2 ≥1 M (T i ) k 1 M (T i r ) k 2 M (T i ) K = k 1 +k 2 =K k 1 ,k 2 ≥1 M (T i ) k 1 N (T i r ) k 2 + N (T i ) k 1 M (T i r ) k 2 + k 1 +k 2 =K+1 k 1 ,k 2 ≥1 M (T i ) k 1 M (T i r ) k 2
(2.9)

Proof. We will prove this proposition in the binary case, the general case being a natural extension of it. If T is a binary tree with T and T r as left and right sub-trees, one faces two situations when partitioning the tips in K groups:

The left and right sub-trees have no group in common. Then, the number of groups in T is equal to the number of groups in its two sub-trees, and there are

k 1 +k 2 =K N (T ) k 1 N (T r ) k 2
such partitions. This is the first term of the equation on N

(T ) K in (2.9).

The left and right sub-trees have at least one group in common. Then, from the no homoplasy assumption, they have exactly one group in common: the ancestral state of the root. Suppose that this ancestral state is marked. Then it must be present in the two sub-trees, and there are

k 1 +k 2 =K+1 M (T ) k 1 M (T r ) k 2 such partitions.
This ends the proof of the formula on N (T ) K .

To get the formula on M (T ) K , we use the same kind of arguments. The second part of the formula is the same as the one for N (T ) K , and the first part corresponds to trees for which the marked partition is present in only one of the two sub-trees.

The complexity of the algorithm described above is O(2 L (K +L) L Ln). Note that N (T ) K depends on the topology of the tree T in general. However, if the tree is binary, a closed form solution of the recurrence relation (2.8), which does not depend on the topology, exists.

Corollary 2.3.1 (Closed Formula Binary Trees). For a rooted binary tree with n tips, we have:

N (T ) K+1 = N (n) K+1 = S P I K = 2n -2 -K K and M (T ) K = M (n) K = 2n -K K -1
The demonstration of this formula is not straightforward, and is based on a Vandermondelike equality, detailed in Appendix 2.B. The formula is then obtained using a strong induction on the number of tips of the tree.

Remark 2.3.1. Note that, when K is large compared to √ n, the average number of configurations per equivalence class goes to infinity. This can be checked by comparing the total number of configurations 2n-1 K-1 with the total number of classes 2n-K-1 K-1 . As a consequence, we only consider models for which K < √ n in the remainder.

Remark 2.3.2. This formula was already obtained in a different context in [START_REF] Steel | The complexity of reconstructing trees from qualitative characters and subtrees[END_REF] (Proposition 1) and, with a slightly different formulation, in Semple & Steel (2003, Proposition 4.1.4). In these works, the authors are interested in counting the "r-states convex characters on a binary tree". Under the no-homoplasy assumption, this number can be shown to be equal to S P I r-1 .

Another Characterization of Parsimony

The following proposition gives an alternative definition of parsimony under the nohomoplasy hypothesis using the linear formulation of the problem. It will be used for model selection in Section 2.4.2.

Proposition 2.3.6 (Equivalence between parsimony and independence). Let m Y be a given mean vector, m Y ∈ R n , and ∆ a vector of shifts such that T∆ = m Y , with T the tree matrix defined in Section 2.2.3. Under the no homoplasy assumption, the vector of shifts ∆ is parsimonious if and only if the corresponding column-vectors of the tree matrix (T i ) i∈Supp(∆) are linearly independent.

Proof of Proposition 2.3.6. By contraposition, let's first assume that the vector-columns (T i ) i∈Supp(∆) are linearly dependent, and prove that ∆ is not parsimonious. This means that we can find a vector E, E ∈ R m+n , such that Supp(E) ⊂ Supp(∆), and TE = 0. We can hence find j ∈ Supp(∆), j > 1, such that E j 0. Then if λ = -∆ j /E j , the vector ∆ = ∆ + λE is a vector of shifts on the tree with one less non-zero coordinate than ∆ such that T∆ = m Y . Hence, ∆ is not parsimonious. Reciprocally, by contraposition, assume that ∆ is not parsimonious. Then by proposition 2.3.4, it produces p groups, with p ≤ K. Hence the application associated with (T i ) i∈Supp(∆) goes from a space of dimension K + 1 to a space of dimension p ≤ K, and hence is not injective, and the family (T i ) i∈Supp(∆) is not independent.

Statistical Inference

Expectation Maximization

Principle. As shown in Section 2.2.2, both BM and OUsun models can be seen as incomplete data models. The Expectation Maximization algorithm (EM, [START_REF] Dempster | Maximum likelihood from incomplete data via the EM algorithm[END_REF] is a widely used algorithm for likelihood maximization of these kinds of models. It is based on the decomposition:

log p θ (Y) = E θ [log p θ (Z, Y) | Y ]-E θ [log p θ (Z | Y ) | Y].
Given an estimate θ (h) of the parameters, we need to compute some moments of p θ (h) (Z | Y) (E step), and then find a new estimate θ

(h+1) = argmax θ E θ (h) [log p θ (Z, Y) | Y ] (M step).
The parameters are given for the BM and OUsun in subsection 2.2.1. We assume here that the number of shifts K is fixed.

We only provide the main steps of the EM. Additional details can be found in Appendix 2.C. E step. As X is Gaussian, the law of the hidden variables Z knowing the observed variables Y is entirely defined by its expectation and variance-covariance matrix, and can be computed using classical formulas for Gaussian conditioning. The needed moments of Z | Y can also be computed using a procedure that is linear in the number of tips (called "Upward-downward") that takes advantage of the tree structure and bypasses inversion of the variance-covariance matrix (see [START_REF] Lartillot | A phylogenetic Kalman filter for ancestral trait reconstruction using molecular data[END_REF], for a similar algorithm).

Complete Likelihood Computation. Using the model described in Section 2.2.2, we can use the following decomposition of the complete likelihood:

p θ (X) = p θ (X 1 ) m+n j=2 p θ X j X pa(j)
Each term of this product is then known, and we easily get

E θ (h) [log p θ (Z, Y) | Y ].
M step. The difficulty comes here from the discrete variables (location of shifts on the branches). The maximization is exact for the BM but we only raise the objective function for the OUsun, hence computing a Generalized EM (GEM, see [START_REF] Dempster | Maximum likelihood from incomplete data via the EM algorithm[END_REF]. This stems from the independent increment nature of the BM: shifts only affect p θ X j X pa(j) on the branches where they occur and the maximization reduces to finding the K highest components of a vector, which has complexity O(n + K log(n)). By contrast, OUsun has autocorrelated increments: shifts affect p θ X j X pa(j) on the branches where they occur and on all subsequent branches. Maximization is therefore akin to segmentation on a tree, which has complexity O(n K ).

Initialization. Initialization is always a crucial step when using an EM algorithm. Here, we use the linear formulation (2.4) or (2.6), and initialize the vector of shifts using a Lasso regression. The selection strength α is initialized using pairs of tips likely to be in the same group.

Model Selection

Model Selection in the iid Case with Unknown Variance. Model selection in a linear regression setting has received a lot of attention over the last few years. In [START_REF] Baraud | Gaussian model selection with an unknown variance[END_REF], the authors developed a non-asymptotic method for model selection in the case where the errors are independent and identically distributed (iid), with an unknown variance. In the following, we first recall their main results, and then adapt it to our setting of non-independent errors.

We assume that we have the following model of independent observations:

Y = s + γE with E ∼ N (0, I n )
and we define a collection S = {S η , η ∈ M} of linear subspaces of R n that we call models, and that are indexed by a finite or countable set M. For each η ∈ M, we denote by ŝ η = Proj S η Y the orthogonal projection of Y on S η , that is a least-square estimator of s , and s η = Proj S η s the projection of s .

We extract from [START_REF] Baraud | Gaussian model selection with an unknown variance[END_REF] the following theorem, that bounds the risk of the selected estimator, and provides us with a non-asymptotic guarantee. It relies on a penalty depending on the EDkhi function, as defined below: Definition 2.4.1 (Baraud et al., 2009, Section 4, definitions 2 and 3). Let D, N be two positive integers, and X D , X N be two independent χ 2 random variables with degrees of freedom D and N respectively. For x ≤ 0, define

Dkhi[D, N , x] = 1 E [X D ] E X D -x X N N +
And define EDkhi[D, N , q] as the unique solution of the equation Dkhi[D, N , EDkhi[D, N , q]] = q (for 0 < q ≤ 1).

Theorem 2.4.1 [START_REF] Baraud | Gaussian model selection with an unknown variance[END_REF], Section 4, theorem 2 and corollary 1). In the setting defined above, let D η be the dimension of S η , and assume that N η = n -D η ≥ 2 for all η ∈ M. Let L = {L η } η∈M be some family of positive numbers such that Ω = η∈M (D η + 1)e -L η < +∞, and assume that, for A > 1,

pen(η) = pen A,L (η) = A N η N η -1 EDkhi[D η + 1, N η -1, e -L η ]
Take η as the minimizer of the criterion:

η = argmin η∈M Y -ŝ η 2 1 + pen(η) N η .
Then, assuming that N η ≥ 7 and max(L η , D η ) ≤ κn for any η ∈ M, with κ < 1, the following non-asymptotic bound holds:

E            s -ŝ η 2 γ 2            ≤ C(A, κ)         inf η∈M          s -s η 2 γ 2 + max(L η , D η )          + Ω        
The penalty used here ensures an oracle inequality: in expectation, the risk of the selected estimator is bounded by the risk of the best possible estimator of the collection of models, up to a multiplicative constant, and a residual term that depends on the dimension of the oracle model. Note that if the collection of models is poor, such an inequality has low value. We refer to [START_REF] Baraud | Gaussian model selection with an unknown variance[END_REF] for a more detailed discussion of this result.

Adaptation to the Tree-Structured Framework. We use the linear formulation described in 2.2.3, and assume that we are in the OUsun model (this procedure would also work for a BM with a deterministic root). Then, if V is a matrix of size n, with V ij = e -αd ij , ∀(i, j) ∈ 1 , n 2 , we have:

Y = TW(α)∆ + γE = s + γE E ∼ N (0, V)
We assume that α is fixed, so that the design matrix TW(α) and the structure matrix V are known and fixed. A model is defined here by the position of the shifts on the branches of the tree, i.e. by the non-zero components of ∆ (with the constraint that the first component, the root, is always included in the model). We denote by M = p-1 K=0 S P I K the set of allowed (parsimonious) allocations of shifts on branches (see Section 2.3.2), p being the maximum allowed dimension of a model. From proposition 2.3.6, for η ∈ M, the columns vectors T η are linearly independent, and the model S η = Span(T i , i ∈ η) is a linear sub-space of R n of dimension D η = η = K η + 1, K η being the number of shifts in model η. Note that as W(α) is diagonal invertible, it does not affect the definition of the linear subspaces. The set of models is then S = {S η , η ∈ M}.

We define the Mahalanobis norm associated to V -1 by: R V

-1 = R T V -1 R, ∀R ∈ R n .
The projection on S η according to the metric defined by V -1 is then:

ŝη = Proj V -1 S η (Y) = argmin a∈S η Y -a 2 V -1 and s η = Proj V -1 S η (s)
For a given number of shifts K, we define the best model with K shifts as the one maximizing the likelihood, or, equivalently, minimizing the least-square criterion for models with K shifts:

ŝK = argmin η∈S, | η | =K+1 Y -ŝη 2 V -1
The idea is then to slice the collection of models by the number of shifts K they employ. Thanks to the EM algorithm above, we are able to select the best model in such a set. The problem is then to select a reasonable number of shifts. To compensate the increase in the likelihood due to over-fitting, using the model selection procedure described above, we select K using the following penalized criterion:

Crit LS (K) = Y -ŝK 2 V -1 1 + pen(K) n -K -1 (2.10)
As noted in [START_REF] Baraud | Gaussian model selection with an unknown variance[END_REF], the previous criterion can equivalently be re-written in term of likelihood, as:

Crit LL (K) = n 2 log       Y -ŝK 2 V -1 n       + 1 2 pen (K) (2.11)
with pen (K) = n log 1 + pen(K)

n-K-1 . As we use maximum-likelihood estimators, we chose this formulation for the implementation. The following proposition then holds: Proposition 2.4.1 (Form of the Penalty and guaranties (α known)). Let L = {L K } K∈ 0,p-1 , with p ≤ min κn 2+log( 2)+log(n) , n -7 , the maximum dimension of a model, with κ < 1, and:

L K = log S P I K + 2 log(K + 2), ∀K ∈ 0 , p -1 (2.

12)

Let A > 1 and assume that

pen A,L (K) = A n -K -1 n -K -2 EDkhi[K, n -K -2, e -L K ]
Suppose that K is a minimizer of (2.10) or (2.11) with this penalty. Then:

E         s -ŝ K 2 V -1 γ 2         ≤ C(A, κ) inf η∈M          s -s η 2 V -1 γ 2 + (K η + 2) (3 + log(n))         
with C(A, κ) a constant depending on A and κ only.

The proof of this proposition can be found in Appendix 2.E. It relies on theorem 2.4.1, adapting it to our tree-structured observations. Remark 2.4.1. With this oracle inequality, we can see that we are missing the oracle by a log(n) term. This term is known to be unavoidable, see [START_REF] Baraud | Gaussian model selection with an unknown variance[END_REF] for further explanations.

Remark 2.4.2. Note that the chosen penalty may depend on the topology of the tree through the term S P I K (see Section 2.3.2). Remark 2.4.3. The penalty involves a constant A > 1, that needs to be chosen by the user. Following [START_REF] Baraud | Gaussian model selection with an unknown variance[END_REF] who tested a series of values, we fixed this constant to A = 1.1.

Simulations Studies

Simulations Scheme

We tested our algorithm on data simulated according to an OUsun, with varying parameters. The simulation scheme is inspired by the work of Uyeda & Harmon (2014). We first generated three distinct trees with, respectively, 64, 128 and 256 tips, using a pure birth process with birth rate λ = 0.1. The tree heights were scaled to one, and their topology and branch lengths were fixed for the rest of the simulations. We then used a star-like simulation study scheme, fixing a base scenario, and exploring the space of parameters one direction at the time. The base scenario was taken to be relatively "easy", with β 1 = 0 (this parameter was fixed for the rest of the simulations), α b = 3 (i.e The problem was all the more difficult that γ 2 , t 1/2 or K were large.

For each simulation, the K shifts were generated in the following way. First, their values were drawn according to a mixture of two Gaussian distributions, N (4, 1) and N (-4, 1), in equal proportions. The mixture was chosen to avoid too many shifts of small amplitude. Then, their positions were chosen to be balanced: we first divided the tree in K segments of equal heights, and then randomly drew in each segment an edge where to place a shift. We only kept parsimonious allocations.

Each of these configurations was repeated 200 times, leading to 16200 simulated data sets. An instance of a tree with the generated data is plotted in Figure 2.5.1.

Inference Procedures

For each generated dataset, we ran our EM procedure with fixed values of K ∈ 0 , √ n , n being the number of tips of the tree. Remark that for n = 64, √ n = 8, and we have no hope of detecting true values of K above 8 (see remark 2.3.1 for an explanation of the bound in √ n). The number of shifts K s was chosen thanks to our penalized criterion, and we kept inferences corresponding to both K s and the true number K t .

We ran two sets of estimations for α either known or estimated. The computations took respectively 66 and 570 (cumulated) days of CPU time. This amounts to a mean computational time of around 6 minutes (367 seconds) for one estimation when α is fixed, and 52 minutes (3137 seconds) when α is estimated, with large differences between easy and difficult scenarios.

Scores Used

The convergence of the EM algorithm was assessed through the comparison of the likelihood of the true and estimated parameters, and the comparison of mean number of EM steps needed when α is fixed or estimated. The quality of the estimates of β 1 , t 1/2 and γ 2 was assessed using the coefficient of variation. The model selection procedure was evaluated by comparing the true number of shifts with the estimated one, which should be lower. We do not expect to find the exact number as some shifts, which are too small or too close of the tips, cannot be detected. To evaluate the quality of the clustering of the tips, the only quantity we can observe, we used the Adjusted Rand Index (ARI, [START_REF] Hubert | Comparing partitions[END_REF] between the true clustering of the tips, and the one induced by the estimated shifts. The ARI is proportional to the number of concordant pairs in two clusterings and has maximum value of 1 (for identical clusterings) and expected value of 0 (for random clusterings). Note that this score is conservative as shifts of small intensity, which are left aside by our model selection procedure, produce "artificial" groups that cannot be reconstructed.

Results

The selection strength is notoriously difficult to estimate, with large ranges of values giving similar behaviors (see [START_REF] Thomas | Bias and measurement error in comparative analyses: a case study with the Ornstein Uhlenbeck model[END_REF]. We hence first analyse the impact of estimating α on our estimations, showing that the main behavior of the algorithm stays the same. Then, we study the shifts reconstruction procedure.

Convergence and Likelihood. For α known, all estimations converged in less than 49 iterations, with a median number of 13 iterations. For α estimated, the number of iterations increased greatly, with a median of 69, and a fraction of estimations (around to its true value (blue) or estimated (red), on a tree with 128 taxa. For better legibility, the y-axis of these two rows were re-scaled, omitting some outliers (respectively, for t 1/2 and γ 2 , 0.82% and 0.46% of points are omitted). The whisker of the first box for t 1/2 goes up to 7.5.

t 1 2 = ln(2) α γ 2 K (t ^1 2 - t 1 2 ) t 1 2 (γ ^2 -γ 2

3.2%

) that reached the maximum allowed number (fixed at 1000 iterations) without converging. Unsurprisingly, the more difficult the problem, the more iterations were needed. The log-likelihoods of the estimated parameters are close to the true ones, even when α is estimated (see supplementary Figure 2.F.3 in Appendix 2.F, first row).

Estimation of Continuous Parameters. In this regime, the model is "over-confident", as it finds a higher selection strength than the real one and therefore a smaller variance (second row of Figure 2.5.2). For smaller and bigger trees, the estimators behave in the same way, but with degraded or improved values, as expected. We also note that taking the true number of shifts instead of the estimated one slightly degrades our estimation of these parameters (see supplementary Figure 2.F.3 in Appendix 2.F). The estimation of β 1 is not affected by the knowledge of α or K (see Figure 2.5.3, first row), and only has an increased variance for more difficult configurations. In the remainder, we only show results obtained for estimated α as estimating α does not impact ARI, K and β0 (see supplementary Figure 2.F.4 in Appendix 2.F).

Estimation of the Number of Shifts. The way shifts were drawn ensures that they are not too small in average, and that they are located all along the tree. Still, some shifts have a very small influence on the data, and are hence hard to detect (see Figure 2.5.1).

The selection model procedure almost always under-estimates the number of shifts, ex- cept in very favorable cases (Figure 2.5.3, second row). This behavior is nonetheless expected, as allowing more shifts does not guarantee that the right shifts will be found (see supplementary Figures 2.F.1 and 2.F.2 in Appendix 2.F).

t 1 2 = ln(2) α γ 2 K β ^1 -β 1 K select ARI 0.
Clustering of the Tips. The ARI tends to be degraded for small values of α or high variance, but remains positive (Figure 2.5.3, third row). When only one shift occurs, the ARI is very unstable, but for any other value of K, it stays quite high. Finally, knowing the number of shifts does not improve the ARI.

Equivalent Solutions. When α and K are both estimated, only 5.1% of the configurations have 2 or more equivalent solutions. One inferred configuration with three equivalent solutions is presented Figure 2.5.1.

Comparison with bayou. As mentioned above, our simulation scheme, although not completely equivalent to the scheme used in Uyeda & Harmon (2014), is very similar, so that we can compare our results with theirs. The main differences lies in the facts that we took a grid on γ 2 = σ 2 /2α instead of σ 2 , and that we took shifts with higher intensities, making the detection of shifts easier. We can see that we get the same qualitative behaviors for our estimators, with the selection strength α over or under estimated, respectively, in small or large values regions. The main difference lies in the estimation of the number of shifts. Maybe because of the priors they used (K ∼ Conditional Poisson(λ = 9, K max = n/2)), they tend to estimate similar numbers of shifts (centered on 9) for any set of parameters. In particular, while our method seems to be quite good at detecting situations where there are no shifts at all, theirs seems unable to catch these kind of configurations, despite the fact that their shifts have low intensity, leading to a possible over-fitting of the data.

Overall, the behavior of the algorithm is quite satisfying. Our model selection procedure avoids over-fitting, while recovering the correct clustering structure of the data. It furthermore allows for a reasonable estimation of the continuous parameters, except for α which is notoriously difficult to estimate.

Description of the Dataset

Extant species of the order Testudines, or Chelonii, are turtles and tortoises, living all across the globe, and exhibiting a wide variation in body size, from the small desert speckled tortoise (Homopus signatus, 10 cm), to the large marine leatherback sea turtle (Dermochelys coriacea, 244 cm). In order to test the hypothesis of island and marine gigantism, that could explain the extreme variations observed, Jaffe et al. ( 2011) compiled a dataset containing a measure of the carapace length for 226 species, along with a phylogenetic tree of theses species, spanning 210 million years (my) (see Figure 2.6.1). They assigned each species to one of four habitats: mainland-terrestrial, freshwater, marine and island-terrestrial. Then, testing several fixed regimes allocations on the branches of the tree using the method described in [START_REF] Butler | Phylogenetic Comparative Analysis: A Modeling Approach for Adaptive Evolution[END_REF], they found the best support in favor of a "OU2" model that assigned one regime to each habitat. Following Uyeda & Harmon (2014), we will refer to this model as the "OU habitat " model. Note that this model is ambiguously defined, as it requires to assign a habitat to each ancestral species. Using proposition 2.3.3, we found that there were 48 equivalent parsimonious ways of doing so that respect the habitats observed at the tips of the tree. One of these habitat reconstruction is presented Figure 2.6.1.

Method

We used the version of the dataset embedded in the package geiger [START_REF] Pennell | geiger v2.0: an expanded suite of methods for fitting macroevolutionary models to phylogenetic trees[END_REF], that contains a phylogenetic tree and a vector of log-carapaces lengths. The corresponding habitats are reported in the Appendix of [START_REF] Jaffe | The evolution of island gigantism and body size variation in tortoises and turtles[END_REF]. We ran our algorithm with a number of shifts going from 0 to 20. Rather than estimating α directly within the EM as we did for the simulations, we took α varying on a grid, taking 6 values regularly spaced between 0.01 and 0.1, but fixed for each estimation. We found that this approach, although computationally more intensive, gave better results. These 6 × 20 = 120 estimations took around 2 hours of CPU time. For each number of shifts, going again from 0 to 20, we kept the solution with the maximal likelihood, and we applied the model selection criterion to them. This method gave a solution with 5 shifts, and a selection strength of 0.06 (i.e. 5.5 % of the total height of the tree). Using a finer grid for α gives highly similar results, allocating shifts to the same edges. These last estimations are given below.

Results

Our method selected a solution with 5 shifts, a rather strong selection strength (t 1/2 = 5.4% of the tree height), and a rather low root variance (γ 2 = 0.22, see table 2.1, first column). Two of those shifts are closely related to the habitats defined in Jaffe et al. (2011) (see Figure 2.6.1). The ancestral optimal value, that applies here to two clades of freshwater turtles, is estimated to be around 38 cm. A small decrease in size for a large number of mainland and freshwater turtles is found (optimal value 24 cm). Marine turtles (super-family Chelonioidea) are found to have an increased carapace length (with an optimal value of 130 cm), as well as a clade containing soft-shell tortes (family Trionychidae, optimal size 110 cm), and a clade containing almost all island tortoises, including several sub-species of Galápagos tortoises (Geochelone nigra). Only the Ryukyu black-breasted leaf turtle (Geoemyda japonica), endemic to the Ryukyu Islands in Japan, and distant on the phylogenetic tree, is not included in this group. Note that the group also contains some mainland tortoises of the genus Geochelone, that are closely related to Galápagos tortoises. This is typical of our method: it constructs groups that are both phenotypically and phylogenetically coherent. Finally, one species is found to have its own group, the black-knobbed map turtle (Graptemys nigrinoda), with a very low optimal value of 1.4 × 10 -20 cm, for a measured trait of 15 cm. The fact that the shift has a very high negative value (-49 in log scale) is just an artifact due to the actualization factor on a very small branch (0.18 my, for an inferred phylogenetic half-life of 11 my). This is a rather unexpected choice of shift location. When considering the linear model as transformed by the cholesky matrix of the variance to get independent errors (as in the proof of proposition 2.4.1), we find a leverage of 0.94, indicating that this species trait behaves in the transformed space as an outsider.

Comparison with other methods

In order to compare our results to previously published ones, we reproduced some of the analysis already conducted on this dataset. We hence ran the methods described in [START_REF] Jaffe | The evolution of island gigantism and body size variation in tortoises and turtles[END_REF] The shifts allocated on the tree by methods bayou, SURFACE and OUshifts are presented on Supplementary Figure 2.F.5 (Appendix 2.F). We can see that 3 among the most strongly supported shifts in the posterior distribution given by bayou, as well as some among the oldest shifts found by SURFACE and OUshifts are similar to the ones found by our method. The bayou method finds equal support for many shifts, all over the tree, and the median of the posterior distribution is 17 shifts, which is pretty close to the mode of the prior put on the number of shifts (15). The SURFACE and OUshifts methods select respectively 33 and 8 shifts, including many on pendant edges, that are not easily interpretable. The backward step of SURFACE allowed to merge the regimes found for marine turtles and soft-shell tortoises that our method found to have very similar optimal values. The results of the five methods are summarized Table 2.1. Note that these models are not nested, due to the status assigned to the root, and to the possible convergences.

Compared to step-wise heuristics, our integrated maximum likelihood based approach allows us to have a more "global" view of the tree, and hence to select a solution that accounts better for the global structure of the trait distribution. Thanks to its rigorous model selection procedure, our model seems to report significant shifts only, that are more easily interpretable than the solutions found by other methods, and that do not rely on any chosen prior.

Habitat

(i 1 , • • • , i L i ), L i ≥ 2
, and assume that the tips are colored according to the application d ∈ (C K ) n . We denote by T i the sub-tree rooted at node i, and by A T i (d) the set of parsimonious shifts allocations on T i that produce a coloring of the tips compatible with d. At the root,

A T 1 (d) = A T (d) = φ -1 (d).
For k ∈ C K , S i (k) is the cost of starting from node i with color k, i.e. the minimal number of shifts needed to get the right coloring of the tips of T i , when starting with color k.

S tot i = min k∈C K S i (k) is the minimal cost of subtree T i , i.e. the number of shifts of a parsimonious coloring. L i = argmin k∈C K S i (k) is the set of colors root i can take in a parsimonious coloring of sub-tree T i .

For k ∈ C K , B k T i
is the set of colorings of T i that respect the colors at the tips, have S i (k) shift, and start with color k.

For K ⊂ C K , B K T i = k∈K B k T i . Hence, A T i (d) = B L i T i
, and the computation of

A T i (d) only requires the computation of S i (k) and B k T i for any k ∈ C K . For (p 1 , • • • , p L i ) ∈ (C K ) L i , and (B 1 , • • • , B L i ) ∈ B p 1 T i 1 × • • • × B p L i T i L i we define, for k ∈ C K , the concatenation B = k L i l=1 B l , B ∈ B k T i
, by:

       B(i) = k B(j) = B l (j) if i ∈ T i l .
As the sub-trees T i l , l ∈ 1 , L i do not overlap, this application is correctly defined on the nodes of T i .

Using these definitions, we can state the following recursion formula:

Proposition 2.A.1 (Enumeration Recursion Formula). Let k ∈ C K , and i ∈ 1 , m + n . If i is a tip of the tree, then

S i (k) =        0 if d(i) = k +∞ otherwise B k T i =        {i → k} if d(i) = k ∅ otherwise If i is a node of tree T with L i daughter nodes (i 1 , • • • , i L i ), L i ≥ 2,
and assuming that S i l (k) and B k T i l are known for any l ∈ 1 , L i and k ∈ C K , define, for l ∈ 1 , L i :

K l k = argmin 1≤p≤K S i l (p) + I{p k}
As these sets are not empty, let (p 1 , . . .

p L i ) ∈ K 1 k × . . . × K L i k . Then S i (k) = L i l=1 S i l (p l ) + I{p l k} and B k T i =          L i k l=1 B l : ∀l ∈ 1 , L i , B l ∈ B K l k T i l         
Proof. The actualization of S i (k) is the same as in the Sankoff algorithm [START_REF] Sankoff | Minimal Mutation Trees of Sequences[END_REF]. The set B k T i is then obtained by enumerating all the possible ways of concatenating

children sets B K l k T i l
, each of which is the ensemble of solutions for the sub-tree T i l that realize the minimal number of shifts when starting in state k.

Remarking that T i (k) = B k T i
, proposition 2.3.3 of the main text follows immediately.

2.B A Vandermonde Like Identity

Proposition 2.B.1. Let (n, n ) ∈ N and K ∈ N. With the standard convention that n k = 0 if n < k, n + n -K K = K k=0 n -k k n -K + k K -k + K-1 k=0 (n -1) -k k (n -1) -(K -1) + k (K -1) -k
which can be rewritten in a more symmetric way as:

n + n -K K = k,k ≥0 k+k =K n -k k n -k k + k,k ≥0 k+k =K-1 (n -1) -k k (n -1) -k k (2.13)
Similarly,

n + n + 1 -K K = K k=0 n -k k n -K + k K -k + K-1 k=0 (n -1) -k k n -(K -1) + k (K -1) -k + n -k k (n -1) -(K -1) + k (K -1) -k
which can be rewritten in a more symmetric way as:

n + n + 1 -K K = k,k ≥0 k+k =K n -k k n -k k + k,k ≥0 k+k =K-1 (n -1) -k k n -k k + n -k k (n -1) -k k (2.14)
Note that Eq (2.13) generalizes in some way the Vandermonde identity which states

n + n K = K k=0 n k n K -k (2.15)
Although several proofs of the Vandermonde identity are known (geometric, algebraic and combinatorial), we only provide a geometric proof of this Vandermonde-like identity.

Consider a grid of size (n + n ) × K. We are interested in grid-valued paths that can move either by (1, 0) or by (2,1). In other words, if the k th position of a path is (x k , y k ), then its next position (x k+1 , y k+1 ) is either (x k + 1, y k ) or (x k + 2, y k + 1). We are interested in paths starting at (0, 0) and ending at (n + n , K). Such a path consists of K moves of type (2, 1) and n + n -2K moves of type (1, 0) and is uniquely determined by the positions of the moves of the former type. There are

n n K k k k + k = K k k k + k = K -1 A B n -1 n -1
n+n -2K+K K = n+n -K K
distinct positions and therefore as many such paths. We now sort the paths according to the value i they take when either reaching the line x = n or reaching the line x = n + 1 without reaching the line x = n first. We refer to the latter paths as crossing the line x = n. Note that this sorting induces a partition of all paths (see Figure 2

.B.1)

A path reaching x = n at position i uniquely gives rise to two paths: one from (0, 0) to (n, i) and one from (n, i) to (n + n , K) or equivalently from 0 to (n , Ki). There are n-i i different paths of the first kind and n -K-i K-i of the second. There are therefore

n-i i n -K+i K-i
paths that pass through (n, i). A path crossing the line x = n and reaching the line x = n + 1 at i must do so with a last move of type (2, 1). It therefore uniquely defines a path from (0, 0) to (n -1, i -1) and a path from

(n + 1, i) to (n + n , K), or equivalently from (0, 0) to (n -1, K -i). There are therefore n-i i-1 n -1-K+i K-i
paths that cross the line x = n and pass through (n + 1, i). Putting everything together, we get:

n + n -K K = K i=0 n -i i n -K + i K -i + K i=0 n -i i -1 n -1 -K + i K -i = K i=0 n -i i n -K + i K -i + K-1 i=0 (n -1) -i i (n -1) -(K -1) + i (K -1) -i
which is exactly Eq. ( 2.13).

To prove Eq. ( 2.14), we start from a grid of size (n+n +1)×K and are again interested in the paths starting from the bottom left corner and ending in the upper right corner using only (2, 1) and (1, 0) moves. These paths have exactly K moves of type (2, 1) and there are n+n +1-K K of them. This time, we partition paths upon the move observed between x = n and x = (n + 1).

n n K k k k + k = K k k k + k = K -1 A B 1 n n -1 k k k + k = K -1 C n -1 n
The move can be (see also Figure 2.B.2):

(1, 0), in which case k (resp. k ) moves of type (2, 1) are used in the interval

[1, n] (resp. [n + 1, n + n 1]) such that k + k = K;
(2, 1) starting from x = n and therefore ending at (2,1) has already been consumed);

x = n + 2, in which case k (resp. k ) moves of type (2, 1) are used in the interval [1, n] (resp. [n + 2, n + n 1]) such that k + k = K -1 (one move
(2, 1) ending at x = n+1 and therefore starting from (2,1) has already been consumed);

x = n-1 in which case k (resp. k ) moves of type (2, 1) are used in the interval [1, n -1] (resp. [n + 1, n + n 1]) such that k + k = K -1 (one move
Wrapping everything together and using the same arguments as before, we get Eq. (2.14).

Shift Detection for Univariate Processes

2.C Technical Details of the EM

2.C.1 E Step

Given a set of parameters θ (h) , we have:

X = (Z, Y) ∼ N       m (h) =       m (h) Z m (h) Y       , Σ (h) =       Σ (h) ZZ Σ (h) YZ Σ (h) ZY Σ (h) YY             hence: Z | Y ∼ N m (h) Z|Y = m (h) Z + Σ (h) ZY (Σ (h) YY ) -1 (Y -m (h) Y ), Σ Z|Y = Σ (h) ZZ -Σ (h) ZY (Σ (h) YY ) -1 Σ (h) YZ Remark 2.C.1.
We can see that this approach forces us to invert

Σ (h)
YY , a n × n matrix, which is a costly operation, of order O(n 3 ). It also computes the complete matrix Σ Z|Y whereas we only need a linear number of its coefficients: conditional variances and covariances of the form Cov Z i ; Z pa(i) Y . Due to the tree structure and to the Gaussian nature of the processes studied, it is possible to compute all the quantities needed in a linear time, using a "forward-backward"-like algorithm (here, "upward-downward", see [START_REF] Lartillot | A phylogenetic Kalman filter for ancestral trait reconstruction using molecular data[END_REF] for a similar algorithm.). The upward step is similar to the pruning algorithm described in Felsenstein (2004, chap. 23). See also Ho & Ané (2013a) for an algorithm linear in the number of iterations.

2.C.2 Complete Likelihood Computation

Using the incomplete data model described in section 2.2.2, we can write:

p θ (X) = p θ (X 1 ) m+n j=2 p θ X j X pa(j)
Taking the expectation, we get for the BM:

-2E [ log p θ (X) | Y ] = A + log γ 2 + 1 γ 2 Var [ X 1 | Y] + (E [ X 1 | Y] -µ) 2 + (m + n -1) log σ 2 + 1 σ 2 m+n j=2 -1 j Var X j -X pa(j) Y + 1 σ 2 m+n j=2 C BM j (∆) (2.16)
and, for the OUsun:

-2E [ log p θ (X) | Y ] = B + m+n j=2 log c j (α) + 1 γ 2 Var [ X 1 | Y] + (m + n) log γ 2 + 1 γ 2 m+n j=2 c j (α) -1 Var X j -X pa(j) e j Y + 1 γ 2 (E [ X 1 | Y ] -β 0 ) 2 + 1 γ 2 m+n j=2 C OU j (α, ∆) (2.17)
where A and B are constants, and for each node j, j ∈ 2 , m+n , we define an actualization factor c j (α) = 1e j (α) 2 , with e j (α) = e -α j , and C BM j and C OU j are costs associated with branch b j :

                 C BM j (∆) = 1 j E X j Y -E X pa(j) Y -∆ i 2 C OU j (α, ∆) = 1 c j (α)       E X j Y -e j E X pa(j) Y -β j 1 -e j       2 2.C.3 M step Assuming that p θ (h) ( Z | Y) is known, we need to compute θ (h+1) by maximizing E θ (h) [log p θ (Z, Y) | Y ].
We have to deal with parameters of different nature, discrete or continuous. For a given vector ∆ (h+1) of K non-zero shifts, we can exhibit closed formulas for µ (h+1) , σ (h+1) and γ (h+1) , for the BM:

                   µ (h+1) = E (h) [Z 1 | Y] γ 2(h+1) = Var (h) [Z 1 | Y] σ 2(h+1) = 1 m + n -1         m+n j=2 -1 j Var (h) X j -X pa(j) | Y + C BM j ∆ (h+1)        
and, for the OUsun:

(m + n)γ 2(h+1) = Var (h) [X 1 | Y] + m+n j=2 c j (α) -1 Var (h) X j -X pa(j) e -α j | Y + E (h) [ X 1 | Y] -β (h+1) 0 2 + m+n j=2 C OU j α (h) , ∆ (h+1)
There is no such closed formula for α. In the implementation we propose, this parameter is actualized after all the others, by doing a numerical maximization of the objective function.

Finally, the vector ∆ (h+1) of K non-zero shifts can be chosen in an optimal way for the BM thanks to a simple algorithm explained below. In the OUsun case, we can only increase the objective function, and not maximize it. In that case, we hence use a Generalized EM algorithm (GEM, see [START_REF] Dempster | Maximum likelihood from incomplete data via the EM algorithm[END_REF].

Optimal Shift Location for the BM. We want to minimize the sum of costs:

C BM (∆) = m+n j=2 C BM j (∆)
Each cost is associated to a branch b j , j ∈ 2 , m + n , and, when the sum is minimal, C BM j (∆) can only take two values:

       CBM j = -1 j E (h) X j Y -E (h) X pa(j) Y 2 if no shift on branch b j 0 if one shift on branch b j
The sum can hence be minimized in the following way:

1. Compute CBM j for all j ∈ 2 , m + n . 2. Find the K highest costs (j 1 , • • • , j K ) ∈ 2 , m + n K . 3. Set ∆ (h+1) j k = E (h) X j k Y -E (h) X pa(j k ) Y for all k ∈ 1 , K , and
∆ (h+1) j = 0 if j {j 1 , • • • , j K }.
This exact and fast algorithm works for the BM because all the costs are independent. Note that it would work for any Levy Process without memory, such as those proposed in [START_REF] Landis | Phylogenetic analysis using Lévy processes: Finding jumps in the evolution of continuous traits[END_REF] to model evolution of quantitative traits.

GM

Step for Shifts Locations for the OU. With α (h) fixed, we want to minimize the sum of costs:

C OU (α (h) , ∆) = E (h) [ X 1 | Y] -β 0 2 + m+n j=2 C OU j (α (h) , ∆)
The previous algorithm does not work, because the costs are not independent. Solving the problem exactly would require to visit all the possible configurations, and the complexity would be too high, of order

O m+n K = O(n K ).
To reduce the execution time of the algorithm, we use heuristics to lower, if not minimize, the sum of costs. We use the following formulation:

C OU (α (h) , ∆) = F (h) -A (h) U∆ 2
where U the complete tree matrix given in subsection 2.2.3, A (h) a diagonal matrix depending on α (h) A (h) = Diag 1, 1-e -α (h) j 1+e -α (h) j

; 2 ≤ j ≤ m + n , and F (h) a vector of expectations, with

F (h) 1 = E (h) [ X 1 | Y], and, for 2 ≤ j ≤ m + n, F (h) j = 1 -e -2α (h) j -1/2 E (h) X j Y -E (h) X pa(j) Y e -α (h) j
We can then use a Lasso algorithm to impose sparsity constraints on ∆. If ∆ -1 is the vector of shifts without the initial value (intercept), then a Lasso estimator is given by, for λ ≥ 0:

∆λ = argmin ∆ F (h) -A (h) U∆ 2 + λ |∆ -1 | 1
The estimated vectors ∆λ have a support that is sparser when λ becomes higher. One then only need to find the right penalty factor λ that ensure that the support has exactly K non zero coordinates, plus the initial value. We ensure that the K shifts are allocated in a parsimonious way by checking their linear independence, using proposition 2.3.6. An other method is to take the previous solution ∆ (h) , and test all the configurations where only one shift has moved, and take the best one. In both methods, one also has to ensure that the objective function is increased by the new choice of shifts, so that the GEM algorithm works correctly. This step is generally the longest one in one iteration of the EM.

2.C.4 Initialization

Initialization is always a crucial step when using an EM algorithm. The vector of shifts ∆ is initialized thanks to a Lasso procedure. To do that, we use the linear formulation (2.4) or (2.6) of the main text, and we calibrate the penalty so that the initialization vector has a non zero first coordinate (initial value), and K other non-zero coordinates. The variance-covariance matrix is initialized with defaults parameters, and is taken into account thanks to a Cholesky decomposition.

We also initialize the selection strength α. We use the following property: if Y i and Y j are two tips in the same group, then, under an OUsun, E (Y i -Y j ) 2 = 2γ 2 (1e -αd ij ).

Using regression techniques, we can get an initial estimation of α and γ 2 from all these couples. In practice, we first initialize the position of the shifts, and then use only pairs of tips from the same estimated group. Then, as the groups are only approximated, some of the selected pairs (Y i , Y j ) might not share the same expectation, and we use a robust regression to get more accurate initial estimates.

2.D Optimal Shift Location with Fixed Root

The algorithm for optimal shift location we described above (see Section 2.C.3) actually only works for a BM with a random root. When the inference is done conditionally to the root value, then an extra step is needed. Indeed, the objective function is then:

-2E [log p θ (X) | Y, X 1 ] = A + (m + n -1) log σ 2 + 1 σ 2 m+n j=2 C BM j (τ, δ) + 1 σ 2 m+n j=2 -1 j Var X j -X pa(j) Y, X 1 , with C BM j (∆) = 1 j E X j Y, X 1 -E X pa(j) Y, X 1 -∆ j 2
And, for the optimal shift location, we want to minimize the sum of costs:

C BM (∆) = m+n j=2 C BM j (∆).
Each cost is associated to a branch b j , j ∈ 2 , m + n . Denote by m j = E X j Y, X 1 for any j ≥ 2. As previously, when the sum is minimal, for a node j that is not a direct descendant of the root, a cost can only take two values:

       CBM j (∆) = -1 j m j -m pa(j) 2 if no shift on branch b j 0 if one shift on branch b j
The problem arise for branches that are descendants of the root, that we denote by (r 1 , . . . , r l ). Indeed, their costs are, for 1 ≤ a ≤ l:

C BM r a (∆) = 1 r a m r a -µ -∆ r a 2
and the unknown parameter µ appears in several costs, so that the joint maximization in µ and ∆ is not straightforward. First, let's assume that the root has only two descendants. Then, we can solve the problem by formally "un-rooting" the tree, replacing the two root branches by a single branch, with a new ad-hoc cost. Indeed, if there are no shifts on these two root branches, we get:

μ = -1 r 1 m r 1 + -1 r 2 m r 2 -1 r 1 + -1 r 2 and CBM r 1,2 = CBM r 1 + CBM r 2 = ( r 1 + r 2 ) -1 (m r 2 -m r 1 ) 2 .
Then, we can use the previously described algorithm to spot the shifts, treating this fictive branch with its new cost as all the others. If a shift has to be placed on it, then it will cancel the cost of the fictive branch. Its position is not identifiable, and we can choose to put it on branch r 1 (then μ = m r 2 and δ = m r 1m r 2 ), or on r 2 (then μ = m r 1 and δ = m r 2m r 3 ) indistinctly. Now, let's assume that the root has three or more descendants. The trick used above cannot be adapted, and we need to resort to a heuristic to minimize the sum of costs. Instead of optimizing it jointly in ∆ and µ, we do a two-steps minimization:

1. Fix µ to its previous value µ (h-1) , and optimize the sum in the position and values ∆ (h) of the shifts.

2. Fix ∆ (h) , and optimize the costs in µ, taking:

µ (h) = 1≤a≤l -1 r a (m (h) r a -∆ (h) r a ) 1≤a≤l -1 r a .
Because this optimization happens inside the EM loop, it is sufficient to just increase the objective function (so that we get a Generalized EM).

2.E Proof of Proposition 2.4.1 for Model Selection

We prove the proposition using the linear formulation s+γE, with E ∼ N (0, V), as derived in the main text for the OUsun (with s = TW(α)∆, γ 2 = σ 2 /(2α), and V ij = e -αd ij , see Formula (2.5)). Note that this framework also holds for the BM with a fixed root (with s = T∆, γ = σ , and V ij = t ij , see Formula (2.4)).

We first handle the case where there are no correlations (V diagonal), and then use a Cholesky decomposition to handle the general case. Note that the case V diagonal can be seen as the limit of the OUsun when α = +∞, or as a BM on a star tree.

Case V diagonal In the iid case, we just need to check the conditions of theorem 2.4.1. This paragraph is highly inspired by the derivation of the bound for the detection of non-zero mean components exposed in [START_REF] Baraud | Gaussian model selection with an unknown variance[END_REF] (sub-section 5.2). Assume that D η = K η +1 ≤ p ≤ n -7 for all η ∈ M. The estimator is defined by ŝ K , with:

K = argmin 0≤K≤p-1 Y -ŝK 2 V -1 1 + pen A,L (K) n -K -1
From the definition of ŝK , and as the penalty depends on the model only through its number of shifts, we get that ŝ K = ŝ η the minimizer of the criterion of theorem 2.4.1 (with N η = n -D η = n -K η -1). We then have:

Ω = η∈M (D η + 1)e -L η = p-1 K=0 S P I K (K + 2)e -L K
With the weights L K defined in Equation ( 2.12) of the proposition, we get:

Ω = p-1 K=0 1 K + 2 ≤ log(p) ≤ log(n)
As: 2)+log(n) , n -7 , then max(L η , D η ) ≤ κn for any η ∈ M, and we get the announced bound from the second proposition of theorem 2.4.1.

L K ≤ log n + m -1 K + 2 log(K + 2) ≤ K log(n + m -1) + 2 log(K + 2) ≤ K log(2n -2) + 2(K + 1) ≤ (K + 1)(2 + log(2) + log(n)) ≤ p(2 + log(2) + log(n)) if p ≤ min κn 2+log(
Case V not diagonal Using a Cholesky decomposition, we can find a lower triangular matrix L such that V = LL T . Then, denoting Y = L -1 Y, s = L -1 s, and E = L -1 E, we have Y = s + γE , with E ∼ N (0, I n ), and we can apply theorem 2.4.1 as above. As we changed the metric, the estimators are projections on the linear spaces S η = L -1 S η for η ∈ M, and we have:

ŝ η = Proj S η Y = argmin a ∈S η Y -a 2 = argmin a ∈S η L -1 Y -L -1 La 2 = argmin a ∈S η Y -La 2 V -1 = L -1 argmin a∈S η Y -a 2 V -1 = L -1 ŝη So s -ŝ η 2 V -1 = s -ŝ η 2 and Y -ŝη 2 V -1 = Y -ŝ η 2
, and, as the form of the penalty does not depend on V , by minimizing:

Crit LS (K) = Y -ŝ K 2 1 + pen A,L (K) n -K -1 = Y -ŝK 2 V -1 1 + pen A,L (K) n -K -1
we get the announced bound on E

s-ŝ K 2 V -1 γ 2 = E        s -ŝ K 2 γ 2        .

2.F Supplementary Figures

2.F.1 Simulation Study: Sensitivity and False Positive Rate

Definition of the Scores. We denote by T P the number of True Positives, i.e. the predicted edges on which a shift actually occurred, and FP the number of False Positives. The sensitivity T P K t is the proportion of well predicted shifts among all shifts to be predicted, and the False Positive Rate (FPR) FP n+m-K t is the proportion of false positive among all edges with no shifts.

Note that here, due to the possible lack of identifiability, the position of the shifts on the tree is not well defined, as a shift can be on a particular edge for one of the equivalent solutions, but not on the others (see Section 2.3.1). These two scores are hence ill defined for our problem. To avoid such problems, we restrict ourselves to the 92% of unambiguous configurations that occurred during the simulations.

Interpretation of Results. Figure 2.F.1 shows that the FPR are systematically worse when using the true number of shifts, indicating that the additional shifts found when compared to the selected number are misplaced. The FPR remains very low, as only a small number of shifts is to be found. Unsurprisingly, the Sensitivity is on the contrary improved when taking the real number of shifts, as shown Figure 2.F.2. In addition, the sensitivity is highly degraded when α is small or γ 2 is high, but does not exhibit a clear tendency in the real number of shifts, and the knowledge of the true value of α does not seem to matter.

2.F.2 Simulation Study: Complementary Analysis

To complete the analysis conducted in the main text, Figure 2.F.3 presents the variations of the log-likelihood, phylogenetic half-life, and root variance when α is estimated, and the number of shifts is known or estimated. We can see here that the likelihood is slightly higher when the number of shifts is fixed, which is coherent with the behavior of our model selection procedure, that tends to under-estimate the true number of shifts (see Figure 2.5.3 of the main text). We also note that knowing the true number of shifts has not a great influence on the estimation of α and γ, making the later worse, if anything.

Figure 2.F.4 shows the variations of the estimations of β 1 , the number of shifts and the ARI when the number of shifts is estimated, and α is fixed or estimated. This confirms our earlier statement, that not knowing α with precision does not have a great impact on the model selection procedure (see also [START_REF] Cressler | Detecting adaptive evolution in phylogenetic comparative analysis using the ornstein-uhlenbeck model[END_REF].

2.F.3 Chelonia Dataset: Comparison of Inferred Shift Locations

On Figure 2.F.5, we present and compare the shift locations found by our method, and methods bayou and SURFACE. The differences found are explored deeper in the main text (Section 2.6.4).

Details on the Methods. In this paragraph, we give more details on the 4 already existing methods that we compared to ours in the dataset. We first fitted an OU habitat model with fixed regimes as in [START_REF] Jaffe | The evolution of island gigantism and body size variation in tortoises and turtles[END_REF], using the R package OUwie [START_REF] Beaulieu | Modeling stabilizing selection: Expanding the Ornstein-Uhlenbeck model of adaptive evolution[END_REF]. We tested all of the 48 possible ways of allocating internal nodes, and took the solution with the highest likelihood. Using the package bayou (Uyeda & Harmon, 2014), we reproduced the Bayesian analysis of the data, using two independent chains of 500000 generations each, discarding the first 150000 generations as burning. We assigned the priors that were used in the original study on the parameters, namely: P (α) ∼ LogNormal(ln µ = -5, ln σ = 2.5), P (σ 2 ) ∼ LogNormal(ln µ = 0, ln σ = 2), P (β i ) ∼ Normal(µ = 3.5, σ = 1.5), P (K) ∼ Conditional Poisson(λ = 15, K max = 113). The computations took around 2.3 hours of CPU time. We also ran the stepwise-AIC method For better legibility, strips with t 1/2 , γ 2 and β 1 on these two figures were re-scaled, omitting some outliers (respectively, 0.21%, 0.27% and 0.27% of points are omitted).

The whisker of the first box for t 1/2 goes up to 7.5.

SURFACE, that relies on a forward-backward procedure. This took around 11 hours of CPU time. Finally, we ran the function OUshifts from the package phylolm, that uses a modified BIC criterion and a heuristic stepwise procedure to detect shifts [START_REF] Ho | Intrinsic inference difficulties for trait evolution with Ornstein-Uhlenbeck models[END_REF]. Thanks to an efficient linear algorithm, detailed in Ho & Ané (2013a), this function is pretty fast, taking only about 8 minutes of CPU time. Note that the model used in these last three methods (bayou, SURFACE and OUshifts) are slightly different from ours, as they assume that the root is fixed to the ancestral optimum state, and not drawn from its stationary distribution.

Note on Computation Times. We found that the running time for our method was similar to the running time of previous algorithms (see Table 2.1 in the main text). However, our computations can be highly parallelized, as each run for a fixed number of shift is independent from the others. For instance, in the previous example, the computation time could be divided by 6, each estimation for a fixed α running on a different core. On the contrary, the SURFACE method cannot be parallelized at all, and only independent chains can be parallelized for Bayesian methods, so that the computation time can only be divided by 2 in our example.

2.G Practical Implementation

The statistical method described here was implemented on the statistical software R (R Core Team, 2017), and the code is freely available on GitHub (https://github.com/ pbastide/Phylogenetic-EM). Phylogenetic trees were handled thanks to the package ape [START_REF] Paradis | APE: Analyses of Phylogenetics and Evolution in R language[END_REF]. Packages TreeSim [START_REF] Stadler | Simulating Trees with a Fixed Number of Extant Species[END_REF], robustbase [START_REF] Rousseeuw | robustbase: Basic Robust Statistics[END_REF] and quadrupen [START_REF] Grandvalet | Sparsity by Worst-Case Quadratic Penalties[END_REF] were used, respectively, for random tree generation, robust regression and Lasso regression. The penalty described in proposition 2.4.1 is implemented in package LINselect [START_REF] Baraud | LINselect: {R} Package for Estimator Selection[END_REF]. Parallelization was achieved thanks to R packages foreach [START_REF] Weston | foreach: Foreach looping construct for R[END_REF] and doParallel (Weston, 2014a).

Package mclust [START_REF] Fraley | mclust Version 4 for R: Normal Mixture Modeling for Model-Based Clustering, Classification, and Density Estimation[END_REF] was used for ARI computations. Plots were made thanks to packages ggplot2 [START_REF] Wickham | ggplot2[END_REF] and reshape2 [START_REF] Wickham | Reshaping Data with the {reshape} Package[END_REF].

Foreword

This chapter has been submitted under the title Inference of Adaptive Shifts for Multivariate Correlated Traits to a Biology oriented journal. It is available as a preprint (Bastide et al., 2017a). Abstract. To study the evolution of several quantitative traits, the classical phylogenetic comparative framework consists of a multivariate random process running along the branches of a phylogenetic tree. The Ornstein-Uhlenbeck (OU) process is sometimes preferred to the simple Brownian Motion (BM) as it models stabilizing selection toward an optimum. The optimum for each trait is likely to be changing over the long periods of time spanned by large modern phylogenies. Our goal is to automatically detect the position of these shifts on a phylogenetic tree, while accounting for correlations between traits, which might exist because of structural or evolutionary constraints. We show that, in the presence shifts, phylogenetic Principal Component Analysis (pPCA) fails to decorrelate traits efficiently, so that any method aiming at finding shift needs to deal with correlation simultaneously. We introduce here a simplification of the full multivariate OU model, named scalar OU (scOU), which allows for noncausal correlations and is still computationally tractable. We extend the equivalence between the OU and a BM on a re-scaled tree to our multivariate framework. We describe an Expectation Maximization algorithm that allows for a maximum likelihood estimation of the shift positions, associated with a new model selection criterion, accounting for the identifiability issues for the shift localization on the tree. The method, freely available as an R-package (PhylogeneticEM) is fast, and can deal with missing values. We demonstrate its efficiency and accuracy compared to another state-of-the-art method ( 1ou) on a wide range of simulated scenarios, and use this new framework to re-analyze recently gathered datasets on New World Monkeys and Anolis lizards. (Keywords: Ornstein-Uhlenbeck, Change-point detection, Adaptive evolution, Phylogeny, Model selection, PhylogeneticEM)

Introduction

Motivation

A major goal of comparative and evolutionary biology is to decipher the past evolutionary mechanisms that shaped the present day diversity. Taking advantage of the increasing amount of molecular data made available by powerful sequencing techniques, sophisticated mathematical models have made it possible to infer reliable phylogenetic trees for ever growing groups of taxa (see e.g. [START_REF] Meredith | Impacts of the Cretaceous Terrestrial Revolution and KPg Extinction on Mammal Diversification[END_REF][START_REF] Jetz | The global diversity of birds in space and time[END_REF]. Models of phenotypic evolution for such large families need to cope with the heterogeneity of observed traits across the species tree. One source of heterogeneity is the mechanism of "evolution by jumps" as hypothesized by [START_REF] Simpson | Tempo and Mode in Evolution. A Wartime book[END_REF]. It states that there exists an adaptive landscape shaping the evolution of functional traits, and that this landscape might shift, sometimes in a dramatic fashion, in response to environmental changes such as migration, or colonization of a new ecological niche. Such shifts, like the one observed in the brain shape and size of New World Monkeys in association with dietary and locomotion changes [START_REF] Aristide | Modeling lineage and phenotypic diversification in the New World monkey (Platyrrhini, Primates) radiation[END_REF][START_REF] Aristide | Brain shape convergence in the adaptive radiation of New World monkeys[END_REF], need to be explicitly accounted for in models of phenotypic evolution.

To detect such adaptive shifts, we must cope with two constraints: species do not evolve independently [START_REF] Felsenstein | Phylogenies and the Comparative Method[END_REF] and adaptive evolution is an intrinsically multivariate phenomenon. The first constraint arises from the shared evolutionary history of species, usually represented as a phylogenetic tree. It means that traits observed on closely related taxa are on average more similar than traits observed on distantly related species. The second constraint results from natural selection acting on many traits at once. Functional traits are indeed often interdependent, either because they are regulated by the same portions of the genetic architecture or because they are functionally constrained (e.g. limb bones lengths in Greater Antillean Anolis lizards [START_REF] Mahler | Ecological opportunity and the rate of morphological evolution in the diversification of greater Antillean anoles[END_REF]).

This work aims to develop a likelihood-based method to detect rapid adaptive events, referred to as shifts, using a time calibrated phylogenetic tree and potentially incomplete observations of a multivariate functional trait at the tips of that tree. The shifts can be used to cluster together species sharing a common adaptive history.

State of the Art

Phylogenetic comparative methods (PCM) are the de facto tools for studying phenotypic evolution. Most of them can be summarized as stochastic processes on a tree. Specifically, given a rooted phylogeny, the traits evolve according to a stochastic process on each branch of the tree. At each speciation event, one independent copy with the same initial conditions is created for each daughter species. A common stochastic process in this setting is the Brownian Motion (BM, [START_REF] Felsenstein | Phylogenies and the Comparative Method[END_REF]. It is well suited to model the random drift of a quantitative, neutral and polygenic trait (see e.g. Felsenstein, 2004, chap. 24). Unfortunately, the BM has no stationary distribution and cannot adequately model adaptation to a specific optimum [START_REF] Hansen | Assessing Current Adaptation and Phylogenetic Inertia as Explanations of Trait Evolution: The Need for Controlled Comparisons[END_REF]. The Ornstein-Uhlenbeck (OU) process is therefore preferred to the BM in the context of adaptive evolution [START_REF] Hansen | Stabilizing Selection and the Comparative Analysis of Adaptation[END_REF][START_REF] Hansen | A Comparative Method for Studying Adaptation to a Randomly Evolving Environment[END_REF]. Note that, as pointed out by [START_REF] Hansen | A Comparative Method for Studying Adaptation to a Randomly Evolving Environment[END_REF] and [START_REF] Cooper | A cautionary note on the use of Ornstein Uhlenbeck models in macroevolutionary studies[END_REF], this model is distinct from the process theoretically derived by [START_REF] Lande | Natural Selection and Random Genetic Drift in Phenotypic Evolution[END_REF] for stabilizing selection toward an optimum on an adaptive landscape at a micro-evolutionary timescale, and is better seen as a heuristic for the macro-evolution of the "secondary optima" themselves in a Simpsonian interpretation of evolution [START_REF] Hansen | A Comparative Method for Studying Adaptation to a Randomly Evolving Environment[END_REF]. Recently, Levy processes have also been used to capture Simpsonian evolution [START_REF] Landis | Phylogenetic analysis using Lévy processes: Finding jumps in the evolution of continuous traits[END_REF][START_REF] Duchen | Inference of Evolutionary Jumps in Large Phylogenies using Lévy Processes[END_REF].

Extensions to multivariate traits have been proposed for both BM [START_REF] Felsenstein | Phylogenies and the Comparative Method[END_REF]) and OU processes [START_REF] Bartoszek | A phylogenetic comparative method for studying multivariate adaptation[END_REF]. [START_REF] Cybis | Assessing phenotypic correlation through the multivariate phylogenetic latent liability model[END_REF] considered even more complex models, with a mix of both quantitative and discrete characters modeled with an underlying multivariate BM and a threshold model [START_REF] Felsenstein | Using the quantitative genetic threshold model for inferences between and within species[END_REF][START_REF] Felsenstein | A Comparative Method for Both Discrete and Continuous Characters Using the Threshold Model[END_REF] for drawing discrete characters from the underlying continuous BM.

The work on adaptive shifts also enjoyed a growing interest in the last decade. In their seminal work, [START_REF] Butler | Phylogenetic Comparative Analysis: A Modeling Approach for Adaptive Evolution[END_REF] considered a univariate trait with known shift locations on the tree and estimated shift amplitudes in the trait optimal value using a maximum-likelihood framework. [START_REF] Beaulieu | Modeling stabilizing selection: Expanding the Ornstein-Uhlenbeck model of adaptive evolution[END_REF] extended the work by estimating shift amplitudes not only in the optimal value but also in the evolutionary rate. The focus then moved to estimating the number and locations of shifts. [START_REF] Eastman | A Novel comparative method for identifying shifts in the rate of character evolution on trees[END_REF][START_REF] Eastman | Simpsonian 'Evolution by Jumps' in an Adaptive Radiation of Anolis Lizards[END_REF] detected shifts, respectively, in the evolutionary rate or the trait expectations, for traits evolving as BM, in a Bayesian setting using reversible jump Markov Chain Monte Carlo (rjMCMC). Ingram & Mahler (2013); Uyeda & Harmon (2014); Bastide et al. (2017b) detected shifts in the optimal value of a trait evolving as an OU. Uyeda & Harmon (2014) and Bastide et al. (2017b) detect all shifts for a given number of shifts and use either rjMCMC or penalized likelihood to select the number of shifts. By contrast, Ingram & Mahler (2013) uses a stepwise procedure, based on AIC, to detect shifts sequentially, stopping when adding a shift does not improve the criteria anymore.

Extensions from univariate to multivariate shifts are more recent. It should be noted that all methods assume that shifts affect all traits simultaneously. Given known shift locations and a multivariate OU process, [START_REF] Bartoszek | A phylogenetic comparative method for studying multivariate adaptation[END_REF] was the first to develop a likelihood-based method (package mvSLOUCH) to estimate both matrices of multivariate evolutionary rates and selection strengths. [START_REF] Clavel | mvmorph : an r package for fitting multivariate evolutionary models to morphometric data[END_REF] soon followed with mvmorph, a comprehensive package covering a wide range of multivariate processes. Detection of shifts in multivariate traits is more involved and both Ingram & Mahler (2013) and [START_REF] Khabbazian | Fast and accurate detection of evolutionary shifts in Ornstein-Uhlenbeck models[END_REF] make the simplifying assumption that all traits are independent, conditional on their shared shifts. Ingram & Mahler (2013) then proceed with the same stepwise procedure as in the univariate case whereas [START_REF] Khabbazian | Fast and accurate detection of evolutionary shifts in Ornstein-Uhlenbeck models[END_REF] uses a lasso-regression to detect the shifts and a phylogenetic BIC (pBIC) criterion to select the number of shifts.

Scope of the Article

In this work, we present a new likelihood-based method to detect evolutionary shifts in multivariate OU models. We make the simplifying assumptions that all traits have the same selection strength but, unlike in [START_REF] Khabbazian | Fast and accurate detection of evolutionary shifts in Ornstein-Uhlenbeck models[END_REF] and Ingram & Mahler (2013), traits can be correlated. Our contribution is multifaceted. We show that the scalar assumption that we make (see Section 3.2) and the independence assumption share a similar feature in their structure that make the shift detection problem tractable. Building upon a formal analysis made in the univariate case (Bastide et al., 2017b), we show that the problem suffers from identifiability issues as two or more distinct shift configurations may be indistinguishable. We propose a latent variable model combined with an OU to BM reparametrization trick to estimate the unknown number of shifts and their locations. Our method is fast and can handle missing data. It also proved accurate in a large scale simulation study and was able to find back known shift locations in reanalysis of public datasets. Finally, we show that the standard practice of decorrelating traits using phylogenetic principal component analysis (pPCA) before using a method designed for independent traits can be misleading in the presence of shifts.

The article is organized as followed. We present the model and inference procedure in Section 3.2, the theoretical bias of pPCA in the presence of shifts in Section 3.3, the simulation study in Section 3.4, the re-analysis of the New World Monkeys and Greater Antillean Anolis lizards datasets in Section 3.5 and discuss the results and limitations of our method in Section 3.6.

Model

Trait Evolution on a Tree

Tree. We consider a fixed and time-calibrated phylogenetic tree linking the presentday species studied. The tree is assumed ultrametric with height h, but with possible polytomies. We denote by n the number of tips and by m the number of internal nodes, such that N = n + m is the total number of nodes. For a fully bifurcating tree, m = n -1, and N = 2n -1.

Traits. We note Y the matrix of size n × p of measured traits at the tips of the tree. For each tip i, the row-vector Y i represents the p measured traits at tip i. Some of the data might be missing, as discussed later (see Section 3.2.5).

Brownian Motion (BM).

The multivariate BM has p +p(p +1)/2 parameters: p for the ancestral mean value vector µ, and p(p + 1)/2 for the drift rate (in the genetic sense) matrix R. The variance of a given trait grows linearly in time, and the covariance between two traits k and l at nodes i and j is given by t ij R kl , where t ij is the time elapsed between the root and the most recent common ancestor (MRCA) of i and j (see e.g. Felsenstein, 2004, chap. 24). Using the vectorized version of matrix Y (where vec(Y) is the vector obtained by "stacking" all the columns of Y), we get: Var [vec(Y)] = R ⊗ C, where ⊗ is the Kronecker product, and C = [t ij ] 1≤i,j≤n .

Ornstein-Uhlenbeck (OU). The Ornstein-Uhlenbeck process has p 2 extra parameters in the form of a selection strength matrix A. The traits evolve according to the stochastic differential equation dX t = A(β -X t )dt + RdW t , where W t stands for the standard p-variate Brownian motion. The first part represents the attraction to a "primary optimum" β, with a dynamic controlled by A. This matrix is not necessarily symmetric in general, but it must have positive eigenvalues for the traits to indeed be attracted to their optima. This assumption also ensures the existence of a stationary state, with mean β and variance Γ (see [START_REF] Bartoszek | A phylogenetic comparative method for studying multivariate adaptation[END_REF][START_REF] Clavel | mvmorph : an r package for fitting multivariate evolutionary models to morphometric data[END_REF], for further details and general expression of Γ).

Shifts. We assume that some environmental changes affected the traits evolution in the past. In the BM model, we take those changes into account by allowing the process to be discontinuous, with shifts occurring in its mean value vector (as e.g. [START_REF] Eastman | Simpsonian 'Evolution by Jumps' in an Adaptive Radiation of Anolis Lizards[END_REF]. This is reasonable if the adaptive response to a change in the environment is fast enough compared to the evolutionary time scale. For the OU, we assume that environmental changes result in a shift in the primary optimum β (as e.g. [START_REF] Butler | Phylogenetic Comparative Analysis: A Modeling Approach for Adaptive Evolution[END_REF]. The process is hence continuous, and goes to a new optimum, with a dynamic controlled by A. In both cases, we make the standard assumptions that all traits shift at the same time (but with different magnitudes), that each shift occurs at the beginning of its branch, and that all other parameters (A, R) of the process remain unchanged. We further assume that each jump induces a specific optimum, which implies that there is no homoplasy for the optimum, that is, no convergent evolution.

Simplifying Assumptions

Trait Independence Assumption. The general OU as described above is computationally hard to fit [START_REF] Clavel | mvmorph : an r package for fitting multivariate evolutionary models to morphometric data[END_REF], even when the shifts are fixed a priori. For automatic detection to be tractable in practice, several assumptions can be made. The two methods that (to our knowledge) tackle this problem in the multivariate setting assume that all the traits are independent, i.e. that matrices A and R are diagonal (Ingram & Mahler, 2013;[START_REF] Khabbazian | Fast and accurate detection of evolutionary shifts in Ornstein-Uhlenbeck models[END_REF]. This is often justified by assuming that a priori preprocessing with phylogenetic Principal Component Analysis (pPCA, [START_REF] Revell | Size-correction and principal components for interspecific comparative studies[END_REF] leads to independent traits. However, pPCA assumes a no-shift BM evolution of the traits, and it can introduce a bias in the downstream analysis conducted on the scores, as shown by [START_REF] Uyeda | Comparative Analysis of Principal Components Can be Misleading[END_REF]. The choice of the number of PC axes to keep is also crucial, and can qualitatively change the results obtained, leading to the detection of artificial shifts near the root when not enough PC axes are kept for the analysis, as observed by [START_REF] Khabbazian | Fast and accurate detection of evolutionary shifts in Ornstein-Uhlenbeck models[END_REF]. Finally, we show theoretically (Section 3.3) and numerically (Section 3.4, last paragraph) that pPCA fails to decorrelate the data in the presence of shifts and may even hamper shift detection accuracy.

Scalar OU (scOU). We offer here an alternative to the independence assumption. Computations are greatly simplified when matrices A and R commute. This happens when both of these matrices are diagonal for example, or when R is unconstrained and A is scalar, i.e. of the form A = αI p , where I p is the identity matrix. We call a process satisfying the latter assumptions a scalar OU (scOU), as it behaves essentially as a univariate OU. In particular, its stationary variance is simply given by Γ = R/(2α) (analogous to the formula γ 2 = σ 2 /(2α) in the univariate case, see e.g. [START_REF] Hansen | Stabilizing Selection and the Comparative Analysis of Adaptation[END_REF].

We define the scOU model as follows: at the root ρ, the traits are either drawn from the stationary normal distribution with mean µ and variance Γ (X ρ ∼ N (µ, Γ)), or fixed and equal to µ. The initial optimum vector is β 0 and the conditional distribution of trait X i at node i given trait X pa(i) at its parent node pa(i) is

X i X pa(i) ∼ N e -α i X pa(i) + (1 -e -α i )β i , 1 2α (1 -e -α i )R (3.1)
where β i = β pa(i) + ∆ i is the optimal value of the process on the branch with length i going from pa(i) to i and ∆ is the N × p matrix of shifts on the branches of the tree: for any node i and any trait l, ∆ il is 0 if there are no shift on the branch going from pa(i) to i, and the value of the shift on trait l otherwise. At the root, we define β ρ = β 0 and, for each trait l: ∆ ρl = e -αh µ l + (1e -αh )β 0l , where h is the age of the root (or tree height). The scOU model can also be expressed under a linear form. Let U be the N × N matrix where U ij is 1 if node j is an ancestor of node i and 0 otherwise. Let T be the n × N matrix made of the n rows of U corresponding to tip taxa. For a given α, we further define the diagonal N matrix W(α) with diagonal term W ii (α) = 1e -αa pa(i) for any non-root node i, where a pa(i) is the age of node pa(i), and W ρρ (α) = 1 for the root node ρ. Then the joint distribution of the observed traits Y is normal

vec(Y) ∼ N (vec(TW(α)∆), R ⊗ F(α)) (3.2)
where F(α) is the symmetric scaled correlation matrix between the n tips, with entries F ij = 1 2α e -αd ij if the root is drawn from the stationary distribution, and F ij = 1 2α e -2αd ij (1e -2αt ij ) if the root is fixed, where d ij is the tree distance between nodes i and j. In the next section, this will allow us to rewrite scOU as a BM on a tree with rescaled branch lengths. This observation is at the core of our statistical inference strategy.

The scOU process allows us to handle the correlations that might exist between traits, and spares us from doing a preliminary pPCA. This however comes at the cost of assuming that all the traits evolve at the same rate toward their respective optima, with the same selection strength α. See the 3.6 for further analysis of these assumptions.

Identifiability Issues

Root State. It can be easily checked that the parameters µ and β 0 at the root are not jointly identifiable from observations at the tips of an ultrametric tree, only the combination λ = e -αh µ + (1e -αh )β 0 is. See [START_REF] Ho | Intrinsic inference difficulties for trait evolution with Ornstein-Uhlenbeck models[END_REF] for a derivation in the univariate case. Note that λ corresponds to the first row of the shift matrix ∆. As we cannot decide from the data, we assume by default β 0 = µ = λ. Shift Position. The location of the shifts may not always be uniquely determined, as several sets of locations (and magnitudes) may yield the same joint marginal distribution of the traits at the tips. These identifiability issues have been carefully studied in Bastide et al. (2017b) for the univariate case. Because we assume that all traits shift at the same time, the sets of equivalent shift locations are the same in the multivariate case as in the univariate case; only the number of parameters involved is different. So, the problem of counting the total number of parsimonious, non-equivalent shift allocations remains the same, as well as the problem of listing the allocations that are equivalent to a given one. As a consequence, all the combinatorial results and algorithms used in Bastide et al. (2017b) are still valid here; only the model selection criterion needs be adapted (see Section 3.2.5).

Re-scaling of the Tree

Equivalency scOU / rBM. As recalled above, the inference of OU models raises specific issues, mostly because some maximum likelihood estimates do not have a closed form expression. Many of these issues can be circumvented using the equivalence between the univariate BM and OU models described in [START_REF] Blomberg | Testing for Phylogenetic Signal in Comparative Data: Behavioral Traits Are More Labile[END_REF]; Ho & Ané (2013a); [START_REF] Pennell | Model Adequacy and the Macroevolution of Angiosperm Functional Traits[END_REF], for ultrametric trees, when α is known. Thanks to the scalar assumption, this equivalence extends to the multivariate case. Indeed, the marginal distribution of the traits at the observed tips Y given in (3.2) is the same as the one arising from a BM model on a re-scaled tree defined by:

X ρ ∼ N β 0 , ρ (α)R or X ρ = β 0 (fixed) X i X pa(i) ∼ N X pa(i) + ∆ i (α), i (α)R , for non-root node i.
where ρ (α) = 1 2α e -2αh , i (α) = 1 2α e -2αh e 2αt ie 2αt pa(i) , and ∆ i (α) = (W(α)∆) i = (1e -α(h-t pa(i) ) )∆ i . Note that, when the root is taken random, everything happens as if we added a fictive branch above the root with length ρ (α). The length of this branch increases when α goes to zero.

We emphasize that only the distribution of the observed traits Y is preserved and not the distribution of the complete dataset X. As a consequence, ancestral traits at internal nodes cannot be directly inferred using this representation. Still, the equivalence recasts inference of R and W(α)∆ in the scOU model into inference of the same parameters in a much simpler BM model, albeit on a tree with rescaled branch lengths i (α). Note that the rescaling depends on α, which needs to be inferred separately. See the discussion (Section 3.6.1) for further analysis of this re-scaling.

Statistical Inference

Incomplete Data Model. We now discuss how to infer the set of parameters θ = (∆, R). We adopt a maximum likelihood strategy, which consists in maximizing the log-likelihood of the observed tip data log p θ (Y) with respect to θ to get the estimate θ. The maximum likelihood estimate θ is difficult to derive directly as the computation of log p θ (Y) requires to integrate over the unobserved values of the traits at the internal nodes. We denote by Z the unobserved matrix of size m×p of these ancestral traits at internal nodes of the tree: for each internal node j, Z j is the row-vector of the p ancestral traits at node j. Following Bastide et al. (2017b), we use the expectation-maximization (EM) algorithm [START_REF] Dempster | Maximum likelihood from incomplete data via the EM algorithm[END_REF] that relies on an incomplete data representation of the model and takes advantage of the decomposition of log p θ (Y) as

E [ log p θ (Y, Z) | Y] -E [ log p θ ( Z | Y) | Y ].
EM. The M step of the EM algorithm consists in maximizing E [log p θ (Y, Z) | Y ] with respect to θ. For a given value of α, thanks to the rescaling described in Section 3.2.4, the formulas to update ∆ and R are explicit (see Appendix 3.C). The optimization of α is achieved over a grid of values, at each point of which a complete EM algorithm is run. At the M step, we need the mean and variance of the unobserved traits Z j at each internal node j conditional on the observed traits Y at the tips. The E step is dedicated to the computation of these values, which can be achieved via an upward-downward recursion [START_REF] Felsenstein | Inferring Phylogenies[END_REF]. The upward path goes from the leaves to the root, computing the conditional means and variances at each internal node given the values of its offspring in a recursive way. The downward recursion then goes from the root to the leaves, updating the values at each internal node to condition on the full taxon set. Thanks to the joint normality of the tip and internal node data, all update formulas have closed form matrix expressions, even when there are some missing values (see Appendix 3.C).

Initialization. The EM algorithm is known to be very sensitive to the initialization. Following Bastide et al. (2017b), we take advantage of the linear formulation (3.2) to initialize the shifts position using a lasso penalization [START_REF] Tibshirani | Regression Selection and Shrinkage via the Lasso[END_REF]. This initialization method is similar to the procedure used in 1ou [START_REF] Khabbazian | Fast and accurate detection of evolutionary shifts in Ornstein-Uhlenbeck models[END_REF]. See Appendix 3.C for more details.

Missing Data. EM was originally designed to handle missing data. As a consequence, the algorithm described above also applies when some traits are unobserved for some taxa. Indeed, the conditional distribution of the missing traits given the observed ones can be derived in the same way as in the E step. However, missing data break down the factorized structure of the dataset and some computational tricks are needed to handle the missing data efficiently (see Appendix 3.C).

Model Selection. For each value of the number of shifts K, the EM algorithm described above provides us with the maximum likelihood estimate θ K . K needs to be estimated to complete the inference procedure. We do so using a penalized likelihood approach. The model selection criterion relies on a reformulation of the model in terms of multivariate linear regression, where we remove the phylogenetic correlation, like independent contrasts and PGLS do. We can re-write (3.2), for a given α, as

Y = T∆ + E where Y = F(α) -1/2 Y, T = F(α) -1/2 TW(α),
where E is a n × p matrix with independent and identically distributed rows, each row being a (transposed) centered Gaussian vector with variance R. In the univariate case (Bastide et al., 2017b), this representation allowed us to cast the problem in the setting considered by [START_REF] Baraud | Gaussian model selection with an unknown variance[END_REF], and hence to derive a penalty on the log-likelihood, or, equivalently, on the least squares. Taking advantage of the well known fact that the maximum likelihood estimators of the coefficients are also the least square ones, and do not depend on the variance matrix R (see, e.g. Mardia et al., 1979, Section 6), we propose to estimate K using the penalized least squares:

K = arg min K 1 + pen(K) n -K p j=1 Y j -Y K j 2
where Y j is the column of Y for the j-th trait, and Y K j the predicted means for trait j from the best model with K shifts. Using the EM results, this can be written as:

K = arg min K 1 + pen(K) n -K tr R(K, α)
where R(K, α) is the ML estimate of the variance parameter obtained by the EM for a fixed number K of shifts. The penalty is the same as in the univariate case:

pen(K) = A n -K -1 n -K -2 EDkhi K, n -K -2, (K + 1) 2 /|S PI K |
where EDkhi is the function from Definition 3 from [START_REF] Baraud | Gaussian model selection with an unknown variance[END_REF] and |S PI K | is the number of parsimonious identifiable sets of locations for K shifts, as defined in Bastide et al. (2017b). It hence might depends on the topology of the tree, for a tree with polytomies. For a fully resolved tree,

|S PI K | = 2n-2-K K .
A is a normalizing constant, that must be greater than 1. In [START_REF] Baraud | Gaussian model selection with an unknown variance[END_REF], the authors showed that it had little influence in the univariate case, and advised for a value around A = 1.1. We took this value as a default.

The criterion is directly inspired from the univariate case and inherits its theoretical properties in the special case R = σ 2 I p . In general however, the criterion should be seen as a heuristic, although with good empirical properties (see Section 3.4).

Implementation

We implemented the method presented above in the PhylogeneticEM R package (R Core Team, 2017), available on the Comprehensive R Archive Network (CRAN). A thorough documentation of its functions, along with a brief tutorial, is available from the GitHub repository of the project (pbastide.github.io/PhylogeneticEM). Thanks to a comprehensive suite of unitary tests, that cover approximately 79% of the code (codecov. io/gh/pbastide/PhylogeneticEM), and that are run automatically on an independent Ubuntu server using the continuous integration tool Travis CI (travis-ci.org), the package was made as robust as possible. The computationally intensive parts of the analysis, such that the upward-downward algorithm of the M step, have been coded in C++ to improve performance (see Section 3.4 for a study of the computation times needed to solve problems of typical size). Because the inference on each α value on the grid used is independent, they can be easily be done in parallel, and a built in option allows the user to choose the number of cores to be allocated to the computations.

pPCA and Shifts

Shift detection in multivariate settings is usually done by first decorrelating traits with pPCA before feeding phylogenetic PCs to detection procedures that assume independent traits. We show hereafter that even in the simple BM setting, phylogenetic PC may still be correlated in the presence of shifts. The problem is only exacerbated in the OU setting.

pPCA is biased in the presence of shifts

Assume that the traits evolve as a shifted BM process on the tree, so that vec(Y) ∼ N (vec(a), R ⊗ C), with a being the n × p matrix of trait means at the tips. Decomposing R as R = VD 2 V T , pPCA relies on the fact that the columns of the matrix YV are independent. Therefore, its efficiency relies on an accurate estimation of R.

The estimate of R used in pPCA is R = (n -1) -1 (Y -1 n ȲT ) T C -1 (Y -1 n ȲT ), where ȲT = (1 T n C -1 1 n ) -1 1 T n C -1
Y, which is known as the estimated phylogenetic mean vector [START_REF] Revell | Size-correction and principal components for interspecific comparative studies[END_REF]. Decomposing the estimate of R as R = V D 2 V T , pPCA then computes the scores as S = (Y -1 n ȲT ) V.

In the absence of shift, all species have the same mean vector µ so a = 1 n µ T and E Ȳ = µ. In the presence of shifts, species do not all share the same mean vector so the uniform centering is not valid anymore. As a consequence, the estimate of R is biased (see appendix 3.A):

E R = R + B where B = 1 n -1 G T C -1 G, G = a -1 n āT (3.3)
The extra term B is analogous to the between-group variance in the context of linear discriminant analysis and cancels out in the absence of shifts (note that R is analogous to the within-group variance, see [START_REF] Mardia | Multivariate analysis. Probability and mathematical statistics[END_REF]. Because R is biased, the columns of the score matrix S resulting from pPCA are still correlated. We illustrate this phenomenon below using toy examples.

Illustration: a simple example

To illustrate the impact of shifts on the decorrelation performed by (p)PCA, we used the simple tree presented in Figure 3.3.1a and considered three scenarios. In all scenarios, we simulated two highly correlated traits under a BM starting from (0, 0) at the root and with covariance matrix R = 1 -0.9 -0.9 1 . The tree has two clearly marked clades, designed to highlight the differences between pPCA and PCA. R is identical in all scenarios; any preprocessing aiming at decorrelating the traits should retrieve the eigenvectors of R as PCs. In the first scenario, there are no trait shifts on the tree, corresponding to the pPCA assumptions, and pPCA is indeed quite efficient in finding the PCs (see Fig. 3.3.1b,left panel). In the second scenario, we added a shift on a long branch. This shift induces a species structure in the trait space that misleads standard PCA. The same structure can however be achieved by a large increment of the BM on that branch and large increments are likely on long branches. pPCA therefore copes with the shift quite well and is able to recover accurate PCs. More quantitatively, the bias induced by the shift on R is quite small, B = 0.16 0.08 0.08 0.04 , around one tenth of the values of R. In the third scenario, we put a shift on a small branch. The structure induced by the shift "breaks down" the upper clade and is unlikely to arise from the increment of a BM on that branch. It is therefore antagonistic to pPCA and results in a large bias for R: the extra term B is equal to 1.58 0.79 0.79 0.4 and comparable to R. In that scenario, both PCA and pPCA find axes that are far away from the eigenvectors of R (Figure 3.3.1b, right panel). The first eigenvector of R captures the evolutionary drift correlation between traits, whereas the PCs of both PCA and pPCA capture a mix of evolutionary drift correlation and correlation resulting from shifts along the tree. (a)

A1 A2 A3 A4 A5 A6 A7 A8 B1 B2 B3 B4 C1 C2 C3 C4 A1 A2 A3 A4 A5 A6 A7 A8 B1 B2 B3 B4 C1 C2 C3 C4 A1 A2 A3 A4 A5 A6 A7 A8 B1 B2 B3 B4 C1 C2 C3 C4 -1 0 1 2 -1 0 1 2 -1 0 1 2 -0.

Simulations Studies

Experimental Design

General Setting. We studied the performance or our method using a "star-like" experimental design, as opposed to a full-factorial design. We first considered a base scenario, corresponding to a base parameter set, and then varied each parameter in turn to assess its impact as in [START_REF] Khabbazian | Fast and accurate detection of evolutionary shifts in Ornstein-Uhlenbeck models[END_REF]. The base scenario was chosen to be only moderately difficult, so that our method would find shifts most but not all of the time.

For the base scenario, we generated one 160-taxon tree according to a pure birth process, using the R package TreeSim [START_REF] Stadler | Simulating Trees with a Fixed Number of Extant Species[END_REF], with unit height and birth rate λ = 0.1. We then generated 4 traits on the phylogeny according to the scOU model, with a rather low selection strength α b = 1 (t 1/2 = 69% of the tree height), and with a root taken with a stationary variance of γ 2 b = σ 2 b /(2α b ) = 1. Diagonal entries of the rate matrix R are σ 2 b and off-diagonal entries were set to σ 2 b r d with a base correlation of r d = 0.4 (correlated traits) when testing the effect of shift number and amplitude, or r d = 0 (independent traits) otherwise.

Finally, we added three shifts on this phylogeny, with fixed positions (see Figure 3.4.1). Shift amplitudes were calibrated so that the means at the tips differ by about 1 standard deviation, which constitute a reasonable shift signal [START_REF] Khabbazian | Fast and accurate detection of evolutionary shifts in Ornstein-Uhlenbeck models[END_REF]. Each configuration was replicated 100 times. We then used both our PhylogeneticEM and 1ou package [START_REF] Khabbazian | Fast and accurate detection of evolutionary shifts in Ornstein-Uhlenbeck models[END_REF] to study the simulated data. We excluded SURFACE (Ingram & Mahler, 2013) from the comparison at is (i) quite slow, (ii) assumes the same evolutionary model as 1ou and (iii) was found to achieve worse accuracy than 1ou [START_REF] Khabbazian | Fast and accurate detection of evolutionary shifts in Ornstein-Uhlenbeck models[END_REF]. We used default setting for both methods. For Phylo-geneticEM this implies an inference on an automatically chosen grid with 10 α values, on a log scale, and a maximum number of shifts of √ n + 5 (See Bastide et al. 2017b and Appendix 3.C for a justification of these default parameters).

Number and Amplitude of Shifts. We explored the effect of shifts by varying both their number and amplitude. We considered successively 0, 3, 7, 11, 15 shifts on the topology, with positions and values fixed as in Figure 3.4.1. Shifts values were chosen to form well separated tip groups; adjacent (in the tree) group means differ by about 1 standard deviation γ b . To mimic adaptive events having different consequences on different traits, all shifts on a trait were then randomly multiplied by -1 or +1. Finally and to assess the effect of shift amplitude, we rescaled all shifts by a common factor taking values in [0.5 , 3]. Low scaling values correspond to smaller, harder to detect, shifts and high values to larger and easier to detect shifts.

Selection Strength. When exploring parameters not related to the shifts, we considered a base number of 3 shifts and a base scaling factor of 1.25, empirically found to correspond to a moderately difficult scenario. We also assumed independent traits with the same variance and selection strength (i.e. scalar A and R, see model A in appendix 3.D.1). We first varied α from 1 to 3 (i.e. t 1/2 varied between 35% and 23% of the tree height). The variance σ 2 varied with α to ensure that the stationary variance γ 2 b remained fixed at γ 2 b = 1.

Model Mis-specification. The two current frameworks ( 1ou and scOU) for multivariate shift detection assume independents traits (diagonal A and R) or correlated traits with equal selection strengths (scalar A and arbitrary R). To assess robustness to model misspecification, we simulated data under four classes of models, referred to as A, B, C, D. Model A is correctly specified for both scOU and 1ou whereas B, C, D correspond respectively to mis-specifications for 1ou, scOU and both. We used the Kullback-Leibler divergence between models A and B (resp. C, D) to choose parameters that attain comparable "levels" of mis-specification (see appendix 3.D.1 for details).

Model A assumes scalar A and R (independent traits, same selection strength and variance) and meets the assumptions of both scOU and 1ou.

-1.01 1.03 Model C assumes diagonal, but not scalar, A, and diagonal R (independent traits, different selection strengths), which matches the assumptions of 1ou only. We considered A = α Diag(s -1.5 , s -0.5 , s 0.5 , s 1.5 ) with s varying from 2 to 8. We accordingly set R = 2γ 2 b A to ensure that all traits have stationary variance γ 2 b = 1. This led to Kullback divergences of up to 286.78 units.

Model D assumes non-diagonal A and diagonal R (uncorrelated drift, but correlated traits selection) and violates both models. Following [START_REF] Khabbazian | Fast and accurate detection of evolutionary shifts in Ornstein-Uhlenbeck models[END_REF], all off-diagonal elements of A were set to α b r s , varying from 0.2 to 0.8. In this case, the stationary variance is not diagonal but has diagonal entries equal to

σ 2 2
1+(p-2)r s

(1-r s )(1+(p-1)r s ) . We thus rescaled σ 2 appropriately to ensure that each trait has marginal stationary variance γ 2 b = 1 as previously. This led to Kullback divergences of up to 112.98 units.

We expected 1ou to outperform scOU in model C and vice versa in model B. To be fair to both methods, we selected parameter ranges leading to similar Kullback divergences, to achieve similar levels of mis-specifications. However, both deviations produce datasets with groups that are also theoretically easier to discriminate compared to model A (see Figure 3 .4.2). Indeed, we can quantify the difficulty of a dataset in terms of group separation by the Mahalanobis distance between the observed data and their expected mean, (phylogenetically) estimated in the absence of shifts:

D = Y vec -(1 T Σ d 1) -1 1 T Σ d Y vec 2 Σ d -1 -(np -N NA ) (3.4)
where Y vec is the vector of observed data at the tips (omitting missing values), and trait correlations (r d > 0) both increase group separation and make it easier to detect shifts.

Σ

Number of Observations.

We varied the number of observations by (i) varying the number of taxa and (ii) adding missing values. To change the number of taxa, we generated 6 extra trees with the same parameters as before but with 32 to 256 taxa. The three shifts were fixed as in Figure 3.4.3. To test the ability of our method to handle missing data, we removed observations at random in our base scenario, taking care to keep at least one observed trait per species, so as not to change the number of taxa. The fraction of missing data varied from 5% to 50%.

Results

Number and Amplitude of Shifts. We assessed shifts detection accuracy with the Adjusted Rand Index (ARI, [START_REF] Hubert | Comparing partitions[END_REF] between the true clustering of the tips, and the clustering induced by the inferred shifts (Fig. 3.4.4,top). Before adjustment, the Rand index is proportional to the number of pairs of species correctly classified in the same group or correctly classified in different groups. The ARI has maximum value of 1 (for a perfectly inferred clustering) and has expected value of 0, conditional on the inferred number and size of clusters. We use this measure rather than the classical -0.99 1.03 32, 64, 96, 128, 192, 256 taxa. precision/sensitivity graphs as only the clustering can be recovered unambiguously (see Section 3.2.3). Note also that when there is no shift (K = 0), there is only one true cluster, and the ARI is either 1 if no shift is found, or 0 otherwise (see appendix 3.D.2). Figure 3. 4.4 (top panel) shows that, unsurprisingly, both methods detect the number and positions of shifts more accurately when the shifts have higher amplitudes. Phylo-geneticEM is also consistently better than 1ou when there is a base correlation (here, r b = 0.4, see section 3.4.1), which is expected as the independence assumption of 1ou is then violated. The case K = 0 (no shift) shows that 1ou systematically finds shifts when there are none, leading to an ARI of 0. More generally, 1ou is prone to over-estimating the number of shifts, even when they have a high magnitude (Fig. 3.4.4,bottom) whereas PhylogeneticEM is more conservative and underestimates the number of shifts when they are difficult to detect.

Selection Strength and Model Mis-specifications. Our method is relatively robust to model mis-specification (Fig. 3.4.5,top). The first panel confirms that, under model A, high values of α reduce the stationary variance and lead to higher ARI values and lower RMSEs for continuous parameters (Fig. 3.4.5,bottom,leftmost panel). Similarly, scOU (resp. 1ou) achieves high ARI values under well specified models A and B (resp. A and C). The mis-specification of model C (different selection strengths) does not affect scOU much: it has higher ARI dispersion than 1ou but their median ARI are comparable. By contrast, 1ou is severely affected by correlated evolution (model C) and higher levels of correlations lead to significantly lower accuracy, even though group separation is increased (Fig. 3.4.2,right). Finally, both methods are negatively affected by correlated selection strengths (Model D), although 1ou seems more robust to this type of mis-specification.

Although shift detection is relatively unaffected by model mis-specification, parameter estimations suffers from it (Fig. 3.4.5,bottom,center and right panels). Both 1ou and scOU behave better for model A than for model D and as expected, scOU is not affected by trait correlation (model B) whereas 1ou is. Unequal selection strengths (model C) degrades parameter estimation for both PhylogeneticEM and, surprisingly, 1ou, that should in principle remain unaffected. Overall, features of trait evolution not properly accounted for by the inference methods (e.g. correlated selection strengths) are turned into overestimated variances. Note that the quality of the estimation of Γ is depends strongly on the estimation of α, and could be improved by taking a finer grid for this parameter.

K = 0 K = 3 K = 7 K = 11 K = 15 ARI K select 1 0 . 5 1 1 . 2 5 1 . 5 2

Number of Observations and Computation Time.

For a given number of shifts, shift detection becomes easier as the number of taxa increases (Fig. 3.4.6,left). Furthermore, our method is robust against missing data with detection accuracy only slightly decreased when up to 50% of the observations are missing (Fig. 3.4.6,right). Finally, our implementation of the EM algorithm, using only two tree traversals (see appendix 3.C.2) and coded in C++, is reasonably fast. Inference takes roughly 15 minutes on a single core on the base 160 taxa tree and less than 45 minutes on the largest simulated trees (256 taxa). 1ou scales less efficiently: it is faster for very small trees (32 taxa) but median running times go up to 20 hours for the large 256-taxon tree. Those long running times were unexpected and higher than the ones reported in [START_REF] Khabbazian | Fast and accurate detection of evolutionary shifts in Ornstein-Uhlenbeck models[END_REF]. This discrepancy is partly due to the maximum number of shifts allowed, which strongly impacts the running time of 1ou. [START_REF] Khabbazian | Fast and accurate detection of evolutionary shifts in Ornstein-Uhlenbeck models[END_REF] capped it at twice the true number of shifts (6 shifts in our base scenario), while we used the default setting, which is half the number of tips (i.e. from 16 to 128 shifts). Although pre-processing is neutral at moderate correlation levels (r d = 0.4) with three "easy" shifts, it becomes harmful and degrades the performances of 1ou when the number or magnitude of the shifts increases (Fig. 3.4.8b). As expected, PhylogeneticEM is unaffected by the pPCA preprocessing, up to numerical issues.

Examples

We used PhylogeneticEM to re-analyse two publicly available datasets.

New World Monkeys

We first considered the evolution of brain shape in New World Monkeys studied by [START_REF] Aristide | Brain shape convergence in the adaptive radiation of New World monkeys[END_REF]. The dataset consists of 49 species on a time-calibrated maximumlikelihood tree. The traits under study are the first two principal components (PC1, PC2) resulting from a PCA on 399 landmarks describing brain shape. We ran PhylogeneticEM on a grid of 30 values for the α parameter. To make this parameter easily interpretable, we report the phylogenetic half-life t 1/2 = ln(2)/α [START_REF] Hansen | Stabilizing Selection and the Comparative Analysis of Adaptation[END_REF], expressed in percentage of total tree height. Here, t 1/2 took values between 0.46 % and 277.26 %. We allowed for a maximum of 20 shifts. The inference took 17.56 minutes, parallelized on 5 cores. The model selection criterion suggests an optimal value of K = 4 shifts (Fig. 3.5.1, inset graph). The criterion does not show a very sharp minimum, however, and a value of K = 5 shifts also seems to be a good candidate. In order to compare our results with that presented in [START_REF] Aristide | Brain shape convergence in the adaptive radiation of New World monkeys[END_REF], we present the solution with 5 shifts (see Fig. 3.5.1,left). The solution with 4 shifts is very similar, except that the group with Aotus species is absent (in red, see Fig. 3.5.1, and supplementary Fig. 3.B.2 in Appendix 3.B). Note that, because of this added group, the solution with K = 5 has 3 equivalent parsimonious allocations of the shifts (see supplementary Fig. 3.B.3 in Appendix 3.B). The groups found by PhylogeneticEM (Fig. 3.5.1) are in close agreement with the ecological niches defined in [START_REF] Aristide | Brain shape convergence in the adaptive radiation of New World monkeys[END_REF]. There are three main differences. First, there is no jump associated with the Pithecia species who, although having their own ecological niche, seem to have quite similar brain shapes as closely related species. Second, Callicebus and Aotus are marked as convergent in [START_REF] Aristide | Brain shape convergence in the adaptive radiation of New World monkeys[END_REF] (in red, right), but form two distinct groups in our model (in pink and red, left). This is due to our assumption of no homoplasy. Finally, the group with Chiropotes, Ateles and Cebus species (in black) was found as having the "ancestral" trait optimum, while it is marked as "convergent" in [START_REF] Aristide | Brain shape convergence in the adaptive radiation of New World monkeys[END_REF]. This is because we did not include any information from the fossil record (not available for brain shape), but instead used a parsimonious solution. Note that the coloring displayed in [START_REF] Aristide | Brain shape convergence in the adaptive radiation of New World monkeys[END_REF] is not parsimonious. The two models have the same number of distinct groups.

The selected α value was found to be reasonably high, with t 1/2 = 12.58%. The estimated correlation between the two PCs was -0.13, confirming that PCA does not result in independent traits.

Lizards

We then considered the dataset from [START_REF] Mahler | Exceptional Convergence on the Macroevolutionary Landscape in Island Lizard Radiations[END_REF], which consists in 100 lizard species on a time-calibrated maximum likelihood tree and 11 morphological traits. We chose this example because of the large number of traits and the high correlation between traits, as all traits are highly correlated (0.82 < ρ < 0.97) with snout-to-vent length (SVL).

To deal with the correlation between traits, [START_REF] Mahler | Ecological opportunity and the rate of morphological evolution in the diversification of greater Antillean anoles[END_REF][START_REF] Mahler | Exceptional Convergence on the Macroevolutionary Landscape in Island Lizard Radiations[END_REF] first performed a phylogenetic regression of all the traits against SVL, retrieved the residuals and then applied a phylogenetic PCA on SVL and the previous residuals, from which they used the first four components (pPC1 to pPC4) for their shift analysis. We first explored how the number of pPCs used can impact the shift detection. Hence we ran PhylogeneticEM 11 times, including 1 to 11 pPCs in the input dataset. Each run was done on a grid of 100 values of α, with t 1/2 = ln(2)/α ∈ [0.99, 693.15] % of tree height, and allowing for a maximum of 20 shifts. It appears that the result is quite sensitive to the number of pPCs included: the selected number of shifts varies from 20, the maximum allowed, to 5 (Fig. 3.5.2). When 4 pPCs were used, as in the original study, the estimated covariance matrix R contains many high correlations, showing that the pPCs are not phylogenetically independent (Fig. 3.5.2).

To avoid the difficult choice of the number of pPCs, we considered the direct analysis of the raw traits without any pre-processing, and found no shift when running Phylo-geneticEM. Although the likelihood was found to increase with K, the model selection criterion profile was found erratic, suggesting numerical instability. A natural suspect for such instability is the extreme correlation between some traits (0.996 for tibia and metatarsal lengths), which results in bad conditioning of several matrices that must be inverted. To circumvent this problem, we used the two pseudo-orthogonalization strategies described above, running PhylogeneticEM on the SVL plus residuals dataset, and on the 11 pPCs, with the same parameters as above. Note that all these transformations use a rotation matrix, so that the likelihood and the least squares of the original or of any of the two transformed datasets are the same. Hence, the objective function, as well as the model selection criterion, should remain unchanged. Still, slight differences were found between the maximized likelihood for each pseudo-orthogonalized datasets. For each value of K, we therefore retained the solution with the highest likelihood.

Using the model selection criterion given in Section 3.2.5, we found K = 5 shifts, which are displayed in Figure 3.5.3, along with the ecomorphs as described in [START_REF] Mahler | Exceptional Convergence on the Macroevolutionary Landscape in Island Lizard Radiations[END_REF].

Three of those shifts seem to single out grass-bush Anolis, that appear to have a rather small body size, with longer than expected lower limbs and tail, and shorter

C 4 =              1 -0.
             Figure 3
.5.2 -Lizard dataset: selected number of shifts K given the number of pPCs included in the analysis (left) and estimated correlation matrix between the first four pPCs (right).

upper limbs. The two others might be associated with twig Anolis, that have smaller than expected limbs and tails. Because of our no-homoplasy assumption, one of those shifts encompasses some species living in other ecomorphs (namely, trunk, trunk-crown and un-classified). The shift, designed to be coherent with the phylogeny, is located on the stem lineage of the smallest clade encompassing the bulk of twig lizards.

Comments

On both examples (p)PCA does not correct a priori for the correlation between the traits in the presence of shifts. In Section 3.3 we formally proved that it cannot correct for it, actually. As a consequence, any shift detection methods has to account for the correlation between traits. Still, high correlations between traits may raise strong numerical issues, so PCA can be used as a pseudo-orthogonalization of traits, as well as any other linear distancepreserving transformation that would reduce the correlation between them. This does not dispense of considering the correlation between the transformed traits in the model.

The other interest of PCA is to reduce the dimension of the data, which may be desirable when dealing with a large number of traits, such as the original dataset from [START_REF] Aristide | Brain shape convergence in the adaptive radiation of New World monkeys[END_REF]. Since PCA does not correct for the right correlation, we have no clue whether or not the dimension reduction performed by PCA is relevant for shift detection, or if it may remove precisely the direction along which the shifts occur. The relevant dimension reduction would consist in approximating the correlation matrix R with a matrix of lower rank q < p. This can obviously not be done before the shifts are known, which suggests that shift detection and dimension reduction should be performed simultaneously.

Trunk-Ground

Trunk-Crown Crown-Giant Twig Grass-Bush Trunk Unique Figure 3.5.3 -Lizard dataset: solution found by PhylogeneticEM. Groups produced by the shifts are colored on the edges of the tree. The species are colored according to ecomorphs defined in [START_REF] Mahler | Exceptional Convergence on the Macroevolutionary Landscape in Island Lizard Radiations[END_REF]. The traits are the snout-to-vent length (SVL), and the phylogenetic residuals of the regression against SVL of the following traits: femur length, tibia length, metatarsal IV length, toe IV length, humerus length, radius length, finger IV length, lamina number (toe and finger IV), and tail length. The same transformations were used as in [START_REF] Mahler | Ecological opportunity and the rate of morphological evolution in the diversification of greater Antillean anoles[END_REF][START_REF] Mahler | Exceptional Convergence on the Macroevolutionary Landscape in Island Lizard Radiations[END_REF]

Discussion

Many phenotypic traits appear to evolve relatively smoothly over time and across many taxa. However, changes in evolutionary pressures (dispersal to new geographic zones, diet change, etc) or key innovations (bipedal locomotion) may cause bursts of rapid trait evolution, coined evolutionary jumps by [START_REF] Simpson | Tempo and Mode in Evolution. A Wartime book[END_REF]. Phenotypic traits typically evolve in a coordinated way [START_REF] Mahler | Exceptional Convergence on the Macroevolutionary Landscape in Island Lizard Radiations[END_REF][START_REF] Aristide | Modeling lineage and phenotypic diversification in the New World monkey (Platyrrhini, Primates) radiation[END_REF] and a multivariate framework is thus best suited to detect evolutionary jumps. We introduced here an Expectation Maximization algorithm embedded in a maximum-likelihood multivariate framework to infer shifts strength, location and number. Importantly, our method uses Gaussian elimination, just like [START_REF] Fitzjohn | Diversitree: Comparative phylogenetic analyses of diversification in R[END_REF], to avoid computing inverses of large variance-covariance matrices and can cope with missing data, an especially important problem in the multivariate setting where some traits are bound to be missing for some taxa. We demonstrated the applicability and accuracy of our method on simulated datasets and by identifying jumps for body size evolution in Anolis lizards and brain shapes of New World Monkeys. In both systems, the well-supported jumps occurred on stem lineages of clades that differ in terms of diet, locomotion, group size or foraging strategy (see [START_REF] Aristide | Brain shape convergence in the adaptive radiation of New World monkeys[END_REF] for a detailed discussion) supporting the Simpsonian hypothesis.

Interpretation Issues

We emphasize that the interpretation of α is a matter of discussion. We introduced the scOU in terms of adaptive evolution with a selection strength α on the tree. However, the equivalency between OU and BM on a distorted tree suggests that α can also be seen as a "phylogenetic signal" parameter, like Pagel's λ [START_REF] Pagel | Inferring the historical patterns of biological evolution[END_REF]. When α is small, i (α) i so that branch lengths are unchanged and the phylogenetic variance is preserved. At the other end of the spectrum, when α is large, i (α) 0 for inner branches and the rescaled tree behaves almost like a star tree. However and unlike Pagel's λ, α also dictates how shifts in the optima in the original OU (∆ OU ) are transformed into shifts in the traits values in the rescaled BM (∆ BM (α)). For small α, recall to the optima is weak and shifts on the optima affect the traits values minimally (∆ BM (α) 0). By contrast, for large α, the recall is strong and shifts on the optima are instantaneously passed on to the traits values (∆ BM (α) ∆ OU ). Note however that in both cases, the topology is never lost: a shift, no matter how small its amplitude or how short the branch it occurs on, always affects the same species.

Note that if we observed traits values at some ancestral nodes (e.g. from the fossil record), the equivalency between BM and OU would break down: α would recover its strict interpretation as selection strength. On non-ultrametric trees, our inference strategy does not benefit from the computational trick to speed up the M step. Similarly to the univariate case, we could write a generalized EM algorithm to handle this situation. In Bastide et al. (2017b), we used a lasso-based heuristic to raise, if not maximize, the objective function at the M step. It worked quite well, but was much slower. This approach could be extended to the multivariate setting, although with impaired computational burden. Note also that some shifts configuration that are not identifiable in the absence of fossil data become distinguishable with the addition of fossil data. This affects our model selection criterion, which relies on the number of distinct identifiable solutions. Computing this number on a non-ultrametric tree for an OU remains an open problem, and is probably highly dependent on the topology of the tree.

Noncausal Correlations

1ou, SURFACE and PhylogeneticEM make many simplifying assumptions to achieve tractable models. Chief among them is the assumption that A is diagonal. While 1ou and SURFACE both assume independent traits, PhylogeneticEM can handle correlated traits through non-diagonal variance matrix R. We warn the reader that correlations encoded by R are not causal and only capture coordinated and non selective traits evolution: i.e. when arm length increases, so does leg length. In order to capture evolution of trait i in response to changes in trait j (i.e. when arm length strays away from its optimal value, does leg length move away or toward its own optimum) one should rather look at the value of A ij , as was recently pointed out [START_REF] Reitan | Phenotypic evolution studied by layered stochastic differential equations[END_REF][START_REF] Liow | Ecological interactions on macroevolutionary time scales: clams and brachiopods are more than ships that pass in the night[END_REF][START_REF] Manceau | A unifying comparative phylogenetic framework including traits coevolving across interacting lineages[END_REF]. Our simplifying assumptions are justified by various considerations: our focus on inference of shifts rather than proper estimation of A and R, simulations showing that shift detection is robust to moderate values of off-diagonal terms in A, difficulties to simultaneously estimate α and shifts even in the univariate case [START_REF] Butler | Phylogenetic Comparative Analysis: A Modeling Approach for Adaptive Evolution[END_REF], and computational gain achieved by considering scalar or diagonal A. They also suggest that if the focus is on causal correlation in the presence of shifts, a two-step strategy that first detects shifts using a crude but robust model, then includes those shifts in a more complex model, may achieve good performance.

The other simplifying assumption we made is that all traits shift at the same time. It makes formal analysis of identifiability issues and selection of the number of shifts similar to the univariate case, previously studied in Bastide et al. (2017b). The assumption is likely to be false in practice, however. Asynchronous shifts are an interesting extension of the model. An ambitious framework would be to build from the ground up a model that allows for different shifts on different traits. It would have to deal with the combinatorial complexity induced by asynchronous shifts, and to use a different selection criterion for the number of shifts. A less ambitious but more pragmatic approach would be a postprocessing of the shifts to select, for each shift, the traits that actually jumped. This would require derivation of confidence intervals for the shift values. Finally, and unlike SURFACE and new version v1.40 of 1ou, our model excludes convergent evolution. This limitation is shared with other shift detection methods such as bayou (Uyeda & Harmon, 2014) in the univariate case. This exclusion simplifies formal analysis and allows us to borrow from the framework of convex characters on a tree developed in [START_REF] Semple | Phylogenetics[END_REF] but is also likely to be false in practice. A straightforward extension of our method to detect convergence relies again on postprocessing of the shifts: the inferred optimal value of a trait after a shift can be tested to assess whether or not it is different from previously inferred optimal values and warrants a regime of its own.

Nature of the jumps

We model shifts as instantaneous and immediately following speciation events, like in the punctuated equilibrium theory of [START_REF] Eldredge | Punctuated equilibria: an alternative to phyletic gradualism[END_REF]. We don't argue that this is necessary the case. Selection and drift can reasonably be seen as instantaneous over macroevolutionary timescales but by no means over microevolutionary timescales. There is very strong evidence, for example in peppered moths [START_REF] Cook | Selective bird predation on the peppered moth: the last experiment of Michael Majerus[END_REF], that rapid adaptation can happen even in the absence of speciation. However our model does not allow us to distinguish between many small jumps distributed across a branch, one big jump anywhere on that branch and one big jump immediately following speciation, and therefore between punctuated or Simpsonian evolution.

C = (1 T n C -1 1 n ) -1 1 T n C -1
, we have that ȲT = CY, and āT = E ȲT = Ca. Denote by N C -1 : R n×p → R p 2 the function that to a n × p matrix A associates the p × p matrix A T C -1 A. We get:

(n -1)E R = E N C -1 Y -1 n ȲT = E N C -1 (Y -a) + (a -1 n āT ) + (1 n āT -1 n ȲT ) = E N C -1 (I -1 n C)(Y -a) + (a -1 n āT ) = E N C -1 (I -1 n C)(Y -a) + N C -1 a -1 n āT
where the two double products cancel out, as E [Y] = a. But, for any non-singular symmetric matrix H, we have:

E (Y -a) T H -1 (Y -a) = 1≤i,j≤n [H -1 ] ij E (Y i -a i )(Y j -a j ) T = 1≤i,j≤n [H -1 ] ij C ij R = tr(H -1 C)R
Hence, applying this formula with

H -1 = (I -1 n C) T C -1 (I -1 n C) = C -1 -C -1
1 n C, some straightforward matrix algebra manipulations give us:

(n -1)E R = (n -1)R + (a -1 n āT ) T C -1 (a -1 n āT )
which is the result stated in the text, with G = a -

1 n āT = (I n -(1 T n C -1 1 n ) -1 1 n 1 T n C -1 )a.

3.B PhylogeneticEM case study: New World Monkeys

In this section, we demonstrate the basic use of the R package PhylogeneticEM for the analysis of the New World Monkeys dataset [START_REF] Aristide | Brain shape convergence in the adaptive radiation of New World monkeys[END_REF].

3.B.1 Loading and Plotting the data

The data have been embedded in the R package PhylogeneticEM, to be loaded easily.

The traits can be plotted on the tree thanks to the function plot applied to a void params process object with dimension 2 (Fig. 3.B.1).

library(PhylogeneticEM) data(monkeys) plot(params_BM(p=2), data = monkeys$dat, phylo = monkeys$phy, show.tip.label = TRUE)

This plot function inherits from most of the optional arguments of the popular ape plot function (here for instance, the optional argument show.tip.label is used). Many other graphical parameters can be set by the user, so as to control the output of the function. All the results showed in the main text were produced by the package's plotting function. The two traits are represented on the right, each with its own scale. Plotting the data on the tree before analyzing it allows us to spot potential errors or outliers.

3.B.2 Analyzing the data

The automatic shift detection is done using function PhyloEM. We show below how the function can be called, using an scOU process (with stationary root, the default), for a maximum number of shifts equal to 10, on an automatically chosen grid with 4 values for the selection strength α, and parallelized on 2 cores. These parameters were chosen only to demonstrate the function, for this example analysis would run in about one minute. Different parameters were used to obtain the results below and in the main text. There are many more options available to guide the analysis, all described in the manual entry of the function. The result is stored in an object of class PhyloEM, which has several extractors available (see manual). By default, the plot function draws the maximum likelihood function selected by the method (Fig. 3 The solution showed in the main text (Fig. 3.5.1) has 5 shifts, instead of 4. It can be plotted using the extractor params process, which extracts some inferred parameters from an object of class PhyloEM. params_5 <-params_process(res, K = 5) plot(res, params = params_5)

3.B.3 Plotting Equivalent Solutions

The previous call actually results in a warning being issued: "Warning in params process.PhyloEM(res, K = 5): There are several equivalent solutions for this shift position."

Indeed, as mentioned in the main text, the solution with 5 shifts has three equivalent shift allocations on the branches. These solutions can be found and plotted thanks to the function equivalent shifts, that returns an object that can be visualized (Fig. 3.B.3).

eq_shifts <-equivalent_shifts(monkeys$phy, params_5) plot(eq_shifts, show_shifts_values = FALSE, shifts_cex = 0.5) By default, the shifts values for the first trait is showed for all equivalent solutions. Black is always reserved to the "ancestral state", and the value λ = β 0 = µ of the ancestral optimal value is shown at the root. Here, the three equivalent solutions are quite straightforward, as one configuration has two shifts on sister edges. Note that the clustering of the species at the tips of the tree remains unchanged, while the historic scenario of the adaptive shifts is slightly altered. This ambiguity is inherent to the data. More information to resolve this ambiguity can only come from a prior distribution on shift values, or ideally from fossil data sampled in the right region of the tree.

3.C EM Inference

This section provides the update formulas for the EM algorithm in Section 3.2.5. Throughout this section, the superscript h refers to the current iteration index, e.g. θ (h) stands for the vector of parameters estimate at iteration h:

θ (h) = (µ (h) , ∆ (h) , R (h) , Γ (h)
). We denote further by X the N × p matrix of the traits at all the nodes of the tree, that contains both Z and Y. In these derivations, nodes are numbered in a preorder, such that the root comes first: ρ = 1, the internal nodes are numbered from 1 to m, and the tips from m + 1 to N = m + n.

Conditional Expectation of the Complete Likelihood. The EM algorithm mainly deals with E[log p θ (X) Y d ], where Y d is the vector of the observed tips data (that might be missing some values). In our case we have that

-2E log p θ (X) Y d = p(m + n) log 2π + p m+n j=2 log j + log |Γ| + tr Γ -1 Var X 1 Y d + E X 1 Y d -µ 2 Γ -1 +(m + n -1) log |R| + m+n j=2 -1 j tr R -1 Var X j -X pa(j) Y d + m+n j=2 -1 j E X j -X pa(j) Y d -∆ j 2 R -1 .
(3.5)

3.C.1 M step

At the M step, the parameters are updated as the minimizers of (3.5) evaluated with the conditional moments of the hidden variables given Y d . We get the following updates.

Root Parameters.

µ (h+1) = E (h) X 1 Y d , Γ (h+1) = Var (h) X 1 Y d . (3.6)
where the conditional moments are obtained as part of the E step, see Equation (3.8). Notations E (h) and Var (h) denote the moments taken with the law defined by current parameters θ (h) .

Rate Matrix.

(m + n -1)R (h+1) = m+n j=2 -1 j Var (h) X j -X pa(j) Y d + -1 j E (h) X j -X pa(j) Y d -∆ (h+1)j • E (h) X j -X pa(j) Y d -∆ (h+1)j T .
(3.7)

Optimal Shift Location. Only the last term of (3.5) depends on the shifts so we have to minimize the sum of costs to find ∆ (h+1) :

C (h) (∆) = m+n j=2 C (h) j (∆) with C (h) j (∆) = -1 j E (h) X j -X pa(j) Y d -∆ j 2 (R (h) ) -1 .
This minimization can be achieved using the same algorithm as in the univariate case (Bastide et al., 2017b) to get the optimal shifts allocations and values. Said algorithm essentially sorts the branches in decreasing order of C (h) j (∆) and assigns shifts to the first K branches.

3.C.2 E step

The aim of the E step is to compute the moments of the completed dataset given the observed traits at the tips, namely:

E j = E X j Y d , V j = Var X j Y d , C j,pa(j) = Cov X j ; X pa(j) Y d (3.8)
where we dropped the dependency in θ (h) for the sake of legibility, but all these moments are indeed taken with the laws given by the current parameters. We do so thanks to an upward-downward recursion on the tree, as described below. This algorithm can apply to a broad classes of Gaussian processes, provided that the moments of the traits at a child node are of the form:

∀j ∈ 2 , m + n ,        E X j X pa(j) = m j (X pa(j) ) = Q j X pa(j) + r j Var X j X pa(j) = Σ j (3.9)
For a BM, we get Q j = I p , r j = ∆ j and Σ j = j R.

A multivariate OU could also be handled, with:

Q j = e -A j , r j = (I p -e -A j )β j and Σ j = Γ -e -A j Γe -A T j .
Although we do not use these last formulas here (thanks to the equivalence between OU and BM in our setting), they are implemented in PhylogeneticEM, and could be readily used in an extension of the method to non-ultrametric trees with fossil taxa. To properly handle missing data in a unified framework, we first re-define ad hoc inversion and determinant operations that allow us to easily write the degenerated Gaussian likelihood that appears along the way.

Missing data. For a multivariate trait observed at node i, define the application f d i :

R p×p → R d i ×d i that, given a matrix, returns the matrix with only rows and columns corresponding to observed traits. Define also the "pseudo-inverse" f -1 d i : R d i ×d i → R p×p that put the observed traits back into their places, and fills the un-defined lines and columns with zeros. This allows us to define a "low-dimensional inverse" as:

[S] -1 ld = f -1 d i f d i (S) -1 , ∀S ∈ R p×p
for all S such that f d i (S) is invertible. We also define a "low dimensional determinant", as:

[S] -1 ld = f d i (S) -1 , ∀S ∈ R p×p .
These conventions amount to taking infinite values for the variance-covariance terms of non-observed traits. This allows us to write the following:

(2π) (p-d)/2 Φ m,S (x) = Φ f d (m),f d (S) (f d (x)).
where Φ m,S denotes the density of a multivariate Gaussian, with expectation vector m and variance matrix S. That is, we write the density of a d-dimensional Gaussian as the density of a p-dimensional one, but with the exact same likelihood value, up to a normalizing constant (2π) (p-d)/2 . If d = 0 (no data at one tip), then [S] -1 ld is a matrix of 0, and we take by convention

[S] -1 ld = 1, so that Φ f d (m),f d (S) (f d (x)) = 1.
Upward Recursion. For a given node j in the tree, we denote by j Y d the set of all traits observed at all the tips below node j. The aim of the upward recursion is to compute the Gaussian pdf f j Y d | X j ( j Y d ; a) of j Y d X j , which we write as proportional to a Gaussian density in a:

f j Y d | X j ( j Y d ; a) = A j ( j Y d )Φ M j ( j Y d ),S j ( j Y d ) (a).
Initialization: For each tip i, the observed values (Y d ) i given the vector of values Y i follow a Dirac distribution:

∀i ∈ 1 , n , f (Y d ) i | Y i ((Y d ) i ; a) = δ (Y d ) i (a).
We can express this in the correct format:

∀i ∈ 1 , n , f (Y d ) i | Y i ((Y d ) i ; a) = (2π) (p-d)/2 Φ Y i ,0 (a)
but taking the "low dimensional" inverses and determinants defined above.

Propagation: The upward recursion formulas result from the standard properties of the conditional distribution of a multivariate Gaussian distribution plus the fact that L daughters of a given node X j are conditionally independent so

f j Y d | X j ( j Y d ; a) = L =1 f j Y d | X j ( j Y d ; a).
We get

                                                                 S j ( j Y d ) =        L =1 Q T j (S j ( j Y d ) + Σ j ) -1 Q j        -1 M j ( j Y d ) = S j ( j Y d ) L =1 Q T j (S j ( j Y d ) + Σ j ) -1 (M j ( j Y d ) -r j ) log A j ( j Y d ) = - (L -1)p 2 log(2π) + 1 2 log S j ( j Y d ) + L =1 log A j ( j Y d ) - 1 2 log S j ( j Y d ) + Σ j - 1 2 L =1 (M j ( j Y d ) -r j ) T (S j ( j Y d ) + Σ j ) -1 (M j ( j Y d ) -r j ) + 1 2 M j ( j Y d ) T S j ( j Y d ) -1 M j ( j Y d )
where we keep track of the log of the constant A j , for numerical accuracy. Remark that we only need to handle the infinite terms properly as described above, using the "low dimensional" inverses and determinants when needed. These terms will disappear as we go up to a node that has at least one tip with some observation for this particular trait. In the pathological case where a trait is never observed, the corresponding term remains infinite throughout the recursion, and hence does not bring any information as to the value of that trait, and does not change the likelihood. The variance of a root non-observed trait is then just the one put a priori in Γ (see below).

Root node and likelihood: Once at the root, we have f

Y d | X 1 (Y d ; a)
, which is the likelihood of the observations given the root state X 1 = a, and we write:

f X 1 | Y d (a; Y d ) ∝ f Y d | X 1 (Y d ; a)f X 1 (a)
which gives

         Var X 1 Y d = Γ -1 + S 1 (Y d ) -1 -1 E X 1 Y d = Var X 1 Y d Γ -1 µ + S 1 (Y d ) -1 M 1 (Y) .
Downward Recursion. We now derive a recursion that goes from the root back to the tips to compute the conditional moments required to evaluate (3.5). Going down the tree, we need to compute, for each node X j , 2 ≤ j ≤ m, E j , V j and C j,pa(j) as in (3.8).

(additionally conditioning on X 1 if the root is fixed).

Initialization: The initialization of the downward is given by the last step of the upward.

If the root is random, we have

             V 1 = Var X 1 Y d = Γ -1 + S 1 (Y d ) -1 -1 E 1 = E X 1 Y d = Var X 1 Y d Γ -1 µ + S 1 (Y d ) -1 M 1 (Y) C 1,pa(1) = NA
whereas, if we work conditionally to the root, we have

V 1 = Var X 1 Y d , X 1 = 0, E 1 = E X 1 Y d , X 1 = µ and C 1,pa(1) = NA. Propagation: We have f X pa(j) ,X j | Y d (a, b; Y d ) = f X pa(j) | Y d (a; Y)f X j | X pa(j) ,Y d (b; a, Y d )
We know the first term from the recurrence, and we can compute the second term thanks to the upward step:

f X j | X pa(j) ,Y d (b; a, Y d ) = f X j | X pa(j) , j Y d (b; a, j Y d ) ∝ f X j | X pa(j) (b; a)f j Y d | X j ( j Y d ; b) As j Y d X j ∼ N M j ( j Y d ), S j ( j Y d
) and X j X pa(j) ∼ N m j (X pa(j) ), Σ j , we get

X j X pa(j) , Y d ∼ N mj (X pa(j) ), Σj with                                                Σj = S j ( j Y d ) -1 + Σ -1 j -1 = S j ( j Y d ) S j ( j Y d ) + Σ j -1 Σ j = Σ j S j ( j Y d ) + Σ j -1 S j ( j Y d ) mj (X pa(j) ) = Σj S j ( j Y d ) -1 M j ( j Y d ) + Σ -1 j m j (X pa(j) ) = S j ( j Y d ) S j ( j Y d ) + Σ j -1 Q j Qj X pa(j) + S j ( j Y d ) S j ( j Y d ) + Σ j -1 r j + Σ j S j ( j Y d ) + Σ j -1 M j ( j Y d ) rj Hence: f X j | X pa(j) ,Y d (b; a, Y d ) ∝ exp - 1 2 (b -mj (a)) T Σ-1 j (b -mj (a))
And, as

X j X pa(j) j Y d ∼ N E j E pa(j) , V j C j,pa(j) C T j,pa(j) V pa(j)
, by Gaussian conditioning, we get, for any a:

       mj (a) = E j + C j,pa(j) V -1 pa(j) (a -E pa(j) ) Σj = V j -C j,pa(j) V -1 pa(j) C T j,pa(j)
From this we get:

C j,pa(j) = Qj V pa(j) , E j = rj + Qj E pa(j) , V j = Σj + Qj V pa(j) QT j .
And, finally:

                 C j,pa(j) = S j ( j Y d ) S j ( j Y d ) + Σ j -1 Q j V pa(j) E j = S j ( j Y d ) S j ( j Y d ) + Σ j -1 (Q j E pa(j) + r j ) + Σ j S j ( j Y d ) + Σ j -1 M j ( j Y d ) V j = S j ( j Y d ) S j ( j Y d ) + Σ j -1 Σ j + Q j V pa(j) Q T j S j ( j Y d ) + Σ j -1 S j ( j Y d )
Missing Data: In presence of missing data, the downward formulas read

             C j,pa(j) = Σj Σ -1 j Q j V pa(j) E j = Σj Σ -1 j (Q j E pa(j) + r j ) + Σj S j ( j Y d ) -1 M j ( j Y d ) V j = Σj I p + Σ -1 j Q j V pa(j) Q T j Σ -1 j Σj )
where Σ-1 j = S j ( j Y d ) -1 +Σ -1 j can be is computed using the "low dimensional inverse" defined earlier for S j ( j Y d ), if needed.

Remark that theses formulas involve the inversion of two matrices (Σ j and Σ-1 j ), each of dimension p (typically small), which is not computationally intensive.

3.C.3 EM Initialization

Because it is only guaranteed to converge to a local optimum, the EM algorithm is highly sensitive to its starting point. As consequence, it needs to be provided with good initial guesses for the shifts positions and value, as well as the variance matrix R. Initial values are determined as follows:

1. Do a lasso regression, assuming all traits are independent, choosing a penalty so that K shifts are found.

2. Find the groups of tips created by those shifts, and center each group by its empirical mean.

3. Use the centered data to estimate an empirical variance matrix. This is done using the Minimum Covariance Determinant (MCD) method, with function covMcd from package robustbase [START_REF] Rousseeuw | robustbase: Basic Robust Statistics[END_REF].

4. Use this estimated matrix to correct for correlations (see paragraph below), before running a lasso again.

5. For this second lasso, choose a penalty that selects for K + K lag shifts, with K lag a fixed value (default to 5). Then, using a Gauss-lasso procedure, select the best K shifts (in term of log-likelihood) among those.

This last step can be combinatorially intensive. To keep it fast, we bound the number of trials. It has proven to enhance the results of the algorithm substantially.

Correcting for Correlations. Using the same notations as in Section 3.2, the linear model (3.2) for the BM can be written as:

vec(Y) ∼ N (vec(T∆), R ⊗ C)
To apply the standard group-lasso (point 4), the coefficients of Y must be independent, and identically distributed. Assume that we known R the rate matrix. We can then de-correlate Y by combining the equations of Section 3.2.5 (model selection) and Section 3.3.1. Indeed, we take the Cholesky transform of

C = C c C T c and R = R c R T c . Then, as R ⊗ C = (R c ⊗ C c )(R c ⊗ C c ) T and (R c ⊗ C c ) -1 = R c -1 ⊗ C c -1 (see proposition 1.B.2), we get: vec(C c -1 Y(R c -1 ) T ) ∼ N vec(C c -1 T∆(R c -1 ) T ), I np .
Hence, using the standard group lasso on C c -1 Y(R c -1 ) T , we get an estimation of the non-zero lines of ∆(R c -1 ) T , which are the same as the non-zero lines of ∆.

During point 4, we don't actually know R, but we have an estimation of it, so that we can approximately decorrelate the observations using the transformation above.

3.C.4 Grid on α

The inference presented above works for the rescaled BM, when the parameter α is supposed to be known. In practice, this parameter needs to be estimated. One simple way to do that is to use a grid on α. For each value on the grid, one can find an associated estimator, and then find the maximum likelihood estimator of the parameters by taking the best likelihood, for each number of shifts K. For instance, we plot below (Fig. 3.C.1) the likelihood profile in K for 30 α values on a grid, for the New World Monkey dataset [START_REF] Aristide | Brain shape convergence in the adaptive radiation of New World monkeys[END_REF].

This grid of α values can be provided by the user, depending on some a priori knowledge she might have of the problem at hand. If no grid is provided, one is automatically computed, with n α values, evenly spaced on a log scale ranging between α min and α max . Those extrema values are chosen in the following way. α min The minimum value is chosen so that the maximum phylogenetic half-life (t 1/2 = ln(2)/α) is equal to A ln(2)h, where h is the height of the tree, and A is a constant, by default equal to 3. This ensures that the lowest α makes for a phylogenetic half-life approximately two times as high as the tree. Lower values of α would make the process looking too much like a BM.

α max The maximum value of α is chosen so that the correlations between tips is bounded by e -B/2 , with B a constant by default equal to 2. This is obtained by noting that the correlation between two tips i and j for a given trait k is given by (for a stationary root):

Cov Y ik ; Y jk = R kk 2α e -2αd ij R kk 2α R kk 2α = e -2αd ij ≤ e -2αd min
where d min is the minimum phylogenetic distance between two tips. Hence we choose α max = B/(2d min ). Denote by I p the identity matrix of size p, J p = 1 T 1 the matrix filled with ones, and S p = Diag(s -(p+1)/2+q ; 1 ≤ q ≤ p) (so that S p = 1). We consider the four following models:

3.D Simulations Appendices

Model A: A = αI p and R = σ 2 I p Model B: A = αI p and R = R r d = σ 2 (I p + r d (J p -I p )) Model C: A = αS p and R = σ 2 S p Model D: A = α(I p + r s (J p -I p )) and R = σ 2
λ I p The general formula for a Kullback divergence between two multivariate Gaussian distributions with means µ i and variances V i (i ∈ {1, 2}) is:

2K [N 1 ; N 2 ] = tr(V -1 2 V 1 ) + (µ 2 -µ 1 ) T V -1 2 (µ 2 -µ 1 ) -np + ln |V 2 | |V 1 |
We assume that the root is in the stationary state. From the general formula for a multivariate OU, we derive the form of the variances for these four models [START_REF] Bartoszek | A phylogenetic comparative method for studying multivariate adaptation[END_REF][START_REF] Clavel | mvmorph : an r package for fitting multivariate evolutionary models to morphometric data[END_REF]:

General Formula: V (i,j) = P 1 λ q +λ r e -λ q (t i -t ij ) e -λ r (t j -t ij )
1≤q,r≤p P -1 RP -T P T , where P is the orthogonal matrix of diagonalization of A, associated with eigenvalues (λ 1 , . . . , λ p ).

Model A:

V A = σ 2 2α M α ⊗ I p with M α = (e -αd ij ) 1≤i≤j≤n Model B: V B = σ 2 2α M α ⊗ R r d Model C: V (i,j) C = σ 2 2α Diag e -α(S p ) qq d ij ; 1 ≤ q ≤ p Model D: V (i,j) D = σ 2 2λα P Diag 1 1-r s e -α(1-r s )d ij , 1 1-r s e -α(1-r s )d ij , 1 1-r s e -α(1-r s )d ij , 1 1+3r s e -α(1+3r s )d ij P T
For model C, taking R = σ 2 S p ensures that the variances at the tips for all the (independent) traits are equal to γ 2 = σ 2 2α . For model D, the characteristic polynomial of matrix 1 α A is χ(X) = (X+r s -1) 3 (X-3r s -1), so we wrote A = αP Diag (1r s , 1r s , 1r s , 1 + 3r s ) P T . This leads to a variance at the tips of σ 2 2αλ P Diag 1 1-r s , 1 1-r s , 1 1-r s , 1 1+3r s P T . By computing this matrix product (easy linear algebra formula), we find that P Diag

1 1-r s , 1 1-r s , 1 1-r s , 1 1+3r s P T = (λ -κ)I p + κJ p , with λ = 1+(p-2)r s (1-r s )(1+(p-1)r s ) and κ = - r s
(1-r s )(1+(p-1)r s ) . Dividing the variance matrix by a factor λ hence ensures that the diagonal variances at the tips are still equal to γ 2 = σ 2 2α . We can then express the Kullback distance of models B, C and D to model A, using the general formula:

2K [i; A] = tr(V -1 A V i ) -np + ln |V A | |V i | + (T ⊗ I p )[W(A A ) -W(A i )] vec(∆ T ) V A -1 = 2α σ 2 tr((M -1 α ⊗ I p )V i ) -np + np ln σ 2 2α + p ln |M α | -ln |V i | + (T ⊗ I p )[W(A A ) -W(A i )] vec(∆ T ) V A -1
For K [B; A], we can get a closed formula that does not depend on the topology (the expectations term cancels out):

2K [B; A] = n ln[(1 -r) 3 (1 + 3r)]
For the two other distances, there are no such nice simplified formula, and the result depends on the topology (even when there are no shifts). To get an idea of the distance when there are no shifts, we computed it on 100 randomly generated trees, and took the mean. With shifts, we computed the distances for the trees and shift positions chosen and shown above.

3.D.2 Note on the ARI [START_REF] Hubert | Comparing partitions[END_REF] Partitions. Let S be a set with n elements, and U , V two different partitions of S, with respectively R and C groups. Denote by n ij the number of elements of S that are both in groups i ∈ 1 , R of U and j ∈ 1 , C of V , and by

n i• = C j=1 n ij (respectively, n j• = R i=1 n ij ) the number of elements of S that are in group i ∈ 1 , R of U (resp. j ∈ 1 , C of V ).
Rand Index. We further define: a the number of pairs of S that are in the same groups in both partitions U and V ,

a = R i=1 C j=1 n ij 2 b the number of pairs of S that are in different groups in both partitions U and V , b = n 2 -         a +        R i=1 n i• 2 -a        +         C j=1 n •j 2 -a                 = n 2 + a - R i=1 n i• 2 - C j=1 n •j 2
Then the Rand index is defined as the number of agreeing pairs on the total number of pairs:

Rand = a + b n 2
Adjusted Rand Index. Assume that the null model is a generalized hypergeometric models, where the partitions and the number of elements in each group are fixed (i.e. the n i• and n •j are fixed), and the element randomly distributed among them. Then:

E n ij 2 = n i• 2 n •j 2 / n 2
The ARI is then defined as (1 is the maximum value of the Rand index):

ARI = Rand -E [Rand] 1 -E [Rand]
which can be re-written as:

ARI = R i=1 C j=1 n ij 2 -R i=1 n i• 2 C j=1 n •j 2 / n 2 1 2 R i=1 n i• 2 + C j=1 n •j 2 -R i=1 n i• 2 C j=1 n •j 2 / n 2
One Class Partition. Assume that R = 1, i.e. that one of the partition has only one class. Then:

R i=1 C j=1 n ij 2 = C j=1 n 1j 2 = C j=1 n •j 2 and R i=1 n i• 2 C j=1 n •j 2 = n 1• 2 C j=1 n •j 2 = n 2 C j=1 n •j 2
so that ARI = 0. Hence, if one of the true solution or the estimated solution has no shift, then the ARI is automatically equal to 0.

3.D.3 Supplementary Figures

Sensitivity / Precision. Because only the clustering of the tips induced by the shifts, and not their exact position on the branches of the tree, are identifiable, we used the ARI, rather than sensitivity and precision, to assess methods of shift detection. With this caveat in mind, we plot these quantities here for the interested reader. To do that, we removed the 6.53% of solutions that were not identifiable in the results of the methods. These graphs confirm our conclusions drawn in the main text, with PhylogeneticEM, more conservative, having a better precision, along with a similar sensitivity than 1ou. It is interesting to note that, even when the model is violated for PhylogeneticEM, the methods keeps a better or similar precision (see e.g. Model C in Fig. 3.D.3).

Introduction: Phylogenetic Networks

Biological Insights

In the previous chapters of this thesis, we assumed that the relationships between species was well represented by a phylogenetic tree. However, a tree can only represent the vertical transmission of the genetic material, from an ancestral species to its offspring. This is the most common mechanism, but horizontal transmission, between contemporary species, is also possible for some organisms. The main events inducing horizontal transmission of genes are hybridization and Horizontal Gene Transfer.

Hybridization happens when two distinct species produce a fertile new species, that inherits its genetic material from both parents, in varying proportions. It is sometimes associated with chromosomal doubling (allopolyploidy). Hybridization is known to be quite common for plant species, but also for animal species (25% of plant species, and 10% of animal species, are known to hybridize with at least one other species, [START_REF] Mallet | Hybridization as an invasion of the genome[END_REF]. It is thought to be an important driver of genetic diversity and evolutionary innovation [START_REF] Mallet | Hybrid speciation[END_REF].

Horizontal Gene Transfer is common in bacteria and archea, and have recently been hypothesized to also play a role in the evolution of multicellular organisms [START_REF] Soucy | Horizontal gene transfer: building the web of life[END_REF]. It relies on many mechanisms [START_REF] Soucy | Horizontal gene transfer: building the web of life[END_REF], that can involve direct transmission between organisms through a contact (conjugation), assimilation of exogenous DNA from the environment (transformation) or transmission through a predatory vector, such as a virus (transduction).

Because they happen quite frequently, and because they are important drivers of diversification and trait evolution, these events cannot be ignored. Adding some horizontal edges, they transform the usual phylogenetic tree into a phylogenetic network. In the next two sections, we give a formal definition of a phylogenetic network, and browse the main statistical methods that aim at inferring them.

Formal Definition and Properties

We only consider here rooted phylogenetic networks, and use the definition given in Solís-Lemus & Ané (2016).

Definition 4.1.1 (Rooted Binary Directed Network). A reticulate network N = (V , E) is a connected directed acyclic graph with vertices V = {ρ} ∪ V L ∪ V H ∪ V T and edges E = E H ∪ E T such that:
the root ρ has an in-degree 0, and out-degree 2; vertices in V L (leaves) have an in-degree 1, and out-degree 0; vertices in V T (tree nodes) have an in-degree 1 ant out-degree 2; vertices in V H (hybrid nodes) have an in-degree 2 and out-degree 1;

edges in E T (tree branches) have a tree node child; Finally, as mentioned above, a hybrid species inherits its genetic material from its two parents with given proportions, that might vary from one case to another. These proportions are represented by an extra parameter γ, that represents inheritance probabilities.

Definition 4.1.5 (Weighted Network). A weighted phylogenetic network (N , γ) is a phylogenetic network where each edge e ∈ E is weighted by an inheritance probability factor γ e , that is such that:

for any edge e ∈ E, γ e ∈ [0 , 1];

for any tree edge e ∈ E T , γ e = 1;

for any hybrid node with parents edges e a and e b , γ e a + γ e b = 1.

X 13 X 12 X 11 X 9 X 8 X 2 X 3 X 7 X 1
Hybrid Branch : γ 6a = 0.3

γ 6b = 0.7 X 10 X 6 X 5 X 4
Tree Branch : γ 2 = 1 l 4 Figure 4.1.2 -A dated weighted binary rooted network with six tips and one hybridization event. Inheritance probabilities at the hybridization event are γ 6a and γ 6b , with γ 6a + γ 6b = 1. Inheritance probabilities on tree branches are equal to 1.

Inference

Gene Trees and Species Tree. The methods for tree inference we presented in Section 1.3.4 mostly rely on models that are well suited for nonrecombined loci of the genome, i.e. parts of genes that form a block that was not subject to recombination. The genetic history of such a locus can always be represented as a tree [START_REF] Maddison | Gene Trees in Species Trees[END_REF]. In a given genetic sequence, we can find many of those nonrecombined loci, and we can infer a so-called gene tree for each of them. All those trees are unlikely to be exactly concordant. The species tree (or phylogenetic tree) can be seen as a hull that constrains the form of all the gene trees. It represents the branching pattern induced by speciation events [START_REF] Maddison | Gene Trees in Species Trees[END_REF].

This can be seen using the coalescent theory [START_REF] Kingman | The coalescent[END_REF], that can describe the probability distribution of a gene tree. In its simplest form, this model, that is backward in time (from the tips to the root), allows for coalescence events to happen with an exponential law (see e.g. [START_REF] Wakeley | Coalescent Theory: An Introduction[END_REF], for an introduction). The genes trees are assumed to follow such a process, but constrained by the species tree, as two lineages in two different branches of the species tree cannot merge. See Incomplete Lineage Sorting (ILS). One source of discordance between the gene trees and the species tree is Incomplete Lineage Sorting (ILS, also referred to as deep coalescence). As presented in Figure 4.1.3, this phenomenon happens when two lineages do not coalesce in their most recent common ancestral branch, but instead in an older branch where a third lineage has already joined them. This is perfectly explained by the coalescent theory, and can produce some incongruent gene trees. Given a species tree, the gene tree distribution under this coalescent process has been derived by [START_REF] Degnan | Gene tree distributions under the coalescent process[END_REF].

Phylogenetic Networks and ILS. If the species are not related by a phylogenetic tree, but by a phylogenetic network instead, the same model can be used. However, its combinatorial complexity explodes with the number of hybrids, as gene trees can "turn right or left" at each reticulation. See Both ILS and reticulation events are hence a source of discordance among gene trees. Ignoring one source or another leads to inconsistent inferences [START_REF] Kubatko | Identifying hybridization events in the presence of coalescence via model selection[END_REF]Solís-Lemus et al., 2016). Similarly to the tree case, the gene tree distribution under this coalescent process given a species network can be derived [START_REF] Kubatko | Identifying hybridization events in the presence of coalescence via model selection[END_REF].

Phylogenetic Network Inference. From the model presented above, it is possible to design a maximum likelihood method to infer a species phylogenetic network from a number of gene trees. A rigorous framework has been derived by [START_REF] Yu | The Probability of a Gene Tree Topology within a Phylogenetic Network with Applications to Hybridization Detection[END_REF][START_REF] Yu | Maximum likelihood inference of reticulate evolutionary histories[END_REF], and implemented in the stand-alone software PhyloNet. Because of the combinatorial complexity of the problem, it is however difficult to infer trees with more than 10 tips, and 4 hybridization events (Solís-Lemus & Ané, 2016). To tackle this computational issue, Solís-Lemus & Ané (2016) proposed a pseudo-likelihood approach, computed assuming that all the quartets are independent from one another. [START_REF] Yu | A maximum pseudo-likelihood approach for phylogenetic networks[END_REF] described a similar approach, but based on triplets. These relaxations improve the size of the datasets that can be analysed, but the number of hybridization events, as well as the number of species, that can be dealt with is still quite limited (in their article, Solís-Lemus & Ané 2016 deal with networks with at most 15 species, and 3 hybridization events).

Dating. In section 1.3.3, we saw that expressing the branch length in real elapsed time was a difficult problem for phylogenetic trees. As expected, this problem does not get easier for phylogenetic networks, and is in fact still an open problem. This will hamper our attempts to apply the models of continuous traits evolution that we describe in the remaining of the section to a biological dataset.

Continuous Trait Evolution on a Network

As in previous chapters, we will assume from now on that the network is known, along with all branch lengths and inheritance probabilities. Given that, as we saw in the previous section, the state of the art methods are still quite limited, this is a strong assumption, but we are confident that these kind of phylogenetic networks will improve and get larger in the coming years.

To model the evolution of a trait on the network, we adopt a framework similar to the one presented in the introductory chapter (Section 1.2.1). The only difference is that, in addition to a process describing the dynamic of the trait and to the split rule after speciation, we need here an extra merging rule for hybridization. It is more difficult to make this merging rule generic, as it will depend on the parameters of the process at hand. Even when the process is fixed, there might be several natural candidate merging rules, each giving birth to a different joint law of the observations at the tips. In the following, we focus on the Brownian Motion process, with a weighted average merging rule.

Brownian Motion on a Network

We use the following formal definition of a BM on a network, inspired by Definition 1.2.1 of Section 1.2.1. Definition 4.2.1 (Brownian Motion on a Network). Let N = (N , φ) be a phylogenetic network as defined in 4.1.2, with N = (E, V ) a rooted directed network. Assume that each edge e ∈ E of the network has an associated branch length e , and inheritance probability γ e . Given a preorder numbering of the vertices, denote by (X i ) 1≤i≤|V | the sequence of random variables, taking its values in R, describing the trait of each node. The law of (X i ) 1≤i≤|V | is recursively defined by: X 1 ∼ N (µ, s 2 ): the root is Gaussian with mean µ and variance s 2 . It can also be taken fixed (s 2 = 0).

Let e ∈ E be a branch, with child node i, and parent node pa(i). On this branch, the traits evolve according to a Brownian Motion (W e t , 0 ≤ t ≤ t e ) with variance σ 2 , independently from other species, conditionally on W e 0 = X pa(i) .

At node i, define:

-X i = W e e
if i is a tree node with only one parent edge e.

- if i is an hybrid node, with parent edges e a and e b .

X i = γ e a W
Iterate down the network.

An example of such a process is presented Figure 4.2.2.

Remark 4.2.1 (Non-zero hybrid branch lengths). Note that here, we use a network with hybrid edges having a non-zero length ( e a and e b in the definition). This might seem contradictory, as we defined hybridization events as happening between contemporary species. These apparently impossible gene flows might appear for two reasons. First, as we saw earlier, the dating of the network is itself a difficult and still open issue, so the branch length might not be accurate. Second, even if all the branch lengths are known without error, this kind of event might still appear on the network, due to extinct or un-sampled species (see Fig. 4.2.1). It is straightforward to show that it would be equivalent to define the BM on the "original", complete network with only zero-length hybrid branches, and with all extinct species. The previous formal definition 4.2.1 is given to make the link with Section 1.2.1, but is not straightforward to use as such. As the underlying process is a Brownian Motion, it is straightforward to derive the following alternative characterization of the process. Proposition 4.2.1 (BM on a Network). Using the notations of Definition 4.2.1, the joint law of X = (X i ) 1≤i≤|V | can also be described as follow:

X 1 ∼ N (µ, s 2 ): the root is Gaussian with mean µ and variance s 2 . It can also be taken fixed (s 2 = 0).

At node i, define:

-If i is a tree node, with parent node a and parent branch e a , take:

X i = X a + e a a ,
with a ∼ N (0, 1) a standard normal variable, independent from all other node variables.

-If i is an hybrid node, with parent nodes a and b, and parent branches e a and e b take:

X i = γ e a X a + e a a + γ e b X b + e b b
with a and b two independent standard normal variables, independent from all other node variables.

Iterate down the network.

This recursive definition is correct provided that the nodes are ordered in a preorder.

X 13 X 12 X 11 X 9 X 8 X 2 X 3 X 7 X 1 γ 6a γ 6b X 10 X 6 X 5 X 4 (a) A phylogenetic network
γ 6a γ 6b X 13 X 12 X 11 X 9 X 8 X 1 X 2 X 3 X 7 X 6 X 5 X 4 X 10
(b) BM on the branches of the network Figure 4.2.2 -Realization of a univariate BM process (with µ = 0 and σ 2 = 0.04) on a calibrated network. The colors of the branches (left) match with the colors of the distinct processes (right). Only tip values are observed (at time t = 0). For simplicity reasons, the two hybrid branches were chosen to have a length equal to 0, but this need not to be the case (see Fig. 4.2.1). Inheritance probabilities at the hybridization event are γ 6a and γ 6b , with γ 6a + γ 6b = 1.

Biological Interpretation. We already discussed the biological interpretation of a BM on a tree in the introduction (see Section 1.4.1.3). The basic idea is that the BM can represent the drift of a polygenic trait, that is, a trait which value depends on the additive expression of many genes. With this interpretation in mind, it is natural to think that the trait on a hybrid, that inherits a proportion γ a of its genetic material from a parent a, and γ b = 1γ a from its other parent b, is a weighted average of the traits of its two parents. This is the assumption we make for our null model. We will see in Section 4.2.3 how this model can be refined, taking into account some of the non standard effects that might occur during a hybridization.

Possible Other Merging Rules. The merging rule we chose (weighted average) is nice from a mathematical point of view, as it allows us to carry all the computations analytically. However, that is not the only merging rule one could think of for a BM. For instance, another possible merging rule could be to choose the trait of one of the parents, with a probability given by the inheritance probability parameters γ. This model could be suited to model traits that would inherit all their coding genes from only one of their two parents. However, it introduces a discrete law in the stochastic process, and hence this model is more difficult to study. We will not look further into that direction here, but it could be a starting point for new developments.

Joint Law

For the BM on a tree, we were able to describe the joint law of the trait values at all the nodes of the tree, with a covariance between node i and j equal to σ 2 t ij , were t ij is the time elapsed between the root and the most recent common ancestor (mrca) of i and j (see Equation 1.4 in Section 1.4.1.1). Our goal here is to derive a similar expression for a trait evolving on a network. An intuition of how this is going to work can be given by re-writing t ij as:

t ij = e∈p i ∩p j e (4.1)
where p i is is path going from the root to node i:

p i = {e ∈ E : pa(e) ∈ anc(i)}
where pa(e) is the parent node of edge e ∈ E, and anc(i) is the set of all ancestor nodes of i (as defined for a tree in Section 1.1.1). This formula just expresses that the variance is proportional to the total length of the path shared between the two nodes, that precisely ends at the mrca. On a network, the difficulty is coming from the fact that there is not a unique path going from the root to a given node. Indeed, if there is a hybrid among the ancestors of node i, then a path might go "right" of "left" of the hybrid loop to go from the root to i.

The general formula was first derived by [START_REF] Pickrell | Inference of Population Splits and Mixtures from Genome-Wide Allele Frequency Data[END_REF] in the context of population genomics. It is similar to Equation (4.1), just summing over all possible paths, each weighted by their inheritance probabilities. Proposition 4.2.2 (Variance Matrix [START_REF] Pickrell | Inference of Population Splits and Mixtures from Genome-Wide Allele Frequency Data[END_REF]. Assume that X is the random vector of the traits at the nodes of a network, as defined in 4.2.1 (with a fixed root). Then its variance matrix is equal to σ 2 V, with:

V ij = p i ∈P i p j ∈P j       e∈p i γ e             e∈p j γ e       e∈p i ∩p j e
where P i denotes the set of all the paths going from the root to node i. This closed formula is compact, and can help us understand the problem, but it is not practical to compute. Using the characterization of the process given in 4.2.1, we can derive an iterative way to compute this covariance matrix, in just one traversal of the tree. Proposition 4.2.3. Assume that X is the random vector of the traits at the nodes of a network, as defined in 4.2.1 (with a fixed root). Let i ∈ V be a node of the network. Then: If i = 1 then i is the root, and V ii = 0.

If i is a tree node, denote by a the parent of i, and by e a the length of the branch e going from a to i. Then:

       V ij = V aj ∀1 ≤ j ≤ i -1 V ii = V aa + e a (4.2)
If i is a hybrid node, denote by a and b the parents of i, by e a and e b the lengths of the branches e a and e b going from a or b to i, and by γ e a and γ e b the associated inheritances probabilities. Then:

       V ij = γ e a V aj + γ e b V bj ∀1 ≤ j ≤ i -1 V ii = γ 2 e a (V aa + e a ) + γ 2 e b (V bb + e b ) + 2γ e a γ e b V ab (4.3)
Proof. Let i ≥ 2, and j ≤ i. Because of the preorder, there is no directed path from i to j if i j. We use the same notations than in the proposition.

If i is a tree node, then X i = X a + , with ∼ N (0, e a ), independent of the values X j in the current network (j < i). Then:

Cov X i ; X j =        Cov X a ; X j if j < i Cov [X a ; X a ] + e a if j = i If i is a hybrid node, then X i = (γ e a X a +γ e b X b )+(γ e a a +γ e b b ), with k ∼ N (0, e k ),
and k independent of the all values X j in the current network (j < i) for k ∈ {a, b}. Then:

Cov X i ; X j =            γ e a Cov X a ; X j + γ e b Cov X b ; X j if j < i γ 2 e a Cov [X a ; X a ] + e a + γ 2 e b Cov [X b ; X b ] + e b + 2γ e a γ e b Cov [X a ; X b ] if j = i .
This ends the proof, because

       P i = {(p a , e a ) : p a ∈ P a } if i is a tree node P i = {(p a , e a ) : p a ∈ P a } ∪ {(p b , e b ) : p b ∈ P b } if i is a hybrid node
and because, if i j, p j cannot go through i, so p j cannot go through e a , or e a or e b .

Link Between the Tree and the Network Variance Matrix. Assume for simplicity reasons that we have a phylogenetic network with only one hybridization event, with transitions probabilities γ and 1γ. Then the network has only two underlying trees, obtained by setting γ respectively to 0 or 1 (so that all the genes come from one side or another of the hybrid). One natural question to ask is: can we compute the network variance matrix from both the trees variances matrices? As we already know how to compute efficiently these matrices for a tree, that might be an easy way to get the network matrix, without using the algorithm presented above. It is indeed possible to get a simple formula, as stated in the next proposition. Proposition 4.2.4. Let N be a rooted binary network with only one hybridization event. Denote by p the hybrid node, and by s the MRCA of a and b, that are the direct parents of p (where p stand for pit, and s for source, see [START_REF] Alexeev | Combinatorial Scoring of Phylogenetic Networks[END_REF]. Assume that the hybrid branch going from a to p has weight γ and hybrid branch going from b to p has weight 1γ. Then the variance matrix V(γ) of the network can be obtained from the variances matrices V(0) and V(1) of the two underlying subtrees as:

V(γ) = γV(1) + (1 -γ)V(0) -2γ(1 -γ) t p -t s D(p) (4.4)
where t p and t s are the times elapsed between the root and nodes p and s, and D(p) is the matrix of nodes descending of p: for any two nodes i and j,

D(p) ij =       
1 if i and j are descendants of p 0 otherwise.

This proposition is proven in Appendix 4.B, as a corollary of a more general case. It has a natural form, and one could think of using it for the matrix computation. However, it only deals with the case of a network with only one hybridization event. In the same appendix, we derive the general formula for a level-1 network with any number h of hybrids. However, this formula involves a sum over all the 2 h underlying trees on the network. It is hence not practical to use, and the algorithm derived above in Proposition 4.2.3 is still the best option to compute the variance matrix of a network. The form we derived here might however be useful for other purposes, such as a more systematic study of the hybridization test described below (Section 4.3.2).

Shifted BM and Heterosis

In the model we described, the trait of an ancestor was passed on to its children directly, so that the overall expectation of the trait is constant equal to µ for all the nodes of the network. However, similarly to the model we used on a tree, some events might happen, that induce a sudden change in the value of the trait on a given branch. We define the shifted BM as a slightly modified version of Definition 4.2.1. Proposition 4.2.5 (Shifted BM on a Network). Using the notations of Definition 4.2.1, the joint law of X = (X i ) 1≤i≤|V | is defined as follow:

X 1 ∼ N (µ, s 2 ): the root is Gaussian with mean µ and variance s 2 . It can also be taken fixed (s 2 = 0).

At node i, define:

-If i is a tree node, with parent node a and parent branch e a , take:

X i = X a + e a a + ∆ e a ,
with a ∼ N (0, 1) a standard normal variable, independent from all other node variables, and ∆ e a a fixed shift value (possibly equal to 0) associated with branch e a .

-If i is an hybrid node, X i is defined as in 4.2.1 (no shift are allowed on hybrid branches).

Iterate down the tree.

This recursive definition is correct provided that the nodes are ordered in a preorder.

Remark 4.2.2. In this definition, we forbade shifts on hybrid branches. This can be done without loss of generality. Indeed, a hybrid connects three branches, two in and one out.

A shift on any of those three branches would impact the same set of nodes (apart from the hybrid itself), and hence would produce the same data at the tips. The position of a shift on these three branches is consequently not identifiable. By convention, we assume that this shift happens on the branch going out of the hybrid, which is a tree-like branch (it has only one parent and daughter node). We present an example of heterosis in Figure 4.2.3. As the shifts are fixed, they do not impact the variance matrix, that remains unchanged. As in the tree case, we expect that most of the shifts ∆ e on the branches will be zero. However, and contrary to the tree case, we have some pre-defined candidate branches for those shifts to occur on. Indeed a shift might have a different biological interpretation, depending on where it occurs:

X 13 X 12 X 11 X 9 X 8 X 2 X 3 X 7 X 1 γ 6a γ 6b X 10 X 6 X 5
γ 6a γ 6b X 13 X 12 X 11 X 9 X 8 X 1 X 2 X 3 X 7 X 6 X 5 X 4 X 10
If it occurs on a "regular" tree-branch, i.e. a branch that is not coming out of a hybrid node, then it has the same interpretation as before. The shift can then represent the effect of a sudden environmental change, that has an impact on the ecological niche of the species studied.

If it occurs on a branch going out of a hybrid node, then it can be seen as an effect of heterosis. Heterosis, or hybrid vigor, is a well documented effect (see, e.g. [START_REF] Fiévet | Systemic properties of metabolic networks lead to an epistasis-based model for heterosis[END_REF][START_REF] Chen | Genomic and epigenetic insights into the molecular bases of heterosis[END_REF], for recent developments, and a review) that happens when two distinct species are hybridized. The hybrid species might then exhibit a shift in some of its traits, making it particularly fit (hybrid vigor) or ill-fit (hybrid depression) to its environment. Such a shift can hence be seen as a component of hybridization: the new species inherits its trait as a weighted average of the traits of its two parents, plus a shift representing heterosis.

Remark 4.2.3 (Identifiability). We are not discussing here identifiability problems that are likely to arise, as in the tree case (see Section 2.3 in Chapter 2). A careful analysis of this question should be the focus of future work. However, we won't try to infer the position of the shifts here, and rather impose their position by hand and a priori. We hence assume that the user "knows what he's doing" and will not use non-identifiable configurations. When the shift positions are fixed, it is however easy to check that the corresponding regression matrix has full rank (see next section).

We explain in the next section how these shifts can be easily included in the model.

Phylogenetic Regression Model

Now that, given a network, we are able to compute the matrix V giving the covariance structure of the observations Y at the tips of the network, we can use the linear regression framework, as defined for models on trees in Section 1.4.2.2 of the introduction.

Y = Uθ + σ 2 E with E ∼ N (0, V) (4.5)
where U is a n × q matrix of regressors, and θ a vector of q coefficients. In the simple case of a BM with root value fixed equal to µ, we simply get U = 1 n , and θ = µ. Matrix U can also contain some explanatory traits variable of interest. As in Section 2.2.3 (see also Section 1.4.3), we can also include some shifts on the branches of the network, and take them into account using an equivalent of the incidence matrix we used for the tree.

Definition 4.2.2. The incidence matrix U of a network N = (E, V ) with ordered nodes is defined as, for any two nodes i and j:

U ij = p∈P j→i e∈p
γ e (4.6) where P j→i is the set of all the paths going from j to i (respecting the orientation of the network). Note that, if i is not a descendant of j, then P j→i = ∅ and U ij = 0.

Associated with this incidence matrix, we define the vector of the shifts on the branches by identifying the branches with their descending node (when possible), as in the tree case. Definition 4.2.3. The vector ∆ represents all the shifts on the network, numbered by nodes. For any node i, if i is tree-like, then it represents the edge ending at i. If i is hybrid, then it artificially represents both the hybrid edges ending at i. As, for identifiability reasons, shifts are forbidden on hybrid edges (see Remark 4.2.2), these coefficients will not be used anyway. We get, for any node i:

∆ i =                  µ if i = 1 (root node) δ i if i is
tree-like and there is a shift on edge ending at i 0 if i is tree-like and there are no shift on the edge ending at i 0 if i is a hybrid note that we put the ancestral mean µ of the BM on the fictive branch ending at the root of the tree. Remark 4.2.4. It is straightforward to see that, when the network actually reduces to a tree, then this definition is compatible with the definition of an incidence matrix for a tree we gave in Section 2.2.3. Compared to the incidence matrix of a plain tree, the incidence matrix of a network can have non-binary entries: some of its coefficients are given by the transmission probabilities γ.

Using these definitions, the joint law of a shifted BM on a network can be expressed in the linear model framework. See Example 4.2.1 for the incidence matrix and shift vector associated with Figure 4.2.3. Proposition 4.2.6. Let X be the vector of the traits at the nodes of a network N = (E, V ) with ordered nodes. Assume that X is the result of a shifted BM as defined in 4.2.5, with vector of shifts ∆. Then its variance matrix is given by σ 2 V, with V defined in 4.2.2, and its expectation by: E [X] = U∆ Proof. We show this equality recursively. Assume that the nodes are numbered in preorder (from the root to the tips). Denote by U i the i t h row-vector of U. Then, as the root is its only descendant: E [X 1 ] = µ = ∆ 1 = U 1 ∆ Then, assuming that the property is true for its parents, let's show it for node i.

If i is tree-like, then denote by a its unique parent, and by e a the edge linking the two nodes. We have, for any node k above i: P k→i = {(p a , e a ) : p a ∈ P k→a }, so that, from definition 4.2.2:

U ik =        U ak ∀k i 1 if k = i hence E [X i ] = E [X a ] + ∆ i = U a ∆ + ∆ i = U i ∆ If i is
U ik =        γ a U ak + γ e b U bk ∀k i 1 if k = i
hence, as no shift can occur on the hybrid branches (∆ i = 0 by convention):

E [X i ] = γ e a E [X a ] + γ e b E [X b ] = γ e a U a ∆ + γ e a U b ∆ = U i ∆
Remark 4.2.5. Note that the proof above also gives us a way of computing the incidence matrix of a network in just one preorder traversal of the network.

Keeping only the tips of the network, it is straightforward to get the following corollary.

Corollary 4.2.1. Using the same notations as in Proposition 4.2.6, let T be the matrix of U with only lines corresponding to tips of the network. Then the expectation of the vector of traits Y at the tips of the tree is given by:

E [Y] = T∆.
Example 4.2.1 (Incidence Matrix and Shift Vector). The incidence matrix T associated with the network presented Figure 4.2.3 is given by:

U =                                                  X 1 X 2 X 3 X 4 X 5 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 1 1 • • • • • • • • • • • X 2 1 1 • • • • • • • • • • X 3 1 1 1 • • • • • • • • • X 4 1 • • 1 • • • • • • • • X 5 1 1 • • 1 • • • • • • • X 7 1 • • 1 • 1 • • • • • • X 8 1 • • 1 • 1 1 • • • • • X 9 1 • • 1 • 1 • 1 • • • • X 10 1 • • γ 6b γ 6a • • • 1 • • • X 11 1 1 • • 1 • • • • 1 • • X 12 1 1 1 • • • • • • • 1 • X 13 1 1 1 • • • • • • • • 1                                                                      

Tests of Phylogenetic Signal

The phylogenetic linear regression framework gives us all the tools needed to test some hypothesis about the distribution of the traits observed at the tips of a network. We describe here two tests on the variance structure, and one on the expectation structure, to test for the impact, respectively, of the network and of heterosis.

Pagel's λ on a Network

Recall that Pagel's λ transform [START_REF] Pagel | Inferring the historical patterns of biological evolution[END_REF] could be seen as a modification of the branch lengths of a tree, giving more importance to external edges, i.e. edges that are leading to a tip (see Section 1.4.2.3 in the introduction). We want to define here the same transformation on a network. For a network with consistent branch lengths representing real time, all the paths going from the root to a given node i have the same length, that can be defined as:

t i = 1 |P i | p i ∈P i e∈p i e = e∈p i e , ∀p i ∈ P i
Using this definition, Pagel's λ transformation on the branch lengths is the same as in the tree case.

Definition 4.3.1 (Pagel's λ transform of the branch lengths). Let e be a branch of the network, with child node i, parent node pa(i), and length e . Then its transformed length is given by:

e (λ) =        λ e if i is an internal node e + (1 -λ)t pa(i) = λ e + (1 -λ)t i if i is a tip (4.7)
The interpretation is then similar: when λ decreases to zero, the network structure is less and less important, until it's completely gone for λ = 0, and all the tips are independent. However, its impact on the matrix V is not completely similar, and cannot be written in the simple form we used on a tree (see Equation 1.11 in the introduction). The structure matrix of the variance V(λ) of such a transformed network is given by the following proposition. Proposition 4.3.1 (Pagel's λ effect on the variance). The structure of the variance matrix of a BM running on a network transformed by a parameter λ is given by:

                 V (λ) ij = λV ij
for any two nodes i and j, i j V (λ) ii = λV ij for any internal node i V (λ) ii = λV ii + (1λ)t i for any tree tip i V (λ) ii = λV ii + (γ 2 e a + γ 2 e b )(1λ)t i for any hybrid tip i with parent branches e a and e b

Proof. From the general formula given in Proposition 4.2.2, the first two equations (for non-diagonal elements and internal nodes) are straightforward (all the branch lengths included in the paths of the sum are multiplied by λ). Let's now prove the last two. Take i a tip node of the network.

If i is a tree node, with parent node a and parent branch e a , then, from the recursive formula (4.2), its variance is proportional to:

V ii (λ) = V (λ) aa + e a (λ) = λV aa + λ e a + (1 -λ)t i = λV ii + (1 -λ)t i
If i is a hybrid tip, with parent nodes a and b, and parent branches e a and e b , then, from the recursive formula 4.3, its variance is proportional to:

V (λ) ii = γ 2 e a (V (λ) aa + e a (λ)) + γ 2 e b (V (λ) bb + e b (λ)) + 2γ e a γ e b V (λ) ab = λV ii + (γ 2 e a + γ 2 e b )(1 -λ)t i
The extra-diagonal elements are still just multiplied by λ (as in Equation 1.11). But, the variance of a trait is impacted by any hybridization event that happened in it's history. So, when reducing the impact of the network structure, the variances are going to change too, in opposition with the tree case. From these equations, we can see that any ancestral hybridization event is forgotten (which is coherent with the "star network" representation), but that present day (tips) hybridizations remain. It is not clear however whether "hybrid tips" should be allowed or not.

Once the model is defined, we can use the same method as in the tree case to test for "phylogenetic signal", using a maximum-likelihood ratio test for H 0 : λ = 0 (no structure) vs H 1 : λ > 0. There are no closed form estimate for the λ parameter, and a numerical optimization needs to be carried out. The interpretation of this test is similar to the one given in the tree case (Section 1. 4.2.3).

A systematic study of the features of this test is still to be carried on. Because the generalization is quite straightforward, it is natural to think that this test will have the same strengths and flaws as its equivalent on phylogenetic trees.

Can we Detect Hybridization Events ?

Description of a Hybridization Effect Test

In the previous section, we tested whether the data contained any structure at all. We might want to be more precise, and test the form of this structure. Namely, we could want to test whether a tree is enough to explain the data, against the full network. In other words, such a test would give us an indication of whether the trait we are studying was impacted or not by the hybridization events. Indeed, the "inheritance probability" coefficients γ associated with an hybridization event just gives us roughly the proportion of the genome that the hybrid inherits from its parents. It might happen that all the genes coding for the trait we are studying are all on the "same side" of the genome, and hence that the trait does not "see" the hybridization, and behaves as if the transmission were purely vertical.

On a network with several hybridization events, testing for all one by one would not be practical. To keep things simple, in the same spirit as Pagel's λ transformation, we introduce a single tuning parameter, that controls all the hybridization events. Definition 4.3.2 (Network Tuning Parameters λ). Take a rooted phylogenetic network N with h hybrids. Denote by γ = (γ 1 , • • • , γ h ) the vector of minor coefficients for each hybrid (i.e. γ i ≤ 1/2, ∀1 ≤ i ≤ h). The phylogenetic model is then defined by the couple (N , γ) of a network topology and minor inheritance probabilities. Indeed, all other inheritance probabilities are either 1 (for tree edges) or 1γ mate(e) , where mate(e) is the minor parent leading to the same hybrid node as the major hybrid edge e. The tuning parameter λ acts on all the minor hybrids in the following way:

N (λ) = (N , λγ)
The parameter λ quantifies the importance of the hybridization events on the trait: If λ = 1 then the original inferred network is unchanged.

If λ = 0 then the model is the major tree extracted from the network: the hybridization have no influence on the trait.

If λ < 0 of λ > 1, then the trait of the hybrid might go outside of the interval of the traits of its two parents. This might be one way to model heterosis (but see next section for a more natural way).

The structure matrix V(λγ) can be obtained with the same recursive algorithm as before, for any fixed λ. When there is only one hybridization event in the network, some closed form formulas can be derived (see Appendix 4.B). In any case, a numerical optimization on λ allows us to use the maximum likelihood ratio test, the same way we did for Pagel's test. Here, we can take H 0 : λ = 0 (the tree is enough) vs H 1 ; λ 0 (some events occurred at the hybridizations). An alternative way could be to take the inferred network as the null (H 0 : λ = 1).

Empirical Power Study

To have an idea of how this test behaves, we did an empirical study of its power for some given fixed networks. We chose four different networks, all sharing the same backbone symmetric phylogenetic tree with 32 tips and total height 1. We added 1 to 8 hybridization events. In all scenarios, the number of tips that have a hybrid in their ancestors is fixed equal to 8. The network used, along with the empirical results on 100, 000 simulations are shown Figure 4.3.1.

The main conclusion is that the test has a very small power, that is hardly above the imposed level. This means that the test is not efficient at all in detecting hybridization effects on the traits, and never rejects the null hypothesis, even when the network is strongly marked (γ = 0.5). The only case where the power seems to be a little bit less miserable is for the network with many recent hybridization events (leftmost, see Fig. 4.3.1). This would hint that recent hybridization events have a stronger impact on a continuous trait.

The fact that this test fails is not that surprising. Indeed, we are trying to detect the fine effects induced by hybridization events on the variance matrix structure, with only one trait observed at the tips of the network. One natural thing to do would be to study the effect of the number of (independent) traits observed at the tips on the power of this test. Because most dataset do not have such independent traits observations, and because the test on heterosis presented below revealed more powerful and natural, we did not push this analysis further in the present work.

Test of Heterosis

Description of the Test

In this section, we use the phylogenetic linear model defined in (4.5), and use the incidence matrix defined in 4.2.2 to model heterosis as shifts on branches that come out of a hybrid.

Assume that the network has h hybrids, and denote by N the submatrix of the incidence matrix T that has n rows corresponding to the tips, and h columns corresponding All hybridization events on the original networks had minor weights γ. The empirical distribution of the statistic under H 0 (no hybridization event, γ = 0) and various alternative (0 < γ ≤ 0.5) were obtained on 100, 000 simulations. The mean and variance of the BM were fixed, respectively, to 0 and 1. Dotted lines show the levels of the test, that should be below the power.

to the h branches linking a hybrid to its child. Further define N the column vector with size n containing the row sums of N: for any tip i, Ni = h k=1 N ik . Then, from Proposition 4.2.6, the shifted BM can be written as:

Y = Xβ + Nb + Nd + E , d s.t h k=1 d k = 0 , E ∼ N (0, σ 2 V) (4.8)
where X is a given matrix of regressors, with associated coefficients β. For a simple BM with initial root value µ, we can take X = 1 n and β = µ.

When written this way, the problem of testing for heterosis just amounts to testing the fixed effects b and d. Indeed, we can write the following assumptions on the hybrids events, with their counterparts in our linear model framework.

Hypotheses

Linear Hypothesis H 0 corresponds to the null model where the trait of the hybrids are just inherited from their parent's through a weighted average. H 1 is the case where all hybridization events result in the same heterosis effect, the trait being shifted by a coefficient b. Finally, H 2 is the case where each hybridization event k is impacted by its own heterosis event, with a shift b + d k .

These tests on fixed effects are very classic in the statistics literature (see e.g. [START_REF] Lehman | Testing Statistical Hypotheses[END_REF][START_REF] Searle | Linear Modelss for Unbalanced Data[END_REF]. The tests we write are all exact and uniformally most powerful among all invariant tests. They are also admissible against all invariant alternatives [START_REF] Lehman | Testing Statistical Hypotheses[END_REF]. In our case, we can write the following two Fisher statistics:

F 10 = Y -Proj X Y 2 V -1 -Y -Proj [X N] Y 2 V -1 Y -Proj [X N] Y 2 V -1
(4.9)

F 21 = Y -Proj [X N] Y 2 V -1 -Y -Proj [X N] Y 2 V -1 Y -Proj [X N] Y 2 V -1 (4.10)
where Proj [X N] denotes the projection on the linear space spanned by the columns of matrices X and N. These statistics follow a noncentral Fisher distribution:

N -r [X N] r [X N] -r X F 10 ∼ F r [X N] -r X , N -r [X N] , b 2 2σ 2 (I -Proj X ) N 2 V -1 (4.11) N -r [X N] r [X N] -r [X N] F 21 ∼ F r [X N] -r [X N] , N -r [X N] , 1 2σ 2 (I -Proj [X N] )Nd 2 V -1 (4.12)
where r [X N] is the rank of the matrix obtained by pasting the columns of X and N together. The noncentral coefficient depends on the network topology, through the metric defined by V, and through the regression matrix N. We will study it for several symmetric networks in the following section.

As noted previously, we did not study the identifiability of such a model carefully. For the tests above to be meaningful, one could expect that the regression matrix N has full rank. This verification is left to the user. For small level-1 networks such as the ones that can be inferred by state of the art methods, this is however likely to be the case.

Theoretical Power Study

As the distribution of the statistics above are fully known, it is possible to conduct a theoretical study of the power of the two tests of heterosis presented above.

Test H 0 vs H 1 . We first study the theoretical power to detect a single heterosis effect. The non-central coefficient of the Fisher statistic F 01 (4.11) depends on the size of the effect b, the variance σ 2 of the BM, the topology of the network (through N and V), and the value of the inheritance probabilities γ (through V). In the following, we fix the scaling variance factor σ 2 = 1. We use the same symmetric backbone tree with total height 1 as before, and add one single hybridization event at various heights (see Fig. 4.3.2,top line). The leftmost topology has a very recent hybridization event, that only affects one tip, while the rightmost has a very ancient one, that affects 8 tips. We fix the inheritance probability γ = 0.4 in all topology, as this parameter revealed to have only but a small impact on the power of the test (not shown). The variation of the power for these four networks with the size of the effect b is presented As expected, the power improves with the effect size, reaching approximately 1 for b = 5 in all scenarios. In addition, the heterosis effect seems easier to detect for recent hybridization events, even if they affect a lower number of tips. One intuition for that is that ancient hybridization effects are "diluted" by the variance of the BM, and are hence harder to detect, even if they affect more tips.

Note that here, we used a scenario slightly different from the one presented in Figure 4.3.1: each network has only one hybridization event. We used this scenario to stress out the impact of recent hybridization event: even when they are affecting only one tip, their signal is much stronger. Taking the previous scenario, that adds such recent hybridization events in the already favorable case, only strengthen the effect.

Test H 1 vs H 2 . To study the power of this test, we use the same networks topologies as before, with γ = 0.4, keeping only networks with more than one hybridization event (as we want to test for heterogeneity). The non-central coefficient of the Fisher statistic F 12 (4.12) depends on the same parameters as before, and of the heterogeneity of the effects through vector d. Here, denoting h the number of hybrids, and h = q.2 + r the euclidean division of h by 2, we take vector d = bd u as proportional to unit vector d u , defined as:

d u i =        1/f if 1 ≤ i ≤ q -f if q < i ≤ h with f = q q + r .
This form is convenient, as, first, it ensures us that the sum of coefficients is 0, and, second, it allows us to re-write the non-central coefficient in (4.12) as:

1 2σ 2 (I -Proj [X N] )Nd 2 V -1 = b 2σ 2 (I -Proj [X N] )Nd u 2 V -1 .
The heterogeneity is hence controlled by coefficient b, that we vary between 0 and 5 (fixing σ 2 = 1). The results, presented Figure 4.3.3, are similar to the ones commented for the single effect: the test is more powerful for a high heterogeneity coefficient b, and for recent hybridization event.

The Julia package PhyloNetworks

In this section, we briefly describe the PhyloNetworks package [START_REF] Solís-Lemus | PhyloNetworks: a package for phylogenetic networks[END_REF].

Julia. Because they are computationally intensive, the methods for phylogenetic network inference need to be implemented in an efficient way. Solís-Lemus & Ané (2016) decided to use the new programming language Julia [START_REF] Bezanson | Julia: A Fresh Approach to Numerical Computing[END_REF]. Julia is a high-level programming language similar to R, Matlab or Python, that is also highperformance. It is still under rapid development, and a long-lasting stable version is yet to come. With 1465 registered packages (as of July 13, 2017, see julialang.org), Julia provides an ever growing community of users with an interactive and comprehensive computing environment. The language and the packages are all developed on GitHub (github.com), which makes them open to contributions from any interested researcher.

Inferring and Manipulating Networks. Solís-Lemus & Ané (2016) made their method for network inference available through a Julia package PhyloNetworks (github.com/ crsl4/PhyloNetworks.jl). This package was designed to be useful not only for network inference, but also for interactive network manipulation and visualization. This package has for ambition to become the standard tool to deal with phylogenetic networks on Julia.

Trait Evolution on Networks. We implemented several functions and data structures to analyse continuous traits evolving on networks using the methods presented above. The functions we wrote are fully integrated in the Julia environment, and take advantage of the numerous tools it offers. In particular, we build on the package GLM [START_REF] Bates | Generalized linear models in Julia[END_REF], which is part of the JuliaStats project (JuliaStats, 2016). The implementation has been written to be flexible, so that models other than the BM could be easily cast in this linear regression framework in the future. See Appendix 4.A for the manual pages corresponding to the functions developed for the continuous traits study.

Testing and Documentation. The package uses the continuous integration tool Travis CI (travis-ci.org), to run an extensive set of unitary tests, and to automatically deploy the documentation (http://crsl4.github.io/PhyloNetworks.jl/stable/). The manual pages are automatically built at each new update (push to the master branch), thanks to the package Documenter [START_REF] Hatherly | A documentation generator for Julia[END_REF]. It is written in a "Julia markdown" (.jmd) format, so that all the examples shown are re-run at each build with the last version of the functions, thanks to package Weave [START_REF] Pastell | Weave.jl: Scientific Reports Using Julia[END_REF]. Associated with the Git tracking system, all these tools are there to help us keep this collaborative package up-to-date and working smoothly.

Perspectives

To link this section with the rest of this manuscript, that is dealing with shift detection for OU processes, one could think of two natural extensions of the model presented above: shift detection for the BM, and OU modeling.

Shift Detection

In this chapter, we only studied shifts on fixed branches, representing heterosis. However, similar to the tree case, as the phylogenetic networks become larger, shift detection on other branches might be needed. Because we forbade shifts on hybrid branches for identifiability reasons, this problem is actually quite similar to the one we tackled in Chapters 2 and 3. Using the notations of Proposition 4.2.5, denote by X the vector of traits measured at the node of a network N = (V , E) issued from a shifted BM. We identify an edge with its ending node for tree edges, and for a hybrid edge ending at node i, we denote by (i, 1) the major edge (with γ i,1 > 0.5) and (i, 2) the minor edge (γ i,2 = 1-γ i,1 ). Denoting pa(i) the parent nodes of node i (|pa(i)| = 1 if i is a tree node, and |pa(i)| = 2 We can plot the ancestral states or prediction intervals on the tree, using the nodeLabel argument of the plot function.

ancExpe = expectationsPlot(ancTrait1); # format expected ancestral states for the plot plot(truenet, nodeLabel = ancExpe) [2.94, 4.17] 2.17 1.87 [1.24, 2.93] [0.84, 4.02] [0.68, 4.55] 2.84 [0.58, 4.54] [0.69, 3.85] 5.88 [2.94, 4.17] 2.17 1.87 [1.24, 2.93] [0.84, 4.02] [0.68, 4.55] 2.84 [0.58, 4.54] [0.69, 3.85] 5.88 In real applications though, we do not have access to the true parameters of the process that generated the data. We can estimate it using the previous function. To fit a regular BM, we just need to do a regression of trait 1 against a simple intercept: fitTrait1 = phyloNetworklm(@formula(trait1 ~1), dat, truenet)

| Row | infPred | trueValue | supPred | -------------------------------------- | 1 | 2.
We can then apply the ancestralStateReconstruction function directly to the fitted object:

ancTrait1Approx = ancestralStateReconstruction(fitTrait1)
The prediction intervals ignore the fact that we estimated the process parameters, so they are less accurate and the function throws a warning. The output is an object of the same ReconstructedStates type as earlier, and the same extractors can be applied to it: plot(truenet, nodeLabel = expectationsPlot(ancTrait1Approx)) For convenience, the two steps described above (fitting against the intercept, and then do ancestral state reconstruction) can be done all at once with a single call of the function ancestralStateReconstruction on a DataFrame with the trait to reconstruct, and the tip labels: datTrait1 = DataFrame(trait1 = trait1, tipNames = tipLabels(sim1)) ancTrait1Approx = ancestralStateReconstruction(datTrait1, truenet) plot(truenet, nodeLabel = predintPlot(ancTrait1Approx))

4.08 3.11 [2.9, 4.25] 2.17 1.87 [1.2, 3.06] [0.9, 4.56] [0.81, 5.38] 2.84 [0.63, 5.12] [0.72, 6.19] 5.88 2.9, 4.25] 2.17 1.87 [1.2, 3.06] [0.9, 4.56] [0.81, 5.38] 2.84 [0.63, 5.12] [0.72, 6.19] 5.88

4.A.3.3 Data imputation

Note that there is no theoretical difference between an internal node, for which we could not measure the value of the trait, and a missing value at a tip of the network. Consequently, the previous ancestralStateReconstruction function can be used to do data imputation. To see this, let's add some missing values in trait 1.

datTrait1[ [2], :trait1] = NA # second row: for taxon C ancTrait1Approx = ancestralStateReconstruction(datTrait1, truenet) plot(truenet, nodeLabel = predintPlot(ancTrait1Approx))

4.08 [2.9, 5.14] [3.24, 4.8] 2.17 1.87 [1.38, 2.92] [1.31, 4.36] [1.37, 5.21] 2.84 [1.02, 4.75] [1.26, 5.87] 5.88 2.9, 5.14] [3.24, 4.8] 2.17 1.87 [1.38, 2.92] [1.31, 4.36] [1.37, 5.21] 2.84 [1.02, 4.75] [1.26, 5.87] 5.88

4.A.3.4 With known predictors

At this point, it might be tempting to apply this function to trait 3 we simulated earlier as a linear combination of trait 1 and a phylogenetic noise. However, this cannot be done directly: ancTrait3 = ancestralStateReconstruction(fitTrait3) # Throws an error ! This is because the model we used to fit the trait (a regression with one predictor and an intercept) is not compatible with the simple model of Brownian evolution that we assumed for the ancestral state reconstruction. As the predictor used is not known for ancestral states, it is not possible to reconstruct the trait for this particular model.

The only option we have is to provide the function with the predictor's ancestral states, if they are known. They are known indeed in this toy example that we generated ourselves, so we can reconstruct our trait doing the following: [13.81, 14.96] 14.45 13.97 [14.09, 14.94] [12.08, 14.36] [11.72, 14.35] 16. 42 [15.27, 17.09] [12.27, 16.89] 22.03 [12.66, 17.34

] D C A B E O
where we provided the ancestral predictors as a matrix, containing the intercept, and the known predictor at the nodes. The user must be very careful with this function, as no check is done for the order of the predictors, that must be in the same order as the internal nodes of the phylogeny. As ancestral predictors are often unknown, the use of this functionality is discouraged.

4.A.4 Phylogenetic ANOVA

As mentioned above, the phyloNetworklm function is based on the lm function from GLM. This means that it inherits from most of its features, and in particular, it can handle formulas with factors or interactions. For example, in lizards, we might want to do a regression of toe length against body length and the region where each species is found, where this region is coded into 4 categories (say). We might also want to include an interaction effect between body length and region. (This model has no biological basis. It is just meant to show the possibilities of the function).

To illustrate the use of categorical predictors of particular interest in a network with reticulations, let's assume that some heterosis took place after the hybridization event, so that tips "A" and "B" have larger mean compared to the others. The categorical variable underHyb separates tips "A" and "B" from the others. We need to mark it as a factor, not a numerical variable, i.e. as a PooledDataArray. Now we can include this factor in the regression. In this case, the categorical variable indicating which tips are descendants of the reticulation event is indeed relevant, and the heterosis effect is recovered. This is a very simple example of how to include heterosis, but some general functions to test for it, on networks with more than on hybrid, are also available.

4.A.5 Pagel's Lambda

One classical question about trait evolution is the amount of "phylogenetic signal" in a dataset, that is, the importance of the tree structure to explain variation in the observed traits. One way of doing measuring that is to use Pagel's lambda transformation of the branch lengths. This model assumes a BM on a tree where the internal branches are multiplied by a factor λ, while the external branches are modified so that the total height of the tree is constant. Hence, λ varies between 0 (the tree has no influence on the data) and 1 (the tree is unchanged). Using the same branch length transformations, this model can be straightforwardly extended to phylogenetic networks.

We can illustrate this with the predictor trait we used earlier. We use the same function as before, only indicating the model we want to use: fitPagel = phyloNetworklm(@formula(trait1 ~1), dat, truenet, model="lambda")

As it is indeed generated according to a plain BM on the phylogeny, the estimated λ should be close to 1. It can be extracted with function lambda_estim: julia> lambda_estim(fitPagel) 0.907356122898758

4.B Decomposition of the Covariance Matrix

In this section, we derive a general formula linking the covariance matrix of a network to the covariance matrices of its underlying trees. We start by dealing with only one hybridization event, and then show how to extend the formula to any number of hybrids.

Assume that we have a network N , that has at least one hybridization event (but that might have more). Take p the pit of this hybridization, with transmissions γ from its first parent a, and 1γ from it's other parent b. We want to express V(γ) the covariance matrix of the network, using V(γ = 0) and V(γ = 1) the covariance matrices of the network where this hybridization event is suppressed. (4.13) where D(p) is the matrix of nodes descending of p:

V(γ) = γV(1) + (1 -γ)V(0) -γ(1 -γ) V(1) pp -V(1) ab + V(0) pp -V(0) ab D(p)
∀i, j ∈ N , D(p) ij =       
1 if i and j descendants of p 0 otherwise Proof. Let i and j be two nodes of N . We have three distinct cases: i and j are not descendants of p. Then, by definition, no path going from i or j to the root will go through p, and, from the general formula of the covariance matrix, we can see that:

V(γ) ij = V(0) ij = V(1) ij
and the formula holds.

i is a descendant of p, but not j. Remark that any path going from i to the root must go through a or b, exclusively, so that the set of path is partitioned as

P i = P γ=0 i ∪ P γ=1 i
where P γ=0 i

and

P γ=1 i
are the set of path going from i to the root when the topology is such that, respectively, γ = 0 or γ = 1. Then using the general formula, we get the following formula: 0) ij i and j are descendants of p. We write the following decomposition:

V(γ) ij = p i ∈P i p j ∈P j       e∈p i γ(e)             e∈p j γ(e)       e∈p i ∩p j e = γ p i ∈P γ=1 i p j ∈P j       e∈p i γ(e)             e∈p j γ(e)       e∈p i ∩p j e + (1 -γ) p i ∈P γ=0 i p j ∈P j       e∈p i γ(e)             e∈p j γ(e)       e∈p i ∩p j e = γV(1) ij + (1 -γ)V(
Cov X i ; X j = E Cov X i ; X j X p + Cov E X i X p ; E X j X p = Cov X i ; X j X p + Var X p
Then, from the recursive formulas:

Var X p = γ 2 (Cov [X a ; X a ] + 1 ) + (1 -γ) 2 (Cov [X b ; X b ] + 2 ) + 2γ(1 -γ)Cov [X a ; X b ] = γ 2 Var X p γ = 1 + (1 -γ) 2 Var X p γ = 0 + 2γ(1 -γ)Cov [X a ; X b ] = γVar X p γ = 1 + (1 -γ)Var X p γ = 0 + γ(1 -γ) 2Cov [X a ; X b ] -Var X p γ = 1 -Var X p γ = 0 (because γ 2 = γ -γ(1 -γ) and (1 -γ) 2 = 1 -γ -γ(1 -γ)).
As a and b are not descendants of p, from the above, V(γ) ab = V(0) ab = V(1) ab . In addition, Cov X i ; X j X p is not dependent on γ anymore, so that:

Cov X i ; X j X p = γCov X i ; X j X p , γ = 1 + (1 -γ)Cov X i ; X j X p , γ = 0
and: Cov X i ; X j X p , γ = 1 + Var X p γ = 1 = Cov X i ; X j γ = 1 Putting everything together, we finally get the advertised formula:

V(γ) ij = γV(1) ij + (1 -γ)V(0) ij -γ(1 -γ) V(1) pp -V(1) ab + V(0) pp -V(0) ab Corollary 4.B.1.
If N is tree like everywhere but in p (i.e. if there is only one hybridization event), then the formula simplifies to:

V(γ) = γV(1) + (1 -γ)V(0) -2γ(1 -γ) t p -t s D(p) (4.14)
where s is the source of the hybridization event.

This corollary is precisely Proposition 4.4 of the main text.

Proof. If N is tree-like everywhere but in p, then:

Cov [X a ; X b ] = σ 2 t s and Var X p γ = 1 = Var X p γ = 0 = σ 2 t p hence the simplification.

V(γ 1 , • • • , γ k ) = a∈{0,1} k k i=1 γ i (a i )         V(a) - k j=1 γ j (a j -1)(V(a) p j p j -V(a) a j b j )D(p j )        
where, for any 1 ≤ i ≤ k, γ i (1) = γ i (-1) = γ i , and γ i (0) = (1γ i ).

We show this formula by recurrence, using the following lemma: Proof. The reciprocal assumption simply follows the definition of descending nodes, and holds for any kind of network. Let's focus on the direct implication. Assume that p 2 is a descendant of p 1 , and that a 2 is not. We show that this contradicts the level-1 assumption. Indeed, as p 2 is a descendant of p 1 , there exits a path t going from the root to p 2 and going through p 1 . Similarly, as a 2 is not a descendant of p 1 , there exits a path t going from the root to a 2 and not going through p 1 . Then, the set of edges (t ∪ t ) \ (t ∩ t ) defines a cycle above p 2 . But p 1 is in this cycle, hence some edges are in two cycles, which contradicts the level-1 assumption. This ends the proof.

Proof of proposition 4.B.2. We show the formula by recurrence. If there is only one hybrid, then, from proposition 4.B.1, we have:

V(γ 1 ) = γ 1 V(1) -(1 -γ 1 ) V(1) p 1 p 1 -V(1) a 1 b 1 D(p 1 ) + (1 -γ 1 ) V(0) -γ 1 V(0) p 1 p 1 -V(0) a 1 b 1 D(p 1 )
and the formula holds. Assume now that it holds for k -1 hybrids, and let's prove it for k. From the recurrence, we get:

V(γ 1 , • • • , γ k ) = a∈{0,1} k-1 k-1 i=1 γ i (a i )         V(a, γ k ) - k-1 j=1 γ j (a j -1)(V(a, γ k ) p j p j -V(a, γ k ) a j b j )D(p j )        
If a ∈ {0, 1} k-1 we have, from proposition 4.B.1:

V(a, γ k ) = γ k V(a, 1) -(1 -γ k ) V(a, 1) p k p k -V(a, 1) a k b k D(p k ) + (1 -γ k ) V(a, 0) -γ k V(a, 0) p k p k -V(a, 0) a k b k D(p k )
and, for any 1 ≤ j ≤ k -1:

V(a, γ k ) p j p j -V(a, γ k ) a j b j = γ k V(a, 1) p j p j -V(a, 1) a j b j + (1 -γ k ) V(a, 0) p j p j -V(a, 0) a j b j -γ k (1 -γ k ) V(a, 1) p k p k -V(a, 1) a k b k D(p k ) p j p j -D(p k ) a j b j -γ k (1 -γ k ) V(a, 0) p k p k -V(a, 0) a k b k D(p k ) p j p j -D(p k ) a j b j
but, from lemma 4.B.1, for any 1 ≤ j ≤ k -1, D(p k ) p j p j -D(p k ) a j b j = 0. Indeed, if p j is a descendant of p k , then a j and b j are too, and D(p k ) p j p j = D(p k ) a j b j = 1, and, if p j is a not descendant of p k , then a j and b j are not either, and D(p k ) p j p j = D(p k ) a j b j = 0. Hence:

V(a, γ k ) p j p j -V(a, γ k ) a j b j = γ k V(a, 1) p j p j -V(a, 1) a j b j + (1γ k ) V(a, 0) p j p j -V(a, 0) a j b j and:

V(γ 1 , • • • , γ k ) = a∈{0,1} k-1 k-1 i=1 γ i (a i ) ×       γ k       V(a, 1) -(1 -γ k ) V(a, 1) p k p k -V(a, 1) a k b k D(p k ) - k-1 j=1 γ j (a j -1)(V(a, 1) p j p j -V(a, 1) a j b j )D(p j )       + (1 -γ k )       V(a, 0) -γ k V(a, 0) p k p k -V(a, 0) a k b k D(p k ) - k-1 j=1 γ j (a j -1)(V(a, 0) p j p j -V(a, 0) a j b j )D(p j )            
and the announced formula follows.

Corollary 4.B.2. Assume that N is a level-1 network, and that there are exactly k hybrid species p 1 , • • • , p k in the network N , i.e. that the rest of the network is tree-like. Then the formula can be simplified to:

V(γ 1 , • • • , γ k ) = a∈{0,1} k k i=1 γ i (a i )V(a) -2 k j=1 γ j (1 -γ j )(t p j -t s j )D(p j )
where, for any 1 ≤ i ≤ k, s j is the MRCA of a j and b j (source of the hybrid).

Proof. If there are exactly k hybrids in N , then, for any a ∈ {0, 1} k , V(a) is the variance matrix of a tree. Hence V(a) p j p j = t p j , and V(a) a j b j = t s j for any 1 ≤ j ≤ k, and the second term of the formula becomes:

M = a∈{0,1} k k i=1 γ i (a i ) k j=1 γ j (a j -1)(V(a) p j p j -V(a) a j b j )D(p j ) = a∈{0,1} k k i=1 γ i (a i ) k j=1 γ j (a j -1)(t p j -t s j )D(p j ) = k j=1          a∈{0,1} k k i=1 γ i (a i )γ j (a j -1)          (t p j -t s j )D(p j ) but: a∈{0,1} k k i=1 γ i (a i )γ j (a j -1) = a∈{0,1} k i j γ i (a i )γ j (a j )γ j (a j -1) = a∈{0,1} k-1 i j γ i (a i ) a j ∈{0,1} γ j (a j )γ j (a j -1) =          a∈{0,1} k-1 i j γ i (a i )          2γ j (1 -γ j ) = 2γ j (1 -γ j )         i j (γ i (0) + γ i (1))         = 2γ j (1 -γ j )
Hence, M = k j=1 2γ j (1γ j )(t p jt s j )D(p j ), and we get the announced formula.

Other Form for the Variance Matrix. From the proof of proposition 4.B.1, we can state a more precise formula:

Proposition 4.B.3. For a level-1 network:

V(γ) ij =            V(0) ij if i and j are not descendants of p γV(1) ij + (1 -γ)V(0) ij if i or j is descendant of p V(0) ij -2γ(1 -γ)(t p -t s ) if i and j are both descendants of p (4.15)
Proof. The first two cases follow directly from the proof of proposition 4.B.1. The last case follows from the fact that, for a level-1 network, V(0) pp = V(1) pp . Indeed, for a level-1 network, all the nodes between the source s and the pit p are tree-like. Hence, Var X p γ = 1 = Var [X s ] + s→p = Var X p γ = 0 , where s→p = t pt s is the time elapsed between s and p, that do not depends on γ. As Cov [X a ; X b ] = Var [X s ], the formula follows. In this section, we try to alleviate some of the (numerous) assumptions we made, and explore their consequences on our framework. These developments are still preliminary but could serve as inspiration for future work on the subject.

Dealing with Tree and Trait Uncertainty

As stated in the introductory chapter (Sections 1.2.1 and 1.4.5.1), we assumed throughout this work that both the tree (topology and branch lengths) and the tip data were known without any uncertainty. In this section, we first try to assess, through simulations, the bias introduced when these assumptions are not fulfilled. We then briefly review some of the adaptations that could be made to account for the trait measurement errors.

Simulation Studies

In this section, we try to assess the impact of measurement errors or tree misspecifications on parameters estimation, when they are not explicitly accounted for.

Experimental Design. We used here the same simulation scheme than in the multivariate analysis of Chapter 3 (see Section 3.4). The base scenario had 3 shifts, with fixed positions and values, on a 160 taxa tree (see Fig. 3.4.1,. The base scaling factor of 1.25 was applied to the shift values. Four traits were simulated on the tree, with a scalar selection strength matrix with α = 1, a tip stationary variance γ 2 = 1, and a base correlation r d = 0.4. We added the three parameters described below, that we varied one by one. First, we added some measurement errors at the tips. To do that, we simulated a matrix Y of traits at the tips according to the model at hand, and then generated a matrix of observations Y obs , adding a noise independently to each tip:

Y i obs ∼ N (Y i , P) with P =             
e r e r e r e r e e r e r e r e r e e r e r e r e r e e

             .
e is a diagonal measurement error variance on the tip traits, that took 9 values between 0 and 5. (r e was fixed to 0 when e varied). It was applied independently to all the tip measurements. When e = 0 the model is correctly specified, and when e > γ 2 = 1, the error variance is larger than the tree-induced variance, so we expect the method to behave poorly.

r e is a correlation error factor for the measurement at the tips, that took 5 values between 0 and 0.8. When r e varied, e was fixed to 0.5. This parameter is used to asses the impact of the measurement error correlations on the method, for a fixed level of noise.

The third parameter impacted the branch lengths of the trees:

1/l is the parameter of a gamma distribution, that took 6 values between 0 and 1.

We used this parameter to alter the original simulation tree. For a given l value, we drew a parameter δ ∼ Gamma(l, 1/l), so that δ had expectation 1 and variance 1/l. We then applied Pagel's δ transform (see Section 1.4.2.3 of the introductory chapter) to the tree, in order to alter its branch lengths, while keeping the tree ultrametric. Traits were simulated under this altered tree, whereas parameter inference was performed using the original tree. When 1/l = 0, then the variance is formally equal to 0, and both tree are equal. When 1/l increases, the variance increases, and the altered tree moves away from the original (observed) one. See Figures 1. 4.9 and 5.1.4 for examples of several altered version of an original tree.

Effects of Measurement Error. In Figure 5.1.1, we first analyse the effects of measurement error e on the estimations. As expected, the measurement error progressively dilutes the phylogenetic signal, with a sharp decrease of performances when e is larger than γ 2 = 1. When the error is large, then the shifts tend to be missed, and the variance is over-estimated. In addition, the selection strength is also over-estimated. This is consistent with the conclusions of [START_REF] Cooper | A cautionary note on the use of Ornstein Uhlenbeck models in macroevolutionary studies[END_REF], who found that the OU was erroneously favored over the BM for simulated datasets with added measurement errors. Indeed, as we saw in Section 1.4.2.4 of the introductory chapter, the univariate OU can be seen as a tree transformation, that extends the terminal branches when α increases, reducing the phylogenetic signal (see Fig. 1.4.10). When the measurement errors are not accounted for explicitly in the model, they act like longer terminal branches, and have a tendency to dilute the phylogenetic signal. They hence favor artificially large values of α. This is another evidence that this α parameter, that was initially introduced as a selection strength parameter, should be interpreted with caution (see also Section 3.6.1 of Chapter 3). Effects of Measurement Error Correlations. On Figure 5.1.2, we see that increasing the correlations of the measurement errors, for a fixed level of noise (e = 0.5), does not substantially degrade the estimations. The intensity of the measurement error, rather than its structure, hence alters the results. Effects of Tree Misspecification. On Figure 5.1.3, we show the impact of a tree misspecification on the parameters estimation. It seems that misspecified branch lengths tend to lead to an increase in the number of false-positives, with an ARI that drops when the simulation tree differs more and more from the tree used in the analysis. Here, we present the results of two different model selection criteria. In blue ("LINselect ml") is the default criterion, that we've been using until now. In red ("LINselect lsq") is an alternative criterion, where the best solution in α, for a given number of shifts, is taken to be the one minimizing the least squares criterion, instead of the maximum likelihood. It seems that this criterion is more robust to the tree misspecification, as it selects for less shifts. However, the ARI scores obtained using this criterion are not dramatically improved, compared to the default selection criterion.

On Figure 5.1.4, we show two typical scenarios, with, on the left, the original tree (with 1/l = 0.75), and, on the right, the solution found on the wrong observed tree. The first line presents a "good" scenario, where the transformation factor δ is greater than 1, so that most of the variation occurs on tip branches. In such a scenario, clades are not clearly marked, and the structured differences are mainly due to the shifts. The right solution is almost found in that case. On the second line, we show a "bad" scenario, where δ < 1, so that most of the variation on the modified tree happens on ancestral branches. This tends to create well separated clades, with highly structured variations of the trait. When using the original tree for inference, these variations cannot be explained by the tree, as the clades are not that well separated anymore, and the method makes up for this by adding numerous shifts. Figure 5.1.4 -Simulation scenario with the true tree and shifts (left) and inferred solutions with the wrong tree (right), with 1/l = 0.75. The upper line shows a "good" scenario (the true solution is almost perfectly recovered), and the bottom line a "bad" one (many shifts are added to make up for the lost clade structure of the tree).

These simulations show us that the tree branch length misspecification can have an unexpected and deleterious impact on shift detection. Going further, errors in the topology of the tree are likely to alter the results even more. There are no simple ways to take these tree uncertainties into account in our framework. This is one of the strength of Bayesian methods, that perform tree inference and trait analysis at once, rather than using a two step procedure (see Section 1.4.5.3 of the introductory chapter).

Including Trait Measurement Errors

As presented in the introductory chapter (Section 1.4.5.1), several methods already exist to cope with measurement errors. These methods could be easily adapted to our framework. Indeed, errors just add an extra layer to our hierarchical modeling: as exposed in Section 1.4.5.1, we link each observation on the tree with its species by a zero-length branch. What we used to consider as tips are now internal nodes, and the observations, for each species, are linked to them by zero length branches. Using the same notations as before (see Section 3.2), we denote by X = (Z, Y) the matrix of (non-observed) traits at the internal nodes and tips of the tree, and by Y o the matrix of observed traits. We assume that there are m internal nodes numbered from 1 to m, (1 is the root), n tips numbered from m+1 to m+n, and n o observations, numbered from m+n+1 to m+n+n o . See Figure 5.1.5 for an illustration of these notations. The model can then be written as:

X 1 ∼ N (µ, Γ) for the root, X j X pa(j) ∼ N X pa(j) + ∆ j , j R for nodes 2 ≤ j ≤ m + n, Y i o Y pa(i) ∼ N Y pa(i) , P for observations m + n + 1 ≤ i ≤ m + n + n o .
To keep things simple, we only present details for the BM. Using the graphical model as in Section 2.4, we can factorize the likelihood of the completed dataset p θ (Z, Y, Y o ) as a product of Gaussian densities over the edges of the tree. We are hence able to write the same EM algorithm as before. As in Section 3.C, the expectation given the observation can be written as:

-2E [ log p θ (X) | Y o ] = p(m + n) log 2π + p m+n j=2 log j + log |Γ| + tr Γ -1 Var X 1 Y o + E X 1 Y o -µ 2 Γ -1 + (m + n -1) log |R| + m+n j=2 -1 j tr R -1 Var X j -X pa(j) Y o + m+n j=2 -1 j E X j -X pa(j) Y o -∆ j 2 R -1 + n o log |P| + m+n+n o i=m+n+1 tr P -1 Var Y i o -Y pa(i) Y o + m+n+n o i=m+n+1 E Y i o -Y pa(i) Y o 2 P -1 .
At the M step, the estimators for the parameters are the same than in the case without error, and we can get an estimation of the measurement error matrix in a similar way:

n o P (h+1) = m+n+n o i=m+n+1 Var (h) Y pa(i) Y o + E (h) Y i o -Y pa(i) Y o E (h) Y i o -Y pa(i) Y o T .
At the E step, we can write a similar upward-downward algorithm, using the graphical model presented in Figure 5.1.5. All the propagation formula we wrote can be readily applied, using the following model, adapted from Equation (3.9) of Section 3.C.2:

∀j ∈ 2 , m + n        E X j X pa(j) = m j (X pa(j) ) = Q j X pa(j) + r j Var X j X pa(j) = Σ j ∀i ∈ m + n + 1 , m + n + n o        E Y i o Y pa(i) = Y pa(i) Var Y i o Y pa(i) = P.
The missing data can be handled the same way as before.

Once implemented, this method to deal with measurement errors should improve the robustness of the algorithm to trait uncertainty. Some tests would be needed to assess the quality of the estimation of the measurement error, especially when there are only but a few species with multiple measurements. It such situations, it might be more robust to estimate the measurement error beforehand, based on some prior information on the way the data was gathered, and then to fix P during the inference step (as in [START_REF] Ives | Within-Species Variation and Measurement Error in Phylogenetic Comparative Methods[END_REF].

Factor Analysis

Interestingly, the framework developed above could also be used in a factor analysis. The idea of factor analysis is to reduce the p observed traits to a smaller number q < p of hidden "factors" that would capture the dynamic of trait evolution. The q factors would then evolve on the tree as, for instance, a BM with no correlation. The observed "real" traits would then be obtained as a linear combination of these factors, plus an error. This hierarchical model would read, using the notations and numbering defined above (see Fig. 5.1.5):

F 1 ∼ N (µ F , Γ F )
for the root, F j F pa(j) ∼ N F pa(j) + ∆ j , j I q for nodes 2 ≤ j ≤ m + n,

Y i o F pa(i) ∼ N F pa(i) L, P for observations m + n + 1 ≤ i ≤ m + n + n o .
Here, F is the (m + n) × q matrix of ancestral and current factors, that evolve according to an independent BM on the tree with shifts ∆ (size (m + n) × q), and ancestral qdimensional expectation and variance µ F and Γ F . L is a q × p matrix of loadings, and P is a p × p covariance error matrix, accounting for representation and measurement errors simultaneously.

When written this way, the factor model is very similar to the BM with errors presented above, and the upward-downward algorithm for moments computation at the E step could be readily used here. Two main difficulties might arise. First, when the number of latent trait q is fixed, the M step would need to estimate P and L, which might cause some identifiability problems. The classical constraints on the matrix of loadings (upper-triangular matrix with positive diagonal) would need to be analysed in this context. The second problem would then be the selection of q itself. Indeed, one would need to design an adequate model selection criterion to select for the right number of shifts K and the right number of factors q. In addition, trying to infer the model for every couple (K, q) might become computationally burdensome.

We did not pursue this direction, but the model could be interesting to study. A version of it was already analysed in a Bayesian framework (without shift) by [START_REF] Tolkoff | Phylogenetic Factor Analysis[END_REF]. We saw in Section 3.5.2 of Chapter 3 that our method was somehow sensitive to the number of traits considered in the analysis. This modelling, that tries to select for only a small number of independent factors, could make the method more robust to this kind of trait overflow.

Convergence and Sparsity

In Section 1.5.3.2 (see also Sections 2.C.4 and 3.C.3), we saw that, using the linear formulation (see e.g. Equation (3.2)) of the problem, a (group)-lasso penalty could be used to select for non-zero lines of the shift matrix ∆, and hence the position of the shifts. Here, we show how different penalties can induce some other desired structural constraints on the shifts, such as convergence, or sparsity in the number of shifted traits. In all this section, for the sake of clarity, we assume that all the tips are independent (i.e. related by a star-tree). If the tree-induced correlations are known, it is straightforward to reduce theoretical considerations to that simple case (see Section 3.C.3).

Convergence and Fused-ANOVA

In all the developments above, we made the strong assumption that there was no homoplasy (see Sections 2.3.1 and 3.2.1). However, in many cases, evolutionary biologists are actually interested in these convergence phenomena (see e.g. [START_REF] Mahler | Exceptional Convergence on the Macroevolutionary Landscape in Island Lizard Radiations[END_REF][START_REF] Aristide | Brain shape convergence in the adaptive radiation of New World monkeys[END_REF]. The definition of the term "convergence" is fluctuating in the literature (see Stayton 2015 for a review). Here, we simply define convergence as two distinct clades having the same optimal trait values. In our framework, as any shift produces a new optimum, this situation is forbidden, and the two clades will typically be found to have very similar, but still different, optima.

If we want to account for convergence, we need to count the complexity of a model not by its number of shifts, but by its number of "regimes", i.e. the number of truly different optima, no matter how many shift. This means that we need to find a new way of navigating through the models. Indeed, in our EM approach, we split the space of models by their number of shifts, and this partition might not be relevant anymore. In addition, we cannot use the results exposed in Section 1.1 for model selection, as we did in Section 2.3.1. Another penalty criterion, based on a yet to compute complexity, would also be required.

As an alternative to the rigorous, full likelihood approach, we propose here a simple way to detect convergence a posteriori, using a fused-ANOVA penalty [START_REF] Chiquet | Fast Tree Inference With Weighted Fusion Penalties[END_REF], that uses a penalty similar to the fused-lasso (see Section 1.5.3.2) to ensure that only a few regimes are actually different. Assume that we found a homoplasy-free solution with K shifts thanks to our previous method, so that we can classify all the tips of the tree in one of the K +1 groups created. More specifically, we know a map κ : 1 , n → 1 , K +1 that to a tip i associate its group κ(i). Each group k has n k members, with K+1 k=1 n k = n. Let Y be the n × p matrix of observations, and β the (K + 1) × p matrix of distinct optimal values of the regimes. Then, the fused-ANOVA is the solution to the following minimization problem [START_REF] Chiquet | Fast Tree Inference With Weighted Fusion Penalties[END_REF]:

argmin β∈R (K+1)×p              n i=1 Y i -β κ(i) 2 2 + λ 1≤k,l≤K+1 k l ω k,l Ω(β k -β l )              . (5.1)
Here, Ω is a given norm on R p , that penalizes large differences between regimes values, and (ω kl ) 1≤k,l≤K+1 are weights, that need to be chosen properly. [START_REF] Chiquet | Fast Tree Inference With Weighted Fusion Penalties[END_REF] offer several forms for these norm and weights that have some good theoretical properties.

In particular, if ω kl = n k n l and Ω is an q -norm, with q ∈ N * ∪ {+∞}, then the path of solution {β(λ) : λ > 0} has no split. In other words, when λ increases, the penalty becomes stronger, so that groups are progressively merged together, in such a way that if two groups are merged for a given λ 1 , then they are still merged for any λ 2 ≥ λ 1 . The choice of λ itself remains a problem, as we don't have any good model selection criterion available yet. Cross validation could be used as a first guess.

An alternate way is to use the lasso penalty from the beginning, instead of the EM algorithm. Using the same notations, the corresponding minimization problem is:

argmin ∆∈R (m+n)×p          n i=1 Y i -(T∆) i 2 2 + λ 1 1≤j≤m+n ω 1 j ∆ j 2 + λ 2 1≤k,l≤n ω 2 k,l Ω((T∆) k -(T∆) l )          .
However, the problem of calibrating the tuning parameters λ 1 and λ 2 remains. It is also possible to write an EM to maximize the penalized likelihood directly. However, it is not clear that this new criterion can be optimized efficiently at the M step. The discrete shift location algorithm should in particular probably be revised.

Sparse Number of Shifted Traits

Another strong assumption we made in Chapter 3 is that, in the multivariate case, all the traits shift at the same time. This assumption might be impairing when the number of traits grows, and can only be valid for carefully pre-selected traits that are assumed to shift in a synchronized way. We saw on the lizard example (Section 3.5.2, Fig. 3.5.2) that the number of shifts detected tends to decrease when there are more traits included in the analysis. Intuitively, the more traits one includes, the more "unlikely" they are to shift together, and the more "costly" including a shift becomes.

As in the previous section, designing an exact EM algorithm to deal with this problem might be difficult. Indeed, models in this setting would be indexed not only by the number of shifts, but also by the number of non-zero components in each of them, so that the maximization step might become prohibitive, and the model selection inefficient.

Again, one easy way to deal with this problem would be to simply add a sparsity inducing penalty. The following minimization problem could be solved:

argmin ∆∈R (m+n)×p          n i=1 Y i -(T∆) i 2 2 + λ 1 1≤j≤m+n ω 1 j ∆ j 2 + λ 2 ∆ 1          .
Where we used a "sparse-group-sparse" penalty (see Section 1.5.3.2). As previously, the problem of selecting the two tuning parameters remains.

Non-Ultrametric Trees

In Chapter 2 and 3, we made the assumption that the tree was ultrametric. This assumption is reasonable in many cases, as one usually only has access to trait measurements for extant species. However, such a framework does not allow us to deal with fossil data points that might be available for some traits of some species. When available, these fossils provide the researcher with unique insights on the process, and should not be ignored. For instance, and as expected, incorporating them in an ancestral trait reconstruction study is known to significantly improve the estimates [START_REF] Finarelli | Ancestral State Reconstruction of Body Size in the Caniformia (Carnivora, Mammalia): The Effects of Incorporating Data from the Fossil Record[END_REF][START_REF] Albert | Fossils provide better estimates of ancestral body size than do extant taxa in fishes[END_REF]. Non-ultrametric trees are also common in some other biological fields, such as virology, where organisms evolve very fast, and can be sampled over long periods of time [START_REF] Eldredge | Punctuated equilibria: an alternative to phyletic gradualism[END_REF]. In the developments above, this assumption was used twice: for the identifiability and the computation of the models complexity in Chapter 2; and for tree re-scaling in Chapter 3. Note that in both problems, this assumption allowed us to somehow reduce the OU to a more manageable BM.

As the OU has a dynamical component, we expect that having un-synchronized data points will generally improve the identifiability of the model. This has already been observed on simulation studies [START_REF] Slater | Integrating fossils with molecular phylogenies improves inferences of trait evolution[END_REF]. In the next two sections, we review the changes induced by non-ultrametric trees, and expose some possible solutions to deal with such trees.

Identifiability and Model Selection

When assessing identifiability in Chapter 2, the fact that we only dealt with ultrametric trees allowed us to reduce each regime to s single color (through Lemma 2.2.1 and Proposition 2.3.2), and hence to use the combinatorial results of Section 1.1. This is not true anymore, and has several consequences, listed below.

Identifiability of the Root Value. In Section 1.4.1.2, we saw that, on an ultrametric tree with height h, the root expectation µ and the root optimal value β 0 of an OU (without any shift) only appeared on the tips through the linear combination λ = e -αh µ + (1e -αh )β 0 , so that only λ was identifiable, and not β 0 and µ separately (see Fig. 1.4.3). On a non-ultrametric tree, we have at least two tips i and j such that t i t j , so that the expectations on these two tips are, respectively, e -αt i µ + (1e -αt i )β 0 and e -αt j µ + (1e -αt j )β 0 . Formally, we hence get a system with two independent equations, so that the two parameters become identifiable.

Identifiability of Shifts Position. We use a simple example to show how a configuration that was not identifiable on an ultrametric tree can become identifiable on a non-ultrametric tree.

t 4 = t 6 t 5 t 3 t 2 t 1 = 0 Y 4 Y 5 Y 6 Y 7 Z 1 Z 2 Z 3 δ 1 δ 2 Y 4 Y 5 Y 6 Y 7 Z 1 Z 2 Z 3 δ 1 ′ δ 2 ′ Figure 5.
3.1 -A non-ultrametric tree, with two shifts configurations that are equivalent for a BM, but not for an OU.

The two shifts configurations presented in Figure 5.3.1, are not identifiable for a BM (or an OU on an ultrametric tree), but actually are on a non-ultrametric tree. Indeed, using the notation of Figure 5.3.1, we have, in the first configuration (taking µ = β 0 = 0, and using Equation (2.5) of Section 2.2.3):

           E [Y 4 ] = δ 1 (1 -e -αt 4 ) E [Y 5 ] = δ 1 (1 -e -αt 5 ) + δ 2 (1 -e -α(t 5 -t 2 ) ) E [Y 6 ] = δ 1 (1 -e -αt 6 ) + δ 2 (1 -e -α(t 6 -t 2 ) ) (5.2)
and, in the second configuration:

           E [Y 4 ] = δ 1 (1 -e -αt 4 ) + δ 2 (1 -e -α(t 4 -t 2 ) ) E [Y 5 ] = δ 1 (1 -e -αt 5 ) E [Y 6 ] = δ 1 (1 -e -αt 6 ) (5.3)
To prove that the two configuration produce the same trait distribution at the tips, we need to show that the induced expectations at the tips are equal (shifts do not impact the variances). If the tree is ultrametric, then t 4 = t 5 = t 6 , and the last two equations are the same. We can hence take:

             δ 1 = δ 1 + δ 2 1 -e -α(t 5 -t 2 ) 1 -e -αt 5 δ 2 = -δ 2 1 -e -α(t 5 -t 2 )
1e -αt 5 1e -αt 4 1e -α(t 4 -t 2 ) = -δ 2 to get two configurations that produce the same distribution of the trait at the tips (note that when α → +∞, then δ 1 = δ 1 + δ 2 and δ 2 = -δ 2 , so that we find back the BM solution). However, when t 5 t 6 , then the three equations become linearly independent, and having only two free parameters, do not have any solution. Intuitively, when the two branches below the shift δ 2 do not have the same length, because of the non-linearity of the actualization factor, it is impossible to mimic the effect of the shifts with a different value of δ 1 . Note that this same example can be used to show that even non parsimonious shift configurations can become identifiable on a non-ultrametric tree. On Figure 5.3.2, we

t 4 = t 6 t 5 t 3 t 2 t 1 = 0 Y 4 Y 5 Y 6 Y 7 Z 1 Z 2 Z 3 δ 1 δ 2 δ 3 Y 4 Y 5 Y 6 Y 7 Z 1 Z 2 Z 3 δ 1 ′ δ 2 ′ Figure 5
.3.2 -A non-ultrametric tree, with a "non parsimonious" solution on the left that cannot be reduced to the "parsimonious" one on the right for an OU.

show a non-parsimonious solution with three shifts, that used to be forbidden, as it could be replaced by a configuration with only two shifts. Writing equations similar to (5.2) and ( 5.3), we can show that the system of equation only has a solution when the tree is ultrametric. In general, it is hence impossible to get the tips trait distribution on the left with only two shifts. This has an important implication on the linear model view of the problem. Recall from Equation 2.5 that, for a univariate OU model, the vector of traits Y measured at the tips of a tree with n tips and m internal nodes, is such that:

Y = T(α)∆ + E
where T(α) = T-ATB, with T the incidence matrix of the tree, and A = Diag(e -αt i , m+1 ≤ i ≤ m + n), B = Diag(0, e αt pa(i) , 2 ≤ i ≤ m + n) diagonal matrices of sizes n and m + n representing the actualization factors. E is an error vector with a variance structure defined by the tree and the OU model. Note that, when the tree is ultrametric with height h, then A = e -αh I n , and we get T(α) = TW(α), with W(α) invertible, as in Equation (2.6). In general however, T cannot be factorized, so that T(α) does not directly inherit its properties from T.

In particular, Proposition 2.3.6 that ensured us, in the ultrametric case, that a shift configuration was parsimonious if and only if the corresponding columns of the regression incidence matrix T were linearly independent cannot be used anymore. On a nonultrametric tree, it is easy to show that only the direct implication is still true: if a shift configuration is parsimonious, then the corresponding columns of T(α) are linearly independent. As shown by the example above, the converse statement is false.

This leads us to a new definition of what is an acceptable model with K shifts: it is not just a parsimonious model, but a model that is such that the corresponding columns of T(α) are linearly independent. A general study of these models would be needed. As in Section 2.3, we would like to know, first, the size of an equivalent class (as in Propositions 2.3.3), and, second, the number of truly different models one has for a fixed number of shifts (as in Proposition 2.3.5). From the simple examples above, we see that adding fossils, as expected, allows us to choose between different scenarios that were not identifiable before. Hence, the number of distinguishable models should be bigger. In addition, we can have the intuition that identifiability will highly depend on the number of non-synchronized tips below each shift. It is hence probable that no general formula can be easily derived in this case.

Model Selection. The fact that we are not able in general to compute the true number of different models might impair our model selection procedure, that took this number explicitly into account (see Proposition 2.4.1 in Section 2.4.2). One simple solution is to use the natural bound we have of this number of models. For a tree with m internal nodes and n tips, the (unknown) number of different models N I K is bounded by the number of possible allocations of K shifts on the m + n -1 internal branches:

N I K ≤ m + n -1 K .
This bound is actually sufficient to derive a penalty that fulfills the conditions of the LINselect model selection (Theorem 1.5.2), recalled in the introductory chapter (Section 1.5.4), and used in Chapter 2 (Section 2.4.2). To see this, let's assume, for the sake of clarity, that we are in the univariate case, and that we already corrected for the phylogeny (for a known α). We are then in the classical linear model setting for model selection:

Y = s + γE , E ∼ N (0, I n )
with models (S η ) η∈M that are linear sub-spaces of R n defined by the shift positions on the tree, with dimension D η = η = K η + 1.

The crucial point, when applying Theorem 1.5.2, is to find a set of weights (L η ) η∈M such that:

η∈M (D η + 1)e -L η = Ω < +∞;
L η is of the order than D η .

Taking the proof of Proposition 2.4.1 (see Section 2.E), we can see that this can be achieved by just replacing N I K by its upper bound in the expression of the weights:

L K = log m + n -1 K + 2 log(K + 2), ∀K ∈ 0 , p -1 .
Indeed, we get:

Ω = η∈M (D η +1)e -L η = p-1 K=0 N I K (K+2)e -L K ≤ p-1 K=0 m + n -1 K (K+2)e -L K ≤ p-1 K=0 1 K + 2 ≤ log(n)
and, using the same inequalities as in Section 2.E:

L K = log n + m -1 K + 2 log(K + 2) ≤ (K + 1)(2 + log(2) + log(n)) ≤ p(2 + log(2) + log(n))
All the subsequent derivations of Section 2.E then hold. This proves that Proposition 2.4.1 still holds when we choose a more stringent set of weights L η . The practical properties of such a penalty would need to be evaluated on simulations. For example, because we use an upper bound of the number of models, we expect that the criterion might have a tendency to over-penalize models with a great number of shifts.

Inference of the OU

We saw in previous chapters that the selection strength parameter α, that represents a dynamic aspect of the evolution model, was rather poorly estimated when using data coming from a single time point, at the tips of an ultrametric tree (see Section 2.5, Fig. 2.5.2 and Section 3.4). Having access to fossil data points should break synchronicity, and hence help us estimate this α parameter. In [START_REF] Slater | Integrating fossils with molecular phylogenies improves inferences of trait evolution[END_REF], the authors indeed showed on some simulations that including some fossil information on the analysis helped to discriminate between several dynamical models of evolution, including the BM, AC/DC, and OU. However, the inference method of Chapter 3 heavily relies on the equivalency between an OU and a BM on a re-scaled tree, that only holds for an ultrametric tree (see Sections 1. 4.2.4 and 3.2.4). We hence need to design a new method to explicitly deal with the OU in the multivariate case. Using the EM framework, we can readily see that the E step is not a problem. In Section 3.C, we indeed described a quite general upward-downward algorithm, that can deal with a broad class of Gaussian processes, including the general OU, on any dated tree.

The M step would then be the limiting point. In the univariate case, we showed that the efficient shift allocation algorithm that worked for the BM could not be used anymore, because of the non-independent increments of the OU (see Sections 2.4, 2.C.3 and 3.C). We hence resorted to heuristics in order to raise, if not maximize, the objective function at each step of the EM. This leads to a Generalized EM algorithm (GEM [START_REF] Dempster | Maximum likelihood from incomplete data via the EM algorithm[END_REF], that behaved well in the univariate case, but was quite slow compared to the rescaling tree (see Section 2.5). We sketch here two simple heuristics that could be used in the multivariate case for the OU. The first one, based on a lasso penalty, is a direct adaptation from the univariate case. The second one, based on a binary segmentation algorithm, is a promising and possibly fast alternative.

A Lasso Based Heuristic. In the multivariate setting, with a scalar OU (scOU), an heuristic based on a lasso penalty can be readily adapted from the univariate case, developed in Section 2.C.3. At iteration (h + 1) of the M step, the optimal shift location boils down to the minimization of the following sum of costs over all the branches of the tree:

C OU = m+n j=1 1 -e -2α j -1 E (h) D j Y -E j β j 2 (Γ (h) ) -1
where D j = X j -e -α j X pa(j) and E j = (1-e -α j ) (we formally set 1 = +∞). Γ (h) is the root stationary variance estimate obtained at the previous M step, and E (h) is taken according to the previous estimates of the parameters, and was computed at the E step. β = U∆ is the (m + n) × p matrix of optimal values on each branches. The optimization must be conducted by finding the K non-zero lines of ∆, and their associated values. Define matrix F (size (m + n) × p) and diagonal matrix A (size m + n) by, for any 1 ≤ j ≤ m + n:

F j = 1 -e -2α j -1/2 E D j Y A jj = 1 -e -2α j -1/2 E j .
Then, the objective function to be minimized can be re-written as: (5.4) This sum can be seen as the least squares minimization associated with the linear regression model:

C OU = m+n j=1 F j -(AU∆) j 2 (Γ (h) ) -1 .
F = AU∆ + E , with E j ∼ N (0, Γ (h) ) i.i.d.
A sparse estimation of ∆ can then be obtained using a lasso regression, using a sparsegroup penalty, as explained in Section 1.5.3.2.

A Binary Segmentation Based Heuristic. Segmentation, or shift detection for data points displayed on a line, has received a lot of attention these last few decades (see e.g. [START_REF] Eckley | Analysis of changepoint models[END_REF][START_REF] Fryzlewicz | Wild binary segmentation for multiple change-point detection[END_REF] for a review). Among all the numerous algorithms designed to tackle this problem, the binary segmentation heuristic, although very simple, has proven to be very efficient [START_REF] Rigaill | A pruned dynamic programming algorithm to recover the best segmentations with $1$ to $K {max}$ change-points[END_REF]. It is rather easy to implement, runs quite fast, and finds very reasonable solutions, when compared to the exact one.

In classical segmentation, we assume that we have an ordered sequence data Y 1:n = (Y 1 , . . . , Y n ), and that we are able to compute a cost C(Y r:s ) of any continuous sequence of data (with 1 ≤ r ≤ s ≤ n). The cost might be associated to the least squares, or the maximum likelihood, depending on the underlying model for the observations. The goal is to find the K change points v

1:K = (v 1 , . . . , v K ) such that K+1 k=1 C(Y (v k-1 +1):v k )
is minimal (where v 0 = 0, and v K+1 = n). Classical binary segmentation relies on the fact that, given a segment of data Y r:s (with 1 ≤ r < s ≤ n), we know how to find vr:s ∈ r , s that minimizes the total cost of the segment by introducing one change point:

v( r , s ) = argmin v∈ r,s C(Y r:v ) + C(Y (v+1):s ) ≤ C(Y r:s ).
Denote also Ĉ( r , s ) = min v∈ r,s C(Y r:v ) + C(Y (v+1):s ) , with Ĉ( r , r ) = +∞ (a unique point cannot be split). The idea is then to do a step-wise optimization, that adds shifts one by one: we first find v( 1 , n ) the best split point on the all segment, and then split one of the two segments produced, getting the best split between v ( 1 , v( 1 , n ) ) and v ( v( 1 , n ) + 1 , n ), and so on, until K shifts are found. See Algorithm 5.3.1 for a more formal description (this presentation is inspired by [START_REF] Eckley | Analysis of changepoint models[END_REF]

. Note Algorithm 5.3.1 Binary Segmentation S ← { 1 , n } for k ∈ 1 , K do Î ← argmin I∈S Ĉ(I) v k ← v( Î) S ← (S \ Î) ∪ { min( Î) , v k , v k + 1 , max( Î) } end for return v = (v 1 , . . . , v K )
that this algorithm has no guaranty to converge to the global minimum. An efficient implementation of it relies on the efficient computation of the costs Ĉ(I) for the needed intervals I of 1 , n .

In our problem, the data points do not lie on a segment, but at the nodes of a tree. Hence, instead of considering the cost of intervals, we need to consider the cost of connex sets of nodes on the tree. Let I be such a connex set of nodes. Using Equation (5.4), the cost of I is obtained by minimizing the least squares in the optimal value β I that is common to all the nodes in I:

C(I) = j∈I F j -A jj βI 2 (Γ (h) ) -1 = j∈I F j 2 (Γ (h) ) -1 -         j∈I A 2 jj         βI 2 (Γ (h) ) -1 with βI =         j∈I A 2 jj         -1 j∈I A jj F j .
As the nodes are naturally ordered by the tree, finding the best split of a connex subset I into two connex subsets I v(I) and I -v(I) using the costs above is straightforward. The previous binary splitting heuristic could then be applied to the tree. The efficiency of the algorithm will depend on how fast we can compute the costs involved. Because, on a tree, a connex subset of nodes I is just a subtree, minus one or several sub-subtrees, all the sums involved can be computed from the quantities j∈T i A 2 jj and j∈T i A jj F j , where T i = des(i) is the set of descendants of node i (with 1 ≤ i ≤ m + n). These base sums could be computed in one postorder traversal of the tree.

We only sketched the heuristic here, and some work would be needed to figure out the details of the algorithm, and find an efficient way to implement it. Note that we wrote here the costs for a scalar OU, but that similar expressions could be obtained for the general OU (starting from expressions given in Section 1.A.3). This binary heuristic might hence also be useful for the extension of the method to a full OU.

The two methods presented above are heuristics: they raise, if not maximize, the objective function at each M step. In linear segmentation problems, dynamic programming can be used to minimize the sum of costs efficiently (see e.g. [START_REF] Lebarbier | Detecting multiple change-points in the mean of Gaussian process by model selection[END_REF]. It might be possible to adapt these kind of methods to segmentation on a tree, using nonserial dynamic programming [START_REF] Bertele | Nonserial Dynamic Programming[END_REF]. We mention this possible direction to be comprehensive, but we did not look much into it yet.

Sampling Scheme and Missing Data

One of the strengths of our method is that it can readily handle missing data. In Section 3.4 (see Fig. 3.4.6), we showed that the method was robust to a great proportion of randomly chosen missing data. However, we did not study the impact that structured missing data could have on the analysis. A simple example that might come in mind is a trait missing for an entire clade of the tree. In that case, any shift occurring somewhere on the clade is likely to be missed by any shift detection method. Such a pattern might be due to the lack of information collected on this given clade, or to the fact that this particular trait is difficult to measure on the organisms of the clade, for instance because of its extremely small values. Some statistical tools have been developed to explicitly model the process giving rise to missing data. In this last section, we briefly recall the main ideas of these methods, and show in an informal way how they can be included in our framework.

Statistical Framework. The data sampling scheme describes the way the data was collected. In the statistical literature, sampling schemes are usually classified into three categories, based on the kind of structure of missing data they produce [START_REF] Rubin | Inference and missing data[END_REF][START_REF] Little | Statistical Analysis with Missing Data[END_REF]. The are defined as follows. Finally, the mechanism is called not missing at random (NMAR) if the distribution of M also depends on the missing values of Y.

In other words, if the mechanism is MCAR, the sampling scheme does not depend on the values of the traits whatsoever: there is an independent rule controlling which traits of which species are measured, on the whole tree. At the other side of the spectrum, if the mechanism is NMAR, then the sampling scheme does depend on the values of observed and missing traits. This would be the case in the simple example presented above, where a trait that is "small" is less likely to be measured.

The great strength of this methodology is that we can explicitly take into account any information we have on the sampling scheme, in order to improve our estimation of the parameters. Before going any further, let's take a example of such a NMAR sampling rule.

Definition 5.4.2 (Size Censored Sampling). Assume that each trait l, 1 ≤ l ≤ p, has a smaller probability of being measured if it is below a given threshold c l . The conditional sampling distribution p ψ (M | Y) is then defined by:

P [ M il = 1 | Y il < c l ] = ρ s P [ M il = 1 | Y il ≥ c l ] = ρ l
where 0 ≤ ρ s ≤ ρ l ≤ 1 are the probability of the traits being measured, when they are smaller or larger than the threshold.

One can imagine many other sampling schemes. In designing one, the researcher should try, first, to mimic the actual sampling process going on, and, second, to choose one that can lead to tractable computations in its subsequent analysis. If more down to earth, the second condition is crucial for a method to be tractable. In the following, we sketch the main points of the inference method, and show how it can be applied to the problem of shift detection.

General Setting. When dealing with an explicit sampling scheme, the quantity of interest is not the likelihood of the sole data p θ (Y obs ) anymore, but the joint likelihood p θ,ψ (Y obs , M) of the data and the sampling design. This quantity needs to be optimized in θ and ψ, that lie in a product space.

Recall that Z is the m × p matrix of un-observed traits at the internal nodes of the tree. When the sampling scheme was not accounted for, we saw that the completed likelihood p θ (Y obs , Y miss , Z) was easy to write (it could be decomposed in a product of Gaussian, see Section 2.4). Following [START_REF] Tabouy | Inference under Missing Data Conditions in the Stochastic Block Model[END_REF], we decompose the likelihood of the completed dataset as follow: (5.5) Note that, in general, the maximization must be conducted jointly in (θ, ψ), as the expectation is taken according to the distribution of (Y obs , M), that depends on both these parameters. However, if the sampling is MAR (or MCAR), then the right hand side of this equation simplifies to : log p ψ (M | Y obs ) + E [ log p θ (Y obs , Y miss , Z) | Y obs ] and the two terms of the sum can be optimized separately respectively in ψ and θ. Furthermore, the second term of the sum is exactly the one we used when ignoring the sampling scheme. So, if the sampling is MAR, then the problem is the same as before, and the sampling scheme does not bring us any information (see also Prop. 1 in [START_REF] Tabouy | Inference under Missing Data Conditions in the Stochastic Block Model[END_REF]. The interesting case is then the NMAR case: the maximization problem is actually impacted by the sampling scheme, and we hope that this extra information will help us infer the parameters. Taking the example of the size censored sampling (Def. 5.4.2), we review the consequences of a NMAR sampling scheme on the EM algorithm. These developments are quite informal, and would require some more work to assess their relevance and feasibility. E step. In the "upward-downward" framework of Section 3.C.2, the fact that we had no information on the trait values of the missing tips data was reflected in the degenerate Gaussian distribution we took at each tip i of the tree for f Y i obs | Y i (Y i obs ; a). For a measured trait, it is a Gaussian with a zero variance (i.e. a Dirac on the observed value), and for an unobserved trait, a Gaussian with infinite variance. When the sampling is not independent from the trait value, the very fact that we did not measure a trait gives us an information on its value. We now need to compute the distribution of:

f Y i obs ,M i | Y i (Y i obs , M i ; a) = f Y i obs | M i ,Y i (Y i obs ; M i , a)f M i | Y i (M i ; a).
The first term of the product is the same Dirac as before, and the second term is given by the sampling scheme, that defines the distribution of M i Y i . However, recall that the upward-downward algorithm we wrote heavily depends on all the distributions being Gaussian like. It is not clear whether the size censored sampling scheme (Def. 5.4.2) can be cast into this framework or not. If we want to keep this algorithm, we hence would need to design a maybe more regular sampling scheme, that would give us a Gaussian like distribution for (Y i obs , M i ) Y i (or maybe a mixture of Gaussians). If this framework cannot be adapted, other paths might be explored. There is a vast literature describing EM algorithm adaptations when the E step is not tractable. As in [START_REF] Tabouy | Inference under Missing Data Conditions in the Stochastic Block Model[END_REF], the Variational EM algorithm might be a promising alternative (see also [START_REF] Jaakkola | Tutorial on Variational Approximation Methods[END_REF][START_REF] Wainwright | Graphical Models, Exponential Families, and Variational Inference[END_REF][START_REF]Models with Hidden Structure: Application to Genomics[END_REF].

M step. At the M step, the maximization in θ and ψ are independent, as we can see in Eq. (5.5). The estimation on θ can hence be carried on as previously. The maximization in ψ will again depend on the sampling scheme chosen. For the size censored scheme, if the thresholds c k are fixed, then the maximization in ρ s and ρ l is straightforward (and very similar to the "double standard sampling" of [START_REF] Tabouy | Inference under Missing Data Conditions in the Stochastic Block Model[END_REF]. However, the optimization in these thresholds is more difficult, and one would probably need to design some heuristics to tackle it. Then again, this size censored scheme is not carved in stone, and it might be possible to think of another, more easily tractable, strategy. hypothèse ne tient cependant pas à un examen approfondi, et peut conduire à des conclusions erronées. C'est qu'elle ne prend pas en compte le fait que les espèces actuelles ne sont précisément pas indépendantes les unes des autres. D'après la théorie de l'évolution [START_REF] Darwin | On the Origin of Species[END_REF], il existe en effet un arbre phylogénétique reliant toutes les espèces entre elles, et permettant d'expliquer leurs relations de parenté. Il est alors naturel de faire l'hypothèse que les traits de deux espèces proches, c'est-à-dire dont l'ancêtre commun est relativement récent, seront plus semblables que ceux de deux espèces éloignées, dont la relation de parenté est plus distante. L'un des objectifs principaux des Méthodes Phylogénétiques Comparatives est de rendre explicites les hypothèses faites sur l'évolution des traits au cours du temps, afin de proposer un modèle nul raisonnable pour la répartition actuelles de ces traits parmi les espèces.

Méthodes Phylogénétiques Comparatives

Les Méthodes Phylogénétiques Comparatives (PCM, de l'anglais Phylogenetic Comparative Methods) utilisent un modèle défini par deux composantes principales. Premièrement, on suppose que l'on a accès à un arbre phylogénétique daté liant les espèces actuelles entre elles. Cet arbre donne les relations de parentés, ainsi que les dates des événements de spéciations qui ont eu lieu au cours de l'histoire. Deuxièmement, on choisi un modèle dynamique décrivant l'évolution des traits quantitatifs considérés au cours du temps. Les traits en question sont des caractères continus, comme le poids, la taille, ou encore la couleur d'une fleur. Si l'on fait l'hypothèse que l'arbre phylogénétique est donné, le hasard est entièrement défini par ce modèle d'évolution des traits au cours du temps, que l'on choisi souvent dans une classe de processus stochastiques. Un tel processus permet de quantifier les variations du trait modélisé. Le processus stochastique le plus simple que l'on peut envisager est le mouvement brownien (BM, de l'anglais Brownian Motion). Un trait suivant un tel modèle d'évolution n'a aucune tendance, et a des incréments gaussiens indépendants.

La distribution attendue du trait dans la population d'espèces actuelles est alors obtenue en combinant ces deux ingrédients de la manière suivante. Le trait d'une espèce ancestrale donnée évolue au cours du temps comme un BM. Lorsqu'un événement de spéciation survient, les deux espèces filles héritent de la valeur du trait de leur mère. Chacune voie ensuite son trait évoluer comme un BM, indépendamment l'une de l'autre. Il est important de noter que, même si l'on suppose que les deux espèces filles sont indépendantes, le simple fait qu'elles aient hérité leur trait d'un même ancêtre commun introduit des corrélations entre leurs traits respectifs. Par exemple, supposons que, par hasard, le trait de l'espèce mère a dérivé vers des valeurs extrêmes. Si le trait considéré est la taille, l'espèce est, disons, particulièrement grande. Ses deux enfants commenceront alors leur évolution en étant de grande taille, et elles auront une grande probabilité de se ressembler pendant encore un long moment, étant plus grande que la plupart des autres espèce du groupe. Si le processus d'évolution du trait est un BM, on peut quantifier ces corrélations : la covariance entre les traits de deux espèces actuelles est proportionnelle à leur temps d'évolution partagé, c'est-à-dire au temps qui s'est écoulé entre la racine de l'arbre et leur plus récent ancêtre commun.

Tout l'art des PCM réside dans la définition correcte du modèle d'évolution dynamique du trait, et dans l'étude du type de distribution qu'il produit aux feuilles de l'arbre, pour les espèces observées. Réalisation d'un BM univarié sur un arbre phylogénétique daté. Les couleurs des branches (à gauche) sont associées aux couleurs de différents processus (à droite). Par exemple, le trait de l'espèce ancestrale rouge évolue d'une valeur de 0 (noeud R au temps -200) jusqu'à une valeur de 2.6 (noeud S, au temps -100). Seules les espèces actuelles (à t = 0), aux feuilles de l'arbre, sont observées. Les espèces violette et bleu (A et B) ont hérité du trait de leur ancêtre vert (U ) assez récemment, ils ont donc une grande probabilité de se ressembler encore au temps présent. Les valeurs de leur traits sont marginalement corrélées (mais indépendantes conditionnellement à U ).

Détection de sauts

La distribution du trait aux feuilles de l'arbre obtenu par ce processus peut être vue comme un modèle nul, qui décrit les corrélations entre les espèces, ainsi que les intervalles de variation du trait, que l'on peut s'attendre à observer sous le coup du hasard seul.

Si la distribution observée diffère de manière significative de la distribution attendue, on peut alors être amené à penser qu'un événement particulier a contribué à façonner l'histoire du trait étudié. Dans ce manuscrit, on s'intéresse plus particulièrement aux sauts qui peuvent survenir à certains moments de l'histoire évolutive du trait considéré. De tels sauts sont caractérisés par un changement brutal de la valeur du trait, et peuvent avoir plusieurs causes biologiques, comme une migration vers un nouvel environnement ou un changement climatique rapide. Une espèce ancestrale affectée par un tel saut va transmettre la valeur de son trait à sa progéniture, si bien que, parmi les espèces actuelles, tous ses descendants vont hériter du changement découlant de cet événement. Un exemple d'une telle situation est présenté dans la figure qui suit.

Bien entendu, plusieurs sauts peuvent avoir lieu dans l'histoire d'un groupe d'espèces. L'un des buts principaux de cette thèse est de retrouver, premièrement, le nombre et, subséquemment, la position de ces sauts sur l'arbre phylogénétique considéré. Ces deux questions posent chacune des problèmes statistiques différents, qui sont exposés dans les deux paragraphes suivants.

Identifiabilité

L'un des aspects importants du problème à garder à l'esprit est que, bien que l'on ait défini un modèle dynamique d'évolution du trait au cours du temps, on ne peut mesurer l'état du système qu'à un instant donné, pour les espèces observées aujourd'hui. Seules les dernières valeurs prises par le processus stochastique, sur les feuilles de l'arbre, sont donc accessibles. Dans une telle situation, on s'attend à voir émerger des problèmes d'identifiabilité.

L'ajout de sauts ne fait qu'empirer la situation. Sur la figure suivante, on montre qu'il est possible de construire facilement deux scénarios distincts, avec des sauts se produisant sur des branches différentes, qui pourtant donnent exactement la même distribution attendue du trait aux feuilles de l'arbre. Il est impossible de discriminer ces deux scénarios, donnant deux histoires biologiquement différentes de l'évolution du trait, en se basant uniquement sur les données accessibles aux feuilles de l'arbre. On dit qu'ils ne sont pas identifiables. L'étude et la quantification de ces problèmes d'identifiabilité est cruciale. D'un point de vue statistique, les ignorer nous conduirait à utiliser des modèles mathématiquement mal définis, ce qui poserait des problèmes pour leur inférence. De plus, d'un point de vue biologique, il est important de comprendre ce que les données collectées peuvent -et ne peuvent pas -nous dire sur l'histoire évolutive du trait considéré.

Sélection de modèle

Une fois que l'on a déterminé la collection de modèles identifiables que l'on peut utiliser, il reste à trouver une méthode pour choisir le meilleur de ces modèles, au vu des données collectées. Cette inférence se fait en deux étapes. Premièrement, si l'on se donne un nombre arbitraire K de sauts à répartir sur l'arbre, on montre que l'on est capable de trouver le modèle à K sauts qui maximise la vraisemblance des données. Cependant, ce nombre de sauts est lui-même inconnu. La deuxième étape consiste donc à choisir un nombre de sauts approprié. Le critère de vraisemblance que l'on a utilisé à l'étape précédente ne peut pas être utilisé en l'état pour ce problème. En effet, il est facile de montrer que la vraisemblance croît avec le nombre de paramètres d'un modèle, si bien que qu'une solution K + 1 sauts aura toujours une vraisemblance plus grande qu'une solution à K sauts. Utiliser ce critère reviendrait ainsi à toujours choisir, quelles que soient les données étudiées, la solution avec le plus de sauts possibles, c'est à dire celle présentant un saut pour chaque espèce de l'arbre. Une telle solution correspondrait typiquement à un cas de sur-ajustement du modèle aux données, et n'apporterait aucune information sur le processus biologique à l'oeuvre.

Pour ne garder que les sauts dit significatifs, il est courant d'utiliser un critère de vraisemblance pénalisée. La pénalité doit être choisie de manière à compenser, entièrement et uniquement, l'augmentation mécanique de la vraisemblance avec le nombre de sauts. Le principe de cette méthode est illustré dans la figure qui suit. Cet exemple simple montre l'importance du choix de la pénalité, qui doit être adaptée au problème considérée. En particulier, on voit sur ce graphique que des critères utilisé de manière courante, comme l'AIC ou le BIC, ne sont pas à même de corriger les effets du surajustement. On s'attachera ici à dériver une pénalité prenant en compte les spécificités de la collection de modèles considérés, dont la structure particulière a été décrite dans la section précédente. Grâce à la théorie de la sélection de modèle, cette pénalité hérite de bonnes garanties théoriques. Profile de vraisemblance typique. Les données utilisées ont été générées par simulation, en utilisant un BM courant sur un arbre de 64 espèces, et présentant K true = 5 sauts bien marqués. Chaque point rouge montre la vraisemblance obtenue en fixant le nombre K de sauts autorisés, pour K variant de 0 à 20. Comme attendu, cette vraisemblance est strictement croissante. Le rôle d'une pénalité est de créer un critère ayant un maximum en K = 5 (ligne verticale), afin que l'on puisse retrouver le vrai nombre de sauts (inconnu dans les cas d'application, mais connu ici, puisque les données sont simulés suivant un modèle fixé). Les critères standards AIC et BIC (en vert et bleu) sont tous les deux strictement croissants, et ne peuvent donc pas être utilisés ici. En revanche, le critère LINselect (en violet) que nous proposons d'utiliser a bien un maximum en K = 5, qui nous permet de retrouver la bonne solution dans cet exemple jouet.

Les modèles et méthodes statistiques présentés ici sont à la base de ces travaux de thèse. Dans ce document, on s'attache d'abord à en présenter les fondations (Chapitre 1), avant de les développer et d'en présenter des extensions à d'autres processus stochastiques (Chapitres 2 et 3) ou à d'autres structures de parentés entre les espèces (Chapitre 4).

Chapitre 1 : Contexte Le premier chapitre s'attache à dresser un panorama des outils convoqués dans le reste du manuscrit. Trois thèmes principaux sont abordés. Tout d'abord, on s'intéresse aux propriétés mathématiques des arbres phylogénétiques, qui servent de support aux développements ultérieurs, et on rappelle quelques résultats sur la structure de l'espace des caractères associés aux noeuds d'un tel arbre (section 1.1). Dans un deuxième temps, on décrit un certain nombre de modèles classiques d'évolution dynamique de traits, discrets ou quantitatifs, le long d'un arbre phylogénétique (sections 1.2, 1.3 et 1.4). Enfin, on évoque quelques résultats statistiques découlant de la la théorie de la sélection de modèle, qui seront utile dans la suite (section 1.5).

Arbres phylogénétiques, caractères convexes et parcimonie

En se basant essentiellement sur les livres de Semple & Steel (2003[START_REF] Felsenstein | Inferring Phylogenies[END_REF], on rappelle les définitions et propriétés suivantes. Tout d'abord, on appelle arbre phylogénétique un arbre dont les feuilles sont identifiées par un label distinctif (comme un nom d'espèce).

Définition (Arbre phylogénétique). Un arbre binaire raciné T = (V , E) est un graphe connecté acyclique, avec V un ensemble de noeuds, et E d'arêtes, tel que tous les noeuds internes sont de degrés 3, sauf un, la racine, de degré 2. Les noeuds externes, de degré 1, sont les feuilles de l'arbre.

Un arbre phylogénétique (sur X) T est un couple (T , φ), où T est un arbre, et φ : X → L une bijection depuis un ensemble de labels X, vers l'ensemble L des feuilles de T .

Pour chacune des ces espèces identifiées aux feuilles de l'arbre, on mesure un trait, ou caractère donné. On se limite ici aux caractères dit convexes, qui sont le résultats d'une évolution où chaque innovation est unique (la même innovation ne peut pas apparaître deux fois indépendamment, on dit aussi qu'il n'y a pas d'homoplasie).

Définition (Caractère convexe). Un caractère discret complet χ : X → C est une application de l'ensemble des feuilles d'un arbre phylogénétique (identifiées par leurs labels) vers un ensemble de caractères C. Si |χ(X)| = r, χ est un caractère à r états.

Une extension de χ sur T est une application χ : V → C telle que χ • φ = χ. On note Ex(χ, T ) l'ensemble de toutes les extensions de χ sur T .

χ est dit convexe s'il existe une extension χ telle que, pour tout c, c ∈ C, le sousgraphe de T induit par {v ∈ V | χ(v) = c} est connecté.

La proposition suivante porte sur l'énumération des caractères convexes sur une phylogénie. Elle nous sera utile lors de notre étude d'identifiabilité.

Proposition [START_REF] Steel | The complexity of reconstructing trees from qualitative characters and subtrees[END_REF], proposition 1, item 4). Le nombre de caractères complets à r états sur un arbre phylogénétique binaire ayant n feuilles est donné par :

2n -r -1 r -1 .
un espace de caractères arbitraire C (indifféremment discret ou continu). La loi de X est définie par :

X ρ ∼ D(θ 1 ) : la racine suit une loi donnée D, de paramètres θ 1 .

Soit e ∈ E une branche, allant de pa(i) à i. Sur cette branche, le trait évolue comme un processus stochastique (W e t , 0 ≤ t ≤ e ) de loi P (θ e ), et ceux indépendamment des autres espèces, conditionnellement à W e 0 = X pa(i) .

Au noeud i, on défini X i = W e e .

On itère le long de l'arbre jusqu'à ce que tous les noeuds soient visités.

Un exemple d'un tel modèle a été présenté en introduction pour un trait continu, en prenant comme processus P le BM. Lorsque l'espace d'état est discret, de nombreux modèles peuvent être décrits, qui permettent de modéliser par exemple l'évolution des bases aminées d'une séquence d'ADN. Ces modèles sont à la base des méthodes modernes pour inférer un arbre phylogénétique par maximum de vraisemblance.

Le modèle général décrit repose sur l'hypothèse fondamentale que les espèces évoluent de manière indépendantes les unes des autres après une spéciation. Cette hypothèse, bien que peu réaliste d'un point de vue biologique, est nécessaire pour le traitement mathématique simple du modèle. D'autres hypothèses doivent être faites sur le processus P , en fonction de l'espace d'états C choisi. Si l'on fait l'hypothèse générique que le processus est markovien on peut alors montrer que la loi de X peut être obtenu comme le résultat d'un modèle graphique orienté, tel que défini comme suit.

Définition (Modèle graphique orienté). Un vecteur X de variables aléatoires sur un espace C suit un modèle graphique orienté s'il se situe aux noeuds d'un graphe acyclique orienté, et est tel que sa distribution jointe peut se factoriser de la manière qui suit :

p θ (X) = i∈V p θ X i X pa(i)
où pa(i) est l'ensemble de tous les parents directs de i dans le graphe, et θ un vecteurs de paramètres de la distribution. Par convention, si pa(i) = ∅ (par exemple, à la racine d'un arbre), on prend : p θ X i X pa(i) = p θ (X i ).

En pratique, X se divise en deux composantes, Y, les traits aux feuilles de l'arbre, observées, et Z les traits aux noeuds internes de l'arbre, pour des espèces ancestrales, non observées. On est alors dans le cadre d'un modèle graphique à variables latentes. C'est dans ce cadre, bien étudié, que nous nous plaçons pour notre étude statistique.

Sélection de modèle

Le principe général de la sélection de modèle par vraisemblance pénalisée a été exposé plus haut dans cette introduction. On renvoie à Giraud (2014) pour une introduction construite à ces méthodes statistiques. Dans la suite, on se base sur la méthode LINselect, présentée dans [START_REF] Baraud | Estimator selection in the Gaussian setting[END_REF] Processus OU avec saut courant sur les branches de l'arbre. L'évolution de la moyenne du trait après le saut est indiqué en pointillé. Le temps de demi-vie phylogénétique nécessaire au trait pour parcourir en moyenne la moitié de la distance le séparant de l'optimum est indiqué en bordeaux. Ici, la force de sélection est grande par rapport à la taille de l'arbre.

À la différence du BM, les sauts adaptatifs sur l'OU n'ont pas lieu directement sur la valeur du trait, mais sur la valeur de l'optimum β, comme on le voit sur la figure ci-dessus. Un tel saut peut traduire un changement de conditions environnementales, qui induit un nouvel équilibre optimal, vers lequel le trait converge, de manière continue, et avec une vitesse contrôlée par la force de sélection α. Ce modèle OU, qui admet un état stationnaire et induit une variance bornée, a été proposé pour modéliser une évolution stabilisatrice.

Comme on l'a vu dans le chapitre précédent, la définition du modèle en terme de loi conditionnelle d'une espèce fille sachant la valeur de sa mère nous permet de reformuler le problème en terme de modèle graphique. Une autre vision, complémentaire, peut être obtenue en écrivant la loi des feuilles sous forme d'un régression linéaire.

Proposition (Modèle linéaire). On suppose que les noeuds internes de l'arbre sont numérotés de 1 à m, et ses feuilles de m + 1 à m + n. Soit T la matrice d'incidence de l'arbre, de taille n × (m + n), telle que, pour 1 ≤ i ≤ n et 1 ≤ j ≤ m + n, T ij vaut 1 si la feuille m + i est descendante du noeud j, et 0 sinon. Soit Y le vecteur des traits aux feuilles de l'arbre. Pour un modèle d'OU, on a :

Y = TW(α)∆ + σ 2 2α E
où ∆ est un vecteur (parcimonieux) de taille m+n, représentant les sauts sur les branches de l'arbre : pour tout noeud i, ∆ i vaut 0 s'il n'y a pas de saut sur la branche menant à i, et la valeur de ce saut sinon. W(α) est une matrice diagonale d'expression connue, et E est un vecteur gaussien, dont la matrice de variance V(α). Ces deux quantités ne dépendent que de α, et des paramètres (fixés) de l'arbre phylogénétique.

Cette vision du problème nous permet d'appliquer les outils de sélection de modèle évoqués précédemment, à condition de caractériser avec précision les modèles considérés, ce que l'on s'attache à faire dans la section suivante.

Identifiabilité

On s'intéresse ici à deux problèmes complémentaires. Premièrement, étant donnée une allocation de sauts sur les branches de l'arbre, on cherche à énumérer toutes les allocations distinctes qui lui sont équivalentes, au sens où elles produisent un modèle de même vraisemblance, comme exposé dans l'introduction. Cette question répond au problèmes d'identifiabilité. Deuxièmement, étant donné un nombre K de sauts fixés, on compte le nombre de modèles réellement distincts qui possèdent K sauts. Ce nombre nous donne la complexité de cette classe de modèle, dont on a besoin dans l'étape de sélection de modèle.

Ces problèmes peuvent s'étudier en utilisant le formalisme des caractères convexes introduit dans le chapitre précédent. Les deux points fondamentaux sont, d'une part, de se limiter aux allocations parcimonieuses de sauts sur l'arbre, et d'autre part, de représenter une classe d'équivalence pour une allocation donnée à K sauts par la classification en K + 1 groupes qu'elle induit aux feuilles.

La première question (énumération d'une classe d'équivalence) peut alors être réglée par un algorithme récursif, adapté de l'algorithme de Sankoff de programmation dynamique pour trouver le coût parcimonieux d'un caractère évoqué précédemment.

La seconde question (décompte du nombres de classes d'équivalences à K sauts) revient à un décompte des caractères convexes. Pour un arbre binaire, la proposition rappelée dans l'introduction nous permet ainsi de répondre à la question. On constate en particulier que la formule close exhibée ne dépend pas de la topologie de l'arbre. Pour vu comme une simple heuristique, dont la pertinence a été évaluée par un grand nombre de simulations.

Le méthode d'inférence pour le BM multivarié, efficacement implémentée dans le paquet PhylogeneticEM, est ainsi rapide et complète. Contrairement aux méthodes proposées jusqu'à présent, elle ne fait pas l'hypothèse que les traits sont indépendants les uns des autres. Cette hypothèse est particulièrement fausse sur beaucoup de jeux de donnés écologiques. Pour tenter de décorréller les traits, une adaptation phylogénétique de l'ACP (en anglais, pPCA) était utilisée jusqu'à présent. Cependant, lorsque les traits ont subis des sauts au cours de leur histoire, on peut montrer que cette méthode est biaisée, et peut fausser l'analyse. On s'attend ainsi à ce que notre méthode, qui en fait l'économie, donne de meilleurs résultats.

L'extension à l'OU multivarié est plus problématique. En toute généralité, le paramètre de force de sélection, α, se transforme en matrice A, difficile à gérée. La loi produite par ce processus général, bien que toujours gaussienne, n'est ainsi pas facile à étudier, et les interactions entre les matrices A et Σ de variance mal connues, et propres à générer des problèmes d'identifiabilité. Dans ce travail, on décide de simplifier le problème en ne considérant que des matrices A scalaires, c'est-à-dire égales à α fois la matrice identité. Cette hypothèse est assez restrictive, car elle suppose que tous les traits sont attirés par leurs divers optimums indépendamment, et avec une même vitesse. On ne fait en revanche pas d'hypothèse sur la matrice de variance Σ, si bien que les traits sont tout de même autorisés à évoluer de manière corrélé.

Lorsque toutes les données sont mesurées pour des espèces actuelles, à un seul moment dans l'histoire, on montre que l'OU est équivalent à un BM courant sur un arbre dont les branches ont été renormalisées, par une transformation dépendant de α. À α connu, il est alors possible de bénéficier de la méthode multivariée développée pour le BM. Il suffit alors de reproduire cette analyse sur une grille en α, avant de sélectionner la meilleure solution en terme de vraisemblance. L'étape de sélection de modèle utilise ensuite une heuristique similaire.

De même que précédemment, la performance de la méthode, sous divers scénarios explorant plusieurs formes de violations aux hypothèses du modèle, a été évaluée par simulations, et utilisée pour analyser des jeux de donnés classique issus de la littérature.

Chapitre 4 : Évolution de traits sur des réseaux phylogénétiques Ce chapitre s'éloigne de la thématique de la détection de ruptures pour explorer d'autres formes de relations de parentés entre les espèces, représentées non plus par un arbre, mais par un réseau phylogénétique. Il a fait l'objet d'une soumission dans un journal de biologie à comité de relecture (Bastide, Solís-Lemus, Kriebel, Sparks & Ané, 2017c). Les outils développés ici ont été intégrés au paquet Julia PhyloNetworks, dont la présentation a été publiée dans Molecular Biology and Evolution (Solís-Lemus, Bastide & Ané, 2017). La présentation que l'on en fait ici est adaptée du résumé long de l'exposé présenté aux 49 èmes Journées de Statistiques de la SFdS (Avignon, 2017).

Réseau phylogénétique

Les liens de parentés entre espèces sont représentées de manière classique par un arbre phylogénétique. Cependant, cette représentation arborescente ne tient pas compte des événements d'hybridations, ou de transferts de gènes horizontaux, qui peuvent modifier substantiellement les relations de filiation entre les espèces présentes. On a alors recours à un réseau phylogénétique pour représenter ces liens. Un réseau phylogénétique est un graphe acyclique dirigé et raciné, dont les feuilles représentent les espèces actuelles observées, et les noeuds internes des espèces ancestrales. Les noeuds internes peuvent avoir un seul parent (filiation arborescente) ou bien deux parents (hybridation). Le réseau est calibré en temps, si bien que la longueur des branches arborescentes représente un temps évolutif. L'événement d'hybridation étant instantané, les branches menant à un noeud hybride sont supposées de longueur nulle. Un paramètre γ leur est cependant associé, représentant une proportion de patrimoine génétique transmis par chacun des deux parents. Un exemple de réseau phylogénétique présentant un seul événement d'hybridation est présenté ci-dessous. Sur cet exemple, le noeud hybride M a hérité d'une proportion γ de ses gènes de l'espèce L, et le reste 1γ de l'espèce N . Plusieurs méthodes d'inférence ont été développées ces dernières années (voir par exemple [START_REF] Yu | Maximum likelihood inference of reticulate evolutionary histories[END_REF], Solís-Lemus & Ané (2016)), et ce type de réseaux phylogénétiques commence à être disponible pour un certain nombre de groupes d'espèces. Dans toute la suite, on suppose que le réseau est connu et fixé. Comparé au modèle d'évolution sur un arbre, le point nouveau est la règle de fusion adoptée aux points d'hybridations. Ici, la fusion par moyenne pondérée a été choisie, car elle conduit à des calculs simples, et est en accord avec la modélisation d'un trait multi-loci par le BM. Grâce à ce modèle, il est possible d'étendre les Méthodes Comparatives Phylogénétiques à des espèces liés par un réseau, plutôt que par un arbre phylogénétique. Le point central dans cette adaptation est le calcul de la matrice de variance induite par ce nouveau modèle. La covariance entre les traits Y i et Y j de deux espèces i et j aux feuilles du réseau phylogénétique s'écrit [START_REF] Pickrell | Inference of Population Splits and Mixtures from Genome-Wide Allele Frequency Data[END_REF]) :

Cov Y i ; Y j = σ 2 V ij = σ 2 p i ∈P i p j ∈P j       e∈p i γ e             e∈p j γ e       e∈p i ∩p j e
où σ 2 est la variance du mouvement Brownien, P i est l'ensemble des chemins allant de la racine au noeud i, et, pour une arrête e, γ e est le coefficient de transmission génétique (γ e = 1 pour toutes les arrêtes arborescentes), et e est la longueur de l'arrête, en temps phylogénétique.

Cette formule close, impliquant une somme sur un nombre potentiellement grand de chemins, ne peut pas être utilisée directement pour calculer efficacement la matrice de covariance. On montre qu'il est possible de trier les noeuds du réseau de telle sorte à ce que la matrice V puisse être calculée récursivement en un parcours du réseau, depuis la racine jusques aux feuilles.

Évolution transgressive

L'hétérosis, ou vigueur hybride, est un phénomène bien connu en génétique, qui rend possible la naissance d'un hybride ayant un caractère exceptionnellement grand (ou petit) par rapport à ses deux parents. Dans notre modèle, le trait hybride est alors obtenu comme la moyenne pondérée des traits espèces parentes, comme précédemment, plus un saut d'une valeur b. De la même manière que pour le BM sur un arbre, on montre qu'il est alors possible de ré-écrire le problème sous la forme d'un modèle linéaire à effets fixes, et ainsi de replacer la question dans un cadre statistique bien connu. Ce modèle est semblable à celui exposé précédemment, à la différence que la position potentielle des sauts est connue d'avance : ceux-ci ne peuvent avoir lieu que sur les branches suivant un événement d'hybridation. Ceci nous permet d'écrire un test de Fisher pour tester la nullité de ces sauts d'hétérosis, dont on sait exprimer la puissance théorique.

Chapitre 5 : Extensions et Perspectives

Dans ce dernier chapitre, on explore quelques pistes d'extensions, en essayant d'ébaucher des solutions simples lorsque cela est possible, et en identifiant les difficultés principales lorsqu'elles se présentent.

Dans tous nos développements méthodologiques, nous avons supposé disposer de mesures sans erreurs sur un arbre connu parfaitement. La non prise en compte de ces sources d'incertitudes peut avoir des conséquences néfastes sur le résultats de nos analyses, que l'on tente de quantifier à l'aide d'une série de simulations. Si la mauvaise connaissance de l'arbre est difficile à prendre en compte, les erreurs ou incertitudes de mesure des traits aux feuilles de l'arbre sont en revanche mieux étudiées dans la littérature. On montre ici Titre : Modèles de processus stochastiques avec sauts sur arbres : application à l'évolution adaptative sur des phylogénies Title : Shifted stochastic processes evolving on trees: application to models of adaptive evolution on phylogenies Keywords : Model selection, Comparative ecology, Phylogeny, Orstein-Uhlenbeck Abstract : This project is aiming at taking a step further in the process of systematic statistical modeling that is occurring in the field of comparative ecology. A way to account for correlations between quantitative traits of a set of sampled species due to common evolutionary histories is to see the current state as the result of a stochastic process running on a phylogenetic tree. Due to environmental changes, some ecological niches can shift in time, inducing a shift in the parameters values of the stochastic process modeling trait evolution. Because we only measure the value of the process at a single time point, for extant species, some evolutionary scenarios cannot be reconstructed, or have some identifiability issues, that we carefully study. We construct an incomplete-data model for statistical inference, along with an efficient implementation. We perform an automatic shift detection, and choose the number of shifts thanks to a model selection procedure, specifically crafted to handle the special structure of the problem. Theoretical guaranties are derived in some special cases. A phylogenetic tree cannot take into account hybridization or horizontal gene transfer events, that are widely spread in some groups of species, such as plants or bacterial organisms. A phylogenetic network can be used to deal with these events. We develop a new model of trait evolution on this kind of structure, that takes non-linear effects such as heterosis into account. Heterosis, or hybrid vigor or depression, is a well studied effect, that happens when a hybrid species has a trait value that is outside of the range of its two parents.

Université Paris-Saclay Espace Technologique / Immeuble Discovery Route de l'Orme aux Merisiers RD 128 / 91190 Saint-Aubin, France

  un sa ut a sh ift to En gli sh (se e wh at I di d th er e ?) to th an k th e wo nd er fu l, nic e, we lco mi ng peo ple I me t in Ma dis on Wi sco nsi n. M a n y th an ks to K en S yt sm a an d hi s L ab fo r w el co m in g m e in B ir g t t o a n t h e r a n d s e e d . A s p e c ia l th a n k to R ic a r d o , w h o s e m a n y q u a li ti e s a r e in s p ir in g . I w a s g la d to m e e t y o u a t F A C a n d b e y o n d a n d p r o m is e , I 'l l w o r k o n th a t F r e n c h a c c e n t T h a n k y o u a ls o to th e s ta ts p e o p le fo r th ri ll in g a n d s im u la ti n g d is c u s s io n s . d o in g w o rk a n d c o d e a n d m a th s a n d a ll w it h y o u w a s a re a l p le a su re ! tou s les m em br es de la co m m iss io n Fu lb rig ht fra nc o-am ér ica in e, qu i on t re nd u po ss ib le m on vo ya ge ou tre at la nt iq ue da ns le s m ei lle ur s co nd iti on s im ag in ab le s et on t fa ci lit é l'é cl os io n d' un e ex pé ri en ce ri ch e, in ou bl ia bl e et fé co nd e th an k yo u al so to al l th e m em be rs of th e II E , fo r th ei r co nt in uo us su pp or t, an d to th e vo lu n te er s o f th e U o f D el aw ar e an d T ex as , fo r th ei r w ar m w el co m e J'adre sse également tous mes sincères remerciement s à Élisabeth Gassiat, ainsi qu'à Amaur y Lambe rt, qui ont accepté de faire partie du jury de cette soute nanc e, tout comm e Hélè ne Morl on, que je rem erci e de surc roît pou r son suiv it bien veil lant dep uis le M2 .Je sui s très heu reu x et hon oré d'a voi r de tels exa min ate urs et j'e spè re qu e mo n tra va il ser a dig ne de cet te au die nc e acc ord ée.

  m o n c o m it é d e th è s e p o u r le u rs a id e , le u rs c o n s e il s , e t le u r é c o u te a tt e n ti v e g r a n d m e r c i à V in c e n t B a n s a y e e t C a th e r in e M a ti a s S a n d r in e P a v o in e

  BM on the branches of the tree. The vertical axis gives the value of the trait.

  BM on the branches of the tree.

  of Convex Characters on Phylogenies . . . . . . . . . . . . . . . . . . . 1.1.1 Phylogenetic Tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.2 Convex Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.3 Parsimony . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2 Latent Variable Models of Character Evolution . . . . . . . . . . . . . . . . . 1.2.1 A Generic Model for Trait Evolution on a Tree . . . . . . . . . . . . . 1.2.2 Directed Graphical Models and Latent Variables . . . . . . . . . . . . 1.2.3 Pruning Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2.4 Expectation Maximization . . . . . . . . . . . . . . . . . . . . . . . . . 1.3 Discrete Models of Evolution and Tree Reconstruction . . . . . . . . . . . . . 1.3.1 Continuous Time Markov Chains . . . . . . . . . . . . . . . . . . . . . 1.3.2 Models of DNA Evolution . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.3 Molecular Clocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.4 Tree Reconstruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.4 Continuous Models of Evolution . . . . . . . . . . . . . . . . . . . . . . . . . 1.4.1 Models of Evolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.4.2 Phylogenetic Comparative Methods . . . . . . . . . . . . . . . . . . . 1.4.3 Detecting Shifts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.4.4 Algorithms for Likelihood Computation . . . . . . . . . . . . . . . . . 1.4.5 Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5 Model Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.1 Penalized Likelihood . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.2 Model selection à la Birgé & Massart (2001) . . . . . . . . . . . . . . 1.5.3 The Lasso Penalty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.4 Model selection with LINselect . . . . . . . . . . . . . . . . . . . . . . Appendices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.A The Ornstein-Uhlenbeck Process . . . . . . . . . . . . . . . . . . . . . . . . . 1.A.1 Stochastic Differential Equation and General Solution . . . . . . . . . 1.A.2 Induced Variance Structure . . . . . . . . . . . . . . . . . . . . . . . . 1.A.3 Incomplete Data Formulation . . . . . . . . . . . . . . . . . . . . . . . 1.B Multivariate Analysis Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.B.1 Kronecker Product and Vectorization . . . . . . . . . . . . . . . . . . 1.B.2 Hadamard Product . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Figure 1

 1 Figure 1.1.1 -A rooted binary tree with 5 tips (nodes {4, 5, 6, 8, 9}) and 4 internal nodes (nodes {1, 2, 3, 7}). The root is node 1. In addition, we have: pa(3) = {2}, anc(3) = {1, 2, 3}, child(3) = {4, 5} and des(3) = {3, 4, 5}. The nodes are numbered in a preorder.When visiting the nodes in this order, we know when we see a new node that we already visited all its ancestors. A postorder is obtained by reversing this order.

  (a) Convex character, homoplasy free evolution. (b) Non-convex character, convergent transition.

Figure 1

 1 Figure 1.1.2 -A phylogenetic tree with a convex (left) and non-convex (right) character.For the convex character, "white" and "grey" are unique innovations of the two tips on the left. For the non-convex one, the "grey" innovation appears twice: this is an example of convergent evolution. There are several possible extension of the character on the internal node (see Section 1.1.3), but none is homoplasy free for the non-convex character.

Figure 1 . 4 . 1 -

 141 Figure 1.4.1 -Realization of a univariate BM process (with µ = 0 and σ 2 = 0.04) on a calibrated tree. The colors of the branches (left) match with the colors of the distinct processes (right). Only tip values are observed (at time t = 0).

  Figure 1.4.2 -One realization of a univariate OU process, with fixed root µ = 0, variance σ 2 = 0.04, optimal value β = 3, and selection strength α such that t 1/2 = ln(2)/(2α) = 25% of the total time allocated (h = 200).

Figure 1 . 4 . 4 -

 144 Figure 1.4.4 -Scatter plot of traits A and B. The dotted line is the simple regression line (R function lm, R Core Team, 2017). A Pearson correlation test between the two traits (R function cor.test) gives a p-value of 3.9e -05. This would lead us to conclude that the two traits are biologically correlated. (The arbitrary scales on the axes are omitted).

  Figure 1.4.6 -Scatter plot of contrasts on traits A and B (computed with ape (Paradiset al., 2004) function pic). A Pearson correlation test between the two traits gives a p-value of 0.88: there is no significant correlation between the two traits. (Arbitrary scales omitted.)

Figure 1

 1 Figure 1.4.7 -Transformations of the tree induced by Pagel's λ parameter.

  Figure 1.4.8 -Transformations of the tree induced by Pagel's κ parameter.

  Figure 1.4.9 -Transformations of the tree induced by Pagel's δ parameter.

  Figure 1.4.10 -Transformations of the tree induced the OU process.

  then based on the posterior distribution of a model p η Y given the observations:

Figure 1

 1 Figure 1.5.1 -A matrix (left) and its vectorized form (right), obtained by stacking all the columns. The first line of the matrix (in blue) is dispersed on the vector, forming a group G 1 = {kn + 1 : 0 ≤ k ≤ p -1} of coordinates.

Figure 2 .

 2 Figure 2.1.1 -Trait evolution under a Brownian Motion. The ancestral value of the trait is 0, and the observed values (time 800) range from -4 to 11 for extant species. One shift occurs on the parent branch of (D,E), changing the trajectory of their ancestral trait value from the grey one to the colored one. The shift increases the observed dispersion.

Figure 2 .

 2 Figure 2.2.1 -A rooted and time calibrated phylogenetic tree with the notations used to parametrize the tree (l, t, d, b) and the observed (Y ) and non-observed (Z) variables.

Figure 2 .

 2 Figure 2.3.1 -Equivalent allocations in the BM case. Mean tip values are represented by colors and equal for all allocations. The two allocations on the right are parsimonious.

Figure 2 .

 2 Figure 2.3.1 shows a simple example where the model is not identifiable in the BM case.Here, four distinct allocations give the same mean values (µ + δ 1 , µ + δ 2 ) at the tips. The lack of identifiability is due to the non-invertibility of the tree matrix T.

  Lemma 2.3.1. Let b be the canonical basis of R m+n , and S a supplementary space of ker(T). Then b = (K 1 , • • • , K m , b m+1 , • • • , b m+n ) is a basis adapted to the decomposition ker(T) ⊕ S, and the matrix U (as defined in Section 2.2.3) is the change of basis matrix between b and b . As a consequence, U is invertible. Proof of lemma 2.3.1. First, (b m+1 , • • • , b m+n ) is a family of n independent vectors of S of dimension n, so is a basis of S, and b is a basis adapted to ker(T) ⊕ S.

  and, from equation (2.7), Ub i = b i . This shows that U is the change of basis matrix between b and b .

Figure 2

 2 Figure2.3.2 -Five equivalent shift allocations that produce colorings that are adapted to an OUsun, with α = 3 and γ 2 = 0.1. The box at the root represents the ancestral optimum β 1 , and the boxes on the branches represent the positions and values of the shifts on the optimal value. While accounting for very different evolutionary scenarios, all allocations produce the same trait distribution at the tips.

  Proposition 2.3.5 (Computation of the Number of Equivalent Classes). Let i be a node of tree T , and K ∈ N * .

  t 1/2,b = 23%), γ 2 b = 0.5 and K b = 5. The parameters then varied in the following ranges: the phylogenetic half life t 1/2 = ln(2)/α took 11 values in [0.01 , 10]; the root variance γ 2 = σ 2 2α took 9 values in [0.05 , 25]; the number of shifts K took 9 values in [0 , 16] (see Figures 2.5.2-2.5.3 for the exact values taken).

Figure 2

 2 Figure 2.5.1 -Left: Simulated configuration (with t 1/2 = 0.75, γ 2 = 0.5 and K = 5). The shifts positions and values are marked on the tree. The value of the character generated (positive or negative) is represented on the right. The colors of the branches correspond to the true regimes, black being the ancestral state. Right: One of the three equivalent allocations of shifts for the model inferred from the data, with corresponding vector of mean tip values. Shifts not recovered are located on pendant edges, and have low influence on the data. The two other equivalent allocations can be easily deducted from this one.

Figure 2

 2 Figure2.5.2 -Box plots over the 200 repetitions of each set of parameters, for the phylogenetic half-life (top) and root variance (bottom) with K estimated, and α fixed to its true value (blue) or estimated (red), on a tree with 128 taxa. For better legibility, the y-axis of these two rows were re-scaled, omitting some outliers (respectively, for t 1/2 and γ 2 , 0.82% and 0.46% of points are omitted). The whisker of the first box for t 1/2 goes up to 7.5.

Figure 2 .

 2 5.2 (first row) shows that we tend to slightly over-estimate α in general. The estimation is particularly bad for large values of α (with a high variance on the result, see first box of the row), and low values of α.

Figure 2

 2 Figure2.5.3 -Same for β 1 (top), the number of shifts (middle) and ARI (bottom), with α estimated, and K fixed to its true value (blue) or estimated (red). As previously, the y-axis of the first row (β 1 ) was re-scaled, omitting some outliers (1.39% of points are omitted).

Figure 2 .

 2 Figure 2.6.1 -Phylogenetic tree of the Chelonians. Log-transformed trait values are represented on the right. Branch colors represent the habitats. The shifts found by our EM algorithm are shown as circles, with a color indicating the value of the shift, from blue (negative) to red (positive). Boxes highlight the groups induced by the shifts. The x-scale is in million years.

  (using the R package OUwie, with fixed positions for the shifts),Uyeda & Harmon (2014) (implemented in package bayou), Ingram & Mahler (2013) (package SURFACE), and Ho & Ané (2014) (function OUshifts in package phylolm). See Section 2.F.3 in Appendix 2.F for more details on these methods and the parameters we used.

Figure 2 .

 2 Figure 2.B.1 -Partition of paths according to whether they reach (A) or cross (B) the line x = n

Figure 2 .B. 2 -

 22 Figure 2.B.2 -Partition of paths according to whether to the move used between x = n and x = n + 1. Cases A, B and C correspond to the items listed in the main text.

Figure 2 .Figure 2 .F. 4 -

 224 Figure 2.F.3 -Box plots over the 200 repetitions of each set of parameters, for the log-likelihood (top), phylogenetic half-life (middle) and root variance (bottom) with α estimated, and K fixed or estimated, on a tree with 128 taxa.

Figure 2 .

 2 Figure 2.F.5 -Solutions found by the EM (top left), bayou (top right), SURFACE (bottom left) and OUshifts (bottom right).The branch coloring represents the habitats. For the EM, bayou and OUshifts, the shifts coloring represents their values, from blue (negative) to red (positive). For bayou, the size of the circles are proportional to their posterior probability. For SURFACE, the 13 colors of the shifts represent the regimes.

Figure 3

 3 Figure 3.3.1 -Bivariate traits simulated as a BM under three scenarios: no shift (left), shift on a long branch (middle) and shift on a short branch (right). Species affected by the shift are in dark red. Top: Phylogenetic tree, shift position and simulated trait values. Bottom: Scatterplot of species in the trait space and corresponding first eigenvector computed from the true covariance R (red) or found by PCA (green) and pPCA (blue).

Figure 3

 3 Figure 3.4.1 -Shifts locations and magnitudes used in the base scenario. Mean trait values are identical for the 4 traits, up to a multiplicative ±1 factor and shown at the tips. Colors correspond to the different regimes. The bar plots on the right represent the expected traits values under the base model.

Figure 3 . 4 . 2 -

 342 Figure 3.4.2 -Impact of trait correlation r d (left) and unequal selection strengths s (right) on group separation, as defined in Eq. (3.4). Unequal selection strengths (s > 1)and trait correlations (r d > 0) both increase group separation and make it easier to detect shifts.

Figure 3 . 4 . 4 -

 344  and number of shifts selected (bottom) for the solutions found by PhylogeneticEM (red) and 1ou (blue). Each box corresponds to one of the configuration shown in Figure3.4.1, with a scaling factor varying between 0.5 and 3, and a true number of shift between 0 and 15 (solid lines, bottom). For the ARI, the two lines represent the maximum (1) and expected (0, for a random solution) ARI values.

Figure 3

 3 Figure 3.4.8 -ARI of the solutions found by PhylogeneticEM (red) and 1ou (blue), without (solid lines) or with (dotted lines) pPCA preprocessing. (a) Trait correlation (r d ) increases from 0 to 0.8. (b) Each box corresponds to one of the configuration shown in Figure 3.4.1, and shifts are increasingly large with a scaling factor varying between 0.5 and 3.

Figure 3

 3 Figure 3.5.1 -Solution given by PhylogeneticEM for K = 5 (left) against groups defined in Aristide et al. (2016, Fig. 3) (right), based on ecological criteria including locomotion (arboreal quadrupedal walk, clamber and suspensory locomotion or clawed locomotion), diet (leaves, fruits, seeds or insects) and group size (smaller or larger than 15 individuals). The inset graph shows the model selection criterion. The minimum is for K = 4, but K = 5 is also a good candidate.

  Estimated Variance-Covariance Matrix. Taking

Figure 3 .B. 2 -

 32 Figure 3.B.2 -Maximum likelihood solution with 4 shifts selected by the method.

Figure 3 .

 3 Figure 3.B.3 -The three equivalent maximum likelihood shift allocations for the solution with 5 shifts.

α

  Figure 3.C.1 -Likelihood profile for all the α values, on the New World Monkey dataset. Each colored line represents the likelihood of the solution for a given α. The maximum value of the likelihood for each K is emphasized. The maximum is not reached by the same value of α for each K. Colors in log scale.

Figure 3

 3 Figure 3.D.1 -KL divergences from the base model

Figure 3

 3 Figure 3.D.2 -Sensitivity (top) and precision (bottom) for the solutions found by Phylo-geneticEM (red) and 1ou (blue). Each box corresponds to one of the configuration shown in Figure 3.4.1, with a scaling factor varying between 0.5 and 3, and a true number of shift between 3 and 15 (solid lines, bottom).

Figure 3

 3  and precision (bottom) for the solutions found by Phy-logeneticEM (red) and 1ou (blue). Each panel corresponds to a different type of misspecification (except Model A) and the parameters r d , s and r s control the level of mis-specification, with leftmost values corresponding to no mis-specification. For the ARI, the solid lines represent the maximum (1) and expected (0, for a random solution) ARI values.

  Figure 4.1.3 for an example.

Figure 4 .

 4 Figure 4.1.3 -Incomplete Lineage Sorting (ILS). The species tree (hull) constrains the form of the gene tree (line): for instance, lineages from A and B cannot coalesce before time T 1 . However, they can still coalesce after time T 2 , as shown here, so that B and C merge before A. This example of ILS makes the gene tree ((A,(B,C)),D) (in Newick format) discordant with the species tree (((A,B),C),D).Figure taken from Kubatko (2009).

  Figure 4.1.3 -Incomplete Lineage Sorting (ILS). The species tree (hull) constrains the form of the gene tree (line): for instance, lineages from A and B cannot coalesce before time T 1 . However, they can still coalesce after time T 2 , as shown here, so that B and C merge before A. This example of ILS makes the gene tree ((A,(B,C)),D) (in Newick format) discordant with the species tree (((A,B),C),D).Figure taken from Kubatko (2009).

  Figure 4.1.4 for an example.

Figure 4 .

 4 Figure 4.1.4 -ILS on a phylogenetic network. Four independent loci (shapes) are illustrated. Two gene trees are depicted for the triangle and diamond loci. Both agree on a same tree shape (A,(B,C)). However, the red tree is obtained through ILS, whereas the blue one is due to hybridization. Figure slightly modified from Yu et al. (2014).

Figure 4

 4 Figure 4.2.1 -Non-zero hybrid branch length case. Species B goes extinct or is unsampled. In the sampled network, everything happens as if the event involved noncontemporary species A and C.

  BM on the branches of the network

Figure 4 .

 4 Figure 4.2.3 -Realization of a univariate BM process (with µ = 0 and σ 2 = 0.04) on a calibrated network, with heterosis. The shift occurs right after the hybridization event, and changes the trajectory of the BM from the grey one to the colored one.

  a hybrid, then denote by a and b its two parents, by e a and e b the corresponding edges, with coefficients γ e a and γ e b . Then for any node k above i, we have: P k→i = {(p a , e a ) : p a ∈ P k→a } ∪ {(p b , e b ) : p b ∈ P k→b }, so that, from definition 4.2.2:

Figure 4

 4 Figure4.3.1 -Empirical power of the LRT of hybridization, for four different network topologies (shown above), and two different test levels (colors). All hybridization events on the original networks had minor weights γ. The empirical distribution of the statistic under H 0 (no hybridization event, γ = 0) and various alternative (0 < γ ≤ 0.5) were obtained on 100, 000 simulations. The mean and variance of the BM were fixed, respectively, to 0 and 1. Dotted lines show the levels of the test, that should be below the power.

Model H 0

 0 No heterosis b = 0 and d = 0 H 1 Single effect heterosis b 0 and d = 0 H 2 Multi effect heterosis b 0 and d 0

  Figure 4.3.2 (bottom line) for three test levels.

Figure 4 . 3 . 2 -

 432 Figure 4.3.2 -Theoretical power of the single effect heterosis test H 0 vs H 1 , for four different networks topologies with inheritance probability γ = 0.4, and a BM with variance σ 2 = 1.

Figure 4

 4 Figure 4.3.3 -Theoretical power of the heterogeneity heterosis effect test H 1 vs H 2 , for three different networks topologies with inheritance probability γ = 0.4, and a BM with variance σ 2 = 1.

  (ancTrait1) # format the prediction intervals for the plot plot(truenet, nodeLabel = ancInt)

O

  As we know the true ancestral states here, we can compare them to our estimation.

  julia> predictions = DataFrame(infPred=predint(ancTrait1)[1:7, 1], trueValue=sim1[:InternalNodes], supPred=predint(ancTrait1)[1:7, 2]) 7x3 DataFrames.DataFrame

[

[

  function, a prediction interval is shown for the missing values.

  delta = 5.0; # value of heterosis underHyb = [(n == "A" || n == "B") for n in tipLabels(sim1)] # tips under hybrid underHyb 1:length(trait3) underHyb[i] && (trait3[i]+=delta) # add delta to tips A and B end trait3 # changed: +5 was added by the previous loop to A and B

  dat = DataFrame(trait1 = trait1, trait2 = trait2, trait3 = trait3, underHyb = underHyb, tipNames = tipLabels(sim1)) dat[:underHyb] = PooledDataArray(dat[:underHyb])

Proposition 4 .

 4 B.1. The following proposition holds:

Proposition 4 .B. 2 .

 42 Assume that N is a level-1 network. If there are k hybrid species p 1 , • • • , p k in the network N , with parents (a 1 , b 1 ), • • • , (a k , b k ) and coefficients γ 1 , • • • , γ k , then the variance matrix can be written as a linear combination of variance matrices of trees:

Lemma 4 .

 4 B.1. Assume that N is a level-1 network. Take p 1 and p 2 two hybrid nodes, with parents (a 1 , b 1 ) and (a 2 , b 2 ). Denote by des(p 1 ) the set of all descendants of p 1 . The following holds: p 2 ∈ des(p 1 ) ⇐⇒ a 2 ∈ des(p 1 ) and b 2 ∈ des(p 1 )

Figure 5

 5 Figure 5.1.1 -Estimated number of shifts, ARI and Root Mean Square Error (RMSE) of the diagonal coefficient of stationary variance matrix Γ and selection strength α, for Phy-logeneticEM with the default model selection criterion, when the diagonal measurement errors e increase.

2 -

 2 Figure 5.1.2 -Estimated number of shifts, ARI and Root Mean Square Error (RMSE) of the diagonal coefficient of stationary variance matrix Γ and selection strength α, for PhylogeneticEM with the default model selection criterion, when the correlations r e of the measurement error increase (with e = 0.5 fixed).

Figure 5

 5 Figure 5.1.3 -Estimated number of shifts, ARI and Root Mean Square Error (RMSE) of the diagonal coefficient of stationary variance matrix Γ and selection strength α, for PhylogeneticEM with the default model selection criterion (blue), or an alternative one (red) when the tree modification factor 1/l increases.

4 Figure 5

 45 Figure 5.1.5 -A phylogenetic tree with 5 tips and 4 internal nodes, and several measurements at each tips. For instance, species 5 was measured twice, while species 6 was only measured once. Terminal branches linking tips (noted Y) with observations (noted Y o ) have length 0.

  Definition 5.4.1 (MCAR, MAR, NMAR,Little & Rubin 2002, Eq. (1.1) to (1.3)). Let Y be a n × p be the matrix of the complete data, with n individuals and p traits, and M the n × p missing data indicator matrix: for any individual i, 1 ≤ i ≤ n, and trait l,1 ≤ l ≤ p, Y il is actually measured if and only if M il = 1. Assume that the conditional distribution p ψ (M | Y) of M given Y is described by parameters ψ.The data are called missing completely at random (MCAR) if missingness does not depend on the data:p ψ (M | Y) = p ψ (M).Denoting Y miss the missing components of Y, and Y obs the observed components, the data are called missing at random (MAR) if missingness only depends on the observed data:p ψ (M | Y) = p ψ (M | Y obs ).

  p θ,ψ (Y obs , M, Y miss , Z) = p ψ (M | Y obs , Y miss , Z )p θ (Y obs , Y miss , Z).Then, setting up an EM algorithm framework, we need to look at the conditional expectation of the completed log-likelihood given the observations:E log p θ,ψ (Y obs , M, Y miss , Z) Y obs , M = E log p ψ (M | Y obs , Y miss , Z) Y obs , M + E [ log p θ (Y obs , Y miss , Z) | Y obs , M ] .

  Arbre phylogénétique daté. La position verticale des espèces actuelles (feuilles) est arbitraire.

  BM sur les branches de l'arbre. L'axe vertical donne la valeur du trait (unité arbitraire).

  BM sur les branches de l'arbre.Même processus, mais avec un saut sur la branche vert clair (entre S et T ). Les feuilles D et E sont affectées par le saut ancestral : leur trait a une valeur bien plus grande que celle attendue en l'absence de saut (en gris).

2

 2 Deux scénarios équivalents. On suppose que le trait évolue suivant un BM avec des sauts marqués sur les branches de l'arbre, et partant d'une valeur ancestrale de 0. L'espérance du trait aux feuilles est indiquée en bleu. Les deux scénarios, bien que donnant la même distribution du trait, ne sont pas équivalents d'un point de vue biologique. Dans le scénario de gauche, les deux enfants de l'espèce S sont chacun affectés par un événement extrême, qui conduit à deux sauts dans la valeur de leurs traits respectifs. Dans celui de droite, c'est l'espèce ancestrale qui subit d'abord un saut, transmis en l'état à son premier enfant C, tandis que son second enfant s'ajuste avec un deuxième saut.

  OU sur les branches de l'arbre.

  Réseau phylogénétique. Le noeud L est hybride.RN est la longueur de la branche allant de R à N.

  Variation du trait en fonction du temps. Seule la valeur du processus aux feuilles est observée.

Figure 6

 6 Figure 6.0.1 -Réseau phylogénétique d'un ensemble d'espèces contemporaines, et modélisation de l'évolution d'un caractère par un mouvement Brownien.

  Mots clefs : Sélection de Modèle, Écologie Comparative, Phylogénie, Orstein-Uhlenbeck Résumé : Le projet s'inscrit dans la dynamique de systématisation statistique qui s'opère aujourd'hui dans le champ de l'écologie comparative. Les différents traits quantitatifs d'un jeu d'espèces échantillonné peuvent être vus comme le résultat d'un processus stochastique courant le long d'un arbre phylogénétique, ce qui permet de prendre en compte des corrélations issues d'histoires évolutives communes. Certains changements environnementaux peuvent produire un déplacement de niches évolutive, qui se traduisent par un saut dans la valeur du processus stochastique décrivant l'évolution au cours du temps du trait des espèces concernées. Parce qu'on ne mesure la valeur du processus dynamique qu'à un seul instant, pour les espèces actuelles, certains scénarii d'évolution ne peuvent être reconstruits, ou présentent des problèmes d'identifiabilité, que l'on étudie avec soin. On construit ici un modèle à données incomplètes d'inférence statistique, que l'on implémente efficacement. La position des sauts est détectée de manière automatique, et leur nombre est choisi grâce à une procédure de sélection de modèle adaptée à la structure du problème, et pour laquelle on dispose de certaines garanties théoriques. Un arbre phylogénétique ne prend pas en compte les phénomènes d'hybridation ou de transferts de gènes horizontaux, qui sont fréquents dans certains groupes d'organismes, comme les plantes ou les bactéries. Pour pallier ce problème, on utilise alors un réseau phylogénétique, pour lequel on propose une adaptation du modèle d'évolution de traits quantitatifs décrit précédemment. Ce modèle permet d'étudier l'hétérosis, qui se manifeste lorsqu'un hybride présente un trait d'une valeur exceptionnelle par rapport à celles de ses deux parents.

  If A and B are squared with eigenvalues (λ 1 , . . . , λ m ) and (µ 1 , . . . , µ p ), then A ⊗ B has eigenvalues (λ j µ l ) 1≤j≤m;1≤l≤p .

and B are non-singular) |A ⊗ B| = |A| p |B| m tr(A ⊗ B) = tr(A) tr(B) e A ⊗ e B = e A⊕B where A ⊕ B = A ⊗ I m + I p ⊗ B 1.B.1.2 Vectorization Definition 1.B.2. The vectorized vector of an m × n matrix A is obtained by staking its columns together: vec(A) = (A 11 , . . . , A m1 , A 12 , . . . , A m2 , . . . , A 1n , . . . , A mn ) T

Table 2 .

 2 1 -Summary of the results obtained with several methods for the Chelonian Dataset. For bayou, the median of the posterior distributions is given. (Coloring concatenation). Let i be a node of tree T with L i daughter nodes

		EM	bayou	SURFACE OUshifts
	Number of shifts 16	5	17	33	8
	Number of regimes 4	6	18	13	9
	lnL -133.86 -97.59 -91.54 30.38	-79.79
	Marginal lnL NA	NA	-149.09 NA	NA
	α (×h, per my) 9.32	12.76 36.54	1.72	3.25
	ln 2/α (my) 15.56 σ 2 (×h, per my) 6.21 γ 2 0.33	11.36 3.97 5.57 11.91 0.22 0.16	84.28 0.72 0.21	44.64 2.29 0.35
	CPU time (min) 65.25	134.49 136.81 634.16	8.28

  Scope of the Article . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2 Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Simulations Studies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Appendices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.A PCA: Mathematical Derivations . . . . . . . . . . . . . . . . . . . . . . . . . 3.B PhylogeneticEM case study: New World Monkeys . . . . . . . . . . . . . . . . 3.B.1 Loading and Plotting the data . . . . . . . . . . . . . . . . . . . . . . 3.B.2 Analyzing the data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.B.3 Plotting Equivalent Solutions . . . . . . . . . . . . . . . . . . . . . . . 3.C EM Inference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.C.1 M step . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.C.2 E step . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.C.3 EM Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

	Chapter 3
	Shift Detection for Multivariate Processes

Contents 3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.1.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.1.2 State of the Art . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.1.3 3.2.1 Trait Evolution on a Tree . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.2 Simplifying Assumptions . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.3 Identifiability Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.4 Re-scaling of the Tree . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.5 Statistical Inference . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.6 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3 pPCA and Shifts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3.1 pPCA is biased in the presence of shifts . . . . . . . . . . . . . . . . . 3.3.2 Illustration: a simple example . . . . . . . . . . . . . . . . . . . . . . . 3.4 3.4.1 Experimental Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.4.2 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.5 3.5.1 New World Monkeys . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.5.2 Lizards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.5.3 Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.6 3.6.1 Interpretation Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.6.2 Noncausal Correlations . . . . . . . . . . . . . . . . . . . . . . . . . . 3.6.3 Nature of the jumps . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.C.4 Grid on α . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.D Simulations Appendices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.D.1 Kullback-Leibler Divergences . . . . . . . . . . . . . . . . . . . . . . . 3.D.2 Note on the ARI (Hubert & Arabie, 1985) . . . . . . . . . . . . . . . . 3.D.3 Supplementary Figures . . . . . . . . . . . . . . . . . . . . . . . . . .

  Figure 3.4.3 -Shifts locations and magnitudes used for the test trees with, respectively,

	1.6	1.8
				1.8
	-2	-1.9		-1.8
				1.7
	2.1	1.8
			-1.03 1.06	-1.02	0.99
	1.7	1.7
				1.7
		-1.7		-1.7
	-1.7			1.8
		1.7
	1.9
	-1	1	-1.04	1.06	-1.03	1.04

  Inference running times (in log-scale) of scOU and 1ou. All tests were run on a high-performance computing facility with CPU speeds ranging from 2.2 to 2.8Ghz. three moderate shifts, pPCA preprocessing slightly decreases performance for low levels of correlations (r d ≤ 0.2) but drastically improves them for moderate to high correlations levels (r d ≥ 0.6).

	1.00	Model A						Model B ntaxa			Model C 80.00				Model D
	0.25 0.50 0.75	time (seconds)	300 600 3600 72000								0.25 0.50 0.75 1.00 2.00 20.00 10.00 5.00	time (hours)	Method PhylogeneticEM l1ou			ARI
	0.00 1.25			30 60	3 2	6 4 9 6 1 2 8 1 6 0 1 9 2 2 5 6								l1ou Method PhylogeneticEM
	1.00
	0.50 0.75 Figure 3.4.7 -																		RMSE Diag Γ
	0.25
	0.00
	1	2 α	3	0	0 . 2	0 . 4 r d	0 . 6	0 . 8	1	2	4 s	6	8	0	0 . 2	0 . 4 r s	0 . 6	0 . 8
									ntaxa		NA (%)
						1.00
						0.75
																Method
					ARI	0.50									PhylogeneticEM l1ou
						0.25
						0.00
							3 2 6 4 9 6 1 2 8 1 6 0 1 9 2 2 5 6	0 0 . 0 5 0 . 1 0 . 2 0 . 5
	Figure 3.4.6 -ARI of the solutions found by PhylogeneticEM (red) and 1ou (blue) when
	the number of taxa (left) or the number of missing values (right) increases. No ARI is
	available for 1ou when there are missing values as it does not accept them in the version
	used here, v1.21.

Figure 3.4.5 -ARI (top) and root mean squared error (RMSE) of the diagonal values of the estimated stationary variance Γ (bottom) for the solutions found by PhylogeneticEM (red) and 1ou (blue). Each panel corresponds to a different type of mis-specification (except Model A) and the parameters r d , s and r s control the level of mis-specification, with leftmost values corresponding to no mis-specification. For the ARI, the solid lines represent the maximum (1) and expected (0, for a random solution with the same number and size of clusters) ARI values.

Impact of pPCA on Shift Detection Accuracy. To illustrate how pPCA can both improve and hamper shift detection, we compared PhylogeneticEM on raw traits to 1ou on both raw traits and phylogenetic PCs. Figure

3

.4.8a shows that in our base scenario, with

  .B.2). The same optional parameters can be used as before to control how the figure should look like. plot(res, edge.width = 2, show.tip.label = TRUE)

	PC1		PC2
				Saguinus bicolor Saguinus midas Saguinus mystax Saguinus fuscicollis Callithrix jacchus Callithrix penicillata Callithrix kuhlii Callithrix aurita Mico humeralifer Mico chrysoleucus Mico argentatus Cebuella pygmaea Callimico goeldii Leontopithecus chrysomelas Leontopithecus rosalia Aotus azarae Aotus nigriceps Aotus vociferans Cebus apella Cebus robustus Cebus albifrons Cebus capucinus Saimiri sciureus Saimiri boliviensis Ateles geoffroyi Ateles marginatus Ateles paniscus Ateles chamek Lagothrix lagotricha Brachyteles hypoxanthus Brachyteles arachnoides Alouatta macconnelli Alouatta seniculus Alouatta caraya Alouatta belzebul Alouatta guariba Alouatta palliata Alouatta pigra Callicebus moloch Callicebus brunneus Callicebus donacophilus Callicebus personatus Cacajao calvus Cacajao melanocephalus Chiropotes satanas Chiropotes chiropotes Pithecia monachus Pithecia irrorata Pithecia pithecia
	-0.1	0.1	-0.04	0.05

  Dealing with Tree and Trait Uncertainty . . . . . . . . . . . . . . . . . . . . . 197 5.1.1 Simulation Studies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 5.1.2 Including Trait Measurement Errors . . . . . . . . . . . . . . . . . . . 201 5.1.3 Factor Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202 5.2 Convergence and Sparsity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 5.2.1 Convergence and Fused-ANOVA . . . . . . . . . . . . . . . . . . . . . 203 5.2.2 Sparse Number of Shifted Traits . . . . . . . . . . . . . . . . . . . . . 205 5.3 Non-Ultrametric Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 5.3.1 Identifiability and Model Selection . . . . . . . . . . . . . . . . . . . . 205 5.3.2 Inference of the OU . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 5.4 Sampling Scheme and Missing Data . . . . . . . . . . . . . . . . . . . . . . . 212

	Chapter 5
	Extensions and Perspectives
	Contents
	5.1

  . Cette méthode s'applique à des problèmes écris sous forme de régression linéaire : Y = µ + σ 2 E avec E un vecteur de variables gaussiennes i.i.d., et σ 2 un paramètre de variance inconnu. Les différents modèles sont représentés par les espace vectoriels de divers dimensions dans lequel on autorise µ à évoluer. Chapitre 2 : Détection de sauts pour des processus univariés Ce chapitre à fait l'objet d'une publication dans le Journal of the Royal Statistical Society (Bastide, Mariadassou & Robin, 2017b). Il s'attaque au problème de la détection de sauts adaptatifs dans le cas univarié : seul un trait est mesuré pour chaque espèce. Cette étude se fait en trois étapes principales. On s'intéresse tout d'abord à la définition et aux propriétés des modèles utilisés, avant d'en étudier l'identifiabilité en détails, puis d'en proposer une procédure d'inférence statistiques, que l'on valide grâce à une campagne de simulations, et dont on étudie les résultats sur un jeu de données classique. Modèle Le modèle d'évolution du trait est le même que celui décrit ci-dessus, en prenant comme espace d'états C la droite réelle, et comme processus P le BM, ou le processus d'Ornstein-Uhlenbeck (OU). Un trait (X t ) t≥0 suivant ce processus a pour l'équation différentielle stochastique : dX t = α(β -X t )dt + σ dB t , où (B t ) t≤0 est le mouvement brownien et σ 2 un paramètre de variance. La partie déterministe de l'équation décrit un mouvement de rappel vers une valeur centrale, β, interprétée comme la valeur optimale du trait dans un environnement donné, avec une vitesse contrôlée par le paramètre de rappel élastique α. Ce paramètre s'interprète plus facilement en considérant le temps de demi vie phylogénétique t 1/2 = ln(2)/α (Hansen, 1997). C'est le temps nécessaire au trait pour parcourir la moitié de la distance qui le sépare de l'optimum. On peut comparer ce temps avec la hauteur totale h de l'arbre phylogénétique sur lequel il évolue. Si t 1/2 est grand par rapport à h, cela signifie que le trait, durant son histoire évolutive, n'a jamais le temps d'arriver à son optimum : la sélection est de faible intensité. À l'inverse, si t 1/2 est petit par rapport à h, le trait converge rapidement vers son optimum, et la force de sélection est grande. Un exemple de ce modèle sur un arbre simple est présenté dans la figure suivante.

Trait Evolution on Phylogenetic Networks

Crédits photographiques : voir note page 15.

This last short chapter, writen in French, describes the context and main results presented in this manuscript. It can be read independently from the rest, and is highly redundant with the introduction, that precisely ended this way.

Acknowledgments

We would like to thank Cécile Ané for helpful discussions on an early draft of this manuscript. We are grateful to the INRA MIGALE bioinformatics platform (http: //migale.jouy.inra.fr) for providing the computational resources needed for the experiments. We also thank the two anonymous reviewers whose careful and critical reading greatly helped improve this manuscript.

Acknowledgments

We are grateful to the INRA MIGALE bioinformatics platform (http://migale.jouy. inra.fr) for providing the computational resources needed for the experiments. comment elles pourraient être incorporées dans notre cadre de travail. Il est intéressant de noter que ces adaptations, vues sous un autre angles, peuvent également être adoptées pour réaliser une analyse à facteurs d'un jeu de données multivarié.

Lorsque l'on s'intéresse à la détection de sauts, deux phénomènes, jusqu'à présent négligés, peuvent être intéressants à étudier : la convergence évolutive, et la parcimonie dans le nombre de traits impactés par chaque saut. Une solution simple pour incorporer ces contraintes au modèle serait d'ajouter des pénalités structurelles adéquates. Deux espèces distinctes sont dites convergentes si elles atteignent un même régime évolutif de manière indépendante. un critères de type fused-ANOVA , qui pénaliserait la présence de deux régimes distincts mais proches, et favoriserait leur fusion en un seul, pourrait être adaptée pour étudier ce phénomène. D'autre part, dans le cas multivarié, on a supposé que tous les traits étaient indifféremment impactés par chaque saut. Cela revient à faire l'hypothèse que tous les traits inclus dans l'analyse sont pertinents pour l'étude des régimes adaptatifs, et peut rendre la méthode sensible à l'ajout de traits neutres brouillant le signal. Une pénalité LASSO de type sparse group sparse , qui privilégierait les solutions dans lesquels un petit nombre seulement de traits seraient impliqués dans chaque saut, pourrait rendre la méthode plus robuste à ce type de bruit, et rendre l'analyse moins dépendante du choix arbitraire des traits inclus ou non.

Jusqu'à présent, nous avons également fait l'hypothèse forte que toutes les mesures provenaient d'espèces observées à un seul instant dans l'histoire, au temps présent. Cela revient à supposer que tous les arbres considérés étaient ultramétriques, en ignorant toutes les données fossiles éventuelles. Ces sources de données, bien que rares, sont précieuses, et peuvent nous donner des renseignements sur la nature de la dynamique de l'évolution des traits au cours du temps. Par exemple, en terme d'identifiabilité, deux solutions que l'on considérait équivalentes sur un arbre ultramétrique peuvent devenir distinguable lorsque l'on inclue des données fossiles. Ce pouvoir discriminant est cependant très dépendant de la position du fossile sur l'arbre. Une étude systématique de l'identifiabilité des configurations de sauts sur l'arbre, telle que celle menée au chapitre 2, serait donc plus complexe, et les résultats dépendants de la topologie des arbres considérés. D'un point de vue pratique, la rupture de l'hypothèse d'ultramétrie rend l'astuce de changement d'échelle utilisée au chapitre 3, pour étendre les résultats du BM à l'OU de manière efficace, caduque. On propose ici plusieurs heuristiques pour pallier ce problème.

Enfin, dans une dernière partie, on tente de jeter les bases d'une méthode permettant d'intégrer les données manquantes de manière plus satisfaisante. En effet, on a considéré jusqu'ici que les mesures étaient manquantes de manière complètement aléatoire, pour toutes les espèces et pour tous les traits. Or, l'échantillonnage en lui-même peut avoir une certaine structure. Par exemple, des phénomènes de censure peuvent être observés, induisant des données manquantes pour toute une série de traits, par exemple très petits, donc difficiles à mesurer. La prise en compte de ces biais d'échantillonnage peuvent ainsi nous renseigner sur la nature des traits manquants, et ainsi améliorer notre analyse. On étudie ainsi pour finir quelques unes des conséquences de l'ajout de ce modèle d'échantillonnage sur notre méthode.

Chapitre 6 : Résumé substantiel

Funding

The visit of PB to the University of Wisconsin-Madison during the fall of 2015 was funded by a grant from the Franco-American Fulbright Commission.

1.B.2 Hadamard Product

The Hadamard product enjoys less properties than the Kronecker product, but is sometimes useful to write compact expressions.

Definition 1.B.3. Let A and B be matrices of size m × n. Their Hadamard product A B is the m × n matrix defined by: Lemma 1.B.1 (Kronecker and Hadamard products [START_REF] Kollo | Asymptotics of Eigenvalues and Unit-Length Eigenvectors of Sample Variance and Correlation Matrices[END_REF]; [START_REF] Mond | On Inequalities Involving The Hadamard Product of Matrices[END_REF]). Let J be a n 2 × n matrix, such that

is the matrix of concatenation of base matrices E ii that are matrices of zeros, with one one at entry (i, i).

We have JJ T = I n 2 . Let A and B two n × n matrices. Then:

Chapter 2

Shift Detection for Univariate Processes

Contents

Toward the Multivariate Analysis

In this chapter, we presented a general framework for the analysis of univariate trait evolution with shifts on a phylogenetic tree. It sets the ground for a multivariate trait study, that is the object of the next chapter. To scale up to several traits, the main change we make in the inference framework is the way we deal with the OU process. Instead of developing heuristics to maximize the OU likelihood, as we did in this chapter (see Section 2.C.3), we make use of the re-scaling trick presented in the introductory chapter (see Section 1. 4.2.4). This allows us to reduce the OU to a more manageable BM, for which we have exact and fast algorithms. To validate this new inference method, we applied it to univariate datasets, so that we could compare its results with the ones of the previous method. The three mains results (not shown) were: (1) the new method gives very similar results to the old one, with likelihoods equal up to numerical accuracy, ( 2) the new method is substantially faster than the old one (with speed even improved thanks to the efficient implementation of the "upward-downward" algorithm) and ( 3) the new method is much more sensitive to the initialization, as the EM algorithm almost never moves away from the first shift configuration. This last feature is a bit surprising, and quite unsatisfactory. Special care was hence taken in the design of the initialization step, performed thanks to a lasso regression. We then define phylogenetic networks the same way we did for phylogenetic trees (see Section 1.1.1). Definition 4.1.2 (Phylogenetic Network). A phylogenetic network (on X) N is a pair (N , φ), where N = (V , E) is a network, and φ : X → V L is a bijection between a set of labels X and the set V L of the leaves of N .

The definition above is quite general, and can encompass some fairly intricate networks. However, for identifiability reasons (Solís-Lemus & Ané, 2016), we will limit ourselves to "simple" networks, that have clearly separated cycles. An example of such a network is given Figure 4 2016). It has two hybridization events. This is a level-1 network: cycle 1 (red) and cycle 2 (cyan) are disjoint. The figure is plotted with julia package PhyloNetworks, and slightly modified with a vector graphic editor.

For phylogenetic trees, we defined a preorder of the nodes, that allowed for efficient traversal of the tree (see Def. 1.1.3 in Section 1.1.1). We can define a similar order for networks, called the topological sorting [START_REF] Kahn | Topological sorting of large networks[END_REF]. Definition 4.1.4 (Topological Sorting). A topological sorting of the nodes of a rooted network N = (V , E), also called a preorder, is such that any node comes after all its parents: for any two nodes numbered i and j, if there is an oriented path going from i to j, then i ≤ j. Such an ordering can be obtained in a linear time in the number of nodes and edges [START_REF] Kahn | Topological sorting of large networks[END_REF].

if i is a hybrid), we get the following completed model from Proposition 4.2.5:

The likelihood of the completed dataset can then be written as:

where each term of the product is just a Gaussian distribution. Similarly to the approach we took in the tree case (see Section 2.4.1), an EM could be written to maximize the likelihood when the number of shifts is fixed. The conditional expectation of the complete log-likelihood given the data at the tips is straightforward to write. At the M step, the parameters would be estimated the same way they were for trees. In particular, as shifts are only allowed on tree branches, we recover the sum of costs that makes their positioning easy (see Section 2.C.3).

At the E step, as everything is Gaussian, we can still compute the conditional expectations and variances explicitly (using the same equations as in Section 2.C.1). However, it is not clear that an efficient algorithm such as the upward-downward (see Section 3.C.2) could be used here. Indeed, the hybridization events introduce some loops in the graphical model, that need to be handled separately. It could be possible to deal with those cycles through "variable elimination", merging all the nodes in the cycle into one new synthetic multivariate node [START_REF] Peyrard | Exact and approximate inference in graphical models: variable elimination and beyond[END_REF].

Finally, the identifiability and model selection problems remain. As in the tree case, we would need some combinatorial tools to measure the space of solutions. These are yet to be studied. [START_REF] Alexeev | Combinatorial Scoring of Phylogenetic Networks[END_REF] recently proposed an extension of the problem of counting the number of convex coloring of the tips (see Sections 1.1 and 2.3.2) to a network, that could be used for model selection.

Ornstein-Uhlenbeck

As for trait evolution on trees, other processes than the BM could be used to model the dynamical evolution of the trait. The Ornstein-Uhlenbeck naturally comes into mind. As pointed out earlier (see Section 4.2.1), the salient difference is that we need to define a merging rule for the traits of hybrids. For an OU with one single optimum value over the whole tree, the weighted average merging rule could be adapted. Problems might arise if the OU is allowed to have several optima on the tree. What should be the optimum value of a hybrid species, whose parents have different optima β a and β b ? Should we also take the weighted average? Or choose one of the two values? Or maybe define a brand new optimum for the hybrid species?

All of these choices could be legitimate from a biological point of view, depending on the species and traits studied. However, further work would be needed to see which merging rule would make the computations feasible from a mathematical and computational point of view. In particular, it could be interesting to find a merging rule that could allow, in the ultrametric case, to see the OU as a BM on a re-scaled network, as we did in the tree case (see Sections 1. 4.2.4 and 3.2.4).

Appendix 4.A Documentation: Continuous Trait Evolution

This appendix presents the main functions for trait analysis in the PhyloNetworks package. It is extracted from the online documentation (http://crsl4.github.io/PhyloNetworks. jl/stable/man/trait_tree/). It was written in collaboration with Cécile Ané and Claudia Solís-Lemus.

We assume a fixed network, correctly rooted, with branch lengths proportional to calendar time. Here, we consider the true network that was used in the previous sections, and which is ultrametric (all the tips are contemporary).

4.A.1 Trait simulation

We start by generating continuous traits to study. We simulate three traits on the network (two independent, one dependent), using a Brownian Motion (BM) model of trait evolution on the network. We start by choosing the parameters of the BM (ancestral mean and variance), by creating objects of class ParamsBM<:ParamsProcess. params_trait1 = ParamsBM( 2, 0.5) # BM with mean 2 and variance 0.5 params_trait2 = ParamsBM(-2, 1)

# BM with mean -2 and variance 1.0

We then simulate the independent traits according to these parameters, using function simulate (fixing the seed, for reproducibility).

srand(18480224) sim1 = simulate(truenet, params_trait1) # simulate a BM on truenet sim2 = simulate (truenet, params_trait2) This creates objects of class TraitSimulation, from which we can extract the data at the tips, thanks to the method getindex(::TraitSimulation, ::Symbol). This extractor creates an Array with one column, and as many lines as the number of tips there are in the phylogeny. It is sorted in the same order as the tips of the phylogeny used to simulate it. If needed, we could also extract the simulated values at the internal nodes in the network:

Finally, we generate the last trait correlated with trait 1 (but not trait 2), with phylogenetic noise.

4.A.2 Phylogenetic regression

Assume that we measured the three traits above, and that we wanted to study the impact of traits 1 and 2 on trait 3. To do that, we can perform a phylogenetic regression.

In order to avoid confusion, the function takes in a DataFrame, that has an extra column with the names of the tips of the network, labeled tipNames. Here, we generated the traits ourselves, so they are all in the same order. From this, we can see that the intercept, the coefficient for trait 1 and the variance of the noise are correctly estimated (given that there are only 6 taxa). In addition, the Student test for the coefficient associated with trait 2 has a high p-value, which means that this coefficient is not significantly different from 0. This is consistent with the way we simulated trait 3.

The function returns an object of type PhyloNetworkLinearModel<:LinPredModel. It is a subtype of the GLM type LinPredModel, which means that all base functions from Julia StatsBase can be applied to it. See the documentation for this type for a list of all functions that can be used. Some functions allow the user to retrieve directly the estimated parameters of the BM, and are specific to this object. If we assume that we know the exact model of evolution that generated the traits, we can do ancestral trait reconstruction. Here, we simulated trait 1 ourselves, so we can use the true process, with the true parameters. In other words, we can reconstruct the state at the internal nodes, given the values at the tips, the known value at the root and the known BM variance.