Skip to content

Commit

Permalink
MNT: Avoid redundant table DF transpositions biocore#155
Browse files Browse the repository at this point in the history
  • Loading branch information
fedarko committed Apr 17, 2020
1 parent 09cae3f commit 427dbb4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions empress/_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,17 @@ def plot(
# 2. Now that we've converted/read/etc. all of the four input sources,
# ensure that the samples and features they describe "match up" sanely.

feature_table_transposed, sample_metadata = tools.match_inputs(
# Note that the feature_table we get from QIIME 2 (as an argument to this
# function) is set up such that the index describes sample IDs and the
# columns describe feature IDs. We transpose this table before sending it
# to tools.match_inputs() and keep using the transposed table for the rest
# of this visualizer.

feature_table, sample_metadata = tools.match_inputs(
empress_tree, feature_table.T, sample_metadata, feature_metadata,
ignore_missing_samples, filter_missing_features
)

feature_table = feature_table_transposed.T

# 3. Go forward with creating the Empress visualization!

# extract balance parenthesis
Expand Down Expand Up @@ -119,7 +123,7 @@ def plot(

# create a mapping of observation ids and the samples that contain them
obs_data = {}
feature_table = (feature_table > 0).T
feature_table = (feature_table > 0)
for _, series in feature_table.iteritems():
sample_ids = series[series].index.tolist()
obs_data[series.name] = sample_ids
Expand Down

0 comments on commit 427dbb4

Please sign in to comment.