[R-sig-phylo] Use of OUCH package

Aaron A. King kingaa at umich.edu
Thu Jan 21 14:48:52 CET 2010


I've been a bit mystified by questions referring to an ouch format for data, 
ouch data files, etc. and even more mystified by the fact that others seem to 
understand the reference.  As far as I know, there is no ouch format for data 
and no file format for ouch either.  I surmise that a convention has evolved 
for setting up ouch trees and that the questions are evidence that this 
convention should be better communicated.  

Graham Slater at UCLA contacted me off-list with some code that sets up a 
function to automate the process.  I suspect the time is not quite right for 
such a function.  However, I modified his codes a bit to give an example of 
how one can turn an 'ape'-formatted tree into an 'ouch' formatted tree and 
then call 'brown' and 'hansen'.  The example follows.

######################################################
require(geiger)
require(ouch)

### an example data set
data(geospiza)
str(geospiza)
sapply(geospiza,class)

attach(geospiza)

### check the correspondence between data and tree tips:
print(nc <- name.check(geospiza.tree,geospiza.data))
### looks like one of the terminal twigs has no data associated
### drop that tip:
tree <- drop.tip(geospiza.tree,nc$Tree.not.data)

### make an ouchtree out of the phy-format tree
ot <- ape2ouch(tree)

### merge data with tree info
otd <- as(ot,"data.frame")
### in these data, it so happens that the rownames correspond to node names
### we will exploit this correspondence in the 'merge' operation:
geospiza.data$labels <- rownames(geospiza.data) 
otd <- merge(otd,geospiza.data,by="labels",all=T)
rownames(otd) <- otd$nodes
print(otd)
### this data-frame now contains the data as well as the tree geometry

### now remake the ouch tree
ot <- 
with(otd,ouchtree(nodes=nodes,ancestors=ancestors,times=times,labels=labels))

b1 <- with(otd,brown(tree=ot,data=otd[c("tarsusL","beakD")]))
print(summary(b1))

### evaluate an OU model with a single, global selective regime
otd$regimes <- as.factor("global")
h1 <- with(
           otd,
           hansen(
                  tree=ot,
                  data=otd[c("tarsusL","beakD")],
                  regimes=otd["regimes"],
                  sqrt.alpha=c(1,0,1),
                  sigma=c(1,0,1),
                  maxit=10000
                  )
           )
print(summary(h1))

detach(geospiza)
######################################################
Note that the call to hansen above assumes version 2.6-1 of ouch, which is on 
R-forge now and will be released to CRAN very soon.


On Wednesday 20 January 2010, Graham Slater wrote:
> My name is Graham Slater - I'm a postdoc with Mike Alfaro at UCLA. I
> wrote the attached function to form an ouch formatted data file from a
> phylogeny and a dataframe, assuming that the taxon names in the data
> and tree match and that the species column in the data frame is named
> "species". I'm happy to share it with people if it helps save time in
> making files but i figured you should check it out first.
>
> I hoep this might be of some help.



-- 
Aaron A. King, Ph.D.
Ecology & Evolutionary Biology
Mathematics
Center for the Study of Complex Systems
University of Michigan
GPG Public Key: 0x6E74F51B
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <https://stat.ethz.ch/pipermail/r-sig-phylo/attachments/20100121/522bcafe/attachment.bin>


More information about the R-sig-phylo mailing list