Skip to content

Commit

Permalink
Comparative profiles work for families
Browse files Browse the repository at this point in the history
  • Loading branch information
proost committed Nov 29, 2017
1 parent 9f7aff0 commit 22d7ee9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
20 changes: 20 additions & 0 deletions conekt/controllers/heatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from conekt.models.relationships.sequence_cluster import SequenceCoexpressionClusterAssociation
from conekt.models.sequences import Sequence
from conekt.models.trees import Tree
from conekt.models.gene_families import GeneFamily
from conekt.models.expression.cross_species_profile import CrossSpeciesExpressionProfile

heatmap = Blueprint('heatmap', __name__)
Expand Down Expand Up @@ -112,6 +113,25 @@ def heatmap_comparative_tree(tree_id, option='raw'):
tree=tree)


@heatmap.route('/comparative/family/<int:family_id>')
@heatmap.route('/comparative/family/<int:family_id>/<option>')
@cache.cached()
def heatmap_comparative_family(family_id, option='raw'):
family = GeneFamily.query.get_or_404(family_id)
sequences = family.sequences
sequence_ids = [s.id for s in sequences]

heatmap_data = CrossSpeciesExpressionProfile().get_heatmap(*sequence_ids, option=option)

print(heatmap_data)

return render_template("expression_heatmap.html", order=heatmap_data['order'],
profiles=heatmap_data['heatmap_data'],
zlog=1 if option == 'zlog' else 0,
raw=1 if option == 'raw' else 0,
family=family)


@heatmap.route('/inchlib/j/<cluster_id>.json')
@cache.cached()
def heatmap_inchlib_json(cluster_id):
Expand Down
8 changes: 7 additions & 1 deletion conekt/templates/expression_heatmap.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ <h1>Heatmap: <strong><a href="{{ url_for('expression_cluster.expression_cluster_
</div>
{% elif tree %}
<h1>Comparative Heatmap for <a href="{{ url_for('tree.tree_view', tree_id=tree.id) }}">{{ tree.label }}</a></h1>
{% elif family %}
<h1>Comparative Heatmap for <a href="{{ url_for('family.family_view', family_id=family.id) }}">{{ family.name }}</a></h1>
{% else %}
<h1>Heatmap</h1>
{% endif %}
Expand All @@ -53,12 +55,16 @@ <h1>Heatmap</h1>
{% elif raw == 1 %}
{% if tree %}
<p class="text-muted" >(Showing raw values, normalize by <a href="{{ url_for('heatmap.heatmap_comparative_tree', tree_id=tree.id, option='row') }}">row</a>)</p>
{% elif family %}
<p class="text-muted" >(Showing raw values, normalize by <a href="{{ url_for('heatmap.heatmap_comparative_family', family_id=family.id, option='row') }}">row</a>)</p>
{% else %}
<p class="text-muted" >(Showing raw values)</p>
{% endif%}
{% else %}
{% if tree %}
<p class="text-muted" >(Values are normalized against highest expression of the row, show <a href="{{ url_for('heatmap.heatmap_comparative_tree', tree_id=tree.id, option='raw') }}">raw</a> values)</p>
{% elif family %}
<p class="text-muted" >(Values are normalized against highest expression of the row, show <a href="{{ url_for('heatmap.heatmap_comparative_family', family_id=family.id, option='raw') }}">raw</a> values)</p>
{% else %}
<p class="text-muted" >(Values are normalized against highest expression of the row)</p>
{% endif %}
Expand Down Expand Up @@ -92,7 +98,7 @@ <h1>Heatmap</h1>
<td><div><span>{{ p.name }}</span></div></td>
{% endif %}
{% for o in order %}
<td class="value">{% if p['values'][o] != '-' %}{{ p['values'][o]|round(2) }}{% else %}-{% endif %}</td>
<td class="value">{% if p['values'][o] != '-' and p['values'][o] is defined %}{{ p['values'][o]|round(2) }}{% else %}-{% endif %}</td>
{% endfor %}
</tr>
{% endfor %}
Expand Down

0 comments on commit 22d7ee9

Please sign in to comment.