Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tree.numberprune does not seem to work #1

Closed
jakobnissen opened this issue Mar 14, 2022 · 1 comment
Closed

Tree.numberprune does not seem to work #1

jakobnissen opened this issue Mar 14, 2022 · 1 comment
Assignees

Comments

@jakobnissen
Copy link

Using version 1.5.5. MWE

import phylotreelib as pt
tree = pt.Tree.from_string("(Gorilla:3, (Human:2, (Chimpanzee:1, Bonobo:1):1):1);")
tree.numberprune(2, return_leaves=True)

Observed error:

>>> tree.numberprune(2, return_leaves=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/site-packages/phylotreelib.py", line 2192, in numberprune
    clusters = self.cluster_n(nclust=nkeep)[0]   # list containing sets of leafnames
  File "/usr/local/lib/python3.9/site-packages/phylotreelib.py", line 1825, in cluster_n
    kid_dict[kid].parent_height = pheight
AttributeError: 'Branchstruct' object has no attribute 'parent_height'
@agormp agormp self-assigned this Mar 23, 2022
@agormp
Copy link
Owner

agormp commented Mar 23, 2022

Fixed in version 1.6.2

Note: instead of number_prune() I recommend using function prune_maxlen(). This function prunes the tree such that the remaining nkeep leaves spread out the maximal percentage of branch length. The function number_prune() instead conceptually finds the height above the root where cutting the branches will result in nkeep separate clusters, and then keeps one leaf from each of these (and where leaves that are below this cutpoint - i.e. closer to the root - are considered individual clusters and are all kept also). This is highly dependent on rooting, and will not necessarily result in the most representative set of leaves. The function prune_maxlen() can instead be said to return the set of leaves that maintains the maximal phylogenetic diversity possible.

Also: I should clean up function names to be more consistent...

@agormp agormp closed this as completed Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants