Abstract
Functions for reading, writing, plotting, and manipulating phylogenetic trees, analyses of comparative data in a phylogenetic framework, ancestral character analyses, analyses of diversification and macroevolution, computing distances from DNA sequences, reading and writing nucleotide sequences as well as importing from BioConductor, and several tools such as Mantel's test, generalized skyline plots, graphical exploration of phylogenetic data (alex, trex, kronoviz), estimation of absolute evolutionary rates and clock-like trees using mean path lengths and penalized likelihood, dating trees with non-contemporaneous sequences, translating DNA into AA sequences, and assessing sequence alignments. Phylogeny estimation can be done with the NJ, BIONJ, ME, MVR, SDM, and triangle methods, and several methods handling incomplete distance matrices (NJ, BIONJ, MVR*, and the corresponding triangle method). Some functions call external applications (PhyML, Clustal, T-Coffee, Muscle) whose results are returned into R.
Introduction
The ape package provides a comprehensive suite for phylogenetic analysis. Source, p. 7
In the early stages of computational biology, phylogenetic analysis was a fragmented field. Researchers were often forced to navigate between disparate, incompatible standalone programs to perform tasks such as sequence alignment, tree estimation, and hypothesis testing. A significant challenge was the lack of a unified environment where statistical tests on traits—such as body size—could be performed while accounting for the non-independence of species due to common ancestry.
The 'ape' (Analyses of Phylogenetics and Evolution) package addresses this by integrating phylogenetics into the R statistical environment. By introducing standardized data objects, most notably the phylo class, 'ape' allows phylogenetic trees to be treated as formal statistical structures. This integration enables researchers to move seamlessly from raw genomic data to complex evolutionary models.
Methods and Data Structures
The package provides a vast library of methods, characterized by several key technical approaches:
Efficient Data Handling
'ape' utilizes bit-level coding for DNA (DNAbin) and amino acid (AAbin) sequences. This approach allows R to store and manipulate large genomic datasets in memory far more efficiently than standard character strings.
Tree Estimation and Comparative Statics
While 'ape' can interface with external high-performance tools like PhyML for maximum likelihood estimation, it also contains native implementations of distance-based methods, including Neighbor-Joining (NJ), BIONJ, and Minimum Evolution (ME). Specialized versions (NJ, BIONJ) are included to handle incomplete distance matrices.
For comparative analysis, the package implements Phylogenetically Independent Contrasts (PIC) and Phylogenetic Generalized Linear Mixed Models (PGLMM). These methods are crucial for correcting "phylogenetic signal"—the statistical bias inherent in data from related species.
Molecular Dating
Sophisticated tools for "clock-like" tree estimation, such as chronos and chronopl, are included. These use penalized likelihood to estimate absolute evolutionary rates, even in the absence of a perfectly constant molecular clock.
Key Insights: The Tree as a Covariance Matrix
A fundamental insight provided by 'ape' is the representation of a phylogenetic tree as a variance-covariance matrix (vcv). This transformation allows evolutionary history to be incorporated directly into standard regression models. Furthermore, 'ape' acts as a bridge, wrapping external optimized C++ programs like Clustal, T-Coffee, or Muscle for alignment, and returning the results to R for statistical analysis. Interactive tools like alex (Alignment Explorer) and trex (Tree Explorer) facilitate the exploration of massive datasets.
Datasets and Results
The package documentation highlights several benchmark datasets:
woodmouse: 15 Cytochrome b gene sequences for demonstrating sequence manipulation.bird.orders&bird.families: Phylogenies based on Sibley and Ahlquist’s DNA-DNA hybridization work.carnivora: 112 observations across 17 variables for analyzing trait evolution.hivtree: A clock-like phylogeny of 193 HIV-1 sequences used for population size estimation via skyline plots.
'ape' supports 28 different models of DNA evolution and provides robust metrics for tree comparison, such as the Robinson-Foulds distance. The ace (Ancestral Character Estimation) function allows for the reconstruction of ancestral states for both continuous and discrete traits.
Limitations and Conclusion
While 'ape' is highly efficient, some functions may become computationally expensive as tree sizes reach tens of thousands of tips. Additionally, 'ape' focuses primarily on frequentist and likelihood-based methods; Bayesian inference is typically handled by complementary tools like BEAST.
In conclusion, 'ape' serves as the foundational infrastructure for modern comparative biology. Its continued development ensures that R remains a primary platform for evolutionary data science, providing the essential tools for reading, manipulating, and analyzing the history of life.
Summary updated