diff --git a/cami_opal/evaluate.py b/cami_opal/evaluate.py index bbcda1f..123dc2d 100644 --- a/cami_opal/evaluate.py +++ b/cami_opal/evaluate.py @@ -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 @@ -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 @@ -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 diff --git a/cami_opal/html_opal.py b/cami_opal/html_opal.py index c7bacde..f8253c6 100644 --- a/cami_opal/html_opal.py +++ b/cami_opal/html_opal.py @@ -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 diff --git a/requirements.txt b/requirements.txt index 7872c8c..8552963 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/version.py b/version.py index 0fb5dff..bf66ffc 100644 --- a/version.py +++ b/version.py @@ -1 +1 @@ -__version__ = '1.0.12' +__version__ = '1.0.13'