tag:blogger.com,1999:blog-8499895524521663926.post3443930237891742918..comments2024-04-05T07:08:38.476-04:00Comments on Phylogenetic Tools for Comparative Biology: Neat new function to color branches by trait valueLiam Revellhttp://www.blogger.com/profile/04314686830842384151noreply@blogger.comBlogger25125tag:blogger.com,1999:blog-8499895524521663926.post-3273883008304106362018-01-14T06:21:17.132-05:002018-01-14T06:21:17.132-05:00There are some companies who provide wholesome sat...There are some companies who provide wholesome satisfaction related to copying services and color printing since they focus on quality and are reasonably priced. <a href="https://www.55printing.com/cheap-color-copies/" rel="nofollow">cheap color copies online</a><br />Mona martinhttps://www.blogger.com/profile/12201262003404390577noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-48401646998342679412017-07-18T08:28:40.074-04:002017-07-18T08:28:40.074-04:00Hi Liam,
I´m a master student who is aiming to di...Hi Liam, <br />I´m a master student who is aiming to disentangle the evolution of a neotropical interaction. I used allot the functions in phytools to plot results (i.e., cophyloplot) and now I want to create a plot.phylo object that contains a tree with colored branches by the most probable ancestral-range. Then, use this tree in cophyloplot function. However, I am struggling with extract the node branching probabilities of the tree (BioGeoBears result object) for construct the x object in your function plotBranchesbyTrait. <br />Could you please guide me with a few steps on how to create the x object? <br />thank you for your time! <br />María<br /><br />Anonymoushttps://www.blogger.com/profile/00486887434113508414noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-30087349964492400892017-07-18T08:28:37.278-04:002017-07-18T08:28:37.278-04:00Hi Liam,
I´m a master student who is aiming to di...Hi Liam, <br />I´m a master student who is aiming to disentangle the evolution of a neotropical interaction. I used allot the functions in phytools to plot results (i.e., cophyloplot) and now I want to create a plot.phylo object that contains a tree with colored branches by the most probable ancestral-range. Then, use this tree in cophyloplot function. However, I am struggling with extract the node branching probabilities of the tree (BioGeoBears result object) for construct the x object in your function plotBranchesbyTrait. <br />Could you please guide me with a few steps on how to create the x object? <br />thank you for your time! <br />María<br /><br />Anonymoushttps://www.blogger.com/profile/00486887434113508414noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-40381240060237644142016-01-09T14:35:06.497-05:002016-01-09T14:35:06.497-05:00Hi Liam.
Thanks for the great posts.
I would like...Hi Liam.<br /><br />Thanks for the great posts.<br />I would like to colour the branches of a split network, instead of a tree.<br />I didn't have success with this function, probably because the object is of the class network as well.<br />Do you have some directions to help me to accomplish this?<br /><br />Thanks,<br />FernandoFernandohttps://www.blogger.com/profile/12701687770531042607noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-58683920930167740612014-09-25T10:32:35.161-04:002014-09-25T10:32:35.161-04:00Hi Liam,
I don´t know why but I get the same resu...Hi Liam,<br /><br />I don´t know why but I get the same results. It seems that something doesn´t work well, but I can´t figure out what it is. I sent you an email with my doubts. I ´d appreciate if you could help me. Thank you very much.<br />Best,<br /><br />RaquelRaquelhttps://www.blogger.com/profile/05044501168588958868noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-30614841924553205532014-09-25T06:22:39.989-04:002014-09-25T06:22:39.989-04:00This comment has been removed by the author.Raquelhttps://www.blogger.com/profile/05044501168588958868noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-81639619353421545142014-09-19T22:48:16.107-04:002014-09-19T22:48:16.107-04:00Hi Raquel.
The data should be a vector in order t...Hi Raquel.<br /><br />The data should be a vector in order tree$tip.label followed by the 1:tree$Nnode+Ntip(tree) internal nodes.<br /><br />To see what this looks like, try out:<br /><br />tree<-pbtree(n=26,tip.label=LETTERS)<br />x<-fastBM(tree,internal=TRUE)<br />x ## correct order<br />plotBranchbyTrait(tree,x,mode="nodes")<br /><br />Let me know if that works!<br /><br />- LiamLiam Revellhttps://www.blogger.com/profile/04314686830842384151noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-55081116641422728712014-09-19T12:44:54.606-04:002014-09-19T12:44:54.606-04:00Dear Liam,
I find very interesting this tool, bu...Dear Liam, <br /><br />I find very interesting this tool, but I have some problems with the mode="node". I have my nodes information done with ancestral state reconstruction previusly, and I want to plot them in the tree. I put tips and nodes in order as you explain above, but the result is not congruent. <br /><br />There are some areas of the tree that I have the same value in the tips and in the nodes and the colors of edges are not the same or similar...Is there any problem with this mode? Must tree format be in a particular way? (Cronogram, phylogram, branch-lengths) Let me know If you could help me.<br /><br />Thanks.Raquelhttps://www.blogger.com/profile/05044501168588958868noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-57640673146136445952014-06-16T21:52:06.273-04:002014-06-16T21:52:06.273-04:00Hi Carsten.
I just addressed this here. Thanks fo...Hi Carsten.<br /><br />I just addressed this <a href="http://blog.phytools.org/2014/06/computing-average-trait-value-for-set.html" rel="nofollow">here</a>. Thanks for the question.<br /><br />- LiamLiam Revellhttps://www.blogger.com/profile/04314686830842384151noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-79502945270891504732014-06-13T08:49:27.817-04:002014-06-13T08:49:27.817-04:00Dear Liam,
I managed to fix it, by adding in plot...Dear Liam,<br /><br />I managed to fix it, by adding in plotBranchTrait.R:<br /><br />if( mode == "edges" ){<br /> lab=c(tree$tip.label,tree$node.label)<br /> lab = lab[tree$edge[,2]]<br /> x = x[match(lab,names(x))]<br />}<br /><br />Furthermore the data had to be open using:<br />f=read.table("data", header=T, check.names=FALSE)<br />f = as.matrix(f)[1,]<br /><br />to be sure that the nodes names keep the hyphen.<br /><br />Cheers,<br />XavierAnonymoushttps://www.blogger.com/profile/13505534398057571397noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-12868910338130188142014-06-13T07:50:41.714-04:002014-06-13T07:50:41.714-04:00Most likely your problem is that f is not a vector...Most likely your problem is that f is not a vector. Try:<br /><br />f<-read.table("data",header=TRUE)<br />f<-as.matrix(f)[,1]<br /><br />Also, you should not load plotBranchbyTrait from source as you do. It is now part of phytools:<br /><br />rm(plotBranchbyTrait)<br /><br />All the best, LiamLiam Revellhttps://www.blogger.com/profile/04314686830842384151noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-86443171312426708642014-06-13T07:43:13.020-04:002014-06-13T07:43:13.020-04:00Dear Liam,
Thanks for your prompt answer, I do app...Dear Liam,<br />Thanks for your prompt answer, I do appreciate.<br /><br />I want to plot edges and thus removed the node a-d from the dataset, and ordered the vector by adding:<br /> x = x[tree$edge[,2]]<br />to your script.<br /><br />data:<br />a b a-b c d c-d<br />0 0 1 1 0 0<br /><br />tree.mod:<br />((a:1,b:1)a-b:1,(c:1,d:1)c-d:1)a-d;<br /><br />Ran again (with the latest version of phytools):<br /><br />R<br />library(ape)<br />library(phytools)<br />f=read.table("data", header=T)<br />f = data.matrix(f)<br />t=read.tree("tree.mod")<br />source("plotBranchbyTrait.R")<br />plotBranchbyTrait(tree=t,x=f,mode="edges",xlim=c(0,1))<br /><br />and got:<br />Error in while (p >= breaks[i] && p > breaks[i + 1]) i <- i + 1 : <br /> missing value where TRUE/FALSE needed<br /><br />Even though the vector follows the order of the edge, I still cannot make that simple example work. Do you maybe see what I am doing wrong?<br /><br />Thanks,<br /><br />XavierAnonymoushttps://www.blogger.com/profile/13505534398057571397noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-22746867395457125592014-06-12T11:34:39.648-04:002014-06-12T11:34:39.648-04:00Hi Xavier.
Yes, this is pretty straightforward.
...Hi Xavier.<br /><br />Yes, this is pretty straightforward.<br /><br />For mode edges your vector should be in the order of the rows of tree$edge. To see these edge & line them up with the plotted edges of your tree you can do:<br /><br />tree$edge<br />plotTree(tree)<br />nodelabels()<br />tiplabels()<br /><br />The plotted node labels and tip labels are the node indices in tree$edge.<br /><br />In your case, you also have 7 values in your vector but only 6 edges in the tree. It is possible that what you want to do in that case is use mode="nodes". In this case the edge color is based on the average of the tipward & rootward node of each edge. The elements in the vector should be in the numerical order of the indices of tree$edge in this case.<br /><br />Finally, you should install the latest version of phytools rather than loading the function from source.<br /><br />All the best, LiamLiam Revellhttps://www.blogger.com/profile/04314686830842384151noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-60303797546816324922014-06-12T09:36:41.265-04:002014-06-12T09:36:41.265-04:00Dr. Revell,
I am having a similar issue when plot...Dr. Revell,<br /><br />I am having a similar issue when plotting edges:<br /><br />data:<br />a b a-b c d c-d a-d<br />0 0 1 1 0 0 1 <br /><br />tree.mod:<br />((a:1,b:1)a-b:1,(c:1,d:1)c-d:1)a-d;<br /><br />Running:<br /><br />R<br />library(ape)<br />library(phytools)<br />f=read.table("data", header=T)<br />f = data.matrix(f)<br />t=read.tree("tree.mod")<br />source("plotBranchbyTrait.R")<br />plotBranchbyTrait(tree=t,x=f,mode="edges",xlim=c(0,1))<br /><br />The resulting plots does not follow the data. After having spent (much) time on trying to order the labels, I now don't have a clue.<br /><br />Thanks,<br /><br />X<br />Anonymoushttps://www.blogger.com/profile/13505534398057571397noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-89076556927528125932014-05-26T05:26:06.729-04:002014-05-26T05:26:06.729-04:00Dear Liam,
that's a great function, very usefu...Dear Liam,<br />that's a great function, very useful!. I wonder: I have a few numeric extrinsic traits variables (like e.g. extinction risk) for which I cannot assume trait evolution and where It doesn't make sense to reconstruct ancestral states. <br />My way forward for visualizing such data in phylognetic space would be to simply color all branches according to the average trait value of all tips that descend from that branch (so not accounting for branch length or anything). I can't figure our how to do this. Do you have an idea how I would have to change your function to compute for each branch the mean trait value of all its tips and assign the color accordingly?<br />Thanks a lot! Best,<br />CarstenCasihttps://www.blogger.com/profile/14891338144024746669noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-1326032354671331592014-04-17T21:32:36.615-04:002014-04-17T21:32:36.615-04:00Hi JDP.
If I remember correctly, mode="edge&...Hi JDP.<br /><br />If I remember correctly, mode="edge" just takes a vector in the order of the rows of tree$edge. Let me know if this is enough info for you to figure out how to proceed.<br /><br />If you have done ancestral state reconstructions, you might consider mode="nodes", which computes the average of the two flanking nodes to get the color for each branch. In this case, x is a vector with length(tree$tip.label)+tree$Nnode elements in the order of the node numbers in tree$edge. <br /><br />Let me know if you need help figuring this out.<br /><br />- Liam<br /><br />Liam Revellhttps://www.blogger.com/profile/04314686830842384151noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-4296984770128344022014-04-09T14:05:39.052-04:002014-04-09T14:05:39.052-04:00Dr. Revell,
This is a fantastic piece of code. Th...Dr. Revell, <br />This is a fantastic piece of code. Thanks for this. But do you think you could provide an example of the format the input data should be in to use the 'edge' mode. I have done some ancestral state reconstructions and want to color the tree with this code, however, I can't seem to get the function to perform properly with the ways in which I'm inputting the reconstructed nodes as well as tips. <br /><br />Thanks<br /><br />-JDPAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-87041797517808099262014-02-28T13:22:35.188-05:002014-02-28T13:22:35.188-05:00Dear Liam,
Thanks for sharing with us that useful ...Dear Liam,<br />Thanks for sharing with us that useful piece of code. While looking into the code I could not see any special features related to mode=="edge", while it should order the data in a particular way when considering both nodes and tips:<br />http://stackoverflow.com/questions/22100809/in-r-how-to-order-a-vector-of-data-according-to-both-tips-and-edges-of-a-phylog/22102420?noredirect=1#comment33527013_22102420<br />Can it otherwise be that I have an older version? (R 3.0.2)<br />Regards,<br />XavierAnonymoushttps://www.blogger.com/profile/13505534398057571397noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-80231012737182538842014-02-27T11:26:26.247-05:002014-02-27T11:26:26.247-05:00This comment has been removed by the author.Anonymoushttps://www.blogger.com/profile/13505534398057571397noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-8936556606801180532014-02-12T13:36:11.872-05:002014-02-12T13:36:11.872-05:00Hi John.
Are you using the correct "mode&quo...Hi John.<br /><br />Are you using the correct "mode". If your data are the data for tip taxa, then you should use mode="tips".<br /><br />Let me know if this solves your problem. If it does not, feel free to shoot me the data & code that you used to generate the error and I will look into it.<br /><br />Finally, make sure that you have the latest version of phytools (at least the most recent CRAN release).<br /><br />All the best, LiamLiam Revellhttps://www.blogger.com/profile/04314686830842384151noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-75044724223786269462014-02-05T13:12:11.952-05:002014-02-05T13:12:11.952-05:00Dr. Revell,
I encountered a problem when using th...Dr. Revell,<br /><br />I encountered a problem when using this function; it may be because I am not importing the data correctly. I uploaded a phylip tree and a data table into R, then used the following set of functions to associate the data with the tips:<br /><br /> trait<- data[1][tree$tip.label,] <br /><br /> names(trait)<-tree$tip.label<br /><br />This appeared to make a vector in the appropriate input format for the above function. However, when I called the function, the color pattern among the branches didn't jive with the data I input. To test an extreme case, I created a new vector with character values that were inflated for only a few tips ("1" for most; "5" for a few). The resulting colored tree contained "hot" branches but for the incorrect tips; the vector created appeared to show the correct order. Am I mapping the characters to the tree incorrectly? Any reply would be appreciated.<br /><br />Thanks,<br /><br />John McVay<br /><br /><br />limnonecteshttps://www.blogger.com/profile/11252650822358138786noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-48644313602033908902014-02-05T12:24:42.877-05:002014-02-05T12:24:42.877-05:00This comment has been removed by the author.limnonecteshttps://www.blogger.com/profile/11252650822358138786noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-36949443187133214472013-06-18T07:34:50.086-04:002013-06-18T07:34:50.086-04:00Dear Dr. Revell,
Great function. I had a very la...Dear Dr. Revell, <br /><br />Great function. I had a very large tree and the default edge.width of 4 was too big. Unfortunately, I couldn't set this (since it was already set). I just removed "edge.width=4" from the line 35 (I think - the plot.phylo call). Then I was able to see all the edges for a big tree and made a series of fantastic figures. Maybe removing edge.width would be useful for others. <br /><br />Thanks, <br />Daniel HanleyDaniel Hanleyhttps://www.blogger.com/profile/10537260413132788018noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-7391742513599492322013-03-15T21:22:31.822-04:002013-03-15T21:22:31.822-04:00Unfortunately, unlike my other plotting functions,...Unfortunately, unlike my other plotting functions, this function just calls plot.phylo internally - so the problem is with plot.phylo and I can't do much about it. Sorry!<br /><br />Thanks for pointing out that this could be done with the function. I hadn't realized it! More on this <a href="http://blog.phytools.org/2013/03/using-plotbranchbytrait-to-plot.html" rel="nofollow">here</a>.<br /><br />- LiamLiam Revellhttps://www.blogger.com/profile/04314686830842384151noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-13897628149315083762013-03-13T17:08:02.037-04:002013-03-13T17:08:02.037-04:00Hi Liam,
This is a great little script, I spent t...Hi Liam,<br /><br />This is a great little script, I spent the best part of two days writing some exceedingly ugly code in an attempt to do something very similar. Is there a simple fix for correctly shading the ‘horizontal’ edge lengths with plot.phylo(type = “fan”)?<br /><br />Jonathan<br />Anonymousnoreply@blogger.com