From e9727c576312c22e3fdc0a7ba153c414ad8e98da Mon Sep 17 00:00:00 2001 From: zsloan Date: Mon, 12 Oct 2015 15:44:07 +0000 Subject: Fixed an error page that occurs if traits with no overlapping samples are used for correlation matrix --- .../wqflask/correlation_matrix/show_corr_matrix.py | 21 +++++++++++---------- wqflask/wqflask/templates/correlation_matrix.html | 1 - 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 %} n
{{ result[2] }}
{% else %} - {{ '%0.3f' % result[1] }}
{{ result[2] }}
{% endif %} {% endfor %} -- cgit v1.2.3