3aba88e939c2f51ed4a3eaefbc50ecccdc3836f7 kate Wed Mar 30 11:40:32 2016 -0700 Add white background box to graph, and tweak graph sizes. refs #15645 diff --git src/hg/hgTracks/gtexTracks.c src/hg/hgTracks/gtexTracks.c index 8186322..05e816e 100644 --- src/hg/hgTracks/gtexTracks.c +++ src/hg/hgTracks/gtexTracks.c @@ -439,41 +439,41 @@ geneBed = geneBed->next; geneInfo->geneBed->next = NULL; if (extras->isComparison && (tg->visibility == tvFull || tg->visibility == tvPack)) // compute medians based on configuration (comparisons, and later, filters) loadComputedMedians(geneInfo, extras); geneInfo->height = gtexGeneItemHeight(tg, geneInfo); } slReverse(&list); tg->items = list; } /***********************************************/ /* Draw */ /* Bargraph layouts for three window sizes */ -#define WIN_MAX_GRAPH 20000 -#define MAX_GRAPH_HEIGHT 100 +#define WIN_MAX_GRAPH 50000 +#define MAX_GRAPH_HEIGHT 175 #define MAX_BAR_WIDTH 5 #define MAX_GRAPH_PADDING 2 #define WIN_MED_GRAPH 500000 -#define MED_GRAPH_HEIGHT 60 +#define MED_GRAPH_HEIGHT 100 #define MED_BAR_WIDTH 3 #define MED_GRAPH_PADDING 1 -#define MIN_GRAPH_HEIGHT 20 +#define MIN_GRAPH_HEIGHT 35 #define MIN_BAR_WIDTH 1 #define MIN_GRAPH_PADDING 0 #define MARGIN_WIDTH 1 static int gtexBarWidth() { long winSize = virtWinBaseCount; if (winSize < WIN_MAX_GRAPH) return MAX_BAR_WIDTH; else if (winSize < WIN_MED_GRAPH) return MED_BAR_WIDTH; else return MIN_BAR_WIDTH; } @@ -559,64 +559,74 @@ static int valToClippedHeight(double val, double maxVal, int maxView, int maxHeight, boolean doLogTransform) /* Convert a value from 0 to maxVal to 0 to maxHeight-1, with clipping, or log transform the value */ { double useVal = val; double useMax = maxVal; if (!doLogTransform) { useMax = maxView; if (val > maxView) useVal = maxView; } return valToHeight(useVal, useMax, gtexMaxGraphHeight(), doLogTransform); } -static void drawGraphBase(struct track *tg, struct gtexGeneInfo *geneInfo, struct hvGfx *hvg, int x, int y) -/* Draw faint line under graph to delineate extent when bars are missing (tissue w/ 0 expression) */ -{ -Color lightGray = MAKECOLOR_32(0xD1, 0xD1, 0xD1); -int graphWidth = gtexGraphWidth(tg, geneInfo); -hvGfxBox(hvg, x, y, graphWidth, 1, lightGray); -} - static int gtexGeneGraphHeight(struct track *tg, struct gtexGeneInfo *geneInfo, boolean doTop) /* Determine height in pixels of graph. This will be the box for tissue with highest expression If doTop is false, compute height of bottom graph of comparison */ { struct gtexGeneBed *geneBed = geneInfo->geneBed; struct gtexGeneExtras *extras = (struct gtexGeneExtras *)tg->extraUiData; int i; double maxExp = 0.0; int expCount = geneBed->expCount; double expScore; for (i=0; i<expCount; i++) { if (!filterTissue(tg, getTissueName(i, extras->version))) continue; if (doTop) expScore = (geneInfo->medians1 ? geneInfo->medians1[i] : geneBed->expScores[i]); else expScore = geneInfo->medians2[i]; maxExp = max(maxExp, expScore); } double viewMax = (double)cartUsualIntClosestToHome(cart, tg->tdb, FALSE, GTEX_MAX_LIMIT, GTEX_MAX_LIMIT_DEFAULT); double maxMedian = ((struct gtexGeneExtras *)tg->extraUiData)->maxMedian; return valToClippedHeight(maxExp, maxMedian, viewMax, gtexMaxGraphHeight(), extras->doLogTransform); } +static void drawGraphBox(struct track *tg, struct gtexGeneInfo *geneInfo, struct hvGfx *hvg, int x, int y) +/* Draw white background for graph */ +{ +Color lighterGray = MAKECOLOR_32(0xF5, 0xF5, 0xF5); +int width = gtexGraphWidth(tg, geneInfo); +int height = gtexGeneGraphHeight(tg, geneInfo, TRUE); +hvGfxOutlinedBox(hvg, x, y-height, width, height, MG_WHITE, lighterGray); +//hvGfxBox(hvg, x, y-height, width, height, MG_WHITE); +} + +static void drawGraphBase(struct track *tg, struct gtexGeneInfo *geneInfo, struct hvGfx *hvg, int x, int y) +/* Draw faint line under graph to delineate extent when bars are missing (tissue w/ 0 expression) */ +{ +Color lightGray = MAKECOLOR_32(0xD1, 0xD1, 0xD1); +int graphWidth = gtexGraphWidth(tg, geneInfo); +hvGfxBox(hvg, x, y, graphWidth, 1, lightGray); +} + static void gtexGeneDrawAt(struct track *tg, void *item, struct hvGfx *hvg, int xOff, int y, double scale, MgFont *font, Color color, enum trackVisibility vis) /* Draw tissue expression bar graph over gene model. Optionally, draw a second graph under gene, to compare sample sets */ { struct gtexGeneExtras *extras = (struct gtexGeneExtras *)tg->extraUiData; struct gtexGeneInfo *geneInfo = (struct gtexGeneInfo *)item; struct gtexGeneBed *geneBed = geneInfo->geneBed; // Color in squish mode using geneClass Color statusColor = getGeneClassColor(hvg, geneBed); if (vis != tvFull && vis != tvPack) { bedDrawSimpleAt(tg, geneBed, hvg, xOff, y, scale, font, statusColor, vis); return; } @@ -655,30 +665,31 @@ { if (vis != tvFull && vis != tvPack) return; struct gtexGeneExtras *extras = (struct gtexGeneExtras *)tg->extraUiData; struct gtexGeneInfo *geneInfo = (struct gtexGeneInfo *)item; struct gtexGeneBed *geneBed = geneInfo->geneBed; int topGraphHeight = gtexGeneGraphHeight(tg, geneInfo, TRUE); topGraphHeight = max(topGraphHeight, tl.fontHeight); int yZero = topGraphHeight + y - 1; // yZero is bottom of graph int yGene = yZero + gtexGeneMargin()-1; int graphX = gtexGraphX(geneBed); int x1 = xOff + graphX; // x1 is at left of graph int keepX = x1; drawGraphBase(tg, geneInfo, hvg, keepX, yZero+1); +drawGraphBox(tg, geneInfo, hvg, keepX, yZero+1); int startX = x1; struct rgbColor lineColor = {.r=0}; int lineColorIx = hvGfxFindColorIx(hvg, lineColor.r, lineColor.g, lineColor.b); int barWidth = gtexBarWidth(); int graphPadding = gtexGraphPadding(); char *colorScheme = cartUsualStringClosestToHome(cart, tg->tdb, FALSE, GTEX_COLORS, GTEX_COLORS_DEFAULT); Color labelColor = MG_GRAY; Color clipColor = MG_MAGENTA; // add labels to comparison graphs if (geneInfo->medians2) { hvGfxText(hvg, x1, yZero - tl.fontHeight + 2, labelColor, font, "F");