From cbc4e864f3d05da3da54a14a3cad3ea0d18d087f Mon Sep 17 00:00:00 2001
From: zsloan
Date: Thu, 15 Mar 2018 17:59:35 +0000
Subject: Changed appearance of mapping and correlation options on trait page
Fixed issue where changed sample values were not passed to qtlreaper mapping ("Interval Mapping")
Loading factors and their plot are hidden in situations where there's some error with calculating principal components
Added GEMMA description and changed order of descriptions for mapping options on trait page
---
.../wqflask/correlation_matrix/show_corr_matrix.py | 9 +-
.../wqflask/marker_regression/marker_regression.py | 1 +
.../marker_regression/marker_regression_gn1.py | 2 +
.../wqflask/marker_regression/qtlreaper_mapping.py | 17 ++--
wqflask/wqflask/templates/correlation_matrix.html | 3 +-
.../show_trait_calculate_correlations.html | 106 ++++++++++-----------
.../templates/show_trait_mapping_tools.html | 98 ++++++++++---------
wqflask/wqflask/views.py | 2 +-
8 files changed, 125 insertions(+), 113 deletions(-)
diff --git a/wqflask/wqflask/correlation_matrix/show_corr_matrix.py b/wqflask/wqflask/correlation_matrix/show_corr_matrix.py
index b34beb7b..077386a3 100644
--- a/wqflask/wqflask/correlation_matrix/show_corr_matrix.py
+++ b/wqflask/wqflask/correlation_matrix/show_corr_matrix.py
@@ -173,9 +173,12 @@ class CorrelationMatrix(object):
for sample in self.all_sample_list:
groups.append(1)
- pca = self.calculate_pca(range(len(self.traits)), corr_eigen_value, corr_eigen_vectors)
-
- self.loadings_array = self.process_loadings()
+ try:
+ self.pca_works = "True"
+ pca = self.calculate_pca(range(len(self.traits)), corr_eigen_value, corr_eigen_vectors)
+ self.loadings_array = self.process_loadings()
+ except:
+ self.pca_works = "False"
self.js_data = dict(traits = [trait.name for trait in self.traits],
groups = groups,
diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py
index 087b95b4..db4f8f46 100644
--- a/wqflask/wqflask/marker_regression/marker_regression.py
+++ b/wqflask/wqflask/marker_regression/marker_regression.py
@@ -228,6 +228,7 @@ class MarkerRegression(object):
results, self.json_data, self.perm_output, self.suggestive, self.significant, self.bootstrap_results = qtlreaper_mapping.gen_reaper_results(self.this_trait,
self.dataset,
self.samples,
+ self.vals,
self.json_data,
self.num_perm,
self.bootCheck,
diff --git a/wqflask/wqflask/marker_regression/marker_regression_gn1.py b/wqflask/wqflask/marker_regression/marker_regression_gn1.py
index 211cf187..66884b0c 100644
--- a/wqflask/wqflask/marker_regression/marker_regression_gn1.py
+++ b/wqflask/wqflask/marker_regression/marker_regression_gn1.py
@@ -1204,6 +1204,8 @@ class MarkerRegression(object):
else:
if self.mapping_method == "gemma" or self.mapping_method == "gemma_bimbam":
string2 = 'Using GEMMA mapping method with no control for other QTLs.'
+ if self.covariates != "":
+ string3 = 'Using following traits as covariates: ' + self.covariates
elif self.mapping_method == "rqtl_plink" or self.mapping_method == "rqtl_geno":
string2 = 'Using R/qtl mapping method with no control for other QTLs.'
elif self.mapping_method == "plink":
diff --git a/wqflask/wqflask/marker_regression/qtlreaper_mapping.py b/wqflask/wqflask/marker_regression/qtlreaper_mapping.py
index 50228b5e..6b58190f 100644
--- a/wqflask/wqflask/marker_regression/qtlreaper_mapping.py
+++ b/wqflask/wqflask/marker_regression/qtlreaper_mapping.py
@@ -1,17 +1,20 @@
-def gen_reaper_results(this_trait, dataset, samples_before, json_data, num_perm, bootCheck, num_bootstrap, do_control, control_marker, manhattan_plot):
+import utility.logger
+logger = utility.logger.getLogger(__name__ )
+
+def gen_reaper_results(this_trait, dataset, samples_before, trait_vals, json_data, num_perm, bootCheck, num_bootstrap, do_control, control_marker, manhattan_plot):
genotype = dataset.group.read_genotype_file()
if manhattan_plot != True:
genotype = genotype.addinterval()
- samples, values, variances, sample_aliases = this_trait.export_informative()
-
trimmed_samples = []
trimmed_values = []
- for i in range(0, len(samples)):
- if this_trait.data[samples[i]].name in samples_before:
- trimmed_samples.append(samples[i])
- trimmed_values.append(values[i])
+ for i in range(0, len(samples_before)):
+ try:
+ trimmed_values.append(float(trait_vals[i]))
+ trimmed_samples.append(samples_before[i])
+ except:
+ pass
perm_output = []
bootstrap_results = []
diff --git a/wqflask/wqflask/templates/correlation_matrix.html b/wqflask/wqflask/templates/correlation_matrix.html
index ab793d58..d27788a8 100644
--- a/wqflask/wqflask/templates/correlation_matrix.html
+++ b/wqflask/wqflask/templates/correlation_matrix.html
@@ -61,6 +61,7 @@
+{% if pca_works == "True" %}