diff options
-rw-r--r-- | wqflask/wqflask/correlation/show_corr_results.py | 28 | ||||
-rw-r--r-- | wqflask/wqflask/marker_regression/gemma_mapping.py | 18 | ||||
-rw-r--r-- | wqflask/wqflask/templates/correlation_page.html | 51 |
3 files changed, 72 insertions, 25 deletions
diff --git a/wqflask/wqflask/correlation/show_corr_results.py b/wqflask/wqflask/correlation/show_corr_results.py index 3d1c0d17..c072cf82 100644 --- a/wqflask/wqflask/correlation/show_corr_results.py +++ b/wqflask/wqflask/correlation/show_corr_results.py @@ -167,9 +167,26 @@ class CorrelationResults(object): self.sample_data = {} self.corr_type = start_vars['corr_type'] self.corr_method = start_vars['corr_sample_method'] +<<<<<<< HEAD + if 'min_expr' in start_vars: + if start_vars['min_expr'] != "": + self.min_expr = float(start_vars['min_expr']) + else: + self.min_expr = None + logger.debug("P RANGE:", start_vars['p_range_lower']) + try: + self.p_range_lower = float(start_vars['p_range_lower']) + except: + self.p_range_lower = -1.00 + try: + self.p_range_upper = float(start_vars['p_range_upper']) + except: + self.p_range_upper = 1.00 +======= self.min_expr = get_float(start_vars,'min_expr') self.p_range_lower = get_float(start_vars,'p_range_lower',-1.0) self.p_range_upper = get_float(start_vars,'p_range_upper',1.0) +>>>>>>> f44a18ccd4c45ab7fd2179c9000d1bf836e3f654 if ('loc_chr' in start_vars and 'min_loc_mb' in start_vars and @@ -1195,6 +1212,17 @@ class CorrelationResults(object): import math import reaper + def cmpOrder2(A,B): + try: + if A[-1] < B[-1]: + return -1 + elif A[-1] == B[-1]: + return 0 + else: + return 1 + except: + return 0 + def calCorrelation(dbdata,userdata,N): X = [] Y = [] diff --git a/wqflask/wqflask/marker_regression/gemma_mapping.py b/wqflask/wqflask/marker_regression/gemma_mapping.py index 68920130..233a5c76 100644 --- a/wqflask/wqflask/marker_regression/gemma_mapping.py +++ b/wqflask/wqflask/marker_regression/gemma_mapping.py @@ -3,7 +3,7 @@ import os, math, string, random, json from base import webqtlConfig from base.trait import GeneralTrait from base.data_set import create_dataset -from utility.tools import flat_files, GEMMA_COMMAND, GEMMA_WRAPPER_COMMAND, TEMPDIR, assert_bin, assert_file +from utility.tools import flat_files, GEMMA_COMMAND, GEMMA_WRAPPER_COMMAND, TEMPDIR import utility.logger logger = utility.logger.getLogger(__name__ ) @@ -11,7 +11,6 @@ logger = utility.logger.getLogger(__name__ ) def run_gemma(this_dataset, samples, vals, covariates, method, use_loco): """Generates p-values for each marker using GEMMA""" - assert_bin(GEMMA_COMMAND); if this_dataset.group.genofile != None: genofile_name = this_dataset.group.genofile[:-5] else: @@ -193,7 +192,7 @@ def parse_gemma_output(genofile_name): # if marker['chr'] != previous_chr: # previous_chr = marker['chr'] marker['Mb'] = float(line.split("\t")[2]) / 1000000 - marker['p_value'] = float(line.split("\t")[10]) + marker['p_value'] = float(line.split("\t")[11]) if math.isnan(marker['p_value']) or (marker['p_value'] <= 0): marker['lod_score'] = 0 #marker['lrs_value'] = 0 @@ -203,20 +202,15 @@ def parse_gemma_output(genofile_name): marker_obs.append(marker) included_markers.append(line.split("\t")[1]) - p_values.append(float(line.split("\t")[10])) + p_values.append(float(line.split("\t")[11])) return marker_obs def parse_loco_output(this_dataset, gwa_output_filename): output_filelist = [] - jsonfn = "{}/gn2/".format(TEMPDIR) + gwa_output_filename + ".json" - assert_file(jsonfn) - try: - with open(jsonfn) as data_file: - data = json.load(data_file) - except: - logger.error("Can not parse "+jsonfn) + with open("{}/gn2/".format(TEMPDIR) + gwa_output_filename + ".json") as data_file: + data = json.load(data_file) files = data['files'] for file in files: @@ -253,4 +247,4 @@ def parse_loco_output(this_dataset, gwa_output_filename): included_markers.append(line.split("\t")[1]) p_values.append(float(line.split("\t")[10])) - return marker_obs + return marker_obs
\ No newline at end of file diff --git a/wqflask/wqflask/templates/correlation_page.html b/wqflask/wqflask/templates/correlation_page.html index fa9e3585..629724c0 100644 --- a/wqflask/wqflask/templates/correlation_page.html +++ b/wqflask/wqflask/templates/correlation_page.html @@ -1,9 +1,10 @@ {% extends "base.html" %} {% block css %} + <link rel="stylesheet" type="text/css" href="/static/new/packages/tabulator/css/tabulator.css" /> + <!-- <link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/css/jquery.dataTables.css" /> - <link rel="stylesheet" type="text/css" href="/static/packages/DT_bootstrap/DT_bootstrap.css" /> - <link rel="stylesheet" type="text/css" href="/static/packages/TableTools/media/css/TableTools.css" /> <link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/extensions/buttons.bootstrap.css" /> + --> {% endblock %} {% block content %} @@ -63,15 +64,14 @@ </div> <div style="width: {% if target_dataset.type == "ProbeSet" %}1600px{% elif target_dataset.type == "Publish" %}1400px{% else %}800px{% endif %};"> - <table id="trait_table" class="display dataTable nowrap" style="float: left;"> + <table id="trait_table" class="display dataTable nowrap" style="font-size: 12px; float: left;"> <thead> <tr> - <th style="width: 30px;"></th> {% for header in target_dataset.header_fields %} {% if header == 'Year' %} <th>{{header}}</th> {% elif header == 'Max LRS' %} - <th>Max LRS<a href="http://genenetwork.org//glossary.html#L" target="_blank"><sup style="color:#f00"> ?</sup></a></th> + <th>Max LRS</th> {% elif header == 'Max LRS Location' %} <th>{{header}}</th> {% elif header == 'Location' %} @@ -79,7 +79,7 @@ {% elif header == 'Mean' %} <th>{{header}}</th> {% elif header == 'Additive Effect' %} - <th>Additive Effect<a href="http://genenetwork.org//glossary.html#A" target="_blank"><sup style="color:#f00"> ?</sup></a></th> + <th>Additive Effect</th> {% elif header == 'Index' %} <th>{{header}}</th> {% elif header == 'N' %} @@ -91,7 +91,7 @@ {% if target_dataset.type == "ProbeSet" %} {% if corr_method == 'pearson' %} <th>Sample r</th> - <th> N</th> + <th>N</th> <th>Sample p(r)</th> <th>Lit r</th> <th>Tissue r</th> @@ -129,8 +129,7 @@ <tbody> {% for trait in correlation_results %} <tr> - <td style="padding-left: 8px; padding-right: 0px; padding-top: 4px; align: center;"><INPUT TYPE="checkbox" NAME="searchResult" class="checkbox trait_checkbox" style="padding-right: 0px;" VALUE="{{ data_hmac('{}:{}'.format(trait.name, trait.dataset.name)) }}"></td> - <td align="right">{{ loop.index }}</td> + <td style="padding-left: 8px; padding-right: 0px; padding-top: 4px; align: center; display: inline;">{{ loop.index }}<INPUT TYPE="checkbox" NAME="searchResult" class="checkbox trait_checkbox" style="padding-right: 0px;" VALUE="{{ data_hmac('{}:{}'.format(trait.name, trait.dataset.name)) }}"></td> <td> <a href="{{ url_for('show_trait_page', trait_id = trait.name, @@ -191,13 +190,17 @@ {% block js %} <script type="text/javascript" src="/static/new/javascript/search_results.js"></script> + <script language="javascript" type="text/javascript" src="/static/new/js_external/jszip.min.js"></script> + <script language="javascript" type="text/javascript" src="/static/packages/underscore/underscore-min.js"></script> + <script language="javascript" type="text/javascript" src="/static/new/packages/tabulator/js/tabulator.js"></script> + <!-- <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/jquery.dataTables.js"></script> <script language="javascript" type="text/javascript" src="https://cdn.datatables.net/buttons/1.0.0/js/dataTables.buttons.min.js"></script> <script language="javascript" type="text/javascript" src="https://cdn.datatables.net/buttons/1.0.0/js/buttons.html5.min.js"></script> <script language="javascript" type="text/javascript" src="https://cdn.datatables.net/buttons/1.0.0/js/buttons.bootstrap.min.js"></script> - <script language="javascript" type="text/javascript" src="/static/new/js_external/jszip.min.js"></script> <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/dataTables.naturalSort.js"></script> - <script language="javascript" type="text/javascript" src="/static/packages/underscore/underscore-min.js"></script> + --> + <script type="text/javascript" charset="utf-8"> function getValue(x) { if (x.indexOf('input') >= 0) { @@ -213,7 +216,8 @@ } return parseFloat(x); } - + +/* jQuery.fn.dataTableExt.oSort['numeric-html-asc'] = function(a,b) { a = Math.abs(parseFloat($(a).text())); b = Math.abs(parseFloat($(b).text())); @@ -259,10 +263,29 @@ var y = parseFloat(b); return ((x < y) ? 1 : ((x > y) ? -1 : 0)); }; - +*/ $(document).ready( function () { + $("#trait_table").tabulator({ + columns:[ + {title:"Index", formatter:"html"}, + {title:"Record", formatter:"html"}, + {title:"Symbol", formatter:"plaintext"}, + {title:"Description", formatter:"textarea", width:"25%"}, + {title:"Location", formatter:"plaintext"}, + {title:"Mean", formatter:"plaintext"}, + {title:"Max LRS", formatter:"plaintext"}, + {title:"Max LRS Location", formatter:"plaintext"}, + {title:"Additive Effect", formatter:"plaintext"}, + {title:"Sample r", formatter:"html"}, + {title:"N", formatter:"plaintext"}, + {title:"Sample p(r)", formatter:"plaintext"}, + {title:"Lit r", formatter:"plaintext"}, + {title:"Tissue r", formatter:"plaintext"} + ] + }); + $('#trait_table tr').click(function(event) { if (event.target.type !== 'checkbox') { $(':checkbox', this).trigger('click'); @@ -296,6 +319,7 @@ } } + /* console.time("Creating table"); {% if target_dataset.type == "ProbeSet" %} @@ -447,6 +471,7 @@ } ); {% endif %} console.timeEnd("Creating table"); + */ submit_special = function(url) { $("#correlation_form").attr("action", url); |