Commit 2d460417 authored by Nijveen, Harm's avatar Nijveen, Harm
Browse files

limit marker peaking genes to trans QTLs

parent 87ce29a8
......@@ -24,5 +24,6 @@ urlpatterns = [
url(r'^coregulation/', include('coregulation.urls')),
url(r'^correlation/', include('correlation.urls')),
url(r'^multiplot/', include('multiplot.urls')),
url(r'^suggestions/', include('suggestions.urls')),
url(r'^suggestions/', include('suggestions.urls')),
url(r'^download/', include('download.urls')),
]
......@@ -27,6 +27,29 @@
</li>
<li><a href="/AraQTL/?mode=correlation">Correlation</a></li>
<li><a href="/AraQTL/?mode=coregulation">Marker</a></li>
<form class="navbar-form navbar-left" action="/AraQTL/cistrans/" id="top_form" method="get">
<input title="LOD score threshold (numeric, one decimal)" id="thld"
pattern="[0-9]+([.][0-9])?"
name="thld" type="text"
size="4" class="form-control"
value="{% if thld %}{{ thld}}{% else %}{{ lodthld }}{% endif %}">
<select title="Select an experiment" class="form-control" id="experiment_selector" name="experiment_name">
{% for experiment in experiments %}
<option value="{{ experiment.experiment_name }}" {% if experiment.experiment_name == experiment_name %} selected {% endif %}>
{{ experiment.experiment_name }}
</option>
{% endfor %}
</select>
</form>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Help
<span class="caret"></span></a>
<ul class="dropdown-menu dropdown-menu-left">
<li><a href="/AraQTL/?mode=about">About</a></li>
<li><a href="/AraQTL/?mode=manual">Manual</a></li>
<li><a href="/AraQTL/?mode=FAQ">FAQ</a></li>
</ul>
</li>
</ul>
</div>
</div>
......@@ -34,9 +57,6 @@
{% if experiment_name %}
<div class="top"></div>
<div id = "searched_experiment">
Experiment: {{ experiment_name }}. LOD threshold: {% if thld %} {{ thld}} {% else %} {{ lodthld }} (default adjusted LOD threshold using FDR control at 0.05.){% endif %}
</div>
<p id="loading">[Loading...]</p>
......@@ -462,7 +482,7 @@ Experiment: {{ experiment_name }}. LOD threshold: {% if thld %} {{ thld}} {% els
}).on("mouseout", function(d) {
return markercounttip.hide();
}).on("click", function(d) {
location.href="/AraQTL/coregulation/?experiment_name={{ experiment_name }}&marker="+d+"&thld={{ lodthld }}";
location.href="/AraQTL/coregulation/?experiment_name={{ experiment_name }}&query="+d+"&thld={{ lodthld }}";
});
svg.call(eqtltip);
......@@ -500,7 +520,7 @@ Experiment: {{ experiment_name }}. LOD threshold: {% if thld %} {{ thld}} {% els
});
};
var thld_ ='';
{% if thld %} thld_ = {{ thld }};
{% if thld %} thld_ = '{{ thld }}';
{% endif %}
d3.json("../media/data/{{ experiment_name }}/lod"+thld_+".json", draw);
}).call(this);
......@@ -508,5 +528,16 @@ Experiment: {{ experiment_name }}. LOD threshold: {% if thld %} {{ thld}} {% els
</script>
{% endif %}
<script>
$('select#experiment_selector').change(function() {
$('form#top_form').submit();
});
$('input#thld').keypress(function(e) {
if(e.which == 13) {
$('form#top_form').submit();
}
});
</script>
{% endblock %}
This diff is collapsed.
......@@ -4,6 +4,8 @@ import re
from django.shortcuts import render_to_response, HttpResponse
from django.conf import settings
import main
import suggestions
from main.models import Experiment, GeneInfo, Species, Marker
from main import utils
......@@ -28,9 +30,9 @@ def selectMarker(request):
species_short_name = Species.objects.get(species_name=species_name).short_name
if request.method == 'GET':
if request.GET.get('experiment_name') and request.GET.get('marker'):
if request.GET.get('experiment_name') and request.GET.get('query'):
exp_name = request.GET.get('experiment_name')
query = request.GET.get('marker')
query = request.GET.get('query')
lodthld = Experiment.objects.get(experiment_name=exp_name).lodthld
if request.GET.get('thld'):
......@@ -39,6 +41,14 @@ def selectMarker(request):
except ValueError:
return HttpResponse('<h1> invalid LOD threshold </h1>')
min_dist = 0
if request.GET.get('min_dist'):
try:
min_dist = int(request.GET.get('min_dist'))
except ValueError:
min_dist = 0
marker_name = None
if Marker.objects.filter(name=query, experiment__experiment_name=exp_name):
......@@ -70,11 +80,17 @@ def selectMarker(request):
marker_name = closestMarker.name
if marker_name == None:
return HttpResponse('<h1> No information for marker %s</h1>' % query)
ret = suggestions.views.suggest(query, exp_name, "coregulation")
if ret:
return ret
else:
return main.views.no_results(query, "coregulation")
lodscores = getLodScoresForMarker(exp_name, marker_name)
genes = {g: l for (g, l) in lodscores.items() if l >= lodthld}
marker = Marker.objects.get(name=marker_name,experiment__experiment_name=exp_name)
genelist = list()
for gene in genes:
g = GeneInfoMarker()
......@@ -83,18 +99,21 @@ def selectMarker(request):
gi = GeneInfo.objects.filter(gene_id=gene)
if gi:
g.description = gi[0].description
g.gene_name = gi[0].gene_name
g.name = gi[0].gene_name
g.chr = gi[0].chr
g.start = gi[0].start
g.end = gi[0].end
if min_dist and g.start:
dist = abs(long(g.start) - marker.start)/1000000
if g.chr == marker.chromosome.name and dist < min_dist:
continue
genelist.append(g)
marker = Marker.objects.get(name = marker_name, experiment__experiment_name=exp_name)
return render_to_response('peakmarker.html', {'experiment_name': exp_name,
'experiments': experiments,
'species': species_short_name,
'marker': marker,
'min_dist': min_dist,
'gene_list': sorted(genelist, key=lambda x: x.LOD,
reverse=True),
'lodthld': lodthld})
......
......@@ -6,7 +6,6 @@
<link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}"/>
<link rel="stylesheet" href="{% static 'css/main.css' %}" type="text/css" xmlns="http://www.w3.org/1999/html"/>
<!-- <link rel="stylesheet" href="{% static 'css/correlation.css' %}" type="text/css"/> -->
<script type="text/javascript" src="{% static 'js/d3.js' %}"></script>
<script type="text/javascript" src="{% static 'js/d3-tip.js' %}"></script>
<script type="text/javascript" src="{% static 'js/bootstrap.min.js' %}"></script>
......@@ -30,7 +29,7 @@
<li class="active"><a href="/AraQTL/?mode=correlation">Correlation</a></li>
<li><a href="/AraQTL/?mode=coregulation">Marker</a></li>
<form class="navbar-form navbar-left" action="/AraQTL/correlation/" method="get" id="top_form">
<input title="Type your query here" id="query" name="gene_id" type="text" class="form-control"
<input title="Type your query here" id="query" name="query" type="text" class="form-control"
placeholder="Search..." {% if queryGene.id %} value="{{ queryGene.id }}" {% endif %}>
<input title="Correlation threshold" id="corrthld" name="corrthld" type="text" size="4" class="form-control"
placeholder="" {% if corrthld %} value="{{ corrthld }}" {% endif %}>
......@@ -46,9 +45,9 @@
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Help
<span class="caret"></span></a>
<ul class="dropdown-menu dropdown-menu-left">
<li><a href="{% static 'about.html' %}">About</a></li>
<li><a href="{% static 'Manual.html' %}">Manual</a></li>
<li><a href="{% static 'FAQ.html' %}">FAQ</a></li>
<li><a href="/AraQTL/?mode=about">About</a></li>
<li><a href="/AraQTL/?mode=manual">Manual</a></li>
<li><a href="/AraQTL/?mode=FAQ">FAQ</a></li>
</ul>
</li>
</ul>
......@@ -85,7 +84,7 @@ genes.push({ "gene": "{{ gene.gene_id }}",
<th>Gene Name</th>
<th>Pearson's Correlation Coefficient</th>
<th>Description</th>
<th><button onclick="showGeneList()">Copy gene list</button></th>
<th><button onclick="DownloadGeneList()" title="Opens new browser window with the list of genes">Download gene list</button></th>
</tr>
{% for gene in gene_list %}
<tr>
......@@ -124,8 +123,8 @@ genes.push({ "gene": "{{ gene.gene_id }}",
$('input[name="gene_checkbox"]').click(function() {
readCheckboxes();
});
function showGeneList() {
alert("{% for gene in gene_list %}{{ gene.gene_id }}\n{% endfor %}");
function DownloadGeneList() {
window.open('/AraQTL/download/?data={% for gene in gene_list %}{{ gene.gene_id }},{% endfor %}');
}
</script>
{% endif %}
......
......@@ -3,6 +3,8 @@ import os
from django.shortcuts import render, render_to_response, HttpResponse
from django.conf import settings
import suggestions
import main
from main.models import Experiment, GeneInfo, Species
import numpy
......@@ -29,16 +31,20 @@ def correlation(request):
species_short_name = Species.objects.get(species_name=species_name).short_name
if request.method == 'GET':
if request.GET.get('gene_id'):
if request.GET.get('query'):
if request.GET.get('experiment_name'):
exp_name = request.GET.get('experiment_name')
else:
exp_name = experiments[0].experiment_name
gene_id = request.GET.get('gene_id')
gene_id = request.GET.get('query')
geneInfoList = GeneInfo.objects.filter(gene_id = gene_id, species__species_name = species_name)
if (geneInfoList.count() == 0):
return HttpResponse('<h1> Unknown gene %s </h1>'%gene_id)
ret = suggestions.views.suggest(gene_id, exp_name, "correlation")
if ret:
return ret
else:
return main.views.no_results(gene_id, "correlation")
geneInfo = geneInfoList[0]
queryGene = dict()
......
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.index, name='index'),
]
FAQ
\ No newline at end of file
<p>Arabidopsis eQTL resource
<p>Created by Harm Nijveen &amp; Basten Snoek
<p>Using <a href="https://github.com/kbroman/d3examples/tree/master/cistrans">cistrans</a> code by Karl Broman
......@@ -31,17 +31,30 @@
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Help
<span class="caret"></span></a>
<ul class="dropdown-menu dropdown-menu-left">
<li><a href="{% static 'about.html' %}">About</a></li>
<li><a href="{% static 'Manual.html' %}">Manual</a></li>
<li><a href="{% static 'FAQ.html' %}">FAQ</a></li>
<li><a href="/AraQTL/?mode=about">About</a></li>
<li><a href="/AraQTL/?mode=manual">Manual</a></li>
<li><a href="/AraQTL/?mode=FAQ">FAQ</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<div class="container">
<div id="queryBox">
{% if noresults %}
<div id="noresults">
No results for query: {{ query }}
</div>
{% endif %}
{% if mode == "about" %}
{% include "about.html" %}
{% elif mode == "manual" %}
{% include "manual.html" %}
{% elif mode == "FAQ" %}
{% include "FAQ.html" %}
{% else %}
<form method="get"
{% if mode == 'correlation' %}
action="/AraQTL/correlation/"
......@@ -52,9 +65,9 @@
{% endif %}>
{% if mode == "correlation" %}
<input type="text" name="gene_id" id="queryArea">&nbsp;cut-off:<input type="text" name="corrthld" id="threshold" value="0.9">
<input type="text" name="query" id="queryArea">&nbsp;cut-off:<input type="text" name="corrthld" id="threshold" value="0.9">
{% elif mode == "coregulation" %}
<input type="text" name="marker" id="queryArea">
<input type="text" name="query" id="queryArea">
{% else %}
<textarea rows=3 cols=30 id="queryArea" name="query" title="Type your query"></textarea>
{% endif %}
......@@ -110,12 +123,13 @@
</tbody>
</table>
</form>
{% endif %}
</div>
<div onclick="location.href='/AraQTL/multiplot/?query=AT1G21230&experiment_name=all';" class="first"><p>All eQTL patterns for a single
gene</p></div>
<div onclick="location.href='/AraQTL/cistrans/?experiment_name=Joosen_etal_2012';" class="second"><p>Cis-trans plot per experiment</p></div>
<div onclick="location.href='/AraQTL/coregulation/?marker=MSAT321&experiment_name=Joosen_etal_2012';" class="third"><p>Genes peaking at a marker</p></div>
<div onclick="location.href='/AraQTL/correlation/?gene_id=AT1G35614&corrthld=0.9&experiment_name=Joosen_etal_2012';" class="fourth"><p>Correlated QTL patterns</p></div>
<div onclick="location.href='/AraQTL/coregulation/?query=MSAT321&experiment_name=Joosen_etal_2012';" class="third"><p>Genes peaking at a marker</p></div>
<div onclick="location.href='/AraQTL/correlation/?query=AT1G35614&corrthld=0.9&experiment_name=Joosen_etal_2012';" class="fourth"><p>Correlated QTL patterns</p></div>
</div>
<script>
var textAreaDefaultText = "Type your query, i.e. AT1G01150, or GO:0004674, or ERECTA";
......
Help
\ No newline at end of file
......@@ -152,7 +152,7 @@ def createGeneJsonForExperiment(experiment_name,qtl_file):
probe_output_dic = dict()
probe_output_dic["probe"] = gene
probe_output_dic["lod"] = fields[1:]
probe_output_dic["lod"] = list(map(float, fields[1:]))
probe_out_file = os.path.join(settings.MEDIA_ROOT, 'data/%s/probe/%s.json' % (experiment_name, gene))
with open(probe_out_file, 'w') as fo:
......
......@@ -3,7 +3,7 @@ from django.shortcuts import render_to_response
from main.models import Experiment
def index(request):
experiments = Experiment.objects.filter(species__species_name = "Arabidopsis thaliana")
experiments = Experiment.objects.filter(species__species_name="Arabidopsis thaliana")
mode = 'multiplot'
......@@ -13,3 +13,12 @@ def index(request):
return render_to_response('index.html',{'experiments':experiments,
'mode' :mode})
def no_results(query, mode):
experiments = Experiment.objects.filter(species__species_name="Arabidopsis thaliana")
return render_to_response('index.html', {'experiments': experiments,
'query': query,
'noresults': 1,
'mode': mode})
......@@ -143,7 +143,7 @@ genes.push({ "gene": "{{ gene.gene_id }}",
<th>Gene Name</th>
<th>Description</th>
<th>
<button onclick="showGeneList()">Copy gene list</button>
<button onclick="DownloadGeneList()" title="Opens new browser window with the list of genes">Download gene list</button>
</th></tr>
</thead>
<tbody>
......@@ -186,8 +186,8 @@ genes.push({ "gene": "{{ gene.gene_id }}",
readCheckboxes();
});
function showGeneList() {
alert("{% for gene in gene_info_list %}{{ gene.gene_id }}\n{% endfor %}");
function DownloadGeneList() {
window.open('/AraQTL/download/?data={% for gene in gene_list %}{{ gene.gene_id }},{% endfor %}');
}
</script>
{% endif %}
......
......@@ -2,7 +2,8 @@ from django.shortcuts import render_to_response, HttpResponse, redirect
from main.models import Experiment, GeneInfo, ArraySpot, GeneGO, GO, Species
import suggestions
import suggestions
import main
import urllib2
import re
......@@ -40,8 +41,11 @@ def multiplot(request):
else:
genelist = queryGenesForExperiment(exp_name, query)
if len(genelist) == 0:
return suggestions.views.index(request)
#return redirect('/AraQTL/suggestions/?query=%s&experiment_name=%s' %(query,exp_name))
ret = suggestions.views.index(request)
if ret:
return ret
else:
return main.views.no_results(query,"multiplot")
elif len(genelist) == 1:
geneInfoList = GeneInfo.objects.filter(gene_id=query)
title = "%s" % query
......@@ -84,8 +88,11 @@ def multiexperimentplot(request):
genes = ArraySpot.objects.filter(geneinfo__gene_id=query)
if genes.count() == 0:
return suggestions.views.index(request)
#return redirect('/AraQTL/suggestions/?query=%s&experiment_name=%s' % (query, "all"))
ret = suggestions.views.index(request)
if ret:
return ret
else:
return main.views.no_results(query,"multiplot")
experiments4gene = Experiment.objects.filter(arrayspot__spot_id=query).values_list('experiment_name', flat=True)
......
......@@ -304,6 +304,12 @@ a:hover { background: #B9EEEE; }
width:700px;
}
#noresults {
display: inline-block;
text-aligh:center;
color: #F00;
}
#qtltip{
display: inline-block;
margin: 0 auto;
......
......@@ -277,7 +277,7 @@ draw = (data) ->
d3.select(this).attr("opacity", 0)
martip.hide())
.on "click", (td) ->
location.href="/AraQTL/coregulation/?experiment_name="+probe_data.experiment+"&marker="+td.key
location.href="/AraQTL/coregulation/?experiment_name="+probe_data.experiment+"&query="+td.key
probeaxes = svg.append("g").attr("id", "probe_data_axes").attr("class", "probe_data")
......
......@@ -21,8 +21,10 @@
{% endfor %}
</ul>
</li>
<li><a href="/AraQTL/?mode=correlation">Correlation</a></li>
<li><a href="/AraQTL/?mode=coregulation">Marker</a></li>
<li{% if mode == 'correlation' %} class="active"{% endif %}><a
href="/AraQTL/?mode=correlation">Correlation</a></li>
<li{% if mode == 'coregulation' %} class="active"{% endif %}><a
href="/AraQTL/?mode=coregulation">Marker</a></li>
<form class="navbar-form navbar-left" action="/AraQTL/multiplot/" method="get" id="top_form">
<input title="Type your query here" id="query" name="query" type="text" class="form-control"
placeholder="Search...">
......@@ -59,8 +61,15 @@
</tr>
{% for gene in Genes %}
<tr>
<td><A href="/AraQTL/multiplot/?query={{ gene.gene_id|upper }}&experiment_name=all"
TARGET="_blank">{{ gene.gene_id }}</a></td>
<td>
{% if mode == 'correlation' %}
<A href="/AraQTL/correlation/?query={{ gene.gene_id|upper }}&experiment_name={{ experiment_name }}">{{ gene.gene_id }}</a>
{% elif mode == 'coregulation' %}
<A href="/AraQTL/coregulation/?query={{ gene.gene_id|upper }}&experiment_name={{ experiment_name }}">{{ gene.gene_id }}</a>
{% else %}
<A href="/AraQTL/multiplot/?query={{ gene.gene_id|upper }}&experiment_name=all">{{ gene.gene_id }}</a>
{% endif %}
</td>
<td>gene</td>
<td>{{ gene.gene_name }}</td>
<td title="{{ gene.description }}">{{ gene.description }}</td>
......@@ -68,8 +77,7 @@
{% endfor %}
{% for GOterm in GOterms %}
<tr>
<td><A href="/AraQTL/multiplot/?query={{ GOterm.accession|upper }}&experiment_name={{ experiment_name }}"
TARGET="_blank">{{ GOterm.accession }}</a></td>
<td><A href="/AraQTL/multiplot/?query={{ GOterm.accession|upper }}&experiment_name={{ experiment_name }}">{{ GOterm.accession }}</a></td>
<td>GO</td>
<td>{{ GOterm.name }}</td>
<td title="{{ GOterm.definition }}">{{ GOterm.definition }}</td>
......
......@@ -6,9 +6,6 @@ from main.models import GeneInfo, GO, Experiment
def index(request):
species_name = "Arabidopsis thaliana"
experiments = Experiment.objects.filter(species__species_name=species_name)
if request.method == 'GET':
if request.GET.get('query') and request.GET.get('experiment_name'):
......@@ -16,24 +13,38 @@ def index(request):
query = urllib2.unquote(query).strip()
experiment_name = request.GET.get('experiment_name')
GOterms = list()
genes = list()
return suggest(query,experiment_name, None)
return suggest(None,None,None)
def suggest(query, experiment_name, mode):
species_name = "Arabidopsis thaliana"
experiments = Experiment.objects.filter(species__species_name=species_name)
if not query:
return render_to_response('suggestions.html', {'experiments': experiments})
GOterms = list()
genes = list()
go_results = GO.objects.raw(
"select * from main_go WHERE MATCH (name, definition) AGAINST ('%s' IN NATURAL LANGUAGE MODE)"%query)
go_results = GO.objects.raw(
"select * from main_go WHERE MATCH (name, definition) AGAINST ('%s' IN NATURAL LANGUAGE MODE)" % query)
for GOterm in go_results:
GOterms.append(GOterm)
for GOterm in go_results:
GOterms.append(GOterm)
gene_results = GeneInfo.objects.raw(
"select * from main_geneinfo WHERE MATCH (gene_name, description) AGAINST ('%s' IN NATURAL LANGUAGE MODE)"%query)
gene_results = GeneInfo.objects.raw(
"select * from main_geneinfo WHERE MATCH (gene_name, description) AGAINST ('%s' IN NATURAL LANGUAGE MODE)" % query)
for gene in gene_results:
genes.append(gene)
for gene in gene_results:
genes.append(gene)
return render_to_response('suggestions.html', {'Genes': genes,
'GOterms': GOterms,
if len(genes) == 0:
return None
return render_to_response('suggestions.html', {'Genes': genes,
'GOterms': GOterms,
'mode': mode,
'experiments': experiments,
'experiment_name': experiment_name})
return render_to_response('suggestions.html', {'experiments': experiments})
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment