aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wqflask/utility/redis_tools.py10
-rw-r--r--wqflask/wqflask/correlation/show_corr_results.py19
2 files changed, 18 insertions, 11 deletions
diff --git a/wqflask/utility/redis_tools.py b/wqflask/utility/redis_tools.py
index d855a7fa..236cc755 100644
--- a/wqflask/utility/redis_tools.py
+++ b/wqflask/utility/redis_tools.py
@@ -25,6 +25,10 @@ def is_redis_available():
return True
+def load_json_from_redis(item_list, column_value):
+ return json.loads(item_list[str.encode(column_value)])
+
+
def get_user_id(column_name, column_value):
user_list = Redis.hgetall("users")
key_list = []
@@ -46,7 +50,7 @@ def get_user_by_unique_column(column_name, column_value):
if column_name in user_ob and user_ob[column_name] == column_value:
item_details = user_ob
else:
- item_details = json.loads(user_list[column_value])
+ item_details = load_json_from_redis(user_list, column_value)
return item_details
@@ -70,7 +74,7 @@ def get_users_like_unique_column(column_name, column_value):
if column_value in user_ob[column_name]:
matched_users.append(user_ob)
else:
- matched_users.append(json.loads(user_list[column_value]))
+ matched_users.append(load_json_from_redis(user_list, column_value))
return matched_users
@@ -199,7 +203,7 @@ def get_groups_like_unique_column(column_name, column_value):
if column_value in group_info[column_name]:
matched_groups.append(group_info)
else:
- matched_groups.append(json.loads(group_list[column_value]))
+ matched_groups.append(load_json_from_redis(group_list, column_value))
return matched_groups
diff --git a/wqflask/wqflask/correlation/show_corr_results.py b/wqflask/wqflask/correlation/show_corr_results.py
index e710bacd..4c2b64ba 100644
--- a/wqflask/wqflask/correlation/show_corr_results.py
+++ b/wqflask/wqflask/correlation/show_corr_results.py
@@ -184,6 +184,8 @@ class CorrelationResults(object):
for _trait_counter, trait in enumerate(list(self.correlation_data.keys())[:self.return_number]):
trait_object = create_trait(dataset=self.target_dataset, name=trait, get_qtl_info=True, get_sample_info=False)
+ if not trait_object:
+ continue
if self.target_dataset.type == "ProbeSet" or self.target_dataset.type == "Geno":
#ZS: Convert trait chromosome to an int for the location range option
@@ -434,15 +436,15 @@ class CorrelationResults(object):
self.this_trait_vals, target_vals, num_overlap = corr_result_helpers.normalize_values(self.this_trait_vals, target_vals)
- #ZS: 2015 could add biweight correlation, see http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3465711/
- if self.corr_method == 'bicor':
- sample_r, sample_p = do_bicor(self.this_trait_vals, target_vals)
- elif self.corr_method == 'pearson':
- sample_r, sample_p = scipy.stats.pearsonr(self.this_trait_vals, target_vals)
- else:
- sample_r, sample_p = scipy.stats.spearmanr(self.this_trait_vals, target_vals)
-
if num_overlap > 5:
+ #ZS: 2015 could add biweight correlation, see http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3465711/
+ if self.corr_method == 'bicor':
+ sample_r, sample_p = do_bicor(self.this_trait_vals, target_vals)
+ elif self.corr_method == 'pearson':
+ sample_r, sample_p = scipy.stats.pearsonr(self.this_trait_vals, target_vals)
+ else:
+ sample_r, sample_p = scipy.stats.spearmanr(self.this_trait_vals, target_vals)
+
if numpy.isnan(sample_r):
pass
else:
@@ -635,3 +637,4 @@ def get_header_fields(data_type, corr_method):
'Sample p(r)']
return header_fields
+