From 8fe25a1f4af4417452cf8678ce28c6a6497f830c Mon Sep 17 00:00:00 2001 From: Liz Gehret Date: Tue, 11 Jun 2024 16:58:16 -0400 Subject: [PATCH 1/3] BUG: x-axis data missing in alpha rarefaction viz --- q2_diversity/_alpha/_visualizer.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/q2_diversity/_alpha/_visualizer.py b/q2_diversity/_alpha/_visualizer.py index d8522c8..dc106c3 100644 --- a/q2_diversity/_alpha/_visualizer.py +++ b/q2_diversity/_alpha/_visualizer.py @@ -273,6 +273,9 @@ def _compute_summary(data, id_label, counts=None): summary_df['count'] = 1 summary_df = summary_df.reset_index() summary_df.rename(columns={'level_0': id_label}, inplace=True) + # this seems to work, but it's unclear to me why this wasn't needed before + summary_df.rename(columns={'level_1': '_alpha_rarefaction_depth_column_'}, + inplace=True) return summary_df @@ -280,6 +283,7 @@ def _alpha_rarefaction_jsonp(output_dir, filename, metric, data, column): with open(os.path.join(output_dir, filename), 'w') as fh: fh.write("load_data('%s', '%s'," % (metric, column)) data.to_json(fh, orient='split') + # _alpha_rarefaction_depth_column_ is changed to level_1 fh.write(");") @@ -319,6 +323,7 @@ def _compute_rarefaction_data(feature_table, min_depth, max_depth, steps, vector = vector.view(pd.Series) data[metric][(depth, i)] = vector + # at this point, the _alpha_rarefaction_depth_column_ is still present return data @@ -379,7 +384,7 @@ def alpha_rarefaction(output_dir: str, table: biom.Table, max_depth: int, metadata_df.columns = pd.MultiIndex.from_tuples( [(c, '') for c in metadata_df.columns]) columns = metadata_df.columns.get_level_values(0) - + # _alpha_rarefaction_depth_column_ still present data = _compute_rarefaction_data(table, min_depth, max_depth, steps, iterations, phylogeny, metrics) From 60b0d9532c73712acc8604bb311ce7b82c6d42d9 Mon Sep 17 00:00:00 2001 From: Liz Gehret Date: Wed, 12 Jun 2024 13:15:47 -0400 Subject: [PATCH 2/3] remove debug comments & re-run ci --- q2_diversity/_alpha/_visualizer.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/q2_diversity/_alpha/_visualizer.py b/q2_diversity/_alpha/_visualizer.py index dc106c3..bf2278c 100644 --- a/q2_diversity/_alpha/_visualizer.py +++ b/q2_diversity/_alpha/_visualizer.py @@ -273,7 +273,8 @@ def _compute_summary(data, id_label, counts=None): summary_df['count'] = 1 summary_df = summary_df.reset_index() summary_df.rename(columns={'level_0': id_label}, inplace=True) - # this seems to work, but it's unclear to me why this wasn't needed before + # this seems to work, but it's unclear to me why this wasn't needed + # prior to 2024.5 release & python 3.9 update summary_df.rename(columns={'level_1': '_alpha_rarefaction_depth_column_'}, inplace=True) return summary_df @@ -283,7 +284,6 @@ def _alpha_rarefaction_jsonp(output_dir, filename, metric, data, column): with open(os.path.join(output_dir, filename), 'w') as fh: fh.write("load_data('%s', '%s'," % (metric, column)) data.to_json(fh, orient='split') - # _alpha_rarefaction_depth_column_ is changed to level_1 fh.write(");") @@ -323,7 +323,6 @@ def _compute_rarefaction_data(feature_table, min_depth, max_depth, steps, vector = vector.view(pd.Series) data[metric][(depth, i)] = vector - # at this point, the _alpha_rarefaction_depth_column_ is still present return data @@ -384,7 +383,6 @@ def alpha_rarefaction(output_dir: str, table: biom.Table, max_depth: int, metadata_df.columns = pd.MultiIndex.from_tuples( [(c, '') for c in metadata_df.columns]) columns = metadata_df.columns.get_level_values(0) - # _alpha_rarefaction_depth_column_ still present data = _compute_rarefaction_data(table, min_depth, max_depth, steps, iterations, phylogeny, metrics) From f17a3f17ef5cec261332c55c306a8d2cb28dda46 Mon Sep 17 00:00:00 2001 From: Liz Gehret Date: Thu, 20 Jun 2024 13:30:25 -0700 Subject: [PATCH 3/3] better solution --- q2_diversity/_alpha/_visualizer.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/q2_diversity/_alpha/_visualizer.py b/q2_diversity/_alpha/_visualizer.py index bf2278c..3bf8e2e 100644 --- a/q2_diversity/_alpha/_visualizer.py +++ b/q2_diversity/_alpha/_visualizer.py @@ -273,10 +273,6 @@ def _compute_summary(data, id_label, counts=None): summary_df['count'] = 1 summary_df = summary_df.reset_index() summary_df.rename(columns={'level_0': id_label}, inplace=True) - # this seems to work, but it's unclear to me why this wasn't needed - # prior to 2024.5 release & python 3.9 update - summary_df.rename(columns={'level_1': '_alpha_rarefaction_depth_column_'}, - inplace=True) return summary_df @@ -381,7 +377,8 @@ def alpha_rarefaction(output_dir: str, table: biom.Table, max_depth: int, raise ValueError("All metadata filtered after dropping columns " "that contained non-categorical data.") metadata_df.columns = pd.MultiIndex.from_tuples( - [(c, '') for c in metadata_df.columns]) + [(c, '') for c in metadata_df.columns], + names=('_alpha_rarefaction_depth_column_', 'iter')) columns = metadata_df.columns.get_level_values(0) data = _compute_rarefaction_data(table, min_depth, max_depth, steps, iterations, phylogeny, metrics)