1

I'm trying to plot a phylogeny tree of fan type with bars of a continuous trait using plotTree.wBars in package 'phytools'.

This is the tree we use:

> dput(test_tree)
structure(list(edge = structure(c(11L, 12L, 13L, 14L, 15L, 15L, 
14L, 13L, 12L, 16L, 17L, 17L, 16L, 18L, 18L, 11L, 19L, 19L, 12L, 
13L, 14L, 15L, 1L, 2L, 3L, 4L, 16L, 17L, 5L, 6L, 18L, 7L, 8L, 
19L, 9L, 10L), .Dim = c(18L, 2L)), edge.length = c(1.757291759, 
1.830253999, 3.814729475, 1.258073906, 1.578801783, 1.578801783, 
2.836875689, 6.651605164, 0.9299003197, 4.927565734, 2.62439311, 
2.62439311, 0.5692946282, 6.982664215, 6.982664215, 6.763011651, 
3.476139272, 3.476139272), Nnode = 9L, tip.label = c("Melospiza_lincolnii", 
"Melospiza_georgiana", "Melospiza_melodia", "Passerculus_sandwichensis", 
"Ammodramus_maritimus", "Ammodramus_caudacutus", "Pooecetes_gramineus", 
"Amphispiza_belli", "Pipilo_chlorurus", "Pipilo_erythrophthalmus"
)), class = "phylo", order = "cladewise")

This is the data we wanted to plot the bars at the tip of the tree:

> bird_c
  Melospiza_lincolnii       Melospiza_georgiana         Melospiza_melodia Passerculus_sandwichensis       Pooecetes_gramineus 
             428.1096                  274.1982                  331.4227                  188.6693                  230.2079 
     Amphispiza_belli      Ammodramus_maritimus     Ammodramus_caudacutus          Pipilo_chlorurus   Pipilo_erythrophthalmus 
             171.9857                  203.9719                  241.5768                  287.9897                  183.2187 

> bird_lbm
  Melospiza_lincolnii       Melospiza_georgiana         Melospiza_melodia Passerculus_sandwichensis       Pooecetes_gramineus 
             1.282169                  1.268344                  1.511215                  1.356981                  1.378398 
     Amphispiza_belli      Ammodramus_maritimus     Ammodramus_caudacutus          Pipilo_chlorurus   Pipilo_erythrophthalmus 
             1.168792                  1.376577                  1.283301                  1.483587                  1.625312 

My code is as the following:

lbm=contMap(test_tree,bird_lbm, plot=FALSE)
plotTree.wBars(lbm$tree,bird_C*0.1,scale=0.1,method="plotSimmap",colors=lbm$cols)

I can plot a tree with bars with this code(type = phylogram), but when I change the type into fan, I keep getting error "object 'add' not found".

I have found some examples online, but I still get the same error running the examples,what does the error mean? What am I missing?

Thanks in advance.

Heidi
  • 11
  • 2
  • 1
    Please make this question *reproducible*. This includes sample code (including listing non-base R packages), sample data (e.g., `dput(head(tree))` and `bird_C` too), and expected output. Refs: https://stackoverflow.com/questions/5963269, https://stackoverflow.com/help/mcve, and https://stackoverflow.com/tags/r/info. – r2evans Dec 27 '18 at 09:07
  • 1
    I have added some sample data, thank you. – Heidi Dec 27 '18 at 10:47
  • I have solved the problem with reinstalling an older version of phytools package. The original version I use is 0.6-65, I have no error after installing version 0.6-20. – Heidi Jan 30 '19 at 12:10
  • Glad you got it to work. Since it's a version thing, you might want to look at [changes since 0.6-65](https://github.com/liamrevell/phytools/compare/5085d59e1649a4d2fcb4daea923f206c148ee43e...master), and potentially get in touch with the author ([package issues](https://github.com/liamrevell/phytools/issues)) to see if it's an unintentional code regression. If that is fruitful, it might be useful to update your question with another comment or with a self-accepted answer. – r2evans Jan 30 '19 at 16:24

0 Answers0