tag:blogger.com,1999:blog-8499895524521663926.post8142938383287056805..comments2024-03-08T04:19:23.697-05:00Comments on Phylogenetic Tools for Comparative Biology: Projecting a phylogeny onto a geographic map showing species ranges in RLiam Revellhttp://www.blogger.com/profile/04314686830842384151noreply@blogger.comBlogger26125tag:blogger.com,1999:blog-8499895524521663926.post-23496762944929883192022-10-20T15:52:47.216-04:002022-10-20T15:52:47.216-04:00Dear Liam,
this blog is awesome,...Dear Liam,<br /> this blog is awesome, thank you very much for your generosity.<br /> I have a question regarding the possibility of plotting a phylogenetic three on several countries of South América. <br />Thank you a lot,<br /><br />FranFranciscohttps://www.blogger.com/profile/13641351474705088488noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-55220851655657583392021-09-24T18:34:38.210-04:002021-09-24T18:34:38.210-04:00Your comment here solved my problem, José, even th...Your comment here solved my problem, José, even though it had not been your intention, lol. Thank you!Fabio Hepphttps://www.blogger.com/profile/17295127712075162535noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-80666592536413547102020-12-14T13:16:33.977-05:002020-12-14T13:16:33.977-05:00Hi Liam,
I have a similar question as Hugo, is it...Hi Liam, <br />I have a similar question as Hugo, is it possible to add something like rivers to the map? Or to use custom shapefiles? <br /><br />Thanks! This is a great package and the blog posts are really helpful. <br /><br />Best, <br />MareikeAnonymoushttps://www.blogger.com/profile/02121174671558253030noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-76186629893051868272020-09-10T17:42:35.363-04:002020-09-10T17:42:35.363-04:00Hi Liam,
It is possible to used my own shapefile...Hi Liam, <br /><br />It is possible to used my own shapefiles instead of the info available in mapdata? For example, ecoregions, or any other shapefile? Or maybe just add more spatial info to the map create with phylo.to.map?<br /><br />And thanks for the updates and the awesome package. <br /><br />Hugodryashttps://www.blogger.com/profile/06864891993518885607noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-11382930919952241472020-09-02T15:24:23.770-04:002020-09-02T15:24:23.770-04:00Sure. The coordinate system of a plotted map is ju...Sure. The coordinate system of a plotted map is just the decimal degree system, so if you know the lat/long of your pies you can just add them using floating.pie in the plotrix package.Liam Revellhttps://www.blogger.com/profile/04314686830842384151noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-56482488039152579372020-09-01T18:44:07.186-04:002020-09-01T18:44:07.186-04:00hello Liam,
thanks by the script. do you have idei...hello Liam,<br />thanks by the script. do you have ideia how to make a pieplot of genetic data in the map?<br /><br />all the best!herpeto_froghttps://www.blogger.com/profile/14879812818761027738noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-70306972597089439272020-08-06T07:57:30.939-04:002020-08-06T07:57:30.939-04:00Hi Liam,
Thank you. The issue was indeed the coor...Hi Liam,<br /><br />Thank you. The issue was indeed the coordinate matrix row names not matching the tip label order. I was plotting only one clade of a tree, and so subsetting the matrix.<br /><br />Curious that the links mapped and were plotted correctly, just not the tip labels...<br /><br />All the best,<br />ChrisAnonymoushttps://www.blogger.com/profile/12717893201272348335noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-40618276277404631482020-07-27T10:24:59.353-04:002020-07-27T10:24:59.353-04:00Hi Chris.
Is it possible that your input lat/long...Hi Chris.<br /><br />Is it possible that your input lat/long data are in a data frame, instead of a matrix?<br /><br />Alternatively, the row labels may not match the tip labels of the tree. This would also explain the error.<br /><br />Please let me know what you find.<br /><br />All the best, LiamLiam Revellhttps://www.blogger.com/profile/04314686830842384151noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-27055494358629754952020-07-27T09:09:25.486-04:002020-07-27T09:09:25.486-04:00Hi Liam,
I’ve encountered a problem I’ve not seen...Hi Liam,<br /><br />I’ve encountered a problem I’ve not seen others have.<br /><br />I can reproduce your example almost perfectly using my own data; tree, map and links all present and correct when plotted.<br /><br />However, I only get one tip label displayed (the first alphabetically), and all others blank, but spaced correctly based on where the links start. I get this error when I plot:<br /><br />Error in colors[cw$tip.label, ] : subscript out of bounds<br /><br />I can’t get to the bottom of it, might you have an idea?<br /><br />Thank you in advance, and thanks for phytools, such a great package.<br /><br />All the best,<br />ChrisAnonymoushttps://www.blogger.com/profile/12717893201272348335noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-69807490356502598952020-05-07T19:26:00.441-04:002020-05-07T19:26:00.441-04:00Cheers, Liam. How are you? I am trying to project ...Cheers, Liam. How are you? I am trying to project a phylogeny onto a geographic map showing species ranges, but I always obtain the following error:<br />Error in res[edge[i, 2]] <- res[edge[i, 1]] + el[i] : <br /> replacement has length zero<br /><br />Here my procedure:<br />plebejum.tree <- read.tree(file = 'exp6.tre')<br />plebejum.tree<br />plot(ladderize(plebejum.tree), edge.width = 3)<br /><br />#prunning:<br />outgroups <- c('B.sanctulum_var1', 'B.sanctulum', 'B.denticolle',<br /> 'B.denticolle_var1', 'B.denticolle_var2', 'B.amazonum', 'B.amazonum_var1',<br /> 'B.minor', 'B.minor_var1', 'B.oxyurum', 'B.oxyurum_var1',<br /> 'B.horvathi', 'B.candidulum', 'B.candidulum_var1')<br />plebejum <- drop.tip(plebejum.tree, outgroups)<br />Phylogenetic tree with 16 tips and 15 internal nodes.<br /><br />Tip labels:<br /> B.parvum, B.micantulum, B.micantulum_var1, B.estevezae, B.lariversi, B.lariversi_var1, ...<br /><br />Rooted; no branch lengths.<br /><br />plot(ladderize(plebejum), edge.width = 3)<br />#####<br />todos <- read.csv(file.choose(), h = T, sep = ',', dec = '.')<br />todos<br />species Latitude Longitude<br />1 B.estevezae -10.750000 -50.92000<br />2 B.estevezae -29.430631 -53.25316<br />3 B.estevezae -30.334212 -54.36244<br />4 B.lariversi -6.660000 -69.87000<br />5 B.lariversi -10.469700 -50.50310<br />6 B.lariversi_var1 -17.340000 -44.93000<br />7 B.micantulum -1.450000 -48.37000<br />8 B.micantulum -7.500000 -65.90000<br />9 B.micantulum -6.838610 -35.12610<br />10 B.micantulum -7.115000 -34.86310<br />11 B.micantulum -11.858100 -55.50560<br />12 B.micantulum -18.755000 -40.89080<br />13 B.micantulum -19.391100 -40.07220<br />14 B.micantulum -22.382300 -41.77540<br />15 B.micantulum_var1 -7.700000 -57.60000<br />...<br /><br /><br />lat <- todos[,2]<br />long <- todos[,3]<br />names(lat) <- todos$species<br />names(long) <- todos$species<br />locais <- cbind(lat, long)<br />locais<br /> lat long<br />B.estevezae -10.750000 -50.92000<br />B.estevezae -29.430631 -53.25316<br />B.estevezae -30.334212 -54.36244<br />B.lariversi -6.660000 -69.87000<br />B.lariversi -10.469700 -50.50310<br />B.lariversi_var1 -17.340000 -44.93000<br />B.micantulum -1.450000 -48.37000<br />B.micantulum -7.500000 -65.90000<br />B.micantulum -6.838610 -35.12610<br />B.micantulum -7.115000 -34.86310<br />B.micantulum -11.858100 -55.50560<br />B.micantulum -18.755000 -40.89080<br />...<br /><br />cols<-setNames(sample(viridis(n = Ntip(plebejum))),<br /> plebejum$tip.label)<br />cols<br />obj <- phylo.to.map(tree = plebejum, coords = locais, database = "worldHires",<br /> regions = c("Brazil", 'Argentina', 'Colombia', 'Venezuela',<br /> 'Peru', 'Paraguay', 'Bolivia', 'Chile', 'Uruguay',<br /> 'Suriname', 'Guyana', 'Ecuador'),<br /> plot = FALSE, direction = "rightwards")<br />obj<br /><br />plot(obj, direction="rightwards",<br /> colors = cols, cex.points = c(0, 1), lwd = c(3, 1), ftype = "i")<br /><br />The problem is that the tree is not staying together with the map of Brazil. Thank you in advance for considering this matter. My best regards, José Ricardo.Anonymoushttps://www.blogger.com/profile/17538882906021188783noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-6818606363224704342020-04-28T09:46:34.676-04:002020-04-28T09:46:34.676-04:00Hi Liam,
I have been using phytools for a while n...Hi Liam,<br /><br />I have been using phytools for a while now and it really is a fantastic tool. <br /><br />Is there any method of making the colouration for each point dependant on the clade it is with. I currently have a phylogeny containing multiple samples from seperate species, and rather than colouring each sample indivudually I am looking to group colour tips/samples within certain nodes. <br /><br />Is this possible?<br /><br />Thanks,<br /><br />Williamwilliamhttps://www.blogger.com/profile/08605625110390402071noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-92017141879636322302019-11-01T17:48:10.689-04:002019-11-01T17:48:10.689-04:00Andrés, did you try converting your data frame of ...Andrés, did you try converting your data frame of coordinates to a matrix as I advised above (this can be done using the function as.matrix)? This is most likely your problemLiam Revellhttps://www.blogger.com/profile/04314686830842384151noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-76909340056490931032019-11-01T16:34:08.207-04:002019-11-01T16:34:08.207-04:00Hi Liam. I'm having a similar problem. I have ...Hi Liam. I'm having a similar problem. I have multiple coordinates per species, so when I try to assign the rownames() to the matrix it ads a sequential number to the names (e.g. species.1, especies.2, ect.), this ends in a "objective: 0". Any recommendation to deal with the duplicates in the row names of a matrix?Andréshttps://www.blogger.com/profile/04202482231509685710noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-6554035021566541102019-05-01T01:56:13.354-04:002019-05-01T01:56:13.354-04:00Hi Liam! thanks for your great contribution! I was...Hi Liam! thanks for your great contribution! I was trying to use phylo.to.map with different map projections (E.g. Lambert) available in the package maps, with no success. Is phylo.to.map using a particular projection as a default? Nicolashttps://www.blogger.com/profile/05365462765258212747noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-25706237202098892342019-04-14T10:40:32.125-04:002019-04-14T10:40:32.125-04:00In your example:
coords<-as.matrix(lat.long[2:...In your example:<br /><br />coords<-as.matrix(lat.long[2:3])<br />rownames(coords)<-x<br /><br />All the best, LiamLiam Revellhttps://www.blogger.com/profile/04314686830842384151noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-52424897858514210992019-04-13T23:39:46.718-04:002019-04-13T23:39:46.718-04:00Thank you, Dr Revell, but How I can do that? Thank you, Dr Revell, but How I can do that? MAGChttps://www.blogger.com/profile/13693835464075439827noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-5539357712867945142019-04-13T07:14:35.014-04:002019-04-13T07:14:35.014-04:00The problem may be that your matrix should have th...The problem may be that your matrix should have the species names as row names, not as a separate column. Try assigning the species names as the row names of your matrix & see if that works.Liam Revellhttps://www.blogger.com/profile/04314686830842384151noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-84479459050987765972019-04-13T01:20:05.441-04:002019-04-13T01:20:05.441-04:00Dr. Revell, thank you for your answer, I appreciat...Dr. Revell, thank you for your answer, I appreciate very much your work, It's amazing! Thank you<br />as.matrix Didn't work :(<br />> lat.long=read.table(file.choose(), sep=',', head=T, rownames=NULL)<br />> head(lat.long)<br /> X lat long X.1 X.2 X.3 X.4 X.5 X.6 X.7 X<br />1 acutus 19.36117 -101.5737 NA NA NA NA NA NA NA <br />2 acutus 19.51342 -101.6574 NA NA NA NA NA NA NA <br />3 acutus 19.51342 -101.6574 NA NA NA NA NA NA NA <br />4 acutus 19.46861 -101.5619 NA NA NA NA NA NA NA <br />5 acutus 19.46861 -101.5619 NA NA NA NA NA NA NA <br />6 acutus 19.46861 -101.5619 NA NA NA NA NA NA NA<br />>> x=as.vector(lat.long$X)<br />> x<br /> [1] "acutus" "acutus" "acutus" "acutus" "acutus" <br /> [6] "acutus" "acutus" "acutus" "acutus" "acutus" <br /> [11] "acutus" "acutus" "acutus" "acutus" "acutus" <br />> data=as.matrix(lat.long[2:3])<br />> head(data)<br /> lat long<br />[1,] 19.36117 -101.5737<br />[2,] 19.51342 -101.6574<br />[3,] 19.51342 -101.6574<br />[4,] 19.46861 -101.5619<br />[5,] 19.46861 -101.5619<br />[6,] 19.46861 -101.5619<br />> is.matrix(data)<br />[1] TRUE<br />> coords=cbind(x,data)<br />> head(coords)<br /> x lat long <br />[1,] "acutus" "19.3611667" "-101.5736667"<br />[2,] "acutus" "19.5134167" "-101.6574444"<br />[3,] "acutus" "19.5134167" "-101.6574444"<br />[4,] "acutus" "19.4686056" "-101.56195" <br />[5,] "acutus" "19.4686056" "-101.56195" <br />[6,] "acutus" "19.4686056" "-101.56195" <br />> is.matrix(coords)<br />[1] TRUE<br />>objplot(obj,direction="rightwards",colors=cols,cex.points=c(0,1),lwd=c(3,1),ftype="i")<br />Error in coords[cw$tip.label, 2:1] : subscript out of bounds<br /><br />MAGChttps://www.blogger.com/profile/13693835464075439827noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-15272067786956455732019-04-12T23:59:21.275-04:002019-04-12T23:59:21.275-04:00Try as.matrix( ).Try as.matrix( ).Liam Revellhttps://www.blogger.com/profile/04314686830842384151noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-59039319703601273302019-04-12T23:29:37.820-04:002019-04-12T23:29:37.820-04:00@kwgray Hello, How did you resolve it?@kwgray Hello, How did you resolve it?MAGChttps://www.blogger.com/profile/13693835464075439827noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-35684906815030344882019-04-08T12:08:33.653-04:002019-04-08T12:08:33.653-04:00This should already be possible. I'll try to r...This should already be possible. I'll try to remember to post a tutorial showing how when I get a chance.Liam Revellhttps://www.blogger.com/profile/04314686830842384151noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-77583722955427906202019-04-08T12:00:26.982-04:002019-04-08T12:00:26.982-04:00Great contribution, as usual, Liam. Have you had a...Great contribution, as usual, Liam. Have you had any requests to apply colors across clades, rather than across tips? From the figures I've seen so far, each tip receives a unique color. In the polygon figure above, the individual coordinate info is lost due to the collapsing of the clades. Cheers.evozoahttps://www.blogger.com/profile/02734603960419870631noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-59985162734734986152019-04-03T10:57:05.744-04:002019-04-03T10:57:05.744-04:00Yup, that's it!Yup, that's it!Liam Revellhttps://www.blogger.com/profile/04314686830842384151noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-42991611121542689842019-03-20T10:00:19.938-04:002019-03-20T10:00:19.938-04:00Hi Liam, those polygons are simply beautiful!
I ha...Hi Liam, those polygons are simply beautiful!<br />I have some questions about phylo.to.map object and its posterior plotting:<br />I am trying to plot single locations of some primate species on a map, but I'd like to plot just Africa, Asia and some parts of Oceania. I've seen your example pruning Isla de Pascua from a Chile map, but that method doesn't seem to be working. I've checked every region included in the map and its respective code, and unsuccessfully tried to supress the ones I didn't need. Do you know how could I eliminate America and Europe from the world map? (Virtually speaking of course haha). This is some example of what I've been trying:<br /><br />tree<-read.tree("arbol30sp.nwk")<br />plotTree(tree, ftype = "i", lwd = 0.5)<br /><br />geo<-read.csv("Locations.csv", h = T, row.names = 1)<br />geo<-as.matrix(geo)<br /><br />match<-match.phylo.data(tree, geo)<br />#[1] "Dropping tips from the tree because they are not present in the data:"<br />#[1] "Homo_sapiens"*<br />sp29<-match$phy<br /><br />obj<-phylo.to.map(sp29,geo,regions=".",direction="rightwards", plot = FALSE)<br /><br />ii<-which(obj$map$x<c(2,3,4,11,12,13,14,15,16,21,22,23,24,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,182,183,184,185,186,188,189,190,191,192,193,194,195,196,198,240,241,242,243,244,418,419,420,421,422,423,424,425,426,427,428,429,430,431,432,433,434,435,439,440,441,442,443,444,445,446,447,448,449,471,486,496,497,498,499,516,569,593,595,596,597,598,599,600,601,602,603,604,605,606,668,669,670,692,693,694,695,696,697,698,699,700,701,702,703,704,705,706,707,708,709,710,711,712,713,714,715,716,717,718,719,720,721,722,723,724,725,726,727,728,729,730,731,732,733,734,735,736,737,738,739,740,741,742,743,744,745,746,747,748,749,750,751,752,753,754,755,756,757,758,759,760,761,762,763,764,765,766,767,768,769,770,771,772,773,774,775,776,777,778,779,780,781,782,783,784,785,786,787,788,789,790,791,792,793,794,795,796,797,798,799,800,801,802,803,804,805,806,807,808,809,810,811,812,813,814,815,816,817,818,819,820,821,822,823,824,826,827,828,829,830,831,832,833,834,835,836,837,838,839,846,847,848,849,850,851,862,863,864,865,866,867,868,869,870,871,872,873,874,875,876,877,878,879,880,881,882,883,884,885,886,887,888,889,890,891,892,893,894,895,896,897,898,899,900,901,902,903,904,905,906,907,908,909,910,932,933,934,935,936,937,938,939,940,941,942,944,945,946,947,948,949,952,953,954,955,960,962,963,964,965,966,967,968,969,992,995,996,997,998,999,1000,1001,1002,1003,1004,1005,1006,1007,1008,1009,1010,1011,1012,1013,1015,1022,1023,1024,1025,1026,1028,1029,1030,1031,1032,1033,1034,1035,1036,1037,1038,1039,1040,1041,1048,1050,1051,1098,1113,1114,1115,1116,1117,1125,1126,1127,1128,1129,1130,1131,1132 #And so on#))<br />obj$map$x<-obj$map$x[ii]<br />obj$map$y<-obj$map$y[ii]<br /><br />plot(obj,direction="rightwards",fsize = 0.4, ftype="i", lwd = 0.3)Guido R.https://www.blogger.com/profile/16302457923124716560noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-43484733343227385422019-03-19T18:46:05.739-04:002019-03-19T18:46:05.739-04:00I figured out my problem! I need a matrix for the ...I figured out my problem! I need a matrix for the coordinates, not a data frame.kwgrayhttps://www.blogger.com/profile/03412306797106161399noreply@blogger.com