948ce415a6e8b218d601cc2034d7ba1b0c56e468
kate
  Wed Sep 13 10:39:29 2017 -0700
Replace colored asterisk with color patch to indicate tissue color. Input from Casey Brown, U Penn. refs #15646

diff --git src/hg/hgTracks/gtexEqtlClusterTrack.c src/hg/hgTracks/gtexEqtlClusterTrack.c
index 17889e1..422bfad 100644
--- src/hg/hgTracks/gtexEqtlClusterTrack.c
+++ src/hg/hgTracks/gtexEqtlClusterTrack.c
@@ -8,34 +8,30 @@
 #include "hgTracks.h"
 #include "gtexInfo.h"
 #include "gtexTissue.h"
 #include "gtexUi.h"
 #include "gtexEqtlCluster.h"
 
 struct gtexEqtlClusterTrack
 /* Track info for filtering (maybe later for draw, map) */
 {
     struct gtexTissue *tissues; /*  Tissue names, descriptions */
     struct hash *tissueHash;    /* Tissue info, keyed by UCSC name, filtered by UI */
     double minEffect;           /* Effect size filter (abs value) */
     double minProb;             /* Probability filter */
 };
 
-/* Track constants */
-
-#define TISSUE_COLOR_DOT        "*"
-
 /* Utility functions */
 
 static struct gtexEqtlCluster *loadOne(char **row)
 /* Load up gtexEqtlCluster from array of strings. */
 {
 return gtexEqtlClusterLoad(row);
 }
 
 static boolean filterTissuesFromCart(struct track *track, struct gtexEqtlClusterTrack *extras)
 /* Check cart for tissue selection. Populate track tissues hash */
 {
 char *version = gtexVersionSuffix(track->table);
 extras->tissues = gtexGetTissues(version);
 extras->tissueHash = hashNew(0);
 struct gtexTissue *tis = NULL;
@@ -215,65 +211,70 @@
     }
 double cutoff = 2.0;
 if (maxEffect < 0.0)
     {
     /* down-regulation displayed as blue */
     if (maxEffect < 0.0 - cutoff)
         return MG_CYAN;
     return MG_BLUE;
     }
 /* up-regulation displayed as red */
 if (maxEffect > cutoff)
     return MG_MAGENTA;
 return MG_RED;
 }
 
+/* Helper macros */
+
+#define tissueColorPatchSpacer()        (tl.nWidth/4)
+
+#define tissueColorPatchWidth()         (tl.nWidth)
+
 static int gtexEqtlClusterItemRightPixels(struct track *track, void *item)
 /* Return number of pixels we need to the right of an item (for sources label). */
 {
 struct gtexEqtlCluster *eqtl = (struct gtexEqtlCluster *)item;
 int ret = mgFontStringWidth(tl.font, eqtlSourcesLabel(eqtl));
 if (eqtlTissueCount(eqtl) == 1)
-    ret += mgFontStringWidth(tl.font, TISSUE_COLOR_DOT);
+    ret += tissueColorPatchWidth() + tissueColorPatchSpacer();
 return ret;
 }
 
 static void gtexEqtlClusterDrawItemAt(struct track *track, void *item, 
 	struct hvGfx *hvg, int xOff, int y, 
 	double scale, MgFont *font, Color color, enum trackVisibility vis)
 /* Draw GTEx eQTL cluster with right label indicating source(s) */
 {
 bedDrawSimpleAt(track, item, hvg, xOff, y, scale, font, color, vis);
 if (vis != tvFull && vis != tvPack)
     return;
 
 /* Draw text to the right */
 struct gtexEqtlCluster *eqtl = (struct gtexEqtlCluster *)item;
 int x2 = round((double)((int)eqtl->chromEnd-winStart)*scale) + xOff;
 int x = x2 + tl.mWidth/2;
 char *label = eqtlSourcesLabel(eqtl);
 int w = mgFontStringWidth(font, label);
 hvGfxTextCentered(hvg, x, y, w, track->heightPer, MG_BLACK, font, label);
 if (eqtlTissueCount(eqtl) == 1)
     {
-    // append asterisk in tissue color
-    struct rgbColor tisColor = eqtlTissueColor(track, eqtl);
+    // tissue color patch (box)
     x += w;
-    w = mgFontStringWidth(font, TISSUE_COLOR_DOT);
+    int h = w = tissueColorPatchWidth();
+    struct rgbColor tisColor = eqtlTissueColor(track, eqtl);
     int ix = hvGfxFindColorIx(hvg, tisColor.r, tisColor.g, tisColor.b);
-    font = mgFontForSizeAndStyle(tl.textSize, "bold");
-    hvGfxTextCentered(hvg, x, y, w, track->heightPer, ix, font, TISSUE_COLOR_DOT);
+    hvGfxBox(hvg, x + tissueColorPatchSpacer(), y + (tl.fontHeight - h)/2 + tl.fontHeight/8, w, h, ix);
     }
 }
 
 static void gtexEqtlClusterMapItem(struct track *track, struct hvGfx *hvg, void *item, 
                                 char *itemName, char *mapItemName, int start, int end, 
                                 int x, int y, int width, int height)
 /* Create a map box on item and label with list of tissues with colors and effect size */
 {
 char *title = itemName;
 if (track->limitedVis != tvDense)
     {
     struct gtexEqtlCluster *eqtl = (struct gtexEqtlCluster *)item;
     // Experiment: construct list of tissues with colors and effect sizes for mouseover
     //struct gtexEqtlClusterTrack *extras = (struct gtexEqtlClusterTrack *)track->extraUiData;
     //struct hash *tissueHash = extras->tissueHash;