Skip to content

Commit

Permalink
update requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandomeyer committed Aug 14, 2024
1 parent 0eef537 commit 3dc0dd0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 26 deletions.
11 changes: 5 additions & 6 deletions cami_opal/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def reformat_pandas(sample_id, label, braycurtis, shannon, binary_metrics, l1nor
# convert Shannon
pd_shannon = pd.DataFrame([shannon[rank].get_pretty_dict() for rank in shannon.keys()]).set_index(
'rank').stack().reset_index().rename(columns={'level_1': 'metric', 0: 'value'})
pd_shannon['metric'].replace(['diversity', 'equitability'], [c.SHANNON_DIVERSITY, c.SHANNON_EQUIT], inplace=True)
pd_shannon['metric'] = pd_shannon['metric'].replace(['diversity', 'equitability'], [c.SHANNON_DIVERSITY, c.SHANNON_EQUIT])
pd_shannon['sample'] = sample_id
pd_shannon['tool'] = label

Expand All @@ -105,9 +105,9 @@ def reformat_pandas(sample_id, label, braycurtis, shannon, binary_metrics, l1nor
pd_binary_metrics = pd.DataFrame(
[binary_metrics[rank].get_pretty_dict() for rank in binary_metrics.keys()]).set_index(
'rank').stack().reset_index().rename(columns={'level_1': 'metric', 0: 'value'})
pd_binary_metrics['metric'].replace(['fp', 'tp', 'fn', 'jaccard', 'precision', 'recall', 'f1'],
[c.FP, c.TP, c.FN, c.JACCARD, c.PRECISION, c.RECALL, c.F1_SCORE],
inplace=True)
pd_binary_metrics['metric'] = pd_binary_metrics['metric'].replace(
['fp', 'tp', 'fn', 'jaccard', 'precision', 'recall', 'f1'],
[c.FP, c.TP, c.FN, c.JACCARD, c.PRECISION, c.RECALL, c.F1_SCORE])
pd_binary_metrics['sample'] = sample_id
pd_binary_metrics['tool'] = label

Expand Down Expand Up @@ -139,8 +139,7 @@ def reformat_pandas(sample_id, label, braycurtis, shannon, binary_metrics, l1nor

if rename_as_unfiltered:
metrics_list = pd_formatted['metric'].unique().tolist()
pd_formatted['metric'].replace(metrics_list, [metric + c.UNFILTERED_SUF for metric in metrics_list],
inplace=True)
pd_formatted['metric'] = pd_formatted['metric'].replace(metrics_list, [metric + c.UNFILTERED_SUF for metric in metrics_list])

return pd_formatted

Expand Down
23 changes: 11 additions & 12 deletions cami_opal/html_opal.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,21 +203,20 @@ def get_rank_to_sample_pd(pd_metrics):
pd_mean_over_samples_str['sample'] = '(average over samples)'
pd_mean_over_samples_str = pd_mean_over_samples_str.reset_index().set_index(['rank', 'tool', 'sample'])

pd_grouped = pd.concat([pd_grouped, pd_mean_over_samples_str])
pd_grouped = pd.concat([pd_grouped, pd_mean_over_samples_str]).sort_index()

# copy unifrac values to every taxonomic rank
pd_grouped_copy = pd_grouped.copy()
for index, row in pd_grouped_copy.iterrows():
pd_grouped.loc[index][c.UNIFRAC] = pd_grouped.loc[('rank independent', index[1], index[2])][c.UNIFRAC]
pd_grouped.loc[index][c.UNW_UNIFRAC] = pd_grouped.loc[('rank independent', index[1], index[2])][c.UNW_UNIFRAC]
pd_grouped.loc[index][c.UNIFRAC_CAMI] = pd_grouped.loc[('rank independent', index[1], index[2])][c.UNIFRAC_CAMI]
pd_grouped.loc[index][c.UNW_UNIFRAC_CAMI] = pd_grouped.loc[('rank independent', index[1], index[2])][c.UNW_UNIFRAC_CAMI]
for index, row in pd_grouped.iterrows():
pd_grouped.loc[index, c.UNIFRAC] = pd_grouped.loc[('rank independent', index[1], index[2])][c.UNIFRAC]
pd_grouped.loc[index, c.UNW_UNIFRAC] = pd_grouped.loc[('rank independent', index[1], index[2])][c.UNW_UNIFRAC]
pd_grouped.loc[index, c.UNIFRAC_CAMI] = pd_grouped.loc[('rank independent', index[1], index[2])][c.UNIFRAC_CAMI]
pd_grouped.loc[index, c.UNW_UNIFRAC_CAMI] = pd_grouped.loc[('rank independent', index[1], index[2])][c.UNW_UNIFRAC_CAMI]
if c.UNIFRAC + c.UNFILTERED_SUF in pd_grouped.columns:
for index, row in pd_grouped_copy.iterrows():
pd_grouped.loc[index][c.UNIFRAC + c.UNFILTERED_SUF] = pd_grouped.loc[('rank independent', index[1], index[2])][c.UNIFRAC + c.UNFILTERED_SUF]
pd_grouped.loc[index][c.UNW_UNIFRAC + c.UNFILTERED_SUF] = pd_grouped.loc[('rank independent', index[1], index[2])][c.UNW_UNIFRAC + c.UNFILTERED_SUF]
pd_grouped.loc[index][c.UNIFRAC_CAMI + c.UNFILTERED_SUF] = pd_grouped.loc[('rank independent', index[1], index[2])][c.UNIFRAC_CAMI + c.UNFILTERED_SUF]
pd_grouped.loc[index][c.UNW_UNIFRAC_CAMI + c.UNFILTERED_SUF] = pd_grouped.loc[('rank independent', index[1], index[2])][c.UNW_UNIFRAC_CAMI + c.UNFILTERED_SUF]
for index, row in pd_grouped.iterrows():
pd_grouped.loc[index, c.UNIFRAC + c.UNFILTERED_SUF] = pd_grouped.loc[('rank independent', index[1], index[2])][c.UNIFRAC + c.UNFILTERED_SUF]
pd_grouped.loc[index, c.UNW_UNIFRAC + c.UNFILTERED_SUF] = pd_grouped.loc[('rank independent', index[1], index[2])][c.UNW_UNIFRAC + c.UNFILTERED_SUF]
pd_grouped.loc[index, c.UNIFRAC_CAMI + c.UNFILTERED_SUF] = pd_grouped.loc[('rank independent', index[1], index[2])][c.UNIFRAC_CAMI + c.UNFILTERED_SUF]
pd_grouped.loc[index, c.UNW_UNIFRAC_CAMI + c.UNFILTERED_SUF] = pd_grouped.loc[('rank independent', index[1], index[2])][c.UNW_UNIFRAC_CAMI + c.UNFILTERED_SUF]

for (rank, sample), g in pd_grouped.groupby(['rank', 'sample']):
rank_to_sample_pd[rank][sample] = g.reset_index().rename(columns={'tool': 'Tool'}).drop(['rank', 'sample'], axis=1).set_index('Tool').T
Expand Down
14 changes: 7 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
numpy==1.24.2
matplotlib==3.7.1
pandas==1.5.3
jinja2==3.1.2
bokeh==3.1.0
seaborn==0.12.2
numpy==2.0.1
matplotlib==3.8.4
pandas==2.2.2
jinja2==3.1.4
bokeh==3.5.1
seaborn==0.13.2
docker==6.1.2
scipy==1.10.1
scipy==1.14.0
2 changes: 1 addition & 1 deletion version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.0.12'
__version__ = '1.0.13'

0 comments on commit 3dc0dd0

Please sign in to comment.