aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzsloan2015-10-12 15:44:07 +0000
committerzsloan2015-10-12 15:44:07 +0000
commite9727c576312c22e3fdc0a7ba153c414ad8e98da (patch)
tree65bd09783748669fb7aadb2176b210fd1f7db5b2
parent01fb1212408818512a729f6bd00a203defa5290c (diff)
downloadgenenetwork2-e9727c576312c22e3fdc0a7ba153c414ad8e98da.tar.gz
Fixed an error page that occurs if traits with no overlapping samples are used for correlation matrix
-rwxr-xr-xwqflask/wqflask/correlation_matrix/show_corr_matrix.py21
-rwxr-xr-xwqflask/wqflask/templates/correlation_matrix.html1
2 files changed, 11 insertions, 11 deletions
diff --git a/wqflask/wqflask/correlation_matrix/show_corr_matrix.py b/wqflask/wqflask/correlation_matrix/show_corr_matrix.py
index b670f521..2cdd989f 100755
--- a/wqflask/wqflask/correlation_matrix/show_corr_matrix.py
+++ b/wqflask/wqflask/correlation_matrix/show_corr_matrix.py
@@ -138,17 +138,18 @@ class CorrelationMatrix(object):
this_trait_vals.append(sample_value)
target_vals.append(target_sample_value)
- this_trait_vals, target_vals, num_overlap = corr_result_helpers.normalize_values(
- this_trait_vals, target_vals)
-
- if is_spearman == False:
- sample_r, sample_p = scipy.stats.pearsonr(this_trait_vals, target_vals)
- if sample_r == 1:
- is_spearman = True
+ this_trait_vals, target_vals, num_overlap = corr_result_helpers.normalize_values(this_trait_vals, target_vals)
+ if num_overlap == 0:
+ corr_result_row.append([target_trait, 0, num_overlap])
else:
- sample_r, sample_p = scipy.stats.spearmanr(this_trait_vals, target_vals)
-
- corr_result_row.append([target_trait, sample_r, num_overlap])
+ if is_spearman == False:
+ sample_r, sample_p = scipy.stats.pearsonr(this_trait_vals, target_vals)
+ if sample_r == 1:
+ is_spearman = True
+ else:
+ sample_r, sample_p = scipy.stats.spearmanr(this_trait_vals, target_vals)
+
+ corr_result_row.append([target_trait, sample_r, num_overlap])
self.corr_results.append(corr_result_row)
diff --git a/wqflask/wqflask/templates/correlation_matrix.html b/wqflask/wqflask/templates/correlation_matrix.html
index 768367c3..c822b8bc 100755
--- a/wqflask/wqflask/templates/correlation_matrix.html
+++ b/wqflask/wqflask/templates/correlation_matrix.html
@@ -34,7 +34,6 @@
{% if result[0].name == trait.name %}
<td nowrap="ON" align="center" bgcolor="#cccccc"><a href="/show_trait?trait_id={{ trait.name }}&dataset={{ trait.dataset.name }}"><font style="font-size: 11px; color: #000000;" ><em>n</em><br>{{ result[2] }}</font></a></td>
{% else %}
- <!--<td nowrap="ON" align="middle" class="corr_cell"><a href="/corr_scatter_plot?dataset_1={{ trait.dataset.name }}&dataset_2={{ result[0].dataset.name }}&trait_1={{ trait.name }}&trait_2={{ result[0].name }}"><font style="font-size: 11px;{% if result[1] > 0.7 %} color: red; {% elif result[1] > 0.5 %} color: #FF6600; {% elif result[1] < -0.7 %} color: blue; {% elif result[1] < -0.5 %} color: #009900; {% else %} color: #000000; {% endif %}" ><span class="corr_value">{{ '%0.3f' % result[1] }}</span><br>{{ result[2] }}</font></a></td>-->
<td nowrap="ON" align="middle" class="corr_cell"><a href="/corr_scatter_plot?dataset_1={{ trait.dataset.name }}&dataset_2={{ result[0].dataset.name }}&trait_1={{ trait.name }}&trait_2={{ result[0].name }}"><font style="font-size: 11px; color: #000000;" ><span class="corr_value">{{ '%0.3f' % result[1] }}</span><br>{{ result[2] }}</font></a></td>
{% endif %}
{% endfor %}