From 5d2c65eaedcea7a9bbb2a20b46404c0b25d6f065 Mon Sep 17 00:00:00 2001 From: Colin Wood Date: Fri, 13 Sep 2024 15:14:20 -0700 Subject: [PATCH] filtered features visualizer --- q2_qsip2/plugin_setup.py | 20 +++++++++++++++++++- q2_qsip2/visualizers/_visualizers.py | 18 ++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/q2_qsip2/plugin_setup.py b/q2_qsip2/plugin_setup.py index 050a19e..3dc0665 100644 --- a/q2_qsip2/plugin_setup.py +++ b/q2_qsip2/plugin_setup.py @@ -18,7 +18,7 @@ ) from q2_qsip2.visualizers._visualizers import ( plot_weighted_average_densities, plot_sample_curves, plot_density_outliers, - show_comparison_groups + show_comparison_groups, plot_filtered_features ) @@ -231,4 +231,22 @@ citations=[], ) +plugin.visualizers.register_function( + function=plot_filtered_features, + inputs={ + 'filtered_qsip_data': QSIP2Data[Filtered] + }, + parameters={}, + input_descriptions={ + 'filtered_qsip_data': 'Your filtered qsip data artifact.' + }, + parameter_descriptions={}, + name='Visualize feature retention.', + description=( + 'Displays per-source stacked bar charts of feature retention by ' + 'relative abundance and feature count.' + ), + citations=[], +) + importlib.import_module('q2_qsip2.types._deferred_setup') diff --git a/q2_qsip2/visualizers/_visualizers.py b/q2_qsip2/visualizers/_visualizers.py index 2a09a1b..ab2e761 100644 --- a/q2_qsip2/visualizers/_visualizers.py +++ b/q2_qsip2/visualizers/_visualizers.py @@ -106,3 +106,21 @@ def show_comparison_groups( df = qsip2.show_comparison_groups(qsip_data, groups_vector) df.to_html(Path(output_dir) / 'index.html') + + +def plot_filtered_features(output_dir: str, filtered_qsip_data: RS4) -> None: + ''' + Displays per-source stacked bar charts showing the retention of features. + + Parameters + ---------- + output_dir : str + The root directory of the visualization loaded into the browser. + qsip_data : RS4 + The "qsip_data" object. + ''' + plot = qsip2.plot_filter_gradient_position(filtered_qsip_data) + + _ggplot2_object_to_visualization( + plot, Path(output_dir), width=10, height=10 + )