68d7b2a05006852f9c3b3d0e2b2950bd9e28856e kate Tue Sep 26 09:25:29 2017 -0700 Change effect size color conventions, input from JK. refs #15646 diff --git src/hg/hgTracks/gtexEqtlClusterTrack.c src/hg/hgTracks/gtexEqtlClusterTrack.c index beb5c2d..73d1f03 100644 --- src/hg/hgTracks/gtexEqtlClusterTrack.c +++ src/hg/hgTracks/gtexEqtlClusterTrack.c @@ -193,56 +193,72 @@ { isFiltered = TRUE; filterItems(track, eqtlIncludeFilter, "include"); } if (isFiltered) labelTrackAsFiltered(track); } static char *gtexEqtlClusterItemName(struct track *track, void *item) /* Left label is gene name */ { struct gtexEqtlCluster *eqtl = (struct gtexEqtlCluster *)item; return eqtl->target; } +// blues +#define EQTL_COLOR_HIGH_NEGATIVE MAKECOLOR_32(0x0, 0x0, 0xff) +#define EQTL_COLOR_LOW_NEGATIVE MAKECOLOR_32(0xa0, 0xa0, 0xff) +// reds +#define EQTL_COLOR_HIGH_POSITIVE MAKECOLOR_32(0xff, 0x0, 0x0) +#define EQTL_COLOR_LOW_POSITIVE MAKECOLOR_32(0xff, 0xa0, 0xa0) +// gray +#define EQTL_COLOR_MIXED MAKECOLOR_32(0x69, 0x69, 0x69) + static Color gtexEqtlClusterItemColor(struct track *track, void *item, struct hvGfx *hvg) -/* Color by highest effect in list (blue -, red +), with brighter for higher effect (teal, fuschia) */ +/* Color by highest effect in list (blue -, red +), grayed for lower effect. Gray if mixed effect*/ { struct gtexEqtlCluster *eqtl = (struct gtexEqtlCluster *)item; double maxEffect = 0.0; +double minEffect = 0.0; int i; for (i=0; iexpCount; i++) { if (eqtlIsExcludedTissue(eqtl, i)) continue; double effect = eqtl->expScores[i]; - if (fabs(effect) > fabs(maxEffect)) + if (effect > maxEffect) maxEffect = effect; + else if (effect < minEffect) + minEffect = effect; } +if (minEffect < 0.0 && maxEffect > 0.0) + // mixed effect + return EQTL_COLOR_MIXED; + double cutoff = 2.0; -if (maxEffect < 0.0) +if (minEffect < 0.0) { - /* down-regulation displayed as blue */ - if (maxEffect < 0.0 - cutoff) - return MG_CYAN; - return MG_BLUE; + // down-regulation displayed as blue + if (minEffect < 0.0 - cutoff) + return EQTL_COLOR_HIGH_NEGATIVE; + return EQTL_COLOR_LOW_NEGATIVE; } -/* up-regulation displayed as red */ +// up-regulation displayed as red if (maxEffect > cutoff) - return MG_MAGENTA; -return MG_RED; + return EQTL_COLOR_HIGH_POSITIVE; +return EQTL_COLOR_LOW_POSITIVE; } /* Helper macros */ #define tissueColorPatchSpacer (max(2, tl.nWidth/4)) #define tissueColorPatchWidth (tl.nWidth * .8) 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 += tissueColorPatchWidth + tissueColorPatchSpacer; return ret; @@ -273,48 +289,40 @@ struct rgbColor tisColor = eqtlTissueColor(track, eqtl); int ix = hvGfxFindColorIx(hvg, tisColor.r, tisColor.g, tisColor.b); hvGfxBox(hvg, x + tissueColorPatchSpacer, y + (tl.fontHeight - h)/2 + tl.fontHeight/10, 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; struct dyString *ds = dyStringNew(0); dyStringPrintf(ds, "%s/%s: ", eqtl->name, eqtl->target); int i; for (i=0; iexpCount; i++) { if (eqtlIsExcludedTissue(eqtl, i)) continue; double effect= eqtl->expScores[i]; dyStringPrintf(ds, "%s(%s%0.2f)%s", eqtl->expNames[i], effect < 0 ? "" : "+", effect, i < eqtl->expCount - 1 ? ", " : ""); - //struct gtexTissue *tis = (struct gtexTissue *)hashFindVal(tissueHash, eqtl->expNames[i]); - //unsigned color = tis ? tis->color : 0; // BLACK - //char *name = tis ? tis->name : "unknown"; - //#dyStringPrintf(ds,"*%s%s%0.2f\n", - //color, name, effect < 0 ? "" : "+", effect); } title = dyStringCannibalize(&ds); } int w = width + gtexEqtlClusterItemRightPixels(track, item); genericMapItem(track, hvg, item, title, itemName, start, end, x, y, w, height); } void gtexEqtlClusterMethods(struct track *track) /* BED5+5 with target, expNames,expScores, expProbs */ { track->loadItems = gtexEqtlClusterLoadItems; track->itemName = gtexEqtlClusterItemName; track->itemColor = gtexEqtlClusterItemColor; track->itemRightPixels = gtexEqtlClusterItemRightPixels; track->drawItemAt = gtexEqtlClusterDrawItemAt;