plots¶
lab.connectome.plots
¶
Figures drawn from tables.
Each function returns a figure and writes no file;
plot_neurons and network_figure return HTML,
the others a figure object.
Colors come from lab.connectome.look.
jaccard_heatmaps(panels, types)
¶
Draw four titled Jaccard matrices, shaded from 0 to 1.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
panels
|
dict of str to numpy.ndarray
|
Four square matrices by title, as
|
required |
types
|
sequence of str
|
The names of the rows and columns of every matrix. |
required |
Returns:
| Type | Description |
|---|---|
Figure
|
A 2 x 2 grid with the value written in each cell. |
See Also
lab.connectome.overlap.jaccard_matrix : Builds each panel.
Examples:
>>> import numpy as np
>>> rng = np.random.default_rng(0)
>>> def panel():
... m = rng.uniform(0, 1, (4, 4))
... m = (m + m.T) / 2
... np.fill_diagonal(m, 1)
... return m
>>> panels = {
... f"{side}, by {level}": panel()
... for level in ("type", "cell")
... for side in ("output", "input")
... }
>>> figure = jaccard_heatmaps(panels, ["T1", "T2", "T3", "T4"])
Source code in lab/connectome/plots.py
network_figure(edges, types)
¶
Draw a network of types and their partner types.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edges
|
DataFrame
|
Columns |
required |
types
|
sequence of str
|
The types to draw large, each in its color; every other node is a partner type, in gray. |
required |
Returns:
| Type | Description |
|---|---|
str
|
A page of HTML that loads vis-network, so it needs a network connection. An arrow runs from each source to its target, as wide as its synapse count in proportion to the heaviest edge, and in the color of its kind. A partner is larger the more edges it has. Drag a node to move it; hover over an edge for its count. The layout starts from a fixed seed, so the same edges draw the same figure. |
See Also
lab.connectome.between_types.network_edges : Picks the edges.
Examples:
>>> import polars as pl
>>> rows = [
... ("LC16", "P1", 2400, "out"),
... ("LC16", "P2", 1500, "out"),
... ("LC16", "P3", 800, "out"),
... ("LC16", "P4", 300, "out"),
... ("P5", "LC16", 900, "in"),
... ("P6", "LC16", 450, "in"),
... ("P7", "LC16", 120, "in"),
... ("P1", "P3", 600, "lateral"),
... ("P2", "P3", 90, "lateral"),
... ]
>>> names = ["src", "dst", "synapses", "kind"]
>>> edges = pl.DataFrame(rows, schema=names, orient="row")
>>> figure = network_figure(edges, ["LC16"])
Source code in lab/connectome/plots.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 | |
plot_neurons(cells, colors=TYPE_COLORS, height=560)
¶
Show cells in 3D in a Neuroglancer frame, with buttons.
The frame draws the public FlyWire meshes of the cells, each type in its color. The buttons below it open the same scene in a new tab and list the same cells in the Codex search.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cells
|
mapping of str to sequence of int
|
The root ids of the cells to show, by cell type. |
required |
colors
|
mapping of str to str
|
Color of each type; |
TYPE_COLORS
|
height
|
int
|
Height of the frame in pixels. |
560
|
Returns:
| Type | Description |
|---|---|
str
|
HTML for a page or a notebook cell. The frame needs a browser that has WebGL, and the Codex button needs a Codex login. |
See Also
lab.connectome.links.neuroglancer_url : Builds the scene. lab.connectome.links.codex_search_url : Builds the search.
Examples:
>>> cells = {"LC16": [720575940606173630]}
>>> "Open in Codex" in plot_neurons(cells)
True
>>> figure = plot_neurons(cells)
Source code in lab/connectome/plots.py
top_partners_figure(out_mass, in_mass, types, *, shown=15)
¶
Draw the heaviest partner types of each type as bars.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
out_mass
|
DataFrame
|
Columns |
required |
in_mass
|
DataFrame
|
Columns |
required |
types
|
sequence of str
|
The types, one column of panels each, in their colors. |
required |
shown
|
int
|
Bars per panel. |
15
|
Returns:
| Type | Description |
|---|---|
Figure
|
Outputs in the top row, inputs in the bottom row. |
Examples:
>>> import polars as pl
>>> def mass(counts):
... return pl.DataFrame(
... {
... "type": ["LC16"] * 6 + ["LC6"] * 6,
... "partner_type": [f"P{i}" for i in range(1, 7)] * 2,
... "synapses": counts,
... }
... )
>>> out_mass = mass(
... [820, 460, 300, 120, 60, 25, 90, 640, 40, 410, 30, 220]
... )
>>> in_mass = mass(
... [300, 700, 150, 520, 80, 40, 610, 200, 330, 90, 260, 20]
... )
>>> figure = top_partners_figure(
... out_mass, in_mass, ["LC16", "LC6"], shown=5
... )