[Phylobase-devl] edge matrix ordering in phylobase and ape

Ben Bolker bolker at ufl.edu
Tue Dec 30 21:40:07 CET 2008


  Emmanuel, [cc'd to phylobase devel list]

  we (the phylobase group) are having some discussions about
edge matrix ordering.  The parts about what is safe (and not
safe) to import from/export to ape would benefit from your
input.

   At the moment our rules for edge matrix ordering
in phylobase are that any order is allowed (nominally the
same as in ape, although see below).  Node ID numbers must
follow the same rule as in ape (1:m are tips, m+1 is the
root if there is one, m+2 ... m+n are internal).
The phylo4[d] object also has an additional slot describing
the order, which (at the moment) can be "unknown" (default),
"preorder" (="cladewise" in ape) or "postorder" (almost="pruningwise"
in ape).  We are somewhat divided about what to do on import from/
export to ape.

  import:
   if $order is NULL in the phylo object (i.e., not explicitly
specified):
     a. set @order to "unknown" (most conservative)
     b. set @order to "cladewise" (probably true by default
          since things break in ape otherwise?  see below)

  if $order=="cladewise"
     set @order to "preorder" (a no-brainer)

  if $order=="pruningwise"
     a. set to "unknown" (at the moment we don't allow "pruningwise")
        [this loses information]
     b. set to "postorder" (not really true!)
     c. allow "pruningwise" as an option in phylobase

  export:
    if @order is "unknown"
     a. don't rearrange edge matrix (allows flexibility in edge matrix
ordering  -- e.g. some packages other than ape might explicitly want
non-cladewise ordering -- but dangerous since such trees can crash
plot.tree).  Leave $order NULL
     b. enforce preorder/cladewise ordering (safer -- but makes
it hard to export trees in any other order
        b1. set $order to "cladewise"
        b2. leave $order NULL

  b1 will break round-trip capability
(i.e.  identical(phy,as(as(phy,"phylo4"),"phylo")) will be FALSE) even
for trees that start out cladewise ordering but with $order NULL

  What do you think??

---------------
   The ape nodeId rules (which we do follow) are (tips, int.nodes); the
ape API <ape.mpl.ird.fr/misc/FormatTreeR_28July2008.pdf> says
"There is no mandatory order for the rows of edge, but they may be
arranged in a way that is efficient for computation and manipulation.",
but I have some reason to suspect that's not true.  For example, this code

library(ape)
example("read.tree")
set.seed(1001)
tt <- tree.owls

permtree <- function(phy) {
  phy$edge <- phy$edge[sample(nrow(phy$edge)),]
  phy
}

for (i in 1:40) {
  cat(i,"\n")
  ttp <- permtree(tt)
  plot(ttp)
}

  hangs R in an infinite loop on the second try ...
  I don't know whether pruningwise (or anything other
than cladewise will do it) ...

-- 
Ben Bolker
Associate professor, Biology Dep't, Univ. of Florida
bolker at ufl.edu / www.zoology.ufl.edu/bolker
GPG key: www.zoology.ufl.edu/bolker/benbolker-publickey.asc


More information about the Phylobase-devl mailing list