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

#1008 split tree and group into subtrees by state #1105

Open
wants to merge 40 commits into
base: master
Choose a base branch
from

Conversation

frogsquire
Copy link
Contributor

@frogsquire frogsquire commented May 4, 2020

Outstanding issues I am still working on:

  • Branches not within subtrees need to be hidden, and branches that within subtrees need to be rendered correctly. I think this is the biggest issue remaining.
  • Zooming the tree doesn't look quite right yet, partially because of the branches, I think.
  • I haven't disabled this functionality when not using the rectangular layout (or forced the tree to a rectangular layout - which do we prefer?).
  • I haven't tested situations like multiple trees enabled, or extensive zooming/filtering.
  • I'm not yet really handling nodes that have no value for the given trait. They get shoved to the bottom for now; what do we want to do with them?

Some other points following up on our discussion:

  • The subtrees are ordered from top to bottom by the num_date trait. This seems to work quite well visually, I think.
  • It doesn't look like I need offsets to make the data look reasonable, at least with the ncov dataset. With more sparse datasets, perhaps it'd be helpful, but the tree resizing should take care of making it look nice.
  • I'd appreciate any further suggestions on how to improve the efficiency of what I'm doing here; I've taken @jameshadfield's suggestions and tried to run with them, but I want to be sure I am producing something that will meet our needs. Specifically:
    -- I couldn't find a way to run this code without updating the layout, and without using the modifySVGInStages approach. This makes the transition when flipping the checkbox on and off pretty slow. Would love to improve this.
    -- Any optimizations of the tree traversal/subtree data gathering process would be appreciated.
    -- I need to do some code cleanup/quality improvements (for example, using a dictionary or trait-indexed array instead of a custom object to store the subtrees), run the linter, etc. Would appreciate any suggestions on this front as well.

I will continue working on this over the coming days, but wanted to update on my progress again. Thanks!

@frogsquire frogsquire changed the title 1008 split by state - progress update #1008 split by state - progress update May 4, 2020
@frogsquire
Copy link
Contributor Author

frogsquire commented May 10, 2020

@jameshadfield @evogytis Just wanted to check in on this -- any thoughts? At a point where I want to be sure this is a good direction before doing more.

@evogytis
Copy link
Contributor

Hey @frogsquire, I checked the branch as of 2870aa3 and this is what I get (this is DENV1 dataset):
Screenshot 2020-05-11 at 08 43 57

What I'm seeing is missing internal nodes. This is what it should look like roughly (colours and sorting might differ, but the look of each subtree shouldn't):
download (26)

@trvrb
Copy link
Member

trvrb commented May 12, 2020

Very exciting to see this progress @frogsquire. 😀 I see the same issue as Gytis with deeper nodes missing connections. I think for ordering subtrees I would do:

  1. First order based on legend ordering. In the attached it would be China, Hong Kong, Taiwan, etc...
  2. Within these color blocks, order by num_date as you propose above.

Screen Shot 2020-05-11 at 10 23 18 PM

@jameshadfield jameshadfield temporarily deployed to auspice-1008-split-by-s-kpz2xb May 13, 2020 06:13 Inactive
{
args.splitTreeByTrait = newProps.tree.splitTreeByTrait;
if (args.splitTreeByTrait == null) {// if the split is being unset, reset the layout
// todo: could use updateLayout instead?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's revisit this, and exactly how we're using d3 to update the DOM (e.g. transitions) once the algorithm is working correctly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update on this - the d3 transition is working reasonably well for turning the toggle off. For turning it on, it still looks a bit jerky.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jameshadfield, if you feel we are at this point, do you have any thoughts on why the transition is still not smooth when enabling the toggle (though it is smooth at all other times)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll look into this shortly, as I do think we're at this point 😄

…e all children before pushing node onto subtree stack to improve ordering
@jameshadfield jameshadfield temporarily deployed to auspice-1008-split-by-s-kpz2xb May 14, 2020 02:51 Inactive
@jameshadfield jameshadfield temporarily deployed to auspice-1008-split-by-s-kpz2xb May 16, 2020 22:00 Inactive
…t trait data; unhide them when turning split mode off
@jameshadfield jameshadfield temporarily deployed to auspice-1008-split-by-s-kpz2xb May 17, 2020 16:38 Inactive
frogsquire added 16 commits May 24, 2020 13:45
…e all children before pushing node onto subtree stack to improve ordering
…t trait data; unhide them when turning split mode off
@frogsquire
Copy link
Contributor Author

frogsquire commented May 24, 2020

@jameshadfield Please see the attached image diffs from the integration tests. The only differences I can see is that there's some issues with font aliasing between my machine and the reference images, and that the UI has been altered because of the new toggle.

If these look acceptable to you, let me know, and I can work on the font issue (according to this and the terminal output I've gotten, I may just need to reinstall some fonts) and provide new reference images.

Color-by-author-diff
Color-by-country-diff
Color-by-date-diff
Color-by-region-diff

@frogsquire frogsquire changed the base branch from master to adjust-deme-size May 25, 2020 00:40
@frogsquire frogsquire changed the base branch from adjust-deme-size to master May 25, 2020 00:40
@frogsquire
Copy link
Contributor Author

Base changed and changed back because I ran into this issue.

@jameshadfield jameshadfield temporarily deployed to auspice-1008-split-by-s-qtutep May 25, 2020 03:49 Inactive
jameshadfield added a commit that referenced this pull request Dec 22, 2021
Introduces the ability to cut trees at various branches and display the resulting trees as subtrees. These cut points are here defined to be a change in a (user-selected) state trait, which are simply the non-continuous colourings (to start with).

Briefly, given a parent node (A) with children (B,C), and a change in trait moving from (A->B), we add B to the children of the overall tree root, and update the children of A to be only C. We store the original children (B,C) so that we can return to the starting state.

This implementation, specifically the ability for PhyloTree to update the node ordering, should allow for branch rotations in the future.

There are a number of future improvements to be made in subsequent commits:
* The subtrees should be ordered on trait (or we may wish to make this a toggle)
* the stem length of subtrees is inconsistent
* exploded trait cannot be stored in URL state
* we should limit the explode options to those colourings which are defined on internal nodes (currently a warning is shown)
* genotype should be available to explode on
* remove console logging introduced here
* consider undefined (internal) traits, e.g. currently nodes (X -> undefined -> Y) would not be exploded
* multiple trees are not considered here

Prior art: I was first made aware of this style of tree rendering by Gytis Dudas. An implementation was attempted by @frogsquire<https://github.com/frogsquire> in #1105 and this commit uses ideas introduced there.
@jameshadfield jameshadfield mentioned this pull request Dec 22, 2021
13 tasks
jameshadfield added a commit that referenced this pull request Jan 30, 2022
Introduces the ability to cut trees at various branches and display the resulting trees as subtrees. These cut points are here defined to be a change in a (user-selected) state trait, which are simply the non-continuous colourings (to start with).

Briefly, given a parent node (A) with children (B,C), and a change in trait moving from (A->B), we add B to the children of the overall tree root, and update the children of A to be only C. We store the original children (B,C) so that we can return to the starting state.

This implementation, specifically the ability for PhyloTree to update the node ordering, should allow for branch rotations in the future.

There are a number of future improvements to be made in subsequent commits:
* The subtrees should be ordered on trait (or we may wish to make this a toggle)
* the stem length of subtrees is inconsistent
* exploded trait cannot be stored in URL state
* we should limit the explode options to those colourings which are defined on internal nodes (currently a warning is shown)
* genotype should be available to explode on
* remove console logging introduced here
* consider undefined (internal) traits, e.g. currently nodes (X -> undefined -> Y) would not be exploded
* multiple trees are not considered here

Prior art: I was first made aware of this style of tree rendering by Gytis Dudas. An implementation was attempted by @frogsquire<https://github.com/frogsquire> in #1105 and this commit uses ideas introduced there.
jameshadfield added a commit that referenced this pull request Feb 9, 2022
Introduces the ability to cut trees at various branches and display the resulting trees as subtrees. These cut points are here defined to be a change in a (user-selected) state trait, which are simply the non-continuous colourings (to start with).

Briefly, given a parent node (A) with children (B,C), and a change in trait moving from (A->B), we add B to the children of the overall tree root, and update the children of A to be only C. We store the original children (B,C) so that we can return to the starting state.

This implementation, specifically the ability for PhyloTree to update the node ordering, should allow for branch rotations in the future.

There are a number of future improvements to be made in subsequent commits:
* The subtrees should be ordered on trait (or we may wish to make this a toggle)
* the stem length of subtrees is inconsistent
* exploded trait cannot be stored in URL state
* we should limit the explode options to those colourings which are defined on internal nodes (currently a warning is shown)
* genotype should be available to explode on
* remove console logging introduced here
* consider undefined (internal) traits, e.g. currently nodes (X -> undefined -> Y) would not be exploded
* multiple trees are not considered here

Prior art: I was first made aware of this style of tree rendering by Gytis Dudas. An implementation was attempted by @frogsquire<https://github.com/frogsquire> in #1105 and this commit uses ideas introduced there.
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

Successfully merging this pull request may close these issues.

4 participants