7d70cdf40567dbcfd3a190c844d99046aced5637 kate Thu Apr 9 13:58:39 2020 -0700 Add settings to define window sizes for small/medium/large graphs. Useful for small (e.g. virus) genomes. Prompted by Max barCharts on wuhCor1. refs #25339 diff --git src/hg/hgTracks/barChartTrack.c src/hg/hgTracks/barChartTrack.c index 88e249a..56a4913 100644 --- src/hg/hgTracks/barChartTrack.c +++ src/hg/hgTracks/barChartTrack.c @@ -23,30 +23,33 @@ boolean noWhiteout; /* Suppress whiteout of graph background (allow highlight, blue lines) */ double maxMedian; /* Maximum median across all categories */ boolean doLogTransform; /* Log10(x+1) */ char *unit; /* Units for category values (e.g. RPKM) */ struct barChartCategory *categories; /* Category names, colors, etc. */ int categCount; /* Count of categories - derived from above */ char **categNames; /* Category names - derived from above */ char **categLabels; /* Category labels - derived from above */ struct rgbColor *colors; /* Colors for all categories */ struct hash *categoryFilter; /* NULL out excluded factors */ int maxViewLimit; // dimensions for drawing char *maxGraphSize; /* optionally limit graph size (override semantic zoom) small, medium, or large (default) */ + int winMaxGraph; /* Draw large graphs if window size smaller than this */ + int winMedGraph; /* Draw medium graphs if window size greater than this + and smaller than winMaxGraph */ int squishHeight; /* Height of item in squish mode (larger than typical) */ int boxModelHeight; /* Height of indicator box drawn under graph to show gene extent */ int modelHeight; /* Height of box drawn under graph with padding */ int barWidth; /* Width of individual bar in pixels */ int margin; int padding; int maxHeight; }; struct barChartItem /* BED item plus computed values for display */ { struct barChartItem *next; /* Next in singly linked list */ struct bed *bed; /* Item coords, name, exp count and values */ @@ -332,60 +335,65 @@ extras->colors = getCategoryColors(tg); struct trackDb *tdb = tg->tdb; extras->doLogTransform = cartUsualBooleanClosestToHome(cart, tdb, FALSE, BAR_CHART_LOG_TRANSFORM, BAR_CHART_LOG_TRANSFORM_DEFAULT); extras->maxMedian = barChartUiMaxMedianScore(tdb); extras->noWhiteout = cartUsualBooleanClosestToHome(cart, tdb, FALSE, BAR_CHART_NO_WHITEOUT, BAR_CHART_NO_WHITEOUT_DEFAULT); extras->maxViewLimit = (double)cartUsualIntClosestToHome(cart, tg->tdb, FALSE, BAR_CHART_MAX_VIEW_LIMIT, BAR_CHART_MAX_VIEW_LIMIT_DEFAULT); extras->maxGraphSize = trackDbSettingClosestToHomeOrDefault(tdb, BAR_CHART_MAX_GRAPH_SIZE, BAR_CHART_MAX_GRAPH_SIZE_DEFAULT); extras->unit = trackDbSettingClosestToHomeOrDefault(tdb, BAR_CHART_UNIT, ""); /* Set barchart dimensions to draw. For three window sizes */ -#define WIN_MAX_GRAPH 50000 -#define WIN_MED_GRAPH 500000 #define MAX_BAR_CHART_MODEL_HEIGHT 2 #define MED_BAR_CHART_MODEL_HEIGHT 2 #define MIN_BAR_CHART_MODEL_HEIGHT 1 -#define WIN_MAX_GRAPH 50000 +#define WIN_MAX_GRAPH_DEFAULT 50000 #define MAX_GRAPH_HEIGHT 175 #define MAX_BAR_WIDTH 5 #define MAX_GRAPH_PADDING 2 -#define WIN_MED_GRAPH 500000 +#define WIN_MED_GRAPH_DEFAULT 500000 #define MED_GRAPH_HEIGHT 100 #define MED_BAR_WIDTH 3 #define MED_GRAPH_PADDING 1 #define MIN_BAR_WIDTH 1 #define MIN_GRAPH_PADDING 0 +char *setting = trackDbSetting(tdb, BAR_CHART_WIN_MAX_GRAPH); +extras->winMaxGraph = isNotEmpty(setting) ? atoi(setting) : WIN_MAX_GRAPH_DEFAULT; +setting = trackDbSetting(tdb, BAR_CHART_WIN_MED_GRAPH); +extras->winMedGraph = isNotEmpty(setting) ? atoi(setting) : WIN_MED_GRAPH_DEFAULT; + int scale = (getCategoryCount(tg) < 15 ? 2 : 1); long winSize = virtWinBaseCount; -if (winSize < WIN_MAX_GRAPH && sameString(extras->maxGraphSize, BAR_CHART_MAX_GRAPH_SIZE_LARGE)) +if (winSize < extras->winMaxGraph && + sameString(extras->maxGraphSize, BAR_CHART_MAX_GRAPH_SIZE_LARGE)) { extras->boxModelHeight = MAX_BAR_CHART_MODEL_HEIGHT; extras->barWidth = MAX_BAR_WIDTH * scale; extras->padding = MAX_GRAPH_PADDING; extras->maxHeight = MAX_GRAPH_HEIGHT; } -else if (winSize < WIN_MED_GRAPH && differentString(extras->maxGraphSize, BAR_CHART_MAX_GRAPH_SIZE_SMALL)) +else if (winSize < extras->winMedGraph && + differentString(extras->maxGraphSize, BAR_CHART_MAX_GRAPH_SIZE_SMALL)) { extras->boxModelHeight = MED_BAR_CHART_MODEL_HEIGHT; extras->barWidth = MED_BAR_WIDTH * scale; extras->padding = MED_GRAPH_PADDING; extras->maxHeight = MED_GRAPH_HEIGHT; } else { extras->boxModelHeight = MIN_BAR_CHART_MODEL_HEIGHT; extras->barWidth = MIN_BAR_WIDTH * scale; extras->padding = MIN_GRAPH_PADDING; extras->maxHeight = tl.fontHeight * 4; } extras->modelHeight = extras->boxModelHeight + 3; extras->margin = 1;