Création d'un compte pour un collaborateur extérieur au laboratoire depuis l'intranet ICube : https://intranet.icube.unistra.fr/fr/labs/member/profile

Commit 14d947eb authored by Anze Vavpetic's avatar Anze Vavpetic
Browse files

added rank plotter and rule browser widgets. rule browser is not interactive yet.

parent 951c8d72
......@@ -8,10 +8,19 @@ from django.shortcuts import render
def segmine_ttest_gene_filter(request, input_dict, output_dict, widget):
dataset = input_dict['dataset']
targets = dataset.domain.classVar.values
return render(request, 'interactions/segmine_ttest_gene_filter.html', {'widget':widget, 'targets' : targets, 'default_threshold' : 0.05})
return render(request, 'interactions/segmine_ttest_gene_filter.html',
{'widget':widget, 'targets' : targets,
'default_threshold' : 0.05})
def segmine_fc_gene_filter(request, input_dict, output_dict, widget):
dataset = input_dict['dataset']
targets = dataset.domain.classVar.values
return render(request, 'interactions/segmine_fc_gene_filter.html', {'widget':widget, 'targets' : targets, 'default_threshold' : 1.0})
return render(request, 'interactions/segmine_fc_gene_filter.html',
{'widget':widget, 'targets' : targets,
'default_threshold' : 1.0})
def segmine_rule_browser(request, input_dict, output_dict, widget):
rules = input_dict['rules']
return render(request, 'interactions/segmine_rule_browser.html',
{'widget':widget, 'rules' : rules})
......@@ -10,10 +10,7 @@ from segs import Segs
# Visualization widgets:
#
def segmine_rank_plotter(input_dict):
return input_dict
def segmine_rule_browser(input_dict):
return input_dict
return {}
def segmine_biomine_visualizer(input_dict):
return {'graph' : input_dict.get('graph', None)}
......@@ -21,6 +18,12 @@ def segmine_biomine_visualizer(input_dict):
#
# Interactions widgets:
#
def segmine_rule_browser(input_dict):
return {'node_list' : []}
def segmine_rule_browser_finished(input_dict):
return {'node_list' : []}
def segmine_fc_gene_filter_finished(postdata, input_dict, output_dict):
from orngBioinformatics import obiExpression as rankers
import orange
......@@ -114,7 +117,10 @@ def segmine_gene_ranker(input_dict, widget):
def segmine_segs(input_dict, widget):
segs = Segs(input_dict['wsdl'])
results = segs.run(input_dict, widget=widget)
return {'rules' : results}
return {'rules_fisher' : results.get('rules_fisher', None),
'rules_PAGE' : results.get('rules_PAGE', None),
'rules_GSEA' : results.get('rules_GSEA', None),
'rules_combined' : results.get('rules_combined', None)}
def segmine_resolve_gene_synonyms(input_dict):
from .data import mappings
......
......@@ -22,9 +22,6 @@ def recursive_asdict(d):
out[k] = v
return out
def suds_to_json(data):
return json.dumps(recursive_asdict(data))
class Segs:
'''Interface to the SEGS web service'''
......@@ -50,7 +47,7 @@ class Segs:
jobID = self.client.service.runSEGS(**inputs)
self.wait_for_job(widget, jobID)
rules = self.client.service.getResult(jobID=jobID)
return suds_to_json(rules)
return recursive_asdict(rules)
def wait_for_job(self, widget, jobID):
if widget:
......@@ -76,4 +73,7 @@ if __name__ == '__main__':
}
segs = Segs('http://segs.ijs.si:8090/SEGS?wsdl')
result = segs.run(inputs)
print suds_to_json(result)
\ No newline at end of file
with open('rules.pkl', 'w') as f:
json.dump(result, f)
f.flush()
print result
\ No newline at end of file
<div id="widgetinteract-{{widget.pk}}" rel="{{widget.pk}}" class="widgetinteractdialog" title="{{widget.name}} wants your input!" width=800 height=600>
<center>
<form>
<table id="segs_rules{{widget.pk}}">
<thead>
<tr>
<th>#</th>
<th>Description</th>
<th>Top genes</th>
<th>All genes</th>
<th>Fisher p-value</th>
<th>GSEA p-value</th>
<th>PAGE p-value</th>
<th>Aggregate p-value</th>
</tr>
</thead>
<tbody>
{% for rule in rules %}
<tr>
<td>{{ forloop.counter }}</td>
<td>
{% for term in rule.description.terms %}
<a data-toggle="tooltip" title="{{term.termID}}" id="{{term.termID}}">{{ term.name }}</a>{% if forloop.counter < rule.description.terms|length %},{% endif %}
{% endfor %}
{% if rule.description.interactingTerms %}
<br/>INTERACTING:
{% endif %}
{% for term in rule.description.interactingTerms %}
<a data-toggle="tooltip" title="{{term.termID}}" id="{{term.termID}}">{{ term.name }}</a>{% if forloop.counter < rule.description.interactingTerms|length %},{% endif %}
{% endfor %}
</td>
<td>{{rule.coveredTopGenes|length}}</td>
<td>{{rule.coveredGenes|length}}</td>
<td>{{rule.fisher_pval|floatformat:3}}</td>
<td>{{rule.GSEA_pval|floatformat:3}}</td>
<td>{{rule.PAGE_pval|floatformat:3}}</td>
<td>{% if rule.aggregate_pval %}
{{rule.aggregate_pval|floatformat:3}}
{% else %}
N/A
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
<input type="hidden" name="widget_id" value="{{widget.pk}}"/>
</form>
</center>
</div>
<script type="text/javascript">
$(function () {
$(document).ready(function() {
$('#segs_rules{{widget.pk}}').dataTable( {
"bSortCellsTop" : true,
"bJQueryUI": true,
"sPaginationType": "full_numbers"
});
$('#segs_rules{{widget.pk}}').selectable({
filter: "td"
});
});
});
</script>
</div>
\ No newline at end of file
<div id="widgetvisualization-{{widget.pk}}" rel="{{widget.pk}}" class="widgetvisualizationdialog" title="{{widget.name}} visualization" width=800 height=600>
<div id="ranks{{widget.pk}}"></div>
</div>
<script type="text/javascript">
$(document).ready(function () {
new Highcharts.Chart({
chart: {
renderTo: 'ranks{{widget.pk}}',
type: 'spline',
width: 700,
height: 500,
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
title: {
text: 'Gene ranks'
},
legend: {
enabled: false
},
xAxis: {
reversed: false,
title: {
enabled: true,
text: 'Genes'
},
labels: {
formatter: function() {
return 'Gene ' + this.value;
}
},
maxPadding: 0.05,
showLastLabel: true
},
yAxis: {
title: {
text: 'Rank'
},
labels: {
formatter: function() {
return this.value;
}
}
},
tooltip: {
headerFormat: '<b>{series.name}</b><br/>',
pointFormat: 'Gene {point.x}: {point.y}'
},
plotOptions: {
spline: {
lineWidth: 4,
marker: {
enabled: false
}
}
},
series: [{
name: 'Ranks',
data: {{ gene_ranks|safe }}
}],
credits: {
enabled: false
},
});
});
</script>
\ No newline at end of file
......@@ -5,6 +5,7 @@ Segmine visualization viewes.
'''
from django.shortcuts import render
import os
import json
def segmine_biomine_visualizer(request, input_dict, output_dict, widget):
from mothra.settings import MEDIA_ROOT
......@@ -16,4 +17,10 @@ def segmine_biomine_visualizer(request, input_dict, output_dict, widget):
f.write(str(input_dict['graph']))
f.close()
return render(request, 'visualizations/segmine_biomine_visualizer.html',
{'widget':widget, 'filename' : filename})
\ No newline at end of file
{'widget':widget, 'filename' : filename})
def segmine_rank_plotter(request, input_dict, output_dict, widget):
scores = input_dict['ranks']
scores = zip(*scores)[1]
return render(request, 'visualizations/segmine_rank_plotter.html',
{'widget':widget, 'gene_ranks' : json.dumps(scores)})
\ No newline at end of file
Markdown is supported
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