e02a7c45c8e48c1510ac488e87ceedccbdd84dbe kate Thu Mar 31 22:07:21 2016 -0700 Fixes to 'no gene model display', and make it default, as per JK. refs #15645 diff --git src/hg/hgTracks/gtexTracks.c src/hg/hgTracks/gtexTracks.c index 5550852..1b4f749 100644 --- src/hg/hgTracks/gtexTracks.c +++ src/hg/hgTracks/gtexTracks.c @@ -260,30 +260,50 @@ medians1[i] = 0; } } } geneInfo->medians1 = medians1; geneInfo->medians2 = medians2; } } static int gtexSquishItemHeight() /* Height of squished item (request to have it larger than usual) */ { return tl.fontHeight - tl.fontHeight/2; } +static int gtexGeneBoxModelHeight() +/* Height of indicator box drawn under graph to show gene extent */ +{ +long winSize = virtWinBaseCount; +//FIXME: dupes!! +#define WIN_MAX_GRAPH 50000 +#define WIN_MED_GRAPH 500000 + +#define MAX_GENE_BOX_HEIGHT 2 +#define MED_GENE_BOX_HEIGHT 2 +#define MIN_GENE_BOX_HEIGHT 1 + +if (winSize < WIN_MAX_GRAPH) + return MAX_GENE_BOX_HEIGHT; +else if (winSize < WIN_MED_GRAPH) + return MED_GENE_BOX_HEIGHT; +else + return MIN_GENE_BOX_HEIGHT; +} + static int gtexGeneItemHeight(struct track *tg, void *item); static void filterTissues(struct track *tg) /* Check cart for tissue selection. NULL out unselected tissues in tissue list */ { struct gtexGeneExtras *extras = (struct gtexGeneExtras *)tg->extraUiData; struct gtexTissue *tis = NULL; extras->tissues = getTissues(extras->version); extras->tissueFilter = hashNew(0); if (cartListVarExistsAnyLevel(cart, tg->tdb, FALSE, GTEX_TISSUE_SELECT)) { struct slName *selectedValues = cartOptionalSlNameListClosestToHome(cart, tg->tdb, FALSE, GTEX_TISSUE_SELECT); if (selectedValues != NULL) { @@ -489,31 +509,31 @@ } static enum trackVisibility gtexGeneModelVis(struct gtexGeneExtras *extras) { if (!extras->showExons) return tvSquish; long winSize = virtWinBaseCount; if (winSize < WIN_MED_GRAPH && !extras->isComparison) return tvPack; return tvSquish; } static int gtexGeneModelHeight(struct gtexGeneExtras *extras) { if (!extras->showExons) - return 1; + return gtexGeneBoxModelHeight()+3; enum trackVisibility vis = gtexGeneModelVis(extras); if (vis == tvSquish) return trunc(tl.fontHeight/2) + 1; return tl.fontHeight; } static int gtexGraphPadding() { long winSize = virtWinBaseCount; if (winSize < WIN_MAX_GRAPH) return MAX_GRAPH_PADDING; else if (winSize < WIN_MED_GRAPH) return MED_GRAPH_PADDING; else @@ -606,100 +626,112 @@ 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(0xF3, 0xF3, 0xF3); 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 getItemX(int start, int end, int *x1, int *x2) /* Return startX, endX based on item coordinates and current window */ +// TODO: Should be using simpleTracks.c scaledBoxToPixelCoords { int s = max(start, winStart); int e = min(end, winEnd); double scale = scaleForWindow(insideWidth, winStart, winEnd); assert(x1); *x1 = round((double)((int)s-winStart)*scale + insideX); assert(x2); *x2 = round((double)((int)e-winStart)*scale + insideX); } +static void drawGeneExprBox(struct track *tg, struct gtexGeneBed *geneBed, struct hvGfx *hvg, int y) +/* Draw box colored by max expressed tissue (if any), for use in squish mode */ +// TODO: Should be using simpleTracks.c:drawScaledBox +{ +int x1, x2; +getItemX(geneBed->chromStart, geneBed->chromEnd, &x1, &x2); +Color color = gtexGeneItemColor(tg, geneBed, hvg); +hvGfxBox(hvg, x1, y, x2-x1, gtexSquishItemHeight(), color); +} + +static void drawGeneModelBox(struct track *tg, struct gtexGeneBed *geneBed, struct hvGfx *hvg, int y, Color color) +/* Draw indicator bar under graph, covering extent of gene */ +// TODO: Should be using simpleTracks.c:drawScaledBox +{ +int x1, x2; +getItemX(geneBed->chromStart, geneBed->chromEnd, &x1, &x2); +hvGfxBox(hvg, x1, y, x2-x1, gtexGeneBoxModelHeight(), color); +} + 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 == tvDense) { - bedDrawSimpleAt(tg, geneBed, hvg, xOff, y, scale, font, statusColor, vis); + bedDrawSimpleAt(tg, geneBed, hvg, xOff, y, scale, font, MG_WHITE, vis); // color ignored (using grayscale) return; } if (vis == tvSquish) { - int x1, x2; - getItemX(geneBed->chromStart, geneBed->chromEnd, &x1, &x2); - Color color = gtexGeneItemColor(tg, geneBed, hvg); - int height = gtexSquishItemHeight(); - hvGfxBox(hvg, x1, y, x2-x1, height, color); + drawGeneExprBox(tg, geneBed, hvg, y); return; } int graphX = gtexGraphX(geneBed); if (graphX < 0) return; // draw gene model 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 heightPer = tg->heightPer; tg->heightPer = gtexGeneModelHeight(extras) + 1; +Color statusColor = getGeneClassColor(hvg, geneBed); if (geneInfo->geneModel && extras->showExons) { struct linkedFeatures *lf = linkedFeaturesFromGenePred(tg, geneInfo->geneModel, FALSE); lf->filterColor = statusColor; linkedFeaturesDrawAt(tg, lf, hvg, xOff, yGene, scale, font, color, gtexGeneModelVis(extras)); } else { - tg->exonArrows = FALSE; - tg->colorShades = FALSE; - bedDrawSimpleAt(tg, geneBed, hvg, xOff, yGene+2, scale, font, statusColor, tvSquish); + drawGeneModelBox(tg, geneBed, hvg, yGene+2, statusColor); } tg->heightPer = heightPer; } static int gtexGeneNonPropPixelWidth(struct track *tg, void *item) /* Return end chromosome coordinate of item, including graph */ { struct gtexGeneInfo *geneInfo = (struct gtexGeneInfo *)item; int graphWidth = gtexGraphWidth(tg, geneInfo); return graphWidth; } static void gtexGeneNonPropDrawAt(struct track *tg, void *item, struct hvGfx *hvg, int xOff, int y, double scale, MgFont *font, Color color, enum trackVisibility vis) { @@ -795,64 +827,68 @@ int height = valToClippedHeight(expScore, maxMedian, viewMax, gtexMaxGraphHeight(), extras->doLogTransform); if (graphPadding == 0 || sameString(colorScheme, GTEX_COLORS_GTEX)) hvGfxBox(hvg, x1, yZero, barWidth, height, fillColorIx); else hvGfxOutlinedBox(hvg, x1, yZero, barWidth, height, fillColorIx, lineColorIx); // mark clipped bar with magenta tip if (!extras->doLogTransform && expScore > viewMax) hvGfxBox(hvg, x1, yZero + height-1, barWidth, 2, clipColor); x1 = x1 + barWidth + graphPadding; } } static int gtexGeneItemHeightOptionalMax(struct track *tg, void *item, boolean isMax) { +int height; if (tg->visibility == tvSquish || tg->visibility == tvDense) { if (tg->visibility == tvSquish) { tg->lineHeight = gtexSquishItemHeight(); tg->heightPer = tg->lineHeight; } - int height = tgFixedItemHeight(tg, item); + height = tgFixedItemHeight(tg, item); return height; } struct gtexGeneExtras *extras = (struct gtexGeneExtras *)tg->extraUiData; if (isMax) { int extra = 0; if (((struct gtexGeneExtras *)tg->extraUiData)->isComparison) extra = gtexMaxGraphHeight() + 2; - return gtexMaxGraphHeight() + gtexGeneMargin() + gtexGeneModelHeight(extras) + extra; + height= gtexMaxGraphHeight() + gtexGeneMargin() + gtexGeneModelHeight(extras) + extra; + return height; } if (item == NULL) return 0; struct gtexGeneInfo *geneInfo = (struct gtexGeneInfo *)item; if (geneInfo->height != 0) + { return geneInfo->height; + } int topGraphHeight = gtexGeneGraphHeight(tg, geneInfo, TRUE); topGraphHeight = max(topGraphHeight, tl.fontHeight); int bottomGraphHeight = 0; boolean isComparison = ((struct gtexGeneExtras *)tg->extraUiData)->isComparison; if (isComparison) { bottomGraphHeight = max(gtexGeneGraphHeight(tg, geneInfo, FALSE), tl.fontHeight) + gtexGeneMargin(); } -int height = topGraphHeight + bottomGraphHeight + gtexGeneMargin() + +height = topGraphHeight + bottomGraphHeight + gtexGeneMargin() + gtexGeneModelHeight(extras); return height; } static int gtexGeneMaxHeight(struct track *tg) /* Maximum height in pixels of a gene graph */ { return gtexGeneItemHeightOptionalMax(tg, NULL, TRUE); } static int gtexGeneItemHeight(struct track *tg, void *item) { int height = gtexGeneItemHeightOptionalMax(tg, item, FALSE); return height; }