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(-) (limited to 'wqflask') 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" %}

Factor Loadings Plot

@@ -93,7 +94,7 @@ - +{% endif %} {% endblock %} {% block js %} diff --git a/wqflask/wqflask/templates/show_trait_calculate_correlations.html b/wqflask/wqflask/templates/show_trait_calculate_correlations.html index c5f815ce..ef233333 100644 --- a/wqflask/wqflask/templates/show_trait_calculate_correlations.html +++ b/wqflask/wqflask/templates/show_trait_calculate_correlations.html @@ -1,9 +1,10 @@
+
- -
+ +
{% for tissue in corr_tools.dataset_menu %} {% if tissue.tissue %} @@ -37,8 +38,8 @@
- -
+ +
{% for group, pretty_group in sample_group_types.items() %} @@ -64,8 +65,8 @@
- -
+ +
- -
+ +
Chr:     Mb:  to  @@ -89,8 +90,8 @@
- -
+ +
@@ -103,48 +104,45 @@
- -
+ +
- -
- -
- - The Sample Correlation - is computed - between trait data and any - other traits in the sample database selected above. Use - Spearman - Rank - when the sample size is small (<20) or when there are influential outliers. - - - -
-
+
+
+ + The Sample Correlation + is computed + between trait data and any + other traits in the sample database selected above. Use + Spearman + Rank + when the sample size is small (<20) or when there are influential outliers. + + + +
\ No newline at end of file diff --git a/wqflask/wqflask/templates/show_trait_mapping_tools.html b/wqflask/wqflask/templates/show_trait_mapping_tools.html index ab2e2aae..03590c2c 100644 --- a/wqflask/wqflask/templates/show_trait_mapping_tools.html +++ b/wqflask/wqflask/templates/show_trait_mapping_tools.html @@ -1,5 +1,5 @@
- {% if (use_pylmm_rqtl and dataset.group.species != "human") or use_plink_gemma %} + {% if dataset.group.mapping_names|length > 0 %}
@@ -41,7 +41,7 @@
{% if genofiles and genofiles|length>0 %}
- +
- -
+ +
@@ -75,7 +75,7 @@
-->
- +
{% if g.user_session.user_ob and (g.user_session.user_ob.display_num_collections() == "") %} No collections available. Please add traits to a collection to use them as covariates. @@ -86,13 +86,13 @@
- + {% endif %}
- -
+ +
@@ -116,7 +116,7 @@
{% if genofiles and genofiles|length>0 %}
- +
- +
- -
+ +
{% if dataset.type == 'ProbeSet' and this_trait.locus_chr != "" %} {% else %} @@ -184,8 +184,8 @@
- -
+ +
- -
+ +
@@ -212,7 +212,7 @@
{% if genofiles and genofiles|length>0 %}
- +
- -
+ +
{% if dataset.type == 'ProbeSet' and this_trait.locus_chr != "" %} {% else %} @@ -248,7 +248,7 @@
- +
@@ -289,8 +289,8 @@
-->
- -
+ +
- -
+ +
@@ -316,7 +316,7 @@
{% if genofiles and genofiles|length>0 %}
- +
{% for item in genofiles %} @@ -354,13 +354,13 @@
{% endif %}
- +
- +
{% if g.user_session.user_ob and (g.user_session.user_ob.display_num_collections() == "") %} No collections available. Please add traits to a collection to use them as covariates. @@ -376,8 +376,8 @@
- -
+ +
@@ -389,16 +389,16 @@