03683582252ee7b4f9b503063a6405a6455933bf
kate
Thu Oct 8 17:15:50 2015 -0700
Preliminary work to add tick marks and sanity check Y axis label (max value) on GTEx expression graph. refs #15645
diff --git src/hg/hgc/gtexClick.c src/hg/hgc/gtexClick.c
index 643c710..b1518a3 100644
--- src/hg/hgc/gtexClick.c
+++ src/hg/hgc/gtexClick.c
@@ -276,41 +276,88 @@
//hvGfxSetClip(hvg, 0, 0, imageWidth, imageHeight); // needed ?
int x=innerXoff + pad, y = innerYoff + pad;
for (tsv = tsList; tsv != NULL; tsv = tsv->next)
{
struct rgbColor fillColor = rgbFromIntColor(tsv->color);
int fillColorIx = hvGfxFindColorIx(hvg, fillColor.r, fillColor.g, fillColor.b);
drawBoxAndWhiskers(hvg, fillColorIx, x, y, tsv, maxVal);
x += barWidth + pad;
}
//hvGfxUnclip(hvg);
/* Draw title */
int blackColorIx = hvGfxFindColorIx(hvg, 0,0,0);
char title[256];
-safef(title, sizeof(title), "GTEx V4 Tissue Expression in %s", gtexGene->name);
+// TODO: get tissue count and release from tables
+safef(title, sizeof(title), "%s Gene Expression in 53 Tissues from GTEx (V4 release, 2014) - %s",
+ gtexGene->name, doLogTransform ? "log10(RPKM+1)" : "(RPKM)");
hvGfxTextCentered(hvg, 0, innerYoff, imageWidth, titleHeight, blackColorIx, mgMediumFont(), title);
/* Draw axes */
x = innerXoff - margin;
-// Y axis
+
+// Y axis, tick marks, and labels
hvGfxLine(hvg, x, innerYoff, x, plotHeight, blackColorIx);
+
+// for now, just mark the max value
+char buf[16];
+safef(buf, sizeof(buf), "%d -", round(maxVal));
+hvGfxText(hvg, x-24, innerYoff-8, blackColorIx, mgMediumFont(), buf);
+
// X axis
y = innerYoff + plotHeight;
hvGfxLine(hvg, innerXoff, y, plotWidth, y, blackColorIx);
+// Draw vertical labels on separate graphics object, rotate, then merge
+/*
+struct memGvx *mg = mgNew(imageHeight, imageWidth);
+MgFont *font = mgMediumFont();
+int lineHeight = mgFontLineHeight(font)-1;
+y += lineHeight;
+mgTextRight(mg, 0+1, y+1, width-1, lineHeight, MG_BLACK, font, labels[i]);
+hvGfxMergeWithPng(hvg, mgRotate90(mg));
+// or try using mg lib entirely, via mgSavePng.
+*/
+
+#ifdef TICKS
+/* Figure tick intervals. GTEx portal uses .5 for log, 2, 5, 10, 20, 50, 100 for linear.
+ * With 7-12 ticks. 5-10 seems nicer to me. Here's how it's done for browser ruler */
+
+static long figureTickSpan(long totalLength, int maxNumTicks)
+/* Figure out whether ticks on ruler should be 1, 5, 10, 50, 100, 500,
+ * 1000, etc. units apart. */
+{
+int roughTickLen = totalLength/maxNumTicks;
+int i;
+int tickLen = 1;
+
+for (i=0; i<9; ++i)
+ {
+ if (roughTickLen < tickLen)
+ return tickLen;
+ tickLen *= 5;
+ if (roughTickLen < tickLen)
+ return tickLen;
+ tickLen *= 2;
+ }
+return 1000000000;
+}
+#endif
+
+
+
hvGfxClose(&hvg);
printf("
\n", pngTn.forHtml);
/*printf("
\n",
pngTn.forHtml, imageWidth, imageHeight);
*/
//cloneString(gifTn.forHtml);
// Track description
printTrackHtml(tdb);
// Print out tissue table with color assignments
#ifdef DEBUG
conn = hAllocConn("hgFixed");
char *tissueTable = "gtexTissue";
if (sqlTableExists(conn, tissueTable))