ape: Analyses of Phylogenetics and Evolution

系統学、進化学の解析ツール

> library(ape)
> data("bird.families")

バージョン: 3.4


関数名 概略
CADM.global Congruence among distance matrices
DNAbin Manipulate DNA Sequences in Bit-Level Format
FastME Tree Estimation Based on the Minimum Evolution Algorithm
Initialize.corPhyl Initialize a 'corPhyl' Structure Object
LTT Theoretical Lineage-Through Time Plots
MPR Most Parsimonious Reconstruction
Moran.I Moran's I Autocorrelation Index
SDM Construction of Consensus Distance Matrix With SDM
ace Ancestral Character Estimation
add.scale.bar Add a Scale Bar to a Phylogeny Plot
additive Incomplete Distance Matrix Filling
alex Alignment Explorer With Multiple Devices
all.equal.phylo Global Comparison of two Phylogenies
ape-package Analyses of Phylogenetics and Evolution
as.alignment Conversion Among DNA Sequence Internal Formats
as.bitsplits Split Frequencies and Conversion Among Split Classes
as.matching Conversion Between Phylo and Matching Objects
as.phylo Conversion Among Tree and Network Objects
as.phylo.formula Conversion from Taxonomy Variables to Phylogenetic Trees
axisPhylo Axis on Side of Phylogeny
balance Balance of a Dichotomous Phylogenetic Tree
base.freq Base frequencies from DNA Sequences
bd.ext Extended Version of the Birth-Death Models to Estimate Speciation and Extinction Rates
bd.time Time-Dependent Birth-Death Models
bind.tree Binds Trees
bionj Tree Estimation Based on an Improved Version of the NJ Algorithm
bird.families Phylogeny of the Families of Birds From Sibley and Ahlquist
bird.orders Phylogeny of the Orders of Birds From Sibley and Ahlquist
birthdeath Estimation of Speciation and Extinction Rates With Birth-Death Models
boot.phylo Tree Bipartition and Bootstrapping Phylogenies
branching.times Branching Times of a Phylogenetic Tree
c.phylo Building Lists of Trees
carnivora Carnivora body sizes and life history traits
cherry Number of Cherries and Null Models of Trees chiroptera Bat Phylogeny
chronoMPL Molecular Dating With Mean Path Lengths
chronopl Molecular Dating With Penalized Likelihood
chronos Molecular Dating by Penalised Likelihood and Maximum Likelihood
clustal Multiple Sequence Alignment with External Applications
coalescent.intervals Coalescent Intervals
collapse.singles Collapse Single Nodes
collapsed.intervals Collapsed Coalescent Intervals
compar.cheverud Cheverud's Comparative Method
compar.gee Comparative Analysis with GEEs
compar.lynch Lynch's Comparative Method
compar.ou Ornstein-Uhlenbeck Model for Continuous Characters
compute.brlen Branch Lengths Computation
compute.brtime Compute and Set Branching Times
consensus Concensus Trees
cophenetic.phylo Pairwise Distances from a Phylogenetic Tree
cophyloplot Plots two phylogenetic trees face to face with links between the tips.
corBlomberg Blomberg et al.'s Correlation Structure
corBrownian Brownian Correlation Structure
corClasses Phylogenetic Correlation Structures
corGrafen Grafen's (1989) Correlation Structure
corMartins Martins's (1997) Correlation Structure
corPagel Pagel's "lambda" Correlation Structure
correlogram.formula Phylogenetic Correlogram
data.nex NEXUS Data Example
dbd Probability Density Under Birth-Death Models
def Definition of Vectors for Plotting or Annotating
del.gaps Delete Alignment Gaps in DNA Sequences
delta.plot Delta Plots
dist.dna Pairwise Distances from DNA Sequences
dist.gene Pairwise Distances from Genetic Data
dist.topo Topological Distances Between Two Trees
diversi.gof Tests of Constant Diversification Rates
diversi.time Analysis of Diversification with Survival Models
diversity.contrast.test Diversity Contrast Test
drop.tip Remove Tips in a Phylogenetic Tree
edges Draw Additional Edges on a Plotted Tree
evonet Evolutionary Networks
ewLasso Incomplete distances and edge weights of unrooted topology
gammaStat Gamma-Statistic of Pybus and Harvey
hivtree Phylogenetic Tree of 193 HIV-1 Sequences
howmanytrees Calculate Numbers of Phylogenetic Trees
identify.phylo Graphical Identification of Nodes and Tips
image.DNAbin Plot of DNA Sequence Alignement
is.binary.tree Test for Binary Tree
is.compatible Check Compatibility of Splits
is.monophyletic Is Group Monophyletic
is.ultrametric Test if a Tree is Ultrametric
kronoviz Plot Multiple Chronograms on the Same Scale
ladderize Ladderize a Tree
landplants Gene Tree of 36 Landplant rbcL Sequences
lmorigin Multiple regression through the origin
ltt.plot Lineages Through Time Plot
makeLabel Label Management
makeNodeLabel Makes Node Labels
mantel.test Mantel Test for Similarity of Two Matrices
mat3 Three Matrices
mat5M3ID Five Trees
mat5Mrand Five Independent Trees
matexpo Matrix Exponential
mcconwaysims.test McConway-Sims Test of Homogeneous Diversification
mcmc.popsize Reversible Jump MCMC to Infer Demographic History
mixedFontLabel Mixed Font Labels for Plotting
mrca Find Most Recent Common Ancestors Between Pairs
mst Minimum Spanning Tree
multi2di Collapse and Resolve Multichotomies
multiphylo Manipulating Lists of Trees
mvr Minimum Variance Reduction
nj Neighbor-Joining Tree Estimation
njs Tree Reconstruction from Incomplete Distances
With NJ or bio-NJ
node.depth Depth and Heights of Nodes and Tips
nodelabels Labelling the Nodes, Tips, and Edges of a Tree
nodepath Find Paths of Nodes
opsin Gene Tree of 32 opsin Sequences
parafit Test of host-parasite coevolution
pcoa Principal Coordinate Analysis
phydataplot Tree Annotation
phymltest Fits a Bunch of Models with PhyML
pic Phylogenetically Independent Contrasts
pic.ortho Phylogenetically Independent Orthonormal Contrasts
plot.correlogram Plot a Correlogram
plot.phylo Plot Phylogenies
plot.varcomp Plot Variance Components
print.phylo Compact Display of a Phylogeny
rTraitCont Continuous Character Simulation
rTraitDisc Discrete Character Simulation
rTraitMult Multivariate Character Simulation
read.GenBank Read DNA Sequences from GenBank via Internet
read.caic Read Tree File in CAIC Format
read.dna Read DNA Sequences in a File
read.nexus Read Tree File in Nexus Format
read.nexus.data Read Character Data In NEXUS Format
read.tree Read Tree File in Parenthetic Format
reconstruct Continuous Ancestral Character Estimation
reorder.phylo Internal Reordering of Trees
richness.yule.test Test of Diversification-Shift With the Yule Process
rlineage Tree Simulation Under the Time-Dependent Birth-Death Models
root Roots Phylogenetic Trees
rotate Swapping Sister Clades
rtree Generates Random Trees
rtt Root a Tree by Root-to-Tip Regression
seg.sites Find Segregating Sites in DNA Sequences
skyline Skyline Plot Estimate of Effective Population Size
skylineplot Drawing Skyline Plot Graphs
slowinskiguyer.test Slowinski-Guyer Test of Homogeneous Diversification
speciesTree Species Tree Estimation
stree Generates Systematic Regular Trees
subtreeplot Zoom on a Portion of a Phylogeny by Successive Clicks
subtrees All subtrees of a Phylogenetic Tree
summary.phylo Print Summary of a Phylogeny
treePop Tree Popping
trex Tree Explorer With Multiple Devices
triangMtd Tree Reconstruction Based on the Triangles Method
unique.multiPhylo Revomes Duplicate Trees
varCompPhylip Variance Components with Orthonormal Contrasts
varcomp Compute Variance Component Estimates
vcv Phylogenetic Variance-covariance or Correlation Matrix
vcv2phylo Variance-Covariance Matrix to Tree
weight.taxo Define Similarity Matrix
where Find Patterns in DNA Sequences
which.edge Identifies Edges of a Tree
woodmouse Cytochrome b Gene Sequences of Woodmice
write.dna Write DNA Sequences in a File
write.nexus Write Tree File in Nexus Format
write.nexus.data Write Character Data in NEXUS Format
write.tree Write Tree File in Parenthetic Format
yule Fits the Yule Model to a Phylogenetic Tree
yule.cov Fits the Yule Model With Covariates
yule.time Fits the Time-Dependent Yule Model
zoom Zoom on a Portion of a Phylogeny

bird.families

鳥類の系統的データ。phyloクラスオブジェクト

> data("bird.families")
> bird.families %>% {
+   class(.) %>% print()
+   str(.) %>% print()
+   .
+ }
[1] "phylo"
List of 4
 $ edge       : int [1:271, 1:2] 138 139 140 141 142 142 141 143 143 140 ...
 $ Nnode      : int 135
 $ tip.label  : chr [1:137] "Struthionidae" "Rheidae" "Casuariidae" "Apterygidae" ...
 $ edge.length: num [1:271] 2.1 4.1 3.9 0.8 17.1 17.1 8.4 9.5 9.5 21.8 ...
 - attr(*, "class")= chr "phylo"
NULL

Phylogenetic tree with 137 tips and 135 internal nodes.

Tip labels:
    Struthionidae, Rheidae, Casuariidae, Apterygidae, Tinamidae, Cracidae, ...

Rooted; includes branch lengths.

collapse.singles

drop.tip

系統樹からtipsを取り除く

Arguments

  • phy... phyloクラスオブジェクト
  • tip
  • trim.internal
  • subtree
  • root.edge
  • rooted
  • interactive
> data("bird.families")
> tip <- c(
+ "Eopsaltriidae", "Acanthisittidae", "Pittidae", "Eurylaimidae",
+ "Philepittidae", "Tyrannidae", "Thamnophilidae", "Furnariidae",
+ "Formicariidae", "Conopophagidae", "Rhinocryptidae", "Climacteridae",
+ "Menuridae", "Ptilonorhynchidae", "Maluridae", "Meliphagidae",
+ "Pardalotidae", "Petroicidae", "Irenidae", "Orthonychidae",
+ "Pomatostomidae", "Laniidae", "Vireonidae", "Corvidae",
+ "Callaeatidae", "Picathartidae", "Bombycillidae", "Cinclidae",
+ "Muscicapidae", "Sturnidae", "Sittidae", "Certhiidae",
+ "Paridae", "Aegithalidae", "Hirundinidae", "Regulidae",
+ "Pycnonotidae", "Hypocoliidae", "Cisticolidae", "Zosteropidae",
+ "Sylviidae", "Alaudidae", "Nectariniidae", "Melanocharitidae",
+ "Paramythiidae","Passeridae", "Fringillidae")
> length(tip)
[1] 47
> bird.families %>% {
+   summary(.) %>% print()
+   drop.tip(., tip = tip) %>% summary()
+ }

Phylogenetic tree: . 

  Number of tips: 137 
  Number of nodes: 135 
  Branch lengths:
    mean: 7.413653 
    variance: 38.49237 
    distribution summary:
   Min. 1st Qu.  Median 3rd Qu.    Max. 
   0.10    1.15    9.10   11.50   27.00 
  No root edge.
  First ten tip labels: Struthionidae 
                        Rheidae
                        Casuariidae
                        Apterygidae
                        Tinamidae
                        Cracidae
                        Megapodiidae
                        Phasianidae
                        Numididae
                        Odontophoridae
  No node labels.
NULL

Phylogenetic tree: . 

  Number of tips: 95 
  Number of nodes: 93 
  Branch lengths:
    mean: 8.206952 
    variance: 42.80151 
    distribution summary:
   Min. 1st Qu.  Median 3rd Qu.    Max. 
    0.2     1.5     9.2    12.6    27.0 
  No root edge.
  First ten tip labels: Struthionidae 
                        Rheidae
                        Casuariidae
                        Apterygidae
                        Tinamidae
                        Cracidae
                        Megapodiidae
                        Phasianidae
                        Numididae
                        Odontophoridae
  No node labels.

lmorigin

原点を通る重回帰モデル

Arguments

  • formula
  • data
  • origin
  • nperm
  • method
  • silent
> data("lmorigin.ex1")
> out <- lmorigin.ex1 %>% lmorigin(SO2 ~ ., data = ., origin = FALSE, nperm = 99)
Multiple regression with estimation of intercept 
Permutation method = residuals of full model 
Computation time = 0.427000  sec
> out

Multiple regression with estimation of intercept 

Call:
lmorigin(formula = SO2 ~ ., data = ., origin = FALSE, nperm = 99) 

Coefficients and parametric test results 

                   Coefficient Std_error t-value   Pr(>|t|)    
(Intercept)          58.195935 20.487894  2.8405    0.00728 ** 
Mean_Annual_Temp_F   -0.587145  0.371008 -1.5826    0.12203    
No_manufactures       0.071225  0.016060  4.4349 0.00007955 ***
Population_x_1000    -0.046648  0.015372 -3.0346    0.00439 ** 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Two-tailed tests of regression coefficients

                   Coefficient p-param p-perm   
(Intercept)          58.195935  0.0073     NA   
Mean_Annual_Temp_F   -0.587145  0.1220   0.17   
No_manufactures       0.071225  0.0001   0.01 **
Population_x_1000    -0.046648  0.0044   0.02 * 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

One-tailed tests of regression coefficients: 
test in the direction of the sign of the coefficient

                   Coefficient p-param p-perm   
(Intercept)          58.195935  0.0036     NA   
Mean_Annual_Temp_F   -0.587145  0.0610   0.07 . 
No_manufactures       0.071225  0.0000   0.01 **
Population_x_1000    -0.046648  0.0022   0.01 **
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 15.19126 on 37 degrees of freedom 
Multiple R-square: 0.6125468   Adjusted R-square: 0.5811317 

F-statistic: 19.49847 on 3 and 37 DF:
   parametric p-value   : 0.0000000948852 
   permutational p-value: 0.01 
after 99 permutations of residuals of full model

pic

系統独立対比の実施

> tree.primates <- c("((((Homo:0.21,Pongo:0.21):0.28,","Macaca:0.49):0.13,Ateles:0.62):0.38,Galago:1.00);") %>%
+   read.tree(text = .)
> X <- c(4.09434, 3.61092, 2.37024, 2.02815, -1.46968)
> Y <- c(4.74493, 3.33220, 3.36730, 2.89037, 2.30259)
> names(X) <- names(Y) <- c("Homo", "Pongo", "Macaca", "Ateles", "Galago")
> (pic.X <- pic(X, tree.primates))
        6         7         8         9 
3.3583189 1.1929263 1.5847416 0.7459333
> (pic.Y <- pic(Y, tree.primates))
        6         7         8         9 
0.8970604 0.8678969 0.7176125 2.1798897
> cor.test(pic.X, pic.Y)

    Pearson's product-moment correlation

data:  pic.X and pic.Y
t = -0.85623, df = 2, p-value = 0.4821
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.9874751  0.8823934
sample estimates:
       cor 
-0.5179156

read.tree

系統樹ファイルの読み込み

> library(adephylo)
Loading required package: ade4

Attaching package: 'adephylo'
The following object is masked from 'package:ade4':

    orthogram
> data("ungulates")
> read.tree(text = ungulates$tre) %>%  {
+   print(.)
+   plot(.)
+ }

Phylogenetic tree with 18 tips and 13 internal nodes.

Tip labels:
    Antilocapra_americana, Gorgon_taurinus, Oryx_leucoryx, Taurotragus_livingstoni, Tautragus_oryx, Gazella_thompsoni, ...
Node labels:
    Root, W11, W10, W1, W2, W7, ...

Rooted; no branch lengths.

plot of chunk usage_read.tree

rtree

ランダムな系統樹データを生成

rtree, rcoal, rmtree

Arguments

  • n
  • rooted
  • tip.label
  • br
  • ...
  • N
> rtree(n = 20)

Phylogenetic tree with 20 tips and 19 internal nodes.

Tip labels:
    t8, t20, t9, t3, t11, t7, ...

Rooted; includes branch lengths.

write.tree

Newickファイルの書き出し

> set.seed(100)
> rtree(n = 20) %>% 
+   write.tree(phy = ., file = "../inst/ape_write_tree.tre")
> 
> read.tree(file = "../inst/ape_write_tree.tre") %>% {
+   print(.)
+   is.binary.tree(.)
+ }

Phylogenetic tree with 20 tips and 19 internal nodes.

Tip labels:
    t6, t8, t14, t12, t4, t20, ...

Rooted; includes branch lengths.
[1] TRUE