[Phylobase-devl] tree structures

Ben Bolker bolker at ufl.edu
Sun Oct 12 23:53:02 CEST 2008


   A few questions about tree structure -- what's
expected, what's required, are we enforcing that
structure?

   The assumptions we are currently checking in phylobase
are:
     tips should be numbered 1:(ntips),
      internal nodes (ntips+1):nnodes

   polytomies OK

   must root be (ntips+1) ??? I think we assume this, but
don't say it.
## [example]

library(phylobase)

## construct a tree (no tip labels, no edge lengths,
##   4 tips.  node 5 -> (1,2), node 6 -> (3,4), node 7
## is the root.  No polytomies, no reticulation,
##  no cycles.

z = list(edge=
  matrix(c(5,1,5,2,6,3,6,4,7,5,7,6),
         byrow=TRUE,ncol=2),
  tip.labels=LETTERS[1:4],
  Nnode=3)
class(z) = "phylo"
z

plot(reorder(z))  ## boom
plot(z)
## plot(z): boom.
## *** caught segfault ***
## address 0x483fdb98, cause 'memory not mapped'

zz <- as(z,"phylo4")
## no complaints from checktree

## plot(zz): boom.  Same error.
## *** caught segfault ***
## address 0x483fdb98, cause 'memory not mapped'

library(phylobase)
z = list(edge=
  matrix(c(7,1,7,2,6,3,6,4,5,7,5,6),
         byrow=TRUE,ncol=2),
  tip.labels=LETTERS[1:4],
  Nnode=3)
class(z) = "phylo"
z
zz <- as(z,"phylo4")
zz

plot(reorder(z))
plot(z) ## boom

zz2 <- as(reorder(z),"phylo4")
plot(zz2)

  for plotting in ape: must be ordered cladewise?

## load ape
library(ape)
## generate random 5-tip tree
set.seed(1001)
t5 <- rtree(5)
## for easier staring at edge values
t5$edge.length <- round(10*t5$edge.length)
## get var-cov matrix
(v5 <- vcv.phylo(t5))

## plot with internal nodes
plot(t5)
nodelabels(6:9,6:9)

source("phylo.vcv.R")
t5b <- phylo.vcv(v5)

library(phylobase)
check_tree(as(t5b,"phylo4"))  ## nothing obviously wrong
plot(t5b) ## would go boom

library(phylobase)
## or wherever you keep PDC's new code
source("/home/ben/lib/R/pkgs/phylobase/branches/pdcgsoc/misc/plot.phylo.R")
t5c <- as(t5b,"phylo4")
myplot(t5c)

## careful inspection of t5, t5b, t5c
##  shows that they are the same
## e.g. nodes 8,9 numbers are switched
##  but lengths are switched accordingly:
##  (8,1) branch (tip label t3) has length 8 in t5,
##  (9,1) branch (tip label t3) has length 8 in t5b
##  [second-longest branch; branch to node 3 (tip label t4) is longer]

plot(t5c)
myplot(t5c)  ## t3, t4 are not longest branches any more!

## what other assumption is "myplot" making?
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: phylo.vcv.R
Url: http://lists.r-forge.r-project.org/pipermail/phylobase-devl/attachments/20081012/a32568c1/attachment-0001.txt 


More information about the Phylobase-devl mailing list