Thanks, this is useful info (that should probably get included in the docs for the phylo4() constructor).&nbsp; Turns out I&#39;ll have to conform to this spec to get many other things working as well, so (as you say), the requirement for &quot;nbins&quot; in tabulate() goes away with &quot;proper&quot; edge matrices.<br>
<br>Thanks again,<br><br>-Aaron<br><br><div class="gmail_quote">On Wed, May 21, 2008 at 12:02 PM, Ben Bolker &lt;<a href="mailto:bolker@ufl.edu">bolker@ufl.edu</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
-----BEGIN PGP SIGNED MESSAGE-----<br>
Hash: SHA1<br>
<br>
~ &nbsp;OK.<br>
<br>
~ &nbsp;It&#39;s easy enough for me to make these changes, *but* I think we<br>
need to step back for a minute here.<br>
<br>
~ &nbsp;We inherit much of our code and conventions from<br>
Emmanuel Paradis&#39;s &quot;phylo&quot; objects.<br>
<br>
<a href="http://ape.mpl.ird.fr/misc/FormatTreeR_4Dec2006.pdf" target="_blank">http://ape.mpl.ird.fr/misc/FormatTreeR_4Dec2006.pdf</a><br>
<br>
is very informative: in particular, it says that<br>
for well-formed phylo objects the maximum node numbers are always<br>
internal nodes and always have degree &gt; 0 (see below) -- so your problem<br>
wouldn&#39;t arise.<br>
<br>
~ &nbsp;Now, I will admit that we do not currently prevent this; we should<br>
(1) decide whether we want to accept all of these rules for phylo4<br>
objects as well (I would like to eliminate rule b below, to<br>
allow &quot;singleton&quot; nodes); (2) add these rules to phylo4 object<br>
checking so that they can&#39;t happen.<br>
<br>
~ &nbsp;Thoughts, anyone?<br>
<br>
~ &nbsp;Ben<br>
<br>
===========================<br>
Definition of the Class &quot;phylo&quot;<br>
<br>
An object of class &quot;phylo&quot; is a list with, at least, the following<br>
mandatory elements:<br>
<br>
1. A numeric matrix named edge with two columns and as many rows as<br>
there are branches in the tree;<br>
2. A character vector of length n named tip.label with the labels of the<br>
tips;<br>
3. A numeric value named Nnode giving the number of (internal) nodes;<br>
4. An attribute class equal to &quot;phylo&quot;.<br>
<br>
In the matrix edge, each branch is coded by the nodes it connects: tips<br>
are coded 1, . . . , n, and internal nodes are coded n + 1, . . . , n +<br>
m (n + 1 is the root). Both series are numbered with no gaps. The matrix<br>
edge has the following properties:<br>
<br>
a· The first column has only values &gt; n (thus, values &nbsp;n appear only in<br>
the second column).<br>
b· All nodes appear in the first column at least twice.<br>
c· The number of occurrences of a node in the first column is related to<br>
the nature of the node: twice if it is dichotomous (i.e., of degree 3),<br>
three times if it is trichotomous (degree 4), and so on.<br>
d· All elements, except the root n + 1, appear once in the second column<br>
(only if the tree has no reticulation). This representation is used for<br>
rooted and unrooted trees. For the latter, the position of the root is<br>
arbitrary.<br>
<br>
~ [I added labels a-d]<div><div></div><div class="Wj3C7c"><br>
<br>
<br>
<br>
<br>
Aaron Mackey wrote:<br>
| err, wait, sorry. &nbsp;it&#39;s not nrows() we want, but max(edge) ...<br>
|<br>
| -Aaron<br>
|<br>
| On Wed, May 21, 2008 at 11:35 AM, Ben Bolker &lt;<a href="mailto:bolker@zoology.ufl.edu" target="_blank">bolker@zoology.ufl.edu</a>&gt;<br>
wrote:<br>
|<br>
|&gt;<br>
|&gt;<br>
|&gt; Aaron Mackey wrote:<br>
|&gt;<br>
|&gt;&gt; I don&#39;t have functional SVN access at the moment, otherwise I&#39;d do this<br>
|&gt;&gt; myself. &nbsp;But essentially, calls to &quot;tabulate()&quot; need to define the<br>
number<br>
|&gt;&gt; of<br>
|&gt;&gt; bins explicitly, otherwise problems occur. &nbsp;For example:<br>
|&gt;&gt;<br>
|&gt;&gt; &nbsp;edge<br>
|&gt;&gt; [1,] &nbsp;1 &nbsp;3<br>
|&gt;&gt; [2,] &nbsp;1 &nbsp;2<br>
|&gt;&gt; [3,] &nbsp;3 &nbsp;4<br>
|&gt;&gt; [4,] &nbsp;3 &nbsp;7<br>
|&gt;&gt; [5,] &nbsp;4 &nbsp;5<br>
|&gt;&gt; [6,] &nbsp;4 &nbsp;6<br>
|&gt;&gt; [7,] &nbsp;7 &nbsp;8<br>
|&gt;&gt; [8,] &nbsp;7 &nbsp;9<br>
|&gt;&gt;<br>
|&gt;&gt;&gt; tabulate(edge[,1])<br>
|&gt;&gt;&gt;<br>
|&gt;&gt; [1] 2 0 2 2 0 0 2<br>
|&gt;&gt;<br>
|&gt;&gt;&gt; tabulate(edge[,1], nbins=dim(edge)[1])<br>
|&gt;&gt;&gt;<br>
|&gt;&gt; [1] 2 0 2 2 0 0 2 0<br>
|&gt;&gt;<br>
|&gt;&gt; -Aaron<br>
|&gt;&gt;<br>
|&gt;&gt;<br>
|&gt; &nbsp;I grepped for &quot;tabulate&quot;. &nbsp;Are you recommending that<br>
|&gt; we change all of these usages as above?<br>
|&gt; (Is it worth defining a &quot;tabedge&quot; function<br>
|&gt;<br>
|&gt; tabedge &lt;- function(object,i) {<br>
|&gt; &nbsp; &nbsp;tabulate(edges(object[,i]), nbins=nrow(edges(object)))<br>
|&gt; }<br>
|&gt;<br>
|&gt; &nbsp;to replace most of these, or is that just too complicated?<br>
|&gt;<br>
|&gt; &nbsp;Ben<br>
|&gt;<br>
|&gt;<br>
|&gt; 1 checkdata.R: &nbsp; &nbsp;nAncest &lt;- tabulate(edges(object)[, 2])<br>
|&gt; 2 class-phylo4.R: &nbsp; &nbsp;ntips &lt;- sum(tabulate(edge[, 1]) == 0)<br>
|&gt; 3 class-phylo4.R: &nbsp; &nbsp;nnodes &lt;- sum(tabulate(edge[, 1]) &gt; 0)<br>
|&gt; 4 methods-phylo4.R: &nbsp; &nbsp;tabulate(edges(x)[, 1])[nTips(x) + 1] &lt;= 2<br>
|&gt; 5 methods-phylo4.R: &nbsp; &nbsp; &nbsp; &nbsp;temp &lt;- tabulate(E[,1])<br>
|&gt; 6 treestruc.R: &nbsp;degree &lt;- tabulate(edges(object)[, 1])<br>
|&gt; 7 treestruc.R: &nbsp;degree &lt;- tabulate(edges(object)[, 1])<br>
|&gt; 8 treestruc.R:# &nbsp;isTips &lt;- (tabulate(x@edge[,1]) == 0)<br>
|&gt; 9 treestruc.R:# &nbsp;res &lt;- (tabulate(x@edge[,1]) &gt; 2)<br>
|&gt;<br>
|&gt;<br>
|&gt;<br>
|&gt;<br>
|&gt;<br>
|<br>
<br></div></div>
-----BEGIN PGP SIGNATURE-----<br>
Version: GnuPG v1.4.6 (GNU/Linux)<br>
Comment: Using GnuPG with Mozilla - <a href="http://enigmail.mozdev.org" target="_blank">http://enigmail.mozdev.org</a><br>
<br>
iD8DBQFINEedc5UpGjwzenMRArZWAJ9UaRMyNjDS77YSiUx4FAZfitqJQwCgoBX4<br>
yN+fVxyrLTbir7wZLvpZ32w=<br>
=XNte<br>
-----END PGP SIGNATURE-----<br>
</blockquote></div><br>