def distancematrix(self, transpose=0, dist='e'):
        """Calculate the distance matrix and return it as a list of arrays.

        Arguments:
         - transpose: if equal to 0: calculate the distances between genes
           (rows); if equal to 1: calculate the distances beteeen microarrays
           (columns).
         - dist     : specifies the distance function to be used:

           - dist=='e': Euclidean distance
           - dist=='b': City Block distance
           - dist=='c': Pearson correlation
           - dist=='a': absolute value of the correlation
           - dist=='u': uncentered correlation
           - dist=='x': absolute uncentered correlation
           - dist=='s': Spearman's rank correlation
           - dist=='k': Kendall's tau

        Return value:

        The distance matrix is returned as a list of 1D arrays containing the
        distance matrix between the gene expression data. The number of columns
        in each row is equal to the row number. Hence, the first row has zero
        elements. An example of the return value is::

            matrix = [[],
                      array([1.]),
                      array([7., 3.]),
                      array([4., 2., 6.])]

        This corresponds to the distance matrix::

            [0., 1., 7., 4.]
            [1., 0., 3., 2.]
            [7., 3., 0., 6.]
            [4., 2., 6., 0.]

        """
        if transpose == 0:
            weight = self.eweight
        else:
            weight = self.gweight
        return distancematrix(self.data, self.mask, weight, transpose, dist)
示例#2
0
    def distancematrix(self, transpose=0, dist='e'):
        """Calculate the distance matrix and return it as a list of arrays.

        Arguments:
         - transpose: if equal to 0: calculate the distances between genes
           (rows); if equal to 1: calculate the distances beteeen microarrays
           (columns).
         - dist     : specifies the distance function to be used:

           - dist=='e': Euclidean distance
           - dist=='b': City Block distance
           - dist=='c': Pearson correlation
           - dist=='a': absolute value of the correlation
           - dist=='u': uncentered correlation
           - dist=='x': absolute uncentered correlation
           - dist=='s': Spearman's rank correlation
           - dist=='k': Kendall's tau

        Return value:

        The distance matrix is returned as a list of 1D arrays containing the
        distance matrix between the gene expression data. The number of columns
        in each row is equal to the row number. Hence, the first row has zero
        elements. An example of the return value is::

            matrix = [[],
                      array([1.]),
                      array([7., 3.]),
                      array([4., 2., 6.])]

        This corresponds to the distance matrix::

            [0., 1., 7., 4.]
            [1., 0., 3., 2.]
            [7., 3., 0., 6.]
            [4., 2., 6., 0.]

        """
        if transpose == 0:
            weight = self.eweight
        else:
            weight = self.gweight
        return distancematrix(self.data, self.mask, weight, transpose, dist)