From 427dbb405346013cf26453d3a3d3126539e8e201 Mon Sep 17 00:00:00 2001 From: Marcus Fedarko Date: Fri, 17 Apr 2020 11:46:42 -0700 Subject: [PATCH] MNT: Avoid redundant table DF transpositions #155 --- empress/_plot.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/empress/_plot.py b/empress/_plot.py index f18123308..321c24fbc 100644 --- a/empress/_plot.py +++ b/empress/_plot.py @@ -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 @@ -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