From 90b0bd5f399a8795392e56d5ec1b472fa38312b6 Mon Sep 17 00:00:00 2001 From: Fernando Meyer Date: Fri, 26 Apr 2019 14:09:02 +0200 Subject: [PATCH] fix metrics ranking in the case of ties --- src/html_opal.py | 4 ++-- src/rankings.py | 7 ++----- version.py | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/html_opal.py b/src/html_opal.py index 25b2846..be1669b 100644 --- a/src/html_opal.py +++ b/src/html_opal.py @@ -305,8 +305,8 @@ def create_metrics_table(pd_metrics, labels, sample_ids_list): alpha_diversity_metics = 'Alpha diversity' all_metrics_labels = [presence_metrics_label, estimates_metrics_label, alpha_diversity_metics] - styles = [{'selector': 'td', 'props': [('width', '77pt')]}, - {'selector': 'th', 'props': [('width', '77pt'), ('text-align', 'left')]}, + styles = [{'selector': 'td', 'props': [('width', '100pt')]}, + {'selector': 'th', 'props': [('width', '100pt'), ('text-align', 'left')]}, {'selector': 'th:nth-child(1)', 'props': [('width', '120pt'), ('font-weight', 'normal')]}, {'selector': '', 'props': [('width', 'max-content'), ('width', '-moz-max-content'), ('border-top', '1px solid lightgray'), ('border-spacing', '0px')]}, {'selector': 'expand-toggle:checked ~ * .data', 'props': [('background-color', 'white !important')]}] diff --git a/src/rankings.py b/src/rankings.py index 1dfa4ea..7df385d 100644 --- a/src/rankings.py +++ b/src/rankings.py @@ -40,11 +40,8 @@ def highscore_table(metrics, useranks=['phylum', 'class', 'order', 'family', 'ge for (metric, sample, rank), g in pd_metrics.groupby(['metric', 'sample', 'rank']): if metric in sort_ascendingly: if ((rank in useranks) and (metric != c.UNIFRAC)) or ((rank == 'rank independent') and (metric == c.UNIFRAC)): - res = g.groupby('tool').sum().sort_values('value', ascending=sort_ascendingly[metric]) - worstpos = res.shape[0]+1 - res['position'] = range(0, worstpos-1) - for m in set(pd_metrics['tool'].unique()) - set(res.index): - res.loc[m, 'position'] = worstpos + res = g.groupby('tool').sum() + res['position'] = res['value'].rank(method='min', ascending=sort_ascendingly[metric]) - 1 res['metric'] = metric res['sample'] = sample res['rank'] = rank diff --git a/version.py b/version.py index 1f356cc..cd7ca49 100644 --- a/version.py +++ b/version.py @@ -1 +1 @@ -__version__ = '1.0.0' +__version__ = '1.0.1'