Save the clustering results. The saved files follow the convention for the Java TreeView program, which can therefore be used to view the clustering result. Arguments: jobname: The base name of the files to be saved. The filenames are jobname.cdt, jobname.gtr, and jobname.atr for hierarchical clustering, and jobnameK*.cdt, jobnameK*.kgg, jobnameK*.kag for kmeans clustering results. geneclusters=None: For hierarchical clustering results, geneclusters is a Tree object as returned by the treecluster method. For kmeans clustering results, geneclusters is a vector containing ngenes integers, describing to which cluster a given gene belongs. This vector can be calculated by kcluster. expclusters=None: For hierarchical clustering results, expclusters is a Tree object as returned by the treecluster method. For kmeans clustering results, expclusters is a vector containing nexps integers, describing to which cluster a given experimental condition belongs. This vector can be calculated by kcluster. Definition at line 469 of file __init__.py. 00469 : """Save the clustering results. The saved files follow the convention for the Java TreeView program, which can therefore be used to view the clustering result. Arguments: jobname: The base name of the files to be saved. The filenames are jobname.cdt, jobname.gtr, and jobname.atr for hierarchical clustering, and jobnameK*.cdt, jobnameK*.kgg, jobnameK*.kag for kmeans clustering results. geneclusters=None: For hierarchical clustering results, geneclusters is a Tree object as returned by the treecluster method. For kmeans clustering results, geneclusters is a vector containing ngenes integers, describing to which cluster a given gene belongs. This vector can be calculated by kcluster. expclusters=None: For hierarchical clustering results, expclusters is a Tree object as returned by the treecluster method. For kmeans clustering results, expclusters is a vector containing nexps integers, describing to which cluster a given experimental condition belongs. This vector can be calculated by kcluster. """ (ngenes,nexps) = numpy.shape(self.data) if self.gorder == None: gorder = numpy.arange(ngenes) else: gorder = self.gorder if self.eorder == None: eorder = numpy.arange(nexps) else: eorder = self.eorder if geneclusters!=None and expclusters!=None and \ type(geneclusters) != type(expclusters): raise ValueError("found one kmeans and one hierarchical " + "clustering solution in geneclusters and " + "expclusters") gid = 0 aid = 0 filename = jobname postfix = "" if type(geneclusters) == Tree: # This is a hierarchical clustering result. geneindex = _savetree(jobname, geneclusters, gorder, 0) gid = 1 elif geneclusters!=None: # This is a kmeans clustering result. filename = jobname + "_K" k = max(geneclusters+1) kggfilename = "%s_K_G%d.kgg" % (jobname, k) geneindex = self._savekmeans(kggfilename, geneclusters, gorder, 0) postfix = "_G%d" % k else: geneindex = numpy.argsort(gorder) if type(expclusters) == Tree: # This is a hierarchical clustering result. expindex = _savetree(jobname, expclusters, eorder, 1) aid = 1 elif expclusters!=None: # This is a kmeans clustering result. filename = jobname + "_K" k = max(expclusters+1) kagfilename = "%s_K_A%d.kag" % (jobname, k) expindex = self._savekmeans(kagfilename, expclusters, eorder, 1) postfix += "_A%d" % k else: expindex = numpy.argsort(eorder) filename = filename + postfix self._savedata(filename,gid,aid,geneindex,expindex) def _savekmeans(self, filename, clusterids, order, transpose):
