From dbedd94bdcd004f6005411e345af9f23904dcb8b Mon Sep 17 00:00:00 2001 From: Marcus Fedarko Date: Wed, 20 Feb 2019 20:45:09 -0800 Subject: [PATCH] RM use of sample ranks variable from most of code Since it wasn't getting used for anything after matching it with the BIOM table's dataframe. See #46 for a relevant discussion. --- rankratioviz/generate.py | 9 ++++----- rankratioviz/q2/_method.py | 4 ++-- rankratioviz/scripts/_plot.py | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/rankratioviz/generate.py b/rankratioviz/generate.py index 512b552d..b8dfa200 100755 --- a/rankratioviz/generate.py +++ b/rankratioviz/generate.py @@ -71,15 +71,14 @@ def process_input(ordination_file, biom_table, taxam=None): V.index = matched_taxam["Taxon"].values table.columns = matched_taxam["Taxon"].values - return U, V, table + return V, table -def gen_rank_plot(U, V, rank_col): +def gen_rank_plot(V, rank_col): """Generates altair.Chart object describing the rank plot. Arguments: - U: sample ranks V: feature ranks rank_col: the column index to use for getting the rank values from a taxon. @@ -222,7 +221,7 @@ def gen_sample_plot(table, metadata, category, palette='Set1'): return sample_logratio_chart_json -def gen_visualization(U, V, processed_table, df_sample_metadata, category, +def gen_visualization(V, processed_table, df_sample_metadata, category, output_dir): """Creates a rankratioviz visualization. This function should be callable from both the QIIME 2 and standalone rankratioviz scripts. @@ -232,7 +231,7 @@ def gen_visualization(U, V, processed_table, df_sample_metadata, category, index_path: a path to the index.html file for the output visualization. This is needed when calling q2templates.render(). """ - rank_plot_chart = gen_rank_plot(U, V, 0) + rank_plot_chart = gen_rank_plot(V, 0) sample_plot_json = gen_sample_plot(processed_table, df_sample_metadata, category) os.makedirs(output_dir, exist_ok=True) diff --git a/rankratioviz/q2/_method.py b/rankratioviz/q2/_method.py index ca1e6359..a97847bb 100644 --- a/rankratioviz/q2/_method.py +++ b/rankratioviz/q2/_method.py @@ -23,11 +23,11 @@ def plot(output_dir: str, ranks: skbio.OrdinationResults, table: biom.Table, """ # get data df_feature_metadata = feature_metadata.to_dataframe() - U, V, processed_table = process_input(ranks, table, df_feature_metadata) + V, processed_table = process_input(ranks, table, df_feature_metadata) # We can't "subscript" Q2 Metadata types, so we have to convert this to a # dataframe before working with it df_sample_metadata = sample_metadata.to_dataframe() - index_path = gen_visualization(U, V, processed_table, df_sample_metadata, + index_path = gen_visualization(V, processed_table, df_sample_metadata, category, output_dir) # render the visualization using q2templates.render(). # TODO: do we need to specify plot_name in the context in this way? I'm not diff --git a/rankratioviz/scripts/_plot.py b/rankratioviz/scripts/_plot.py index 1b5c0709..4d83826e 100644 --- a/rankratioviz/scripts/_plot.py +++ b/rankratioviz/scripts/_plot.py @@ -39,8 +39,8 @@ def plot(ranks: str, table: str, sample_metadata: str, feature_metadata: str, taxonomy = pd.read_csv(feature_metadata, sep='\t') taxonomy.set_index('feature id', inplace=True) - U, V, processed_table = process_input(ranks, loaded_biom, taxonomy) - gen_visualization(U, V, processed_table, df_sample_metadata, category, + V, processed_table = process_input(ranks, loaded_biom, taxonomy) + gen_visualization(V, processed_table, df_sample_metadata, category, output_dir)