示例#1
0
 def setup(self):
     with open(get_data_path('PCoA_sample_data_3'), 'U') as lines:
         dist_matrix = DistanceMatrix.from_file(lines)
     self.ordination = PCoA(dist_matrix)
     self.ids = [
         'PC.636', 'PC.635', 'PC.356', 'PC.481', 'PC.354', 'PC.593',
         'PC.355', 'PC.607', 'PC.634'
     ]
示例#2
0
    def test_values(self):
        """Adapted from cogent's `test_principal_coordinate_analysis`:
        "I took the example in the book (see intro info), and did the
        principal coordinates analysis, plotted the data and it looked
        right"."""
        with warnings.catch_warnings():
            warnings.filterwarnings('ignore', category=RuntimeWarning)
            ordination = PCoA(self.dist_matrix)
        scores = ordination.scores()

        # Note the absolute value because column can have signs swapped
        npt.assert_almost_equal(np.abs(scores.species[0, 0]),
                                0.24078813304509292)

        # cogent returned the scores transposed
        npt.assert_almost_equal(np.abs(scores.species[0, 1]),
                                0.23367716219400031)
示例#3
0
 def test_input(self):
     with npt.assert_raises(TypeError):
         PCoA([[1, 2], [3, 4]])
示例#4
0
 def setup(self):
     matrix = np.loadtxt(get_data_path('PCoA_sample_data_2'))
     self.ids = map(str, range(matrix.shape[0]))
     dist_matrix = DistanceMatrix(matrix, self.ids)
     self.ordination = PCoA(dist_matrix)