Built with blockbuilder.org
forked from swaggernation77's block: fresh block
forked from scampbell2434's block: fresh block numero dos
xxxxxxxxxx
contig histogram
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
.bar rect {
fill: Indigo;
}
.bar text {
fill: #fff;
font: 10px sans-serif;
}
</style>
</head>
<body>
<script>
// Feel free to change or delete any of the code you see in this editor!
var svg = d3.select("body").append("svg")
.attr("width", 960)
.attr("height", 500)
var usv = d3.dsvFormat("_");
var headers = [];
// this is the parse
var output = usv.parse(">NODE_length_135_cov_6.362500")
//console.log(output)
d3.request("Test.Fasta")
.mimeType("text/plain")
.response(function(xhr) { return usv.parse(xhr.responseText) })
// function that access information from a URL
.get(function(data) {
//console.log("data: ", data)
data.forEach(function (d){
if (d.node == ">NODE"){
headers.push("size: ", +d.size)
}
})
console.log ("headers: ", headers);
var data = d3.range(1000).map(d3.randomBates(10));
var formatCount = d3.format(",.0f");
var svg = d3.select("svg"),
margin = {top: 10, right: 30, bottom: 30, left: 30},
width = +svg.attr("width") - margin.left - margin.right,
height = +svg.attr("height") - margin.top - margin.bottom,
g = svg.append("g").attr("transform", "translate(" + margin.left + "," + margin.top + ")");
var x = d3.scaleLinear()
.rangeRound([0, width]);
var bins = d3.histogram()
.domain(x.domain())
.thresholds(x.ticks(43))
(data);
var y = d3.scaleLinear()
.domain([0, d3.max(bins, function(d) { return d.length; })])
.range([height, 0]);
var bar = g.selectAll(".bar")
.data(bins)
.enter().append("g")
.attr("class", "bar")
.attr("transform", function(d) { return "translate(" + x(d.x0) + "," + y(d.length) + ")"; });
bar.append("rect")
.attr("x", 1)
.attr("width", x(bins[0].x1) - x(bins[0].x0) - 1)
.attr("height", function(d) { return height - y(d.length); });
bar.append("text")
.attr("dy", ".75em")
.attr("y", 6)
.attr("x", (x(bins[0].x1) - x(bins[0].x0)) / 2)
.attr("text-anchor", "middle")
.text(function(d) { return formatCount(d.length); });
g.append("g")
.attr("class", "axis axis--x")
.attr("transform", "translate(0," + height + ")")
.call(d3.axisBottom(x));
});
</script>
</body>
https://d3js.org/d3.v4.min.js