[Phylobase-devl] Proposition for phylo4d constructor

François Michonneau fmichon at flmnh.ufl.edu
Tue Aug 26 21:08:24 CEST 2008


Hello,

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

library(phylobase)
### create a tree and some data
## 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 directly add 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 method, 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))

   If you think that this new method will be useful I'll commit it to 
SVN and 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/20080826/64d41cc8/attachment-0001.bin 


More information about the Phylobase-devl mailing list