[Phylobase-devl] change root node from NA to 0

Peter Cowan pdc at berkeley.edu
Thu Sep 24 02:05:20 CEST 2009


Okay, I think this is finished.  For the time being I've uploaded the  
result to a branch called edgesNAto0.  It is ready to be merged if  
people approve.

In a testament to the nice abstractions of the package, most of the  
changes are actually to examples and unit tests that use hand made  
edge matrices.

It does make some code slightly less elegant e.g.

-    singletons <- which(tabulate(na.omit(edge.new[,1]))==1)
+    singletons <- which(tabulate(edge.new[edge.new[, 1] != 0, 1])==1)

One remaining question: getNode(NA) would return NA but getNode(0)  
returns 0, is this the desired behavior?

Cheers

Peter

On Sep 21, 2009, at 4:23 PM, Jim Regetz wrote:

> Fine with me. One suggestion: In recent weeks I have changed several  
> instances of this sort of thing:
>  edges(x)[which(is.na(edges(x)[,1])), ]
>
> to this:
>  edges(x, drop.root=TRUE)
>
> which accomplishes the same thing but leaves the implementation  
> details to the edges method. I know for sure there are still several  
> instances of the former in the code base. I suggest making sure the  
> latter form is used everywhere. It would then be easy enough to  
> update the edges method to match a new 0 encoding for root nodes.
>
> On that note, would it further simplify this transition to add an  
> analogous drop.root=TRUE argument to some of the other edge-related  
> phylo4 methods? It would be most obviously beneficial in the case of  
> edgeLength (and thus probably sumEdgeLength to match), but also  
> possibly edgeLabels, edgeId, and maybe even nEdges. Just a thought.
>
> Jim
>
>
> Peter Cowan wrote:
>> Given that significant changes are still fair game, I'd like to   
>> propose changes the root edge from having NA as the ancestor to 0  
>> as  the ancestor.
>> I'd be willing to do the lifting for this one, and could probably  
>> get  it done around the same time the unification gets finished up.
>> I found myself having to work around the NA issue in several  
>> places  where 0 wouldn't have been a problem.  Does anyone have a  
>> case where  NA is superior to 0 in the edge matrix?
>> 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