[Phylobase-devl] Proposition for phylo4d constructor

François Michonneau fmichon at flmnh.ufl.edu
Mon Aug 25 23:29:17 CEST 2008


Hello

   As the phylo4d constructor is currently implemented, I don't think 
it's possible to add directly tip data, node data or both to a phylo4d 
object. If you do:

### create a tree and some data
library(phylobase)
## create a tree
rTr <- rcoal(20)
rTP <- as(rTr, "phylo4")
## create tip data
rDt <- data.frame(trait1 = rnorm(20), trait2 = rnorm(20))
rownames(rDt) <- labels(rTP)
## create node data
rDn <- data.frame(trait1 = rnorm(19), trait2 = rnorm(19))
rownames(rDn) <- nodeLabels(rTP)
## create all data
rDa <- data.frame(trait1 = rnorm(39), trait2 = rnorm(39))
rownames(rDa) <- c(paste("t", 1:20, sep=""), nodeLabels(rTP))

## create a phylo4d object
rTdA <- phylo4d(rTP, all.data=rDa)

## try to add tip data to rTda
rTdAt <- phylo4d(rTdA, tip.data=rDt)

then rTdAt contains only the newly added tip data and the "all.data" 
previously stored are overridden.

   I started during the summer course at NESCent to write a new method 
for the phylo4d constructor which deals with phylo4d objects. In the new 
version of the code I propose you can add directly data to a phylo4d 
object. It's also possible to add at the same time tip.data, node.data 
and all.data. To use this new methods, the data provided as arguments in 
the constructors must have names that match (at least partially) tip 
and/or node labels.
   After you sourced the new method, you can try for instance:

(rTdAt <- phylo4d(rTdA, tip.data=rDt))
(rTdAatn <- phylo4d(rTdA, all.data=rDa, node.data=rDn, tip.data=rDt))

   I have requested to become a developer of phylobase on R-forge, so if 
you think that this new method will be useful I'll commit it and try to 
update the documentation.

   I'm also interested in feedback if you think that there are things to 
change.

   Cheers,
    François

-------------- next part --------------
A non-text attachment was scrubbed...
Name: class-phylo4d.R
Type: application/x-extension-r
Size: 8559 bytes
Desc: not available
Url : http://lists.r-forge.r-project.org/pipermail/phylobase-devl/attachments/20080825/5467a955/attachment-0001.bin 


More information about the Phylobase-devl mailing list