-
Notifications
You must be signed in to change notification settings - Fork 1
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
54 smooth lineages plot #58
Conversation
Added a drop-down menu in lineages tab to select size of smoothing (default=14 days) Updated citation link in acknowledgement tab to point to published article
…informatics/covigator into 54-smooth_lineages_plot
Set default smoothing window to 14 days
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done, I only have some minor comments. Once you look into those this looks ready to be merged.
logger.debug("Getting data on samples by country...") | ||
data = self.queries.get_accumulated_lineages_by_country( | ||
data_source=data_source, countries=countries, lineages=lineages) | ||
graph = dcc.Markdown("""**No data for the current selection**""") | ||
if data is not None and data.shape[0] > 0: | ||
logger.debug("Prepare plot on samples by lineage...") | ||
lineages = list(data.sort_values("cumsum", ascending=False).lineage.unique()) | ||
|
||
data.set_index('date', drop=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this line is not doing anything, as set_index()
does not affect the DataFrame on which it is called unless inplace=True
is passed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good hint. I thought I had already removed the line
sma_df = sma_df.reset_index(level='lineage')[['ratio_per_date', 'cumsum', 'count']] | ||
# Update columns with moving average over selected period | ||
smooth_data.loc[:, 'ratio_per_date'] = sma_df['ratio_per_date'] | ||
smooth_data.loc[:, 'cumsum'] = sma_df['cumsum'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering if we want to do the rolling average also on cumsum
and count
considering that these values are only shown in the hover data, hence they do not affect the looks of the plot. What do you think? I don't have a strong preference here, just wondering.
html.A("https://doi.org/10.1101/2021.02.04.429765", | ||
href="https://doi.org/10.1101/2021.02.04.429765", target="_blank"), | ||
html.A("https://doi.org/10.1371/journal.pone.0249254", | ||
href="https://doi.org/10.1371/journal.pone.0249254", target="_blank"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one! :) thanks
covigator/dashboard/tabs/lineages.py
Outdated
dcc.Markdown("""Select time period for smoothing"""), | ||
dcc.Dropdown( | ||
id=ID_DROPDOWN_PERIOD, | ||
options=[{'label': c, 'value': c} for c in range(1, 32)] + [{'label': 'Disable', 'value': False}], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest you set the label to "{} days".format(c)
so it is more explicit what the numbers correspond to.
Incorporation of the suggestions for improvement from @priesgo
No description provided.