Commit faa69d39 authored by Nijveen, Harm's avatar Nijveen, Harm
Browse files

changes to the data model

parent ecf7370a
......@@ -16,7 +16,7 @@ def eQTLPlotView(request):
plot eQTL maping
'''
experiments = Experiment.objects.all().values_list('experiment_name',flat=True)
experiments = Experiment.objects.filter(species__species_name = "Arabidopsis thaliana").values_list('experiment_name',flat=True)
if request.method=='GET':
if request.GET.get('experiment_name'):
exp_name = request.GET.get('experiment_name')
......
......@@ -42,7 +42,7 @@ $(function(){
{% for gene in gene_list %}
<tr><td><A href="/AraQTL/multiexperimentplot/?gene_name={{ gene.transcript_name|upper }}" TARGET="_blank">{{ gene.transcript_name }}</a></td>
<td>{{ gene.LOD|floatformat:2 }}</td>
<td>{{ gene.description }}</td></tr>
<td align=left>{{ gene.description }}</td></tr>
{% endfor %}
</table>
</div>
......
......@@ -22,7 +22,7 @@ def selectMarker(request):
select a marker, experiment and threshold
'''
experiments = Experiment.objects.all().values_list('experiment_name',flat=True)
experiments = Experiment.objects.filter(species__species_name = "Arabidopsis thaliana").values_list('experiment_name',flat=True)
if request.method=='GET':
if request.GET.get('experiment_name') and request.GET.get('marker'):
exp_name = request.GET.get('experiment_name')
......
......@@ -40,11 +40,12 @@ $(function(){
<div id="container" align="center">
<p>
<table cellspacing='0'>
<tr><th>Transcript&nbsp;ID (count={{ gene_list|length }})</th><th>Pearson's Correlation Coefficient</th><th>Description</th></tr>
<tr><th>Transcript&nbsp;ID (count={{ gene_list|length }})</th><th>Gene Name</th><th>Pearson's Correlation Coefficient</th><th>Description</th></tr>
{% for gene in gene_list %}
<tr><td><A href="/AraQTL/multiexperimentplot/?gene_name={{ gene.transcript_name|upper }}" TARGET="_blank">{{ gene.transcript_name }}</a></td>
<td>{{ gene.gene_name }}</td>
<td>{{ gene.correlation|floatformat:2 }}</td>
<td>{{ gene.description }}</td></tr>
<td align=left>{{ gene.description }}</td></tr>
{% endfor %}
</table>
</div>
......
......@@ -23,7 +23,7 @@ def correlation(request):
select a gene and experiment, and find the top genes that show correlation
'''
experiments = Experiment.objects.all().values_list('experiment_name',flat=True)
experiments = Experiment.objects.filter(species__species_name = "Arabidopsis thaliana").values_list('experiment_name',flat=True)
if request.method=='GET':
if request.GET.get('experiment_name') and request.GET.get('gene_name'):
exp_name = request.GET.get('experiment_name')
......
......@@ -12,7 +12,7 @@ from __future__ import unicode_literals
from django.db import models
class Species(models.Model):
species_name = models.CharField(primary_key=True, max_length=50)
species_name = models.CharField(max_length=50)
class Meta:
managed = False
......@@ -42,15 +42,6 @@ class Experiment(models.Model):
db_table = 'main_experiment'
class ArraySpot(models.Model):
experiment = models.ForeignKey(Experiment)
spot_id = models.CharField(max_length=50)
class Meta:
managed = False
db_table = 'main_arrayspot'
class Line(models.Model):
experiment = models.ForeignKey(Experiment)
line_name = models.CharField(max_length=50)
......@@ -71,28 +62,28 @@ class Marker(models.Model):
managed = False
db_table = 'main_marker'
class Transcript(models.Model):
spot_id = models.ForeignKey(ArraySpot, db_column='spot_id')
transcript_name = models.CharField(max_length=30, blank=True, null=True)
ref_id = models.CharField(max_length=20, blank=True, null=True)
class GeneInfo(models.Model):
species = models.ForeignKey(Species)
gene_id = models.CharField(max_length=30, blank=True, null=True, unique=True)
description = models.TextField(blank=True,null=True)
gene_name = models.CharField(max_length=30, blank=True, null=True, unique=True)
chr = models.CharField(max_length=3)
start = models.IntegerField(blank=True, null=True)
end = models.IntegerField(blank=True, null=True)
class Meta:
managed = False
db_table = 'main_transcript'
db_table = 'main_geneinfo'
class GeneInfo(models.Model):
species = models.ForeignKey(Species)
gene_id = models.CharField(max_length=30, blank=True, null=True, unique=True)
description = models.TextField(blank=True,null=True)
gene_name = models.CharField(max_length=30, blank=True, null=True, unique=True)
class Transcript(models.Model):
geneinfo = models.ForeignKey(GeneInfo)
transcript_name = models.CharField(max_length=30, blank=True, null=True)
transcript_id = models.CharField(max_length=20, blank=True, null=True)
class Meta:
managed = False
db_table = 'main_geneinfo'
db_table = 'main_transcript'
class GO(models.Model):
accession = models.CharField(primary_key=True,max_length=30,blank=False,null=False, unique=True)
......@@ -105,7 +96,7 @@ class GO(models.Model):
db_table = 'main_go'
class GeneGO(models.Model):
gene_id = models.ForeignKey(GeneInfo, to_field='gene_id', db_column = 'gene_id')
geneinfo = models.ForeignKey(GeneInfo)
term_accession = models.ForeignKey(GO,to_field='accession', db_column = 'term_accession')
term_evidence_code = models.CharField(max_length=30,blank=False,null=False)
......@@ -113,3 +104,13 @@ class GeneGO(models.Model):
managed = False
db_table = 'main_gene_go'
class ArraySpot(models.Model):
experiment = models.ForeignKey(Experiment)
geneinfo = models.ForeignKey(GeneInfo)
spot_id = models.CharField(max_length=50)
class Meta:
managed = False
db_table = 'main_arrayspot'
......@@ -5,6 +5,18 @@
{% load staticfiles %}
<link rel="stylesheet" href="{% static 'css/main.css' %}" type="text/css"/>
<div class="top">
<form action="multiplot" method="get">
Experiment: <select id="experiment_name" name="experiment_name">
{% for experiment in experiments %}
<option value= "{{ experiment }}">{{ experiment }}</option>
{% endfor %}
</select>
Query: <input type="textbox" id="query" title ="type your query" name="query" value="GO:0009965"/>
<input type="submit" id="multiplot_submit" class="btn_analysis" value="Query" />
<p><i>Show eQTL profiles for transcripts matching your query</i>
</form>
</div>
<div class="container">
<div onclick="location.href='/AraQTL/multiexperimentplot/';" class="first"><p>Plot all eQTL patterns for a single gene</p></div>
<div onclick="location.href='/AraQTL/cistrans/';" class="second"><p>Show cistransplot per experiment</p></div>
......
......@@ -2,5 +2,8 @@ from django.shortcuts import render_to_response
from django.http import HttpResponse
from main.models import Experiment
def index(request):
return render_to_response('index.html')
experiments = Experiment.objects.filter(species__species_name = "Arabidopsis thaliana").values_list('experiment_name',flat=True)
return render_to_response('index.html',{'experiments':experiments})
......@@ -38,7 +38,7 @@ $(function(){
draw = function(error, loddata) {
var altpink, axislabels, bigRad, bottom, c, checkerboard, chrGap, chrLowXScale, chrXScale, chrYScale, chrindex,
ci, cj, cur, darkGray, darkblue, darkgreen, darkred, draw_probe, g, gene, h, hLegend, i, j, labelcolor, legend,
left, leftLegend, lightGray, m, maincolor, martip, maxlod, newg, nodig, onedig, p, pad, pink, probe, purple,
left, leftLegend, lightGray, m, maincolor, martip, markertickstip, maxlod, newg, nodig, onedig, p, pad, pink, probe, purple,
right, rightLegend, svg, tickHeight, titlecolor, top, topLegend, totalChrLength, totalh, totalw, twodig,
w, wLegend, xloc, yloc, _i, _j, _k, _l,
_len, _len1, _len10, _len2, _len3, _len4, _len5, _len6, _len7, _len8, _len9,
......@@ -182,7 +182,13 @@ $(function(){
attr("fill", titlecolor);
//################################### END #######################################
//MarkerCount tooltip/////////
markertickstip = d3.svg.tip().orient("right").padding(3).text(function(z) {
return " Marker: "+ z;
}).attr("class", "d3-tip").attr("id", "markertickstip");
//end/////////////////////////////////
//marker tooltip//////////////////////
martip = d3.svg.tip().orient("right").padding(3).text(function(z) {
return z;
......@@ -262,6 +268,25 @@ $(function(){
//#######################################end#################################################
{% for experiment in experiments %}
markerticks{{ forloop.counter0 }} = svg.append("g").attr("id", "markerticks").selectAll("empty").
data(loddata[{{ forloop.counter0 }}].markers).enter().append("line").attr("class", function(d) {
return "marker_" + d;
}).attr("x1", function(d) {
return chrLowXScale[loddata[{{ forloop.counter0 }}].pmark[d].chr](loddata[{{ forloop.counter0 }}].pmark[d].start);
}).attr("x2", function(d) {
return chrLowXScale[loddata[{{ forloop.counter0 }}].pmark[d].chr](loddata[{{ forloop.counter0 }}].pmark[d].start);
}).attr("y1", function(d) {
return 341;
}).attr("y2", function(d) {
return 345;
}).attr("stroke-width", 1)
.attr("stroke", darkblue).on("mouseover", function(d) {
return markertickstip.call(this,d);
}).on("mouseout", function(d) {
return d3.selectAll("#markertickstip").remove()}
);
{% endfor %}
//########## draw legend #########
......@@ -318,7 +343,7 @@ $(function(){
titletxt += " (" + trans + ")";
//open window in a new tab <a href="#" target="_blank">Link</a>
xlink = probeaxes.append("a").attr("target","_blank").attr("xlink:href", hyper_link);
xlink.append("text").text(titletxt).
xlink.append("text").text("{{ title }}").
attr("x", (left + right) / 2).
attr("y", top - pad.top / 2).
attr("fill", maincolor).style("font-size", "18px");
......@@ -379,6 +404,8 @@ $(function(){
}).on("mouseout", function(td) {
d3.select(this).attr("opacity", markerClick{{ forloop.counter0 }}[td]);
return d3.selectAll("#martip").remove();
}).on("click", function(d) {
location.href="http://www.bioinformatics.nl/AraQTL/coregulation/?experiment_name={{ experiment }}&marker="+d;
});
//end draw LOD score plot
{% endfor %}
......
......@@ -18,22 +18,19 @@ def lodPlot(request):
'''
if request.method=='GET':
if request.GET.get('gene_name'):
#experiments = Experiment.objects.all().values_list('experiment_name',flat=True)
gene_name = request.GET.get('gene_name')
arraySpots = ArraySpot.objects.filter(spot_id = gene_name)
if arraySpots.count() == 0:
transcripts = ArraySpot.objects.filter(transcript__transcript_name = gene_name)
if transcripts.count() == 0:
return render_to_response('plotLod.html')
#geneinfos = ArraySpot.objects.filter(transcript__geneinfo_gene_name = gene_name)
#if geneinfos.count() != 0:
# gene_name = geneinfos.values_list('spot_id',flat = True)[0];
elif transcripts.count() > 1:
gene_names = transcripts.values_list('spot_id',flat = True);
return render_to_response('plotLod.html',{'gene_names': gene_names})
#gene_name = transcripts.values_list('spot_id',flat = True)[0];
experiments = Experiment.objects.filter(arrayspot__spot_id = gene_name).values_list('experiment_name',flat=True)
return render_to_response('plotLod.html',{'gene_name': gene_name, 'experiments': experiments})
gene_id = request.GET.get('gene_name').upper()
genes = ArraySpot.objects.filter(geneinfo__gene_id = gene_id)
if genes.count() == 0:
return render_to_response('plotLod.html')
experiments = Experiment.objects.filter(arrayspot__spot_id = gene_id).values_list('experiment_name',flat=True)
gene_name = GeneInfo.objects.filter(gene_id = gene_id).values_list("gene_name",flat=True)[0]
title = "%s"%gene_id
if gene_name:
title += " (%s)"%gene_name
return render_to_response('plotLod.html',{'gene_name': gene_id, 'experiments': experiments, 'title': title})
return render_to_response('plotLod.html')
......
......@@ -30,13 +30,25 @@ $(function(){
<option value= "{{ experiment }}" {%if experiment == experiment_name %} selected {% endif %}>{{ experiment }}</option>
{% endfor %}
</select>
query :<input type="text" id="query" title ="select a gene" name="query" value ="{{ query }}"/>
query :<input type="text" id="query" title ="type your query" name="query" value ="{{ query }}"/>
<input type="submit" id="query_submit" class="btn_analysis" value="Query" />
</form>
<div id ="multiexperimentplot"></div>
<div id="container" align="center">
<p>
<table cellspacing='0'>
<tr><th>Transcript&nbsp;ID (count={{ gene_list|length }})</th><th>Gene Name</th><th>Description</th></tr>
{% for gene in gene_info_list %}
<tr><td><A href="/AraQTL/multiexperimentplot/?gene_name={{ gene.gene_id|upper }}" TARGET="_blank">{{ gene.gene_id }}</a></td>
<td>{{ gene.gene_name }}</td>
<td align=left>{{ gene.description }}</td></tr>
{% endfor %}
</table>
</div>
<script type="text/javascript">
(function() {
......@@ -71,7 +83,7 @@ $(function(){
topLegend = 41;
bottom = 341;
h = 300;
hLegend = 200;
hLegend = 300;
w = 700;
wLegend = 300;
......@@ -262,11 +274,11 @@ $(function(){
//########## draw legend #########
colors = d3.scale.category10();
colors = d3.scale.category20();
_ref13 = probe_data_set;
for (_v = 0, _len13 = _ref13.length; _v < _len13; _v++) {
for (_v = 0, _len13 = Math.min(15,_ref13.length); _v < _len13; _v++) {
legend.append("line").
attr("x1",leftLegend + 10).
attr("y1",topLegend + 18*_v + 15).
......@@ -299,32 +311,14 @@ $(function(){
style("pointer-events", "none").attr("fill", "none");
}
}
titletxt = probe_data_set[0].probe.toUpperCase();
titletxt = "{{ title }}";
probeaxes = svg.append("g").attr("id", "probe_data_axes").attr("class", "probe_data");
trans = data.spot[titletxt].transcript;
var link_pre;
if (data["spec"] == "Arabidopsis Thaliana"){
link_pre = "http://plants.ensembl.org/Arabidopsis_thaliana/Gene/Summary?g=";
}
if (data["spec"] == "Caenorhabditis Elegans"){
link_pre = "http://www.wormbase.org/species/c_elegans/gene/";
}
var hyper_link = link_pre+ trans;
if (trans !== null) {
titletxt += " (" + trans + ")";
//open window in a new tab <a href="#" target="_blank">Link</a>
xlink = probeaxes.append("a").attr("target","_blank").attr("xlink:href", hyper_link);
xlink.append("text").text(titletxt).
attr("x", (left + right) / 2).
attr("y", top - pad.top / 2).
attr("fill", maincolor).style("font-size", "18px");
} else {
probeaxes.append("text").text(titletxt).
probeaxes.append("text").text(titletxt).
attr("x", (left + right) / 2).
attr("y", top - pad.top / 2).
attr("fill", maincolor).style("font-size", "18px");
}
svg.append("rect").
attr("class", "probe_data").
attr("x", left).
......@@ -333,16 +327,6 @@ $(function(){
attr("width", w).
attr("class", "outerBox");
svg.append("circle").attr("class", "probe_data").
attr("id", "probe_circle").
attr("cx", chrLowXScale[data.spot[probe_data_set[0].probe.toUpperCase()].chr](data.spot[probe_data_set[0].probe.toUpperCase()].start)).
attr("cy", top).
attr("r", bigRad).
attr("fill", pink).
attr("stroke", darkblue).
attr("stroke-width", 1).
attr("opacity", 1);
//############# Calculate the number of markers and save to markerClick with default value of 0 ###################
markerClick = {};
......@@ -354,7 +338,7 @@ $(function(){
//########################## end ############################
_ref13 = probe_data_set;
{% for gene in gene_list|slice:":100" %}
{% for gene in gene_list %}
svg.append("g").
attr("id", "markerCircle").
attr("class", "probe_data").selectAll("empty").
......@@ -373,7 +357,9 @@ $(function(){
}).on("mouseout", function(td) {
d3.select(this).attr("opacity", markerClick[td]);
return d3.selectAll("#martip").remove();
});
}).on("click", function(d) {
location.href="http://www.bioinformatics.nl/AraQTL/coregulation/?experiment_name={{ experiment_name }}&marker="+d;
});
//end draw LOD score plot
{% endfor %}
};
......@@ -381,7 +367,7 @@ $(function(){
data_set = [];
queue()
{% for gene in gene_list|slice:":100" %}
{% for gene in gene_list %}
.defer(d3.json,"../media/data/{{ experiment_name }}/probe/{{ gene|upper }}.json")
{% endfor %}
.awaitAll(draw_plot);
......@@ -398,7 +384,7 @@ $(function(){
<option value= "{{ experiment }}">{{ experiment }}</option>
{% endfor %}
</select>
Query :<input type="text" id="query" title ="select a gene" name="query" value="AT1G35614"/>
Query :<input type="text" id="query" title ="type your query" name="query" value="GO:0009965"/>
<input type="submit" id="multiplot_submit" class="btn_analysis" value="Query" />
</form>
......
......@@ -4,7 +4,7 @@ import os
from django.shortcuts import render,render_to_response,HttpResponse
from django.conf import settings
from main.models import Experiment, GeneInfo, ArraySpot
from main.models import Experiment, GeneInfo, ArraySpot, GeneGO, GO
import re
import json
......@@ -16,28 +16,61 @@ def multiplot(request):
select a gene and experiment, and find the top genes that show correlation
'''
experiments = Experiment.objects.all().values_list('experiment_name',flat=True)
experiments = Experiment.objects.filter(species__species_name = "Arabidopsis thaliana").values_list('experiment_name',flat=True)
if request.method=='GET':
if request.GET.get('experiment_name') and request.GET.get('query'):
exp_name = request.GET.get('experiment_name')
query = request.GET.get('query')
query = request.GET.get('query').strip()
genelist = queryGenesForExperiment(exp_name,query)
title = ""
if re.match("GO:",query,re.I):
genelist = queryGO(exp_name,query)
if len(genelist) > 0:
title = "%s (%s)"%(GO.objects.filter(accession = query).values_list("name",flat=True)[0],query)
else:
genelist = queryGenesForExperiment(exp_name,query)
if len(genelist) == 1:
gene_name = GeneInfo.objects.filter(gene_id = query).values_list("gene_name",flat=True)[0]
title = "%s"%query
if gene_name:
title += " (%s)"%gene_name
genelist = set(genelist)
geneInfoList = getGeneInfoForGeneIDs(genelist)
return render_to_response('multiplot.html',{'experiment_name': exp_name,
'experiments':experiments,
'query':query,
'gene_list':genelist
'title':title,
'gene_list':sorted(genelist),
'gene_info_list':sorted(geneInfoList, key=lambda x:x.gene_id),
})
else:
return render_to_response('multiplot.html',{'experiments':experiments})
def getGeneInfoForGeneIDs(geneIDs):
geneInfoList = list()
for geneID in geneIDs:
if len(GeneInfo.objects.filter(gene_id = geneID)) == 1:
geneInfoList.append(GeneInfo.objects.get(gene_id = geneID))
return geneInfoList
def queryGenesForExperiment(exp_name, query):
genelist = list()
geneIDs = query.split(" ")
for geneID in geneIDs:
if ArraySpot.objects.filter(spot_id = geneID).filter(experiment__experiment_name = exp_name).count() == 1:
genelist.append(geneID)
return ArraySpot.objects.filter(experiment__experiment_name = exp_name).filter(spot_id__in = geneIDs).values_list('spot_id',flat=True)
def queryGO(exp_name, query):
GO_ID = query
genelist = list(GeneGO.objects.filter(term_accession = GO_ID).values_list('geneinfo__gene_id', flat=True))
genelist = set(genelist)
genelist = queryGenesForExperiment(exp_name, ' '.join(genelist))
return genelist
......@@ -13,6 +13,14 @@ p {
transform: translateY(-50%);
}
.top {
float: center;
width: 100%;
height: 15%;
background-color: white;
text-align:center;
}
.first {
float: left;
width: 50%;
......@@ -20,9 +28,10 @@ p {
background-color: white;
text-align:center;
background-image: url("/AraQTL/static/image/multiQTL.png");
background-size: 90%;
background-size: 70%;
background-position: 50% 10%;
background-repeat: no-repeat;
margin: 0 0;
}
.first:hover {
......@@ -34,7 +43,7 @@ p {
width: 50%;
height: 50%;
background-image: url("/AraQTL/static/image/cistrans.png");
background-size: 45%;
background-size: 35%;
background-position: 50% 10%;
background-repeat: no-repeat;
}
......@@ -51,7 +60,7 @@ p {
background-color: white;
text-align:center;
background-image: url("/AraQTL/static/image/coregulation.png");
background-size: 90%;
background-size: 70%;
background-position: 50% 10%;
background-repeat: no-repeat;
}
......@@ -67,7 +76,7 @@ p {
background-color: white;
text-align:center;
background-image: url("/AraQTL/static/image/correlation.png");
background-size: 90%;
background-size: 70%;
background-position: 50% 10%;
background-repeat: no-repeat;
}
......
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