about summary refs log tree commit diff
path: root/wqflask
diff options
context:
space:
mode:
authorzsloan2020-11-02 13:16:59 -0600
committerzsloan2020-11-02 13:16:59 -0600
commit2864bf07f919dacc72b5df590b140881bbe8dc0c (patch)
treef05f57a030fdfcca6a209f721af5e55d7b73628d /wqflask
parentad716823091959a5332173a0fd2a040c969d2712 (diff)
downloadgenenetwork2-2864bf07f919dacc72b5df590b140881bbe8dc0c.tar.gz
Changed correlation page logic to skip over traits that share fewer than 6 samples + traits that user doesn't have permission to access
* wqflask/wqflask/correlation/show_corr_results.py - Moved the num_overlap check so that it never attempts to calculate the correlation if it's too low + checked if trait_object is None in the main loop (since it would be returned as None if the user doesn't have permissions
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/correlation/show_corr_results.py19
1 files changed, 11 insertions, 8 deletions
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
+