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

Fix bounds matching for zero values #1643

Merged
merged 1 commit into from
Mar 20, 2023
Merged

Conversation

jameshadfield
Copy link
Member

This fixes a common bug for continuous scales where nodes have (valid) zero values. The bound for the first (smallest) legend entry would have zero as it's lower value, and as we strictly matched v \in [a,b) the node was never included as a match. This presented in two places:

  1. Hovering over a legend swatch would not highlight (increase the radius of) matching nodes whose value was zero
  2. The frequencies stream graph would map zeros to "unassigned" rather than their correct legend bin.

There were a few code changes needed to case (2) as we also had falsey checks (and 0 is falsey).

Note that the algorithm to create legend bounds is problematic - I'll make a separate issue about this.

This bug was first identified by Hugh Haddox, but others may have noticed it over the years?!?

The /flu/seasonal/h3n2/ha/2y dataset is useful to test this bug:

  • c=ne_star - most of the tree has zeros, none are unassigned
  • c=projected_frequency - both unassigned and zero tips.
  • c=fitness failure to match lowest legend entry due to the bug in the legend bounds creation

@nextstrain-bot nextstrain-bot temporarily deployed to auspice-legend-bound-ma-otwavd March 14, 2023 03:15 Inactive
This fixes a common bug for continuous scales where nodes have (valid)
zero values. The bound for the first (smallest) legend entry would have
zero as it's lower value, and as we strictly matched `v \in [a,b)`
the node was never included as a match. This presented in two places:
1. Hovering over a legend swatch would not highlight (increase the
radius of) matching nodes whose value was zero
2. The frequencies stream graph would map zeros to "unassigned" rather
than their correct legend bin.

There were a few code changes needed to case (2) as we also had
falsey checks (and 0 is falsey).

Note that the algorithm to create legend bounds is problematic and
should be rewritten.

This bug was first identified by Hugh Haddox, but others may have
noticed it over the years?!?

The /flu/seasonal/h3n2/ha/2y dataset is useful to test this bug:
* `c=ne_star` - most of the tree has zeros, none are unassigned
* `c=projected_frequency` - both unassigned and zero tips.
* `c=fitness` failure to match lowest legend entry due to the bug in
the legend bounds creation
@jameshadfield jameshadfield force-pushed the legend-bound-matching branch from 1983f07 to c0baa80 Compare March 14, 2023 03:21
@nextstrain-bot nextstrain-bot temporarily deployed to auspice-legend-bound-ma-otwavd March 14, 2023 03:22 Inactive
@jameshadfield
Copy link
Member Author

Top image is auspice 2.45.0 at https://nextstrain.org/flu/seasonal/h3n2/ha/2y?c=ne_star&d=tree,frequencies&p=full.
Bottom frequencies graph is this PR (same dataset).
image

Copy link
Contributor

@huddlej huddlej left a comment

Choose a reason for hiding this comment

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

Nice catch, @Haddox, and thanks for the fix, @jameshadfield! I can't speak to the code as much, but from the user experience side I have noticed the legend on-hover issue previously and assumed it was a "feature". I never noticed the frequencies panel issue with the "unassigned" label for continuous traits, since I rarely look at that kind of view in my builds (usually its frequencies of categorical labels when "unassigned" can be common and intentional).

Comparing the review app to the production app, the behavior now seems to be what I would expect.

@jameshadfield jameshadfield merged commit c5a2a90 into master Mar 20, 2023
@jameshadfield jameshadfield deleted the legend-bound-matching branch March 20, 2023 01:42
@corneliusroemer
Copy link
Member

Great catch! I had also noticed the lack of highlighting on hover for the first item in a continuous trait - but thought it may be an error on my side in making the dataset and wasn't bothered enough to create an issue (I know, it's weird as I usually open issues for everything...)

@corneliusroemer
Copy link
Member

Actually - the same bug seems to happen for minima in general, not just for 0?

When you hover over -3.62, it doesn't highlight the blue dot - the blue dot is never highlighted -> same bug?

image

https://next.nextstrain.org/nextclade/sars-cov-2/21L?c=ace2_binding

@jameshadfield
Copy link
Member Author

Actually - the same bug seems to happen for minima in general, not just for 0?

That's #1644 -- this PR fixed the bugs around comparing node values to the specified minima, and that issue describes a related bug where the minima is always set as 0 🙈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

4 participants