[Phylobase-devl] check_phylo4() bug

Peter Cowan pdc at berkeley.edu
Wed Feb 27 23:02:52 CET 2008

>  (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 can make printing work as follows;
> foo <- new('phylo4')
> set.seed(1001)
> foo at edge <- rcoal(10)$edge
> foo at tip.label <- rep('blah',10)
> foo at node.label <- rep("",9)
>  but I still crash the plot function.
>  should we
> (a) insist that internal node labels exist?
> (b) modify the coercion to data frame to work
>   without node labels?
>  I'm not yet sure of the problem with plot.
>  I would also like it if (eventually) plot worked
> with 'singleton' nodes, but that could be a lot
> of work ...

Add a feature request...


> Peter Cowan wrote:
>> A first for me, I found a way to dump core on R.
>> I was trying to put a phylo4 object together by hand.  Granted this  
>> is  pretty stupid use, but perhaps we should validate before  
>> plotting.
>> require(phylobase)
>> foo <- new('phylo4')
>> foo at edge <- rcoal(10)$edge
>> plot(foo) ## WARNING core dumps on my system
>> foo doesn't pass check_phylo4()
>> however if I do:
>> > foo at tip.label <- rep('blah', 10)
>> > check_phylo4(foo)
>> [1] TRUE
>> > foo
>> Error in data.frame(species.name, node, ancestor, branch.length,   
>> node.type) :
>>   arguments imply differing number of rows: 10, 19
>> Error in print(as(x, "data.frame")) :
>>   error in evaluating the argument 'x' in selecting a method for   
>> function 'print'
>> and plot(foo) hangs.
>> Peter
>> _______________________________________________
>> Phylobase-devl mailing list
>> Phylobase-devl at lists.r-forge.r-project.org
>> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/phylobase-devl

More information about the Phylobase-devl mailing list