Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Working multiple diagonal heatmaps
  • Loading branch information
pkerpedjiev committed Aug 10, 2016
1 parent 5413871 commit ca6a0ac
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .tern-project
Expand Up @@ -2,7 +2,7 @@
"ecmaVersion": 6,
"libs": [
"d3",
"jquery",
"jquery"
],
"loadEagerly": [
"app/scripts/*.js"
Expand Down
5 changes: 1 addition & 4 deletions app/scripts/MultiTrackContainer.jsx
Expand Up @@ -15,7 +15,6 @@ import {AddTrackDiv} from './AddTrackDiv.js'
import {TopGeneLabelsTrack} from './TopGeneLabelsTrack.js'
import {TopChromosomeAxis} from './TopChromosomeAxis.js'
import {LeftChromosomeAxis} from './LeftChromosomeAxis.js'
import {Pool} from 'threads';

export class MultiTrackContainer extends React.Component {
constructor(props) {
Expand All @@ -32,6 +31,7 @@ export class MultiTrackContainer extends React.Component {
{source: this.awsDomain + '/hg19.1/mm9.NCAPH2.1kb.cool.reduced.genome.gz', uid: slugid.nice(), type: 'top-diagonal-heatmap', height: 100},
{source: this.awsDomain + '/hg19.1/mm9.UNTR.1kb.cool.reduced.genome.gz', uid: slugid.nice(), type: 'top-diagonal-heatmap', height: 100},
{source: this.awsDomain + '/hg19.1/mm9.TAM.1kb.cool.reduced.genome.gz', uid: slugid.nice(), type: 'top-diagonal-heatmap', height: 100},
{source: this.awsDomain + '/hg19.1/mm9.NIPBL.1kb.cool.reduced.genome.gz', uid: slugid.nice(), type: 'top-diagonal-heatmap', height: 100},
//{source: this.awsDomain + '/hg19.1/Rao2014-GM12878-MboI-allreps-filtered.1kb.cool.reduced.genome.gz', uid: slugid.nice(), type: 'heatmap', height: 200},
{source: '//s3.amazonaws.com/pkerp/data/hg19/chromInfo.txt', uid: slugid.nice(), type: 'top-chromosome-axis', height: 35},
//{source: '//s3.amazonaws.com/pkerp/data/hg19/chromInfo.txt', uid: slugid.nice(), type: 'left-chromosome-axis', width: 35},
Expand Down Expand Up @@ -333,14 +333,11 @@ export class MultiTrackContainer extends React.Component {
.resizeDispatch(this.resizeDispatch)
.zoomDispatch(this.zoomDispatch);

let threadPool = new Pool();
console.log('threadPool:', threadPool);
let diagonalHeatmapTrack = TopDiagonalHeatmapRectangleTrack()
.xScale(this.xScale.copy())
.yScale(this.yScale.copy())
.width(this.state.width)
.height(this.state.height)
.threadPool(threadPool)
.pixiStage(this.stage)
.resizeDispatch(this.resizeDispatch)
.zoomDispatch(this.zoomDispatch);
Expand Down
13 changes: 10 additions & 3 deletions app/scripts/TopDiagonalHeatmapTrack.js
Expand Up @@ -3,6 +3,7 @@ import PIXI from 'pixi.js';
import slugid from 'slugid';
import d3 from 'd3';
import {workerProcess2DTile} from './worker.js';
import {WorkerPool} from './WorkerPool.js';

export function TopDiagonalHeatmapRectangleTrack() {
let width = 200;
Expand All @@ -23,14 +24,17 @@ export function TopDiagonalHeatmapRectangleTrack() {
.range([255,0]);
let threadPool = null;

let tileDataLoaded = function() {};
let workerPool = new WorkerPool('scripts/worker.js', 2);

/*
let worker = new Worker('scripts/worker.js');
worker.postMessage = worker.webkitPostMessage || worker.postMessage;
worker.addEventListener('message', function(e) {
//should only ever receive a message in the event that workerSetPix completed;
tileDataLoaded(e.data.shownTileId, e.data.tile, e.data.pixData)
}, false);
*/

function tileId(tile) {
// uniquely identify the tile with a string
Expand Down Expand Up @@ -222,7 +226,7 @@ export function TopDiagonalHeatmapRectangleTrack() {

}

tileDataLoaded = function(shownTileId, tile, pixData) {
function tileDataLoaded(shownTileId, tile, pixData) {
let canvas = tileDataToCanvas(pixData, minVisibleValue, maxVisibleValue);

delete d.rendering[shownTileId];
Expand Down Expand Up @@ -295,7 +299,10 @@ export function TopDiagonalHeatmapRectangleTrack() {
'yOrigDomain': tiles[i].yOrigScale.domain(),
'yOrigRange': tiles[i].yOrigScale.range() },
minVisibleValue: minVisibleValue, maxVisibleValue: maxVisibleValue}
worker.postMessage(workerObj, [workerObj.tile.data]);
//worker.postMessage(workerObj, [workerObj.tile.data]);
workerPool.submitMessage(workerObj, [workerObj.tile.data], function(e) {
tileDataLoaded(e.data.shownTileId, e.data.tile, e.data.pixData);
})
} else {

}
Expand Down

0 comments on commit ca6a0ac

Please sign in to comment.