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

Enforce unnormalized frequencies when data is lacking #1278

Merged
merged 4 commits into from
Mar 12, 2021

Conversation

trvrb
Copy link
Member

@trvrb trvrb commented Jan 27, 2021

Description of proposed changes

This commit forces controls.normalizeFrequencies to be false if there are any pivots where the total frequency is less than 0.1%.

This addresses two issues:

  1. In the existing code, attempting to normalize situations where pivots have 0% total frequency results in bad looking "all equal" bands. This commit removes the capacity to get into this bad looking app state.
  2. When filtering to a particular clade, we often want to switch to unnormalized frequencies anyway (as opposed to filtering to geography). This commit accomplishes this automatically because filtering to an emerging clade will generally result in pivots with <0.1% frequency.

Related issue(s)

Fixes #1225

Testing

Tested locally through npm run dev.

@jameshadfield --- I'm still not great at redux dataflow and there are places where I set controls.normalizeFrequencies = false that may need to be corrected. Everything seemed to work as it should in my testing, but that's not a guarantee that I'm not doing something wrong.

This commit forces controls.normalizeFrequencies to be false if there are any pivots where the total frequency is less than 0.1%.

This addresses two issues:
1. In the existing code, attempting to normalize situations where pivots have 0% total frequency results in bad looking "all equal" bands. This commit removes the capacity to get into this bad looking app state.
2. When filtering to a particular clade, we often want to switch to unnormalized frequencies anyway (as opposed to filtering to geography). This commit accomplishes this automatically because filtering to an emerging clade will generally result in pivots with <0.1% frequency.
@jameshadfield jameshadfield temporarily deployed to auspice-frequencies-def-mldq3u January 27, 2021 05:45 Inactive
@trvrb trvrb added enhancement New feature or request high priority labels Jan 27, 2021
@trvrb
Copy link
Member Author

trvrb commented Feb 12, 2021

Hi @jameshadfield I know you have a million priorities right now, if this is a quick review, I'd love some attention here. Filters like https://nextstrain.org/ncov/global?gt=S.501Y or https://nextstrain.org/ncov/global?f_clade_membership=20H/501Y.V2 are super common now, but the resulting rainbow band in the frequencies panel looks pretty broken.

I just noticed this when I was interested in frequency of B.1.1.7 across Europe and how this mapped across countries. This was the app state I made for this question: https://nextstrain.org/ncov/europe?dmin=2021-01-01&f_region=Europe showing just samples after Jan 1, but this results in the unfortunate rainbow banding:

501y

Previous implementation continued to display the toggle icon but disabled its functionality (by forcing `normalizeFrequencies` to be `false`). Here we replace the toggle with a "not available" message & update the info-popup text.
Upon initial parsing of the frequencies JSON as well as frequency data updates we may set redux→controls→normalizeFrequencies→false. This commit modifies the LOAD_FREQUENCIES and FREQUENCY_MATRIX actions to pass this information to the reducer, rather than updating the redux state directly from within the actions.

I couldn't find any bugs caused by the previous implementation, but this change is more in line with suggested behaviour and should help future-proof work here.
The frequencies component performed some basic comparisons between the previously rendered data and new data to avoid unnecessary re-renders. This logic was too simplistic and caused a bug where the component wouldn't re-render the graph when the data had indeed changed. This commit skips these checks. This may result in some unnecessary re-renders, however I couldn't find any in my testing.

Closes #1224
@jameshadfield
Copy link
Member

This looks great! I added a few small commits to

  • bbef8f8 display that frequencies cannot be normalized in the sidebar, rather than rendering a toggle that didn't work
  • 0de2197 no changes to behaviour, but uses a more redux-y pattern of updating state via reducers
  • 658f8dc fix a nasty 🐛 where the frequency panel wouldn't update. Not technically part of this PR, but that's where I ended up doing the work.

Closes #1224
Closes #1225

@trvrb trvrb temporarily deployed to auspice-frequencies-def-higgws March 10, 2021 21:47 Inactive
@trvrb
Copy link
Member Author

trvrb commented Mar 10, 2021

Fantastic! Thanks for the additional cleanup here @jameshadfield. And thanks for the redux help. This is ready to be merged from my perspective.

@trvrb trvrb merged commit 058d23f into master Mar 12, 2021
@trvrb trvrb deleted the frequencies-default branch March 12, 2021 00:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Frequency Panel Shows 'All Equal' Before Estimated Date of Ancestor on Zoomed-in Cluster
2 participants