Exemplo n.º 1
0
    def test_proportion_plot_order_figure(self):
        self.maxDiff = None
        np.random.seed(0)
        # 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,
                                   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']
        self.assertListEqual(res, exp)
Exemplo n.º 2
0
    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,
                                   'groups',
                                   'X',
                                   'Y',
                                   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']
        self.assertListEqual(res, exp)
Exemplo n.º 3
0
    def test_proportion_plot_order_figure(self):
        self.maxDiff = None
        np.random.seed(0)
        # 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,
                                   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']
        self.assertListEqual(res, exp)
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
    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)
Exemplo n.º 6
0
    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,
                                   'groups', 'X', 'Y',
                                   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']
        self.assertListEqual(res, exp)