From 048bbf7e4ee49fece9652dad401f40b6a865e1a9 Mon Sep 17 00:00:00 2001 From: zsloan Date: Thu, 24 Sep 2015 17:13:19 +0000 Subject: Location range feature should work for correlations now, though the interface appearance needs to be improved --- wqflask/wqflask/correlation/show_corr_results.py | 39 +++++++++++++++++++--- .../show_trait_calculate_correlations.html | 14 ++++++++ 2 files changed, 49 insertions(+), 4 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/correlation/show_corr_results.py b/wqflask/wqflask/correlation/show_corr_results.py index 6a120325..63a7a555 100755 --- a/wqflask/wqflask/correlation/show_corr_results.py +++ b/wqflask/wqflask/correlation/show_corr_results.py @@ -110,6 +110,17 @@ class CorrelationResults(object): self.min_expr = float(start_vars['min_expr']) self.p_range_lower = float(start_vars['p_range_lower']) self.p_range_upper = float(start_vars['p_range_upper']) + self.min_location_chr = start_vars['min_loc_chr'] + self.max_location_chr = start_vars['max_loc_chr'] + if start_vars['min_loc_mb'].isdigit(): + self.min_location_mb = start_vars['min_loc_mb'] + else: + self.min_location_mb = 0 + if start_vars['max_loc_mb'].isdigit(): + self.max_location_mb = start_vars['max_loc_mb'] + else: + self.max_location_mb = 1000 + self.max_location = [start_vars['max_loc_chr'], start_vars['max_loc_mb']] self.get_formatted_corr_type() self.return_number = int(start_vars['corr_return_results']) @@ -167,15 +178,35 @@ class CorrelationResults(object): key=lambda t: -abs(t[1][0]))) + #ZS: Convert min/max chromosome to an int for the location range option + min_chr_as_int = 1 + max_chr_as_int = 30 #Just to make sure all are included if user inputs nothing + for order_id, chr_info in self.dataset.species.chromosomes.chromosomes.iteritems(): + if chr_info.name == self.min_location_chr: + min_chr_as_int = order_id + if chr_info.name == self.max_location_chr: + max_chr_as_int = order_id + for _trait_counter, trait in enumerate(self.correlation_data.keys()[:self.return_number]): print("trait name:", trait) trait_object = GeneralTrait(dataset=self.target_dataset, name=trait, get_qtl_info=True) - print("trait_object.mean:", trait_object.mean) - print("self.min_expr:", self.min_expr) - print("self.p_range_upper:", self.p_range_upper) + + #ZS: Convert trait chromosome to an int for the location range option + chr_as_int = 0 + for order_id, chr_info in self.dataset.species.chromosomes.chromosomes.iteritems(): + if chr_info.name == trait_object.chr: + chr_as_int = order_id + if (float(trait_object.mean) > self.min_expr and float(self.correlation_data[trait][0]) > self.p_range_lower and - float(self.correlation_data[trait][0]) < self.p_range_upper): + float(self.correlation_data[trait][0]) < self.p_range_upper and + chr_as_int >= min_chr_as_int and + chr_as_int <= max_chr_as_int): + + if (chr_as_int == min_chr_as_int and float(trait_object.mb) < float(self.min_location_mb)): + continue + elif (chr_as_int == max_chr_as_int and float(trait_object.mb) > float(self.max_location_mb)): + continue (trait_object.sample_r, trait_object.sample_p, diff --git a/wqflask/wqflask/templates/show_trait_calculate_correlations.html b/wqflask/wqflask/templates/show_trait_calculate_correlations.html index cefe9763..65b9d08e 100755 --- a/wqflask/wqflask/templates/show_trait_calculate_correlations.html +++ b/wqflask/wqflask/templates/show_trait_calculate_correlations.html @@ -79,6 +79,20 @@ +
+ +
+ + Min Chr: + Mb: + +
+ + Max Chr: + Mb: + +
+
-- cgit v1.2.3 From f4733114121b2f55bfcbd093ab2728f86860c9cd Mon Sep 17 00:00:00 2001 From: zsloan Date: Fri, 25 Sep 2015 16:41:03 +0000 Subject: Made the basic statistics table look nicer and got rid of the foo column if only one sample group --- wqflask/wqflask/show_trait/show_trait.py | 9 +++-- .../wqflask/static/new/javascript/show_trait.js | 5 --- wqflask/wqflask/templates/show_trait.html | 47 ++++++++++++++++++++-- .../templates/show_trait_statistics_new.html | 7 ++-- 4 files changed, 53 insertions(+), 15 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py index e83437ab..850c99a7 100755 --- a/wqflask/wqflask/show_trait/show_trait.py +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -139,9 +139,12 @@ class ShowTrait(object): self.temp_uuid = uuid.uuid4() self.sample_group_types = OrderedDict() - self.sample_group_types['samples_primary'] = self.dataset.group.name + " Only" - self.sample_group_types['samples_other'] = "Non-" + self.dataset.group.name - self.sample_group_types['samples_all'] = "All Cases" + if len(self.sample_groups) > 1: + self.sample_group_types['samples_primary'] = self.dataset.group.name + " Only" + self.sample_group_types['samples_other'] = "Non-" + self.dataset.group.name + self.sample_group_types['samples_all'] = "All Cases" + else: + self.sample_group_types['samples_primary'] = self.dataset.group.name sample_lists = [group.sample_list for group in self.sample_groups] print("sample_lists is:", pf(sample_lists)) diff --git a/wqflask/wqflask/static/new/javascript/show_trait.js b/wqflask/wqflask/static/new/javascript/show_trait.js index 302d5ec4..1dd54e3a 100755 --- a/wqflask/wqflask/static/new/javascript/show_trait.js +++ b/wqflask/wqflask/static/new/javascript/show_trait.js @@ -179,13 +179,10 @@ for (key in _ref) { if (!__hasProp.call(_ref, key)) continue; value = _ref[key]; - console.log("aa key:", key); - console.log("aa value:", value); the_id = process_id("column", key); header += "" + value + ""; } header += ""; - console.log("windex header is:", header); the_rows = ""; for (_i = 0, _len = Stat_Table_Rows.length; _i < _len; _i++) { row = Stat_Table_Rows[_i]; @@ -201,9 +198,7 @@ for (key in _ref1) { if (!__hasProp.call(_ref1, key)) continue; value = _ref1[key]; - console.log("apple key:", key); the_id = process_id(key, row.vn); - console.log("the_id:", the_id); row_line += "foo"; } row_line += ""; diff --git a/wqflask/wqflask/templates/show_trait.html b/wqflask/wqflask/templates/show_trait.html index c5921ccf..a86a149d 100755 --- a/wqflask/wqflask/templates/show_trait.html +++ b/wqflask/wqflask/templates/show_trait.html @@ -212,7 +212,7 @@ "buttons": [ 'csv' ], - "sDom": "RZBtir", + "sDom": "RZBtr", "iDisplayLength": -1, "autoWidth": false, "bLengthChange": true, @@ -240,7 +240,7 @@ "buttons": [ 'csv' ], - "sDom": "RZBtir", + "sDom": "RZBtr", "iDisplayLength": -1, "autoWidth": false, "bLengthChange": true, @@ -254,7 +254,48 @@ "paging": false } ); {% endif %} - + + console.log("SAMPLE GROUP TYPES:", js_data.sample_group_types) + if (Object.keys(js_data.sample_group_types).length > 1) { + $('#stats_table').DataTable( { + "columns": [ + { "bSortable": false }, + { "bSortable": false }, + { "bSortable": false }, + { "bSortable": false } + ], + "sDom": "RZtr", + "iDisplayLength": -1, + "autoWidth": false, + "bLengthChange": true, + "bDeferRender": true, + "bSortClasses": false, + "colResize": { + "tableWidthFixed": false + }, + "paging": false + } ); + } + else { + $('#stats_table').DataTable( { + "columns": [ + { "bSortable": false }, + { "bSortable": false } + ], + "sDom": "RZtr", + "iDisplayLength": -1, + "autoWidth": false, + "bLengthChange": true, + "bDeferRender": true, + "bSortClasses": false, + "colResize": { + "tableWidthFixed": false + }, + "paging": false + } ); + + } + var slider = document.getElementById('p_range_slider'); noUiSlider.create(slider, { start: [-1.0, 1.0], diff --git a/wqflask/wqflask/templates/show_trait_statistics_new.html b/wqflask/wqflask/templates/show_trait_statistics_new.html index b7323ba3..1c269fda 100755 --- a/wqflask/wqflask/templates/show_trait_statistics_new.html +++ b/wqflask/wqflask/templates/show_trait_statistics_new.html @@ -24,10 +24,9 @@
-
-

Stats

-
-
+ +
+
-- cgit v1.2.3 From 9f15eac5a1f6301f93e3dfc276924baca8f91d41 Mon Sep 17 00:00:00 2001 From: zsloan Date: Fri, 25 Sep 2015 16:44:52 +0000 Subject: Forgot to add the table-striped class to the basic stats table to make its style the same as other tables --- wqflask/wqflask/templates/show_trait_statistics_new.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/templates/show_trait_statistics_new.html b/wqflask/wqflask/templates/show_trait_statistics_new.html index 1c269fda..1932d968 100755 --- a/wqflask/wqflask/templates/show_trait_statistics_new.html +++ b/wqflask/wqflask/templates/show_trait_statistics_new.html @@ -24,8 +24,7 @@
- -
+
-- cgit v1.2.3