Ancestral State Reconstruction of Continuous Trait in R

ML Reconstruction for Continuous Characters in R

In this section, we will use the 'ape' package in R to reconstruct ancestral states using the of the intermembral index in apes from the book. The procedure is similar to that in Section 3.4. The data can be found in these files:

If you haven't done so already, download R. Open R and navigate to the folder that contains the datafile from above (e.g., on a Mac, go to the Misc menu and change the working directory, or use the setwd function). Load the 'ape' library (see Section 1.1.2 for installation instructions):

library("phytools")
        

Now, let's load the data and phylogeny:

imi_data = read.csv("anthrotree41_imi.csv") imi_tree = read.nexus("anthrotree41_tree.txt")

Check out the data by typing "imi_data". You should see the following output on the command line:

            Species   IMI 1        Gorilla_gorilla 115.8 2           Homo_sapiens  72.0 3       Hylobates_agilis 121.0 4     Hylobates_concolor 140.0 5      Hylobates_hoolock 129.0 6      Hylobates_klossii 126.0 7          Hylobates_lar 129.7 8   Hylobates_leucogenys 140.0 9       Hylobates_moloch 127.0 10    Hylobates_muelleri 129.0 11 Hylobates_syndactylus 147.0 12          Pan_paniscus 102.7 13       Pan_troglodytes 104.5 14        Pongo_pygmaeus 139.0

Similarly, take a look at the tree by typing:

plot(imi_tree)

Notice that some of the branches represent polytomies (set to be zero branch length in this file), with the phylogenetic information taken from Bininda-Emonds et al. (2007, 2008). Let's also be sure that the species in the tree and data files are identical by typing "imi_tree$tip.label". You should see something like this (depending on the width of your R console screen):

            [1] "Gorilla_gorilla"       "Homo_sapiens"            
[3] "Hylobates_agilis" "Hylobates_concolor"
[5] "Hylobates_hoolock" "Hylobates_klossii"
[7] "Hylobates_lar" "Hylobates_leucogenys"
[9] "Hylobates_moloch" "Hylobates_muelleri"
[11] "Hylobates_syndactylus" "Pan_paniscus"
[13] "Pan_troglodytes" "Pongo_pygmaeus"

Because this is in the same order as in the data table, the data could be run with our variables as is. In the case that the species are not in the same order, however, a named vector can be used as well.

imi_data.vector = c(imi_data$IMI)
imi_data.names = rep(1, length(imi_data.vector))
for(i in 1:length(imi_data.vector)) {
imi_data.names[i] = toString(imi_data$Species[i])}
names(imi_data.vector) = imi_data.names

Now, we can use the fastAnc function from phytools to obtain estimates of ancestral states, using maximum likelihood, and plot those on the tree:

anc_states = fastAnc(imi_tree, imi_data.vector, CI = TRUE) nodelabels(round(anc_states$ace, digits=1))

You should see the following:

It is important to note that not all programs calculate ancestral states exactly the same way. The help function for fastAnc describes the function in the following manner:

This function performs fast estimation of the ML ancestral states for a continuous trait by taking advantage of the fact that the state computed for the root node of the tree during Felsenstein's (1985) contrasts algorithm is also the MLE of the root node. Thus, the function reroots the tree at all internal nodes and computes the contrasts state at the root each time.

On the other hand, the ace function in the package "ape" estimates ancestral states by maximizing likelihood across all nodes simultaneously, and gives slightly different results. It is worthwhile to cross-check multiple methods for reconstructing continuous characters on a phylogeny.

References

Bininda-Emonds, O. R. P., M. Cardillo, K. E. Jones, R. D. E. MacPhee, R. M. D. Beck, R. Grenyer, S. A. Price, R. A. Vos, J. L. Gittleman, and A. Purvis. 2007. The delayed rise of present-day mammals. Nature 446:507-512.

Bininda-Emonds, O. R. P., M. Cardillo, K. E. Jones, R. D. E. MacPhee, R. M. D. Beck, R. Grenyer, S. A. Price, R. A. Vos, J. L. Gittleman, and A. Purvis. . 2008. Corrigendum: The delayed rise of present-day mammals. Nature 456:274.

Pagel, Mark D. "A method for the analysis of comparative data." Journal of theoretical Biology 156.4 (1992): 431-442.

Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). Methods Ecol. Evol. 3 217-223. doi:10.1111/j.2041-210X.2011.00169.x

Schluter, D., T. Price, A. O. Mooers, and D. Ludwig. 1997. Likelihood of ancestor states in adaptive radiation. Evolution 51:1699-1711.

Contributed by Alexander Vining and Charles Nunn

usseryegaised.blogspot.com

Source: https://wiki.duke.edu/display/AnthroTree/4.1+Maximum+Likelihood+Reconstruction+for+Continuous+Characters+in+R

0 Response to "Ancestral State Reconstruction of Continuous Trait in R"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel