[Phylobase-devl] [R-sig-phylo] phylobase::descendants issue

Ben Bolker bbolker at gmail.com
Sat Apr 27 23:10:00 CEST 2013


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

  Thanks for the heads-up.  I or one of the other phylobase developers
will try to take a look ...

  cheers
    Ben Bolker


On 13-04-26 06:50 PM, Nick Matzke wrote:
> Hi all,
> 
> Not sure if this is a bug, but I noticed weird behavior when
> loading a tree with APE and then converting to phylo4 to do
> descendants() -- not all the tips are produced.
> 
> Example:
> 
> 
> library(ape) library(phylobase)
> 
> trstr = 
> "((((((((P_hawaiiensis_WaikamoiL1:0.9656850499,P_mauiensis_Eke:0.9656850499):0.7086257935,(P_fauriei2:1.230218511,P_hathewayi_1:1.230218511):0.4440923324):0.1767115552,(P_kaduana_PuuKukuiAS:1.851022399,P_mauiensis_PepeAS:1.851022399):0.0008897862802):0.3347375986,P_kaduana_HawaiiLoa:2.185759997):0.302349378,(P_greenwelliae07:1.131363255,P_greenwelliae907:1.131363255):1.35674612):1.689170274,((((P_mariniana_MauiNui:1.994011054,P_hawaiiensis_Makaopuhi:1.994011054):0.7328279804,P_mariniana_Oahu:2.726839034):0.2574151709,P_mariniana_Kokee2:2.984254205):0.4601084855,P_wawraeDL7428:3.444362691):0.732916959):0.7345185743,(P_grandiflora_Kal2:2.479300491,P_hobdyi_Kuia:2.479300491):2.432497733):0.2873119899,((P_hexandra_K1:2.363984189,P_hexandra_M:2.363984189):0.4630447802,P_hexandra_Oahu:2.826939991):2.372081244);"
>
> 
> 
> # Load tree tr = read.tree(file="", text=trstr) tr
> 
> # Convert to phylo4 tr4 = as(tr, "phylo4")
> 
> # Find root (node 20) rootnode = nodeId(tr4, type="root") rootnode
> 
> # Only 3 tips! (there should be 19) tipnames = descendants(phy=tr4,
> node=rootnode, type="tips") tipnames
> 
> 
> 
> 
> The problem is here in descendants():
> 
> if (phy at order == "preorder") { edge <- phy at edge } else { edge <-
> reorder(phy, order = "preorder")@edge } ancestor <-
> as.integer(edge[, 1]) descendant <- as.integer(edge[, 2]) isDes <-
> .Call("descendants", node, ancestor, descendant)
> 
> ...it works if I force phy at order to "cladewise" or "unknown"
> 
> 
> library(ape) library(phylobase)
> 
> trstr = 
> "((((((((P_hawaiiensis_WaikamoiL1:0.9656850499,P_mauiensis_Eke:0.9656850499):0.7086257935,(P_fauriei2:1.230218511,P_hathewayi_1:1.230218511):0.4440923324):0.1767115552,(P_kaduana_PuuKukuiAS:1.851022399,P_mauiensis_PepeAS:1.851022399):0.0008897862802):0.3347375986,P_kaduana_HawaiiLoa:2.185759997):0.302349378,(P_greenwelliae07:1.131363255,P_greenwelliae907:1.131363255):1.35674612):1.689170274,((((P_mariniana_MauiNui:1.994011054,P_hawaiiensis_Makaopuhi:1.994011054):0.7328279804,P_mariniana_Oahu:2.726839034):0.2574151709,P_mariniana_Kokee2:2.984254205):0.4601084855,P_wawraeDL7428:3.444362691):0.732916959):0.7345185743,(P_grandiflora_Kal2:2.479300491,P_hobdyi_Kuia:2.479300491):2.432497733):0.2873119899,((P_hexandra_K1:2.363984189,P_hexandra_M:2.363984189):0.4630447802,P_hexandra_Oahu:2.826939991):2.372081244);"
>
> 
> 
> # Load tree tr = read.tree(file="", text=trstr) tr
> 
> # Convert to phylo4 tr4 = as(tr, "phylo4")
> 
> # Looks like by default the tree is called "preorder" tr4 at order
> 
> # It works if I do this: tr4 at order = "cladewise"
> 
> # Find root (node 20) rootnode = nodeId(tr4, type="root") rootnode
> 
> # Now this works tipnames = descendants(phy=tr4, node=rootnode,
> type="tips") tipnames
> 
> 
> 
> 
> # This also works:
> 
> # Load tree tr = read.tree(file="", text=trstr) tr
> 
> # Convert to phylo4 tr4 = as(tr, "phylo4")
> 
> # Looks like by default the tree is called "preorder" tr4 at order
> 
> # It works if I do this: tr4 at order = "unknown"
> 
> # Find root (node 20) rootnode = nodeId(tr4, type="root") rootnode
> 
> # Now this works tipnames = descendants(phy=tr4, node=rootnode,
> type="tips") tipnames
> 
> 
> ...so at least there's a workaround...
> 
> Cheers, Nick
> 
> 
> 
ph
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with undefined - http://www.enigmail.net/

iQEcBAEBAgAGBQJRfD6oAAoJEOCV5YRblxUHwC0IAKFRYnR1RoYqxVf2GFQxc03R
HQAo5/N01tWBsTKZ7c4KdIk9HIhANu3F9v0trtwutUNXs/V7v3oa8QZFI9CC4Plk
2HIAox/rgwrX7yhlmKPf21KTMiiM5zHxtlCF63tkGCnwi/v/xf8IbFyqTd9ZH9NG
0xoeQTrhOLp8Lu0ARVWc1Ie01ujV+RXgJvv9RTJEhDSqeRKsYb46qhh4eFHjd4bE
qB/9P40Z4RUhV2gMXRkaPDWGWzXUhLrl1qvdPgSJ/5yQgns+g0I007452SALv3yV
mQ13Nkd/9Ze0mGUC2KjxlBiVmyDWWQQvKbJlA9eTHxZv3DPZgyg5YwiBDgf3Tsk=
=L06Y
-----END PGP SIGNATURE-----


More information about the Phylobase-devl mailing list