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

G3 540 genes in threshold #33

Merged
merged 7 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "geneweaver-legacy"
version = "1.5.6"
version = "1.5.7"
description = ""
authors = ["Alexander Berger <[email protected]>"]
readme = "README.md"
Expand Down
39 changes: 39 additions & 0 deletions src/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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/<int:gs_id>')
def render_set_threshold_legacy(gs_id):
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions src/templates/genesetMeta.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@
<p>{{ threshold_value }}</p>
</div>
</div>

<div class="row">
<div class="col-md-2">
<p class="text-right"><strong>GENES IN THRESHOLD:</strong></p>
</div>
<div class="col-md-10">
<p>{{ num_genes_in_threshold }}</p>
</div>
</div>
{% endif %}

<div class="row">
Expand Down
21 changes: 11 additions & 10 deletions src/templates/viewThreshold_new.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ <h2 class="panel-title"><strong>Set GeneSet Threshold</strong></h2>
{% else %}
{{ threshold[1] }}
{% endif %}
( genes count: {{ curr_gene_count }} )
</p>
</div>
{% else %}
Expand Down Expand Up @@ -95,6 +96,9 @@ <h2 class="panel-title"><strong>Set GeneSet Threshold</strong></h2>
<div class="row">
<div id="myHisPlot" style="width:100%; height:500px;"></div>
</div>
<div class="row">
<p>* Selected threshold range in red color</p>
</div>
<div class="row">
<p id="selectedGeneCount"></p>
</div>
Expand Down Expand Up @@ -237,9 +241,9 @@ <h2 class="panel-title"><strong>Set GeneSet Threshold</strong></h2>
Plotly.restyle(plotElement, {
selectedpoints: [indices],
selected: {
marker: {
color: '#ff0000'
}
marker: {
color: '#ff0000'
}
}
});
//update gene count display
Expand All @@ -260,12 +264,8 @@ <h2 class="panel-title"><strong>Set GeneSet Threshold</strong></h2>
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']
Expand All @@ -292,7 +292,8 @@ <h2 class="panel-title"><strong>Set GeneSet Threshold</strong></h2>
xaxis: {
title: {
text: "Threshold Range"
}
},
range: [v_min, v_max]
},
yaxis: {
title: {
Expand Down
1 change: 1 addition & 0 deletions src/templates/viewgenesetdetails.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ <h3 class="panel-title">Gene List &bull; {{ totalGenes }} Genes</h3>
<div class="row">
<div class="col-xs-12 col-md-9">
<div class="row">
<p>Genes in threshold: {{ num_genes_in_threshold }}</p>
</div>
</div>
<div class="col-xs-6 col-md-3" style="margin:0; padding:0;">
Expand Down
Loading