Skip to content

Commit

Permalink
fix metrics ranking in the case of ties
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandomeyer committed Apr 26, 2019
1 parent 197c21b commit 90b0bd5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/html_opal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')]}]
Expand Down
7 changes: 2 additions & 5 deletions src/rankings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.0.0'
__version__ = '1.0.1'

0 comments on commit 90b0bd5

Please sign in to comment.