veg / phylotree.js

Interactive viewer of phylogenetic trees
http://phylotree.hyphy.org
MIT License
169 stars 72 forks source link

Load a specific branch #348

Open IgnatG opened 3 years ago

IgnatG commented 3 years ago

Does anyone know if it's possible to load only a part of the tree?

See below an example where I have the full tree loaded by default. I was wondering if there is a way to load only the tree on the right-hand-side (which is a specific part of the original one)

abc

stephenshank commented 3 years ago

Dear @IgnatG,

As far as I know, this functionality does not exist in phylotree.js at present. There seems to be a function to do this in ETE3: http://etetoolkit.org/docs/latest/reference/reference_tree.html#ete3.TreeNode.prune

Let's keep this issue open since this would definitely be useful to have and others may want to chime in. Thanks for pointing out an interesting feature!

Best, Stephen

spond commented 3 years ago

Dear @IgnatG,

When you say

to load only the tree on the right-hand-side

do you mean

  1. Load the entire tree, display only a substree
  2. Load only the subtree, ie. ignore the rest of the tree when the Newick string is parsed

Best, Sergei

stephenshank commented 3 years ago

Dear @IgnatG,

Also it definitely could be done. Perhaps by programmatically hiding, see the following functionality which is part of the default user interface. I just meant that there is no equivalent function to ETE3's to do this immediately at the moment.

image

Best, Stephen

IgnatG commented 3 years ago

Dear @spond,

Ideally, it would be option 2 to avoid having to load the entire tree. But option 1 is fine as well. I don't have a personal preference as long as it achieves the goal.

My scenario is as follows: I have a newick tree saved in a variable (or file). It's a big tree so I don't want to look at the whole thing at once, but rather only on specific parts/branches at a time. This example helps as it has 2 coloured clusters:

Screenshot 2021-04-19 at 14 46 40

In this case, I'd want to look first at Cluster 1 only - so only this one would be visible at a time. But I should be able to look at Cluster 2 as well if I need to (but again, only this one would be visible). Or, I should be able to go back to see the entire tree if needed.

Let me know if this helps.

Best wishes, Gabriel

IgnatG commented 3 years ago

Dear @stephenshank ,

Yes, this is what I'm doing now. I'm actually doing it in the code as well through tree.delete_a_node(node) and it hides the branch as expected.

I was just curious to see if there is a better way of doing it as sometimes I could have multiple branches that need hiding. Of course, this can be achieved through a loop, but that's a back-up plan

Thank you for your help though!

Best wishes, Gabriel