From fe10970d6f7e9fba1cb2a7cbd7dd28e8ba9017a4 Mon Sep 17 00:00:00 2001 From: francastell Date: Thu, 19 Dec 2024 10:56:13 -0500 Subject: [PATCH 1/5] G3-540 genes count within threshold for geneset details view --- src/application.py | 39 ++++++++++++++++++++++++++++ src/templates/genesetMeta.html | 9 +++++++ src/templates/viewThreshold_new.html | 4 +++ 3 files changed, 52 insertions(+) diff --git a/src/application.py b/src/application.py index fc269e98..e46f15ba 100644 --- a/src/application.py +++ b/src/application.py @@ -2005,6 +2005,8 @@ def render_set_threshold(gs_id): if threshold_type == 1 or threshold_type == 2: threshold_gene_counts = calc_genes_count_in_threshold(gsv_values, thresh) curr_gene_count = curr_gene_count if thresh[0] == 'None' else threshold_gene_counts[float(thresh[0])] + elif threshold_type == 4 or threshold_type == 5: + curr_gene_count = calc_genes_in_threshold_range(gsv_values, thresh[0], thresh[1]) score_types = { 1: "p-value", @@ -2045,7 +2047,28 @@ def calc_genes_count_in_threshold(gsv_values, curr_thresh) -> dict: return threshold_gene_counts +def calc_genes_in_threshold_range(gsv_values, min_thresh, max_thresh) -> int: + """ Calculate the number of genes that fall within a given threshold range + :param gsv_values: list of gene set values + :param min_thresh: minimum threshold value + :param max_thresh: maximum threshold value + :return: number of genes that fall within the threshold range + """ + if min_thresh is None or max_thresh == '0': + return 0 + + min_thresh = float(min_thresh) + max_thresh = float(max_thresh) + + gene_count = 0 + if gsv_values is not None: + for gsv_value in gsv_values: + value = list(gsv_value.values())[0] + if min_thresh <= float(value) <= max_thresh: + gene_count += 1 + + return gene_count @app.route('/setthreshold-legacy/') def render_set_threshold_legacy(gs_id): @@ -2777,6 +2800,21 @@ def render_viewgeneset_main(gs_id, curation_view=None, curation_team=None, curat if plat['pf_id'] == gene_type: uploaded_as = plat['pf_name'] + threshold = str(geneset.threshold) + threshold_type = geneset.threshold_type + curr_threshold = threshold.split(',') + + gsv_values = geneweaverdb.get_all_geneset_values(gs_id) + # get genes count for the current threshold + num_genes_in_threshold = 0; + if threshold_type == 1 or threshold_type == 2: + gene_counts = calc_genes_count_in_threshold(gsv_values, curr_threshold) + num_genes_in_threshold = num_genes_in_threshold if curr_threshold[0] == 'None' else gene_counts[float(curr_threshold[0])] + elif threshold_type == 4 or threshold_type == 5: + if len(curr_threshold) == 1: + curr_threshold.append('0') + num_genes_in_threshold = calc_genes_in_threshold_range(gsv_values, curr_threshold[0], curr_threshold[1]) + show_gene_list = True # get value for the alt-gene-id column # if this is a 'stub' geneset.gene_id_type might not be valid, @@ -2876,6 +2914,7 @@ def render_viewgeneset_main(gs_id, curation_view=None, curation_team=None, curat totalGenes=numgenes, uploaded_as=uploaded_as, threshold_value=threshold_value, + num_genes_in_threshold = num_genes_in_threshold, #SRP IMPLEMENTATION srp=srp #SRP IMPLEMENTATION END diff --git a/src/templates/genesetMeta.html b/src/templates/genesetMeta.html index f4697efa..8c24f0db 100644 --- a/src/templates/genesetMeta.html +++ b/src/templates/genesetMeta.html @@ -43,6 +43,15 @@

{{ threshold_value }}

+ +
+
+

GENES IN THRESHOLD:

+
+
+

{{ num_genes_in_threshold }}

+
+
{% endif %}
diff --git a/src/templates/viewThreshold_new.html b/src/templates/viewThreshold_new.html index fdf1b4f5..4a1bb2fa 100644 --- a/src/templates/viewThreshold_new.html +++ b/src/templates/viewThreshold_new.html @@ -42,6 +42,7 @@

Set GeneSet Threshold

{% else %} {{ threshold[1] }} {% endif %} + ( genes count: {{ curr_gene_count }} )

{% else %} @@ -95,6 +96,9 @@

Set GeneSet Threshold

+
+

* Selected threshold range in red color

+

From c8854d2a78db540c09d4417425b155254787c363 Mon Sep 17 00:00:00 2001 From: francastell Date: Thu, 19 Dec 2024 10:57:35 -0500 Subject: [PATCH 2/5] G3-540 version udpate --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 56373a2e..34f31477 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "geneweaver-legacy" -version = "1.5.5" +version = "1.5.6" description = "" authors = ["Alexander Berger "] readme = "README.md" From a64450bc82952a0e9de665c3de78f06ed45aa4d1 Mon Sep 17 00:00:00 2001 From: francastell Date: Thu, 19 Dec 2024 15:26:36 -0500 Subject: [PATCH 3/5] G3-540 additional display of counts --- src/templates/viewgenesetdetails.html | 1 + 1 file changed, 1 insertion(+) diff --git a/src/templates/viewgenesetdetails.html b/src/templates/viewgenesetdetails.html index cdc65819..fab80879 100644 --- a/src/templates/viewgenesetdetails.html +++ b/src/templates/viewgenesetdetails.html @@ -115,6 +115,7 @@

Gene List • {{ totalGenes }} Genes

+

Genes in threshold: {{ num_genes_in_threshold }}

From 38aded7a5e76cc96c6495be96bfb30bb73a746ef Mon Sep 17 00:00:00 2001 From: francastell Date: Thu, 19 Dec 2024 18:01:00 -0500 Subject: [PATCH 4/5] G3-540 fixing issue with histogram display --- src/templates/viewThreshold_new.html | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/templates/viewThreshold_new.html b/src/templates/viewThreshold_new.html index 4a1bb2fa..4fe9fbf8 100644 --- a/src/templates/viewThreshold_new.html +++ b/src/templates/viewThreshold_new.html @@ -241,9 +241,9 @@

Set GeneSet Threshold

Plotly.restyle(plotElement, { selectedpoints: [indices], selected: { - marker: { - color: '#ff0000' - } + marker: { + color: '#ff0000' + } } }); //update gene count display @@ -264,12 +264,8 @@

Set GeneSet Threshold

var x_bin_size = 0.5; if (v_max - v_min < 100) { x_bin_size = 0.1 }; if (v_max - v_min < 1) { x_bin_size = 0.01 }; - var x_bin_conf = {}; - if (threshold_type === 4 || threshold_type === 5) { - x_bin_conf = {size: x_bin_size} - } else { - x_bin_conf = {start:0, size: x_bin_size} - } + var x_bin_conf = {size: x_bin_size}; + //buttons to remove from plotly bar var btns2rm = [ 'toggleSpikelines', 'lasso2d', 'hoverClosestCartesian', 'hoverCompareCartesian'] @@ -296,7 +292,8 @@

Set GeneSet Threshold

xaxis: { title: { text: "Threshold Range" - } + }, + range: [v_min, v_max] }, yaxis: { title: { From cd73bbc5643c1d0dafa9445a129979c00d86c951 Mon Sep 17 00:00:00 2001 From: francastell Date: Fri, 20 Dec 2024 12:56:50 -0500 Subject: [PATCH 5/5] G3-540 version udpate --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 34f31477..a3d493b0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "geneweaver-legacy" -version = "1.5.6" +version = "1.5.7" description = "" authors = ["Alexander Berger "] readme = "README.md"