[med-svn] [r-cran-ape] 01/02: Imported Upstream version 3.1-3

Dylan Aïssi bob.dybian-guest at moszumanska.debian.org
Sat Jul 12 15:09:35 UTC 2014


This is an automated email from the git hooks/post-receive script.

bob.dybian-guest pushed a commit to branch master
in repository r-cran-ape.

commit 5b373e525f3622bea15dda585fe0677cf4dbf8f0
Author: Dylan Aïssi <bob.dybian at gmail.com>
Date:   Sat Jul 12 17:08:57 2014 +0200

    Imported Upstream version 3.1-3
---
 DESCRIPTION         |  82 +++++++++++++++++++++++++++-------------------------
 MD5                 |  30 ++++++++++---------
 NEWS                |  27 +++++++++++++++++
 R/nodelabels.R      |   8 ++---
 R/phymltest.R       |  13 +++++----
 R/read.GenBank.R    |   4 +--
 R/read.dna.R        |   9 ++++--
 R/root.R            |  12 ++++++--
 R/rotate.R          |  41 ++++++++++----------------
 R/rtt.R             |  59 +++++++++++++++++++++++++++++++++++++
 R/which.edge.R      |  47 ++++++++++--------------------
 inst/doc/MoranI.pdf | Bin 256525 -> 256305 bytes
 man/dist.dna.Rd     |   2 +-
 man/image.DNAbin.Rd |   1 +
 man/nodelabels.Rd   |   7 +++++
 man/rtt.Rd          |  74 +++++++++++++++++++++++++++++++++++++++++++++++
 man/which.edge.Rd   |  10 +++----
 17 files changed, 292 insertions(+), 134 deletions(-)

diff --git a/DESCRIPTION b/DESCRIPTION
index cfa009d..bfaaa88 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,26 +1,27 @@
 Package: ape
-Version: 3.1-2
-Date: 2014-05-27
+Version: 3.1-3
+Date: 2014-07-12
 Title: Analyses of Phylogenetics and Evolution
 Authors at R: c(person("Emmanuel", "Paradis", role = c("aut", "cre", "cph"), email = "Emmanuel.Paradis at ird.fr"),
-  person("Ben", "Bolker", role = "aut"),
-  person("Julien", "Claude", role = "aut"),
-  person("Hoa Sien", "Cuong", role = "aut"),
-  person("Richard", "Desper", role = "aut"),
-  person("Benoit", "Durand", role = "aut"),
-  person("Julien", "Dutheil", role = "aut"),
-  person("Olivier", "Gascuel", role = "aut"),
-  person("Christoph", "Heibl", role = "aut"),
-  person("Daniel", "Lawson", role = "aut"),
-  person("Vincent", "Lefort", role = "aut"),
-  person("Pierre", "Legendre", role = "aut"),
-  person("Jim", "Lemon", role = "aut"),
-  person("Johan", "Nylander", role = "aut"),
-  person("Rainer", "Opgen-Rhein", role = "aut"),
-  person("Andrei-Alin", "Popescu", role = "aut"),
-  person("Klaus", "Schliep", role = "aut"),
-  person("Korbinian", "Strimmer", role = "aut"),
-  person("Damien", "de Vienne", role = "aut"))
+  person("Ben", "Bolker", role = c("aut", "cph")),
+  person("Julien", "Claude", role = c("aut", "cph")),
+  person("Hoa Sien", "Cuong", role = c("aut", "cph")),
+  person("Richard", "Desper", role = c("aut", "cph")),
+  person("Benoit", "Durand", role = c("aut", "cph")),
+  person("Julien", "Dutheil", role = c("aut", "cph")),
+  person("Olivier", "Gascuel", role = c("aut", "cph")),
+  person("Christoph", "Heibl", role = c("aut", "cph")),
+  person("Daniel", "Lawson", role = c("aut", "cph")),
+  person("Vincent", "Lefort", role = c("aut", "cph")),
+  person("Pierre", "Legendre", role = c("aut", "cph")),
+  person("Jim", "Lemon", role = c("aut", "cph")),
+  person("Rosemary", "McCloskey", role = c("aut", "cph")),
+  person("Johan", "Nylander", role = c("aut", "cph")),
+  person("Rainer", "Opgen-Rhein", role = c("aut", "cph")),
+  person("Andrei-Alin", "Popescu", role = c("aut", "cph")),
+  person("Klaus", "Schliep", role = c("aut", "cph")),
+  person("Korbinian", "Strimmer", role = c("aut", "cph")),
+  person("Damien", "de Vienne", role = c("aut", "cph")))
 Depends: R (>= 3.0.0)
 Suggests: gee, expm
 Imports: nlme, lattice, graphics, stats, tools, utils
@@ -28,27 +29,28 @@ ZipData: no
 Description: ape provides functions for reading, writing, plotting, and manipulating phylogenetic trees, analyses of comparative data in a phylogenetic framework, ancestral character analyses, analyses of diversification and macroevolution, computing distances from allelic and nucleotide data, reading and writing nucleotide sequences, and several tools such as Mantel's test, generalized skyline plots, graphical exploration of phylogenetic data (alex, trex, kronoviz), estimation of absolu [...]
 License: GPL (>= 2)
 URL: http://ape-package.ird.fr/
-Packaged: 2014-05-27 09:44:56 UTC; paradis
+Packaged: 2014-07-12 12:25:07 UTC; paradis
 Author: Emmanuel Paradis [aut, cre, cph],
-  Ben Bolker [aut],
-  Julien Claude [aut],
-  Hoa Sien Cuong [aut],
-  Richard Desper [aut],
-  Benoit Durand [aut],
-  Julien Dutheil [aut],
-  Olivier Gascuel [aut],
-  Christoph Heibl [aut],
-  Daniel Lawson [aut],
-  Vincent Lefort [aut],
-  Pierre Legendre [aut],
-  Jim Lemon [aut],
-  Johan Nylander [aut],
-  Rainer Opgen-Rhein [aut],
-  Andrei-Alin Popescu [aut],
-  Klaus Schliep [aut],
-  Korbinian Strimmer [aut],
-  Damien de Vienne [aut]
+  Ben Bolker [aut, cph],
+  Julien Claude [aut, cph],
+  Hoa Sien Cuong [aut, cph],
+  Richard Desper [aut, cph],
+  Benoit Durand [aut, cph],
+  Julien Dutheil [aut, cph],
+  Olivier Gascuel [aut, cph],
+  Christoph Heibl [aut, cph],
+  Daniel Lawson [aut, cph],
+  Vincent Lefort [aut, cph],
+  Pierre Legendre [aut, cph],
+  Jim Lemon [aut, cph],
+  Rosemary McCloskey [aut, cph],
+  Johan Nylander [aut, cph],
+  Rainer Opgen-Rhein [aut, cph],
+  Andrei-Alin Popescu [aut, cph],
+  Klaus Schliep [aut, cph],
+  Korbinian Strimmer [aut, cph],
+  Damien de Vienne [aut, cph]
 Maintainer: Emmanuel Paradis <Emmanuel.Paradis at ird.fr>
 NeedsCompilation: yes
 Repository: CRAN
-Date/Publication: 2014-05-27 12:44:48
+Date/Publication: 2014-07-12 15:02:57
diff --git a/MD5 b/MD5
index 3fc0633..8f284c3 100644
--- a/MD5
+++ b/MD5
@@ -1,7 +1,7 @@
 eb723b61539feef013de476e68b5c50a *COPYING
-0886cb4ddb9055dd86d406fd8d35c226 *DESCRIPTION
+2bfd1bb4d4d1c00d776da77748e929d7 *DESCRIPTION
 1434ba4e31040404e8b049f75a705af5 *NAMESPACE
-c12ba812ce8e6465319ef3c40499dee8 *NEWS
+dbdd47f2098b6439b7d12e841b6bd14b *NEWS
 0c7bc9101516fd26fb3ddbedbe25b6a3 *R/CADM.global.R
 e042efca1d8a00d4178204f5f481b64d *R/CADM.post.R
 5fd68920346c5aca7e7695fd9dbc1c3c *R/CDF.birth.death.R
@@ -71,11 +71,11 @@ baf380fc68864e9a4c3d07f5158d3722 *R/multi2di.R
 0850fdd19c01d37ac632fc308632a463 *R/mvr.R
 282308c27ac1e78e330711d635d2e572 *R/nj.R
 e3f22d0f260c43be87a17b0ab091e2bb *R/njs.R
-1413a267f2ca08adce203e2ba44d74ad *R/nodelabels.R
+080c82acd4a90a88a1bbd098ebfe6b60 *R/nodelabels.R
 7425d422f7ca9b3966bb65a4e4336bbe *R/parafit.R
 fc0260f9e8e17fc1446117580bbc93cc *R/pcoa.R
 4999c85e82105ded85a214204321c3d1 *R/phydataplot.R
-2730f72b8b261609ae8a57a7f0c0bb8b *R/phymltest.R
+f71b4d1a0cba643e7c5cbc6f01c0e9a1 *R/phymltest.R
 61d1360195bf4d5e6e2d8c30de335dc8 *R/pic.R
 57478ff610b5d0d3010c12ad17d968f8 *R/plot.phylo.R
 e579ec65c808c29e1ecaae1501784b37 *R/plot.popsize.R
@@ -83,16 +83,17 @@ e579ec65c808c29e1ecaae1501784b37 *R/plot.popsize.R
 1e2485437566ca9af99d93b4580cbbc2 *R/print.lmorigin.R
 d0e8bd41d5acc217fdee3578adcf635b *R/print.parafit.R
 8c401518738b9cda403fa9f0eb382757 *R/rTrait.R
-77eddff87cbbebdf5dc2c2fd81e74961 *R/read.GenBank.R
+1895483cd4f45095860092900e0672c8 *R/read.GenBank.R
 b13dfb8f455b1c9e74a364085f72dbce *R/read.caic.R
-0b661f16611ef934c60f0a003734d471 *R/read.dna.R
+c1fc8ab4715f1d58145f533fbaf776e4 *R/read.dna.R
 fca9cd2c52414a936ab10a522136cf8a *R/read.nexus.R
 13ce7f5c7d1bcb7101469d12651e99c8 *R/read.nexus.data.R
 8aefdf68a66fc5ad148b4d5211a285ed *R/read.tree.R
 b1218f7862a66f566e4f3165f28fe47c *R/reorder.phylo.R
-cda4c985d8f4a51682c387c07bc6761b *R/root.R
-b31509f82422b3db2d2bc035bd3ad561 *R/rotate.R
+a71f335ebf44985121b28bfcf86d698d *R/root.R
+f584366b32e7414c669714ba5b84951b *R/rotate.R
 b7158b84c7ee7d9dcb2e0abeb6005cb0 *R/rtree.R
+01db17803643af9627fbde7dcb34dd8b *R/rtt.R
 cee88a7a00b3a858c18a3299eef49b79 *R/scales.R
 d2e06f8288af941a00c46248b586225a *R/skyline.R
 1f82059f740388b7430b2359e54a147f *R/skylineplot.R
@@ -105,7 +106,7 @@ b5081fca8758fe4458183c3e25e3e661 *R/triangMtd.R
 6e92716e8004feb088d5c093bad3828f *R/unique.multiPhylo.R
 2937379ad9e91e263b7956c264926466 *R/varcomp.R
 d2fef53445996fca1a2fca2d67f8dbb9 *R/vcv.phylo.R
-98260df0d86f094c3c9da02dbe1b27ac *R/which.edge.R
+e96c64f02ab104073d8b889193ae5152 *R/which.edge.R
 aa484437bf64a39b737665b0769e320b *R/write.dna.R
 846c603fdb8bda22e5d3e2c81681221f *R/write.nexus.R
 2ac18a948dfca02a878b4ccf3a07b145 *R/write.nexus.data.R
@@ -136,7 +137,7 @@ e2d1339025ed901009bfed58dc6505ff *data/mat5M3ID.RData
 828290996b613493f96e0fab024beebb *inst/CITATION
 3f54f3775bcf382e25df2a12228894f6 *inst/doc/MoranI.R
 abf2e3e84707634e32f3e7cc6a5ee7ae *inst/doc/MoranI.Rnw
-4dfb14a17dec4621f06dd5981acd5925 *inst/doc/MoranI.pdf
+fdb9f105c8a4991d804fb392ee52a197 *inst/doc/MoranI.pdf
 e6876b193a0df06697c788a8e48cf4bc *man/CADM.global.Rd
 060222d269ef45f0c7df76bb723e7d45 *man/DNAbin.Rd
 8b9bc214e32cde4c6e5970e48ff30c5f *man/Initialize.corPhyl.Rd
@@ -199,7 +200,7 @@ c199605f9d353b303acad4896f9b39a5 *man/cynipids.Rd
 34164e368efd0d5d961fe62e9ede75e8 *man/dbd.Rd
 e5fd45ae77e515b42d180a8c5369987d *man/del.gaps.Rd
 fbcd1d4bcf74e21fc93c195c7af3db98 *man/delta.plot.Rd
-d4dafdb3dcabdd4a984cb2bff4d987ad *man/dist.dna.Rd
+e9a4068c29af95a6c2474192b3e1af1b *man/dist.dna.Rd
 38011e81d28a120d88eead09e62c154a *man/dist.gene.Rd
 a93e4fe0f50b5b8ded1b47cb9c76ec1f *man/dist.topo.Rd
 883eb866baf7f1eb68b52ba5aa123c8e *man/diversi.gof.Rd
@@ -214,7 +215,7 @@ eea313e8ee32597b4cec120d23113642 *man/gammaStat.Rd
 3991fa7864e326579f1ab8b671095e4b *man/hivtree.Rd
 18012643a904f657fc5f5896f3d14054 *man/howmanytrees.Rd
 86c49d080fdffd614d8056021e91cc55 *man/identify.phylo.Rd
-1bfeb64b47a8d7ce253d5c6df6c18fc8 *man/image.DNAbin.Rd
+46c7c675e02d355a25d8c1c02deffcd7 *man/image.DNAbin.Rd
 4bb168908d445690105ad4c00661b93b *man/is.binary.tree.Rd
 80a5a228a43679edf75903590253a875 *man/is.compatible.Rd
 d2de8fd9549ef01a1dddeb726dd77fcf *man/is.monophyletic.Rd
@@ -242,7 +243,7 @@ dcee2d8c67b0a19c27aa3d833f33f83b *man/mst.Rd
 3df9e16b8a09df3f1dba5c4327a635fc *man/nj.Rd
 9ea7d5899a190171de4165e3240de62e *man/njs.Rd
 8f30d041ced38534477c2fac72fb1abf *man/node.depth.Rd
-a617a7e7ceacb8b2fd8a697de08b363c *man/nodelabels.Rd
+ba754eba67181a1c39d417ffd9d23b76 *man/nodelabels.Rd
 4f8b4cf2a725a8001e49390056181bef *man/opsin.Rd
 c2e2f35f4e233265c86b7967ec2d0630 *man/parafit.Rd
 89db814a5fc2e9fa5f0b9f4ad2f0d070 *man/pcoa.Rd
@@ -269,6 +270,7 @@ a3cf7db0d79645f61aa15634b21a5c92 *man/rlineage.Rd
 aa7d8a43e8456fe53480c023b7ef1648 *man/root.Rd
 6b97ea2fd96bf948fca764deab3a6e76 *man/rotate.Rd
 1a7314ee0aa76712737e76162df6cc74 *man/rtree.Rd
+e53b4b3f7e009289c628e16143b3e8b4 *man/rtt.Rd
 2b2faabf81e29f320eff5adde7e6d75d *man/seg.sites.Rd
 ce6f293b22e9b0fd36f38c67b5f40e6e *man/skyline.Rd
 74d4e9d6fc374c26807825795dff1e0e *man/skylineplot.Rd
@@ -287,7 +289,7 @@ dbb269e680caf8c722cf53c9b5ce7ace *man/triangMtd.Rd
 904af4ee107d88d1bd1b57bca4a8d535 *man/vcv.phylo.Rd
 a5d3cbf19df84d0f1e4e3a4650945cbf *man/weight.taxo.Rd
 19d511057993a6335549d8e84f6ef86a *man/where.Rd
-54579df63b905cb394dfabc5fc11843a *man/which.edge.Rd
+ef9658f5343bdcbfc3673c7f936934f5 *man/which.edge.Rd
 f569d0058bc598bb92c42ef99a58f272 *man/woodmouse.Rd
 510a3ad17baa847a3f581e9d1babb534 *man/write.dna.Rd
 b9fe1836be61c56a521386b00021fa67 *man/write.nexus.Rd
diff --git a/NEWS b/NEWS
index 8a73e7b..c6d6468 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,30 @@
+		CHANGES IN APE VERSION 3.1-3
+
+
+NEW FEATURES
+
+    o The new function rtt contributed by Rosemary McCloskey roots a
+      tree with dated tips in the location most compatible with the
+      assumption of a strict molecular clock.
+
+
+BUG FIXES
+
+    o root(, resolve.root = TRUE) did not manage node labels correctly
+      in the case where 'outgroup' was already an outgroup of the tree.
+
+    o read.dna(file, format = "fasta") works (again) with URIs (i.e.,
+      file = "http://..." or "ftp://...").
+
+    o rotate() made R crash if the tree was not in cladewise order.
+
+    o which.edge() did not work correctly for trees not in cladewise
+      order.
+
+    o read.GenBank failed to read older GenBank records.
+
+
+
 		CHANGES IN APE VERSION 3.1-2
 
 
diff --git a/R/nodelabels.R b/R/nodelabels.R
index 4d1aebb..fbb5edd 100644
--- a/R/nodelabels.R
+++ b/R/nodelabels.R
@@ -1,8 +1,8 @@
-## nodelabels.R (2013-09-21)
+## nodelabels.R (2014-06-05)
 
 ##   Labelling Trees
 
-## Copyright 2004-2013 Emmanuel Paradis, 2006 Ben Bolker, and 2006 Jim Lemon
+## Copyright 2004-2014 Emmanuel Paradis, 2006 Ben Bolker, and 2006 Jim Lemon
 
 ## This file is part of the R-package `ape'.
 ## See the file ../COPYING for licensing issues.
@@ -26,12 +26,12 @@ floating.pie.asp <- function(xpos, ypos, x, edges = 200, radius = 1,
     x <- c(0, cumsum(x)/sum(x))
     dx <- diff(x)
     nx <- length(dx)
-    col <- if (is.null(col)) rainbow(nx) else rep(col, length.out = nx) # rep_len(col, nx) was introduced in R 3.0.0 so we avoid it to keep working with older versions of R
+    col <- if (is.null(col)) rainbow(nx) else rep_len(col, nx)
     ## next a fix from Klaus to avoid a "3-o'clock" segment on pies with
     ## only one proportion equal to 1:
     if (length(i <- which(dx == 1))) {
         symbols(xpos, ypos, circles = radius, inches = FALSE, add = TRUE,
-                fg = 1, bg = col[i])
+                fg = par("fg"), bg = col[i]) # suggested by Liam
     } else {
         bc <- 2 * pi * (x[1:nx] + dx/2) + startpos
         for (i in seq_len(nx)) {
diff --git a/R/phymltest.R b/R/phymltest.R
index a87d46d..f98ec0f 100644
--- a/R/phymltest.R
+++ b/R/phymltest.R
@@ -1,8 +1,8 @@
-## phymltest.R (2009-03-29)
+## phymltest.R (2014-06-16)
 
 ##   Fits a Bunch of Models with PhyML
 
-## Copyright 2004-2009 Emmanuel Paradis
+## Copyright 2004-2014 Emmanuel Paradis
 
 ## This file is part of the R-package `ape'.
 ## See the file ../COPYING for licensing issues.
@@ -26,9 +26,10 @@ phymltest <- function(seqfile, format = "interleaved", itree = NULL,
     os <- Sys.info()[1]
     ## default names of PhyML:
     if (is.null(execname)) {
-        if (os == "Linux") execname <- "phyml_3.0.1_linux32"
-        if (os == "Darwin") execname <- "phyml_3.0.1_macintel"
-        if (os == "Windows") execname <- "phyml_3.0.1_win32"
+        execname <- switch(os, "Linux" = {
+            ## PhyML location for Debian and Fedora packages and maybe for other distributions (fix by Dylan A\"issi)
+            if (file.exists("/usr/bin/phyml")) "/usr/bin/phyml" else "phyml_3.0.1_linux32"
+	}, "Darwin" = "phyml_3.0.1_macintel", "Windows" = "phyml_3.0.1_win32")
     }
     if (is.null(execname))
         stop("you must give an executable file name for PHYML")
@@ -87,7 +88,7 @@ summary.phymltest <- function(object, ...)
             m1 <- unlist(strsplit(names(object)[i], "\\+"))
             m2 <- unlist(strsplit(names(object)[j], "\\+"))
             if (m1[1] == "K80" && m2[1] == "F81") next
-            ## � v�rifier que ds les 2 lignes suivantes les conversions
+            ## a verifier que ds les 2 lignes suivantes les conversions
             ## se font bien correctement!!!!
             if (length(grep("\\+I", names(object)[i])) > 0 && length(grep("\\+I", names(object)[j])) == 0) next
             if (length(grep("\\+G", names(object)[i])) > 0 && length(grep("\\+G", names(object)[j])) == 0) next
diff --git a/R/read.GenBank.R b/R/read.GenBank.R
index d490215..f224144 100644
--- a/R/read.GenBank.R
+++ b/R/read.GenBank.R
@@ -1,4 +1,4 @@
-## read.GenBank.R (2014-04-02)
+## read.GenBank.R (2014-07-03)
 
 ##   Read DNA Sequences from GenBank via Internet
 
@@ -25,7 +25,7 @@ read.GenBank <-
                      "&rettype=gb&retmode=text", sep = "")
         X <- c(X, scan(file = URL, what = "", sep = "\n", quiet = TRUE))
     }
-    FI <- which(X == "ORIGIN      ") + 1 # fix by Sofia Sal Bregua (2014-04-02)
+    FI <- grep("^ORIGIN      ", X) + 1 # fix by Sofia Sal Bregua (2014-04-02) + Ingo Michalak (2014-07-03)
     LA <- which(X == "//") - 1
     obj <- vector("list", N)
     for (i in 1:N) {
diff --git a/R/read.dna.R b/R/read.dna.R
index b75d624..c72609b 100644
--- a/R/read.dna.R
+++ b/R/read.dna.R
@@ -1,14 +1,19 @@
-## read.dna.R (2013-04-02)
+## read.dna.R (2014-05-29)
 
 ##   Read DNA Sequences in a File
 
-## Copyright 2003-2013 Emmanuel Paradis
+## Copyright 2003-2014 Emmanuel Paradis
 
 ## This file is part of the R-package `ape'.
 ## See the file ../COPYING for licensing issues.
 
 read.FASTA <- function(file)
 {
+    if (length(grep("^(ht|f)tp:", file))) {
+        url <- file
+        file <- tempfile()
+        download.file(url, file)
+    }
     sz <- file.info(file)$size
     x <- readBin(file, "raw", sz)
     icr <- which(x == as.raw(0x0d)) # CR
diff --git a/R/root.R b/R/root.R
index 9badd2e..681d1de 100644
--- a/R/root.R
+++ b/R/root.R
@@ -1,8 +1,8 @@
-## root.R (2013-10-04)
+## root.R (2014-05-28)
 
 ##   Root of Phylogenetic Trees
 
-## Copyright 2004-2013 Emmanuel Paradis
+## Copyright 2004-2014 Emmanuel Paradis
 
 ## This file is part of the R-package `ape'.
 ## See the file ../COPYING for licensing issues.
@@ -172,11 +172,17 @@ root <- function(phy, outgroup, node = NULL,
                 phy$edge[sndcol, 2] <- newNb[phy$edge[sndcol, 2]] <- n + 2:phy$Nnode
                 phy$edge[, 1] <- newNb[phy$edge[, 1]]
             }
+            if (!is.null(phy$node.label)) {
+                newNb <- newNb[-(1:n)]
+                phy$node.label <- phy$node.label[order(newNb)]
+                phy$node.label[is.na(phy$node.label)] <- phy$node.label[1]
+                phy$node.label[1] <- "Root"
+            }
         }
         return(phy)
     }
 
-    phy$root.edge <- NULL # just in case...
+    phy$root.edge <- NULL # just in case
     Nclade <- tabulate(phy$edge[, 1])[ROOT] # degree of the root node
     ## if only 2 edges connect to the root, we have to fuse them:
     fuseRoot <- Nclade == 2
diff --git a/R/rotate.R b/R/rotate.R
index 2ea8480..81c73f3 100644
--- a/R/rotate.R
+++ b/R/rotate.R
@@ -1,17 +1,11 @@
-### ROTATE
-### Last update CH on 09.08.2007 (updated by EP 2011-06-14)
+## rotate.R (2014-06-05)
 
-# Contents:
-# 1. rotate
+##   Ancestral Character Estimation
 
-# 1: This function swops sister clades in a phylogenetic tree. 
-# Branch lengths are considered.
-# Arguments: 
-# phy: an object of class phylo
-# node: the number (integer) of the corresponding node or number or names of two tips that coalesce to th internal node
-# polytom: use a vector of two integers to define those two clades of a tritomy, that are swopped. The default is c(1,2). The clade number is counted from the from bottom to top in the plotted tree.
-# Author: C.Heibl
+## Copyright 2007 Christoph Heibl
 
+## This file is part of the R-package `ape'.
+## See the file ../COPYING for licensing issues.
 
 rotate <- function(phy, node, polytom = c(1,2)){
 	# load DESCENDANTS function
@@ -19,17 +13,17 @@ rotate <- function(phy, node, polytom = c(1,2)){
 		tips <- length(tree$tip.label)
 		x <- tree$edge[,2][tree$edge[,1] == node]
 		while(max(x) > tips){
-			x <- x[x > tips] 
+			x <- x[x > tips]
 			for(h in 1:length(x)) tree$edge <- tree$edge[!tree$edge[,2] == x[h],]
 			for(i in 1:length(x)) tree$edge[,1][tree$edge[,1] == x[i]] <- node
-			x <- tree$edge[,2][tree$edge[,1] == node] 
+			x <- tree$edge[,2][tree$edge[,1] == node]
 			}
-		x	
+		x
 		}
-# function starts here	
-# definitions
+
 	if (!inherits(phy, "phylo")) # is phy of class phylo?
         stop("object \"phy\" is not of class \"phylo\"")
+        phy <- reorder(phy) # added by EP 2014-06-05
     nb.tips <- length(phy$tip.label) # number of tiplabels
 	max.int.node <- phy$Nnode+nb.tips # number of last internal node
 	nb.edges <- dim(phy$edge)[1] # number of branches
@@ -42,17 +36,17 @@ rotate <- function(phy, node, polytom = c(1,2)){
 			node[2] <- tips[,2][tips[,1] == node[2]]
 			node <- as.numeric(node)
     		}
-    	if (any(!node %in% 1:nb.tips)) # is phy of class phylo?
+    	if (any(!node %in% 1:nb.tips))
         	stop("object \"node\" does not contain terminal nodes")
     	node <- getMRCA(phy, node)
     	}
 	if (node  <= nb.tips || node > max.int.node) # is node really internal?
-        stop("object \"node\" is not an internal node of object \"phy\"")  
+        stop("object \"node\" is not an internal node of object \"phy\"")
 	with.br.length <- !is.null(phy$edge.length) # does phy contain brlength?
-	G <- cbind(phy$edge, 1:(length(phy$edge)/2)) 
+	G <- cbind(phy$edge, 1:(length(phy$edge)/2))
 	N <- phy$edge[phy$edge[,1] == node]
 	N <- N[N != node]
-	if (length(N) > 2) N <- N[polytom] 
+	if (length(N) > 2) N <- N[polytom]
 	CLADE1 <- N[1]
 	CLADE2 <- N[2]
 # do clades comprise interior nodes?
@@ -68,12 +62,12 @@ rotate <- function(phy, node, polytom = c(1,2)){
 			}
 		if (CLADE2 > nb.tips){
 			c3 <- G[,3][G[,2] == CLADE2]
-			c4 <- G[,3][G[,2] == max(CLADE22)]	
+			c4 <- G[,3][G[,2] == max(CLADE22)]
 			} else {
 			c3 <- G[,3][G[,2] == CLADE2]
 			c4 <- G[,3][G[,2] == CLADE2]
 			}
-	
+
 # create new phy$edge and  phy$edge.length
 if (c2+1 == c3){
 	if (c1 == 1 && c4 != nb.edges){
@@ -119,8 +113,5 @@ else {
 			phy$edge.length <- c(phy$edge.length[c3:c4], phy$edge.length[(c2+1):(c3-1)], phy$edge.length[c1:c2])
 		}
 	}
-        ## deleted by EP (2011-06-14):
-	## S <- write.tree(phy)
-        ## phy <- if (!with.br.length) clado.build(S) else tree.build(S)
 	phy
 	}
diff --git a/R/rtt.R b/R/rtt.R
new file mode 100644
index 0000000..8006f52
--- /dev/null
+++ b/R/rtt.R
@@ -0,0 +1,59 @@
+## rtt.R (2014-06-16)
+
+##   Root a tree by root-to-tip regression
+
+## Copyright (c) 2014, Rosemary McCloskey, BC Centre for Excellence in HIV/AIDS
+
+## This file is part of the R-package `ape'.
+## See the file ../COPYING for licensing issues.
+
+if (getRversion() >= "2.15.1") utils::globalVariables("mclapply")
+
+rtt <- function(t, tip.dates, ncpu = 1, objective = "correlation", opt.tol = .Machine$double.eps^0.25)
+{
+    if (ncpu > 1) library(parallel)
+
+    ## These are objective functions which can be used to evaluate the "goodness" of
+    ## a regression fit.
+    if (objective == "correlation")
+        objective <- function(x, y) cor.test(y, x)$estimate
+    else if (objective == "rsquared")
+        objective <- function(x, y) summary(lm(y ~ x))$r.squared
+    else if (objective == "rms")
+        objective <- function(x, y) -summary(lm(y ~ x))$sigma^2
+    else
+        stop('objective must be one of "correlation", "rsquared", or "rms"')
+
+    t <- unroot(t)
+    dist <- dist.nodes(t)[, 1:(t$Nnode + 2)]
+
+    ## Do root-to-tip regressions for every possible choice of root.
+    fits <- if (ncpu > 1)
+        unlist(mclapply(1:nrow(dist), function(row) objective(tip.dates, dist[row, ]),
+                                      mc.cores = ncpu))
+        else unlist(lapply(1:nrow(dist), function(row) objective(tip.dates, dist[row, ])))
+
+    ## Find the best one (highest value of objective function).
+    fit.edge <- apply(t$edge, 2, function(e) fits[e])
+    obj.edge <- apply(fit.edge, 1, mean)
+    ## Compatibility with Path-O-Gen: find the last maximum, not the first.
+    best.edge <- length(obj.edge) - which.max(rev(obj.edge)) + 1
+    best.edge.parent <- t$edge[best.edge, 1]
+    best.edge.child <- t$edge[best.edge, 2]
+    best.edge.length <- t$edge.length[best.edge]
+
+    ## Find the best location on that edge.
+    f <- function(x) {
+        dist <- x * dist[best.edge.parent, ] + (1 - x) * dist[best.edge.child, ]
+        objective(tip.dates, dist)
+    }
+    best.pos <- optimize(f, c(0, 1), maximum = TRUE, tol = opt.tol)$maximum
+
+    ## Reroot the tree at the optimal location
+    new.root <- list(edge = matrix(c(2L, 1L), 1, 2), tip.label = "new.root", edge.length = 1, Nnode = 1L, root.edge = 1)
+    class(new.root) <- "phylo"
+    t <- bind.tree(t, new.root, where = best.edge.child, position = best.pos * best.edge.length)
+    t <- collapse.singles(t)
+    t <- root(t, "new.root")
+    drop.tip(t, "new.root")
+}
diff --git a/R/which.edge.R b/R/which.edge.R
index d22d97a..1909afd 100644
--- a/R/which.edge.R
+++ b/R/which.edge.R
@@ -1,8 +1,8 @@
-## which.edge.R (2013-05-10)
+## which.edge.R (2014-06-05)
 
 ##   Identifies Edges of a Tree
 
-## Copyright 2004-2013 Emmanuel Paradis
+## Copyright 2004-2014 Emmanuel Paradis
 
 ## This file is part of the R-package `ape'.
 ## See the file ../COPYING for licensing issues.
@@ -32,36 +32,19 @@ getMRCA <- function(phy, tip)
 which.edge <- function(phy, group)
 {
     if (!inherits(phy, "phylo"))
-      stop('object "phy" is not of class "phylo"')
+        stop('object "phy" is not of class "phylo"')
     if (is.character(group))
-      group <- which(phy$tip.label %in% group)
-    if (length(group) == 1)
-      return(match(group, phy$edge[, 2]))
-    nb.tip <- length(phy$tip.label)
-    MRCA <- getMRCA(phy, group)
-    if (MRCA == nb.tip + 1) {
-        from <- 1
-        to <- dim(phy$edge)[1]
-    } else {
-        from <- which(phy$edge[, 2] == MRCA) + 1
-        to <- max(which(phy$edge[, 2] %in% group))
-    }
-    wh <- from:to
-    tmp <- phy$edge[wh, 2]
-    ## check that there are no extra tips:
-    ## (we do this by selecting the tips in `group' and the nodes
-    ##  i.e., the internal edges)
-    test <- tmp %in% group | tmp > nb.tip
-    if (any(!test)) {
-        wh <- wh[test] # drop the extra tips
-        ## see if there are no extra internal edges:
-        tmp <- phy$edge[wh, ]
-        test <- !(tmp[, 2] %in% tmp[, 1]) & tmp[, 2] > nb.tip
-        while (any(test)){
-            wh <- wh[!test]
-            tmp <- phy$edge[wh, ]
-            test <- !(tmp[, 2] %in% tmp[, 1]) & tmp[, 2] > nb.tip
-        }
+        group <- which(phy$tip.label %in% group)
+
+    n <- length(phy$tip.label)
+    sn <- .Call(seq_root2tip, phy$edge, n, phy$Nnode)[group]
+    i <- 2L
+    repeat {
+        x <- unique(unlist(lapply(sn, "[", i)))
+        if (length(x) != 1) break
+        i <- i + 1L
     }
-    wh
+    d <- -(1:(i - 1L))
+    x <- unique(unlist(lapply(sn, function(x) x[d])))
+    match(x, phy$edge[, 2L])
 }
diff --git a/inst/doc/MoranI.pdf b/inst/doc/MoranI.pdf
index 2d44754..9dc876c 100644
Binary files a/inst/doc/MoranI.pdf and b/inst/doc/MoranI.pdf differ
diff --git a/man/dist.dna.Rd b/man/dist.dna.Rd
index 8168603..d67ea13 100644
--- a/man/dist.dna.Rd
+++ b/man/dist.dna.Rd
@@ -41,7 +41,7 @@ dist.dna(x, model = "K80", variance = FALSE,
   The molecular evolutionary models available through the option
   \code{model} have been extensively described in the literature. A
   brief description is given below; more details can be found in the
-  References.
+  references.
 
 \itemize{
   \item{\code{raw}, \code{N}: }{This is simply the proportion or the number of
diff --git a/man/image.DNAbin.Rd b/man/image.DNAbin.Rd
index 0740aae..6ad2210 100644
--- a/man/image.DNAbin.Rd
+++ b/man/image.DNAbin.Rd
@@ -49,6 +49,7 @@
 \examples{
 data(woodmouse)
 image(woodmouse)
+rug(seg.sites(woodmouse), -0.02, 3, 1)
 image(woodmouse, "n", "blue") # show missing data
 image(woodmouse, c("g", "c"), "green") # G+C
 par(mfcol = c(2, 2))
diff --git a/man/nodelabels.Rd b/man/nodelabels.Rd
index 5c44f3f..229b517 100644
--- a/man/nodelabels.Rd
+++ b/man/nodelabels.Rd
@@ -99,6 +99,13 @@ plot(tr)
 nodelabels("7.3 Ma", 4, frame = "r", bg = "yellow", adj = 0)
 nodelabels("5.4 Ma", 5, frame = "c", bg = "tomato", font = 3)
 
+## A trick by Liam Revell when there are many categories:
+plot(tr, x.lim = c(-1, 4))
+nodelabels(node = 4, pie = matrix(rep(1, 100), 1), cex = 5)
+op <- par(fg = "transparent")
+nodelabels(node = 5, pie = matrix(rep(1, 100), 1), cex = 5)
+par(op)
+
 data(bird.orders)
 plot(bird.orders, use.edge.length = FALSE, font = 1)
 bs <- round(runif(22, 90, 100), 0) # some imaginary bootstrap values
diff --git a/man/rtt.Rd b/man/rtt.Rd
new file mode 100644
index 0000000..c36948b
--- /dev/null
+++ b/man/rtt.Rd
@@ -0,0 +1,74 @@
+\name{rtt}
+\alias{rtt}
+\title{Root a Tree by Root-to-Tip Regression}
+\description{
+  This function roots a phylogenetic tree with dated tips in the location
+  most compatible with the assumption of a strict molecular clock.
+}
+\usage{
+rtt(t, tip.dates, ncpu = 1, objective = correlation,
+    opt.tol = .Machine$double.eps^0.25)
+}
+\arguments{
+  \item{t}{an object of class \code{"phylo"}.}
+  \item{tip.dates}{a vector of sampling times associated to the tips of
+    \code{t}, in the same order as \code{t$tip.label}.}
+  \item{ncpu}{number of cores to use.}
+  \item{objective}{one of \code{"correlation"}, \code{"rms"}, or
+    \code{"rsquared"}.}
+  \item{opt.tol}{tolerance for optimization precision.}
+}
+\details{
+  This function duplicates one part the functionality of the program
+  Path-O-Gen (see references). The root position is chosen to produce
+  the best linear regression of root-to-tip distances against sampling
+  times.
+
+  \code{t} must have branch lengths in units of expected substitutions
+  per site.
+
+  \code{tip.dates} should be a vector of sampling times, in any time
+  unit, with time increasing toward the present. For example, this may
+  be in units of ``days since study start'' or ``years since 10,000
+  BCE'', but not ``millions of yearsago''.
+
+  Setting \code{ncpu} to a value larger than 1 requires the \code{parallel}
+  library.
+
+  \code{objective} is the measure which will be used to define the
+  ``goodness'' of a regression fit. It may be one of \code{"correlation"}
+  (strongest correlation between tip date and distance from root),
+  \code{"rms"} (lowest root-mean-squared error), or \code{"rsquared"}
+  (highest R-squared value).
+
+  \code{opt.tol} is used to optimize the location of the root along the best
+  branch. By default, R's \code{optimize} function uses a precision of
+  \code{.Machine$double.eps^0.25}, which is about 0.0001 on a 64-bit system.
+  This should be set to a smaller value if the branch lengths of \code{t} are
+  very short.
+}
+\value{
+  an object of class \code{"phylo"}.
+}
+\note{
+  This function only chooses the best root. It does not rescale the branch
+  lengths to time, or perform a statistical test of the molecular clock
+  hypothesis.
+}
+\author{
+  Rosemary McCloskey\email{rmccloskey at cfenet.ubc.ca},
+  Emmanuel Paradis
+}
+\references{
+  Rambaut, A. (2009). Path-O-Gen: temporal signal investigation
+  tool. \url{http://tree.bio.ed.ac.uk/software/pathogen/}
+
+  Rambaut, A. (2000). Estimating the rate of molecular evolution:
+  incorporating non-contemporaneous sequences into maximum likelihood
+  phylogenies. \emph{Bioinformatics}, \bold{16}, 395-399.
+}
+\examples{
+t <- rtree(100)
+tip.date <- rnorm(t$tip.label)^2
+rtt(t, tip.date)
+}
diff --git a/man/which.edge.Rd b/man/which.edge.Rd
index c2a782e..d6eea9f 100644
--- a/man/which.edge.Rd
+++ b/man/which.edge.Rd
@@ -1,6 +1,10 @@
 \name{which.edge}
 \alias{which.edge}
 \title{Identifies Edges of a Tree}
+\description{
+  This function identifies the edges that belong to a group (possibly
+  non-monophyletic) specified as a set of tips.
+}
 \usage{
 which.edge(phy, group)
 }
@@ -9,17 +13,13 @@ which.edge(phy, group)
   \item{group}{a vector of mode numeric or character specifying the tips
     for which the edges are to be identified.}
 }
-\description{
-  This function identifies the edges that belong to a group (possibly
-  non-monophyletic) specified as a set of tips.
-}
 \details{
   The group of tips specified in `group' may be non-monophyletic
   (paraphyletic or polyphyletic), in which case all edges from the tips
   to their most recent common ancestor are identified.
 
   The identification is made with the indices of the rows of the matrix
-  `edge' of the "phylo" object.
+  `edge' of the tree.
 }
 \value{
   a numeric vector.

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/r-cran-ape.git



More information about the debian-med-commit mailing list