Skip to content

Commit

Permalink
RM use of sample ranks variable from most of code
Browse files Browse the repository at this point in the history
Since it wasn't getting used for anything after matching it with the
BIOM table's dataframe.

See #46 for a relevant discussion.
  • Loading branch information
fedarko committed Feb 21, 2019
1 parent 5848a45 commit dbedd94
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
9 changes: 4 additions & 5 deletions rankratioviz/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions rankratioviz/q2/_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions rankratioviz/scripts/_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down

0 comments on commit dbedd94

Please sign in to comment.