Skip to content

Commit

Permalink
make Wiggle/XYPlot variance_band conf accept an array of band locat…
Browse files Browse the repository at this point in the history
…ions, references #133
  • Loading branch information
rbuels committed Feb 20, 2013
1 parent bbd156d commit e2cdb7b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
6 changes: 5 additions & 1 deletion release-notes.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{{$NEXT}}

* Wiggle/XYPlot tracks now accept an array for their `variance_band`
argument, allowing users to set the position of the variance bands
to show (issue #133).

* Added support `autoscale: "local"` in Wiggle, FeatureCoverage, and
SNPCoverage tracks, which automatically sets the scale of the
y-axis based on the range of the data being displayed in the
current view.
current view (issue #203).

* Added an "About JBrowse" popup dialog, which supports an
`aboutThisBrowser` configuration stanza containing a title for the
Expand Down
18 changes: 16 additions & 2 deletions src/JBrowse/View/Track/Wiggle/XYPlot.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ var XYPlot = declare( [WiggleBase, YScaleMixin],

// draw the variance_band if requested
if( this.config.variance_band ) {
var bandPositions =
typeof this.config.variance_band == 'object'
? array.map( this.config.variance_band, function(v) { return parseFloat(v); } ).sort().reverse()
: [ 2, 1 ];
this.getGlobalStats( dojo.hitch( this, function( stats ) {
if( ('scoreMean' in stats) && ('scoreStdDev' in stats) ) {
var drawVarianceBand = function( plusminus, fill, label ) {
Expand All @@ -154,8 +158,18 @@ var XYPlot = declare( [WiggleBase, YScaleMixin],
context.fillText( label, 2, varTop );
}
};
drawVarianceBand( 2*stats.scoreStdDev, 'rgba(0,0,0,0.12)', '2σ' );
drawVarianceBand( stats.scoreStdDev, 'rgba(0,0,0,0.25)', '1σ' );

var minOpacity = 0.12;
var maxOpacity = 0.3;
var bandOpacityStep = 0;
if( bandPositions.length > 1 )
bandOpacityStep = (maxOpacity-minOpacity)/(bandPositions.length-1);
else
minOpacity = maxOpacity;

array.forEach( bandPositions, function( pos,i ) {
drawVarianceBand( pos*stats.scoreStdDev, 'rgba(0,0,0,'+(minOpacity+bandOpacityStep*i)+')', pos+'σ');
});
drawVarianceBand( 0, 'rgba(255,255,0,0.7)', 'mean' );
}
}));
Expand Down

0 comments on commit e2cdb7b

Please sign in to comment.