[Phylobase-devl] path between two tips
François Michonneau
francois.michonneau at gmail.com
Thu Nov 20 21:25:48 CET 2008
Yes I committed the patch (revision 288).
- François
On Thu, 2008-11-20 at 14:58 -0500, Brian O'Meara wrote:
> The MRCA error may relate to this bug (<http://r-forge.r-project.org/
> tracker/index.php?func=detail&aid=177&group_id=111&atid=488>) which
> Francois has a patch for, but I haven't checked to see if it's
> committed.
>
> Brian
>
> On Nov 20, 2008, at 2:54 PM, Thibaut Jombart wrote:
>
> > Peter Cowan wrote:
> >> There is a function for calculating the MRCA. Line 101 of the
> >> treewalk.R file. Perhaps this is helpful.
> >>
> >> Peter
> > Yes, it is. I used it in the function:
> >
> > shortestPath <- function(x, node1, node2){
> > if(!require(phylobase)) stop("phylobase package is not installed")
> >
> > ## conversion from phylo, phylo4 and phylo4d
> > x <- as(x, "phylo4")
> >
> > ## check phylo4 object
> > if (is.character(checkval <- check_phylo4(x))) stop(checkval)
> >
> > ## main computations
> > t1 <- getnodes(x, node1)
> > t2 <- getnodes(x, node2)
> >
> > comAnc <- MRCA(x, t1, t2) # common ancestor
> > desComAnc <- descendants(x, comAnc, which="all")
> > ancT1 <- ancestors(x, t1, which="all")
> > path1 <- intersect(desComAnc, ancT1) # path: common anc -> t1
> >
> > ancT2 <- ancestors(x, t2, which="all")
> > path2 <- intersect(desComAnc, ancT2) # path: common anc -> t2
> >
> > res <- union(path1, path2) # union of the path
> > res <- c(comAnc,res) # add the common ancestor
> > res <- getnodes(x, res)
> >
> > return(res)
> > } # end shortestPath
> >
> > Example:
> > ##
> > tr=as(rtree(20),"phylo4")
> > plot(tr, show.node=T)
> > shortestPath(tr,"t1","t2")
> > ##
> >
> > It works for tips, but some pb occur with internal nodes.
> > The pb seems to come from MRCA. For instance:
> > ##
> > data(geospiza)
> > plot(as(geospiza,"phylo4"), show.node=T)
> > shortestPath(geospiza, "N02","N05")
> > MRCA(geospiza, "N02","N05")
> > ##
> >
> > MRCA returns N01 (the root) instead of N02.
> >
> >
> > Best,
> >
> > Thibaut.
> >
> > --
> > ######################################
> > Dr Thibaut JOMBART
> > CNRS UMR 5558 - Laboratoire de Biométrie et Biologie Evolutive
> > Universite Lyon 1
> > 43 bd du 11 novembre 1918
> > 69622 Villeurbanne Cedex
> > Tél. : 04.72.43.29.35
> > Fax : 04.72.43.13.88
> > jombart at biomserv.univ-lyon1.fr
> > http://biomserv.univ-lyon1.fr/%7Ejombart/
> > http://adegenet.r-forge.r-project.org/
> >
> > _______________________________________________
> > 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
>
>
> ________________________________
> Brian O'Meara
> NESCent
> Durham, NC
> http://www.brianomeara.info
> ________________________________
>
>
>
> _______________________________________________
> 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