From 02a3a6a959dcc9521ca2afe626bff8264ce7c4c9 Mon Sep 17 00:00:00 2001 From: sepro Date: Tue, 19 Sep 2017 11:46:20 +0200 Subject: [PATCH] added low abundance warning on profile pages --- planet/models/expression/profiles.py | 14 ++++++++++++++ planet/static/css/main.css | 4 ++++ planet/templates/expression_profile.html | 7 +++++++ 3 files changed, 25 insertions(+) diff --git a/planet/models/expression/profiles.py b/planet/models/expression/profiles.py index 34ffaf3..1284bbf 100644 --- a/planet/models/expression/profiles.py +++ b/planet/models/expression/profiles.py @@ -63,6 +63,20 @@ def tissue_table(self, condition_tissue_id, use_means=True): ) return table + @property + def low_abundance(self, cutoff=10): + """ + Checks if the mean expression value in any conditions in the plot is higher than the desired cutoff + + :param cutoff: cutoff for expression, default = 10 + :return: True in case of low abundance otherwise False + """ + data = json.loads(self.profile) + + checks = [mean(v) > cutoff for _, v in data["data"].items()] + + return not any(checks) + def tissue_profile(self, condition_tissue_id, use_means=True): """ Applies a conversion to the profile, grouping several condition into one more general feature (e.g. tissue). diff --git a/planet/static/css/main.css b/planet/static/css/main.css index 21683c5..58bc8d8 100644 --- a/planet/static/css/main.css +++ b/planet/static/css/main.css @@ -519,4 +519,8 @@ div#phyd3 .table-responsive > table { .global-message { color: #31708f; +} + +.warning-message { + color: #a94442; } \ No newline at end of file diff --git a/planet/templates/expression_profile.html b/planet/templates/expression_profile.html index 3c44afa..1b187e6 100644 --- a/planet/templates/expression_profile.html +++ b/planet/templates/expression_profile.html @@ -32,11 +32,18 @@

Expression profile for Attention: This gene has low abundance. +

+ {% endif %} + {% for s in profile.specificities %} {{ s.method.description }}: {{ s.condition }} (SPM: {{ s.score|round(2) }}, entropy: {{ s.entropy|round(2) }}{%- if s.tau -%}, tau: {{ s.tau|round(2) }}{% endif %})
{% endfor %} +