aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/base/data_set.py6
-rw-r--r--wqflask/wqflask/marker_regression/marker_regression.py3
-rw-r--r--wqflask/wqflask/show_trait/show_trait.py12
-rw-r--r--wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js3
-rw-r--r--wqflask/wqflask/templates/marker_regression_gn1.html3
-rw-r--r--wqflask/wqflask/templates/show_trait.html1
-rw-r--r--wqflask/wqflask/templates/show_trait_mapping_tools.html36
-rw-r--r--wqflask/wqflask/views.py1
8 files changed, 64 insertions, 1 deletions
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py
index fddfce58..918932fa 100644
--- a/wqflask/base/data_set.py
+++ b/wqflask/base/data_set.py
@@ -278,6 +278,7 @@ class DatasetGroup(object):
self.incparentsf1 = False
self.allsamples = None
self._datasets = None
+ self.genofile = None
def get_specified_markers(self, markers = []):
self.markers = HumanMarkers(self.name, markers)
@@ -408,7 +409,10 @@ class DatasetGroup(object):
genotype_1 = reaper.Dataset()
# reaper barfs on unicode filenames, so here we ensure it's a string
- full_filename = str(locate(self.name+'.geno','genotype'))
+ if self.genofile:
+ full_filename = str(locate(self.genofile, 'genotype'))
+ else:
+ full_filename = str(locate(self.name + '.geno', 'genotype'))
genotype_1.read(full_filename)
if genotype_1.type == "group" and self.parlist:
diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py
index 37ee42a7..543eeede 100644
--- a/wqflask/wqflask/marker_regression/marker_regression.py
+++ b/wqflask/wqflask/marker_regression/marker_regression.py
@@ -165,6 +165,7 @@ class MarkerRegression(object):
self.mapping_scale = "morgan"
self.control_marker = start_vars['control_marker']
self.do_control = start_vars['do_control']
+ self.dataset.group.genofile = start_vars['genofile']
self.method = start_vars['mapmethod_rqtl_geno']
self.model = start_vars['mapmodel_rqtl_geno']
if start_vars['pair_scan'] == "true":
@@ -200,12 +201,14 @@ class MarkerRegression(object):
self.control_marker = start_vars['control_marker']
self.do_control = start_vars['do_control']
+ self.dataset.group.genofile = start_vars['genofile']
logger.info("Running qtlreaper")
results = self.gen_reaper_results()
elif self.mapping_method == "plink":
results = self.run_plink()
elif self.mapping_method == "pylmm":
logger.debug("RUNNING PYLMM")
+ self.dataset.group.genofile = start_vars['genofile']
if self.num_perm > 0:
self.run_permutations(str(temp_uuid))
results = self.gen_data(str(temp_uuid))
diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py
index d9617c7c..ce8b2ced 100644
--- a/wqflask/wqflask/show_trait/show_trait.py
+++ b/wqflask/wqflask/show_trait/show_trait.py
@@ -4,6 +4,7 @@ import string
import os
import cPickle
import uuid
+import json as json
#import pyXLWriter as xl
from collections import OrderedDict
@@ -24,6 +25,7 @@ from basicStatistics import BasicStatisticsFunctions
from pprint import pformat as pf
from utility.tools import flat_files, flat_file_exists
+from utility.tools import get_setting
from utility.logger import getLogger
logger = getLogger(__name__ )
@@ -175,6 +177,7 @@ class ShowTrait(object):
else:
return False
+ self.genofiles = get_genofiles(self.this_trait)
self.use_plink_gemma = check_plink_gemma()
self.use_pylmm_rqtl = check_pylmm_rqtl()
@@ -1260,6 +1263,15 @@ def get_nearest_marker(this_trait, this_db):
else:
return result[0][0]
#return result[0][0], result[1][0]
+
+def get_genofiles(this_trait):
+ jsonfile = "%s/%s.json" % (get_setting('GENOFILE_META'), this_trait.dataset.group.name)
+ try:
+ f = open(jsonfile)
+ except:
+ return None
+ jsondata = json.load(f)
+ return jsondata['genofile']
def get_trait_table_width(sample_groups):
table_width = 35
diff --git a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js
index e9db0a12..e7df9228 100644
--- a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js
+++ b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js
@@ -168,6 +168,7 @@
//$("#progress_bar_container").modal();
url = "/marker_regression";
$('input[name=method]').val("pylmm");
+ $('input[name=genofile').val($('#genofile_pylmm').val());
$('input[name=num_perm]').val($('input[name=num_perm_pylmm]').val());
$('input[name=manhattan_plot]').val($('input[name=manhattan_plot_pylmm]:checked').val());
form_data = $('#trait_data_form').serialize();
@@ -183,6 +184,7 @@
//$("#progress_bar_container").modal();
url = "/marker_regression";
$('input[name=method]').val("rqtl_geno");
+ $('input[name=genofile').val($('#genofile_rqtl_geno').val());
$('input[name=num_perm]').val($('input[name=num_perm_rqtl_geno]').val());
$('input[name=manhattan_plot]').val($('input[name=manhattan_plot_rqtl]:checked').val());
$('input[name=control_marker]').val($('input[name=control_rqtl_geno]').val());
@@ -242,6 +244,7 @@
//$("#progress_bar_container").modal();
url = "/marker_regression";
$('input[name=method]').val("reaper");
+ $('input[name=genofile').val($('#genofile_reaper').val());
$('input[name=num_perm]').val($('input[name=num_perm_reaper]').val());
$('input[name=control_marker]').val($('input[name=control_reaper]').val());
$('input[name=do_control]').val($('input[name=do_control_reaper]:checked').val());
diff --git a/wqflask/wqflask/templates/marker_regression_gn1.html b/wqflask/wqflask/templates/marker_regression_gn1.html
index 7454b650..c6112edb 100644
--- a/wqflask/wqflask/templates/marker_regression_gn1.html
+++ b/wqflask/wqflask/templates/marker_regression_gn1.html
@@ -14,6 +14,9 @@
<input type="hidden" name="temp_uuid" value="{{ temp_uuid }}">
<input type="hidden" name="trait_id" value="{{ this_trait.name }}">
<input type="hidden" name="dataset" value="{{ dataset.name }}">
+ {% if mapping_method == "reaper" %}
+ <input type="hidden" name="genofile" value="{{ dataset.group.genofile }}">
+ {% endif %}
<input type="hidden" name="method" value="{{ mapping_method }}">
{% for sample in samples %}
<input type="hidden" name="value:{{ sample }}" value="{{ vals[loop.index - 1] }}">
diff --git a/wqflask/wqflask/templates/show_trait.html b/wqflask/wqflask/templates/show_trait.html
index 59e0185e..d76e8af8 100644
--- a/wqflask/wqflask/templates/show_trait.html
+++ b/wqflask/wqflask/templates/show_trait.html
@@ -39,6 +39,7 @@
</div>
<input type="hidden" name="temp_uuid" id="temp_uuid" value="{{ temp_uuid }}">
+ <input type="hidden" name="genofile" value="">
<div class="container">
<div class="panel-group" id="accordion">
diff --git a/wqflask/wqflask/templates/show_trait_mapping_tools.html b/wqflask/wqflask/templates/show_trait_mapping_tools.html
index 0f293942..149ad864 100644
--- a/wqflask/wqflask/templates/show_trait_mapping_tools.html
+++ b/wqflask/wqflask/templates/show_trait_mapping_tools.html
@@ -32,6 +32,18 @@
{% if use_pylmm_rqtl and not use_plink_gemma and dataset.group.species != "human" %}
<div class="tab-pane active" id="interval_mapping">
<div style="margin-top: 20px" class="form-horizontal">
+ {% if genofiles and genofiles|length>0 %}
+ <div class="mapping_method_fields form-group">
+ <label for="genofiles" class="col-xs-3 control-label">Genotypes</label>
+ <div style="margin-left: 20px;" class="col-xs-8 controls">
+ <select id="genofile_reaper" class="form-control">
+ {% for item in genofiles %}
+ <option value="{{item['location']}}">{{item['title']}}</option>
+ {% endfor %}
+ </select>
+ </div>
+ </div>
+ {% endif %}
<div class="mapping_method_fields form-group">
<label for="mapping_permutations" class="col-xs-3 control-label">Permutations</label>
<div style="margin-left: 20px;" class="col-xs-4 controls">
@@ -114,6 +126,18 @@
</div>
<div class="tab-pane" id="pylmm">
<div style="margin-top: 20px" class="form-horizontal">
+ {% if genofiles and genofiles|length>0 %}
+ <div class="mapping_method_fields form-group">
+ <label for="genofiles" class="col-xs-3 control-label">Genotypes</label>
+ <div style="margin-left: 20px;" class="col-xs-8 controls">
+ <select id="genofile_pylmm" class="form-control">
+ {% for item in genofiles %}
+ <option value="{{item['location']}}">{{item['title']}}</option>
+ {% endfor %}
+ </select>
+ </div>
+ </div>
+ {% endif %}
<div class="mapping_method_fields form-group">
<label for="mapping_permutations" class="col-xs-3 control-label">Permutations</label>
<div style="margin-left: 20px;" class="col-xs-4 controls">
@@ -169,6 +193,18 @@
<div class="tab-pane" id="rqtl_geno">
<div style="margin-top: 20px" class="form-horizontal">
+ {% if genofiles and genofiles|length>0 %}
+ <div class="mapping_method_fields form-group">
+ <label for="genofiles" class="col-xs-3 control-label">Genotypes</label>
+ <div style="margin-left: 20px;" class="col-xs-8 controls">
+ <select id="genofile_rqtl_geno" class="form-control">
+ {% for item in genofiles %}
+ <option value="{{item['location']}}">{{item['title']}}</option>
+ {% endfor %}
+ </select>
+ </div>
+ </div>
+ {% endif %}
<div class="mapping_method_fields form-group">
<label for="mapping_permutations" class="col-xs-3 control-label">Permutations</label>
<div style="margin-left: 20px;" class="col-xs-4 controls">
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index 33fab84d..406f8930 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -452,6 +452,7 @@ def marker_regression_page():
'control_marker',
'control_marker_db',
'do_control',
+ 'genofile',
'pair_scan',
'startMb',
'endMb',