[Phylobase-devl] extractTree proposal

Jim Regetz regetz at nceas.ucsb.edu
Tue Aug 25 18:44:28 CEST 2009


Hi all,

The extractTree function currently extracts the tree part of a phylo4d 
object by manually accessing each relevant phylo4 slot and passing them 
to the phylo4('matrix') constructor. I'd like to propose this instead:

extractTree <- function(from) as(from, "phylo4")

Note that this "as" method requires no maintenance on our part, because 
it is derived implicitly from the class definition of phylo4d as an 
extension of phylo4. You can use this incantation to see the method:
   selectMethod("coerce", c("phylo4d", "phylo4"))

Defining extractTree this way makes it faster and simpler, and also more 
robust to other code changes. It also means that if there are problems 
with the phylo4d object, an error will come from checkTree rather than 
the phylo4 constructor, which IMHO is more sensible. If future changes 
require a more complicated approach, we can deal with it then (and it 
will still just be extractTree to the end user, which is a good reason 
not to drop this function altogether).

Thanks,
Jim


More information about the Phylobase-devl mailing list