src/hg/instinct/hgGeneset/hgGenesets.c 1.9

1.9 2010/01/29 00:34:07 jsanborn
added 2D clustering
Index: src/hg/instinct/hgGeneset/hgGenesets.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/instinct/hgGeneset/hgGenesets.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -b -B -U 4 -r1.8 -r1.9
--- src/hg/instinct/hgGeneset/hgGenesets.c	28 Jan 2010 23:19:36 -0000	1.8
+++ src/hg/instinct/hgGeneset/hgGenesets.c	29 Jan 2010 00:34:07 -0000	1.9
@@ -859,23 +859,42 @@
 
 if (method == '-' || metric == '-')
     errAbort("Invalid clustering method or metric string.\n");
 
-struct slName *sl, *ordered = clusterDataByGene(rdList, settings, method, metric);
+struct slName *sl, *geneOrder = NULL, *sampleOrder = NULL;
+clusterData(rdList, settings, method, metric, &geneOrder, &sampleOrder);
 
-// Remove old hash, update it with new order.
-hashFree(&settings->y_index);
-settings->y_index = hashNew(0);
-
-struct hashEl *el;
-int numFeatures = 0;
-for (sl = ordered; sl; sl = sl->next)
+if (sampleOrder)
+    {    
+    hashFree(&settings->x_index);
+    settings->x_index = hashNew(0);
+    
+    struct hashEl *el;
+    int numSamples = 0;
+    for (sl = sampleOrder; sl; sl = sl->next)
+	{
+	if ((el = hashLookup(settings->x_index, sl->name)) != NULL)
+	    continue;
+	hashAddInt(settings->x_index, sl->name, numSamples);
+	numSamples += 1;
+	}
+    }
+
+if (geneOrder)
+    {
+    hashFree(&settings->y_index);
+    settings->y_index = hashNew(0);
+    
+    struct hashEl *el;
+    int numFeatures = 0;
+    for (sl = geneOrder; sl; sl = sl->next)
     {
     if ((el = hashLookup(settings->y_index, sl->name)) != NULL)
 	continue;
     hashAddInt(settings->y_index, sl->name, numFeatures);
     numFeatures += 1;
     }
+    }
 }