From ebe556c3dfa7d1bbf6797d51452d06e53184f679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ann-Kathrin=20Br=C3=BCggemann?= <90249112+AKBrueggemann@users.noreply.github.com> Date: Fri, 10 Dec 2021 13:29:33 +0100 Subject: [PATCH] fix: relative aggregation of samples for variants and lineages over time plots (#382) * Changed plots occurence threshold to relative * fmt * Name changed: number of occurences in plot * fmt Co-authored-by: Thomas Battenfeld <46334240+thomasbtf@users.noreply.github.com> --- workflow/scripts/plot-lineages-over-time.py | 7 ++++--- workflow/scripts/plot-variants-over-time.py | 5 ++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/workflow/scripts/plot-lineages-over-time.py b/workflow/scripts/plot-lineages-over-time.py index 164cfb89d..9dc933b7c 100644 --- a/workflow/scripts/plot-lineages-over-time.py +++ b/workflow/scripts/plot-lineages-over-time.py @@ -31,9 +31,10 @@ def plot_lineages_over_time(sm_input, sm_output, dates, sm_output_table): ].transform(lambda s: s.count()) # mask low occurrences - pangolin_calls.loc[ - pangolin_calls["lineage_count"] < 10, "lineage" - ] = "other (< 10 occ.)" + threshold = len(pangolin_calls) / 10 + pangolin_calls.loc[pangolin_calls["lineage_count"] < threshold, "lineage"] = ( + "other (<" + str(threshold) + " occ.)" + ) pangolin_calls.rename(columns={"lineage": "Lineage", "date": "Date"}, inplace=True) diff --git a/workflow/scripts/plot-variants-over-time.py b/workflow/scripts/plot-variants-over-time.py index 541575d2f..d03daed57 100644 --- a/workflow/scripts/plot-variants-over-time.py +++ b/workflow/scripts/plot-variants-over-time.py @@ -84,7 +84,10 @@ def plot_variants_over_time(sm_output, sm_output_table): ].transform(lambda s: s.count()) # mask low occurrences - calls.loc[calls["total occurrence"] < 10, "alteration"] = "other (< 10 occ.)" + threshold = len(calls) / 10 + calls.loc[calls["total occurrence"] < threshold, "alteration"] = ( + "other (<" + str(threshold) + " occ.)" + ) calls.rename(columns={"alteration": "Alteration", "date": "Date"}, inplace=True)