Skip to content

Commit

Permalink
Add example of select-region event
Browse files Browse the repository at this point in the history
  • Loading branch information
haxiomic committed Mar 11, 2020
1 parent e0f5475 commit 2bc9020
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 16 deletions.
8 changes: 4 additions & 4 deletions examples/bigbed/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,28 @@
{
name: 'bigBed',
type: 'annotation',
path: './example-files/wgEncodeDukeAffyExon8988tSimpleSignalRep1V2.bigBed',
path: '../example-files/wgEncodeDukeAffyExon8988tSimpleSignalRep1V2.bigBed',
},
/**
{
name: 'NarrowPeak',
type: 'annotation',
path: './example-files/narrowpeak.bigBed',
path: '../example-files/narrowpeak.bigBed',
heightPx: 60,
},
/**/
/**
{
name: 'BroadPeak',
type: 'annotation',
path: './example-files/broadpeak.bigBed',
path: '../example-files/broadpeak.bigBed',
heightPx: 60,
},
/**
{
name: 'IDR Peaks',
type: 'annotation',
path: './example-files/GSE105392_ENCFF119SYV_optimal_idr_thresholded_peaks_hg19.bigBed',
path: '../example-files/GSE105392_ENCFF119SYV_optimal_idr_thresholded_peaks_hg19.bigBed',
heightPx: 60,
},
/**/
Expand Down
46 changes: 34 additions & 12 deletions examples/clickable-annotations/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@
</head>
<body>
<div id="container"></div>

<div class="log-container">
<div id="log">
<div class="entry" style="text-align: center; color: grey">Click on annotations</div>
</div>
</div>

<script src="../../dist/valis-hpgv.js"></script>

Expand All @@ -77,11 +83,21 @@
x1: 89274809,
}
}],
tracks: []
tracks: [
{
name: 'bigBed',
type: 'annotation',
path: '../example-files/wgEncodeDukeAffyExon8988tSimpleSignalRep1V2.bigBed',
},
]
});
visualizer.setDataSource('https://s3-us-west-1.amazonaws.com/valis-file-storage/genome-data/GRCh38.vdna-dir/manifest.json');
visualizer.addTrackFromFilePath('https://s3-us-west-1.amazonaws.com/valis-file-storage/genome-data/GRCh38.vdna-dir', 'DNA', false);
visualizer.addTrackFromFilePath('https://s3-us-west-1.amazonaws.com/valis-file-storage/genome-data/GRCh38.92.vgenes-dir', 'Annotation', false);

// this server is no longer active:
// visualizer.setDataSource('https://s3-us-west-1.amazonaws.com/valis-file-storage/genome-data/GRCh38.vdna-dir/manifest.json');
// visualizer.addTrackFromFilePath('https://s3-us-west-1.amazonaws.com/valis-file-storage/genome-data/GRCh38.vdna-dir', 'DNA', false);
// visualizer.addTrackFromFilePath('https://s3-us-west-1.amazonaws.com/valis-file-storage/genome-data/GRCh38.92.vgenes-dir', 'Annotation', false);

let logElement = document.querySelector('#log');

visualizer.addEventListener('annotation-clicked', (e) => {
// e.type is the event type string, in this case it is 'annotation-clicked'
Expand All @@ -97,8 +113,6 @@

console.log('Annotation clicked event', e, 'feature:', feature, 'in gene', gene);

let logElement = document.querySelector('#log');

let logHTML = `
<div class="entry">
<span class="arg component">${feature.soClass}</span>
Expand All @@ -111,16 +125,24 @@
logElement.innerHTML = logHTML + logElement.innerHTML;
});

visualizer.addEventListener('select-region', (e) => {
console.log('select-region', e);

e.preventDefault(); // prevent default zoom-in behavior

let logHTML = `
<div class="entry">
Select Region: <span class="arg component">${e.x0} - ${e.x1}</span>
</div>
`;

logElement.innerHTML = logHTML + logElement.innerHTML;
});

let container = document.getElementById('container');

visualizer.render({ width: 800, height: 250 }, container);
</script>

<div class="log-container">
<div id="log">
<div class="entry" style="text-align: center; color: grey">Click on annotations</div>
</div>
</div>

</body>
</html>
File renamed without changes.
File renamed without changes.

0 comments on commit 2bc9020

Please sign in to comment.