Skip to content

Commit

Permalink
Make read cloud specific options into separate track menu
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Nov 27, 2018
1 parent 72f66e4 commit 718465c
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 26 deletions.
9 changes: 5 additions & 4 deletions src/JBrowse/View/Dialog/SetTrackHeight.js
Expand Up @@ -2,7 +2,7 @@ define([
'dojo/_base/declare',
'dojo/dom-construct',
'dijit/focus',
'dijit/form/NumberSpinner',
'dijit/form/NumberSpinner',
'JBrowse/View/Dialog/WithActionBar',
'dojo/on',
'dijit/form/Button',
Expand All @@ -14,7 +14,7 @@ define([
return declare( ActionBarDialog, {
/**
* Dijit Dialog subclass that pops up prompt for the user to
* manually set a new highlight.
* manually set a new track height.
* @lends JBrowse.View.InfoDialog
*/
title: 'Set new track height',
Expand All @@ -24,7 +24,8 @@ return declare( ActionBarDialog, {
this.browser = args.browser;
this.setCallback = args.setCallback || function() {};
this.cancelCallback = args.cancelCallback || function() {};
this.heightConstraints = { min: 10, max: 750 };
this.heightConstraints = { min: 10, max: args.maxHeight||750 };
this.msg = args.msg
},

_fillActionBar: function( actionBar ) {
Expand Down Expand Up @@ -60,7 +61,7 @@ return declare( ActionBarDialog, {
this.set('content', [
dom.create('label', { "for": 'newhighlight_locstring', innerHTML: '' } ),
this.heightSpinner.domNode,
dom.create( 'span', { innerHTML: ' pixels' } )
dom.create( 'span', { innerHTML: this.msg||' pixels' } )
] );

this.inherited( arguments );
Expand Down
11 changes: 6 additions & 5 deletions src/JBrowse/View/FeatureGlyph/PairedReadCloud.js
Expand Up @@ -21,18 +21,19 @@ layoutFeature(viewArgs, layout, feature) {
if (feature.pairedFeature()) {
const tlen = Math.abs(feature.read1.get('template_length'))

// log view uses maximum to handle very large, linear uses upper percentile

let k
if(this.track.config.readCloudLogScale) {
// max is set to upper percentile because it can handle things above this value
k = Math.log(tlen + 1) / Math.log(this.track.insertSizeStats.max + 1)
k = Math.log(tlen + 1) / Math.log(this.track.config.readCloudYScaleMax || this.track.insertSizeStats.max + 1)
k /= 2 // squish by 2 means theres space above the maxHeight for things larger than the estimated insert size stats/readcloud max
} else {
// max set to literal max or a configurable insertSizeMax
k = tlen / (this.track.config.insertSizeMax || this.track.insertSizeStats.upper)
// max set to literal max or a configurable readCloudYScaleMax
k = tlen / (this.track.config.readCloudYScaleMax || this.track.insertSizeStats.upper)
k /= 3 // squish by 3 means theres space above the maxHeight for things larger than the estimated insert size stats, higher for linear
}

k *= this.track.config.maxHeight
k /= 3

// use compact view for additional linear compression
if(this.track.config.displayMode === 'compact') {
Expand Down
59 changes: 42 additions & 17 deletions src/JBrowse/View/Track/Alignments2.js
Expand Up @@ -2,6 +2,7 @@ define( [
'dojo/_base/declare',
'dojo/_base/array',
'dijit/MenuItem',
'JBrowse/View/Dialog/SetTrackHeight',
'JBrowse/Util',
'JBrowse/View/Track/CanvasFeatures',
'JBrowse/View/Track/_AlignmentsMixin'
Expand All @@ -10,6 +11,7 @@ define( [
declare,
array,
MenuItem,
Dialog,
Util,
CanvasFeatureTrack,
AlignmentsMixin
Expand Down Expand Up @@ -212,24 +214,47 @@ return declare( [ CanvasFeatureTrack, AlignmentsMixin ], {
thisB.browser.publish('/jbrowse/v1/v/tracks/replace', [thisB.config]);
}
});
c.children.push({
label: 'Show interchromosomal',
type: 'dijit/CheckedMenuItem',
checked: !!this.config.showInterchromosomalArcs,
onClick: function(event) {
thisB.config.showInterchromosomalArcs = this.get('checked');
thisB.browser.publish('/jbrowse/v1/v/tracks/replace', [thisB.config]);
}
});
c.children.push({
label: 'View read cloud log scale',
type: 'dijit/CheckedMenuItem',
checked: !!this.config.readCloudLogScale,
onClick: function(event) {
thisB.config.readCloudLogScale = this.get('checked');
thisB.browser.publish('/jbrowse/v1/v/tracks/replace', [thisB.config]);
if(this.config.glyph == 'JBrowse/View/FeatureGlyph/PairedReadCloud') {
var r = {
type: 'dijit/Menu',
label: 'Read cloud options',
children: []
}
});
r.children.push({
label: 'Show interchromosomal',
type: 'dijit/CheckedMenuItem',
checked: !!this.config.showInterchromosomalArcs,
onClick: function(event) {
thisB.config.showInterchromosomalArcs = this.get('checked');
thisB.browser.publish('/jbrowse/v1/v/tracks/replace', [thisB.config]);
}
});
r.children.push({
label: 'View read cloud log scale',
type: 'dijit/CheckedMenuItem',
checked: !!this.config.readCloudLogScale,
onClick: function(event) {
thisB.config.readCloudLogScale = this.get('checked');
thisB.browser.publish('/jbrowse/v1/v/tracks/replace', [thisB.config]);
}
});
r.children.push({
label: 'Set read cloud Y-scale insert size',
onClick: function(event) {
new Dialog({
title: 'Set read cloud Y-scale in terms of the maximum expected insert size',
msg: ' insert size (note: default estimated from sampling track data)',
maxHeight: Infinity,
height: thisB.config.readCloudYScaleMax || 50000,
setCallback: ret => {
thisB.config.readCloudYScaleMax = ret
thisB.browser.publish('/jbrowse/v1/v/tracks/replace', [thisB.config]);
}
}).show()
}
});
displayOptions.push(r)
}
return Promise.all([ this.inherited(arguments), this._alignmentsFilterTrackMenuOptions(), displayOptions ])
.then( function( options ) {
var o = options.shift();
Expand Down

0 comments on commit 718465c

Please sign in to comment.