From 1edb87671983c8585183fb7c53e11137971d7c5f Mon Sep 17 00:00:00 2001 From: Shettland Date: Fri, 20 Dec 2024 12:31:59 +0100 Subject: [PATCH 01/17] Introducing number of samples with selected lineage --- .../var_needle_mutation_graph_by_lineage.py | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/dashboard/utils/var_needle_mutation_graph_by_lineage.py b/dashboard/utils/var_needle_mutation_graph_by_lineage.py index 76c7953d..4e36926e 100644 --- a/dashboard/utils/var_needle_mutation_graph_by_lineage.py +++ b/dashboard/utils/var_needle_mutation_graph_by_lineage.py @@ -29,17 +29,15 @@ def get_variant_data_from_lineages(graphic_name=None, lineage=None, chromosome=N # lineage_fieldID__property_name__iexact="lineage_name" # ).exists(): # return None - - if lineage is None: - lineage = ( - core.models.LineageValues.objects.filter( + all_lineages = core.models.LineageValues.objects.filter( lineage_fieldID__property_name__iexact="lineage_name" - ) - .values_list("value", flat=True) - .first() - ) - - mdata = json_data[lineage] + ).values_list("value", flat=True) + if lineage is None: + lineage = all_lineages.first() + num_of_samples = len([x for x in all_lineages if x == lineage]) + mdata = {} + mdata["mutations"] = json_data[lineage] + mdata["n_samples"] = num_of_samples return mdata, lineage @@ -84,6 +82,9 @@ def create_needle_plot_graph_mutation_by_lineage(lineage_list, lineage, mdata): ), ] ), + html.Div( + f"Showing mutations for {mdata["n_samples"]} samples" + ), ], style={ "display": "flex", @@ -95,7 +96,7 @@ def create_needle_plot_graph_mutation_by_lineage(lineage_list, lineage, mdata): children=dashbio.NeedlePlot( width="auto", id="dashbio-needleplot", - mutationData=mdata, + mutationData=mdata["mutations"], rangeSlider=True, xlabel="Genome Position", ylabel="Population Allele Frequency ", From ff4bbf4bf2608fee426a2c60f3ee6ca7c8d60905 Mon Sep 17 00:00:00 2001 From: Shettland Date: Fri, 20 Dec 2024 12:33:47 +0100 Subject: [PATCH 02/17] Introducing number of samples with selected lineage. --- dashboard/utils/var_needle_mutation_graph_by_lineage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dashboard/utils/var_needle_mutation_graph_by_lineage.py b/dashboard/utils/var_needle_mutation_graph_by_lineage.py index 4e36926e..d4dad89c 100644 --- a/dashboard/utils/var_needle_mutation_graph_by_lineage.py +++ b/dashboard/utils/var_needle_mutation_graph_by_lineage.py @@ -83,7 +83,7 @@ def create_needle_plot_graph_mutation_by_lineage(lineage_list, lineage, mdata): ] ), html.Div( - f"Showing mutations for {mdata["n_samples"]} samples" + f"Showing mutations for {mdata['n_samples']} samples" ), ], style={ From 479581638a8a284b2f4f647f8509a19b2faa2fbb Mon Sep 17 00:00:00 2001 From: Shettland Date: Fri, 20 Dec 2024 12:40:15 +0100 Subject: [PATCH 03/17] Introducing n_samples var with num of samples --- .../var_needle_mutation_graph_by_lineage.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/dashboard/utils/var_needle_mutation_graph_by_lineage.py b/dashboard/utils/var_needle_mutation_graph_by_lineage.py index d4dad89c..9b0ffc56 100644 --- a/dashboard/utils/var_needle_mutation_graph_by_lineage.py +++ b/dashboard/utils/var_needle_mutation_graph_by_lineage.py @@ -34,15 +34,13 @@ def get_variant_data_from_lineages(graphic_name=None, lineage=None, chromosome=N ).values_list("value", flat=True) if lineage is None: lineage = all_lineages.first() - num_of_samples = len([x for x in all_lineages if x == lineage]) - mdata = {} - mdata["mutations"] = json_data[lineage] - mdata["n_samples"] = num_of_samples + n_samples = len([x for x in all_lineages if x == lineage]) + mdata = json_data[lineage] - return mdata, lineage + return mdata, lineage, n_samples -def create_needle_plot_graph_mutation_by_lineage(lineage_list, lineage, mdata): +def create_needle_plot_graph_mutation_by_lineage(lineage_list, lineage, mdata, n_samples): options = [] for lin in lineage_list: options.append({"label": lin, "value": lin}) @@ -83,7 +81,7 @@ def create_needle_plot_graph_mutation_by_lineage(lineage_list, lineage, mdata): ] ), html.Div( - f"Showing mutations for {mdata['n_samples']} samples" + f"Showing mutations for {n_samples} samples" ), ], style={ @@ -96,7 +94,7 @@ def create_needle_plot_graph_mutation_by_lineage(lineage_list, lineage, mdata): children=dashbio.NeedlePlot( width="auto", id="dashbio-needleplot", - mutationData=mdata["mutations"], + mutationData=mdata, rangeSlider=True, xlabel="Genome Position", ylabel="Population Allele Frequency ", @@ -115,12 +113,12 @@ def create_needle_plot_graph_mutation_by_lineage(lineage_list, lineage, mdata): Input("needleplot-select-lineage", "value"), ) def update_sample(selected_lineage): - mdata, lineage = get_variant_data_from_lineages( + mdata, lineage, n_samples = get_variant_data_from_lineages( graphic_name="variations_per_lineage", lineage=selected_lineage, chromosome=None, ) - return mdata, lineage + return mdata, lineage, n_samples @app.callback( Output("dashbio-needleplot", "rangeSlider"), From 28537ee2854e5bf1bc4eb12ab572a2072fa9475c Mon Sep 17 00:00:00 2001 From: Shettland Date: Fri, 20 Dec 2024 12:40:25 +0100 Subject: [PATCH 04/17] Introducing n_samples var with num of samples --- dashboard/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dashboard/views.py b/dashboard/views.py index 1f2474d3..51aa4ae4 100644 --- a/dashboard/views.py +++ b/dashboard/views.py @@ -32,7 +32,7 @@ def mutations_in_lineage(request): # mutations in lineages by lineage def_chrom = core.utils.variants.get_default_chromosome() lineages_list = core.utils.lineage.get_lineages_list() - mdata, lineage = ( + mdata, lineage, n_samples = ( dashboard.utils.var_needle_mutation_graph_by_lineage.get_variant_data_from_lineages( graphic_name="variations_per_lineage", lineage=None, chromosome=def_chrom ) @@ -45,7 +45,7 @@ def mutations_in_lineage(request): {"ERROR": dashboard.dashboard_config.ERROR_NO_LINEAGES_ARE_DEFINED_YET}, ) dashboard.utils.var_needle_mutation_graph_by_lineage.create_needle_plot_graph_mutation_by_lineage( - lineages_list, lineage, mdata + lineages_list, lineage, mdata, n_samples ) return render( request, From c2470744ff7d25cacf519214e1802842c4e8893f Mon Sep 17 00:00:00 2001 From: Shettland Date: Fri, 20 Dec 2024 12:48:25 +0100 Subject: [PATCH 05/17] Introducing n_samples var with num of samples in app callback --- dashboard/utils/var_needle_mutation_graph_by_lineage.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dashboard/utils/var_needle_mutation_graph_by_lineage.py b/dashboard/utils/var_needle_mutation_graph_by_lineage.py index 9b0ffc56..2d0ef30e 100644 --- a/dashboard/utils/var_needle_mutation_graph_by_lineage.py +++ b/dashboard/utils/var_needle_mutation_graph_by_lineage.py @@ -110,6 +110,7 @@ def create_needle_plot_graph_mutation_by_lineage(lineage_list, lineage, mdata, n @app.callback( Output("dashbio-needleplot", "mutationData"), Output("dashbio-needleplot", "lineage"), + Output("dashbio-needleplot", "n_samples"), Input("needleplot-select-lineage", "value"), ) def update_sample(selected_lineage): From 8cd76e1e1bbc64ef756c198dfe15676da8077821 Mon Sep 17 00:00:00 2001 From: Shettland Date: Fri, 20 Dec 2024 12:53:53 +0100 Subject: [PATCH 06/17] Introducing n_samples within dashbio needleplot --- dashboard/utils/var_needle_mutation_graph_by_lineage.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dashboard/utils/var_needle_mutation_graph_by_lineage.py b/dashboard/utils/var_needle_mutation_graph_by_lineage.py index 2d0ef30e..9387e0ef 100644 --- a/dashboard/utils/var_needle_mutation_graph_by_lineage.py +++ b/dashboard/utils/var_needle_mutation_graph_by_lineage.py @@ -80,9 +80,6 @@ def create_needle_plot_graph_mutation_by_lineage(lineage_list, lineage, mdata, n ), ] ), - html.Div( - f"Showing mutations for {n_samples} samples" - ), ], style={ "display": "flex", @@ -92,6 +89,7 @@ def create_needle_plot_graph_mutation_by_lineage(lineage_list, lineage, mdata, n ), html.Div( children=dashbio.NeedlePlot( + title=f"Showing mutations for {n_samples} samples", width="auto", id="dashbio-needleplot", mutationData=mdata, From 532cb046578b6e7a467a4556332a7548e7c73e9e Mon Sep 17 00:00:00 2001 From: Shettland Date: Fri, 20 Dec 2024 13:00:49 +0100 Subject: [PATCH 07/17] Introducing n_samples within dashbio needleplot. fix --- dashboard/utils/var_needle_mutation_graph_by_lineage.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dashboard/utils/var_needle_mutation_graph_by_lineage.py b/dashboard/utils/var_needle_mutation_graph_by_lineage.py index 9387e0ef..a251604c 100644 --- a/dashboard/utils/var_needle_mutation_graph_by_lineage.py +++ b/dashboard/utils/var_needle_mutation_graph_by_lineage.py @@ -89,13 +89,12 @@ def create_needle_plot_graph_mutation_by_lineage(lineage_list, lineage, mdata, n ), html.Div( children=dashbio.NeedlePlot( - title=f"Showing mutations for {n_samples} samples", width="auto", id="dashbio-needleplot", mutationData=mdata, rangeSlider=True, xlabel="Genome Position", - ylabel="Population Allele Frequency ", + ylabel=f"Population Allele Frequency over {n_samples} samples", domainStyle={ # "textangle": "45", "displayMinorDomains": False, From e7e64fdace9bdec58b4632b2dbef2e33b52c42a4 Mon Sep 17 00:00:00 2001 From: Shettland Date: Fri, 20 Dec 2024 13:14:37 +0100 Subject: [PATCH 08/17] Included num of samples inside mdata --- .../var_needle_mutation_graph_by_lineage.py | 19 ++++++++++--------- dashboard/views.py | 4 ++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/dashboard/utils/var_needle_mutation_graph_by_lineage.py b/dashboard/utils/var_needle_mutation_graph_by_lineage.py index a251604c..37c30444 100644 --- a/dashboard/utils/var_needle_mutation_graph_by_lineage.py +++ b/dashboard/utils/var_needle_mutation_graph_by_lineage.py @@ -34,13 +34,14 @@ def get_variant_data_from_lineages(graphic_name=None, lineage=None, chromosome=N ).values_list("value", flat=True) if lineage is None: lineage = all_lineages.first() - n_samples = len([x for x in all_lineages if x == lineage]) - mdata = json_data[lineage] + mdata = {} + mdata["mutations"] = json_data[lineage] + mdata["n_samples"] = len([x for x in all_lineages if x == lineage]) - return mdata, lineage, n_samples + return mdata, lineage -def create_needle_plot_graph_mutation_by_lineage(lineage_list, lineage, mdata, n_samples): +def create_needle_plot_graph_mutation_by_lineage(lineage_list, lineage, mdata): options = [] for lin in lineage_list: options.append({"label": lin, "value": lin}) @@ -91,10 +92,10 @@ def create_needle_plot_graph_mutation_by_lineage(lineage_list, lineage, mdata, n children=dashbio.NeedlePlot( width="auto", id="dashbio-needleplot", - mutationData=mdata, + mutationData=mdata["mutations"], rangeSlider=True, xlabel="Genome Position", - ylabel=f"Population Allele Frequency over {n_samples} samples", + ylabel=f"Population Allele Frequency ({mdata["n_samples"]} samples)", domainStyle={ # "textangle": "45", "displayMinorDomains": False, @@ -107,16 +108,16 @@ def create_needle_plot_graph_mutation_by_lineage(lineage_list, lineage, mdata, n @app.callback( Output("dashbio-needleplot", "mutationData"), Output("dashbio-needleplot", "lineage"), - Output("dashbio-needleplot", "n_samples"), + Output("dashbio-needleplot", "ylabel"), Input("needleplot-select-lineage", "value"), ) def update_sample(selected_lineage): - mdata, lineage, n_samples = get_variant_data_from_lineages( + mdata, lineage = get_variant_data_from_lineages( graphic_name="variations_per_lineage", lineage=selected_lineage, chromosome=None, ) - return mdata, lineage, n_samples + return mdata, lineage @app.callback( Output("dashbio-needleplot", "rangeSlider"), diff --git a/dashboard/views.py b/dashboard/views.py index 51aa4ae4..1f2474d3 100644 --- a/dashboard/views.py +++ b/dashboard/views.py @@ -32,7 +32,7 @@ def mutations_in_lineage(request): # mutations in lineages by lineage def_chrom = core.utils.variants.get_default_chromosome() lineages_list = core.utils.lineage.get_lineages_list() - mdata, lineage, n_samples = ( + mdata, lineage = ( dashboard.utils.var_needle_mutation_graph_by_lineage.get_variant_data_from_lineages( graphic_name="variations_per_lineage", lineage=None, chromosome=def_chrom ) @@ -45,7 +45,7 @@ def mutations_in_lineage(request): {"ERROR": dashboard.dashboard_config.ERROR_NO_LINEAGES_ARE_DEFINED_YET}, ) dashboard.utils.var_needle_mutation_graph_by_lineage.create_needle_plot_graph_mutation_by_lineage( - lineages_list, lineage, mdata, n_samples + lineages_list, lineage, mdata ) return render( request, From 811121cce5d09a49cf75e2e0d033a7d50911ac6d Mon Sep 17 00:00:00 2001 From: Shettland Date: Fri, 20 Dec 2024 13:15:37 +0100 Subject: [PATCH 09/17] Included num of samples inside mdata. --- dashboard/utils/var_needle_mutation_graph_by_lineage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dashboard/utils/var_needle_mutation_graph_by_lineage.py b/dashboard/utils/var_needle_mutation_graph_by_lineage.py index 37c30444..75def62c 100644 --- a/dashboard/utils/var_needle_mutation_graph_by_lineage.py +++ b/dashboard/utils/var_needle_mutation_graph_by_lineage.py @@ -95,7 +95,7 @@ def create_needle_plot_graph_mutation_by_lineage(lineage_list, lineage, mdata): mutationData=mdata["mutations"], rangeSlider=True, xlabel="Genome Position", - ylabel=f"Population Allele Frequency ({mdata["n_samples"]} samples)", + ylabel=f"Population Allele Frequency ({mdata['n_samples']} samples)", domainStyle={ # "textangle": "45", "displayMinorDomains": False, From cc400f7883b739f29b518bc45b6711588471feaf Mon Sep 17 00:00:00 2001 From: Shettland Date: Fri, 20 Dec 2024 14:14:50 +0100 Subject: [PATCH 10/17] Including n_samples as new html div --- dashboard/utils/var_needle_mutation_graph_by_lineage.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dashboard/utils/var_needle_mutation_graph_by_lineage.py b/dashboard/utils/var_needle_mutation_graph_by_lineage.py index 75def62c..d0c53f59 100644 --- a/dashboard/utils/var_needle_mutation_graph_by_lineage.py +++ b/dashboard/utils/var_needle_mutation_graph_by_lineage.py @@ -81,6 +81,9 @@ def create_needle_plot_graph_mutation_by_lineage(lineage_list, lineage, mdata): ), ] ), + html.Div(children=[ + dcc.Markdown(id='num_of_samples', children=f'Showing mutations for {mdata['n_samples']} samples') + ]), ], style={ "display": "flex", @@ -108,7 +111,6 @@ def create_needle_plot_graph_mutation_by_lineage(lineage_list, lineage, mdata): @app.callback( Output("dashbio-needleplot", "mutationData"), Output("dashbio-needleplot", "lineage"), - Output("dashbio-needleplot", "ylabel"), Input("needleplot-select-lineage", "value"), ) def update_sample(selected_lineage): From 02f1143d5583c060691da2e5f7303cb49ca86156 Mon Sep 17 00:00:00 2001 From: Shettland Date: Fri, 20 Dec 2024 14:15:40 +0100 Subject: [PATCH 11/17] Including n_samples as new html div. --- dashboard/utils/var_needle_mutation_graph_by_lineage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dashboard/utils/var_needle_mutation_graph_by_lineage.py b/dashboard/utils/var_needle_mutation_graph_by_lineage.py index d0c53f59..83195a3a 100644 --- a/dashboard/utils/var_needle_mutation_graph_by_lineage.py +++ b/dashboard/utils/var_needle_mutation_graph_by_lineage.py @@ -82,7 +82,7 @@ def create_needle_plot_graph_mutation_by_lineage(lineage_list, lineage, mdata): ] ), html.Div(children=[ - dcc.Markdown(id='num_of_samples', children=f'Showing mutations for {mdata['n_samples']} samples') + dcc.Markdown(id="num_of_samples", children=f"Showing mutations for {mdata['n_samples']} samples") ]), ], style={ From da4466b3282c74b59f72cbdecea7951d8155bdb1 Mon Sep 17 00:00:00 2001 From: Shettland Date: Fri, 20 Dec 2024 14:19:29 +0100 Subject: [PATCH 12/17] Including n_samples div in app callback --- .../var_needle_mutation_graph_by_lineage.py | 20 +++++++++---------- dashboard/views.py | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/dashboard/utils/var_needle_mutation_graph_by_lineage.py b/dashboard/utils/var_needle_mutation_graph_by_lineage.py index 83195a3a..65ea41da 100644 --- a/dashboard/utils/var_needle_mutation_graph_by_lineage.py +++ b/dashboard/utils/var_needle_mutation_graph_by_lineage.py @@ -34,14 +34,13 @@ def get_variant_data_from_lineages(graphic_name=None, lineage=None, chromosome=N ).values_list("value", flat=True) if lineage is None: lineage = all_lineages.first() - mdata = {} - mdata["mutations"] = json_data[lineage] - mdata["n_samples"] = len([x for x in all_lineages if x == lineage]) + mdata= json_data[lineage] + n_samples = len([x for x in all_lineages if x == lineage]) - return mdata, lineage + return mdata, lineage, n_samples -def create_needle_plot_graph_mutation_by_lineage(lineage_list, lineage, mdata): +def create_needle_plot_graph_mutation_by_lineage(lineage_list, lineage, mdata, n_samples): options = [] for lin in lineage_list: options.append({"label": lin, "value": lin}) @@ -82,7 +81,7 @@ def create_needle_plot_graph_mutation_by_lineage(lineage_list, lineage, mdata): ] ), html.Div(children=[ - dcc.Markdown(id="num_of_samples", children=f"Showing mutations for {mdata['n_samples']} samples") + dcc.Markdown(id="samples_markdown", children=f"Showing mutations for {n_samples} samples") ]), ], style={ @@ -95,10 +94,10 @@ def create_needle_plot_graph_mutation_by_lineage(lineage_list, lineage, mdata): children=dashbio.NeedlePlot( width="auto", id="dashbio-needleplot", - mutationData=mdata["mutations"], + mutationData=mdata, rangeSlider=True, xlabel="Genome Position", - ylabel=f"Population Allele Frequency ({mdata['n_samples']} samples)", + ylabel=f"Population Allele Frequency samples)", domainStyle={ # "textangle": "45", "displayMinorDomains": False, @@ -111,15 +110,16 @@ def create_needle_plot_graph_mutation_by_lineage(lineage_list, lineage, mdata): @app.callback( Output("dashbio-needleplot", "mutationData"), Output("dashbio-needleplot", "lineage"), + Output("samples_markdown", "num_of_samples"), Input("needleplot-select-lineage", "value"), ) def update_sample(selected_lineage): - mdata, lineage = get_variant_data_from_lineages( + mdata, lineage, n_samples = get_variant_data_from_lineages( graphic_name="variations_per_lineage", lineage=selected_lineage, chromosome=None, ) - return mdata, lineage + return mdata, lineage, n_samples @app.callback( Output("dashbio-needleplot", "rangeSlider"), diff --git a/dashboard/views.py b/dashboard/views.py index 1f2474d3..51aa4ae4 100644 --- a/dashboard/views.py +++ b/dashboard/views.py @@ -32,7 +32,7 @@ def mutations_in_lineage(request): # mutations in lineages by lineage def_chrom = core.utils.variants.get_default_chromosome() lineages_list = core.utils.lineage.get_lineages_list() - mdata, lineage = ( + mdata, lineage, n_samples = ( dashboard.utils.var_needle_mutation_graph_by_lineage.get_variant_data_from_lineages( graphic_name="variations_per_lineage", lineage=None, chromosome=def_chrom ) @@ -45,7 +45,7 @@ def mutations_in_lineage(request): {"ERROR": dashboard.dashboard_config.ERROR_NO_LINEAGES_ARE_DEFINED_YET}, ) dashboard.utils.var_needle_mutation_graph_by_lineage.create_needle_plot_graph_mutation_by_lineage( - lineages_list, lineage, mdata + lineages_list, lineage, mdata, n_samples ) return render( request, From 69362ad981531f16c4434e1d615adf5c8f839867 Mon Sep 17 00:00:00 2001 From: Shettland Date: Fri, 20 Dec 2024 14:21:12 +0100 Subject: [PATCH 13/17] Including n_samples div in app callback fix --- dashboard/utils/var_needle_mutation_graph_by_lineage.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dashboard/utils/var_needle_mutation_graph_by_lineage.py b/dashboard/utils/var_needle_mutation_graph_by_lineage.py index 65ea41da..3975b929 100644 --- a/dashboard/utils/var_needle_mutation_graph_by_lineage.py +++ b/dashboard/utils/var_needle_mutation_graph_by_lineage.py @@ -97,7 +97,7 @@ def create_needle_plot_graph_mutation_by_lineage(lineage_list, lineage, mdata, n mutationData=mdata, rangeSlider=True, xlabel="Genome Position", - ylabel=f"Population Allele Frequency samples)", + ylabel=f"Population Allele Frequency samples", domainStyle={ # "textangle": "45", "displayMinorDomains": False, @@ -110,7 +110,7 @@ def create_needle_plot_graph_mutation_by_lineage(lineage_list, lineage, mdata, n @app.callback( Output("dashbio-needleplot", "mutationData"), Output("dashbio-needleplot", "lineage"), - Output("samples_markdown", "num_of_samples"), + Output("samples_markdown", "n_samples"), Input("needleplot-select-lineage", "value"), ) def update_sample(selected_lineage): From 8a252be0d759fe5ff099db5349fda91fd7ba12be Mon Sep 17 00:00:00 2001 From: Shettland Date: Fri, 20 Dec 2024 14:24:08 +0100 Subject: [PATCH 14/17] Including n_samples div in app callback fix2 --- dashboard/utils/var_needle_mutation_graph_by_lineage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dashboard/utils/var_needle_mutation_graph_by_lineage.py b/dashboard/utils/var_needle_mutation_graph_by_lineage.py index 3975b929..a8b2a0e6 100644 --- a/dashboard/utils/var_needle_mutation_graph_by_lineage.py +++ b/dashboard/utils/var_needle_mutation_graph_by_lineage.py @@ -110,7 +110,7 @@ def create_needle_plot_graph_mutation_by_lineage(lineage_list, lineage, mdata, n @app.callback( Output("dashbio-needleplot", "mutationData"), Output("dashbio-needleplot", "lineage"), - Output("samples_markdown", "n_samples"), + Output("samples_markdown", "children"), Input("needleplot-select-lineage", "value"), ) def update_sample(selected_lineage): From 5c39d18e36b7c66fd183146dc17f842b24946c27 Mon Sep 17 00:00:00 2001 From: Shettland Date: Fri, 20 Dec 2024 14:27:40 +0100 Subject: [PATCH 15/17] Including n_samples div in app callback fix3 --- dashboard/utils/var_needle_mutation_graph_by_lineage.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dashboard/utils/var_needle_mutation_graph_by_lineage.py b/dashboard/utils/var_needle_mutation_graph_by_lineage.py index a8b2a0e6..c9d598e3 100644 --- a/dashboard/utils/var_needle_mutation_graph_by_lineage.py +++ b/dashboard/utils/var_needle_mutation_graph_by_lineage.py @@ -119,7 +119,8 @@ def update_sample(selected_lineage): lineage=selected_lineage, chromosome=None, ) - return mdata, lineage, n_samples + markdown_text = f"Showing mutations for {n_samples} samples" + return mdata, lineage, markdown_text @app.callback( Output("dashbio-needleplot", "rangeSlider"), From 2ac9cf7cea1b42a9d6648c1ff56549e617e02601 Mon Sep 17 00:00:00 2001 From: Shettland Date: Fri, 20 Dec 2024 14:33:55 +0100 Subject: [PATCH 16/17] Including n_samples div in app callback fix4 --- dashboard/utils/var_needle_mutation_graph_by_lineage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dashboard/utils/var_needle_mutation_graph_by_lineage.py b/dashboard/utils/var_needle_mutation_graph_by_lineage.py index c9d598e3..5ddf5478 100644 --- a/dashboard/utils/var_needle_mutation_graph_by_lineage.py +++ b/dashboard/utils/var_needle_mutation_graph_by_lineage.py @@ -76,7 +76,7 @@ def create_needle_plot_graph_mutation_by_lineage(lineage_list, lineage, mdata, n clearable=False, multi=False, value=lineage, - style={"width": "150px"}, + style={"width": "150px", "margin-right": "30px"}, ), ] ), From 0719efa51292d07594512f4a8b77530ece50adcb Mon Sep 17 00:00:00 2001 From: Shettland Date: Fri, 20 Dec 2024 14:38:55 +0100 Subject: [PATCH 17/17] Including n_samples div in app callback. linting --- .../var_needle_mutation_graph_by_lineage.py | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/dashboard/utils/var_needle_mutation_graph_by_lineage.py b/dashboard/utils/var_needle_mutation_graph_by_lineage.py index 5ddf5478..8065e766 100644 --- a/dashboard/utils/var_needle_mutation_graph_by_lineage.py +++ b/dashboard/utils/var_needle_mutation_graph_by_lineage.py @@ -30,17 +30,19 @@ def get_variant_data_from_lineages(graphic_name=None, lineage=None, chromosome=N # ).exists(): # return None all_lineages = core.models.LineageValues.objects.filter( - lineage_fieldID__property_name__iexact="lineage_name" - ).values_list("value", flat=True) + lineage_fieldID__property_name__iexact="lineage_name" + ).values_list("value", flat=True) if lineage is None: lineage = all_lineages.first() - mdata= json_data[lineage] + mdata = json_data[lineage] n_samples = len([x for x in all_lineages if x == lineage]) return mdata, lineage, n_samples -def create_needle_plot_graph_mutation_by_lineage(lineage_list, lineage, mdata, n_samples): +def create_needle_plot_graph_mutation_by_lineage( + lineage_list, lineage, mdata, n_samples +): options = [] for lin in lineage_list: options.append({"label": lin, "value": lin}) @@ -80,9 +82,14 @@ def create_needle_plot_graph_mutation_by_lineage(lineage_list, lineage, mdata, n ), ] ), - html.Div(children=[ - dcc.Markdown(id="samples_markdown", children=f"Showing mutations for {n_samples} samples") - ]), + html.Div( + children=[ + dcc.Markdown( + id="samples_markdown", + children=f"Showing mutations for {n_samples} samples", + ) + ] + ), ], style={ "display": "flex", @@ -97,7 +104,7 @@ def create_needle_plot_graph_mutation_by_lineage(lineage_list, lineage, mdata, n mutationData=mdata, rangeSlider=True, xlabel="Genome Position", - ylabel=f"Population Allele Frequency samples", + ylabel="Population Allele Frequency samples", domainStyle={ # "textangle": "45", "displayMinorDomains": False,