R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("ape-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('ape') Loading required package: gee Loading required package: nlme Loading required package: lattice > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "Correlogram" > > ### * Correlogram > > flush(stderr()); flush(stdout()) > > ### Name: Correlogram > ### Title: Compute a correlogram > ### Aliases: Correlogram correlogram.formula correlogram.phylo > ### Keywords: regression dplot > > ### ** Examples > > library(ape) > data(carnivora) > ### Using the formula interface: > co <- correlogram.formula( + log10(SW) ~ Order/SuperFamily/Family/Genus, + data=carnivora) Analysing level: Genus Analysing level: Family Analysing level: SuperFamily Analysing level: Order > co $obs [1] 0.614371364 0.404715752 -0.266621894 -0.001377008 $p.values [1] 9.529087e-07 0.000000e+00 0.000000e+00 5.432094e-01 $labels [1] "Genus" "Family" "SuperFamily" "Order" $filter [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE [16] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE [31] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE [46] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE [61] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE [76] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE [91] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE [106] TRUE TRUE TRUE TRUE TRUE TRUE TRUE attr(,"class") [1] "correlogram" > plot(co) > ### Several correlograms on the same plot: > cos <- correlogram.formula( + log10(SW) + log10(FW) ~ Order/SuperFamily/Family/Genus, + data=carnivora) Analysing level: Genus Analysing level: Family Analysing level: SuperFamily Analysing level: Order > names(cos) [1] "log10(FW)" "log10(SW)" > plot(cos) > > ### Using the phylo interface: > ### (the same analysis than in help(pic)...) > > cat("((((Homo:0.21,Pongo:0.21):0.28,", + "Macaca:0.49):0.13,Ateles:0.62):0.38,Galago:1.00);", + file = "ex.tre", sep = "\n") > tree.primates <- read.tree("ex.tre") > X <- c(4.09434, 3.61092, 2.37024, 2.02815, -1.46968) > Y <- c(4.74493, 3.33220, 3.36730, 2.89037, 2.30259) > ### Since this is a small tree, 2 classes is a reasonable number: > coX <- correlogram.phylo(X, tree.primates, nclass=2) Analysing level: 1 Analysing level: 2 > coY <- correlogram.phylo(Y, tree.primates, nclass=2) Analysing level: 1 Analysing level: 2 > plot(coX) > plot(coY) > ### Nothing significant... > ### Computing Moran's I on the whole matrix: > coX2 <- correlogram.phylo(X, tree.primates); coX2 using whole matrix $obs [1] -0.4250254 $p.values [1] 0.01851316 $labels [1] "Distance" attr(,"class") [1] "correlogram" > ### Significant at the 5 > coY2 <- correlogram.phylo(Y, tree.primates); coY2 using whole matrix $obs [1] -0.3182082 $p.values [1] 0.3530901 $labels [1] "Distance" attr(,"class") [1] "correlogram" > ### Not significant > unlink("ex.tre") # delete the file "ex.tre" > > > > cleanEx(); ..nameEx <- "MoranI" > > ### * MoranI > > flush(stderr()); flush(stdout()) > > ### Name: Moran.I > ### Title: Moran's I Autocorrelation Index > ### Aliases: Moran.I > ### Keywords: models regression > > ### ** Examples > > ### This will draw the correlogram from Gittleman and Kot 1990 > ### This is only for example, consider function plot.correlogram() > ### to draw correlograms. > library(ape) > data(carnivora) > attach(carnivora) > # Compute distance matrix for each taxonomic level: > dG <- dist.taxo(Genus) > dF <- dist.taxo(Family) > dSF <- dist.taxo(SuperFamily) > dO <- dist.taxo(Order) > # We draw the correlogram of average body weights, > # with log10-transformed variable: > IG <- Moran.I(log10(SW), dG , scale=TRUE) > IF <- Moran.I(log10(SW), dF & !dG , scale=TRUE) > ISF <- Moran.I(log10(SW), dSF & !dF , scale=TRUE) > IO <- Moran.I(log10(SW), dO & !dSF, scale=TRUE) > # All Moran's I indices: > i <- c(IG$obs, IF$obs, ISF$obs, IO$obs) > # With their corresponding p-values: > p <- c(IG$p.v, IF$p.v, ISF$p.v, IO$p.v) > # Here's the legend: > l <- c("G", "F", "SF", "O") > # Draw the correlogram (using lattice library): > library(lattice) > # New Black & White device: > trellis.device(device=X11, new=FALSE, color=FALSE) > # Black circles are significant at the 5 > pch <- ifelse(p < 0.05, 19, 21) > # Plot it! > xyplot(i~ordered(l,levels=l), type="b", xlab="Rank", ylab="I / Imax", + lty=2, lwd=2, cex=1.5, pch=pch, ylim=c(-0.75,0.75)) > > > > cleanEx(); ..nameEx <- "NPRS.criterion" > > ### * NPRS.criterion > > flush(stderr()); flush(stdout()) > > ### Name: NPRS.criterion > ### Title: Objective Function Employed in Nonparametric Rate Smoothing > ### Aliases: NPRS.criterion > ### Keywords: manip > > ### ** Examples > > library(ape) > > # get tree > data("landplants.newick") # example tree in NH format > tree.landplants <- read.tree(text = landplants.newick) > > # plot tree > tree.landplants $edge [,1] [,2] [1,] "-1" "1" [2,] "-1" "-2" [3,] "-2" "2" [4,] "-2" "-3" [5,] "-3" "-4" [6,] "-4" "3" [7,] "-4" "4" [8,] "-4" "5" [9,] "-3" "-5" [10,] "-5" "-6" [11,] "-6" "-7" [12,] "-7" "6" [13,] "-7" "7" [14,] "-6" "8" [15,] "-6" "-8" [16,] "-8" "-9" [17,] "-9" "9" [18,] "-9" "-10" [19,] "-10" "10" [20,] "-10" "11" [21,] "-8" "-11" [22,] "-11" "12" [23,] "-11" "-12" [24,] "-12" "13" [25,] "-12" "14" [26,] "-5" "-13" [27,] "-13" "15" [28,] "-13" "-14" [29,] "-14" "16" [30,] "-14" "17" [31,] "-14" "-15" [32,] "-15" "-16" [33,] "-16" "18" [34,] "-16" "-17" [35,] "-17" "19" [36,] "-17" "20" [37,] "-15" "21" [38,] "-14" "-18" [39,] "-18" "22" [40,] "-18" "23" [41,] "-14" "-19" [42,] "-19" "-20" [43,] "-20" "24" [44,] "-20" "25" [45,] "-19" "-21" [46,] "-21" "26" [47,] "-21" "-22" [48,] "-22" "27" [49,] "-22" "28" [50,] "-21" "-23" [51,] "-23" "29" [52,] "-23" "-24" [53,] "-24" "30" [54,] "-24" "-25" [55,] "-25" "31" [56,] "-25" "32" [57,] "-23" "-26" [58,] "-26" "33" [59,] "-26" "34" [60,] "-13" "35" [61,] "-13" "36" $edge.length [1] 0.033817 0.019372 0.040281 0.012469 0.011806 0.048533 0.033640 0.036526 [9] 0.021625 0.010855 0.005021 0.009460 0.018847 0.014702 0.006309 0.002448 [17] 0.021500 0.006473 0.015649 0.021081 0.016663 0.029965 0.006883 0.011298 [25] 0.014165 0.003527 0.016835 0.007348 0.019902 0.020151 0.007844 0.007654 [33] 0.020003 0.002933 0.006005 0.031555 0.038488 0.004656 0.013524 0.035902 [41] 0.002918 0.005117 0.015119 0.010172 0.006457 0.029027 0.003958 0.006180 [49] 0.002347 0.004803 0.013294 0.001994 0.035675 0.001459 0.009848 0.008236 [57] 0.002619 0.019136 0.041396 0.019265 0.019263 $tip.label [1] "Marchantia" "Lycopodium" "Equisetum" "Osmunda" "Asplenium" [6] "Cycas" "Zamia" "Ginkgo" "Pinus" "Podocarpac" [11] "Taxus" "Ephedra" "Welwitsch" "Gnetum" "Nymphaea" [16] "Saururus" "Chloranth" "Araceae" "Palmae" "Oryza" [21] "Acorus" "Calycanth" "Lauraceae" "Magnolia" "Drimys" [26] "Ranunculus" "Nelumbo" "Platanus" "Buxaceae" "Pisum" [31] "Fagus" "Carya" "Ericaceae" "Solanaceae" "Austrobail" [36] "Amborella" attr(,"class") [1] "phylo" > plot(tree.landplants, label.offset = 0.001) > > # estimate chronogram > chrono.plants <- chronogram(tree.landplants) > > # plot and write to file > plot(chrono.plants, label.offset = 0.001) > write.tree(chrono.plants, file = "chronogram.phy") > > # value of NPRS function for our estimated chronogram > NPRS.criterion(tree.landplants, chrono.plants) [1] 0.1697855 > > > > cleanEx(); ..nameEx <- "add.scale.bar" > > ### * add.scale.bar > > flush(stderr()); flush(stdout()) > > ### Name: add.scale.bar > ### Title: Add a Scale Bar to a Phylogeny Plot > ### Aliases: add.scale.bar > ### Keywords: aplot > > ### ** Examples > > tr <- rtree(10) > layout(matrix(1:2, 2, 1)) > plot(tr) > add.scale.bar() > plot(tr) > add.scale.bar(cex = 0.7, font = 2, col = "red") > layout(matrix(1, 2, 1)) > > > > cleanEx(); ..nameEx <- "all.equal.phylo" > > ### * all.equal.phylo > > flush(stderr()); flush(stdout()) > > ### Name: all.equal.phylo > ### Title: Global Comparison of two Phylogenies > ### Aliases: all.equal.phylo > ### Keywords: manip > > ### ** Examples > > ### maybe the simplest example of two representations > ### for the same rooted tree...: > t1 <- read.tree(text = "(a:1,b:1);") > t2 <- read.tree(text = "(b:1,a:1);") > all.equal(t1, t2) [1] TRUE > ### ... compare with this: > identical(t1, t2) [1] FALSE > ### one just slightly more complicated...: > t3 <- read.tree(text = "((a:1,b:1):1,c:2);") > t4 <- read.tree(text = "(c:2,(a:1,b:1):1);") > all.equal(t3, t4) # == all.equal.phylo(t3, t4) [1] TRUE > ### ... here we force the comparison as lists: > all.equal.list(t3, t4) [1] "Component 1: 4 string mismatches" [2] "Component 2: Mean relative difference: 0.6666667" [3] "Component 3: 3 string mismatches" > t5 <- read.tree(text = "(a:2,(c:1,b:1):1);") > ### note that this does NOT return FALSE...: > all.equal(t3, t5) [1] "Number of tips are equal: 3" "Number of nodes are equal: 2" [3] "Tip labels are the same." "Topologies are the same." [5] "The labeled trees differ." > ### ... do this instead: > identical(all.equal(t3, t5), TRUE) [1] FALSE > > > > cleanEx(); ..nameEx <- "as.matching" > > ### * as.matching > > flush(stderr()); flush(stdout()) > > ### Name: as.matching > ### Title: Conversion Between Phylo and Matching Objects > ### Aliases: as.matching as.matching.phylo as.phylo.matching > ### Keywords: manip > > ### ** Examples > > data(bird.orders) > m <- as.matching(bird.orders) > str(m) List of 3 $ matching : num [1:22, 1:3] 1 3 9 11 16 18 21 5 20 26 ... $ edge.length: num [1:44] 21.8 21.8 21.6 21.6 22.9 27 26.3 24.4 20.8 20.8 ... $ tip.label : chr [1:23] "Struthioniformes" "Tinamiformes" "Craciformes" "Galliformes" ... - attr(*, "class")= chr "matching" > m $matching [,1] [,2] [,3] [1,] 1 2 24 [2,] 3 4 25 [3,] 9 10 26 [4,] 11 12 27 [5,] 16 17 28 [6,] 18 19 29 [7,] 21 22 30 [8,] 5 25 31 [9,] 20 30 32 [10,] 26 27 33 [11,] 28 29 34 [12,] 8 33 35 [13,] 23 32 36 [14,] 24 31 37 [15,] 34 36 38 [16,] 15 38 39 [17,] 14 39 40 [18,] 13 40 41 [19,] 35 41 42 [20,] 7 42 43 [21,] 6 43 44 [22,] 37 44 45 $edge.length [1] 21.8 21.8 21.6 21.6 22.9 27.0 26.3 24.4 20.8 20.8 22.1 22.1 24.5 23.7 23.1 [16] 21.3 21.3 20.4 20.4 20.8 20.1 20.1 21.6 4.1 1.3 2.6 1.3 0.6 1.5 0.7 [31] 3.0 0.8 1.0 0.6 0.6 0.9 2.1 0.6 0.6 0.8 0.5 1.3 0.7 1.0 $tip.label [1] "Struthioniformes" "Tinamiformes" "Craciformes" "Galliformes" [5] "Anseriformes" "Turniciformes" "Piciformes" "Galbuliformes" [9] "Bucerotiformes" "Upupiformes" "Trogoniformes" "Coraciiformes" [13] "Coliiformes" "Cuculiformes" "Psittaciformes" "Apodiformes" [17] "Trochiliformes" "Musophagiformes" "Strigiformes" "Columbiformes" [21] "Gruiformes" "Ciconiiformes" "Passeriformes" attr(,"class") [1] "matching" > tr <- as.phylo(m) > all.equal(tr, bird.orders) [1] TRUE > > > > cleanEx(); ..nameEx <- "as.phylo" > > ### * as.phylo > > flush(stderr()); flush(stdout()) > > ### Name: as.phylo > ### Title: Conversion Among Tree Objects > ### Aliases: as.phylo as.phylo.hclust as.phylo.phylog as.hclust.phylo > ### Keywords: manip > > ### ** Examples > > data(bird.orders) > hc <- as.hclust(bird.orders) > tr <- as.phylo(hc) > identical(bird.orders, tr) # FALSE, but... [1] FALSE > all.equal(bird.orders, tr) # ... TRUE [1] TRUE > > ### shows the three plots for tree objects: > dend <- as.dendrogram(hc) > layout(matrix(c(1:3, 3), 2, 2)) > plot(bird.orders, font = 1) > plot(hc) > par(mar = c(8, 0, 0, 0)) # leave space for the labels > plot(dend) > > ### how to get (nearly) identical plots with > ### plot.phylo and plot.dendrogram: > layout(matrix(1:2, 2, 1)) > plot(bird.orders, font = 1, no.margin = TRUE) > par(mar = c(0, 0, 0, 8)) > plot((dend), horiz = TRUE) > layout(matrix(1, 1, 1)) > > > > graphics::par(get("par.postscript", env = .CheckExEnv)) > cleanEx(); ..nameEx <- "axisPhylo" > > ### * axisPhylo > > flush(stderr()); flush(stdout()) > > ### Name: axisPhylo > ### Title: Axis on Side of Phylogeny > ### Aliases: axisPhylo > ### Keywords: aplot > > ### ** Examples > > tr <- rtree(30) > ch <- chronogram(tr) > plot(ch) > axisPhylo() > plot(tr, "c", FALSE, direction = "u") > axisPhylo(2, las = 1) > > > > cleanEx(); ..nameEx <- "bd.ext" > > ### * bd.ext > > flush(stderr()); flush(stdout()) > > ### Name: bd.ext > ### Title: Extended Version of the Birth-Death Models to Estimate > ### Speciation and Extinction Rates > ### Aliases: bd.ext > ### Keywords: models > > ### ** Examples > > ### An example from Paradis (2003) using the avian orders: > data(bird.orders) > ### Number of species in each order from Sibley and Monroe (1990): > S <- c(10, 47, 69, 214, 161, 17, 355, 51, 56, 10, 39, 152, + 6, 143, 358, 103, 319, 23, 291, 313, 196, 1027, 5712) > bd.ext(bird.orders, S) Warning in log(x) : NaNs produced Warning: NA/Inf replaced by maximum positive value Warning in log(x) : NaNs produced Warning: NA/Inf replaced by maximum positive value Warning in log(x) : NaNs produced Warning in log(x) : NaNs produced Warning: NA/Inf replaced by maximum positive value Warning: NA/Inf replaced by maximum positive value Warning: NA/Inf replaced by maximum positive value Warning in log(x) : NaNs produced Warning in log(x) : NaNs produced Warning: NA/Inf replaced by maximum positive value Extended Version of the Birth-Death Models to Estimate Speciation and Extinction Rates Data: phylogenetic: bird.orders taxonomic: S Number of tips: 23 Deviance: 289.1639 Log-likelihood: -144.5820 Parameter estimates: d / b = 0 StdErr = 0 b - d = 0.2866789 StdErr = 0.007215593 (b: speciation rate, d: extinction rate) > > > > cleanEx(); ..nameEx <- "bind.tree" > > ### * bind.tree > > flush(stderr()); flush(stdout()) > > ### Name: bind.tree > ### Title: Binds Trees > ### Aliases: bind.tree > ### Keywords: manip > > ### ** Examples > > ### binds the two clades of bird orders > cat("((Struthioniformes:21.8,Tinamiformes:21.8):4.1,", + "((Craciformes:21.6,Galliformes:21.6):1.3,Anseriformes:22.9):3.0):2.1;", + file = "ex1.tre", sep = "\n") > cat("(Turniciformes:27.0,(Piciformes:26.3,((Galbuliformes:24.4,", + "((Bucerotiformes:20.8,Upupiformes:20.8):2.6,", + "(Trogoniformes:22.1,Coraciiformes:22.1):1.3):1.0):0.6,", + "(Coliiformes:24.5,(Cuculiformes:23.7,(Psittaciformes:23.1,", + "(((Apodiformes:21.3,Trochiliformes:21.3):0.6,", + "(Musophagiformes:20.4,Strigiformes:20.4):1.5):0.6,", + "((Columbiformes:20.8,(Gruiformes:20.1,Ciconiiformes:20.1):0.7):0.8,", + "Passeriformes:21.6):0.9):0.6):0.6):0.8):0.5):1.3):0.7):1.0;", + file = "ex2.tre", sep = "\n") > tree.bird1 <- read.tree("ex1.tre") > tree.bird2 <- read.tree("ex2.tre") > unlink(c("ex1.tre", "ex2.tre")) # clean-up > birds <- bind.tree(tree.bird1, tree.bird2, branch = -1, + position = tree.bird1$root.edge) > birds $edge [,1] [,2] [1,] "-1" "-2" [2,] "-2" "-3" [3,] "-3" "1" [4,] "-3" "2" [5,] "-2" "-4" [6,] "-4" "-5" [7,] "-5" "3" [8,] "-5" "4" [9,] "-4" "5" [10,] "-1" "-6" [11,] "-6" "6" [12,] "-6" "-7" [13,] "-7" "7" [14,] "-7" "-8" [15,] "-8" "-9" [16,] "-9" "8" [17,] "-9" "-10" [18,] "-10" "-11" [19,] "-11" "9" [20,] "-11" "10" [21,] "-10" "-12" [22,] "-12" "11" [23,] "-12" "12" [24,] "-8" "-13" [25,] "-13" "13" [26,] "-13" "-14" [27,] "-14" "14" [28,] "-14" "-15" [29,] "-15" "15" [30,] "-15" "-16" [31,] "-16" "-17" [32,] "-17" "-18" [33,] "-18" "16" [34,] "-18" "17" [35,] "-17" "-19" [36,] "-19" "18" [37,] "-19" "19" [38,] "-16" "-20" [39,] "-20" "-21" [40,] "-21" "20" [41,] "-21" "-22" [42,] "-22" "21" [43,] "-22" "22" [44,] "-20" "23" $edge.length [1] 2.1 4.1 21.8 21.8 3.0 1.3 21.6 21.6 22.9 1.0 27.0 0.7 26.3 1.3 0.6 [16] 24.4 1.0 2.6 20.8 20.8 1.3 22.1 22.1 0.5 24.5 0.8 23.7 0.6 23.1 0.6 [31] 0.6 0.6 21.3 21.3 1.5 20.4 20.4 0.9 0.8 20.8 0.7 20.1 20.1 21.6 $tip.label [1] "Struthioniformes" "Tinamiformes" "Craciformes" "Galliformes" [5] "Anseriformes" "Turniciformes" "Piciformes" "Galbuliformes" [9] "Bucerotiformes" "Upupiformes" "Trogoniformes" "Coraciiformes" [13] "Coliiformes" "Cuculiformes" "Psittaciformes" "Apodiformes" [17] "Trochiliformes" "Musophagiformes" "Strigiformes" "Columbiformes" [21] "Gruiformes" "Ciconiiformes" "Passeriformes" $root.edge [1] 0 attr(,"class") [1] "phylo" > layout(matrix(c(1, 2, 3, 3), 2, 2)) > plot(tree.bird1) > plot(tree.bird2) > plot(birds) > layout(matrix(1)) > > > > cleanEx(); ..nameEx <- "bird.families" > > ### * bird.families > > flush(stderr()); flush(stdout()) > > ### Name: bird.families > ### Title: Phylogeny of the Families of Birds From Sibley and Ahlquist > ### Aliases: bird.families > ### Keywords: datasets > > ### ** Examples > > data(bird.families) > op <- par() > par(cex = 0.3) > plot(bird.families) > par(op) Warning in par(args) : parameter "cin" cannot be set Warning in par(args) : parameter "cra" cannot be set Warning in par(args) : parameter "csi" cannot be set Warning in par(args) : parameter "cxy" cannot be set Warning in par(args) : parameter "din" cannot be set Warning in par(args) : gamma cannot be modified on this device > > > > graphics::par(get("par.postscript", env = .CheckExEnv)) > cleanEx(); ..nameEx <- "bird.orders" > > ### * bird.orders > > flush(stderr()); flush(stdout()) > > ### Name: bird.orders > ### Title: Phylogeny of the Orders of Birds From Sibley and Ahlquist > ### Aliases: bird.orders > ### Keywords: datasets > > ### ** Examples > > data(bird.orders) > plot(bird.orders) > > > > cleanEx(); ..nameEx <- "carnivora" > > ### * carnivora > > flush(stderr()); flush(stdout()) > > ### Name: carnivora > ### Title: Carnivora body sizes and life history traits > ### Aliases: carnivora > ### Keywords: datasets > > ### ** Examples > > data(carnivora); > # This is figure 1 of Gittleman 1986: > library(lattice) > trellis.device(color=FALSE) > xyplot(BW ~ FW, groups=Family, data=carnivora, auto.key=TRUE, xlog=TRUE, + scale=list(log=TRUE), ylim=c(1, 2000)) > trellis.device(color=FALSE) > xyplot(BW ~ FB, groups=Family, data=carnivora, auto.key=TRUE, xlog=TRUE, + scale=list(log=TRUE), ylim=c(1, 2000)) > > > > cleanEx(); ..nameEx <- "chiroptera" > > ### * chiroptera > > flush(stderr()); flush(stdout()) > > ### Name: chiroptera > ### Title: Bat Phylogeny > ### Aliases: chiroptera > ### Keywords: datasets > > ### ** Examples > > data(chiroptera) > str(chiroptera) List of 2 $ edge : chr [1:1344, 1:2] "-1" "-2" "-3" "-4" ... $ tip.label: chr [1:916] "Paranyctimene_raptor" "Nyctimene_aello" "Nyctimene_celaeno" "Nyctimene_certans" ... - attr(*, "class")= chr "phylo" - attr(*, "origin")= chr "D:/rw1090/library/ape/data/Jonesetal2002.nex" > op <- par() > par(cex = 0.3) > plot(chiroptera, type = "c") > par(op) Warning in par(args) : parameter "cin" cannot be set Warning in par(args) : parameter "cra" cannot be set Warning in par(args) : parameter "csi" cannot be set Warning in par(args) : parameter "cxy" cannot be set Warning in par(args) : parameter "din" cannot be set Warning in par(args) : gamma cannot be modified on this device > > > > graphics::par(get("par.postscript", env = .CheckExEnv)) > cleanEx(); ..nameEx <- "chronogram" > > ### * chronogram > > flush(stderr()); flush(stdout()) > > ### Name: chronogram > ### Title: Chronogram Computed by Nonparametric Rate Smoothing > ### Aliases: chronogram > ### Keywords: manip > > ### ** Examples > > library(ape) > > # get tree > data("landplants.newick") # example tree in NH format > tree.landplants <- read.tree(text = landplants.newick) > > # plot tree > tree.landplants $edge [,1] [,2] [1,] "-1" "1" [2,] "-1" "-2" [3,] "-2" "2" [4,] "-2" "-3" [5,] "-3" "-4" [6,] "-4" "3" [7,] "-4" "4" [8,] "-4" "5" [9,] "-3" "-5" [10,] "-5" "-6" [11,] "-6" "-7" [12,] "-7" "6" [13,] "-7" "7" [14,] "-6" "8" [15,] "-6" "-8" [16,] "-8" "-9" [17,] "-9" "9" [18,] "-9" "-10" [19,] "-10" "10" [20,] "-10" "11" [21,] "-8" "-11" [22,] "-11" "12" [23,] "-11" "-12" [24,] "-12" "13" [25,] "-12" "14" [26,] "-5" "-13" [27,] "-13" "15" [28,] "-13" "-14" [29,] "-14" "16" [30,] "-14" "17" [31,] "-14" "-15" [32,] "-15" "-16" [33,] "-16" "18" [34,] "-16" "-17" [35,] "-17" "19" [36,] "-17" "20" [37,] "-15" "21" [38,] "-14" "-18" [39,] "-18" "22" [40,] "-18" "23" [41,] "-14" "-19" [42,] "-19" "-20" [43,] "-20" "24" [44,] "-20" "25" [45,] "-19" "-21" [46,] "-21" "26" [47,] "-21" "-22" [48,] "-22" "27" [49,] "-22" "28" [50,] "-21" "-23" [51,] "-23" "29" [52,] "-23" "-24" [53,] "-24" "30" [54,] "-24" "-25" [55,] "-25" "31" [56,] "-25" "32" [57,] "-23" "-26" [58,] "-26" "33" [59,] "-26" "34" [60,] "-13" "35" [61,] "-13" "36" $edge.length [1] 0.033817 0.019372 0.040281 0.012469 0.011806 0.048533 0.033640 0.036526 [9] 0.021625 0.010855 0.005021 0.009460 0.018847 0.014702 0.006309 0.002448 [17] 0.021500 0.006473 0.015649 0.021081 0.016663 0.029965 0.006883 0.011298 [25] 0.014165 0.003527 0.016835 0.007348 0.019902 0.020151 0.007844 0.007654 [33] 0.020003 0.002933 0.006005 0.031555 0.038488 0.004656 0.013524 0.035902 [41] 0.002918 0.005117 0.015119 0.010172 0.006457 0.029027 0.003958 0.006180 [49] 0.002347 0.004803 0.013294 0.001994 0.035675 0.001459 0.009848 0.008236 [57] 0.002619 0.019136 0.041396 0.019265 0.019263 $tip.label [1] "Marchantia" "Lycopodium" "Equisetum" "Osmunda" "Asplenium" [6] "Cycas" "Zamia" "Ginkgo" "Pinus" "Podocarpac" [11] "Taxus" "Ephedra" "Welwitsch" "Gnetum" "Nymphaea" [16] "Saururus" "Chloranth" "Araceae" "Palmae" "Oryza" [21] "Acorus" "Calycanth" "Lauraceae" "Magnolia" "Drimys" [26] "Ranunculus" "Nelumbo" "Platanus" "Buxaceae" "Pisum" [31] "Fagus" "Carya" "Ericaceae" "Solanaceae" "Austrobail" [36] "Amborella" attr(,"class") [1] "phylo" > plot(tree.landplants, label.offset = 0.001) > > # estimate chronogram > chrono.plants <- chronogram(tree.landplants) > > # plot and write to file > plot(chrono.plants, label.offset = 0.001) > write.tree(chrono.plants, file = "chronogram.phy") > > # value of NPRS function for our estimated chronogram > NPRS.criterion(tree.landplants, chrono.plants) [1] 0.1697855 > > > > cleanEx(); ..nameEx <- "coalescent.intervals" > > ### * coalescent.intervals > > flush(stderr()); flush(stdout()) > > ### Name: coalescent.intervals > ### Title: Coalescent Intervals > ### Aliases: coalescent.intervals coalescent.intervals.phylo > ### coalescent.intervals.default > ### Keywords: manip > > ### ** Examples > > library(ape) > > data("hivtree.newick") # example tree in NH format > tree.hiv <- read.tree(text = hivtree.newick) # load tree > > ci <- coalescent.intervals(tree.hiv) # from tree > ci $lineages [1] 193 192 191 190 189 188 187 186 185 184 183 182 181 180 179 178 177 176 [19] 175 174 173 172 171 170 169 168 167 166 165 164 163 162 161 160 159 158 [37] 157 156 155 154 153 152 151 150 149 148 147 146 145 144 143 142 141 140 [55] 139 138 137 136 135 134 133 132 131 130 129 128 127 126 125 124 123 122 [73] 121 120 119 118 117 116 115 114 113 112 111 110 109 108 107 106 105 104 [91] 103 102 101 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 [109] 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 [127] 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 [145] 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 [163] 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 [181] 13 12 11 10 9 8 7 6 5 4 3 2 $interval.length [1] 0.021159 0.028661 0.000236 0.004386 0.003136 0.000040 0.000962 0.000754 [9] 0.000390 0.002121 0.001165 0.002138 0.000392 0.002225 0.000479 0.000039 [17] 0.001056 0.000290 0.000094 0.000405 0.000376 0.000892 0.005770 0.000606 [25] 0.000311 0.000354 0.000049 0.001303 0.000111 0.000191 0.000113 0.000701 [33] 0.000012 0.000004 0.000343 0.000466 0.000701 0.000001 0.000286 0.000404 [41] 0.000048 0.000264 0.000382 0.000723 0.000025 0.000063 0.001082 0.000293 [49] 0.001458 0.000057 0.000268 0.000822 0.000035 0.000141 0.000038 0.000393 [57] 0.000263 0.000061 0.000697 0.000011 0.000331 0.000198 0.000637 0.000161 [65] 0.000722 0.000568 0.000016 0.000892 0.000233 0.000124 0.000044 0.000210 [73] 0.000137 0.000162 0.000066 0.000319 0.000039 0.000226 0.000001 0.000035 [81] 0.000794 0.000107 0.000162 0.000130 0.000588 0.000128 0.000063 0.000001 [89] 0.002044 0.000081 0.000115 0.000144 0.000222 0.001136 0.000794 0.000014 [97] 0.000069 0.000001 0.000437 0.000191 0.000470 0.000654 0.000164 0.000048 [105] 0.000460 0.000098 0.000207 0.000326 0.000001 0.000002 0.000161 0.000873 [113] 0.000141 0.000868 0.000224 0.000342 0.000700 0.000222 0.000151 0.000631 [121] 0.000663 0.001550 0.000323 0.000711 0.000086 0.000651 0.000346 0.000001 [129] 0.000067 0.000255 0.000146 0.000260 0.000169 0.000071 0.000142 0.001229 [137] 0.000106 0.001085 0.000116 0.000204 0.000214 0.000810 0.000112 0.000132 [145] 0.000208 0.000093 0.001182 0.000143 0.000083 0.000003 0.001560 0.000368 [153] 0.000150 0.000537 0.001174 0.000957 0.002662 0.000001 0.000001 0.000095 [161] 0.001008 0.001359 0.000001 0.000103 0.000747 0.000245 0.000829 0.002804 [169] 0.000699 0.000001 0.000119 0.004393 0.002748 0.001334 0.002036 0.001906 [177] 0.001858 0.001173 0.004342 0.009066 0.001531 0.000545 0.009855 0.001407 [185] 0.001059 0.002167 0.011000 0.004665 0.000001 0.007899 0.000001 0.004212 $interval.count [1] 192 $total.depth [1] 0.20911 attr(,"class") [1] "coalescentIntervals" > > data("hivtree.table") # same tree, but in table format > ci <- coalescent.intervals(hivtree.table$size) # from vector of interval lengths > ci $lineages [1] 193 192 191 190 189 188 187 186 185 184 183 182 181 180 179 178 177 176 [19] 175 174 173 172 171 170 169 168 167 166 165 164 163 162 161 160 159 158 [37] 157 156 155 154 153 152 151 150 149 148 147 146 145 144 143 142 141 140 [55] 139 138 137 136 135 134 133 132 131 130 129 128 127 126 125 124 123 122 [73] 121 120 119 118 117 116 115 114 113 112 111 110 109 108 107 106 105 104 [91] 103 102 101 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 [109] 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 [127] 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 [145] 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 [163] 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 [181] 13 12 11 10 9 8 7 6 5 4 3 2 $interval.length [1] 0.021163 0.028658 0.000237 0.004382 0.003138 0.000046 0.000956 0.000754 [9] 0.000394 0.002115 0.001170 0.002138 0.000391 0.002226 0.000478 0.000035 [17] 0.001063 0.000289 0.000093 0.000406 0.000374 0.000894 0.005766 0.000608 [25] 0.000313 0.000351 0.000051 0.001306 0.000103 0.000196 0.000114 0.000699 [33] 0.000014 0.000002 0.000340 0.000467 0.000706 0.000001 0.000281 0.000405 [41] 0.000044 0.000269 0.000381 0.000727 0.000024 0.000061 0.001083 0.000291 [49] 0.001460 0.000056 0.000268 0.000818 0.000041 0.000138 0.000037 0.000397 [57] 0.000262 0.000060 0.000699 0.000008 0.000332 0.000197 0.000641 0.000158 [65] 0.000722 0.000562 0.000023 0.000893 0.000232 0.000122 0.000045 0.000212 [73] 0.000138 0.000158 0.000070 0.000316 0.000040 0.000221 0.000004 0.000037 [81] 0.000795 0.000105 0.000162 0.000129 0.000588 0.000132 0.000065 0.000001 [89] 0.002039 0.000083 0.000108 0.000152 0.000221 0.001135 0.000794 0.000013 [97] 0.000069 0.000001 0.000439 0.000189 0.000468 0.000656 0.000163 0.000052 [105] 0.000456 0.000100 0.000206 0.000328 0.000001 0.000001 0.000162 0.000872 [113] 0.000142 0.000869 0.000222 0.000342 0.000699 0.000225 0.000149 0.000632 [121] 0.000661 0.001551 0.000325 0.000710 0.000084 0.000656 0.000343 0.000001 [129] 0.000062 0.000260 0.000149 0.000257 0.000169 0.000067 0.000146 0.001228 [137] 0.000108 0.001083 0.000115 0.000206 0.000214 0.000810 0.000113 0.000129 [145] 0.000211 0.000090 0.001179 0.000149 0.000080 0.000006 0.001562 0.000365 [153] 0.000148 0.000540 0.001173 0.000955 0.002667 0.000001 0.000001 0.000092 [161] 0.001009 0.001358 0.000001 0.000103 0.000742 0.000244 0.000833 0.002804 [169] 0.000700 0.000005 0.000116 0.004393 0.002747 0.001338 0.002033 0.001904 [177] 0.001861 0.001175 0.004338 0.009062 0.001534 0.000548 0.009855 0.001403 [185] 0.001063 0.002169 0.010997 0.004668 0.000001 0.007897 0.000001 0.004214 $interval.count [1] 192 $total.depth [1] 0.209117 attr(,"class") [1] "coalescentIntervals" > > > > cleanEx(); ..nameEx <- "collapsed.intervals" > > ### * collapsed.intervals > > flush(stderr()); flush(stdout()) > > ### Name: collapsed.intervals > ### Title: Collapsed Coalescent Intervals > ### Aliases: collapsed.intervals > ### Keywords: manip > > ### ** Examples > > library(ape) > > data("hivtree.table") # example tree > > # colescent intervals from vector of interval lengths > ci <- coalescent.intervals(hivtree.table$size) > ci $lineages [1] 193 192 191 190 189 188 187 186 185 184 183 182 181 180 179 178 177 176 [19] 175 174 173 172 171 170 169 168 167 166 165 164 163 162 161 160 159 158 [37] 157 156 155 154 153 152 151 150 149 148 147 146 145 144 143 142 141 140 [55] 139 138 137 136 135 134 133 132 131 130 129 128 127 126 125 124 123 122 [73] 121 120 119 118 117 116 115 114 113 112 111 110 109 108 107 106 105 104 [91] 103 102 101 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 [109] 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 [127] 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 [145] 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 [163] 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 [181] 13 12 11 10 9 8 7 6 5 4 3 2 $interval.length [1] 0.021163 0.028658 0.000237 0.004382 0.003138 0.000046 0.000956 0.000754 [9] 0.000394 0.002115 0.001170 0.002138 0.000391 0.002226 0.000478 0.000035 [17] 0.001063 0.000289 0.000093 0.000406 0.000374 0.000894 0.005766 0.000608 [25] 0.000313 0.000351 0.000051 0.001306 0.000103 0.000196 0.000114 0.000699 [33] 0.000014 0.000002 0.000340 0.000467 0.000706 0.000001 0.000281 0.000405 [41] 0.000044 0.000269 0.000381 0.000727 0.000024 0.000061 0.001083 0.000291 [49] 0.001460 0.000056 0.000268 0.000818 0.000041 0.000138 0.000037 0.000397 [57] 0.000262 0.000060 0.000699 0.000008 0.000332 0.000197 0.000641 0.000158 [65] 0.000722 0.000562 0.000023 0.000893 0.000232 0.000122 0.000045 0.000212 [73] 0.000138 0.000158 0.000070 0.000316 0.000040 0.000221 0.000004 0.000037 [81] 0.000795 0.000105 0.000162 0.000129 0.000588 0.000132 0.000065 0.000001 [89] 0.002039 0.000083 0.000108 0.000152 0.000221 0.001135 0.000794 0.000013 [97] 0.000069 0.000001 0.000439 0.000189 0.000468 0.000656 0.000163 0.000052 [105] 0.000456 0.000100 0.000206 0.000328 0.000001 0.000001 0.000162 0.000872 [113] 0.000142 0.000869 0.000222 0.000342 0.000699 0.000225 0.000149 0.000632 [121] 0.000661 0.001551 0.000325 0.000710 0.000084 0.000656 0.000343 0.000001 [129] 0.000062 0.000260 0.000149 0.000257 0.000169 0.000067 0.000146 0.001228 [137] 0.000108 0.001083 0.000115 0.000206 0.000214 0.000810 0.000113 0.000129 [145] 0.000211 0.000090 0.001179 0.000149 0.000080 0.000006 0.001562 0.000365 [153] 0.000148 0.000540 0.001173 0.000955 0.002667 0.000001 0.000001 0.000092 [161] 0.001009 0.001358 0.000001 0.000103 0.000742 0.000244 0.000833 0.002804 [169] 0.000700 0.000005 0.000116 0.004393 0.002747 0.001338 0.002033 0.001904 [177] 0.001861 0.001175 0.004338 0.009062 0.001534 0.000548 0.009855 0.001403 [185] 0.001063 0.002169 0.010997 0.004668 0.000001 0.007897 0.000001 0.004214 $interval.count [1] 192 $total.depth [1] 0.209117 attr(,"class") [1] "coalescentIntervals" > > # collapsed intervals > cl1 <- collapsed.intervals(ci,0) > cl2 <- collapsed.intervals(ci,0.0119) > > cl1 $lineages [1] 193 192 191 190 189 188 187 186 185 184 183 182 181 180 179 178 177 176 [19] 175 174 173 172 171 170 169 168 167 166 165 164 163 162 161 160 159 158 [37] 157 156 155 154 153 152 151 150 149 148 147 146 145 144 143 142 141 140 [55] 139 138 137 136 135 134 133 132 131 130 129 128 127 126 125 124 123 122 [73] 121 120 119 118 117 116 115 114 113 112 111 110 109 108 107 106 105 104 [91] 103 102 101 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 [109] 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 [127] 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 [145] 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 [163] 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 [181] 13 12 11 10 9 8 7 6 5 4 3 2 $interval.length [1] 0.021163 0.028658 0.000237 0.004382 0.003138 0.000046 0.000956 0.000754 [9] 0.000394 0.002115 0.001170 0.002138 0.000391 0.002226 0.000478 0.000035 [17] 0.001063 0.000289 0.000093 0.000406 0.000374 0.000894 0.005766 0.000608 [25] 0.000313 0.000351 0.000051 0.001306 0.000103 0.000196 0.000114 0.000699 [33] 0.000014 0.000002 0.000340 0.000467 0.000706 0.000001 0.000281 0.000405 [41] 0.000044 0.000269 0.000381 0.000727 0.000024 0.000061 0.001083 0.000291 [49] 0.001460 0.000056 0.000268 0.000818 0.000041 0.000138 0.000037 0.000397 [57] 0.000262 0.000060 0.000699 0.000008 0.000332 0.000197 0.000641 0.000158 [65] 0.000722 0.000562 0.000023 0.000893 0.000232 0.000122 0.000045 0.000212 [73] 0.000138 0.000158 0.000070 0.000316 0.000040 0.000221 0.000004 0.000037 [81] 0.000795 0.000105 0.000162 0.000129 0.000588 0.000132 0.000065 0.000001 [89] 0.002039 0.000083 0.000108 0.000152 0.000221 0.001135 0.000794 0.000013 [97] 0.000069 0.000001 0.000439 0.000189 0.000468 0.000656 0.000163 0.000052 [105] 0.000456 0.000100 0.000206 0.000328 0.000001 0.000001 0.000162 0.000872 [113] 0.000142 0.000869 0.000222 0.000342 0.000699 0.000225 0.000149 0.000632 [121] 0.000661 0.001551 0.000325 0.000710 0.000084 0.000656 0.000343 0.000001 [129] 0.000062 0.000260 0.000149 0.000257 0.000169 0.000067 0.000146 0.001228 [137] 0.000108 0.001083 0.000115 0.000206 0.000214 0.000810 0.000113 0.000129 [145] 0.000211 0.000090 0.001179 0.000149 0.000080 0.000006 0.001562 0.000365 [153] 0.000148 0.000540 0.001173 0.000955 0.002667 0.000001 0.000001 0.000092 [161] 0.001009 0.001358 0.000001 0.000103 0.000742 0.000244 0.000833 0.002804 [169] 0.000700 0.000005 0.000116 0.004393 0.002747 0.001338 0.002033 0.001904 [177] 0.001861 0.001175 0.004338 0.009062 0.001534 0.000548 0.009855 0.001403 [185] 0.001063 0.002169 0.010997 0.004668 0.000001 0.007897 0.000001 0.004214 $collapsed.interval [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 [19] 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 [37] 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 [55] 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 [73] 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 [91] 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 [109] 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 [127] 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 [145] 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 [163] 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 [181] 181 182 183 184 185 186 187 188 189 190 191 192 $interval.count [1] 192 $collapsed.interval.count [1] 192 $total.depth [1] 0.209117 $epsilon [1] 0 attr(,"class") [1] "collapsedIntervals" > cl2 $lineages [1] 193 192 191 190 189 188 187 186 185 184 183 182 181 180 179 178 177 176 [19] 175 174 173 172 171 170 169 168 167 166 165 164 163 162 161 160 159 158 [37] 157 156 155 154 153 152 151 150 149 148 147 146 145 144 143 142 141 140 [55] 139 138 137 136 135 134 133 132 131 130 129 128 127 126 125 124 123 122 [73] 121 120 119 118 117 116 115 114 113 112 111 110 109 108 107 106 105 104 [91] 103 102 101 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 [109] 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 [127] 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 [145] 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 [163] 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 [181] 13 12 11 10 9 8 7 6 5 4 3 2 $interval.length [1] 0.021163 0.028658 0.000237 0.004382 0.003138 0.000046 0.000956 0.000754 [9] 0.000394 0.002115 0.001170 0.002138 0.000391 0.002226 0.000478 0.000035 [17] 0.001063 0.000289 0.000093 0.000406 0.000374 0.000894 0.005766 0.000608 [25] 0.000313 0.000351 0.000051 0.001306 0.000103 0.000196 0.000114 0.000699 [33] 0.000014 0.000002 0.000340 0.000467 0.000706 0.000001 0.000281 0.000405 [41] 0.000044 0.000269 0.000381 0.000727 0.000024 0.000061 0.001083 0.000291 [49] 0.001460 0.000056 0.000268 0.000818 0.000041 0.000138 0.000037 0.000397 [57] 0.000262 0.000060 0.000699 0.000008 0.000332 0.000197 0.000641 0.000158 [65] 0.000722 0.000562 0.000023 0.000893 0.000232 0.000122 0.000045 0.000212 [73] 0.000138 0.000158 0.000070 0.000316 0.000040 0.000221 0.000004 0.000037 [81] 0.000795 0.000105 0.000162 0.000129 0.000588 0.000132 0.000065 0.000001 [89] 0.002039 0.000083 0.000108 0.000152 0.000221 0.001135 0.000794 0.000013 [97] 0.000069 0.000001 0.000439 0.000189 0.000468 0.000656 0.000163 0.000052 [105] 0.000456 0.000100 0.000206 0.000328 0.000001 0.000001 0.000162 0.000872 [113] 0.000142 0.000869 0.000222 0.000342 0.000699 0.000225 0.000149 0.000632 [121] 0.000661 0.001551 0.000325 0.000710 0.000084 0.000656 0.000343 0.000001 [129] 0.000062 0.000260 0.000149 0.000257 0.000169 0.000067 0.000146 0.001228 [137] 0.000108 0.001083 0.000115 0.000206 0.000214 0.000810 0.000113 0.000129 [145] 0.000211 0.000090 0.001179 0.000149 0.000080 0.000006 0.001562 0.000365 [153] 0.000148 0.000540 0.001173 0.000955 0.002667 0.000001 0.000001 0.000092 [161] 0.001009 0.001358 0.000001 0.000103 0.000742 0.000244 0.000833 0.002804 [169] 0.000700 0.000005 0.000116 0.004393 0.002747 0.001338 0.002033 0.001904 [177] 0.001861 0.001175 0.004338 0.009062 0.001534 0.000548 0.009855 0.001403 [185] 0.001063 0.002169 0.010997 0.004668 0.000001 0.007897 0.000001 0.004214 $collapsed.interval [1] 1 2 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 [26] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 [51] 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 [76] 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 [101] 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 [126] 7 7 7 7 7 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 [151] 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10 10 [176] 10 10 10 10 11 11 11 11 12 12 12 12 13 13 13 13 13 $interval.count [1] 192 $collapsed.interval.count [1] 13 $total.depth [1] 0.209117 $epsilon [1] 0.0119 attr(,"class") [1] "collapsedIntervals" > > > > > cleanEx(); ..nameEx <- "compar.cheverud" > > ### * compar.cheverud > > flush(stderr()); flush(stdout()) > > ### Name: compar.cheverud > ### Title: Cheverud's Comparative Method > ### Aliases: compar.cheverud > ### Keywords: regression > > ### ** Examples > > ### Example from Harvey and Pagel's book: > y<-c(10,8,3,4) > W <- matrix(c(1,1/6,1/6,1/6,1/6,1,1/2,1/2,1/6,1/2,1,1,1/6,1/2,1,1), 4) > compar.cheverud(y,W) $rhohat [1] -1.836522 $Wnorm [,1] [,2] [,3] [,4] [1,] 0.0000000 0.3333333 0.3333333 0.3333333 [2,] 0.4545455 0.0000000 0.2727273 0.2727273 [3,] 0.6250000 0.3750000 0.0000000 0.0000000 [4,] 0.6250000 0.3750000 0.0000000 0.0000000 $residuals [,1] [1,] 1.454348 [2,] 2.125652 [3,] 2.259565 [4,] 3.259565 > > ### Example from Rohlf's 2001 article: > W<- matrix(c( + 0,1,1,2,0,0,0,0, + 1,0,1,2,0,0,0,0, + 1,1,0,2,0,0,0,0, + 2,2,2,0,0,0,0,0, + 0,0,0,0,0,1,1,2, + 0,0,0,0,1,0,1,2, + 0,0,0,0,1,1,0,2, + 0,0,0,0,2,2,2,0 + ),8) > W <- 1/W > W[W == Inf] <- 0 > y<-c(-0.12,0.36,-0.1,0.04,-0.15,0.29,-0.11,-0.06) > compar.cheverud(y,W) $rhohat [1] -1.441461 $Wnorm [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [1,] 0.0000000 0.4000000 0.4000000 0.2 0.0000000 0.0000000 0.0000000 0.0 [2,] 0.4000000 0.0000000 0.4000000 0.2 0.0000000 0.0000000 0.0000000 0.0 [3,] 0.4000000 0.4000000 0.0000000 0.2 0.0000000 0.0000000 0.0000000 0.0 [4,] 0.3333333 0.3333333 0.3333333 0.0 0.0000000 0.0000000 0.0000000 0.0 [5,] 0.0000000 0.0000000 0.0000000 0.0 0.0000000 0.4000000 0.4000000 0.2 [6,] 0.0000000 0.0000000 0.0000000 0.0 0.4000000 0.0000000 0.4000000 0.2 [7,] 0.0000000 0.0000000 0.0000000 0.0 0.4000000 0.4000000 0.0000000 0.2 [8,] 0.0000000 0.0000000 0.0000000 0.0 0.3333333 0.3333333 0.3333333 0.0 $residuals [,1] [1,] -0.004333781 [2,] 0.198905747 [3,] 0.004134532 [4,] 0.061490780 [5,] -0.109289742 [6,] 0.077013158 [7,] -0.092353115 [8,] -0.091362782 > > > > cleanEx(); ..nameEx <- "compar.gee" > > ### * compar.gee > > flush(stderr()); flush(stdout()) > > ### Name: compar.gee > ### Title: Comparative Analysis with GEEs > ### Aliases: compar.gee print.compar.gee > ### Keywords: regression > > ### ** Examples > > ### The example in Phylip 3.5c (originally from Lynch 1991) > ### (the same analysis than in help(pic)...) > cat("((((Homo:0.21,Pongo:0.21):0.28,", + "Macaca:0.49):0.13,Ateles:0.62):0.38,Galago:1.00);", + file = "ex.tre", sep = "\n") > tree.primates <- read.tree("ex.tre") > X <- c(4.09434, 3.61092, 2.37024, 2.02815, -1.46968) > Y <- c(4.74493, 3.33220, 3.36730, 2.89037, 2.30259) > ### Both regressions... the results are quite close to those obtained > ### with pic(). > compar.gee(X ~ Y, phy = tree.primates) [1] "Beginning Cgee S-function, @(#) geeformula.q 4.13 98/01/27" [1] "running glm to get initial regression estimate" [1] -4.559093 2.009296 Call: formula: X ~ Y Number of observations: 5 Model: Link: identity Variance to Mean Relation: gaussian Summary of Residuals: Min 1Q Median 3Q Max -1.9460519 0.8312820 0.9651706 1.1805002 2.1069920 Coefficients: Estimate S.E. t Pr(T > |t|) (Intercept) -1.8216247 2.5273632 -0.720761 0.5770502 Y 0.9980051 0.7410169 1.346805 0.3637334 Estimated Scale Parameter: 3.747566 "Phylogenetic" df (dfP): 3.32 > compar.gee(Y ~ X, phy = tree.primates) [1] "Beginning Cgee S-function, @(#) geeformula.q 4.13 98/01/27" [1] "running glm to get initial regression estimate" [1] 2.5989768 0.3425349 Call: formula: Y ~ X Number of observations: 5 Model: Link: identity Variance to Mean Relation: gaussian Summary of Residuals: Min 1Q Median 3Q Max -0.7275418 -0.4857216 -0.1565515 0.4373258 0.4763833 Coefficients: Estimate S.E. t Pr(T > |t|) (Intercept) 2.5000672 0.4325167 5.780279 0.06773259 X 0.4319328 0.1597932 2.703074 0.17406821 Estimated Scale Parameter: 0.4026486 "Phylogenetic" df (dfP): 3.32 > ### Now do the GEE regressions through the origin: the results are quite > ### different! > compar.gee(X ~ Y - 1, phy = tree.primates) [1] "Beginning Cgee S-function, @(#) geeformula.q 4.13 98/01/27" [1] "running glm to get initial regression estimate" [1] 0.7151854 Call: formula: X ~ Y - 1 Number of observations: 5 Model: Link: identity Variance to Mean Relation: gaussian Summary of Residuals: Min 1Q Median 3Q Max -2.6818546 0.5065447 0.5975598 1.5964208 1.8567179 Coefficients: Estimate S.E. t Pr(T > |t|) Y 0.5264396 0.3338464 1.576892 0.2384290 Estimated Scale Parameter: 3.450493 "Phylogenetic" df (dfP): 3.32 > compar.gee(Y ~ X - 1, phy = tree.primates) [1] "Beginning Cgee S-function, @(#) geeformula.q 4.13 98/01/27" [1] "running glm to get initial regression estimate" [1] 1.005403 Call: formula: Y ~ X - 1 Number of observations: 5 Model: Link: identity Variance to Mean Relation: gaussian Summary of Residuals: Min 1Q Median 3Q Max 0.3139433 1.1951019 1.3225974 1.3860895 3.5310502 Coefficients: Estimate S.E. t Pr(T > |t|) X 0.8358692 0.4759221 1.756315 0.2034785 Estimated Scale Parameter: 4.416413 "Phylogenetic" df (dfP): 3.32 > unlink("ex.tre") # delete the file "ex.tre" > > > > cleanEx(); ..nameEx <- "compar.lynch" > > ### * compar.lynch > > flush(stderr()); flush(stdout()) > > ### Name: compar.lynch > ### Title: Lynch's Comparative Method > ### Aliases: compar.lynch > ### Keywords: regression > > ### ** Examples > > ### The example in Lynch (1991) > cat("((((Homo:0.21,Pongo:0.21):0.28,", + "Macaca:0.49):0.13,Ateles:0.62):0.38,Galago:1.00);", + file = "ex.tre", sep = "\n") > tree.primates <- read.tree("ex.tre") > X <- c(4.09434, 3.61092, 2.37024, 2.02815, -1.46968) > Y <- c(4.74493, 3.33220, 3.36730, 2.89037, 2.30259) > compar.lynch(cbind(X, Y), + G = vcv.phylo(tree.primates, cor = TRUE)) $vare [,1] [,2] [1,] 0.04988386 0.1056546 [2,] 0.10565457 0.2675678 $vara X Y X 3.0016391 0.9580373 Y 0.9580373 0.3068246 $A [,1] [,2] [1,] 2.5098436 0.8019430 [2,] 2.5750239 0.8213858 [3,] 1.1534032 0.3678133 [4,] 0.9702777 0.3080176 [5,] -2.7479320 -0.8760176 $E [,1] [,2] [1,] 0.34974667 0.90011195 [2,] -0.19885358 -0.53206089 [3,] -0.01791292 -0.04338837 [4,] -0.17687739 -0.46052269 [5,] 0.04350229 0.13573252 $u X Y 1.234671 3.042850 $lik [,1] [1,] -12.21798 > > > > cleanEx(); ..nameEx <- "compute.brlen" > > ### * compute.brlen > > flush(stderr()); flush(stdout()) > > ### Name: compute.brlen > ### Title: Branch lengths Computation > ### Aliases: compute.brlen > ### Keywords: manip > > ### ** Examples > > data(bird.orders) > split.screen(c(2,2)) [1] 1 2 3 4 > screen(1) > plot(compute.brlen(bird.orders, power=1), main=expression(rho==1)) > screen(2) > plot(compute.brlen(bird.orders, power=3), main=expression(rho==3)) > screen(3) > plot(compute.brlen(bird.orders, power=0.5), main=expression(rho==0.5)) > screen(4) > plot(compute.brlen(bird.orders, power=0.1), main=expression(rho==0.1)) > close.screen(all=TRUE) > > > > cleanEx(); ..nameEx <- "corClasses" > > ### * corClasses > > flush(stderr()); flush(stdout()) > > ### Name: corClasses > ### Title: Phylogenetic Correlation Structures > ### Aliases: corClasses corPhyl > ### Keywords: models > > ### ** Examples > > library(ape) > library(nlme) > cat("((((Homo:0.21,Pongo:0.21):0.28,", + "Macaca:0.49):0.13,Ateles:0.62):0.38,Galago:1.00);", + file = "ex.tre", sep = "\n") > tree.primates <- read.tree("ex.tre") > X <- c(4.09434, 3.61092, 2.37024, 2.02815, -1.46968) > Y <- c(4.74493, 3.33220, 3.36730, 2.89037, 2.30259) > unlink("ex.tre") # delete the file "ex.tre" > m1 <- gls(Y~X, correlation=corBrownian(1, tree.primates)) Warning in Initialize.corPhyl(X[[1]], ...) : Row names in dataframe do not match tree tip names. data taken to be in the same order as in tree. > summary(m1) Generalized least squares fit by REML Model: Y ~ X Data: NULL AIC BIC logLik 17.48072 14.77656 -5.74036 Correlation Structure: corBrownian Formula: ~1 Parameter estimate(s): numeric(0) Coefficients: Value Std.Error t-value p-value (Intercept) 2.5000672 0.7754516 3.224014 0.0484 X 0.4319328 0.2864904 1.507669 0.2288 Correlation: (Intr) X -0.437 Standardized residuals: [1] 0.4187373 -0.6395037 -0.1376075 -0.4269456 0.3844060 attr(,"std") [1] 1.137666 1.137666 1.137666 1.137666 1.137666 attr(,"label") [1] "Standardized residuals" Residual standard error: 1.137666 Degrees of freedom: 5 total; 3 residual > m2 <- gls(Y~X, correlation=corMartins(1, tree.primates)) Warning in Initialize.corPhyl(X[[1]], ...) : Row names in dataframe do not match tree tip names. data taken to be in the same order as in tree. > summary(m2) Generalized least squares fit by REML Model: Y ~ X Data: NULL AIC BIC logLik 17.81880 14.21325 -4.909399 Correlation Structure: corMartins Formula: ~1 Parameter estimate(s): alpha 16.132 Coefficients: Value Std.Error t-value p-value (Intercept) 2.5989364 0.3845062 6.759153 0.0066 X 0.3425282 0.1331771 2.571976 0.0824 Correlation: (Intr) X -0.736 Standardized residuals: [1] 1.27851464 -0.86587008 -0.07481329 -0.69338779 0.35602704 attr(,"std") [1] 0.5815864 0.5815864 0.5815864 0.5815864 0.5815864 attr(,"label") [1] "Standardized residuals" Residual standard error: 0.5815864 Degrees of freedom: 5 total; 3 residual > corMatrix(m2$modelStruct$corStruct) [,1] [,2] [,3] [,4] [,5] [1,] 1.000000e+00 1.141468e-03 1.361702e-07 2.053582e-09 9.72574e-15 [2,] 1.141468e-03 1.000000e+00 1.361702e-07 2.053582e-09 9.72574e-15 [3,] 1.361702e-07 1.361702e-07 1.000000e+00 2.053582e-09 9.72574e-15 [4,] 2.053582e-09 2.053582e-09 2.053582e-09 1.000000e+00 9.72574e-15 [5,] 9.725739e-15 9.725739e-15 9.725739e-15 9.725739e-15 1.00000e+00 > m3 <- gls(Y~X, correlation=corGrafen(1, tree.primates)) Warning in Initialize.corPhyl(X[[1]], ...) : Row names in dataframe do not match tree tip names. data taken to be in the same order as in tree. > summary(m3) Generalized least squares fit by REML Model: Y ~ X Data: NULL AIC BIC logLik 17.81738 14.21183 -4.908688 Correlation Structure: corGrafen Formula: ~1 Parameter estimate(s): rho 0.0002300034 Coefficients: Value Std.Error t-value p-value (Intercept) 2.598961 0.3843951 6.761172 0.0066 X 0.342539 0.1331215 2.573131 0.0823 Correlation: (Intr) X -0.736 Standardized residuals: [1] 1.2787757 -0.8662377 -0.0749226 -0.6936747 0.3561173 attr(,"std") [1] 0.5814135 0.5814135 0.5814135 0.5814135 0.5814135 attr(,"label") [1] "Standardized residuals" Residual standard error: 0.5814135 Degrees of freedom: 5 total; 3 residual > corMatrix(m3$modelStruct$corStruct) [,1] [,2] [,3] [,4] [,5] [1,] 1.000000e+00 3.188016e-04 1.594135e-04 6.616567e-05 0 [2,] 3.188016e-04 1.000000e+00 1.594135e-04 6.616567e-05 0 [3,] 1.594135e-04 1.594135e-04 1.000000e+00 6.616567e-05 0 [4,] 6.616567e-05 6.616567e-05 6.616567e-05 1.000000e+00 0 [5,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 1 > > > > cleanEx(); ..nameEx <- "dist.topo" > > ### * dist.topo > > flush(stderr()); flush(stdout()) > > ### Name: dist.topo > ### Title: Topological Distances Between Two Trees > ### Aliases: dist.topo > ### Keywords: manip > > ### ** Examples > > ta <- rtree(30) > tb <- rtree(30) > dist.topo(ta, ta) # = 0 [1] 0 > dist.topo(ta, tb) # This is unlikely to be 0 ! [1] 46 > > > > cleanEx(); ..nameEx <- "drop.tip" > > ### * drop.tip > > flush(stderr()); flush(stdout()) > > ### Name: drop.tip > ### Title: Remove Tips in a Phylogenetic Tree > ### Aliases: drop.tip > ### Keywords: manip > > ### ** Examples > > 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") > plot(drop.tip(bird.families, tip)) > plot(drop.tip(bird.families, tip, trim.internal = FALSE)) > data(bird.orders) > plot(drop.tip(bird.orders, 6:23, subtree = TRUE), font = 1) > plot(drop.tip(bird.orders, c(1:5, 20:23), subtree = TRUE), font = 1) > > ### Examples of the use of `root.edge' > tr <- read.tree(text = "(A:1,(B:1,(C:1,(D:1,E:1):1):1):1):1;") > drop.tip(tr, c("A", "B"), root.edge = 0) # = (C:1,(D:1,E:1):1); $edge [,1] [,2] [1,] "-1" "1" [2,] "-1" "-2" [3,] "-2" "2" [4,] "-2" "3" $edge.length [1] 1 1 1 1 $tip.label [1] "C" "D" "E" attr(,"class") [1] "phylo" > drop.tip(tr, c("A", "B"), root.edge = 1) # = (C:1,(D:1,E:1):1):1; $edge [,1] [,2] [1,] "-1" "1" [2,] "-1" "-2" [3,] "-2" "2" [4,] "-2" "3" $edge.length [1] 1 1 1 1 $tip.label [1] "C" "D" "E" $root.edge [1] 2 attr(,"class") [1] "phylo" > drop.tip(tr, c("A", "B"), root.edge = 2) # = (C:1,(D:1,E:1):1):2; $edge [,1] [,2] [1,] "-1" "1" [2,] "-1" "-2" [3,] "-2" "2" [4,] "-2" "3" $edge.length [1] 1 1 1 1 $tip.label [1] "C" "D" "E" $root.edge [1] 3 attr(,"class") [1] "phylo" > drop.tip(tr, c("A", "B"), root.edge = 3) # = (C:1,(D:1,E:1):1):3; $edge [,1] [,2] [1,] "-1" "1" [2,] "-1" "-2" [3,] "-2" "2" [4,] "-2" "3" $edge.length [1] 1 1 1 1 $tip.label [1] "C" "D" "E" $root.edge [1] 3 attr(,"class") [1] "phylo" > > > > cleanEx(); ..nameEx <- "hivtree" > > ### * hivtree > > flush(stderr()); flush(stdout()) > > ### Name: hivtree > ### Title: Phylogenetic Tree of 193 HIV-1 Sequences > ### Aliases: hivtree hivtree.newick hivtree.table > ### Keywords: datasets > > ### ** Examples > > library(ape) > > # example tree in NH format (a string) > data("hivtree.newick") > hivtree.newick [1] "(((((((((((A97DCA1EQTB52:0.077166,A97DCA1MBFE185:0.077166):0.008836,(A97DCA1MBS12:0.049821,A97DCA1MBS30:0.049821):0.036182):0.010266,A97DCA1SJDS17:0.096270):0.003116,(A97DCA1KCD9:0.083123,A97DCA1KTB185:0.083123):0.016262):0.002506,A97DCA1KFE58:0.101892):0.046439,(A97DCA1KP18:0.119083,(A97DCA1KP28:0.092297,(A97DCA1KP78:0.090247,A97DCA1MBS63:0.090247):0.002049):0.026786):0.029248):0.003031,(((A97DCA2KP82:0.050058,A97DCA2KP86:0.050058):0.067136,A97DCA2MBCD5:0.117195):0.027195,((((A97DCEQS1:0.101879,A97DCKFE326:0.101879):0.014125,A97DCMBS32:0.116003):0.019791,(A97DCEQS18:0.091575,A97DCKP72:0.091575):0.044219):0.000001,((((((A97DCEQS25:0.078087,A97DCKS34:0.078087):0.036307,A97DCKS47:0.114394):0.006016,(A97DCKMST147:0.103929,(A97DCKMST89:0.091417,A97DCKTB6:0.091417):0.012512):0.016482):0.000086,((((A97DCEQTB44:0.108703,((A97DCKDS85:0.080907,A97DCMBS26:0.080907):0.023577,A97DCKTB79:0.104485):0.004218):0.005284,(A97DCKTB118:0.090239,A97DCKTB132:0.090239):0.023749):0.000575,(A97DCKCC4:0.111547,(((A97DCKP25:0.087787,A97DCKTB7:0.087787):0.018267,A97DCMBS9:0.106055):0.001233,(A97DCKS36:0.094007,A97DCKTB37:0.094007):0.013281):0.004259):0.003015):0.004429,(((A97DCKCD6:0.082435,(A97DCMBFE149:0.069344,A97DCMBFE247:0.069344):0.013092):0.000001,((A97DCKFE198:0.065151,A97DCKP77:0.065151):0.013338,(A97DCKMST52:0.070506,A97DCKS7:0.070506):0.007982):0.003946):0.012315,A97DCKTB36:0.094750):0.024241):0.001504):0.007409,(((A97DCKP36:0.107066,A97DCKTB16:0.107066):0.009046,(A97DCMBS28:0.105021,A97DCMBTB54:0.105021):0.011089):0.011793,(((A97DCKP5:0.113319,(((A97DCMBFE155:0.079795,(A97DCMBFE244:0.057624,A97DCMBFE78:0.057624):0.022171):0.017550,A97DCMBS7:0.097346):0.000001,A97DCMBS341:0.097346):0.015975):0.000815,((A97DCKTB157:0.094386,(A97DCMBP2:0.070132,A97DCMBS4:0.070132):0.024254):0.005564,A97DCMBTB29:0.099950):0.014184):0.007922,A97DCMBDS17:0.122057):0.005848):0.000001):0.000001,((((((A97DCEQS45:0.059728,A97DCEQS49:0.059728):0.021193,A97DCKS56:0.080921):0.007725,A97DCEQTB14:0.088646):0.028870,A97DCKTB20:0.117516):0.000214,A97DCKTB44:0.117729):0.004694,((((((A97DCKCC2:0.021163,A97DCKCC3:0.021163):0.050237,A97DCKTB13:0.071400):0.033783,A97DCKMST140:0.105183):0.004152,(A97DCKMST121:0.101085,((A97DCKP43:0.069726,A97DCKP79:0.069726):0.025382,(A97DCKS55:0.094174,A97DCKTB124:0.094174):0.000933):0.005977):0.008249):0.004330,((A97DCKFE4:0.067768,A97DCKS10:0.067768):0.012439,A97DCKTB48:0.080208):0.033457):0.000001,((A97DCKFE288:0.080093,(A97DCMBFE5:0.063013,A97DCSJFE26:0.063013):0.017081):0.009386,(A97DCKMST50:0.082718,A97DCKS14:0.082718):0.006759):0.024185):0.008758):0.005482):0.007891):0.008594):0.006973):0.029972,(((U97DCKFE267:0.068246,U97DCKTB119:0.068246):0.012677,U97DCMBFE250:0.080923):0.085378,U97DCKMST91:0.166301):0.015033):0.015665,(((E97DCEQS21:0.083436,(E97DCEQS5:0.077774,E97DCKP14:0.077774):0.005662):0.007143,E97DCEQTB60:0.090579):0.044516,(U97DCKFE45:0.089540,U97DCKTB49:0.089540):0.045555):0.061904):0.000001,(((D97DCD1KCD4:0.088821,D97DCD1KMST126:0.088821):0.036417,((((((((((D97DCD1KS2:0.059334,D97DCKP54:0.059334):0.024482,D97DCKP44:0.083817):0.006959,D97DCKTB181:0.090775):0.006373,(D97DCMBS55:0.057578,D97DCMBS56:0.057578):0.039570):0.004811,(D97DCD2KTB23:0.096432,D97DCKMST66:0.096432):0.005529):0.000001,(D97DCKMST30:0.058580,D97DCKP1:0.058580):0.043380):0.002729,((D97DCKS11:0.081263,D97DCKTB27:0.081263):0.013417,(D97DCKTB4:0.094129,D97DCMBS35:0.094129):0.000553):0.010008):0.003638,(D97DCD2KS26:0.104385,D97DCKS15:0.104385):0.003943):0.010453,(D97DCKS39:0.103058,D97DCMBS342:0.103058):0.015722):0.001709,(D97DCKMST144:0.103877,D97DCKS29:0.103877):0.016613):0.004749):0.007051,D97DCKFE53:0.132289):0.064709):0.012112,((((C97DCKCD11:0.130468,((((C97DCKFE372:0.081730,C97DCMBFE92:0.081730):0.023286,((((C97DCKTB110:0.096163,(C97DCMBFE14:0.093774,(C97DCMBFE300:0.089218,(C97DCMBFE34:0.069633,C97DCMBS37:0.069633):0.019585):0.004557):0.002390):0.003304,(C97DCMBFE61:0.087463,C97DCMBTB58:0.087463):0.012005):0.002932,C97DCMBTB11:0.102399):0.002618,C97DCMBTB10:0.105017):0.000001):0.007562,C97DCSJFE59:0.112580):0.011703,((C97DCMBS20:0.065542,C97DCMBTB3:0.065542):0.019087,C97DCMBS33:0.084628):0.039654):0.006187):0.005444,(C97DCMBS80:0.114630,C97DCMBTB13:0.114630):0.021282):0.056420,(((F97DCF1EQS16:0.131458,((F97DCF1KP35:0.068281,((F97DCF1KP40:0.054440,F97DCF1KTB136:0.054440):0.007403,F97DCF1KTB50:0.061843):0.006438):0.027048,((F97DCF1KS50:0.079898,F97DCF1KTB165:0.079898):0.008707,F97DCF1MBFE183:0.088605):0.006724):0.036129):0.033308,(((((K97DCEQTB43:0.092859,K97DCKTB160:0.092859):0.006717,(K97DCKP13:0.083167,K97DCKTB111:0.083167):0.016410):0.014149,K97DCMBFE71:0.113728):0.006534,K97DCKTB1:0.120261):0.010952,U97DCKTB17:0.131213):0.033553):0.013338,U97DCEQS8:0.178107):0.014226):0.012566,(((((((G97DCKCC1:0.123110,(((G97DCKFE181:0.085712,G97DCKTB56:0.085712):0.021918,(G97DCKFE77:0.095370,G97DCKP74:0.095370):0.012260):0.011021,((((G97DCKMST100:0.084544,G97DCKMST85:0.084544):0.009980,G97DCMBTB7:0.094524):0.002757,G97DCKS4:0.097281):0.014591,(G97DCKTB142:0.092882,G97DCKTB18:0.092882):0.018988):0.006781):0.004459):0.005898,(((G97DCKMST10:0.084568,G97DCKS30:0.084568):0.015160,G97DCMBFE91:0.099729):0.008825,G97DCKS27:0.108553):0.020456):0.021182,U97DCKTB22:0.150192):0.016657,U97DCKMST135:0.166847):0.009855,U97DCEQS29:0.176702):0.002466,((((J97DCKFE339:0.095333,J97DCMBTB4:0.095333):0.027238,(((J97DCKS22:0.087519,J97DCMBS41:0.087519):0.016195,J97DCKTB147:0.103713):0.013596,J97DCKTB14:0.117310):0.005262):0.020483,J97DCKS16:0.143056):0.012649,U97DCKMST120:0.155705):0.023463):0.025732,(((H97DCEQTB1:0.130368,(H97DCEQTB80:0.130368,(((H97DCKP63:0.106197,H97DCKTB158:0.106197):0.012343,H97DCKS18:0.118539):0.009461,(H97DCKS42:0.114776,H97DCKTB176:0.114776):0.013225):0.002367):0.000001):0.009940,H97DCKTB62:0.140307):0.006118,(((H97DCKCD2:0.096561,(H97DCKMST43:0.088784,(H97DCKTB140:0.078438,H97DCKTB188:0.078438):0.010346):0.007777):0.006028,H97DCKS38:0.102590):0.010076,((H97DCKS43:0.095068,H97DCKTB32:0.095068):0.014928,H97DCKTB52:0.109996):0.002670):0.033759):0.058474):0.000001):0.004212);" > > # generate file "hivtree.phy" in working directory > cat(hivtree.newick, file = "hivtree.phy", sep = "\n") > tree.hiv <- read.tree("hivtree.phy") # load tree > unlink("hivtree.phy") # delete the file "hivtree.phy" > > plot(tree.hiv) > > # table with list of internode distances > data("hivtree.table") > hivtree.table interval size 1 193 0.021163 2 192 0.028658 3 191 0.000237 4 190 0.004382 5 189 0.003138 6 188 0.000046 7 187 0.000956 8 186 0.000754 9 185 0.000394 10 184 0.002115 11 183 0.001170 12 182 0.002138 13 181 0.000391 14 180 0.002226 15 179 0.000478 16 178 0.000035 17 177 0.001063 18 176 0.000289 19 175 0.000093 20 174 0.000406 21 173 0.000374 22 172 0.000894 23 171 0.005766 24 170 0.000608 25 169 0.000313 26 168 0.000351 27 167 0.000051 28 166 0.001306 29 165 0.000103 30 164 0.000196 31 163 0.000114 32 162 0.000699 33 161 0.000014 34 160 0.000002 35 159 0.000340 36 158 0.000467 37 157 0.000706 38 156 0.000001 39 155 0.000281 40 154 0.000405 41 153 0.000044 42 152 0.000269 43 151 0.000381 44 150 0.000727 45 149 0.000024 46 148 0.000061 47 147 0.001083 48 146 0.000291 49 145 0.001460 50 144 0.000056 51 143 0.000268 52 142 0.000818 53 141 0.000041 54 140 0.000138 55 139 0.000037 56 138 0.000397 57 137 0.000262 58 136 0.000060 59 135 0.000699 60 134 0.000008 61 133 0.000332 62 132 0.000197 63 131 0.000641 64 130 0.000158 65 129 0.000722 66 128 0.000562 67 127 0.000023 68 126 0.000893 69 125 0.000232 70 124 0.000122 71 123 0.000045 72 122 0.000212 73 121 0.000138 74 120 0.000158 75 119 0.000070 76 118 0.000316 77 117 0.000040 78 116 0.000221 79 115 0.000004 80 114 0.000037 81 113 0.000795 82 112 0.000105 83 111 0.000162 84 110 0.000129 85 109 0.000588 86 108 0.000132 87 107 0.000065 88 106 0.000001 89 105 0.002039 90 104 0.000083 91 103 0.000108 92 102 0.000152 93 101 0.000221 94 100 0.001135 95 99 0.000794 96 98 0.000013 97 97 0.000069 98 96 0.000001 99 95 0.000439 100 94 0.000189 101 93 0.000468 102 92 0.000656 103 91 0.000163 104 90 0.000052 105 89 0.000456 106 88 0.000100 107 87 0.000206 108 86 0.000328 109 85 0.000001 110 84 0.000001 111 83 0.000162 112 82 0.000872 113 81 0.000142 114 80 0.000869 115 79 0.000222 116 78 0.000342 117 77 0.000699 118 76 0.000225 119 75 0.000149 120 74 0.000632 121 73 0.000661 122 72 0.001551 123 71 0.000325 124 70 0.000710 125 69 0.000084 126 68 0.000656 127 67 0.000343 128 66 0.000001 129 65 0.000062 130 64 0.000260 131 63 0.000149 132 62 0.000257 133 61 0.000169 134 60 0.000067 135 59 0.000146 136 58 0.001228 137 57 0.000108 138 56 0.001083 139 55 0.000115 140 54 0.000206 141 53 0.000214 142 52 0.000810 143 51 0.000113 144 50 0.000129 145 49 0.000211 146 48 0.000090 147 47 0.001179 148 46 0.000149 149 45 0.000080 150 44 0.000006 151 43 0.001562 152 42 0.000365 153 41 0.000148 154 40 0.000540 155 39 0.001173 156 38 0.000955 157 37 0.002667 158 36 0.000001 159 35 0.000001 160 34 0.000092 161 33 0.001009 162 32 0.001358 163 31 0.000001 164 30 0.000103 165 29 0.000742 166 28 0.000244 167 27 0.000833 168 26 0.002804 169 25 0.000700 170 24 0.000005 171 23 0.000116 172 22 0.004393 173 21 0.002747 174 20 0.001338 175 19 0.002033 176 18 0.001904 177 17 0.001861 178 16 0.001175 179 15 0.004338 180 14 0.009062 181 13 0.001534 182 12 0.000548 183 11 0.009855 184 10 0.001403 185 9 0.001063 186 8 0.002169 187 7 0.010997 188 6 0.004668 189 5 0.000001 190 4 0.007897 191 3 0.000001 192 2 0.004214 > > # construct coalescence intervals > ci <- coalescent.intervals(tree.hiv) # from tree > ci <- coalescent.intervals(hivtree.table$size) #from intervals > ci $lineages [1] 193 192 191 190 189 188 187 186 185 184 183 182 181 180 179 178 177 176 [19] 175 174 173 172 171 170 169 168 167 166 165 164 163 162 161 160 159 158 [37] 157 156 155 154 153 152 151 150 149 148 147 146 145 144 143 142 141 140 [55] 139 138 137 136 135 134 133 132 131 130 129 128 127 126 125 124 123 122 [73] 121 120 119 118 117 116 115 114 113 112 111 110 109 108 107 106 105 104 [91] 103 102 101 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 [109] 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 [127] 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 [145] 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 [163] 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 [181] 13 12 11 10 9 8 7 6 5 4 3 2 $interval.length [1] 0.021163 0.028658 0.000237 0.004382 0.003138 0.000046 0.000956 0.000754 [9] 0.000394 0.002115 0.001170 0.002138 0.000391 0.002226 0.000478 0.000035 [17] 0.001063 0.000289 0.000093 0.000406 0.000374 0.000894 0.005766 0.000608 [25] 0.000313 0.000351 0.000051 0.001306 0.000103 0.000196 0.000114 0.000699 [33] 0.000014 0.000002 0.000340 0.000467 0.000706 0.000001 0.000281 0.000405 [41] 0.000044 0.000269 0.000381 0.000727 0.000024 0.000061 0.001083 0.000291 [49] 0.001460 0.000056 0.000268 0.000818 0.000041 0.000138 0.000037 0.000397 [57] 0.000262 0.000060 0.000699 0.000008 0.000332 0.000197 0.000641 0.000158 [65] 0.000722 0.000562 0.000023 0.000893 0.000232 0.000122 0.000045 0.000212 [73] 0.000138 0.000158 0.000070 0.000316 0.000040 0.000221 0.000004 0.000037 [81] 0.000795 0.000105 0.000162 0.000129 0.000588 0.000132 0.000065 0.000001 [89] 0.002039 0.000083 0.000108 0.000152 0.000221 0.001135 0.000794 0.000013 [97] 0.000069 0.000001 0.000439 0.000189 0.000468 0.000656 0.000163 0.000052 [105] 0.000456 0.000100 0.000206 0.000328 0.000001 0.000001 0.000162 0.000872 [113] 0.000142 0.000869 0.000222 0.000342 0.000699 0.000225 0.000149 0.000632 [121] 0.000661 0.001551 0.000325 0.000710 0.000084 0.000656 0.000343 0.000001 [129] 0.000062 0.000260 0.000149 0.000257 0.000169 0.000067 0.000146 0.001228 [137] 0.000108 0.001083 0.000115 0.000206 0.000214 0.000810 0.000113 0.000129 [145] 0.000211 0.000090 0.001179 0.000149 0.000080 0.000006 0.001562 0.000365 [153] 0.000148 0.000540 0.001173 0.000955 0.002667 0.000001 0.000001 0.000092 [161] 0.001009 0.001358 0.000001 0.000103 0.000742 0.000244 0.000833 0.002804 [169] 0.000700 0.000005 0.000116 0.004393 0.002747 0.001338 0.002033 0.001904 [177] 0.001861 0.001175 0.004338 0.009062 0.001534 0.000548 0.009855 0.001403 [185] 0.001063 0.002169 0.010997 0.004668 0.000001 0.007897 0.000001 0.004214 $interval.count [1] 192 $total.depth [1] 0.209117 attr(,"class") [1] "coalescentIntervals" > > > > cleanEx(); ..nameEx <- "howmanytrees" > > ### * howmanytrees > > flush(stderr()); flush(stdout()) > > ### Name: howmanytrees > ### Title: Calculate Numbers of Phylogenetic Trees > ### Aliases: howmanytrees > ### Keywords: arith math > > ### ** Examples > > ### Table 3.1 in Felsenstein 2004: > for (i in c(1:20, 30, 40, 50)) + cat(paste(i, howmanytrees(i), sep = "\t"), sep ="\n") 1 1 2 1 3 3 4 15 5 105 6 945 7 10395 8 135135 9 2027025 10 34459425 11 654729075 12 13749310575 13 316234143225 14 7905853580625 15 213458046676875 16 6190283353629375 17 191898783962510624 18 6332659870762850304 19 2.216430954767e+20 20 8.2007945326379e+21 30 4.9517976900802e+38 40 1.00984736473787e+57 50 2.75292135328356e+76 > ### Table 3.6: > howmanytrees(8, binary = FALSE, detail = TRUE) 1 2 3 4 5 6 7 1 1 0 0 0 0 0 0 2 1 0 0 0 0 0 0 3 1 3 0 0 0 0 0 4 1 10 15 0 0 0 0 5 1 25 105 105 0 0 0 6 1 56 490 1260 945 0 0 7 1 119 1918 9450 17325 10395 0 8 1 246 6825 56980 190575 270270 135135 > > > > cleanEx(); ..nameEx <- "is.binary.tree" > > ### * is.binary.tree > > flush(stderr()); flush(stdout()) > > ### Name: is.binary.tree > ### Title: Test for Binary Tree > ### Aliases: is.binary.tree > ### Keywords: logic > > ### ** Examples > > library(ape) > > data("hivtree.newick") # example tree in NH format > tree.hiv <- read.tree(text = hivtree.newick) # load tree > > is.binary.tree(tree.hiv) [1] TRUE > > plot(tree.hiv) > > unlink("hivtree.phy") # delete the file "hivtree.phy" > > > > cleanEx(); ..nameEx <- "klastorin" > > ### * klastorin > > flush(stderr()); flush(stdout()) > > ### Name: klastorin > ### Title: Klastorin's (1982) method for classifying genes as suggested by > ### Misawa and Tajima (2000) > ### Aliases: klastorin > ### Keywords: manip > > ### ** Examples > > library(ape) > > # find groups in landplant tree > data("landplants.newick") > tree1 <- read.tree(text = landplants.newick) > plot(tree1, label.offset = 0.001) > klastorin(tree1) [1] 1 2 3 4 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 > tree1$tip.label [1] "Marchantia" "Lycopodium" "Equisetum" "Osmunda" "Asplenium" [6] "Cycas" "Zamia" "Ginkgo" "Pinus" "Podocarpac" [11] "Taxus" "Ephedra" "Welwitsch" "Gnetum" "Nymphaea" [16] "Saururus" "Chloranth" "Araceae" "Palmae" "Oryza" [21] "Acorus" "Calycanth" "Lauraceae" "Magnolia" "Drimys" [26] "Ranunculus" "Nelumbo" "Platanus" "Buxaceae" "Pisum" [31] "Fagus" "Carya" "Ericaceae" "Solanaceae" "Austrobail" [36] "Amborella" > > # find groups in opsin tree > data("opsin.newick") > tree2 <- read.tree(text = opsin.newick) > plot(tree2,label.offset = 0.01) > groups <- klastorin(tree2) > groups [1] 1 2 2 2 2 2 2 2 2 2 2 3 3 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 > tree2$tip.label[groups==1] [1] "K02315" > tree2$tip.label[groups==2] [1] "K03494" "Z22218" "M13305" "M92036" "L11867" "M90075" "U12025" "U12024" [9] "U08131" "M62903" > tree2$tip.label[groups==3] [1] "M92039" "M13299" > tree2$tip.label[groups==4] [1] "M92037" "S66838" "L11864" > tree2$tip.label[groups==5] [1] "M92038" "M92035" "L11865" "L11866" "M63632" "S27231" "L07770" "D00702" [9] "A48191" "L11863" "U12328" "K00506" "A30407" "M55171" "S32696" "K02281" > > > > cleanEx(); ..nameEx <- "landplants" > > ### * landplants > > flush(stderr()); flush(stdout()) > > ### Name: landplants > ### Title: Gene Tree of 36 Landplant rbcL Sequences > ### Aliases: landplants landplants.newick > ### Keywords: datasets > > ### ** Examples > > library(ape) > > # example tree in NH format (a string) > data("landplants.newick") > landplants.newick [1] "(Marchantia:0.033817,(Lycopodium:0.040281,((Equisetum:0.048533,Osmunda:0.033640,Asplenium:0.036526):0.011806,(((Cycas:0.009460,Zamia:0.018847):0.005021,Ginkgo:0.014702,((Pinus:0.021500,(Podocarpac:0.015649,Taxus:0.021081):0.006473):0.002448,(Ephedra:0.029965,(Welwitsch:0.011298,Gnetum:0.014165):0.006883):0.016663):0.006309):0.010855,(Nymphaea:0.016835,(Saururus:0.019902,Chloranth:0.020151,((Araceae:0.020003,(Palmae:0.006005,Oryza:0.031555):0.002933):0.007654,Acorus:0.038488):0.007844,(Calycanth:0.013524,Lauraceae:0.035902):0.004656,((Magnolia:0.015119,Drimys:0.010172):0.005117,(Ranunculus:0.029027,(Nelumbo:0.006180,Platanus:0.002347):0.003958,(Buxaceae:0.013294,(Pisum:0.035675,(Fagus:0.009848,Carya:0.008236):0.001459):0.001994,(Ericaceae:0.019136,Solanaceae:0.041396):0.002619):0.004803):0.006457):0.002918):0.007348,Austrobail:0.019265,Amborella:0.019263):0.003527):0.021625):0.012469):0.019372);" > > # get corresponding phylo object > tree.landplants <- read.tree(text = landplants.newick) > > # plot tree > plot(tree.landplants, label.offset = 0.001) > > > > cleanEx(); ..nameEx <- "ltt.plot" > > ### * ltt.plot > > flush(stderr()); flush(stdout()) > > ### Name: ltt.plot > ### Title: Lineages Through Time Plot > ### Aliases: ltt.plot ltt.lines mltt.plot > ### Keywords: hplot aplot > > ### ** Examples > > data(bird.families) > data(bird.orders) > opar <- par(mfrow = c(2, 1)) > ltt.plot(bird.families) > title("Lineages Through Time Plot of the Bird Families") > ltt.plot(bird.families, log = "y") > title(main = "Lineages Through Time Plot of the Bird Families", + sub = "(with logarithmic transformation of the y-axis)") > par(opar) > ### to plot the tree and the LTT plot together > tmp <- bird.families > tmp$tip.label <- rep("", length(bird.families$tip.label)) > tmp2 <- bird.orders > tmp2$tip.label <- rep("", length(bird.orders$tip.label)) > layout(matrix(1:4, 2, 2)) > plot(tmp) > ltt.plot(bird.families, main = "Bird families") > plot(tmp2) > ltt.plot(bird.orders, main = "Bird orders") > layout(matrix(1)) > mltt.plot(bird.families, bird.orders) > ### Generates 10 random trees with 23 tips: > TR <- list() > for (i in 1:10) TR <- c(TR, list(rtree(23))) > ### Give names to each tree: > names(TR) <- paste("random tree", 1:10) > ### And specify the class of the list so that mltt.plot() > ### does not trash it! > class(TR) <- c("phylo", "multi.tree") > ### (This is non-sense: the trees are not ultrametric!) > mltt.plot(TR) > ### Now rescale the branche lengths to have roughly the > ### same scale than for the avian orders > for (i in 1:10) TR[[i]]$edge.length <- 7 * TR[[i]]$edge.length > ### And now for something (not so) completely different... > ### ... but still non-nense! > ltt.plot(bird.orders, lwd = 2) > for (i in 1:10) ltt.lines(TR[[i]], lty = 2) > legend(-10, 5, lwd = c(2, 1), lty = c(1, 2), bty = "n", + legend = c("Bird orders", "Random trees")) > > > > graphics::par(get("par.postscript", env = .CheckExEnv)) > cleanEx(); ..nameEx <- "mantel.test" > > ### * mantel.test > > flush(stderr()); flush(stdout()) > > ### Name: mantel.test > ### Title: Mantel Test for Similarity of Two Matrices > ### Aliases: mantel.test > ### Keywords: multivariate > > ### ** Examples > > q1 <- matrix(runif(36), nrow = 6) > q2 <- matrix(runif(36), nrow = 6) > mantel.test(q1, q2, graph = TRUE, + main = "Mantel test: a random example with 6 X 6 matrices", + xlab = "z-statistic", ylab = "Density", + sub = "The vertical line shows the observed z-statistic") $z.stat [1] 5.783608 $p [1] 0.501 > > > > cleanEx(); ..nameEx <- "mcmc.popsize" > > ### * mcmc.popsize > > flush(stderr()); flush(stdout()) > > ### Name: mcmc.popsize > ### Title: Reversible Jump MCMC to Infer Demographic History > ### Aliases: mcmc.popsize extract.popsize plot.popsize lines.popsize > ### Keywords: manip > > ### ** Examples > > library(ape) > > # get tree > data("hivtree.newick") # example tree in NH format > tree.hiv <- read.tree(text = hivtree.newick) # load tree > > # run mcmc chain > mcmc.out <- mcmc.popsize(tree.hiv, nstep=100, thinning=1, burn.in=0) # toy run > #mcmc.out <- mcmc.popsize(tree.hiv, nstep=10000, thinning=5, burn.in=500) # remove comments!! > > # make list of population size versus time > popsize <- extract.popsize(mcmc.out) > > # plot and compare with skyline plot > sk <- skyline(tree.hiv) > plot(sk, lwd=1, lty=3, show.years=TRUE, subst.rate=0.0023, present.year = 1997) > lines(popsize, show.years=TRUE, subst.rate=0.0023, present.year = 1997) > > > > cleanEx(); ..nameEx <- "mst" > > ### * mst > > flush(stderr()); flush(stdout()) > > ### Name: mst > ### Title: Minimum Spanning Tree > ### Aliases: mst plot.mst > ### Keywords: multivariate > > ### ** Examples > > library(stats) > n <- 20 > X <- matrix(runif(n * 10), n, 10) > d <- dist(X) > PC <- prcomp(X) > M <- mst(d) > opar <- par() > par(mfcol = c(2, 2)) > plot(M) > plot(M, graph = "nsca") > plot(M, x1 = PC$x[, 1], x2 = PC$x[, 2]) > par(opar) Warning in par(args) : parameter "cin" cannot be set Warning in par(args) : parameter "cra" cannot be set Warning in par(args) : parameter "csi" cannot be set Warning in par(args) : parameter "cxy" cannot be set Warning in par(args) : parameter "din" cannot be set Warning in par(args) : gamma cannot be modified on this device > > > > graphics::par(get("par.postscript", env = .CheckExEnv)) > cleanEx(); ..nameEx <- "multi2di" > > ### * multi2di > > flush(stderr()); flush(stdout()) > > ### Name: multi2di > ### Title: Collapse and Resolve Multichotomies > ### Aliases: multi2di di2multi > ### Keywords: manip > > ### ** Examples > > data(bird.families) > is.binary.tree(bird.families) [1] FALSE > is.binary.tree(multi2di(bird.families)) [1] TRUE > all.equal(di2multi(multi2di(bird.families)), bird.families) [1] TRUE > > > > cleanEx(); ..nameEx <- "nj" > > ### * nj > > flush(stderr()); flush(stdout()) > > ### Name: nj > ### Title: Neighbor-Joining Tree Estimation > ### Aliases: nj > ### Keywords: models > > ### ** Examples > > ### From Saitou and Nei (1987, Table 1): > x <- c(7, 8, 11, 13, 16, 13, 17, 5, 8, 10, 13, + 10, 14, 5, 7, 10, 7, 11, 8, 11, 8, 12, + 5, 6, 10, 9, 13, 8) > M <- matrix(NA, 8, 8) > M[row(M) > col(M)] <- x > M[row(M) < col(M)] <- x > diag(M) <- 0 > rownames(M) <- colnames(M) <- 1:8 > tr <- nj(M) > plot(tr, "u") > ### a less theoretical example > data(woodmouse) > trw <- nj(dist.dna(woodmouse)) > plot(trw) > > > > cleanEx(); ..nameEx <- "nodelabels" > > ### * nodelabels > > flush(stderr()); flush(stdout()) > > ### Name: nodelabels > ### Title: Labelling the Nodes of a Tree > ### Aliases: nodelabels > ### Keywords: aplot > > ### ** Examples > > tr <- read.tree(text = "((Homo,Pan),Gorilla);") > plot(tr) > nodelabels("7.3 Ma", 1, frame = "r", bg = "yellow", adj = 0) > nodelabels("5.4 Ma", 2, frame = "c", bg = "tomato", font = 3) > > data(bird.orders) > plot(bird.orders, use.edge.length = FALSE, font = 1) > bs <- round(runif(22, 90, 100), 0) # some imaginary bootstrap values > bs2 <- round(runif(22, 90, 100), 0) > bs3 <- round(runif(22, 90, 100), 0) > nodelabels(bs, adj = 1.2) > nodelabels(bs2, adj = -0.2, bg = "yellow") > > ### something more classical > plot(bird.orders, use.edge.length = FALSE, font = 1) > nodelabels(bs, adj = -0.2, frame = "n", cex = 0.8) > nodelabels(bs2, adj = c(1.2, 1), frame = "n", cex = 0.8) > nodelabels(bs3, adj = c(1.2, -0.2), frame = "n", cex = 0.8) > > ### the same but we play with the font > plot(bird.orders, use.edge.length = FALSE, font = 1) > nodelabels(bs, adj = -0.2, frame = "n", cex = 0.8, font = 2) > nodelabels(bs2, adj = c(1.2, 1), frame = "n", cex = 0.8, font = 3) > nodelabels(bs3, adj = c(1.2, -0.2), frame = "n", cex = 0.8) > > plot(bird.orders, "u", FALSE, font = 1, lab4ut = "a") > nodelabels(cex = .75, bg = "yellow") > > > > cleanEx(); ..nameEx <- "nuc.div" > > ### * nuc.div > > flush(stderr()); flush(stdout()) > > ### Name: nuc.div > ### Title: Nucleotide Diversity > ### Aliases: nuc.div > ### Keywords: manip univar > > ### ** Examples > > data(woodmouse) > nuc.div(woodmouse) [1] 0.01294610 > nuc.div(woodmouse, TRUE) [1] 0.01294610 0.00333374 > nuc.div(woodmouse, FALSE, TRUE) [1] 0.01316744 > > > > cleanEx(); ..nameEx <- "opsin" > > ### * opsin > > flush(stderr()); flush(stdout()) > > ### Name: opsin > ### Title: Gene Tree of 32 opsin Sequences > ### Aliases: opsin opsin.newick > ### Keywords: datasets > > ### ** Examples > > library(ape) > > # example tree in NH format (a string) > data("opsin.newick") > opsin.newick [1] "(K02315:1.0,(((K03494:0.01102,(Z22218:0.02551,M13305:0.01918):0.02568):0.0529,(M92036:0.10771,(((L11867:0.04787,M90075:0.04443):0.03804,(U12025:0.03546,U12024:0.03083):0.09483):0.01674,(U08131:0.03238,M62903:0.06372):0.03889):0.0225):0.02172):0.30285,((M92039:0.11603,M13299:0.09036):0.34447,((M92037:0.19778,(S66838:0.09894,L11864:0.12521):0.08389):0.18755,(((M92038:0.10886,M92035:0.11081):0.02094,(L11865:0.03836,L11866:0.05773):0.09929):0.02435,(M63632:0.07742,((S27231:0.04088,L07770:0.05902):0.03589,(D00702:0.05681,(((A48191:0.03454,L11863:0.06155):0.04872,U12328:0.09886):0.06074,((K00506:0.01815,A30407:0.01949):0.01219,(M55171:0.02431,(S32696:0.01388,K02281:0.02728):0.0016):0.00518):0.03677):0.00466):0.00811):0.05686):0.07065):0.1661):0.09599):0.1443):0.2164);" > > # get corresponding phylo object > tree.opsin <- read.tree(text = opsin.newick) > > # plot tree > plot(tree.opsin, label.offset = 0.01) > > > > cleanEx(); ..nameEx <- "phymltest" > > ### * phymltest > > flush(stderr()); flush(stdout()) > > ### Name: phymltest > ### Title: Fits a Bunch of Models with PHYML > ### Aliases: phymltest print.phymltest summary.phymltest plot.phymltest > ### Keywords: models > > ### ** Examples > > ### A "fake" example with random likelihood values: it does not > ### make sense, but does not need PHYML and gives you a flavour > ### of how the output looks like: > x <- runif(28, -100, -50) > names(x) <- .phymltest.model > class(x) <- "phymltest" > x nb.free.para loglik AIC JC69 1 -86.72457 175.4491 JC69+I 2 -81.39381 166.7876 JC69+G 2 -71.35733 146.7147 JC69+I+G 3 -54.58961 115.1792 K80 2 -89.91590 183.8318 K80+I 3 -55.08052 116.1610 K80+G 3 -52.76624 111.5325 K80+I+G 4 -66.96011 141.9202 F81 4 -68.54430 145.0886 F81+I 5 -96.91069 203.8214 F81+G 5 -89.70127 189.4025 F81+I+G 6 -91.17216 194.3443 F84 5 -65.64886 141.2977 F84+I 6 -80.79481 173.5896 F84+G 6 -61.50793 135.0159 F84+I+G 7 -75.11504 164.2301 HKY85 5 -64.11907 138.2381 KHY85+I 6 -50.40470 112.8094 HKY85+G 6 -80.99824 173.9965 HKY85+I+G 7 -61.12774 136.2555 TN93 6 -53.26474 118.5295 TN93+I 7 -89.39287 192.7857 TN93+G 7 -67.41631 148.8326 TN93+I+G 8 -93.72225 203.4445 GTR 9 -86.63897 191.2779 GTR+I 10 -80.69430 181.3886 GTR+G 10 -99.33048 218.6610 GTR+I+G 11 -80.88060 183.7612 > summary(x) model1 model2 chi2 df P.val 1 JC69 JC69+I 10.6615236 1 0.0011 2 JC69 JC69+G 30.7344700 1 0.0000 3 JC69 JC69+I+G 64.2699127 2 0.0000 4 JC69 K80 -6.3826732 1 1.0000 5 JC69 K80+I 63.2881022 2 0.0000 6 JC69 K80+G 67.9166605 2 0.0000 7 JC69 K80+I+G 39.5289129 3 0.0000 8 JC69 F81 36.3605381 3 0.0000 9 JC69 F81+I -20.3722393 4 1.0000 10 JC69 F81+G -5.9534088 4 1.0000 11 JC69 F81+I+G -8.8951911 5 1.0000 12 JC69 F84 42.1514184 4 0.0000 13 JC69 F84+I 11.8595055 5 0.0368 14 JC69 F84+G 50.4332757 5 0.0000 15 JC69 F84+I+G 23.2190579 6 0.0007 16 JC69 HKY85 45.2109845 4 0.0000 17 JC69 KHY85+I 72.6397432 5 0.0000 18 JC69 HKY85+G 11.4526516 5 0.0431 19 JC69 HKY85+I+G 51.1936558 6 0.0000 20 JC69 TN93 66.9196568 5 0.0000 21 JC69 TN93+I -5.3366142 6 1.0000 22 JC69 TN93+G 38.6165103 6 0.0000 23 JC69 TN93+I+G -13.9953567 7 1.0000 24 JC69 GTR 0.1712006 8 1.0000 25 JC69 GTR+I 12.0605429 9 0.2099 26 JC69 GTR+G -25.2118330 9 1.0000 27 JC69 GTR+I+G 11.6879294 10 0.3065 28 JC69+I JC69+I+G 53.6083890 1 0.0000 29 JC69+I K80+I 52.6265785 1 0.0000 30 JC69+I K80+I+G 28.8673893 2 0.0000 31 JC69+I F81+I -31.0337629 3 1.0000 32 JC69+I F81+I+G -19.5567147 4 1.0000 33 JC69+I F84+I 1.1979819 4 0.8784 34 JC69+I F84+I+G 12.5575342 5 0.0279 35 JC69+I KHY85+I 61.9782195 4 0.0000 36 JC69+I HKY85+I+G 40.5321322 5 0.0000 37 JC69+I TN93+I -15.9981378 5 1.0000 38 JC69+I TN93+I+G -24.6568804 6 1.0000 39 JC69+I GTR+I 1.3990193 8 0.9943 40 JC69+I GTR+I+G 1.0264057 9 0.9994 41 JC69+G JC69+I+G 33.5354427 1 0.0000 42 JC69+G K80+G 37.1821905 1 0.0000 43 JC69+G K80+I+G 8.7944429 2 0.0123 44 JC69+G F81+G -36.6878788 3 1.0000 45 JC69+G F81+I+G -39.6296611 4 1.0000 46 JC69+G F84+G 19.6988057 4 0.0006 47 JC69+G F84+I+G -7.5154121 5 1.0000 48 JC69+G HKY85+G -19.2818184 4 1.0000 49 JC69+G HKY85+I+G 20.4591858 5 0.0010 50 JC69+G TN93+G 7.8820403 5 0.1629 51 JC69+G TN93+I+G -44.7298267 6 1.0000 52 JC69+G GTR+G -55.9463030 8 1.0000 53 JC69+G GTR+I+G -19.0465406 9 1.0000 54 JC69+I+G K80+I+G -24.7409998 1 1.0000 55 JC69+I+G F81+I+G -73.1651037 3 1.0000 56 JC69+I+G F84+I+G -41.0508548 4 1.0000 57 JC69+I+G HKY85+I+G -13.0762569 4 1.0000 58 JC69+I+G TN93+I+G -78.2652694 5 1.0000 59 JC69+I+G GTR+I+G -52.5819833 8 1.0000 60 K80 K80+I 69.6707754 1 0.0000 61 K80 K80+G 74.2993338 1 0.0000 62 K80 K80+I+G 45.9115861 2 0.0000 63 K80 F84 48.5340916 3 0.0000 64 K80 F84+I 18.2421787 4 0.0011 65 K80 F84+G 56.8159489 4 0.0000 66 K80 F84+I+G 29.6017311 5 0.0000 67 K80 HKY85 51.5936577 3 0.0000 68 K80 KHY85+I 79.0224164 4 0.0000 69 K80 HKY85+G 17.8353248 4 0.0013 70 K80 HKY85+I+G 57.5763290 5 0.0000 71 K80 TN93 73.3023300 4 0.0000 72 K80 TN93+I 1.0460590 5 0.9588 73 K80 TN93+G 44.9991835 5 0.0000 74 K80 TN93+I+G -7.6126835 6 1.0000 75 K80 GTR 6.5538738 7 0.4768 76 K80 GTR+I 18.4432162 8 0.0181 77 K80 GTR+G -18.8291598 8 1.0000 78 K80 GTR+I+G 18.0706026 9 0.0344 79 K80+I K80+I+G -23.7591892 1 1.0000 80 K80+I F84+I -51.4285967 3 1.0000 81 K80+I F84+I+G -40.0690443 4 1.0000 82 K80+I KHY85+I 9.3516410 3 0.0250 83 K80+I HKY85+I+G -12.0944464 4 1.0000 84 K80+I TN93+I -68.6247164 4 1.0000 85 K80+I TN93+I+G -77.2834589 5 1.0000 86 K80+I GTR+I -51.2275592 7 1.0000 87 K80+I GTR+I+G -51.6001728 8 1.0000 88 K80+G K80+I+G -28.3877476 1 1.0000 89 K80+G F84+G -17.4833849 3 1.0000 90 K80+G F84+I+G -44.6976027 4 1.0000 91 K80+G HKY85+G -56.4640089 3 1.0000 92 K80+G HKY85+I+G -16.7230047 4 1.0000 93 K80+G TN93+G -29.3001503 4 1.0000 94 K80+G TN93+I+G -81.9120173 5 1.0000 95 K80+G GTR+G -93.1284935 7 1.0000 96 K80+G GTR+I+G -56.2287312 8 1.0000 97 K80+I+G F84+I+G -16.3098550 3 1.0000 98 K80+I+G HKY85+I+G 11.6647429 3 0.0086 99 K80+I+G TN93+I+G -53.5242697 4 1.0000 100 K80+I+G GTR+I+G -27.8409835 7 1.0000 101 F81 F81+I -56.7327773 1 1.0000 102 F81 F81+G -42.3139469 1 1.0000 103 F81 F81+I+G -45.2557291 2 1.0000 104 F81 F84 5.7908803 1 0.0161 105 F81 F84+I -24.5010326 2 1.0000 106 F81 F84+G 14.0727376 2 0.0009 107 F81 F84+I+G -13.1414802 3 1.0000 108 F81 HKY85 8.8504464 1 0.0029 109 F81 KHY85+I 36.2792051 2 0.0000 110 F81 HKY85+G -24.9078864 2 1.0000 111 F81 HKY85+I+G 14.8331177 3 0.0020 112 F81 TN93 30.5591187 2 0.0000 113 F81 TN93+I -41.6971523 3 1.0000 114 F81 TN93+G 2.2559722 3 0.5210 115 F81 TN93+I+G -50.3558948 4 1.0000 116 F81 GTR -36.1893375 5 1.0000 117 F81 GTR+I -24.2999951 6 1.0000 118 F81 GTR+G -61.5723711 6 1.0000 119 F81 GTR+I+G -24.6726087 7 1.0000 120 F81+I F81+I+G 11.4770482 1 0.0007 121 F81+I F84+I 32.2317448 1 0.0000 122 F81+I F84+I+G 43.5912972 2 0.0000 123 F81+I KHY85+I 93.0119824 1 0.0000 124 F81+I HKY85+I+G 71.5658951 2 0.0000 125 F81+I TN93+I 15.0356251 2 0.0005 126 F81+I TN93+I+G 6.3768825 3 0.0946 127 F81+I GTR+I 32.4327822 5 0.0000 128 F81+I GTR+I+G 32.0601687 6 0.0000 129 F81+G F81+I+G -2.9417822 1 1.0000 130 F81+G F84+G 56.3866845 1 0.0000 131 F81+G F84+I+G 29.1724667 2 0.0000 132 F81+G HKY85+G 17.4060605 1 0.0000 133 F81+G HKY85+I+G 57.1470646 2 0.0000 134 F81+G TN93+G 44.5699191 2 0.0000 135 F81+G TN93+I+G -8.0419479 3 1.0000 136 F81+G GTR+G -19.2584242 5 1.0000 137 F81+G GTR+I+G 17.6413382 6 0.0072 138 F81+I+G F84+I+G 32.1142490 1 0.0000 139 F81+I+G HKY85+I+G 60.0888469 1 0.0000 140 F81+I+G TN93+I+G -5.1001657 2 1.0000 141 F81+I+G GTR+I+G 20.5831205 5 0.0010 142 F84 F84+I -30.2919128 1 1.0000 143 F84 F84+G 8.2818573 1 0.0040 144 F84 F84+I+G -18.9323605 2 1.0000 145 F84 KHY85+I 30.4883248 1 0.0000 146 F84 HKY85+G -30.6987667 1 1.0000 147 F84 HKY85+I+G 9.0422375 2 0.0109 148 F84 TN93 24.7682384 1 0.0000 149 F84 TN93+I -47.4880325 2 1.0000 150 F84 TN93+G -3.5349081 2 1.0000 151 F84 TN93+I+G -56.1467751 3 1.0000 152 F84 GTR -41.9802178 4 1.0000 153 F84 GTR+I -30.0908754 5 1.0000 154 F84 GTR+G -67.3632513 5 1.0000 155 F84 GTR+I+G -30.4634890 6 1.0000 156 F84+I F84+I+G 11.3595524 1 0.0008 157 F84+I HKY85+I+G 39.3341503 1 0.0000 158 F84+I TN93+I -17.1961197 1 1.0000 159 F84+I TN93+I+G -25.8548622 2 1.0000 160 F84+I GTR+I 0.2010374 4 0.9953 161 F84+I GTR+I+G -0.1715761 5 1.0000 162 F84+G F84+I+G -27.2142178 1 1.0000 163 F84+G HKY85+I+G 0.7603801 1 0.3832 164 F84+G TN93+G -11.8167654 1 1.0000 165 F84+G TN93+I+G -64.4286324 2 1.0000 166 F84+G GTR+G -75.6451087 4 1.0000 167 F84+G GTR+I+G -38.7453463 5 1.0000 168 F84+I+G TN93+I+G -37.2144146 1 1.0000 169 F84+I+G GTR+I+G -11.5311285 4 1.0000 170 HKY85 KHY85+I 27.4287587 1 0.0000 171 HKY85 HKY85+G -33.7583329 1 1.0000 172 HKY85 HKY85+I+G 5.9826713 2 0.0502 173 HKY85 TN93 21.7086723 1 0.0000 174 HKY85 TN93+I -50.5475987 2 1.0000 175 HKY85 TN93+G -6.5944742 2 1.0000 176 HKY85 TN93+I+G -59.2063412 3 1.0000 177 HKY85 GTR -45.0397840 4 1.0000 178 HKY85 GTR+I -33.1504416 5 1.0000 179 HKY85 GTR+G -70.4228175 5 1.0000 180 HKY85 GTR+I+G -33.5230551 6 1.0000 181 KHY85+I HKY85+I+G -21.4460874 1 1.0000 182 KHY85+I TN93+I -77.9763574 1 1.0000 183 KHY85+I TN93+I+G -86.6350999 2 1.0000 184 KHY85+I GTR+I -60.5792002 4 1.0000 185 KHY85+I GTR+I+G -60.9518138 5 1.0000 186 HKY85+G HKY85+I+G 39.7410042 1 0.0000 187 HKY85+G TN93+G 27.1638587 1 0.0000 188 HKY85+G TN93+I+G -25.4480083 2 1.0000 189 HKY85+G GTR+G -36.6644846 4 1.0000 190 HKY85+G GTR+I+G 0.2352778 5 0.9987 191 HKY85+I+G TN93+I+G -65.1890125 1 1.0000 192 HKY85+I+G GTR+I+G -39.5057264 4 1.0000 193 TN93 TN93+I -72.2562710 1 1.0000 194 TN93 TN93+G -28.3031465 1 1.0000 195 TN93 TN93+I+G -80.9150135 2 1.0000 196 TN93 GTR -66.7484562 3 1.0000 197 TN93 GTR+I -54.8591139 4 1.0000 198 TN93 GTR+G -92.1314898 4 1.0000 199 TN93 GTR+I+G -55.2317274 5 1.0000 200 TN93+I TN93+I+G -8.6587425 1 1.0000 201 TN93+I GTR+I 17.3971571 3 0.0006 202 TN93+I GTR+I+G 17.0245436 4 0.0019 203 TN93+G TN93+I+G -52.6118670 1 1.0000 204 TN93+G GTR+G -63.8283433 3 1.0000 205 TN93+G GTR+I+G -26.9285809 4 1.0000 206 TN93+I+G GTR+I+G 25.6832861 3 0.0000 207 GTR GTR+I 11.8893424 1 0.0006 208 GTR GTR+G -25.3830336 1 1.0000 209 GTR GTR+I+G 11.5167288 2 0.0032 210 GTR+I GTR+I+G -0.3726135 1 1.0000 211 GTR+G GTR+I+G 36.8997624 1 0.0000 > plot(x) > ### This example needs PHYML, copy/paste or type the > ### following commands if you want to try them, eventually > ### changing setwd() and the options of phymltest() > ## Not run: > ##D setwd("D:/phyml_v2.4/exe") # under Windows > ##D data(woodmouse) > ##D write.dna(woodmouse, "woodmouse.txt") > ##D X <- phymltest("woodmouse.txt") > ##D X > ##D summary(X) > ##D plot(X) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "pic" > > ### * pic > > flush(stderr()); flush(stdout()) > > ### Name: pic > ### Title: Phylogenetically Independent Contrasts > ### Aliases: pic > ### Keywords: regression > > ### ** Examples > > ### The example in Phylip 3.5c (originally from Lynch 1991) > cat("((((Homo:0.21,Pongo:0.21):0.28,", + "Macaca:0.49):0.13,Ateles:0.62):0.38,Galago:1.00);", + file = "ex.tre", sep = "\n") > tree.primates <- read.tree("ex.tre") > 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) > pic.Y <- pic(Y, tree.primates) > cor.test(pic.X, pic.Y) Pearson's product-moment correlation data: pic.X and pic.Y t = -0.8562, 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 > lm(pic.Y ~ pic.X - 1) # both regressions Call: lm(formula = pic.Y ~ pic.X - 1) Coefficients: pic.X 0.4319 > lm(pic.X ~ pic.Y - 1) # through the origin Call: lm(formula = pic.X ~ pic.Y - 1) Coefficients: pic.Y 0.998 > unlink("ex.tre") # delete the file "ex.tre" > > > > cleanEx(); ..nameEx <- "plot.phylo" > > ### * plot.phylo > > flush(stderr()); flush(stdout()) > > ### Name: plot.phylo > ### Title: Plot Phylogenies > ### Aliases: plot.phylo > ### Keywords: hplot > > ### ** Examples > > ### An extract from Sibley and Ahlquist (1990) > cat("(((Strix_aluco:4.2,Asio_otus:4.2):3.1,", + "Athene_noctua:7.3):6.3,Tyto_alba:13.5);", + file = "ex.tre", sep = "\n") > tree.owls <- read.tree("ex.tre") > plot(tree.owls) > unlink("ex.tre") # delete the file "ex.tre" > > ### Show the types of trees. > layout(matrix(1:6, 3, 2)) > plot(tree.owls, main = "With branch lengths") > plot(tree.owls, type = "c") > plot(tree.owls, type = "u") > plot(tree.owls, use.edge.length = FALSE, main = "Without branch lengths") > plot(tree.owls, type = "c", use.edge.length = FALSE) > plot(tree.owls, type = "u", use.edge.length = FALSE) > layout(matrix(1)) > > data(xenarthra) > plot(xenarthra) > ### remove the margins... > plot(xenarthra, no.margin = TRUE) > ### ... and use a smaller font size > plot(xenarthra, no.margin = TRUE, cex = 0.8) > plot(xenarthra, type = "c", no.margin = TRUE, + use.edge.length = FALSE, cex = 0.8) > par(mar = c(5.1, 4.1, 4.1, 2.1)) > > data(bird.orders) > ### using random colours and thichness > plot(bird.orders, + edge.color = sample(colors(), length(bird.orders$edge)/2), + edge.width = sample(1:10, length(bird.orders$edge)/2, replace = TRUE)) > title("Random colours and branch thickness") > ### rainbow colouring... > X <- c("red", "orange", "yellow", "green", "blue", "purple") > plot(bird.orders, + edge.color = sample(X, length(bird.orders$edge)/2, replace = TRUE), + edge.width = sample(1:10, length(bird.orders$edge)/2, replace = TRUE)) > title("Rainbow colouring") > plot(bird.orders, type = "c", use.edge.length = FALSE, + edge.color = sample(X, length(bird.orders$edge)/2, replace = TRUE), + edge.width = rep(5, length(bird.orders$edge)/2)) > segments(rep(0, 6), 6.5:1.5, rep(2, 6), 6.5:1.5, lwd = 5, col = X) > text(rep(2.5, 6), 6.5:1.5, paste(X, "..."), adj = 0) > title("Character mapping is possible...") > plot(bird.orders, "u", font = 1, cex = 0.75) > data(bird.families) > plot(bird.families, "u", lab4ut = "axial", font = 1, cex = 0.5) > plot(bird.families, "r", font = 1, cex = 0.5) > ### cladogram with oblique tip labels > plot(bird.orders, "c", FALSE, direction = "u", srt = -40, x.lim = 25.5) > ### facing trees with different informations... > tr <- bird.orders > tr$tip.label <- rep("", 23) > layout(matrix(1:2, 1, 2), c(5, 4)) > plot(bird.orders, "c", FALSE, adj = 0.5, no.margin = TRUE, label.offset = 0.8, + edge.color = sample(X, length(bird.orders$edge)/2, replace = TRUE), + edge.width = rep(5, length(bird.orders$edge)/2)) > text(7.5, 23, "Facing trees with\ndifferent informations", font = 2) > plot(tr, "p", direction = "l", no.margin = TRUE, + edge.width = sample(1:10, length(bird.orders$edge)/2, replace = TRUE)) > > > > graphics::par(get("par.postscript", env = .CheckExEnv)) > cleanEx(); ..nameEx <- "ratogram" > > ### * ratogram > > flush(stderr()); flush(stdout()) > > ### Name: ratogram > ### Title: Ratogram Computed by Nonparametric Rate Smoothing > ### Aliases: ratogram > ### Keywords: manip > > ### ** Examples > > library(ape) > > # get tree > data("landplants.newick") # example tree in NH format > tree.landplants <- read.tree(text = landplants.newick) > > # plot tree > tree.landplants $edge [,1] [,2] [1,] "-1" "1" [2,] "-1" "-2" [3,] "-2" "2" [4,] "-2" "-3" [5,] "-3" "-4" [6,] "-4" "3" [7,] "-4" "4" [8,] "-4" "5" [9,] "-3" "-5" [10,] "-5" "-6" [11,] "-6" "-7" [12,] "-7" "6" [13,] "-7" "7" [14,] "-6" "8" [15,] "-6" "-8" [16,] "-8" "-9" [17,] "-9" "9" [18,] "-9" "-10" [19,] "-10" "10" [20,] "-10" "11" [21,] "-8" "-11" [22,] "-11" "12" [23,] "-11" "-12" [24,] "-12" "13" [25,] "-12" "14" [26,] "-5" "-13" [27,] "-13" "15" [28,] "-13" "-14" [29,] "-14" "16" [30,] "-14" "17" [31,] "-14" "-15" [32,] "-15" "-16" [33,] "-16" "18" [34,] "-16" "-17" [35,] "-17" "19" [36,] "-17" "20" [37,] "-15" "21" [38,] "-14" "-18" [39,] "-18" "22" [40,] "-18" "23" [41,] "-14" "-19" [42,] "-19" "-20" [43,] "-20" "24" [44,] "-20" "25" [45,] "-19" "-21" [46,] "-21" "26" [47,] "-21" "-22" [48,] "-22" "27" [49,] "-22" "28" [50,] "-21" "-23" [51,] "-23" "29" [52,] "-23" "-24" [53,] "-24" "30" [54,] "-24" "-25" [55,] "-25" "31" [56,] "-25" "32" [57,] "-23" "-26" [58,] "-26" "33" [59,] "-26" "34" [60,] "-13" "35" [61,] "-13" "36" $edge.length [1] 0.033817 0.019372 0.040281 0.012469 0.011806 0.048533 0.033640 0.036526 [9] 0.021625 0.010855 0.005021 0.009460 0.018847 0.014702 0.006309 0.002448 [17] 0.021500 0.006473 0.015649 0.021081 0.016663 0.029965 0.006883 0.011298 [25] 0.014165 0.003527 0.016835 0.007348 0.019902 0.020151 0.007844 0.007654 [33] 0.020003 0.002933 0.006005 0.031555 0.038488 0.004656 0.013524 0.035902 [41] 0.002918 0.005117 0.015119 0.010172 0.006457 0.029027 0.003958 0.006180 [49] 0.002347 0.004803 0.013294 0.001994 0.035675 0.001459 0.009848 0.008236 [57] 0.002619 0.019136 0.041396 0.019265 0.019263 $tip.label [1] "Marchantia" "Lycopodium" "Equisetum" "Osmunda" "Asplenium" [6] "Cycas" "Zamia" "Ginkgo" "Pinus" "Podocarpac" [11] "Taxus" "Ephedra" "Welwitsch" "Gnetum" "Nymphaea" [16] "Saururus" "Chloranth" "Araceae" "Palmae" "Oryza" [21] "Acorus" "Calycanth" "Lauraceae" "Magnolia" "Drimys" [26] "Ranunculus" "Nelumbo" "Platanus" "Buxaceae" "Pisum" [31] "Fagus" "Carya" "Ericaceae" "Solanaceae" "Austrobail" [36] "Amborella" attr(,"class") [1] "phylo" > plot(tree.landplants, label.offset = 0.001) > > # estimate ratogram > rato.plants <- ratogram(tree.landplants) > > # plot and write to file > plot(rato.plants, label.offset = 0.001) > write.tree(rato.plants, file = "ratogram.phy") > > > > cleanEx(); ..nameEx <- "read.GenBank" > > ### * read.GenBank > > flush(stderr()); flush(stdout()) > > ### Name: read.GenBank > ### Title: Read DNA Sequences from GenBank via Internet > ### Aliases: read.GenBank > ### Keywords: IO > > ### ** Examples > > ### This won't work if your computer is not connected > ### to internet!!! > ### > ### Get the 8 sequences of tanagers (Ramphocelus) > ### as used in Paradis (1997) > ref <- c("U15717", "U15718", "U15719", "U15720", + "U15721", "U15722", "U15723", "U15724") > ### Copy/paste or type the following commands if you > ### want to try them. > ## Not run: > ##D Rampho <- read.GenBank(ref) > ##D ### get the species names: > ##D attr(Rampho, "species") > ##D ### build a matrix with the species names and the accession numbers: > ##D cbind(attr(Rampho, "species"), names(Rampho)) > ##D ### print the first sequence > ##D ### (can be done with `Rampho$U15717' as well) > ##D Rampho[[1]] > ##D ### print the first sequence in a cleaner way > ##D cat(Rampho[[1]], "\n", sep = "") > ## End(Not run) > > > > cleanEx(); ..nameEx <- "read.dna" > > ### * read.dna > > flush(stderr()); flush(stdout()) > > ### Name: read.dna > ### Title: Read DNA Sequences in a File > ### Aliases: read.dna > ### Keywords: IO > > ### ** Examples > > ### a small extract from `data(woddmouse)' > cat("3 40", + "No305 NTTCGAAAAACACACCCACTACTAAAANTTATCAGTCACT", + "No304 ATTCGAAAAACACACCCACTACTAAAAATTATCAACCACT", + "No306 ATTCGAAAAACACACCCACTACTAAAAATTATCAATCACT", + file = "exdna.txt", sep = "\n") > ex.dna <- read.dna("exdna.txt", format = "sequential") > str(ex.dna) List of 3 $ No305: chr [1:40] "n" "t" "t" "c" ... $ No304: chr [1:40] "a" "t" "t" "c" ... $ No306: chr [1:40] "a" "t" "t" "c" ... > ex.dna $No305 [1] "n" "t" "t" "c" "g" "a" "a" "a" "a" "a" "c" "a" "c" "a" "c" "c" "c" "a" "c" [20] "t" "a" "c" "t" "a" "a" "a" "a" "n" "t" "t" "a" "t" "c" "a" "g" "t" "c" "a" [39] "c" "t" $No304 [1] "a" "t" "t" "c" "g" "a" "a" "a" "a" "a" "c" "a" "c" "a" "c" "c" "c" "a" "c" [20] "t" "a" "c" "t" "a" "a" "a" "a" "a" "t" "t" "a" "t" "c" "a" "a" "c" "c" "a" [39] "c" "t" $No306 [1] "a" "t" "t" "c" "g" "a" "a" "a" "a" "a" "c" "a" "c" "a" "c" "c" "c" "a" "c" [20] "t" "a" "c" "t" "a" "a" "a" "a" "a" "t" "t" "a" "t" "c" "a" "a" "t" "c" "a" [39] "c" "t" > ### the same data in interleaved format... > cat("3 40", + "No305 NTTCGAAAAA CACACCCACT", + "No304 ATTCGAAAAA CACACCCACT", + "No306 ATTCGAAAAA CACACCCACT", + " ACTAAAANTT ATCAGTCACT", + " ACTAAAAATT ATCAACCACT", + " ACTAAAAATT ATCAATCACT", + file = "exdna.txt", sep = "\n") > ex.dna2 <- read.dna("exdna.txt") > ### ... and in FASTA format > cat("> No305", + "NTTCGAAAAACACACCCACTACTAAAANTTATCAGTCACT", + "> No304", + "ATTCGAAAAACACACCCACTACTAAAAATTATCAACCACT", + "> No306", + "ATTCGAAAAACACACCCACTACTAAAAATTATCAATCACT", + file = "exdna.txt", sep = "\n") > ex.dna3 <- read.dna("exdna.txt", format = "fasta") > ### These are the same! > identical(ex.dna, ex.dna2) [1] TRUE > identical(ex.dna, ex.dna3) [1] TRUE > unlink("exdna.txt") # clean-up > > > > cleanEx(); ..nameEx <- "read.tree" > > ### * read.tree > > flush(stderr()); flush(stdout()) > > ### Name: read.tree > ### Title: Read Tree File in Parenthetic Format > ### Aliases: read.tree > ### Keywords: manip IO > > ### ** Examples > > ### An extract from Sibley and Ahlquist (1990) > cat("(((Strix_aluco:4.2,Asio_otus:4.2):3.1,", + "Athene_noctua:7.3):6.3,Tyto_alba:13.5);", + file = "ex.tre", sep = "\n") > tree.owls <- read.tree("ex.tre") > str(tree.owls) List of 3 $ edge : chr [1:6, 1:2] "-1" "-2" "-3" "-3" ... $ edge.length: num [1:6] 6.3 3.1 4.2 4.2 7.3 13.5 $ tip.label : chr [1:4] "Strix_aluco" "Asio_otus" "Athene_noctua" "Tyto_alba" - attr(*, "class")= chr "phylo" > tree.owls $edge [,1] [,2] [1,] "-1" "-2" [2,] "-2" "-3" [3,] "-3" "1" [4,] "-3" "2" [5,] "-2" "3" [6,] "-1" "4" $edge.length [1] 6.3 3.1 4.2 4.2 7.3 13.5 $tip.label [1] "Strix_aluco" "Asio_otus" "Athene_noctua" "Tyto_alba" attr(,"class") [1] "phylo" > unlink("ex.tre") # delete the file "ex.tre" > ### Only the first three species using the option `text' > TREE <- "((Strix_aluco:4.2,Asio_otus:4.2):3.1,Athene_noctua:7.3);" > TREE [1] "((Strix_aluco:4.2,Asio_otus:4.2):3.1,Athene_noctua:7.3);" > tree.owls.bis <- read.tree(text = TREE) > str(tree.owls.bis) List of 3 $ edge : chr [1:4, 1:2] "-1" "-2" "-2" "-1" ... $ edge.length: num [1:4] 3.1 4.2 4.2 7.3 $ tip.label : chr [1:3] "Strix_aluco" "Asio_otus" "Athene_noctua" - attr(*, "class")= chr "phylo" > tree.owls.bis $edge [,1] [,2] [1,] "-1" "-2" [2,] "-2" "1" [3,] "-2" "2" [4,] "-1" "3" $edge.length [1] 3.1 4.2 4.2 7.3 $tip.label [1] "Strix_aluco" "Asio_otus" "Athene_noctua" attr(,"class") [1] "phylo" > > > > cleanEx(); ..nameEx <- "root" > > ### * root > > flush(stderr()); flush(stdout()) > > ### Name: root > ### Title: Roots Phylogenetic Trees > ### Aliases: root > ### Keywords: manip > > ### ** Examples > > data(bird.orders) > plot(root(bird.orders, 1)) > plot(root(bird.orders, 1:5)) > > > > cleanEx(); ..nameEx <- "rotate" > > ### * rotate > > flush(stderr()); flush(stdout()) > > ### Name: rotate > ### Title: Rotate an Internal Branch of a Tree > ### Aliases: rotate > ### Keywords: manip > > ### ** Examples > > data(bird.orders) > layout(matrix(1:4, 2, 2)) > op <- par(cex = 0.5) > plot(bird.orders) > plot(rotate(bird.orders, 1:5)) > plot(rotate(bird.orders, 6:23)) > plot(rotate(bird.orders, "all")) > layout(matrix(1)) > par(op) > ### The tree hasn't changed: > all.equal(bird.orders, rotate(bird.orders, "all")) [1] TRUE > > > > graphics::par(get("par.postscript", env = .CheckExEnv)) > cleanEx(); ..nameEx <- "rtree" > > ### * rtree > > flush(stderr()); flush(stdout()) > > ### Name: rtree > ### Title: Generates Random Trees > ### Aliases: rtree > ### Keywords: datagen > > ### ** Examples > > layout(matrix(1:9, 3, 3)) > ### Nine random trees: > for (i in 1:9) plot(rtree(20)) > ### Nine random cladograms: > for (i in 1:9) plot(rtree(20, FALSE), type = "c") > layout(matrix(1)) > > > > cleanEx(); ..nameEx <- "seg.sites" > > ### * seg.sites > > flush(stderr()); flush(stdout()) > > ### Name: seg.sites > ### Title: Find Segregating Sites in DNA Sequences > ### Aliases: seg.sites > ### Keywords: univar > > ### ** Examples > > data(woodmouse) > y <- seg.sites(woodmouse) > y [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 [19] 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 [37] 37 38 39 40 41 42 43 44 45 51 54 60 72 96 106 123 188 201 [55] 213 234 237 279 291 297 306 314 316 318 340 342 343 349 365 409 417 430 [73] 435 438 441 456 462 477 510 514 534 540 546 576 591 672 675 684 697 715 [91] 738 788 789 810 837 876 909 920 957 959 960 962 963 964 965 > length(y) [1] 105 > > > > cleanEx(); ..nameEx <- "skyline" > > ### * skyline > > flush(stderr()); flush(stdout()) > > ### Name: skyline > ### Title: Skyline Plot Estimate of Effective Population Size > ### Aliases: skyline skyline.phylo skyline.coalescentIntervals > ### skyline.collapsedIntervals find.skyline.epsilon > ### Keywords: manip > > ### ** Examples > > library(ape) > > # get tree > data("hivtree.newick") # example tree in NH format > tree.hiv <- read.tree(text = hivtree.newick) # load tree > > # corresponding coalescent intervals > ci <- coalescent.intervals(tree.hiv) # from tree > > # collapsed intervals > cl1 <- collapsed.intervals(ci,0) > cl2 <- collapsed.intervals(ci,0.0119) > > #### classic skyline plot #### > sk1 <- skyline(cl1) # from collapsed intervals > sk1 <- skyline(ci) # from coalescent intervals > sk1 <- skyline(tree.hiv) # from tree > sk1 $time [1] 0.021159 0.049820 0.050056 0.054442 0.057578 0.057618 0.058580 0.059334 [9] 0.059724 0.061845 0.063010 0.065148 0.065540 0.067765 0.068244 0.068283 [17] 0.069339 0.069629 0.069723 0.070128 0.070504 0.071396 0.077166 0.077772 [25] 0.078083 0.078437 0.078486 0.079789 0.079900 0.080091 0.080204 0.080905 [33] 0.080917 0.080921 0.081264 0.081730 0.082431 0.082432 0.082718 0.083122 [41] 0.083170 0.083434 0.083816 0.084539 0.084564 0.084627 0.085709 0.086002 [49] 0.087460 0.087517 0.087785 0.088607 0.088642 0.088783 0.088821 0.089214 [57] 0.089477 0.089538 0.090235 0.090246 0.090577 0.090775 0.091412 0.091573 [65] 0.092295 0.092863 0.092879 0.093771 0.094004 0.094128 0.094172 0.094382 [73] 0.094519 0.094681 0.094747 0.095066 0.095105 0.095331 0.095332 0.095367 [81] 0.096161 0.096268 0.096430 0.096560 0.097148 0.097276 0.097339 0.097340 [89] 0.099384 0.099465 0.099580 0.099724 0.099946 0.101082 0.101876 0.101890 [97] 0.101959 0.101960 0.102397 0.102588 0.103058 0.103712 0.103876 0.103924 [105] 0.104384 0.104482 0.104689 0.105015 0.105016 0.105018 0.105179 0.106052 [113] 0.106193 0.107061 0.107285 0.107627 0.108327 0.108549 0.108700 0.109331 [121] 0.109994 0.111544 0.111867 0.112578 0.112664 0.113315 0.113661 0.113662 [129] 0.113729 0.113984 0.114130 0.114390 0.114559 0.114630 0.114772 0.116001 [137] 0.116107 0.117192 0.117308 0.117512 0.117726 0.118536 0.118648 0.118780 [145] 0.118988 0.119081 0.120263 0.120406 0.120489 0.120492 0.122052 0.122420 [153] 0.122570 0.123107 0.124281 0.125238 0.127900 0.127901 0.127902 0.127997 [161] 0.129005 0.130364 0.130365 0.130468 0.131215 0.131460 0.132289 0.135093 [169] 0.135792 0.135793 0.135912 0.140305 0.143053 0.144387 0.146423 0.148329 [177] 0.150187 0.151360 0.155702 0.164768 0.166299 0.166844 0.176699 0.178106 [185] 0.179165 0.181332 0.192332 0.196997 0.196998 0.204897 0.204898 0.209110 $interval.length [1] 0.021159 0.028661 0.000236 0.004386 0.003136 0.000040 0.000962 0.000754 [9] 0.000390 0.002121 0.001165 0.002138 0.000392 0.002225 0.000479 0.000039 [17] 0.001056 0.000290 0.000094 0.000405 0.000376 0.000892 0.005770 0.000606 [25] 0.000311 0.000354 0.000049 0.001303 0.000111 0.000191 0.000113 0.000701 [33] 0.000012 0.000004 0.000343 0.000466 0.000701 0.000001 0.000286 0.000404 [41] 0.000048 0.000264 0.000382 0.000723 0.000025 0.000063 0.001082 0.000293 [49] 0.001458 0.000057 0.000268 0.000822 0.000035 0.000141 0.000038 0.000393 [57] 0.000263 0.000061 0.000697 0.000011 0.000331 0.000198 0.000637 0.000161 [65] 0.000722 0.000568 0.000016 0.000892 0.000233 0.000124 0.000044 0.000210 [73] 0.000137 0.000162 0.000066 0.000319 0.000039 0.000226 0.000001 0.000035 [81] 0.000794 0.000107 0.000162 0.000130 0.000588 0.000128 0.000063 0.000001 [89] 0.002044 0.000081 0.000115 0.000144 0.000222 0.001136 0.000794 0.000014 [97] 0.000069 0.000001 0.000437 0.000191 0.000470 0.000654 0.000164 0.000048 [105] 0.000460 0.000098 0.000207 0.000326 0.000001 0.000002 0.000161 0.000873 [113] 0.000141 0.000868 0.000224 0.000342 0.000700 0.000222 0.000151 0.000631 [121] 0.000663 0.001550 0.000323 0.000711 0.000086 0.000651 0.000346 0.000001 [129] 0.000067 0.000255 0.000146 0.000260 0.000169 0.000071 0.000142 0.001229 [137] 0.000106 0.001085 0.000116 0.000204 0.000214 0.000810 0.000112 0.000132 [145] 0.000208 0.000093 0.001182 0.000143 0.000083 0.000003 0.001560 0.000368 [153] 0.000150 0.000537 0.001174 0.000957 0.002662 0.000001 0.000001 0.000095 [161] 0.001008 0.001359 0.000001 0.000103 0.000747 0.000245 0.000829 0.002804 [169] 0.000699 0.000001 0.000119 0.004393 0.002748 0.001334 0.002036 0.001906 [177] 0.001858 0.001173 0.004342 0.009066 0.001531 0.000545 0.009855 0.001407 [185] 0.001059 0.002167 0.011000 0.004665 0.000001 0.007899 0.000001 0.004212 $population.size [1] 392.033952 525.528096 4.282220 78.750630 55.714176 0.703120 [7] 16.730142 12.972570 6.637800 35.709156 19.400745 35.214998 [13] 6.385680 35.844750 7.630949 0.614367 16.448256 4.466000 [19] 1.431150 6.095655 5.594128 13.117752 83.866950 8.705190 [25] 4.414956 4.965912 0.679189 17.844585 1.501830 2.552906 [31] 1.491939 9.141741 0.154560 0.050880 4.308423 5.779798 [37] 8.584446 0.012090 3.413410 4.759524 0.558144 3.029664 [43] 4.326150 8.079525 0.275650 0.685314 11.610942 3.101405 [49] 15.221520 0.586872 2.721004 8.229042 0.345450 1.371930 [55] 0.364458 3.715029 2.450108 0.559980 6.304365 0.098021 [61] 2.905518 1.711908 5.424055 1.349985 5.960832 4.616704 [67] 0.128016 7.024500 1.805750 0.945624 0.330132 1.550010 [73] 0.994620 1.156680 0.463386 2.202057 0.264654 1.507420 [79] 0.006555 0.225435 5.024432 0.665112 0.989010 0.779350 [85] 3.460968 0.739584 0.357273 0.005565 11.160240 0.433836 [91] 0.604095 0.741744 1.121100 5.623200 3.851694 0.066542 [97] 0.321264 0.004560 1.951205 0.834861 2.010660 2.737644 [103] 0.671580 0.192240 1.801360 0.375144 0.774387 1.191530 [109] 0.003570 0.006972 0.547883 2.899233 0.456840 2.742880 [115] 0.690144 1.027026 2.048200 0.632700 0.419025 1.704331 [121] 1.742364 3.961800 0.802655 1.717065 0.201756 1.482978 [127] 0.765006 0.002145 0.139360 0.514080 0.285138 0.491660 [133] 0.309270 0.125670 0.242962 2.031537 0.169176 1.670900 [139] 0.172260 0.291924 0.294892 1.074060 0.142800 0.161700 [145] 0.244608 0.104904 1.277742 0.148005 0.082170 0.002838 [151] 1.408680 0.316848 0.123000 0.418860 0.869934 0.672771 [157] 1.772892 0.000630 0.000595 0.053295 0.532224 0.674064 [163] 0.000465 0.044805 0.303282 0.092610 0.290979 0.911300 [169] 0.209700 0.000276 0.030107 1.014783 0.577080 0.253460 [175] 0.348156 0.291618 0.252688 0.140760 0.455910 0.825006 [181] 0.119418 0.035970 0.542025 0.063315 0.038124 0.060676 [187] 0.231000 0.069975 0.000010 0.047394 0.000003 0.004212 $parameter.count [1] 192 $epsilon [1] 0 $logL [1] 1408.966 $logL.AICc [1] NA attr(,"class") [1] "skyline" > > plot(skyline(tree.hiv)) > skylineplot(tree.hiv) # shortcut > > plot(sk1, show.years=TRUE, subst.rate=0.0023, present.year = 1997) > > #### generalized skyline plot #### > > sk2 <- skyline(cl2) # from collapsed intervals > sk2 <- skyline(ci, 0.0119) # from coalescent intervals > sk2 <- skyline(tree.hiv, 0.0119) # from tree > sk2 $time [1] 0.021159 0.049820 0.061845 0.077166 0.089214 0.101876 0.113984 0.127900 [9] 0.140305 0.155702 0.176699 0.192332 0.209110 $interval.length [1] 0.021159 0.028661 0.012025 0.015321 0.012048 0.012662 0.012108 0.013916 [9] 0.012405 0.015397 0.020997 0.015633 0.016778 $population.size [1] 392.03395200 525.52809600 26.43747675 18.16241385 4.32071145 [6] 2.19342354 1.06974257 0.55211856 0.27727433 0.33138171 [11] 0.38060475 0.09827875 0.02431880 $parameter.count [1] 13 $epsilon [1] 0.0119 $logL [1] 1239.478 $logL.AICc [1] 1225.456 attr(,"class") [1] "skyline" > > plot(sk2) > > # classic and generalized skyline plot together in one plot > plot(sk1, show.years=TRUE, subst.rate=0.0023, present.year = 1997, col=c(grey(.8),1)) > lines(sk2, show.years=TRUE, subst.rate=0.0023, present.year = 1997) > legend(.15,500, c("classic", "generalized"), col=c(grey(.8),1),lty=1) > > # find optimal epsilon parameter using AICc criterion > find.skyline.epsilon(ci) Searching for the optimal epsilon... epsilon = 0.01191927 [1] 0.01191927 > > sk3 <- skyline(ci, -1) # negative epsilon also triggers estimation of epsilon Searching for the optimal epsilon... epsilon = 0.01191927 > sk3$epsilon [1] 0.01191927 > > > > cleanEx(); ..nameEx <- "skylineplot" > > ### * skylineplot > > flush(stderr()); flush(stdout()) > > ### Name: skylineplot > ### Title: Drawing Skyline Plot Graphs > ### Aliases: skylineplot plot.skyline lines.skyline skylineplot.deluxe > ### Keywords: hplot > > ### ** Examples > > library(ape) > > # get tree > data("hivtree.newick") # example tree in NH format > tree.hiv <- read.tree(text = hivtree.newick) # load tree > > #### classic skyline plot > skylineplot(tree.hiv) # shortcut > > #### plot classic and generalized skyline plots and estimate epsilon > sk.opt <- skylineplot.deluxe(tree.hiv) Searching for the optimal epsilon... epsilon = 0.01191927 > sk.opt$epsilon [1] 0.01191927 > > #### classic and generalized skyline plot #### > sk1 <- skyline(tree.hiv) > sk2 <- skyline(tree.hiv, 0.0119) > > # use years rather than substitutions as unit for the time axis > plot(sk1, show.years=TRUE, subst.rate=0.0023, present.year = 1997, col=c(grey(.8),1)) > lines(sk2, show.years=TRUE, subst.rate=0.0023, present.year = 1997) > legend(.15,500, c("classic", "generalized"), col=c(grey(.8),1),lty=1) > > #### various skyline plots for different epsilons > layout(mat= matrix(1:6,2,3,byrow=TRUE)) > ci <- coalescent.intervals(tree.hiv) > plot(skyline(ci, 0.0));title(main="0.0") > plot(skyline(ci, 0.007));title(main="0.007") > plot(skyline(ci, 0.0119),col=4);title(main="0.0119") > plot(skyline(ci, 0.02));title(main="0.02") > plot(skyline(ci, 0.05));title(main="0.05") > plot(skyline(ci, 0.1));title(main="0.1") > layout(mat= matrix(1:1,1,1,byrow=TRUE)) > > > > cleanEx(); ..nameEx <- "summary.phylo" > > ### * summary.phylo > > flush(stderr()); flush(stdout()) > > ### Name: summary.phylo > ### Title: Print Summary of a Phylogeny > ### Aliases: summary.phylo > ### Keywords: manip > > ### ** Examples > > data(bird.families) > summary(bird.families) Phylogenetic tree: bird.families 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. > > > > cleanEx(); ..nameEx <- "theta.s" > > ### * theta.s > > flush(stderr()); flush(stdout()) > > ### Name: theta.s > ### Title: Population Parameter THETA using Segregating Sites in DNA > ### Sequences > ### Aliases: theta.s > ### Keywords: manip univar > > ### ** Examples > > data(woodmouse) > y <- seg.sites(woodmouse) > s <- length(y) > n <- length(woodmouse[[1]]) > theta.s(s, n) [1] 14.09618 > theta.s(s, n, variance = TRUE) [1] 14.096182 7.555655 > > > > cleanEx(); ..nameEx <- "varcomp" > > ### * varcomp > > flush(stderr()); flush(stdout()) > > ### Name: varcomp > ### Title: Compute Variance Component Estimates > ### Aliases: varcomp > ### Keywords: regression dplot > > ### ** Examples > > data(carnivora) > m <- lme(log10(SW) ~ 1, random = ~ 1|Order/SuperFamily/Family/Genus, data=carnivora) > v <- varcomp(m, TRUE, TRUE) > plot(v) > > > > cleanEx(); ..nameEx <- "woodmouse" > > ### * woodmouse > > flush(stderr()); flush(stdout()) > > ### Name: woodmouse > ### Title: Cytochrome b Gene Sequences of Woodmice > ### Aliases: woodmouse > ### Keywords: datasets > > ### ** Examples > > data(woodmouse) > str(woodmouse) List of 15 $ No305 : chr [1:965] "n" "t" "t" "c" ... $ No304 : chr [1:965] "a" "t" "t" "c" ... $ No306 : chr [1:965] "a" "t" "t" "c" ... $ No0906S: chr [1:965] "a" "t" "t" "c" ... $ No0908S: chr [1:965] "a" "t" "t" "c" ... $ No0909S: chr [1:965] "a" "t" "t" "c" ... $ No0910S: chr [1:965] "a" "t" "t" "c" ... $ No0912S: chr [1:965] "a" "t" "t" "c" ... $ No0913S: chr [1:965] "a" "t" "t" "c" ... $ No1103S: chr [1:965] "a" "t" "t" "c" ... $ No1007S: chr [1:965] "a" "t" "t" "c" ... $ No1114S: chr [1:965] "n" "n" "n" "n" ... $ No1202S: chr [1:965] "a" "t" "t" "c" ... $ No1206S: chr [1:965] "a" "t" "t" "c" ... $ No1208S: chr [1:965] "n" "n" "n" "c" ... > > > > cleanEx(); ..nameEx <- "xenarthra" > > ### * xenarthra > > flush(stderr()); flush(stdout()) > > ### Name: xenarthra > ### Title: Molecular Phylogeny of Living Xenarthrans > ### Aliases: xenarthra > ### Keywords: datasets > > ### ** Examples > > data(xenarthra) > ## Not run: par(ask = TRUE) > plot(xenarthra) > ### remove the margins... > plot(xenarthra, no.margin = TRUE) > ### ... and use a smaller font size > plot(xenarthra, no.margin = TRUE, cex = 0.8) > > > > cleanEx(); ..nameEx <- "yule.cov" > > ### * yule.cov > > flush(stderr()); flush(stdout()) > > ### Name: yule.cov > ### Title: Fits the Yule Model With Covariates > ### Aliases: yule.cov > ### Keywords: models > > ### ** Examples > > ### a simple example with some random data > data(bird.orders) > x <- rnorm(45) # the tree has 23 tips and 22 nodes > ### the standard-error for x should be as large as > ### the estimated parameter > yule.cov(bird.orders, ~ x) ---- Yule Model With Covariates ---- Phylogenetic tree: bird.orders Number of tips: 23 Number of nodes: 22 Deviance: 92.71057 Log-likelihood: -46.35529 Parameter estimates: Estimate StdErr (Intercept) -3.1990487 0.1606267 x 0.1144170 0.2066675 > ### compare with the simple Yule model, eventually > ### with a likelihood ratio test > yule(bird.orders) $lambda [1] 0.03909886 $se [1] 0.008532072 $loglik [1] -46.43266 attr(,"class") [1] "yule" > ### another example with a tree that has a multichotomy > ### but we cannot run yule() because of this! > data(bird.families) > y <- rnorm(272) # 137 tips + 135 nodes > yule.cov(bird.families, ~ y) Warning: NA/Inf replaced by maximum positive value ---- Yule Model With Covariates ---- Phylogenetic tree: bird.families Number of tips: 137 Number of nodes: 135 Deviance: 203.7182 Log-likelihood: -101.8591 Parameter estimates: Estimate StdErr (Intercept) -2.63925612 0.06548840 y 0.03074306 0.06801149 > > > > cleanEx(); ..nameEx <- "zoom" > > ### * zoom > > flush(stderr()); flush(stdout()) > > ### Name: zoom > ### Title: Zoom on a Portion of a Phylogeny > ### Aliases: zoom > ### Keywords: hplot > > ### ** Examples > > ## Not run: > ##D data(chiroptera) > ##D zoom(chiroptera, 1:20, subtree = TRUE) > ##D zoom(chiroptera, grep("Plecotus", chiroptera$tip.label)) > ##D zoom(chiroptera, list(grep("Plecotus", chiroptera$tip.label), > ##D grep("Pteropus", chiroptera$tip.label))) > ## End(Not run) > > > > ### *