diff options
Diffstat (limited to 'wqflask')
-rwxr-xr-x | wqflask/wqflask/correlation/show_corr_results.py | 48 | ||||
-rwxr-xr-x | wqflask/wqflask/templates/show_trait.html | 26 | ||||
-rwxr-xr-x | wqflask/wqflask/templates/show_trait_calculate_correlations.html | 17 |
3 files changed, 72 insertions, 19 deletions
diff --git a/wqflask/wqflask/correlation/show_corr_results.py b/wqflask/wqflask/correlation/show_corr_results.py index 63631350..6a120325 100755 --- a/wqflask/wqflask/correlation/show_corr_results.py +++ b/wqflask/wqflask/correlation/show_corr_results.py @@ -104,6 +104,12 @@ class CorrelationResults(object): self.sample_data = {} self.corr_type = start_vars['corr_type'] self.corr_method = start_vars['corr_sample_method'] + if start_vars['min_expr'] == "": + self.min_expr = 0 + else: + 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.get_formatted_corr_type() self.return_number = int(start_vars['corr_return_results']) @@ -164,27 +170,30 @@ class CorrelationResults(object): 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) + 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): + + (trait_object.sample_r, + trait_object.sample_p, + trait_object.num_overlap) = self.correlation_data[trait] - (trait_object.sample_r, - trait_object.sample_p, - trait_object.num_overlap) = self.correlation_data[trait] - - #trait_object.sample_p = self.correlation_data[trait][1] - #trait_object.num_overlap = self.correlation_data[trait][2] - - #Get symbol for trait and call function that gets each tissue value from the database (tables TissueProbeSetXRef, - #TissueProbeSetData, etc) and calculates the correlation (cal_zero_order_corr_for_tissue in correlation_functions) + #Get symbol for trait and call function that gets each tissue value from the database (tables TissueProbeSetXRef, + #TissueProbeSetData, etc) and calculates the correlation (cal_zero_order_corr_for_tissue in correlation_functions) - # Set some sane defaults - trait_object.tissue_corr = 0 - trait_object.tissue_pvalue = 0 - trait_object.lit_corr = 0 - if self.corr_type == "tissue": - trait_object.tissue_corr = tissue_corr_data[trait][1] - trait_object.tissue_pvalue = tissue_corr_data[trait][2] - elif self.corr_type == "lit": - trait_object.lit_corr = lit_corr_data[trait][1] - self.correlation_results.append(trait_object) + # Set some sane defaults + trait_object.tissue_corr = 0 + trait_object.tissue_pvalue = 0 + trait_object.lit_corr = 0 + if self.corr_type == "tissue": + trait_object.tissue_corr = tissue_corr_data[trait][1] + trait_object.tissue_pvalue = tissue_corr_data[trait][2] + elif self.corr_type == "lit": + trait_object.lit_corr = lit_corr_data[trait][1] + self.correlation_results.append(trait_object) self.target_dataset.get_trait_info(self.correlation_results, self.target_dataset.group.species) @@ -478,6 +487,7 @@ class CorrelationResults(object): this_trait_vals, target_vals, num_overlap = corr_result_helpers.normalize_values( 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 == 'pearson': sample_r, sample_p = scipy.stats.pearsonr(this_trait_vals, target_vals) else: diff --git a/wqflask/wqflask/templates/show_trait.html b/wqflask/wqflask/templates/show_trait.html index 55464635..c5921ccf 100755 --- a/wqflask/wqflask/templates/show_trait.html +++ b/wqflask/wqflask/templates/show_trait.html @@ -12,6 +12,8 @@ <link rel="stylesheet" type="text/css" href="/static/new/packages/nvd3/nv.d3.min.css" /> <link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/css/jquery.dataTables.css" /> <link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/extensions/buttons.bootstrap.css" /> + <link rel="stylesheet" type="text/css" href="/static/new/packages/noUiSlider/nouislider.css" /> + <link rel="stylesheet" type="text/css" href="/static/new/packages/noUiSlider/nouislider.pips.css" /> <link rel="stylesheet" type="text/css" href="/static/packages/DT_bootstrap/DT_bootstrap.css" /> {% endblock %} @@ -147,6 +149,7 @@ <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/dataTables.naturalSort.js"></script> <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/extensions/dataTables.colResize.js"></script> <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/extensions/dataTables.colReorder.js"></script> + <script language="javascript" type="text/javascript" src="/static/new/packages/noUiSlider/nouislider.js"></script> <script type="text/javascript" charset="utf-8"> function getValue(x) { @@ -251,6 +254,29 @@ "paging": false } ); {% endif %} + + var slider = document.getElementById('p_range_slider'); + noUiSlider.create(slider, { + start: [-1.0, 1.0], + range: { + 'min': [-1.0], + 'max': [1.0] + } + }); + + var slider_display = [ + document.getElementById('p_range_lower'), + document.getElementById('p_range_upper') + ]; + var slider_values = [ + $('input[name=p_range_lower]'), + $('input[name=p_range_upper]') + ]; + + slider.noUiSlider.on('update', function( values, handle ) { + slider_display[handle].innerHTML = values[handle]; + slider_values[handle].val(values[handle]); + }); }); </script> diff --git a/wqflask/wqflask/templates/show_trait_calculate_correlations.html b/wqflask/wqflask/templates/show_trait_calculate_correlations.html index f02d1705..cefe9763 100755 --- a/wqflask/wqflask/templates/show_trait_calculate_correlations.html +++ b/wqflask/wqflask/templates/show_trait_calculate_correlations.html @@ -72,6 +72,23 @@ </select> </div> </div> + + <div class="form-group"> + <label class="col-xs-1 control-label">Min Expr</label> + <div class="col-xs-2 controls"> + <input name="min_expr" value="" type="text" class="form-control" style="width: 50px;"> + </div> + </div> + <div class="form-group"> + <label class="col-xs-1 control-label">Range</label> + <div class="col-xs-3 controls"> + <input name="p_range_lower" value="" type="hidden"> + <input name="p_range_upper" value="" type="hidden"> + <div id="p_range_slider" ></div> + <span style="font: 400 12px Arial; color: #888; display: block; margin: 15px 0;" id="p_range_lower"></span> + <span style="font: 400 12px Arial; color: #888; display: block; margin: 15px 0;" id="p_range_upper"></span> + </div> + </div> <div class="form-group"> <label for="corr_sample_method" class="col-xs-1 control-label"></label> |