tag:blogger.com,1999:blog-8499895524521663926.post958274064078886587..comments2024-03-27T07:13:39.236-04:00Comments on Phylogenetic Tools for Comparative Biology: Function to get the sister(s) of a node or tipLiam Revellhttp://www.blogger.com/profile/04314686830842384151noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-8499895524521663926.post-88868266758883078272017-05-03T05:53:49.816-04:002017-05-03T05:53:49.816-04:00goodgoodJens C. Krusehttps://www.blogger.com/profile/06928934543082018334noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-3425130575377250602016-11-30T06:33:36.865-05:002016-11-30T06:33:36.865-05:00Hi Liam,
This is really useful. Is it possible to...Hi Liam,<br /><br />This is really useful. Is it possible to get all the sister species from a multiphylo object?<br />Andreia Miraldohttps://www.blogger.com/profile/14207565027207827019noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-21942339553260786742016-08-15T11:21:32.152-04:002016-08-15T11:21:32.152-04:00Hi Emma. sisters is redundant with functions in ph...Hi Emma. sisters is redundant with functions in phangorn, which are probably faster.<br /><br />You might get a table with all pairs of sister species in a bifurcating tree using phangorn & apply family functions as follows:<br /><br />dd<-lapply(1:tree$Nnode+Ntip(tree),function(n,t)<br /> Descendants(t,n)[[1]],t=tree)<br />nodes<-c(1:tree$Nnode+Ntip(tree))[which(sapply(dd,length)==2)]<br />sisters<-t(sapply(nodes,function(n,t) <br /> t$tip.label[Descendants(t,n)[[1]]],t=tree))<br /><br />- LiamLiam Revellhttps://www.blogger.com/profile/04314686830842384151noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-80564368238348195462016-08-15T00:05:47.869-04:002016-08-15T00:05:47.869-04:00A useful little utility function, thanks Liam!
Th...A useful little utility function, thanks Liam!<br /><br />Thought I'd just post a little code I use with this utility function to find all of the sister species pairs in a tree (Only works for fully resolved, but can be easily modified for polytomies)<br /><br /># find only sister-species pairs<br /> sisters <- matrix(NA, ncol=2, nrow=length(tree$tip.label)) # empty matrix<br /> sisters[,1] <- tree$tip.label # populate first column with tip.labels<br /> for(i in 1:length(tree$tip.label)){<br /> tmp <- phytools::getSisters(tree, tree$tip.label[i], mode="label")<br /> if(!is.null(tmp$tips)){sisters[i,2] <- tmp$tips}<br /> }<br /> sisters <- sisters[-which(is.na(sisters[,2])),] # prune away tips that do not have a labelled tip as sister<br />Emma Sherratthttps://www.blogger.com/profile/10593440736673735935noreply@blogger.com