Ejemplo n.º 1
0
    def somcluster(self,
                   transpose=0,
                   nxgrid=2,
                   nygrid=1,
                   inittau=0.02,
                   niter=1,
                   dist='e'):
        """Calculate a self-organizing map on a rectangular grid.

The somcluster method returns a tuple (clusterid, celldata).

  - transpose: if equal to 0, genes (rows) are clustered;
    if equal to 1, microarrays (columns) are clustered.
  - nxgrid   : the horizontal dimension of the rectangular SOM map
  - nygrid   : the vertical dimension of the rectangular SOM map
  - inittau  : the initial value of tau (the neighborbood function)
  - niter    : the number of iterations
  - 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 values:

    - clusterid: array with two columns, while the number of rows is equal to
      the number of genes or the number of microarrays depending on
      whether genes or microarrays are being clustered. Each row in
      the array contains the x and y coordinates of the cell in the
      rectangular SOM grid to which the gene or microarray was
      assigned.
    - celldata:  an array with dimensions (nxgrid, nygrid, number of
      microarrays) if genes are being clustered, or (nxgrid,
      nygrid, number of genes) if microarrays are being clustered.
      Each element [ix][iy] of this array is a 1D vector containing
      the gene expression data for the centroid of the cluster in
      the SOM grid cell with coordinates (ix, iy).

"""
        if transpose == 0:
            weight = self.eweight
        else:
            weight = self.gweight
        return somcluster(self.data, self.mask, weight, transpose, nxgrid,
                          nygrid, inittau, niter, dist)
Ejemplo n.º 2
0
    def somcluster(self, transpose=0, nxgrid=2, nygrid=1, inittau=0.02,
                   niter=1, dist='e'):
        """Calculate a self-organizing map on a rectangular grid.

        The somcluster method returns a tuple (clusterid, celldata).

        Arguments:
         - transpose: if equal to 0, genes (rows) are clustered;
           if equal to 1, microarrays (columns) are clustered.
         - nxgrid   : the horizontal dimension of the rectangular SOM map
         - nygrid   : the vertical dimension of the rectangular SOM map
         - inittau  : the initial value of tau (the neighborbood function)
         - niter    : the number of iterations
         - 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 values:
         - clusterid: array with two columns, while the number of rows is equal
           to the number of genes or the number of microarrays depending on
           whether genes or microarrays are being clustered. Each row in
           the array contains the x and y coordinates of the cell in the
           rectangular SOM grid to which the gene or microarray was assigned.
         - celldata:  an array with dimensions (nxgrid, nygrid, number of
           microarrays) if genes are being clustered, or (nxgrid, nygrid,
           number of genes) if microarrays are being clustered. Each element
           [ix][iy] of this array is a 1D vector containing the gene
           expression data for the centroid of the cluster in the SOM grid
           cell with coordinates (ix, iy).

        """
        if transpose == 0:
            weight = self.eweight
        else:
            weight = self.gweight
        return somcluster(self.data, self.mask, weight, transpose,
                          nxgrid, nygrid, inittau, niter, dist)