[Phylobase-devl] check_phylo4() bug

Ben Bolker bolker at zoo.ufl.edu
Wed Feb 27 23:08:32 CET 2008


Peter Cowan wrote:
>>  (1) for your first example -- we shouldn't have to be responsible
>> for people who muck with the internals of phylobase objects.  If
>> it couldn't be constructed with phylobase functions (i.e. the
>> constructor or coercion or the phylo4() command) and doesn't
>> pass check_phylo4, then you're on your own.  Nevertheless, since
>> we had the checks in there anyway I've fixed them so they
>> actually do something.
> 
> Agreed.  However, we shouldn't have commands that cause R to crash,  
> whether the user is being foolish or not.  Secondly, as far as I know,  
> we don't have accessor/build functions to build phylo4(d) objects  
> piecemeal safely. I stumbled across this because I was trying to  
> follow up on Thibaut comment about polytomy support and was trying to  
> figure out how to make a tree with some.
> 
>>  (2) is more serious -- the situation here seems to
>> be that foo has tip labels but no (internal) node labels.
>> as(foo,"data.frame") gets confused, as does plot.
>> I think at the moment we're assuming that internal
>> node labels exist (even if blank).
> 
> Yes, so is it possible to enforce some default node labeling, I'm  
> thinking about something elastic.  We would need to add methods like  
> "edges<-" that do some checking.  Good idea, bad idea, too much effort?

   I think this is pretty easy;

setGeneric("edges<-", function(x,value) {
     standardGeneric("edges<-")
})

setMethod("edges<-","phylo4", function(x,value) {
     x at edges <- value
     if (is.character(chk <- check_phylo4(x)))
        stop("bad edges: ",chk)
     x
})

   I haven't tested this at all, but it should look something
like that.

   Ben



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
Url : http://lists.r-forge.r-project.org/pipermail/phylobase-devl/attachments/20080227/d7b55e4b/attachment.pgp 


More information about the Phylobase-devl mailing list