Skip to content

Instantly share code, notes, and snippets.

@cmdcolin
Last active December 17, 2015 19:34
Show Gist options
  • Save cmdcolin/c7bc2155ea74464ecc46 to your computer and use it in GitHub Desktop.
Save cmdcolin/c7bc2155ea74464ecc46 to your computer and use it in GitHub Desktop.
<html>
<head>
<title>JBrowse feature rendering outside of browser</title>
<link rel="stylesheet" type="text/css" href="css/genome.css">
<script type="text/javascript" src="src/dojo/dojo.js" data-dojo-config="async: 1, baseUrl: './src'"></script>
<script type="text/javascript" src="src/JBrowse/init.js"></script>
<script>
require([
'dojo/cookie',
'dojo/_base/window',
'dojo/_base/array',
'dojo/dom',
'dojo/dom-construct',
'JBrowse/Browser',
'JBrowse/View/Track/Wiggle/XYPlot',
'JBrowse/Store/SeqFeature/BigWig',
'JBrowse/View/GranularRectLayout',
'JBrowse/Store/Sequence/StaticChunked'
],
function (
cookie,
win,
array,
dom,
domConstruct,
Browser,
BigWigTrack,
BigWigStore,
Layout,
StaticChunkedSequence
) {
var trackConfig = {
"urlTemplate" : "http://genomes.missouri.edu/bam/BoneDensityLumbarSpine.bfs.hg38-lifted.bed.bw",
"type" : "JBrowse/View/Track/Wiggle/XYPlot",
"label" : "BoneDensityGWAS",
"scoreType" : "maxScore"
};
var browser=new Browser({unitTestMode: true});
var mmin=0;
var mmax=100000000;
browser.view = {
minVisible: function() { return mmin; },
maxVisible: function() { return mmax; }
};
var store = new BigWigStore({ browser: browser, urlTemplate: trackConfig.urlTemplate });
var renderBlock=function(name,id,store,i,length) {
domConstruct.create('div', {
id: id,
style: {
position: "absolute",
width: "3%",
left: i*3.1+"%",
border: "1px solid black"
}
}, win.body());
domConstruct.create('div', {
id: id+'label',
style: {
position: "absolute",
width: "3%",
left: i*3.1+"%"
},
innerHTML: name
}, win.body());
var block={};
block.featureLayout = new Layout(0, length);
block.featureNodes = new Array();
block.startBase = mmin;
block.scale = 50/length;
block.endBase = length;
block.domNode=dom.byId(id);
trackConfig.style={'pos_color':'hsl('+i*20+',50%,50%)'};
var track = new BigWigTrack({
config: trackConfig,
browser: browser,
store: store
});
track.blocks=[block];
track.refSeq={"name":name};
track.label=dom.byId("label");
track.heightUpdateCallback = (function() { "update height" });
track.blockHeights=[100];
track.filterFeature=(function() { return true; });
track.fillBlock({
blockIndex: 0,
block: block,
scale: block.scale,
leftBase: 0,
rightBase: length
});
}
var chroms=[{"length":248956422,"name":"chr1","seqChunkSize":20000,"end":248956422,"start":0},{"length":242193529,"name":"chr2","start":0,"end":242193529,"seqChunkSize":20000},{"length":198295559,"name":"chr3","seqChunkSize":20000,"end":198295559,"start":0},{"length":190214555,"name":"chr4","start":0,"end":190214555,"seqChunkSize":20000},{"length":181538259,"name":"chr5","seqChunkSize":20000,"end":181538259,"start":0},{"length":170805979,"name":"chr6","start":0,"end":170805979,"seqChunkSize":20000},{"length":159345973,"name":"chr7","seqChunkSize":20000,"end":159345973,"start":0},{"length":145138636,"name":"chr8","start":0,"end":145138636,"seqChunkSize":20000},{"length":138394717,"name":"chr9","seqChunkSize":20000,"end":138394717,"start":0},{"length":133797422,"name":"chr10","start":0,"end":133797422,"seqChunkSize":20000},{"length":135086622,"name":"chr11","seqChunkSize":20000,"end":135086622,"start":0},{"length":133275309,"name":"chr12","start":0,"end":133275309,"seqChunkSize":20000},{"length":114364328,"name":"chr13","seqChunkSize":20000,"end":114364328,"start":0},{"length":107043718,"name":"chr14","start":0,"end":107043718,"seqChunkSize":20000},{"length":101991189,"name":"chr15","seqChunkSize":20000,"end":101991189,"start":0},{"length":90338345,"name":"chr16","start":0,"end":90338345,"seqChunkSize":20000},{"length":83257441,"name":"chr17","seqChunkSize":20000,"end":83257441,"start":0},{"length":80373285,"name":"chr18","start":0,"end":80373285,"seqChunkSize":20000},{"length":58617616,"name":"chr19","seqChunkSize":20000,"end":58617616,"start":0},{"length":64444167,"name":"chr20","start":0,"end":64444167,"seqChunkSize":20000},{"length":46709983,"name":"chr21","seqChunkSize":20000,"end":46709983,"start":0},{"length":50818468,"name":"chr22","start":0,"end":50818468,"seqChunkSize":20000},{"length":156040895,"name":"chrX","seqChunkSize":20000,"end":156040895,"start":0},{"length":57227415,"name":"chrY","start":0,"end":57227415,"seqChunkSize":20000},{"length":16569,"name":"chrM","seqChunkSize":20000,"end":16569,"start":0}];
array.forEach(chroms, function(chrom, i) {
renderBlock(chrom.name,"display"+i,store,i,chrom.length);
});
});
</script>
</head>
<body style="margin: 30px">
<div style="margin: 30px">
<h1>BigWig</h1>
</div>
</body>
</html>
@cmdcolin
Copy link
Author

gwas_bigwig

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment