[Phylobase-devl] nTips method defined where?
Ben Bolker
bolker at zoology.ufl.edu
Thu May 22 00:01:16 CEST 2008
Without thinking about it too carefully (on my way out
my office door), I can imagine that reticulation is one
of the things we'd like to allow wherever possible. I have
no problem with putting in a more robust test that
handles this case, but I do predict that you will run
into other funny cases that might be harder to handle.
(As I said before, though, I consider this all a good
part of shaking down the structure of phylobase.)
I will try to commit this tomorrow ...
Ben
Aaron Mackey wrote:
> Here's my edge matrix:
>
> ancestor descendant
> [1,] 6 7
> [2,] 6 1
> [3,] 7 8
> [4,] 7 9
> [5,] 8 2
> [6,] 8 3
> [7,] 9 4
> [8,] 9 5
> [9,] 8 4
>
> note the last edge implies that node 4 has two ancestors (i.e. this is a
> reticulated network, not a strict tree).
>
>> sum(tabulate(F[,1]) == 0)
> [1] 5
>> sum(!(F[,2] %in% F[,1]))
> [1] 6
>
> A quick fix without changing the idiom would be:
>> sum(!(unique(F[,2]) %in% F[,1]))
> [1] 5
>
>
> On Wed, May 21, 2008 at 3:20 PM, Ben Bolker <bolker at zoology.ufl.edu> wrote:
>
>> It's in methods-phylo4.R. There have been some
>> issues in the past with conflicts between an "nTips"
>> function in ape and the one in phylo4, but I don't think
>> that's what's going on here.
>>
>> Our current definition for phylo4 objects is
>>
>> setMethod("nTips", "phylo4", function(x, ...) {
>> E <- edges(x)
>> res <- sum(!E[, 2] %in% E[, 1])
>> return(res)
>> })
>>
>> which, in words, is "number of nodes in column 2 that do
>> not appear in column 1". To be honest, I don't remember
>> how we came up with this. It would seem like "number
>> of nodes of (out)degree 0" would be a better definition --
>> i.e., something using the same tabulate() idiom
>> that you've seen already -- although
>> I'm having a hard time at the moment thinking of the
>> circumstances under which they would differ.
>>
>> What does your edge matrix look like? Can you see
>> why it would be different? Does it violate any of
>> the ape rules quoted earlier?
>>
>> Ben
>>
>>
>>
>>
>> It's really nice to have someone else hacking on the code,
>> to flush out stuff like this!
>>
>> Aaron Mackey wrote:
>>
>>> When reading a nexml-formatted tree with reticulated nodes (i.e. a
>>> network),
>>> I'm getting an error while constructing the phylo4 tree that the number of
>>> tips doesn't match the number of tip labels. This is stemming from
>>> check_phylo4, which checks that nTips(object) is equal to
>>> length(tip.label)
>>> -- but I can't find the code for nTips (here is a snippet of my debugging
>>> session within check_phylo4; there are only 5 tips, but nTips reports 6):
>>>
>>> Browse[1]> nTips(object)
>>> [1] 6
>>> Browse[1]> object at tip.label
>>> [1] "Homo sapiens" "t3" "t2" "t5"
>>> "t4"
>>> Browse[1]> getMethod("nTips", where=object)
>>> Method Definition:
>>>
>>> function (x, ...)
>>> {
>>> .local <- function (x)
>>> {
>>> if (class(x) == "phylo") {
>>> Ntip(x)
>>> }
>>> else stop(paste("no 'nTips' method available for",
>>> deparse(substitute(x)),
>>> "(class", class(x), ")"))
>>> }
>>> .local(x, ...)
>>> }
>>> <environment: 0x861e04c>
>>>
>>> Signatures:
>>> x
>>> target "ANY"
>>> defined "ANY"
>>>
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> 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
>>>
>>
>>
>
-------------- 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/20080521/57f91934/attachment-0001.pgp
More information about the Phylobase-devl
mailing list