From d47c43f1a384ec79c51e301f779547582e5c6fd8 Mon Sep 17 00:00:00 2001 From: Jamie Morton Date: Thu, 20 Jul 2017 11:26:45 -0700 Subject: [PATCH 01/18] DOC: Updating changelog --- CHANGELOG.md | 2 ++ gneiss/__init__.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06b0c56..10a3169 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # gneiss changelog +## Version 0.4.1 +* Added colorbar for heatmap ## Version 0.4.0 * Accelerated the ordinary least squares regression diff --git a/gneiss/__init__.py b/gneiss/__init__.py index f5ecb34..33981ba 100644 --- a/gneiss/__init__.py +++ b/gneiss/__init__.py @@ -6,4 +6,4 @@ # The full license is in the file COPYING.txt, distributed with this software. # ---------------------------------------------------------------------------- -__version__ = "0.4.0" +__version__ = "0.4.1" From a4747f6b5fe006b02a940021af6677ec90cb94f4 Mon Sep 17 00:00:00 2001 From: Jamie Morton Date: Thu, 17 Aug 2017 10:51:09 -0700 Subject: [PATCH 02/18] ENH: Adding in proportion_plots --- CHANGELOG.md | 1 + gneiss/plot/__init__.py | 5 +- gneiss/plot/_decompose.py | 120 ++++++++++++++++++++++++++++ gneiss/plot/tests/test_decompose.py | 55 ++++++++++++- 4 files changed, 178 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10a3169..04b15e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Version 0.4.1 * Added colorbar for heatmap +* Decoupled qiime2 from gneiss. All qiime2 commands have now been ported to [q2-gneiss](https://github.com/qiime2/q2-gneiss) ## Version 0.4.0 * Accelerated the ordinary least squares regression diff --git a/gneiss/plot/__init__.py b/gneiss/plot/__init__.py index 145b09d..340b758 100644 --- a/gneiss/plot/__init__.py +++ b/gneiss/plot/__init__.py @@ -27,7 +27,8 @@ from ._heatmap import heatmap from ._radial import radialplot -from ._decompose import balance_boxplot, balance_barplots +from ._decompose import balance_boxplot, balance_barplots, proportion_plot -__all__ = ["heatmap", "radialplot", "balance_boxplot", "balance_barplots"] +__all__ = ["heatmap", "radialplot", "balance_boxplot", + "balance_barplots", "proportion_plot"] diff --git a/gneiss/plot/_decompose.py b/gneiss/plot/_decompose.py index a6443b7..39531ba 100644 --- a/gneiss/plot/_decompose.py +++ b/gneiss/plot/_decompose.py @@ -155,3 +155,123 @@ def balance_barplots(tree, balance_name, header, feature_metadata, ax_num.set_xlim([0, max([num_.max().values[1], denom_.max().values[1]])]) return ax_num, ax_denom + + +def proportion_plot(table, metadata, num_features, denom_features, + feature_metadata, category, left_group, right_group, + taxa_level='species', + num_color='#105d33', denom_color='#b0d78e', + axes=(None, None)): + """ Plot the mean proportions of features within a balance. + + This plots the numerator and denominator components within a balance. + + Parameters + ---------- + table : pd.DataFrame + Table of relative abundances. + metadata : pd.DataFrame + Samples metadata + spectrum : pd.Series + The component from partial least squares. + feature_metadata : pd.DataFrame + The metadata associated to the features. + category : str + Name of sample metadata category. + left_group : str + Name of group within sample metadata category to plot + on the left of the plot. + right_group : str + Name of group within sample metadata category to plot + on the right of the plot. + taxa_level : str + Taxonomic level to summarize. + num_color : str + Color to plot the numerator. + denom_color : str + Color to plot the denominator. + """ + import seaborn as sns + if axes[0] is None or axes[1] is None: + f, (ax_num, ax_denom) = plt.subplots(1, 2) + else: + ax_num, ax_denom = axes[0][0], axes[0][1] + + level = 'feature' + ptable = table.apply(lambda x: (x+1) / (x+1).sum(), axis=1) + num_collapsed = ptable[num_features] + + denom_collapsed = ptable[denom_features] + + # merge together metadata and sequences + num_data_ = pd.merge(metadata, num_collapsed, + left_index=True, right_index=True) + denom_data_ = pd.merge(metadata, denom_collapsed, + left_index=True, right_index=True) + + # merge the data frame, so that all of the proportions + # are in their own separate column + num_data = pd.melt(num_data_, id_vars=[category], + value_vars=list(num_collapsed.columns), + value_name='proportion', var_name=level) + num_data['part'] = 'numerator' + denom_data = pd.melt(denom_data_, id_vars=[category], + value_vars=list(denom_collapsed.columns), + value_name='proportion', var_name=level) + denom_data['part'] = 'denominator' + data = pd.concat((num_data, denom_data)) + + num_feature_metadata = feature_metadata.loc[num_collapsed.columns, + taxa_level] + denom_feature_metadata = feature_metadata.loc[denom_collapsed.columns, + taxa_level] + + less_df = data.loc[data[category] == left_group].dropna() + + sns.barplot(x='proportion', + y=level, + data=less_df, + color=denom_color, + order=(list(num_feature_metadata.index) + + list(denom_feature_metadata.index)), + ax=ax_denom) + more_df = data.loc[data[category] == right_group].dropna() + + sns.barplot(x='proportion', + y=level, + data=more_df, + color=num_color, + order=(list(num_feature_metadata.index) + + list(denom_feature_metadata.index)), + ax=ax_num) + + ax_denom.set(yticklabels=(sorted(num_feature_metadata) + + sorted(denom_feature_metadata)), + title=left_group) + ax_num.set(yticklabels=[], ylabel='', yticks=[], title=right_group) + + max_xlim = max(ax_denom.get_xlim()[1], ax_num.get_xlim()[1]) + min_xlim = max(ax_denom.get_xlim()[0], ax_num.get_xlim()[0]) + + max_ylim, min_ylim = ax_denom.get_ylim() + + xlim = ([min_xlim, max_xlim]) + ax_denom.set_xlim(max_xlim, min_xlim) + ax_num.set_xlim(min_xlim, max_xlim) + ax_denom.set_position([0.2, 0.125, 0.3, 0.75]) + ax_num.set_position([0.5, 0.125, 0.3, 0.75]) + + num_h = num_collapsed.shape[1] + denom_h = denom_collapsed.shape[1] + + space = (max_ylim - min_ylim) / (num_h + denom_h) + ymid = (max_ylim - min_ylim) * num_h / (num_h + denom_h) - 0.5 * space + + ax_denom.axhspan(min_ylim, ymid, facecolor=num_color, + zorder=0, alpha=0.25) + ax_denom.axhspan(ymid, max_ylim, facecolor=denom_color, + zorder=0, alpha=0.25) + + ax_num.axhspan(min_ylim, ymid, facecolor=num_color, zorder=0, alpha=0.25) + ax_num.axhspan(ymid, max_ylim, facecolor=denom_color, zorder=0, alpha=0.25) + return (ax_num, ax_denom) diff --git a/gneiss/plot/tests/test_decompose.py b/gneiss/plot/tests/test_decompose.py index bef7335..f8deed3 100644 --- a/gneiss/plot/tests/test_decompose.py +++ b/gneiss/plot/tests/test_decompose.py @@ -6,7 +6,7 @@ # The full license is in the file COPYING.txt, distributed with this software. # ---------------------------------------------------------------------------- import unittest -from gneiss.plot import balance_boxplot, balance_barplots +from gneiss.plot import balance_boxplot, balance_barplots, proportion_plot import numpy as np import pandas as pd import numpy.testing as npt @@ -105,5 +105,58 @@ def test_basic_barplot(self): feature_metadata=self.feature_df) +class TestProportionPlot(unittest.TestCase): + def setUp(self): + self.table = pd.DataFrame({ + 'A': [1, 1.2, 1.1, 2.1, 2.2, 2], + 'B': [9.9, 10, 10.1, 2, 2.4, 2.1], + 'C': [5, 3, 1, 2, 2, 3], + 'D': [5, 5, 5, 5, 5, 5], + }, index=['S1', 'S2', 'S3', 'S4', 'S5', 'S6']) + + self.feature_metadata = pd.DataFrame({ + 'A': ['k__foo', 'p__bar', 'c__', 'o__', 'f__', 'g__', 's__'], + 'B': ['k__foo', 'p__bar', 'c__', 'o__', 'f__', 'g__', 's__'], + 'C': ['k__poo', 'p__tar', 'c__', 'o__', 'f__', 'g__', 's__'], + 'D': ['k__poo', 'p__far', 'c__', 'o__', 'f__', 'g__', 's__'] + }, index=['kingdom', 'phylum', 'class', 'order', + 'family', 'genus', 'species']).T + + self.metadata = pd.DataFrame({ + 'groups': ['X', 'X', 'X', 'Y', 'Y', 'Y'], + 'dry': [1, 2, 3, 4, 5, 6] + }, index=['S1', 'S2', 'S3', 'S4', 'S5', 'S6']) + + def test_proportion_plot(self): + + num_features = ['A', 'B'] + denom_features = ['C', 'D'] + ax1, ax2 = proportion_plot(self.table, self.metadata, + num_features, denom_features, + self.feature_metadata, 'groups', 'X', 'Y', + taxa_level='phylum') + res = np.vstack([l.get_xydata() for l in ax1.get_lines()]) + exp = np.array([[0.1863354, 0.], + [0.20529801, 0.], + [0.19254658, 1.], + [0.21794872, 1.], + [0.19230769, 2.], + [0.2484472, 2.], + [0.37267081, 3.], + [0.39735099, 3.]]) + npt.assert_allclose(res, exp) + + res = np.vstack([l.get_xydata() for l in ax2.get_lines()]) + exp = np.array([[0.08032129, 0.], + [0.0990566, 0.], + [0.437751, 1.], + [0.52358491, 1.], + [0.09433962, 2.], + [0.24096386, 2.], + [0.24096386, 3.], + [0.28301887, 3.]]) + npt.assert_allclose(res, exp) + + if __name__ == '__main__': unittest.main() From c0729732c2538f4433ac73d632a54d45795c9478 Mon Sep 17 00:00:00 2001 From: Jamie Morton Date: Thu, 17 Aug 2017 11:02:24 -0700 Subject: [PATCH 03/18] DOC: Updating changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 04b15e6..d0b2e5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # gneiss changelog ## Version 0.4.1 +* Added `proportion_plot` to plot the mean proportions within a single balance [#234](https://github.com/biocore/gneiss/pull/234) * Added colorbar for heatmap * Decoupled qiime2 from gneiss. All qiime2 commands have now been ported to [q2-gneiss](https://github.com/qiime2/q2-gneiss) From b386de8bf41eb7543ff9d959784c9928339df9f4 Mon Sep 17 00:00:00 2001 From: Jamie Morton Date: Thu, 17 Aug 2017 11:38:23 -0700 Subject: [PATCH 04/18] TST: Adding test case for tick ordering --- gneiss/plot/_decompose.py | 14 +++++------ gneiss/plot/tests/test_decompose.py | 38 +++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 7 deletions(-) diff --git a/gneiss/plot/_decompose.py b/gneiss/plot/_decompose.py index 39531ba..07d37d6 100644 --- a/gneiss/plot/_decompose.py +++ b/gneiss/plot/_decompose.py @@ -227,13 +227,14 @@ def proportion_plot(table, metadata, num_features, denom_features, taxa_level] less_df = data.loc[data[category] == left_group].dropna() - + # order of the ids to plot + order = (list(num_feature_metadata.index) + + list(denom_feature_metadata.index)) sns.barplot(x='proportion', y=level, data=less_df, color=denom_color, - order=(list(num_feature_metadata.index) + - list(denom_feature_metadata.index)), + order=order, ax=ax_denom) more_df = data.loc[data[category] == right_group].dropna() @@ -241,12 +242,11 @@ def proportion_plot(table, metadata, num_features, denom_features, y=level, data=more_df, color=num_color, - order=(list(num_feature_metadata.index) + - list(denom_feature_metadata.index)), + order=order, ax=ax_num) - ax_denom.set(yticklabels=(sorted(num_feature_metadata) + - sorted(denom_feature_metadata)), + ax_denom.set(yticklabels=(list(num_feature_metadata.values) + + list(denom_feature_metadata.values)), title=left_group) ax_num.set(yticklabels=[], ylabel='', yticks=[], title=right_group) diff --git a/gneiss/plot/tests/test_decompose.py b/gneiss/plot/tests/test_decompose.py index f8deed3..256f3a0 100644 --- a/gneiss/plot/tests/test_decompose.py +++ b/gneiss/plot/tests/test_decompose.py @@ -157,6 +157,44 @@ def test_proportion_plot(self): [0.28301887, 3.]]) npt.assert_allclose(res, exp) + res = [l._text for l in ax2.get_yticklabels()] + exp = ['p__bar', 'p__bar', 'p__tar', 'p__far'] + self.assertListEqual(res, exp) + + def test_proportion_plot_order(self): + # tests for different ordering + num_features = ['A', 'B'] + denom_features = ['D', 'C'] + ax1, ax2 = proportion_plot(self.table, self.metadata, + num_features, denom_features, + self.feature_metadata, 'groups', 'X', 'Y', + taxa_level='phylum') + res = np.vstack([l.get_xydata() for l in ax1.get_lines()]) + exp = np.array([[0.1863354, 0.], + [0.20529801, 0.], + [0.19254658, 1.], + [0.21794872, 1.], + [0.37267081, 2.], + [0.39735099, 2.], + [0.19230769, 3.], + [0.2484472, 3.]]) + npt.assert_allclose(res, exp, atol=1e-5) + + res = np.vstack([l.get_xydata() for l in ax2.get_lines()]) + exp = np.array([[0.08032129, 0.], + [0.0990566, 0.], + [0.437751, 1.], + [0.52358491, 1.], + [0.24096386, 2.], + [0.28301887, 2.], + [0.09433962, 3.], + [0.24096386, 3.]]) + npt.assert_allclose(res, exp, atol=1e-5) + + res = [l._text for l in ax2.get_yticklabels()] + exp = ['p__bar', 'p__bar', 'p__far', 'p__tar'] + self.assertListEqual(res, exp) + if __name__ == '__main__': unittest.main() From 7941eef2285429af3c390e55cb677cbc4a70381d Mon Sep 17 00:00:00 2001 From: Jamie Morton Date: Thu, 17 Aug 2017 11:57:37 -0700 Subject: [PATCH 05/18] TST: Adding in subplot check --- gneiss/plot/_decompose.py | 2 +- gneiss/plot/tests/test_decompose.py | 37 +++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/gneiss/plot/_decompose.py b/gneiss/plot/_decompose.py index 07d37d6..5b97b7c 100644 --- a/gneiss/plot/_decompose.py +++ b/gneiss/plot/_decompose.py @@ -195,7 +195,7 @@ def proportion_plot(table, metadata, num_features, denom_features, if axes[0] is None or axes[1] is None: f, (ax_num, ax_denom) = plt.subplots(1, 2) else: - ax_num, ax_denom = axes[0][0], axes[0][1] + ax_num, ax_denom = axes[0], axes[1] level = 'feature' ptable = table.apply(lambda x: (x+1) / (x+1).sum(), axis=1) diff --git a/gneiss/plot/tests/test_decompose.py b/gneiss/plot/tests/test_decompose.py index 256f3a0..6c9238c 100644 --- a/gneiss/plot/tests/test_decompose.py +++ b/gneiss/plot/tests/test_decompose.py @@ -10,6 +10,7 @@ import numpy as np import pandas as pd import numpy.testing as npt +import matplotlib.pyplot as plt from skbio import TreeNode @@ -195,6 +196,42 @@ def test_proportion_plot_order(self): exp = ['p__bar', 'p__bar', 'p__far', 'p__tar'] self.assertListEqual(res, exp) + def test_proportion_plot_order_figure(self): + # tests for different ordering + fig, axes = plt.subplots(1, 2) + + num_features = ['A', 'B'] + denom_features = ['D', 'C'] + ax1, ax2 = proportion_plot(self.table, self.metadata, + num_features, denom_features, + self.feature_metadata, 'groups', 'X', 'Y', + taxa_level='phylum', axes=axes) + res = np.vstack([l.get_xydata() for l in ax1.get_lines()]) + exp = np.array([[0.1863354, 0.], + [0.20529801, 0.], + [0.19254658, 1.], + [0.21794872, 1.], + [0.37267081, 2.], + [0.39735099, 2.], + [0.19230769, 3.], + [0.2484472, 3.]]) + npt.assert_allclose(res, exp, atol=1e-2) + + res = np.vstack([l.get_xydata() for l in ax2.get_lines()]) + exp = np.array([[0.08032129, 0.], + [0.0990566, 0.], + [0.437751, 1.], + [0.52358491, 1.], + [0.24096386, 2.], + [0.28301887, 2.], + [0.09433962, 3.], + [0.24096386, 3.]]) + npt.assert_allclose(res, exp, atol=1e-2) + + res = [l._text for l in ax2.get_yticklabels()] + exp = ['p__bar', 'p__bar', 'p__far', 'p__tar'] + self.assertListEqual(res, exp) + if __name__ == '__main__': unittest.main() From c520b42eb83311bad8a3788bf1d4faece5f2659a Mon Sep 17 00:00:00 2001 From: Jamie Morton Date: Sun, 27 Aug 2017 12:43:58 -0700 Subject: [PATCH 06/18] Getting rid of pseudocount --- gneiss/plot/_decompose.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gneiss/plot/_decompose.py b/gneiss/plot/_decompose.py index 5b97b7c..3ef86ff 100644 --- a/gneiss/plot/_decompose.py +++ b/gneiss/plot/_decompose.py @@ -198,7 +198,7 @@ def proportion_plot(table, metadata, num_features, denom_features, ax_num, ax_denom = axes[0], axes[1] level = 'feature' - ptable = table.apply(lambda x: (x+1) / (x+1).sum(), axis=1) + ptable = table.apply(lambda x: x / x.sum(), axis=1) num_collapsed = ptable[num_features] denom_collapsed = ptable[denom_features] From 49837dfc562841b843c4be806aee9d8b70f89811 Mon Sep 17 00:00:00 2001 From: Jamie Morton Date: Thu, 28 Sep 2017 11:06:31 -0400 Subject: [PATCH 07/18] renaming stuff --- gneiss/plot/_decompose.py | 44 ++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/gneiss/plot/_decompose.py b/gneiss/plot/_decompose.py index 3ef86ff..61349db 100644 --- a/gneiss/plot/_decompose.py +++ b/gneiss/plot/_decompose.py @@ -157,9 +157,10 @@ def balance_barplots(tree, balance_name, header, feature_metadata, return ax_num, ax_denom -def proportion_plot(table, metadata, num_features, denom_features, - feature_metadata, category, left_group, right_group, - taxa_level='species', +def proportion_plot(table, metadata, category, left_group, right_group, + num_features, denom_features, + feature_metadata=None, + aggregate_level='species', num_color='#105d33', denom_color='#b0d78e', axes=(None, None)): """ Plot the mean proportions of features within a balance. @@ -184,8 +185,8 @@ def proportion_plot(table, metadata, num_features, denom_features, right_group : str Name of group within sample metadata category to plot on the right of the plot. - taxa_level : str - Taxonomic level to summarize. + aggregrate_col : str + Column in the feature metadata table to summarize by. num_color : str Color to plot the numerator. denom_color : str @@ -197,7 +198,7 @@ def proportion_plot(table, metadata, num_features, denom_features, else: ax_num, ax_denom = axes[0], axes[1] - level = 'feature' + fname = 'feature' ptable = table.apply(lambda x: x / x.sum(), axis=1) num_collapsed = ptable[num_features] @@ -213,25 +214,26 @@ def proportion_plot(table, metadata, num_features, denom_features, # are in their own separate column num_data = pd.melt(num_data_, id_vars=[category], value_vars=list(num_collapsed.columns), - value_name='proportion', var_name=level) + value_name='proportion', var_name=fname) num_data['part'] = 'numerator' denom_data = pd.melt(denom_data_, id_vars=[category], value_vars=list(denom_collapsed.columns), - value_name='proportion', var_name=level) + value_name='proportion', var_name=fname) denom_data['part'] = 'denominator' data = pd.concat((num_data, denom_data)) - - num_feature_metadata = feature_metadata.loc[num_collapsed.columns, - taxa_level] - denom_feature_metadata = feature_metadata.loc[denom_collapsed.columns, - taxa_level] + if feature_metadata is not None: + num_feature_metadata = feature_metadata.loc[num_collapsed.columns, + aggregate_level] + denom_feature_metadata = feature_metadata.loc[denom_collapsed.columns, + aggregate_level] + # order of the ids to plot + order = (list(num_feature_metadata.index) + + list(denom_feature_metadata.index)) less_df = data.loc[data[category] == left_group].dropna() - # order of the ids to plot - order = (list(num_feature_metadata.index) + - list(denom_feature_metadata.index)) + sns.barplot(x='proportion', - y=level, + y=lfname, data=less_df, color=denom_color, order=order, @@ -244,10 +246,10 @@ def proportion_plot(table, metadata, num_features, denom_features, color=num_color, order=order, ax=ax_num) - - ax_denom.set(yticklabels=(list(num_feature_metadata.values) + - list(denom_feature_metadata.values)), - title=left_group) + if feature_metadata is not None: + ax_denom.set(yticklabels=(list(num_feature_metadata.values) + + list(denom_feature_metadata.values)), + title=left_group) ax_num.set(yticklabels=[], ylabel='', yticks=[], title=right_group) max_xlim = max(ax_denom.get_xlim()[1], ax_num.get_xlim()[1]) From ba906c2ac645148ecc630d87c207b3dac0cea63a Mon Sep 17 00:00:00 2001 From: Jamie Morton Date: Thu, 28 Sep 2017 12:15:37 -0400 Subject: [PATCH 08/18] refactoring --- gneiss/plot/_decompose.py | 45 ++++++---- gneiss/plot/tests/test_decompose.py | 124 +++++++++++++++------------- 2 files changed, 95 insertions(+), 74 deletions(-) diff --git a/gneiss/plot/_decompose.py b/gneiss/plot/_decompose.py index 61349db..cd1ffb5 100644 --- a/gneiss/plot/_decompose.py +++ b/gneiss/plot/_decompose.py @@ -160,7 +160,7 @@ def balance_barplots(tree, balance_name, header, feature_metadata, def proportion_plot(table, metadata, category, left_group, right_group, num_features, denom_features, feature_metadata=None, - aggregate_level='species', + label_col='species', num_color='#105d33', denom_color='#b0d78e', axes=(None, None)): """ Plot the mean proportions of features within a balance. @@ -185,12 +185,19 @@ def proportion_plot(table, metadata, category, left_group, right_group, right_group : str Name of group within sample metadata category to plot on the right of the plot. - aggregrate_col : str + label_col : str Column in the feature metadata table to summarize by. num_color : str Color to plot the numerator. denom_color : str Color to plot the denominator. + + Returns + ------- + ax_num : matplotlib.pyplot.Axes + Matplotlib axes for the numerator bars + ax_denom : matplotlib.pyplot.Axes + Matplotlib axes for the denominator bars """ import seaborn as sns if axes[0] is None or axes[1] is None: @@ -200,40 +207,43 @@ def proportion_plot(table, metadata, category, left_group, right_group, fname = 'feature' ptable = table.apply(lambda x: x / x.sum(), axis=1) - num_collapsed = ptable[num_features] + num_df = ptable[num_features] - denom_collapsed = ptable[denom_features] + denom_df = ptable[denom_features] # merge together metadata and sequences - num_data_ = pd.merge(metadata, num_collapsed, + num_data_ = pd.merge(metadata, num_df, left_index=True, right_index=True) - denom_data_ = pd.merge(metadata, denom_collapsed, + denom_data_ = pd.merge(metadata, denom_df, left_index=True, right_index=True) # merge the data frame, so that all of the proportions # are in their own separate column num_data = pd.melt(num_data_, id_vars=[category], - value_vars=list(num_collapsed.columns), + value_vars=list(num_df.columns), value_name='proportion', var_name=fname) num_data['part'] = 'numerator' denom_data = pd.melt(denom_data_, id_vars=[category], - value_vars=list(denom_collapsed.columns), + value_vars=list(denom_df.columns), value_name='proportion', var_name=fname) denom_data['part'] = 'denominator' data = pd.concat((num_data, denom_data)) if feature_metadata is not None: - num_feature_metadata = feature_metadata.loc[num_collapsed.columns, - aggregate_level] - denom_feature_metadata = feature_metadata.loc[denom_collapsed.columns, - aggregate_level] + num_feature_metadata = feature_metadata.loc[num_df.columns, + label_col] + denom_feature_metadata = feature_metadata.loc[denom_df.columns, + label_col] # order of the ids to plot order = (list(num_feature_metadata.index) + list(denom_feature_metadata.index)) + else: + order = (list(num_df.columns) + + list(denom_df.columns)) less_df = data.loc[data[category] == left_group].dropna() sns.barplot(x='proportion', - y=lfname, + y=fname, data=less_df, color=denom_color, order=order, @@ -241,7 +251,7 @@ def proportion_plot(table, metadata, category, left_group, right_group, more_df = data.loc[data[category] == right_group].dropna() sns.barplot(x='proportion', - y=level, + y=fname, data=more_df, color=num_color, order=order, @@ -250,6 +260,9 @@ def proportion_plot(table, metadata, category, left_group, right_group, ax_denom.set(yticklabels=(list(num_feature_metadata.values) + list(denom_feature_metadata.values)), title=left_group) + else: + ax_denom.set(yticklabels=order, title=left_group) + ax_num.set(yticklabels=[], ylabel='', yticks=[], title=right_group) max_xlim = max(ax_denom.get_xlim()[1], ax_num.get_xlim()[1]) @@ -263,8 +276,8 @@ def proportion_plot(table, metadata, category, left_group, right_group, ax_denom.set_position([0.2, 0.125, 0.3, 0.75]) ax_num.set_position([0.5, 0.125, 0.3, 0.75]) - num_h = num_collapsed.shape[1] - denom_h = denom_collapsed.shape[1] + num_h = num_df.shape[1] + denom_h = denom_df.shape[1] space = (max_ylim - min_ylim) / (num_h + denom_h) ymid = (max_ylim - min_ylim) * num_h / (num_h + denom_h) - 0.5 * space diff --git a/gneiss/plot/tests/test_decompose.py b/gneiss/plot/tests/test_decompose.py index 6c9238c..18f9997 100644 --- a/gneiss/plot/tests/test_decompose.py +++ b/gneiss/plot/tests/test_decompose.py @@ -133,29 +133,32 @@ def test_proportion_plot(self): num_features = ['A', 'B'] denom_features = ['C', 'D'] ax1, ax2 = proportion_plot(self.table, self.metadata, + 'groups', 'X', 'Y', num_features, denom_features, - self.feature_metadata, 'groups', 'X', 'Y', - taxa_level='phylum') + self.feature_metadata, + label_col='phylum') res = np.vstack([l.get_xydata() for l in ax1.get_lines()]) - exp = np.array([[0.1863354, 0.], - [0.20529801, 0.], - [0.19254658, 1.], - [0.21794872, 1.], - [0.19230769, 2.], - [0.2484472, 2.], - [0.37267081, 3.], - [0.39735099, 3.]]) + exp = np.array([[0.16528926, 0.], + [0.18965517, 0.], + [0.17355372, 1.], + [0.20689655, 1.], + [0.17241379, 2.], + [0.24793388, 2.], + [0.41322314, 3.], + [0.45045045, 3.]]) + npt.assert_allclose(res, exp) res = np.vstack([l.get_xydata() for l in ax2.get_lines()]) - exp = np.array([[0.08032129, 0.], - [0.0990566, 0.], - [0.437751, 1.], - [0.52358491, 1.], - [0.09433962, 2.], - [0.24096386, 2.], - [0.24096386, 3.], - [0.28301887, 3.]]) + exp = np.array([[0.04784689, 0.], + [0.06395349, 0.], + [0.47368421, 1.], + [0.5872093, 1.], + [0.05813953, 2.], + [0.23923445, 2.], + [0.23923445, 3.], + [0.29069767, 3.]]) + npt.assert_allclose(res, exp) res = [l._text for l in ax2.get_yticklabels()] @@ -167,30 +170,34 @@ def test_proportion_plot_order(self): num_features = ['A', 'B'] denom_features = ['D', 'C'] ax1, ax2 = proportion_plot(self.table, self.metadata, + 'groups', 'X', 'Y', num_features, denom_features, - self.feature_metadata, 'groups', 'X', 'Y', - taxa_level='phylum') + self.feature_metadata, + label_col='phylum') res = np.vstack([l.get_xydata() for l in ax1.get_lines()]) - exp = np.array([[0.1863354, 0.], - [0.20529801, 0.], - [0.19254658, 1.], - [0.21794872, 1.], - [0.37267081, 2.], - [0.39735099, 2.], - [0.19230769, 3.], - [0.2484472, 3.]]) - npt.assert_allclose(res, exp, atol=1e-5) + + exp = np.array([[0.16528926, 0.], + [0.18965517, 0.], + [0.17355372, 1.], + [0.20689655, 1.], + [0.41322314, 2.], + [0.45045045, 2.], + [0.17241379, 3.], + [0.24793388, 3.]]) + + + npt.assert_allclose(res, exp, atol=1e-3, rtol=1e-3) res = np.vstack([l.get_xydata() for l in ax2.get_lines()]) - exp = np.array([[0.08032129, 0.], - [0.0990566, 0.], - [0.437751, 1.], - [0.52358491, 1.], - [0.24096386, 2.], - [0.28301887, 2.], - [0.09433962, 3.], - [0.24096386, 3.]]) - npt.assert_allclose(res, exp, atol=1e-5) + exp = np.array([[0.04784689, 0.], + [0.06395349, 0.], + [0.47368421, 1.], + [0.5872093, 1.], + [0.23923445, 2.], + [0.29069767, 2.], + [0.05813953, 3.], + [0.23923445, 3.]]) + npt.assert_allclose(res, exp, atol=1e-3, rtol=1e-3) res = [l._text for l in ax2.get_yticklabels()] exp = ['p__bar', 'p__bar', 'p__far', 'p__tar'] @@ -203,30 +210,31 @@ def test_proportion_plot_order_figure(self): num_features = ['A', 'B'] denom_features = ['D', 'C'] ax1, ax2 = proportion_plot(self.table, self.metadata, + 'groups', 'X', 'Y', num_features, denom_features, - self.feature_metadata, 'groups', 'X', 'Y', - taxa_level='phylum', axes=axes) + self.feature_metadata, + label_col='phylum', axes=axes) res = np.vstack([l.get_xydata() for l in ax1.get_lines()]) - exp = np.array([[0.1863354, 0.], - [0.20529801, 0.], - [0.19254658, 1.], - [0.21794872, 1.], - [0.37267081, 2.], - [0.39735099, 2.], - [0.19230769, 3.], - [0.2484472, 3.]]) - npt.assert_allclose(res, exp, atol=1e-2) + exp = np.array([[0.16528926, 0.], + [0.18965517, 0.], + [0.17355372, 1.], + [0.20689655, 1.], + [0.41322314, 2.], + [0.45045045, 2.], + [0.17241379, 3.], + [0.24793388, 3.]]) + npt.assert_allclose(res, exp, atol=1e-3, rtol=1e-3) res = np.vstack([l.get_xydata() for l in ax2.get_lines()]) - exp = np.array([[0.08032129, 0.], - [0.0990566, 0.], - [0.437751, 1.], - [0.52358491, 1.], - [0.24096386, 2.], - [0.28301887, 2.], - [0.09433962, 3.], - [0.24096386, 3.]]) - npt.assert_allclose(res, exp, atol=1e-2) + exp = np.array([[0.04784689, 0.], + [0.06395349, 0.], + [0.47368421, 1.], + [0.5872093, 1.], + [0.23923445, 2.], + [0.29069767, 2.], + [0.05813953, 3.], + [0.23923445, 3.]]) + npt.assert_allclose(res, exp, atol=1e-3, rtol=1e-3) res = [l._text for l in ax2.get_yticklabels()] exp = ['p__bar', 'p__bar', 'p__far', 'p__tar'] From fd2d2f51effaf77b86b6b68c001c24cbb5528909 Mon Sep 17 00:00:00 2001 From: Jamie Morton Date: Thu, 28 Sep 2017 12:30:16 -0400 Subject: [PATCH 09/18] Removing tests for coordinates, since they are unstable --- gneiss/plot/tests/test_decompose.py | 89 +++++++---------------------- 1 file changed, 20 insertions(+), 69 deletions(-) diff --git a/gneiss/plot/tests/test_decompose.py b/gneiss/plot/tests/test_decompose.py index 18f9997..d7ceedf 100644 --- a/gneiss/plot/tests/test_decompose.py +++ b/gneiss/plot/tests/test_decompose.py @@ -129,7 +129,7 @@ def setUp(self): }, index=['S1', 'S2', 'S3', 'S4', 'S5', 'S6']) def test_proportion_plot(self): - + np.random.seed(0) num_features = ['A', 'B'] denom_features = ['C', 'D'] ax1, ax2 = proportion_plot(self.table, self.metadata, @@ -137,35 +137,14 @@ def test_proportion_plot(self): num_features, denom_features, self.feature_metadata, label_col='phylum') - res = np.vstack([l.get_xydata() for l in ax1.get_lines()]) - exp = np.array([[0.16528926, 0.], - [0.18965517, 0.], - [0.17355372, 1.], - [0.20689655, 1.], - [0.17241379, 2.], - [0.24793388, 2.], - [0.41322314, 3.], - [0.45045045, 3.]]) - - npt.assert_allclose(res, exp) - - res = np.vstack([l.get_xydata() for l in ax2.get_lines()]) - exp = np.array([[0.04784689, 0.], - [0.06395349, 0.], - [0.47368421, 1.], - [0.5872093, 1.], - [0.05813953, 2.], - [0.23923445, 2.], - [0.23923445, 3.], - [0.29069767, 3.]]) - - npt.assert_allclose(res, exp) res = [l._text for l in ax2.get_yticklabels()] exp = ['p__bar', 'p__bar', 'p__tar', 'p__far'] self.assertListEqual(res, exp) def test_proportion_plot_order(self): + self.maxDiff = None + np.random.seed(0) # tests for different ordering num_features = ['A', 'B'] denom_features = ['D', 'C'] @@ -174,36 +153,14 @@ def test_proportion_plot_order(self): num_features, denom_features, self.feature_metadata, label_col='phylum') - res = np.vstack([l.get_xydata() for l in ax1.get_lines()]) - - exp = np.array([[0.16528926, 0.], - [0.18965517, 0.], - [0.17355372, 1.], - [0.20689655, 1.], - [0.41322314, 2.], - [0.45045045, 2.], - [0.17241379, 3.], - [0.24793388, 3.]]) - - - npt.assert_allclose(res, exp, atol=1e-3, rtol=1e-3) - - res = np.vstack([l.get_xydata() for l in ax2.get_lines()]) - exp = np.array([[0.04784689, 0.], - [0.06395349, 0.], - [0.47368421, 1.], - [0.5872093, 1.], - [0.23923445, 2.], - [0.29069767, 2.], - [0.05813953, 3.], - [0.23923445, 3.]]) - npt.assert_allclose(res, exp, atol=1e-3, rtol=1e-3) res = [l._text for l in ax2.get_yticklabels()] exp = ['p__bar', 'p__bar', 'p__far', 'p__tar'] self.assertListEqual(res, exp) def test_proportion_plot_order_figure(self): + self.maxDiff = None + np.random.seed(0) # tests for different ordering fig, axes = plt.subplots(1, 2) @@ -214,32 +171,26 @@ def test_proportion_plot_order_figure(self): num_features, denom_features, self.feature_metadata, label_col='phylum', axes=axes) - res = np.vstack([l.get_xydata() for l in ax1.get_lines()]) - exp = np.array([[0.16528926, 0.], - [0.18965517, 0.], - [0.17355372, 1.], - [0.20689655, 1.], - [0.41322314, 2.], - [0.45045045, 2.], - [0.17241379, 3.], - [0.24793388, 3.]]) - npt.assert_allclose(res, exp, atol=1e-3, rtol=1e-3) - - res = np.vstack([l.get_xydata() for l in ax2.get_lines()]) - exp = np.array([[0.04784689, 0.], - [0.06395349, 0.], - [0.47368421, 1.], - [0.5872093, 1.], - [0.23923445, 2.], - [0.29069767, 2.], - [0.05813953, 3.], - [0.23923445, 3.]]) - npt.assert_allclose(res, exp, atol=1e-3, rtol=1e-3) res = [l._text for l in ax2.get_yticklabels()] exp = ['p__bar', 'p__bar', 'p__far', 'p__tar'] self.assertListEqual(res, exp) + def test_proportion_plot_original_labels(self): + # tests for different ordering + fig, axes = plt.subplots(1, 2) + + num_features = ['A', 'B'] + denom_features = ['D', 'C'] + ax1, ax2 = proportion_plot(self.table, self.metadata, + 'groups', 'X', 'Y', + num_features, denom_features, + axes=axes) + + res = [l._text for l in ax2.get_yticklabels()] + exp = ['A', 'B', 'D', 'C'] + self.assertListEqual(res, exp) + if __name__ == '__main__': unittest.main() From 761a0c0f27b8366db071669223efb170be031114 Mon Sep 17 00:00:00 2001 From: Jamie Morton Date: Thu, 28 Sep 2017 12:35:06 -0400 Subject: [PATCH 10/18] TST: Adding test for the last column, since it is stable --- gneiss/plot/_decompose.py | 1 - gneiss/plot/tests/test_decompose.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/gneiss/plot/_decompose.py b/gneiss/plot/_decompose.py index cd1ffb5..9b491db 100644 --- a/gneiss/plot/_decompose.py +++ b/gneiss/plot/_decompose.py @@ -270,7 +270,6 @@ def proportion_plot(table, metadata, category, left_group, right_group, max_ylim, min_ylim = ax_denom.get_ylim() - xlim = ([min_xlim, max_xlim]) ax_denom.set_xlim(max_xlim, min_xlim) ax_num.set_xlim(min_xlim, max_xlim) ax_denom.set_position([0.2, 0.125, 0.3, 0.75]) diff --git a/gneiss/plot/tests/test_decompose.py b/gneiss/plot/tests/test_decompose.py index d7ceedf..f7a5520 100644 --- a/gneiss/plot/tests/test_decompose.py +++ b/gneiss/plot/tests/test_decompose.py @@ -137,6 +137,15 @@ def test_proportion_plot(self): num_features, denom_features, self.feature_metadata, label_col='phylum') + res = np.vstack([l.get_xydata() for l in ax1.get_lines()]) + exp=np.array([0., 0., 1., 1., 2., 2., 3., 3.]) + + npt.assert_allclose(res[:, 1], exp, verbose=True) + + res = np.vstack([l.get_xydata() for l in ax2.get_lines()]) + exp=np.array([0., 0., 1., 1., 2., 2., 3., 3.]) + + npt.assert_allclose(res[:, 1], exp, verbose=True) res = [l._text for l in ax2.get_yticklabels()] exp = ['p__bar', 'p__bar', 'p__tar', 'p__far'] @@ -153,6 +162,15 @@ def test_proportion_plot_order(self): num_features, denom_features, self.feature_metadata, label_col='phylum') + res = np.vstack([l.get_xydata() for l in ax1.get_lines()]) + exp = np.array([0., 0., 1., 1., 2., 2., 3., 3.]) + + npt.assert_allclose(res[:, 1], exp, atol=1e-2, rtol=1e-2, verbose=True) + + res = np.vstack([l.get_xydata() for l in ax2.get_lines()]) + exp = np.array([0., 0., 1., 1., 2., 2., 3., 3.]) + + npt.assert_allclose(res[:, 1], exp, atol=1e-2, rtol=1e-2, verbose=True) res = [l._text for l in ax2.get_yticklabels()] exp = ['p__bar', 'p__bar', 'p__far', 'p__tar'] @@ -171,6 +189,16 @@ def test_proportion_plot_order_figure(self): num_features, denom_features, self.feature_metadata, label_col='phylum', axes=axes) + res = np.vstack([l.get_xydata() for l in ax1.get_lines()]) + exp = np.array([0., 0., 1., 1., 2., 2., 3., 3.]) + + npt.assert_allclose(res[:, 1], exp, atol=1e-2, rtol=1e-2, verbose=True) + + res = np.vstack([l.get_xydata() for l in ax2.get_lines()]) + exp = np.array([0., 0., 1., 1., 2., 2., 3., 3.]) + + + npt.assert_allclose(res[:, 1], exp, atol=1e-2, rtol=1e-2, verbose=True) res = [l._text for l in ax2.get_yticklabels()] exp = ['p__bar', 'p__bar', 'p__far', 'p__tar'] From cbb84d311419b8e7ea85205e65f92df1cf0a4d1a Mon Sep 17 00:00:00 2001 From: Jamie Morton Date: Thu, 28 Sep 2017 12:44:58 -0400 Subject: [PATCH 11/18] fixing travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5f0593a..2d82f68 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,7 @@ install: - conda install --yes -n test_env cython - source activate test_env - pip install -r ci/pip_requirements.txt - - pip install -e '.[q2]' + - pip install -e . script: - WITH_COVERAGE=TRUE make all - if [ ${MAKE_DOC} ]; then make -C doc clean html; fi From bf11b08db3ee113137a18d0a952169f32781b6f8 Mon Sep 17 00:00:00 2001 From: Jamie Morton Date: Thu, 28 Sep 2017 12:52:12 -0400 Subject: [PATCH 12/18] removing biom dependency --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index 15d19b1..e31cc3c 100644 --- a/setup.py +++ b/setup.py @@ -86,7 +86,6 @@ def finalize_options(self): 'nose >= 1.3.7', 'scikit-bio==0.5.1', 'statsmodels>=0.8.0', - 'biom-format', 'seaborn' ], classifiers=classifiers, From b93ca29bf00a5836c0f3c24bc51d201e2dd1a8a3 Mon Sep 17 00:00:00 2001 From: Jamie Morton Date: Thu, 28 Sep 2017 23:40:15 -0400 Subject: [PATCH 13/18] pep8 --- gneiss/plot/tests/test_decompose.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gneiss/plot/tests/test_decompose.py b/gneiss/plot/tests/test_decompose.py index f7a5520..19baea6 100644 --- a/gneiss/plot/tests/test_decompose.py +++ b/gneiss/plot/tests/test_decompose.py @@ -138,12 +138,12 @@ def test_proportion_plot(self): self.feature_metadata, label_col='phylum') res = np.vstack([l.get_xydata() for l in ax1.get_lines()]) - exp=np.array([0., 0., 1., 1., 2., 2., 3., 3.]) + exp = np.array([0., 0., 1., 1., 2., 2., 3., 3.]) npt.assert_allclose(res[:, 1], exp, verbose=True) res = np.vstack([l.get_xydata() for l in ax2.get_lines()]) - exp=np.array([0., 0., 1., 1., 2., 2., 3., 3.]) + exp = np.array([0., 0., 1., 1., 2., 2., 3., 3.]) npt.assert_allclose(res[:, 1], exp, verbose=True) @@ -197,7 +197,6 @@ def test_proportion_plot_order_figure(self): res = np.vstack([l.get_xydata() for l in ax2.get_lines()]) exp = np.array([0., 0., 1., 1., 2., 2., 3., 3.]) - npt.assert_allclose(res[:, 1], exp, atol=1e-2, rtol=1e-2, verbose=True) res = [l._text for l in ax2.get_yticklabels()] From ec99a0b16e05a4e9bc23e75ba13b702e582018b5 Mon Sep 17 00:00:00 2001 From: Jamie Morton Date: Mon, 2 Oct 2017 17:18:03 -0700 Subject: [PATCH 14/18] kick conda --- ci/conda_requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/conda_requirements.txt b/ci/conda_requirements.txt index b7b4eae..4025654 100644 --- a/ci/conda_requirements.txt +++ b/ci/conda_requirements.txt @@ -6,4 +6,4 @@ IPython>4.0.0 notebook scikit-bio=0.5.1 pyqt=4.11.4 -bokeh +bokeh=0.12.6 From ff451fce175b96dc47ebabfcacb24bb45da73060 Mon Sep 17 00:00:00 2001 From: Jamie Morton Date: Thu, 12 Oct 2017 10:45:12 -0700 Subject: [PATCH 15/18] DOC: fixing radial test. Also adding more documentation to proportion_plot --- gneiss/plot/_decompose.py | 36 ++++++++++++++++++++++++++++++++ gneiss/plot/tests/test_radial.py | 7 ++++--- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/gneiss/plot/_decompose.py b/gneiss/plot/_decompose.py index 9b491db..952dc63 100644 --- a/gneiss/plot/_decompose.py +++ b/gneiss/plot/_decompose.py @@ -198,6 +198,42 @@ def proportion_plot(table, metadata, category, left_group, right_group, Matplotlib axes for the numerator bars ax_denom : matplotlib.pyplot.Axes Matplotlib axes for the denominator bars + + Examples + -------- + First we'll want to set up the main objects to pass into the plot. + For starters, we'll pass in the feature table, metadata and + feature_metadata. + + >>> table = pd.DataFrame({ + ... 'A': [1, 1.2, 1.1, 2.1, 2.2, 2], + ... 'B': [9.9, 10, 10.1, 2, 2.4, 2.1], + ... 'C': [5, 3, 1, 2, 2, 3], + ... 'D': [5, 5, 5, 5, 5, 5], + ... }, index=['S1', 'S2', 'S3', 'S4', 'S5', 'S6']) + + >>> feature_metadata = pd.DataFrame({ + ... 'A': ['k__foo', 'p__bar', 'c__', 'o__', 'f__', 'g__', 's__'], + ... 'B': ['k__foo', 'p__bar', 'c__', 'o__', 'f__', 'g__', 's__'], + ... 'C': ['k__poo', 'p__tar', 'c__', 'o__', 'f__', 'g__', 's__'], + ... 'D': ['k__poo', 'p__far', 'c__', 'o__', 'f__', 'g__', 's__'] + ... }, index=['kingdom', 'phylum', 'class', 'order', 'family', + ... 'genus', 'species']).T + + >>> metadata = pd.DataFrame({ + ... 'groups': ['X', 'X', 'X', 'Y', 'Y', 'Y'], + ... 'dry': [1, 2, 3, 4, 5, 6]}, + ... index=['S1', 'S2', 'S3', 'S4', 'S5', 'S6']) + + Then we can specify which specific features to visualize and plot. + >>> num_features = ['A', 'B'] + >>> denom_features = ['C', 'D'] + >>> ax1, ax2 = proportion_plot(table, metadata, 'groups', 'X', 'Y', + ... num_features, denom_features, + ... feature_metadata, label_col='phylum') + + Since this method will return the raw matplotlib object, labels, titles, ticks, etc + can directly modified using this object. """ import seaborn as sns if axes[0] is None or axes[1] is None: diff --git a/gneiss/plot/tests/test_radial.py b/gneiss/plot/tests/test_radial.py index b46dc20..5716b6b 100644 --- a/gneiss/plot/tests/test_radial.py +++ b/gneiss/plot/tests/test_radial.py @@ -7,6 +7,7 @@ from gneiss.plot._radial import radialplot from gneiss.plot._dendrogram import UnrootedDendrogram import pandas.util.testing as pdt +import numpy.testing as npt class TestRadial(unittest.TestCase): @@ -84,9 +85,9 @@ def test_basic_plot(self): node_size='node_size', edge_width='edge_width') for e in exp_edges.keys(): - pdt.assert_series_equal( - p.renderers[0].data_source.data[e], - pd.Series(exp_edges[e], name=e)) + self.assertListEqual( + list(p.renderers[0].data_source.data[e]), + exp_edges[e]) for e in exp_nodes.keys(): self.assertListEqual( From 64759c6cde597824fa3d0c9e991642129071f4db Mon Sep 17 00:00:00 2001 From: Jamie Morton Date: Thu, 12 Oct 2017 10:47:15 -0700 Subject: [PATCH 16/18] Upgrade bokeh --- ci/conda_requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/conda_requirements.txt b/ci/conda_requirements.txt index 4025654..b7b4eae 100644 --- a/ci/conda_requirements.txt +++ b/ci/conda_requirements.txt @@ -6,4 +6,4 @@ IPython>4.0.0 notebook scikit-bio=0.5.1 pyqt=4.11.4 -bokeh=0.12.6 +bokeh From 3ffe06b3b16276619613166edf8ba6b479760036 Mon Sep 17 00:00:00 2001 From: Jamie Morton Date: Fri, 13 Oct 2017 07:45:01 -0700 Subject: [PATCH 17/18] pep8 --- gneiss/plot/_decompose.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gneiss/plot/_decompose.py b/gneiss/plot/_decompose.py index 952dc63..96fe1c4 100644 --- a/gneiss/plot/_decompose.py +++ b/gneiss/plot/_decompose.py @@ -232,8 +232,8 @@ def proportion_plot(table, metadata, category, left_group, right_group, ... num_features, denom_features, ... feature_metadata, label_col='phylum') - Since this method will return the raw matplotlib object, labels, titles, ticks, etc - can directly modified using this object. + Since this method will return the raw matplotlib object, labels, titles, + ticks, etc can directly modified using this object. """ import seaborn as sns if axes[0] is None or axes[1] is None: From a6bc991f1f66ec9ba6d0537b28ef4ea1355664c5 Mon Sep 17 00:00:00 2001 From: Jamie Morton Date: Fri, 13 Oct 2017 07:46:08 -0700 Subject: [PATCH 18/18] flake8 --- gneiss/plot/tests/test_radial.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/gneiss/plot/tests/test_radial.py b/gneiss/plot/tests/test_radial.py index 5716b6b..1825a95 100644 --- a/gneiss/plot/tests/test_radial.py +++ b/gneiss/plot/tests/test_radial.py @@ -6,8 +6,6 @@ from skbio import TreeNode, DistanceMatrix from gneiss.plot._radial import radialplot from gneiss.plot._dendrogram import UnrootedDendrogram -import pandas.util.testing as pdt -import numpy.testing as npt class TestRadial(unittest.TestCase):