eaton-lab / toytree

A minimalist tree plotting library using toyplot graphs
http://eaton-lab.org/toytree
BSD 3-Clause "New" or "Revised" License
164 stars 28 forks source link

'ToyTree' object has no attribute 'drop_tips' #81

Closed isgilman closed 2 months ago

isgilman commented 3 months ago

Hello Eaton Lab,

I recently made a new conda environment and downloaded the latest version of toytree and ran into an issue: I can't find the drop_tips method for my tree objects. I checked the latest docs and it doesn't appear the syntax has changed.

[1] from platform import python_version
[2] import toyplot as tp
[3] import toytree as tt
[4] print(tp.__version__)
[5] print(tt.__version__)
[6] print(python_version())
[7] tree = tt.tree("(((A,B),C),D);")
[8] tree.drop_tips(['B'])

>> 1.0.3
>> 3.0.1
>> 3.11.9
AttributeError                            Traceback (most recent call last)
Cell In[90], line 8
      6 print(python_version())
      7 tree = tt.tree("(((A,B),C),D);")
----> 8 tree.drop_tips()

AttributeError: 'ToyTree' object has no attribute 'drop_tips'

Here is the conda package info:

$ conda list | grep "toy"
toyplot                   1.0.3              pyhd8ed1ab_0    conda-forge
toytree                   3.0.1              pyhd8ed1ab_0    conda-forge

Any suggestions would be greatly appreciated, thank you!

Ian

eaton-lab commented 3 months ago

Hi Ian,

Thanks for message. Toytree v3+ has re-organized some old functions, and introduced many new ones. The drop_tips method is now located with several other functions for modifying trees in the mod module. This can be accessed in either of the following two ways:

# example tree
tree = toytree.rtree.unittree(10)

# drop tips r0 and r1 from module-level method
new = toytree.mod.drop_tips(tree, 'r0', 'r1')

# or, drop tips r0 and r1 from tree-level method
new = tree.mod.drop_tips('r0', 'r1')

I jumped the gun a little bit on pushing this update while the docs are still being updated. The new documentation is at https://eaton-lab.org/toytree. The mod section is still in development. I am also still working on updating the old docs to provide a re-direct to the new one.

Thanks for your patience.

Best, Deren

isgilman commented 3 months ago

That worked, thank you!