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

54 smooth lineages plot #58

Merged
merged 4 commits into from
Dec 19, 2022
Merged

54 smooth lineages plot #58

merged 4 commits into from
Dec 19, 2022

Conversation

priesgo
Copy link
Collaborator

@priesgo priesgo commented Dec 16, 2022

No description provided.

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
Set default smoothing window to 14 days
Copy link
Collaborator Author

@priesgo priesgo left a 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)
Copy link
Collaborator Author

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.

Copy link
Member

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']
Copy link
Collaborator Author

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"),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nice one! :) thanks

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}],
Copy link
Collaborator Author

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
@priesgo priesgo merged commit 54e9137 into develop Dec 19, 2022
@priesgo priesgo deleted the 54-smooth_lineages_plot branch December 19, 2022 15:04
@priesgo priesgo linked an issue Jan 5, 2023 that may be closed by this pull request
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.

Smooth the lineages plot
2 participants