Skip to content

Instantly share code, notes, and snippets.

@dhoboy
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhoboy/1e71984423fba734302d to your computer and use it in GitHub Desktop.
Save dhoboy/1e71984423fba734302d to your computer and use it in GitHub Desktop.
Kai drawing paths

Forked from Syntagmatic. Working on visualizing 80,000+ entry chromosome dataset for Stephen Sheng.

<!DOCTYPE html>
<meta charset="utf-8">
<style>
path {
stroke: #000;
stroke-width: 1.5px;
fill: none;
}
</style>
<body>
<script src="http://d3js.org/d3.v3.js"></script>
<script>
var w = 960,
h = 500;
var svg = d3.select("body")
.append("svg")
.attr("width", w)
.attr("height", h);
var xScale = d3.scale.linear()
.range([0, w]);
var yScale = d3.scale.ordinal()
.rangeRoundBands([0, h]);
var line = d3.svg.line()
.x(function(d) { return xScale(d.tx); })
.y(function(d) { return yScale(d.i); });
d3.tsv("sample.tsv", function(error, data) {
xScale.domain([d3.min(data, function(d) { return d["txStart"]; }),
d3.max(data, function(d) { return d["txEnd"]; })])
yScale.domain(d3.range(data.length))
var paths = svg.selectAll("path")
.data(data.map(function(d,i) {
return [
{ tx: d.txStart, i: i },
{ tx: d.txEnd, i: i }
]
}))
.enter()
.append("path")
.attr("d", line)
/*
.attr("transform", function(d, i) {
return "translate(0," + yScale(i) + ")";
});
*/
});
</script>
#name chrom strand txStart txEnd
uc001aaa.3 chr1 + 11873 14409
uc010nxr.1 chr1 + 11873 14409
uc010nxq.1 chr1 + 11873 14409
uc009vis.3 chr1 - 14361 16765
uc009vit.3 chr1 - 14361 19759
uc009viu.3 chr1 - 14361 19759
uc001aae.4 chr1 - 14361 19759
uc001aah.4 chr1 - 14361 29370
uc009vir.3 chr1 - 14361 29370
uc009viq.3 chr1 - 14361 29370
uc001aac.4 chr1 - 14361 29370
uc009viv.2 chr1 - 14406 29370
uc009viw.2 chr1 - 14406 29370
uc009vix.2 chr1 - 15602 29370
uc009vjd.2 chr1 - 15795 18061
uc009viy.2 chr1 - 16606 29370
uc009viz.2 chr1 - 16606 29370
uc009vjc.1 chr1 - 16857 17751
uc001aai.1 chr1 - 16857 19759
uc010nxs.1 chr1 - 16857 29370
uc009vjb.1 chr1 - 16857 29961
uc009vje.2 chr1 - 17232 29370
uc009vjf.2 chr1 - 17605 29370
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment