Re: [R-sig-phylo] Bug in reorder.phylo() (related to cleaning phylo objects)

2015-06-16 Thread Emmanuel Paradis
Hi David & Brian, Yes, I'll put this function in the next release. Cheers, Emmanuel Le 15/06/2015 18:27, David Bapst a écrit : Whoops, I meant a 'function in ape?' -Dave On Mon, Jun 15, 2015 at 10:26 AM, David Bapst wrote: Hi Brian, I was already aware of the read.tree(write.tree()) fix,

Re: [R-sig-phylo] Bug in reorder.phylo() (related to cleaning phylo objects)

2015-06-15 Thread Liam J. Revell
Hi David. I'm not sure about this, but changing to: tree<-read.newick(text=write.tree(tree)) tree<-collapse.singles(tree) may work. I believe that write.tree will write trees with singletons & read.newick in phytools should be able to read them. All the best, Liam Liam J. Revell, Assistant

Re: [R-sig-phylo] Bug in reorder.phylo() (related to cleaning phylo objects)

2015-06-15 Thread David Bapst
Whoops, I meant a 'function in ape?' -Dave On Mon, Jun 15, 2015 at 10:26 AM, David Bapst wrote: > Hi Brian, > > I was already aware of the read.tree(write.tree()) fix, however I've > run into (corner?) cases where a particular sorting of edges or > whatever can lead to a loss of tip taxa using th

Re: [R-sig-phylo] Bug in reorder.phylo() (related to cleaning phylo objects)

2015-06-15 Thread David Bapst
Hi Brian, I was already aware of the read.tree(write.tree()) fix, however I've run into (corner?) cases where a particular sorting of edges or whatever can lead to a loss of tip taxa using the read.tree(write.tree()) approach; plus, read.tree(write.tree()) gets completely flabbergasted by singleto

Re: [R-sig-phylo] Bug in reorder.phylo() (related to cleaning phylo objects)

2015-06-15 Thread Brian O'Meara
A kludgy solution to achieve Dave's original use case of fixing not-quite-right phylo objects is to do: phy <- read.tree(text=write.tree(phy)) It converts the tree to Newick and reads it back in. It's not as good a solution as using a validator (great addition, Emanuel!) to find and fix the gene

Re: [R-sig-phylo] Bug in reorder.phylo() (related to cleaning phylo objects)

2015-06-15 Thread Emmanuel Paradis
Hi David, collapse.singles() seems to work correctly if the "phylo" object is correctly conformed. Some features of this class may seem annoying (and Klaus and I alredy discussed about this), but these help for other things. As a reminder the class "phylo" is defined here: http://ape-package

Re: [R-sig-phylo] Bug in reorder.phylo() (related to cleaning phylo objects)

2015-06-12 Thread David Bapst
Hi Klaus (and others), Ah, I see! The real bug then appears to be in collapse.singles, as it does not reorder the ID numbers in $edge. Here's a quick function to return the root ID: getRootID<-function(tree){ uniqueNode<-unique(tree$edge[,1]) whichRoot<-sapply(uniqueNode,function(x)

Re: [R-sig-phylo] Bug in reorder.phylo() (related to cleaning phylo objects)

2015-06-12 Thread Klaus Schliep
Hi David, I found the bug. Somehow ape assumes on the one hand that the root is number of tips + 1. On the other hand the root of an phylo object is the node which is in tree$edge[,1], but not in tree$edge[,2], this is the case even in an unrooted tree. This annoys me for a long time. The root of

[R-sig-phylo] Bug in reorder.phylo() (related to cleaning phylo objects)

2015-06-12 Thread David Bapst
Hello all, As those of you who directly manipulate the guts of phylo objects in your code (or construct new phylo objects whole cloth from un-phylo-like data structures) have probably experienced, it is sometimes easy to create $edge matrices that aren't accepted by ape functions (I often use plot