src/hg/instinct/hgHeatmap2/drawingCode.c 1.81
1.81 2010/05/06 18:42:50 jsanborn
added new way of accessing clinical features
Index: src/hg/instinct/hgHeatmap2/drawingCode.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/instinct/hgHeatmap2/drawingCode.c,v
retrieving revision 1.80
retrieving revision 1.81
diff -b -B -U 4 -r1.80 -r1.81
--- src/hg/instinct/hgHeatmap2/drawingCode.c 17 Mar 2010 18:08:03 -0000 1.80
+++ src/hg/instinct/hgHeatmap2/drawingCode.c 6 May 2010 18:42:50 -0000 1.81
@@ -1205,9 +1205,8 @@
static struct rgbColor red = {255, 0, 0};
static struct rgbColor green = {0, 255, 0};
static struct rgbColor yellow = {255, 255, 0};
-struct slName *id = NULL;
char *raName = gh->raFile;
struct column *col, *colList = getColumns(conn, raName, gh->patDb);
int sampleHeight = hl->sampleHeight;
@@ -1236,8 +1235,23 @@
}
}
nCols=1;
+struct slInt *si, *siList;
+struct slName *id, *idList = NULL;
+for (sl = gh->sampleList; sl ; sl = sl->next)
+ {
+ int orderId = hashIntValDefault(gh->sampleOrder, sl->name, -1);
+
+ si = slIntNew(orderId);
+ slAddHead(&siList, si);
+
+ id = slNameNew(getId(conn, labTable, key, sl->name, value));
+ slAddHead(&idList, id);
+ }
+slReverse(&siList);
+slReverse(&idList);
+
for (hEl = hl->elements; hEl; hEl = hEl->next)
{
int chromX = hEl->pixelStart, chromY = 0;
int width = hEl->pixelEnd - hEl->pixelStart;
@@ -1303,19 +1317,33 @@
}
else /* single color */
colorScale = COLOR_SCALE / (maxVal - minVal);
- struct slName *sl = NULL;
+
+ struct slName *sv, *id, *valList = col->cellValList(col, idList, conn);
+
+ if (!valList || slCount(valList) != slCount(siList))
+ continue;
+
nSamples=0;
- for (sl = gh->sampleList; sl ; sl = sl->next)
- {
- int orderId = hashIntValDefault(gh->sampleOrder, sl->name, -1);
+ sv = valList;
+ si = siList;
+ id = idList;
+ while (sv && si && id)
+ {
+ int orderId = si->val; //hashIntValDefault(gh->sampleOrder, sl->name, -1);
+ char *cellVal = sv->name;
+
+ sv = sv->next;
+ si = si->next;
+ id = id->next;
if (orderId == -1)
continue;
- id = slNameNew(getId(conn, labTable, key, sl->name, value));
- char *cellVal = col->cellVal(col, id, conn);
+ //id = slNameNew(getId(conn, labTable, key, sl->name, value));
+ //char *cellVal = col->cellVal(col, id, conn);
+
if (output)
{
if (cellVal)
{
@@ -1346,9 +1374,9 @@
if (maxCutVal)
if (val > atof(maxCutVal))
continue;
absVal = fabs(val);
- absVal = reverseColor *( absVal +offset);
+ absVal = reverseColor * (absVal + offset);
/* double color: consistant with the scale of microarray data display */
int colorIndex ;
if ((minVal<0) && (maxVal>0))
@@ -1373,8 +1401,10 @@
vgBox(vg, chromX, y, width, h, valCol);
freez(&id);
}
+ slNameFreeList(&valList);
+
vgUnclip(vg);
}
/* write out feartureArray to output file, can be used for feature download function */
@@ -1460,27 +1490,32 @@
char *value = gh->sampleField;
char *key = gh->patField;
char *db = gh->patDb;
+if ((labTable == NULL) || (key == NULL) || (value == NULL) || (db==NULL))
+ return;
+
+struct sqlConnection *conn = hAllocConnProfile(gh->profile, db);
+
+if (!conn)
+ return;
+
struct slName *sl;
struct slInt *si, *siList = NULL;
+struct slName *id, *idList = NULL;
for (sl = sampleList; sl; sl = sl->next)
{
int i = slNameFindIx(gh->sampleList, sl->name);
- if (i < 0)
- continue;
+// if (i < 0)
+// continue;
si = slIntNew(i);
slAddHead(&siList, si);
+
+ id = slNameNew(getId(conn, labTable, key, sl->name, value));
+ slAddHead(&idList, id);
}
slReverse(&siList);
-
-if ((labTable == NULL) || (key == NULL) || (value == NULL) || (db==NULL))
- return;
-
-struct sqlConnection *conn = hAllocConnProfile(gh->profile, db);
-
-if (!conn)
- return;
+slReverse(&idList);
double colorScale = 0.0;
double val;
double absVal, minVal, maxVal;
@@ -1497,9 +1532,8 @@
static struct rgbColor red = {255, 0, 0};
static struct rgbColor green = {0, 255, 0};
static struct rgbColor yellow = {255, 255, 0};
-struct slName *id = NULL;
char *raName = gh->raFile;
struct column *col, *colList = getColumns(conn, raName, gh->patDb);
int height = hl->height;
@@ -1576,24 +1610,32 @@
}
else /* single color */
colorScale = COLOR_SCALE / (maxVal - minVal);
- struct slName *sl;
struct hmPixel *hm, *hmList = NULL;
- for (sl = sampleList; sl ; sl = sl->next)
- {
- int orderId = hashIntValDefault(gh->sampleOrder, sl->name, -1);
+ struct slName *sv, *id, *valList = col->cellValList(col, idList, conn);
- if (orderId == -1)
+ if (!valList || slCount(valList) != slCount(siList))
continue;
- int y = round((double) orderId * h);
- id = slNameNew(getId(conn, labTable, key, sl->name, value));
+ sv = valList;
+ si = siList;
+ id = idList;
+ while (sv && si && id)
+ {
+ int orderId = si->val; //hashIntValDefault(gh->sampleOrder, sl->name, -1);
+ char *cellVal = sv->name;
- char *cellVal = col->cellVal(col, id, conn);
+ sv = sv->next;
+ si = si->next;
+ id = id->next;
+ if (orderId == -1)
+ continue;
if (!cellVal)
continue;
+
+ int y = round((double) orderId * h);
val = atof(cellVal);
if (minCutVal)
if (val < atof(minCutVal))