{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "![](images/blue_brain_neurons.colorful.png)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Analyzing Connectomics Data\n", "---\n", "The `netsci` package comes with an out-of-box dataset describing the [neuronal network](https://en.wikipedia.org/wiki/Neural_network) among ~2,000 neurons from a rat brain. In this notebook, we shortly explain the nature of this data and demonstrate a basic network analysis applied upon it.\n", "\n", "Essentially, after completing this tutorial, you will know:\n", "1. What are the brain's neural networks and what is the connectome.\n", "2. How to load the (toy) connectomics data and convert it to a network.\n", "3. How to identify and count three-node motifs in a network.\n", "4. That, in neuronal networks, a motif connectivity is highly related to the spatial embedding of its composing neurons.\n", "\n", "A deeper description of this network study, together with its neuroscientific context and implication, can be found in [this recent paper](https://doi.org/10.1101/656058).\n", "\n", "\n", "Let’s get started.\n", "\n", "\n", "## Connectomics\n", "> *You are more than your genes. You are your connectome.* --Sebastian Seung\n", "\n", "The human brain is composed of about 100 billion specialized nerve cells, [**neurons**](https://en.wikipedia.org/wiki/Neuron). Neurons can connect to up to 10,000 other target neurons each, altogether forming the vast and complex [biological neural networks](https://en.wikipedia.org/wiki/Neural_circuit). The inter-connections between neurons are formed by [**synapses**](https://en.wikipedia.org/wiki/Synapse) - structural \"junctions\" that allow transferring electric impulses, [**action potentials**](https://en.wikipedia.org/wiki/Action_potential), from one neuron the another. The precise wiring diagram of all neuronal connections, or [**the connectome**](https://en.wikipedia.org/wiki/Connectome), shapes the network-wide electric activity and underlies the different brain functions like information processing, memory, and, ultimately, behavior. However, how exactly does the network structure affect brain activity and function, is a long-standing and still open question in neuroscience for more than a century. \n", "\n", "
\n", " \n", " from www.khanacademy.org\n", "
\n", "\n", "The biological connectome can be further modeled as a mathematical [**directed graph**](https://en.wikipedia.org/wiki/Directed_graph) whose [**nodes**](https://en.wikipedia.org/wiki/Glossary_of_graph_theory_terms#node) correspond to the neurons, and its [**edges**](https://en.wikipedia.org/wiki/Glossary_of_graph_theory_terms#edge) are the synaptic connections between those neurons. This network-based perspective of the brain allows utilizing tools from [**graph theory**](https://en.wikipedia.org/wiki/Graph_theory) and modern [**network science**](https://en.wikipedia.org/wiki/Network_science) to uncover key network structures that support brain functions. Such methods have already identified several network features in cortex architecture, such as the rare but highly-connected hub neurons, cliques of all-to-all connected neurons, and overall small-world topology of the cortical microcircuit. \n", "\n", "![](images/nn.4576.sketch.reduced.png)\n", "\n", "Arguably, one of the most basic, yet still not fully explained, network structures observed in neuronal circuits are the 3-neuron subgraphs (triplets). When counting the frequency of all possible 3-nodes connectivity patterns in the network, the distribution appears highly unexpected. Specifically, few specific configurations (out of all 16 possible) stand-out and are significantly over-expressed (motifs) when compared with reference randomized networks. More surprisingly, different microcircuits across different brain regions commonly display similar over- and under-expression of the same motifs. However, despite their cross-region universality, both the origin of these motifs and their functional implication have remained elusive.\n", "\n", "![](images/ANNs.cropped.png)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**So, what is the origin of neuronal network motifs?**\n", "\n", "In the absence of a concrete theory about the principles underlying these motifs, their emergence may be hypothetically associated with active plasticity and learning processes. But another, much more parsimonious, possibility comes to mind. Most types of cortical neurons display highly asymmetric geometry with dendritic and axonal trees typically extending in different directions. As a consequence, the probability of forming a connection in one direction (e.g., down) may be higher than in the other direction (e.g., up). This symmetry breaking may distinctively promote some motifs while depressing others. Thus, it could be the case that the geometry per se “enforces” the complex profile of brain microcircuit motifs. \n", "\n", "The importance of this hypothesis is that if it is indeed so, then we can now see learning processes as operating on top of an innate, already structured, cortical skeleton rather than on a _tabula rasa_ network connectivity. This will strongly constrain the degree by which plasticity could further shape neural connectivity, and possible reduce the room for learning.\n", "\n", "We will test this hypothesis below. Toward this end, we will utilize the publicly available dataset of the [Blue Brain model](https://bbp.epfl.ch/nmc-portal/welcome). Specifically, we analyze here a subcircuit of it (pyramidal neurons for layer 5), that is now accessible via `netsci` API's." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "ExecuteTime": { "end_time": "2020-01-22T16:51:59.962075Z", "start_time": "2020-01-22T16:51:56.421345Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Requirement already satisfied: plotly in /Users/eyalgal/anaconda3/envs/hv/lib/python3.7/site-packages (4.2.1)\n", "Requirement already satisfied: six in /Users/eyalgal/anaconda3/envs/hv/lib/python3.7/site-packages (from plotly) (1.12.0)\n", "Requirement already satisfied: retrying>=1.3.3 in /Users/eyalgal/anaconda3/envs/hv/lib/python3.7/site-packages (from plotly) (1.3.3)\n", "Requirement already satisfied: holoviews in /Users/eyalgal/anaconda3/envs/hv/lib/python3.7/site-packages (1.12.6)\n", "Requirement already satisfied: param<2.0,>=1.8.0 in /Users/eyalgal/anaconda3/envs/hv/lib/python3.7/site-packages (from holoviews) (1.9.2)\n", "Requirement already satisfied: numpy>=1.0 in /Users/eyalgal/anaconda3/envs/hv/lib/python3.7/site-packages (from holoviews) (1.17.3)\n", "Requirement already satisfied: pyviz_comms>=0.7.2 in /Users/eyalgal/anaconda3/envs/hv/lib/python3.7/site-packages (from holoviews) (0.7.2)\n", "Requirement already satisfied: netsci in /Users/eyalgal/Dropbox/PhD/Code/python/netsci (0.0.2.2)\n", "Requirement already satisfied: numpy>=1.16.2 in /Users/eyalgal/anaconda3/envs/hv/lib/python3.7/site-packages (from netsci) (1.17.3)\n", "Requirement already satisfied: pandas>=0.24.2 in /Users/eyalgal/anaconda3/envs/hv/lib/python3.7/site-packages (from netsci) (0.25.2)\n", "Requirement already satisfied: matplotlib>=3.0.3 in /Users/eyalgal/anaconda3/envs/hv/lib/python3.7/site-packages (from netsci) (3.1.1)\n", "Requirement already satisfied: seaborn>=0.9.0 in /Users/eyalgal/anaconda3/envs/hv/lib/python3.7/site-packages (from netsci) (0.9.0)\n", "Requirement already satisfied: networkx>=2.2 in /Users/eyalgal/anaconda3/envs/hv/lib/python3.7/site-packages (from netsci) (2.4)\n", "Requirement already satisfied: python-dateutil>=2.6.1 in /Users/eyalgal/anaconda3/envs/hv/lib/python3.7/site-packages (from pandas>=0.24.2->netsci) (2.8.1)\n", "Requirement already satisfied: pytz>=2017.2 in /Users/eyalgal/anaconda3/envs/hv/lib/python3.7/site-packages (from pandas>=0.24.2->netsci) (2019.3)\n", "Requirement already satisfied: cycler>=0.10 in /Users/eyalgal/anaconda3/envs/hv/lib/python3.7/site-packages (from matplotlib>=3.0.3->netsci) (0.10.0)\n", "Requirement already satisfied: kiwisolver>=1.0.1 in /Users/eyalgal/anaconda3/envs/hv/lib/python3.7/site-packages (from matplotlib>=3.0.3->netsci) (1.1.0)\n", "Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /Users/eyalgal/anaconda3/envs/hv/lib/python3.7/site-packages (from matplotlib>=3.0.3->netsci) (2.4.2)\n", "Requirement already satisfied: scipy>=0.14.0 in /Users/eyalgal/anaconda3/envs/hv/lib/python3.7/site-packages (from seaborn>=0.9.0->netsci) (1.3.1)\n", "Requirement already satisfied: decorator>=4.3.0 in /Users/eyalgal/anaconda3/envs/hv/lib/python3.7/site-packages (from networkx>=2.2->netsci) (4.4.1)\n", "Requirement already satisfied: six>=1.5 in /Users/eyalgal/anaconda3/envs/hv/lib/python3.7/site-packages (from python-dateutil>=2.6.1->pandas>=0.24.2->netsci) (1.12.0)\n", "Requirement already satisfied: setuptools in /Users/eyalgal/anaconda3/envs/hv/lib/python3.7/site-packages (from kiwisolver>=1.0.1->matplotlib>=3.0.3->netsci) (41.6.0.post20191030)\n" ] } ], "source": [ "!pip install plotly\n", "!pip install holoviews\n", "!pip install netsci # required, when notebook is executed in Google Colab" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "ExecuteTime": { "end_time": "2020-01-22T16:52:03.360686Z", "start_time": "2020-01-22T16:51:59.973748Z" }, "scrolled": true }, "outputs": [ { "data": { "text/html": [ " \n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.holoviews_load.v0+json": "/**\n* plotly.js v1.50.1\n* Copyright 2012-2019, Plotly, Inc.\n* All rights reserved.\n* Licensed under the MIT license\n*/\n!function(t){if(\"object\"==typeof exports&&\"undefined\"!=typeof module)module.exports=t();else if(\"function\"==typeof define&&define.amd)define([],t);else{(\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:\"undefined\"!=typeof self?self:this).Plotly=t()}}(function(){return function(){return function t(e,r,n){function a(o,s){if(!r[o]){if(!e[o]){var l=\"function\"==typeof require&&require;if(!s&&l)return l(o,!0);if(i)return i(o,!0);var c=new Error(\"Cannot find module '\"+o+\"'\");throw c.code=\"MODULE_NOT_FOUND\",c}var u=r[o]={exports:{}};e[o][0].call(u.exports,function(t){return a(e[o][1][t]||t)},u,u.exports,t,e,r,n)}return r[o].exports}for(var i=\"function\"==typeof require&&require,o=0;o=p0)&&!(p1>=hi)\",[\"p0\",\"p1\"]),g=u(\"lo===p0\",[\"p0\"]),v=u(\"lo >1)-1;0===I?d(s,l,C--,z):1===I?d(c,u,L--,z):2===I&&d(h,f,P--,z)}}},scanBipartite:function(t,e,r,n,a,c,u,h,f,v,m,y){var x=0,b=2*t,_=e,w=e+t,k=1,T=1;n?T=o:k=o;for(var A=a;A =r)for(n=r;++in&&(n=r)}else for(;++i=r)for(n=r;++in&&(n=r);return n},t.mean=function(t,e){var r,n=t.length,a=n,i=-1,o=0;if(null==e)for(;++i l.length)return r;var a,i=c[n-1];return null!=e&&n>=l.length?a=r.entries():(a=[],r.each(function(e,r){a.push({key:r,values:t(e,n)})})),null!=i?a.sort(function(t,e){return i(t.key,e.key)}):a}(u(t,0,i,o),0)},key:function(t){return l.push(t),s},sortKeys:function(t){return c[l.length-1]=t,s},sortValues:function(e){return t=e,s},rollup:function(t){return e=t,s}}},t.set=c,t.map=r,t.keys=function(t){var e=[];for(var r in t)e.push(r);return e},t.values=function(t){var e=[];for(var r in t)e.push(t[r]);return e},t.entries=function(t){var e=[];for(var r in t)e.push({key:r,value:t[r]});return e},Object.defineProperty(t,\"__esModule\",{value:!0})}(\"object\"==typeof r&&\"undefined\"!=typeof e?r:n.d3=n.d3||{})},{}],155:[function(t,e,r){var n;n=this,function(t){\"use strict\";function e(t,e,r){t.prototype=e.prototype=r,r.constructor=t}function r(t,e){var r=Object.create(t.prototype);for(var n in e)r[n]=e[n];return r}function n(){}var a=\"\\\\s*([+-]?\\\\d+)\\\\s*\",i=\"\\\\s*([+-]?\\\\d*\\\\.?\\\\d+(?:[eE][+-]?\\\\d+)?)\\\\s*\",o=\"\\\\s*([+-]?\\\\d*\\\\.?\\\\d+(?:[eE][+-]?\\\\d+)?)%\\\\s*\",s=/^#([0-9a-f]{3})$/,l=/^#([0-9a-f]{6})$/,c=new RegExp(\"^rgb\\\\(\"+[a,a,a]+\"\\\\)$\"),u=new RegExp(\"^rgb\\\\(\"+[o,o,o]+\"\\\\)$\"),h=new RegExp(\"^rgba\\\\(\"+[a,a,a,i]+\"\\\\)$\"),f=new RegExp(\"^rgba\\\\(\"+[o,o,o,i]+\"\\\\)$\"),p=new RegExp(\"^hsl\\\\(\"+[i,o,o]+\"\\\\)$\"),d=new RegExp(\"^hsla\\\\(\"+[i,o,o,i]+\"\\\\)$\"),g={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function v(t){var e;return t=(t+\"\").trim().toLowerCase(),(e=s.exec(t))?new _((e=parseInt(e[1],16))>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):(e=l.exec(t))?m(parseInt(e[1],16)):(e=c.exec(t))?new _(e[1],e[2],e[3],1):(e=u.exec(t))?new _(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=h.exec(t))?y(e[1],e[2],e[3],e[4]):(e=f.exec(t))?y(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=p.exec(t))?k(e[1],e[2]/100,e[3]/100,1):(e=d.exec(t))?k(e[1],e[2]/100,e[3]/100,e[4]):g.hasOwnProperty(t)?m(g[t]):\"transparent\"===t?new _(NaN,NaN,NaN,0):null}function m(t){return new _(t>>16&255,t>>8&255,255&t,1)}function y(t,e,r,n){return n<=0&&(t=e=r=NaN),new _(t,e,r,n)}function x(t){return t instanceof n||(t=v(t)),t?new _((t=t.rgb()).r,t.g,t.b,t.opacity):new _}function b(t,e,r,n){return 1===arguments.length?x(t):new _(t,e,r,null==n?1:n)}function _(t,e,r,n){this.r=+t,this.g=+e,this.b=+r,this.opacity=+n}function w(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?\"0\":\"\")+t.toString(16)}function k(t,e,r,n){return n<=0?t=e=r=NaN:r<=0||r>=1?t=e=NaN:e<=0&&(t=NaN),new A(t,e,r,n)}function T(t,e,r,a){return 1===arguments.length?function(t){if(t instanceof A)return new A(t.h,t.s,t.l,t.opacity);if(t instanceof n||(t=v(t)),!t)return new A;if(t instanceof A)return t;var e=(t=t.rgb()).r/255,r=t.g/255,a=t.b/255,i=Math.min(e,r,a),o=Math.max(e,r,a),s=NaN,l=o-i,c=(o+i)/2;return l?(s=e===o?(r-a)/l+6*(r0&&c<1?0:s,new A(s,l,c,t.opacity)}(t):new A(t,e,r,null==a?1:a)}function A(t,e,r,n){this.h=+t,this.s=+e,this.l=+r,this.opacity=+n}function M(t,e,r){return 255*(t<60?e+(r-e)*t/60:t<180?r:t<240?e+(r-e)*(240-t)/60:e)}e(n,v,{displayable:function(){return this.rgb().displayable()},hex:function(){return this.rgb().hex()},toString:function(){return this.rgb()+\"\"}}),e(_,b,r(n,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new _(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new _(this.r*t,this.g*t,this.b*t,this.opacity)},rgb:function(){return this},displayable:function(){return 0<=this.r&&this.r<=255&&0<=this.g&&this.g<=255&&0<=this.b&&this.b<=255&&0<=this.opacity&&this.opacity<=1},hex:function(){return\"#\"+w(this.r)+w(this.g)+w(this.b)},toString:function(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?\"rgb(\":\"rgba(\")+Math.max(0,Math.min(255,Math.round(this.r)||0))+\", \"+Math.max(0,Math.min(255,Math.round(this.g)||0))+\", \"+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===t?\")\":\", \"+t+\")\")}})),e(A,T,r(n,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new A(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new A(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,r=this.l,n=r+(r<.5?r:1-r)*e,a=2*r-n;return new _(M(t>=240?t-240:t+120,a,n),M(t,a,n),M(t<120?t+240:t-120,a,n),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1}}));var S=Math.PI/180,E=180/Math.PI,C=.96422,L=1,P=.82521,O=4/29,I=6/29,z=3*I*I,D=I*I*I;function R(t){if(t instanceof B)return new B(t.l,t.a,t.b,t.opacity);if(t instanceof G){if(isNaN(t.h))return new B(t.l,0,0,t.opacity);var e=t.h*S;return new B(t.l,Math.cos(e)*t.c,Math.sin(e)*t.c,t.opacity)}t instanceof _||(t=x(t));var r,n,a=U(t.r),i=U(t.g),o=U(t.b),s=N((.2225045*a+.7168786*i+.0606169*o)/L);return a===i&&i===o?r=n=s:(r=N((.4360747*a+.3850649*i+.1430804*o)/C),n=N((.0139322*a+.0971045*i+.7141733*o)/P)),new B(116*s-16,500*(r-s),200*(s-n),t.opacity)}function F(t,e,r,n){return 1===arguments.length?R(t):new B(t,e,r,null==n?1:n)}function B(t,e,r,n){this.l=+t,this.a=+e,this.b=+r,this.opacity=+n}function N(t){return t>D?Math.pow(t,1/3):t/z+O}function j(t){return t>I?t*t*t:z*(t-O)}function V(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function U(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function q(t){if(t instanceof G)return new G(t.h,t.c,t.l,t.opacity);if(t instanceof B||(t=R(t)),0===t.a&&0===t.b)return new G(NaN,0,t.l,t.opacity);var e=Math.atan2(t.b,t.a)*E;return new G(e<0?e+360:e,Math.sqrt(t.a*t.a+t.b*t.b),t.l,t.opacity)}function H(t,e,r,n){return 1===arguments.length?q(t):new G(t,e,r,null==n?1:n)}function G(t,e,r,n){this.h=+t,this.c=+e,this.l=+r,this.opacity=+n}e(B,F,r(n,{brighter:function(t){return new B(this.l+18*(null==t?1:t),this.a,this.b,this.opacity)},darker:function(t){return new B(this.l-18*(null==t?1:t),this.a,this.b,this.opacity)},rgb:function(){var t=(this.l+16)/116,e=isNaN(this.a)?t:t+this.a/500,r=isNaN(this.b)?t:t-this.b/200;return new _(V(3.1338561*(e=C*j(e))-1.6168667*(t=L*j(t))-.4906146*(r=P*j(r))),V(-.9787684*e+1.9161415*t+.033454*r),V(.0719453*e-.2289914*t+1.4052427*r),this.opacity)}})),e(G,H,r(n,{brighter:function(t){return new G(this.h,this.c,this.l+18*(null==t?1:t),this.opacity)},darker:function(t){return new G(this.h,this.c,this.l-18*(null==t?1:t),this.opacity)},rgb:function(){return R(this).rgb()}}));var Y=-.14861,W=1.78277,X=-.29227,Z=-.90649,J=1.97294,K=J*Z,Q=J*W,$=W*X-Z*Y;function tt(t,e,r,n){return 1===arguments.length?function(t){if(t instanceof et)return new et(t.h,t.s,t.l,t.opacity);t instanceof _||(t=x(t));var e=t.r/255,r=t.g/255,n=t.b/255,a=($*n+K*e-Q*r)/($+K-Q),i=n-a,o=(J*(r-a)-X*i)/Z,s=Math.sqrt(o*o+i*i)/(J*a*(1-a)),l=s?Math.atan2(o,i)*E-120:NaN;return new et(l<0?l+360:l,s,a,t.opacity)}(t):new et(t,e,r,null==n?1:n)}function et(t,e,r,n){this.h=+t,this.s=+e,this.l=+r,this.opacity=+n}e(et,tt,r(n,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new et(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new et(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=isNaN(this.h)?0:(this.h+120)*S,e=+this.l,r=isNaN(this.s)?0:this.s*e*(1-e),n=Math.cos(t),a=Math.sin(t);return new _(255*(e+r*(Y*n+W*a)),255*(e+r*(X*n+Z*a)),255*(e+r*(J*n)),this.opacity)}})),t.color=v,t.rgb=b,t.hsl=T,t.lab=F,t.hcl=H,t.lch=function(t,e,r,n){return 1===arguments.length?q(t):new G(r,e,t,null==n?1:n)},t.gray=function(t,e){return new B(t,0,0,null==e?1:e)},t.cubehelix=tt,Object.defineProperty(t,\"__esModule\",{value:!0})}(\"object\"==typeof r&&\"undefined\"!=typeof e?r:n.d3=n.d3||{})},{}],156:[function(t,e,r){var n;n=this,function(t){\"use strict\";var e={value:function(){}};function r(){for(var t,e=0,r=arguments.length,a={};e =a.length)return e;var n=[],o=i[r++];return e.forEach(function(e,a){n.push({key:e,values:t(a,r)})}),o?n.sort(function(t,e){return o(t.key,e.key)}):n}(o(t.map,e,0),0)},n.key=function(t){return a.push(t),n},n.sortKeys=function(t){return i[a.length-1]=t,n},n.sortValues=function(t){return e=t,n},n.rollup=function(t){return r=t,n},n},t.set=function(t){var e=new L;if(t)for(var r=0,n=t.length;r 360?t-=360:t<0&&(t+=360),t<60?n+(a-n)*t/60:t<180?a:t<240?n+(a-n)*(240-t)/60:n}(t))}return t=isNaN(t)?0:(t%=360)<0?t+360:t,e=isNaN(e)?0:e<0?0:e>1?1:e,n=2*(r=r<0?0:r>1?1:r)-(a=r<=.5?r*(1+e):r+e-r*e),new ie(i(t+120),i(t),i(t-120))}function Gt(e,r,n){return this instanceof Gt?(this.h=+e,this.c=+r,void(this.l=+n)):arguments.length<2?e instanceof Gt?new Gt(e.h,e.c,e.l):ee(e instanceof Xt?e.l:(e=fe((e=t.rgb(e)).r,e.g,e.b)).l,e.a,e.b):new Gt(e,r,n)}qt.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),new Ut(this.h,this.s,this.l/t)},qt.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new Ut(this.h,this.s,t*this.l)},qt.rgb=function(){return Ht(this.h,this.s,this.l)},t.hcl=Gt;var Yt=Gt.prototype=new Vt;function Wt(t,e,r){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new Xt(r,Math.cos(t*=Ct)*e,Math.sin(t)*e)}function Xt(t,e,r){return this instanceof Xt?(this.l=+t,this.a=+e,void(this.b=+r)):arguments.length<2?t instanceof Xt?new Xt(t.l,t.a,t.b):t instanceof Gt?Wt(t.h,t.c,t.l):fe((t=ie(t)).r,t.g,t.b):new Xt(t,e,r)}Yt.brighter=function(t){return new Gt(this.h,this.c,Math.min(100,this.l+Zt*(arguments.length?t:1)))},Yt.darker=function(t){return new Gt(this.h,this.c,Math.max(0,this.l-Zt*(arguments.length?t:1)))},Yt.rgb=function(){return Wt(this.h,this.c,this.l).rgb()},t.lab=Xt;var Zt=18,Jt=.95047,Kt=1,Qt=1.08883,$t=Xt.prototype=new Vt;function te(t,e,r){var n=(t+16)/116,a=n+e/500,i=n-r/200;return new ie(ae(3.2404542*(a=re(a)*Jt)-1.5371385*(n=re(n)*Kt)-.4985314*(i=re(i)*Qt)),ae(-.969266*a+1.8760108*n+.041556*i),ae(.0556434*a-.2040259*n+1.0572252*i))}function ee(t,e,r){return t>0?new Gt(Math.atan2(r,e)*Lt,Math.sqrt(e*e+r*r),t):new Gt(NaN,NaN,t)}function re(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function ne(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function ae(t){return Math.round(255*(t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function ie(t,e,r){return this instanceof ie?(this.r=~~t,this.g=~~e,void(this.b=~~r)):arguments.length<2?t instanceof ie?new ie(t.r,t.g,t.b):ue(\"\"+t,ie,Ht):new ie(t,e,r)}function oe(t){return new ie(t>>16,t>>8&255,255&t)}function se(t){return oe(t)+\"\"}$t.brighter=function(t){return new Xt(Math.min(100,this.l+Zt*(arguments.length?t:1)),this.a,this.b)},$t.darker=function(t){return new Xt(Math.max(0,this.l-Zt*(arguments.length?t:1)),this.a,this.b)},$t.rgb=function(){return te(this.l,this.a,this.b)},t.rgb=ie;var le=ie.prototype=new Vt;function ce(t){return t<16?\"0\"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function ue(t,e,r){var n,a,i,o=0,s=0,l=0;if(n=/([a-z]+)\\((.*)\\)/.exec(t=t.toLowerCase()))switch(a=n[2].split(\",\"),n[1]){case\"hsl\":return r(parseFloat(a[0]),parseFloat(a[1])/100,parseFloat(a[2])/100);case\"rgb\":return e(de(a[0]),de(a[1]),de(a[2]))}return(i=ge.get(t))?e(i.r,i.g,i.b):(null==t||\"#\"!==t.charAt(0)||isNaN(i=parseInt(t.slice(1),16))||(4===t.length?(o=(3840&i)>>4,o|=o>>4,s=240&i,s|=s>>4,l=15&i,l|=l<<4):7===t.length&&(o=(16711680&i)>>16,s=(65280&i)>>8,l=255&i)),e(o,s,l))}function he(t,e,r){var n,a,i=Math.min(t/=255,e/=255,r/=255),o=Math.max(t,e,r),s=o-i,l=(o+i)/2;return s?(a=l<.5?s/(o+i):s/(2-o-i),n=t==o?(e-r)/s+(e=o)d(c,u,C--,L=L-o|0);else if(L>=0)d(s,l,E--,L);else if(L<=-o){L=-L-o|0;for(var P=0;Ps&&(r=s-l),i=r;i>=0;i--){for(var h=!0,f=0;f0&&l.push([\"index[\",h,\"]-=s\",h].join(\"\")),l.push([\"++index[\",u,\"]\"].join(\"\"))),l.push(\"}\")}return l.join(\"\\n\")}function i(t,e,r){for(var n=t.body,a=[],i=[],o=0;oh;)f.pop(),--p;var d,g=new Array(p+1);for(i=0;i<=p;++i)(d=g[i]=[]).x0=i>0?f[i-1]:u,d.x1=i=0&&\"xmlns\"!==(r=t.slice(0,e))&&(t=t.slice(e+1)),K.hasOwnProperty(r)?{space:K[r],local:t}:t}},W.attr=function(e,r){if(arguments.length<2){if(\"string\"==typeof e){var n=this.node();return(e=t.ns.qualify(e)).local?n.getAttributeNS(e.space,e.local):n.getAttribute(e)}for(r in e)this.each(Q(r,e[r]));return this}return this.each(Q(e,r))},W.classed=function(t,e){if(arguments.length<2){if(\"string\"==typeof t){var r=this.node(),n=(t=et(t)).length,a=-1;if(e=r.classList){for(;++a