Grayscale
Items in custom tracks submitted in BED format that include a score column can optionally be shaded with a grayscale by setting the track line attribute useScore=1. Sometimes the brightest or the darkest colors in the grayscale appear to be pretty much the same color. If you want to exclude some of the shades from the grayscale, you can do it by transforming the scores in the BED file. A sample transformation is below.
Conversion source code
This is the Genome Browser code that transforms a bed score, original range and max shade array index into a shade index for display:
int hGrayInRange(int oldVal, int oldMin, int oldMax, int newMax) /* Return oldVal, which lies between oldMin and oldMax, to * equivalent number between 1 and newMax. The way this does it * is perhaps a little odd, forcing 0 go to 1, but visually it works * out nicely when 0 is white. */ { int range = oldMax - oldMin; int newVal = ((oldVal-oldMin)*newMax + (range>>1))/range; if (newVal <= 0) newVal = 1; if (newVal > newMax) newVal = newMax; return newVal; }
Substituting 9 for newMax (max shade index), 0 for oldMin and 1000 for oldMax, this is the formula:
shade = trunc( (bedScore*9 + 500) / 1000 ) clip shade to [1,9] ("trunc" = round down to int by truncating the stuff after the decimal point)
Sample Transform
Use this formula on BED scores to convert them to numbers within a particular range so that only some of the shades are used:
bedScore = ((myScore - minMyScore) * (maxBedScore - minBedScore) / (maxMyScore - minMyScore)) + minBedScore
For example, to transform scores of 1 to 10 into BED scores for the six darkest shades of gray, do this:
bedScore = ((myScore - 1) * (1000 - 389) / (10 - 1)) + 389
389 is the lowest BED score for the desired lightest shade, 1000 is the top of the BED score range (assuming darkest desired shade is black), 1 is the lowest myScore (at least that you want to make sure is visible) and 10 is the max myScore (or big enough so that you want to max out the shade at myScore=10).