8a8d56bd2f8702698393727cbb7a480d73a413ea Merge parents 01604ed a7ba9fb kate Thu Mar 31 18:57:11 2016 -0700 Merge branch 'master' into gtexUiExon diff --cc src/hg/hgTracks/gtexTracks.c index beda624,5aa95c3..5550852 --- src/hg/hgTracks/gtexTracks.c +++ src/hg/hgTracks/gtexTracks.c @@@ -458,55 -461,52 +464,56 @@@ #define MAX_GRAPH_HEIGHT 175 #define MAX_BAR_WIDTH 5 #define MAX_GRAPH_PADDING 2 #define WIN_MED_GRAPH 500000 #define MED_GRAPH_HEIGHT 100 #define MED_BAR_WIDTH 3 #define MED_GRAPH_PADDING 1 #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; } 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; 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 @@@ -595,83 -595,99 +602,104 @@@ 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); + 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 */ + { + 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 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) + if (vis == tvDense) { bedDrawSimpleAt(tg, geneBed, hvg, xOff, y, scale, font, statusColor, vis); 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); + return; + } -int heightPer = tg->heightPer; 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; -if (geneInfo->geneModel) // some BEDs do not have a corresponding geneModel record +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)); + 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); } 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) {