plots¶
champalimaud.plots
¶
Figures drawn from tables.
Each function returns a figure object and writes no file.
Colors come from champalimaud.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
champalimaud.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 champalimaud/plots.py
network_figure(edges, types, *, height='640px')
¶
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 and larger the more edges it has. |
required |
height
|
str
|
Height of the canvas, as a CSS length. |
"640px"
|
Returns:
| Type | Description |
|---|---|
Network
|
An interactive network. An edge is as wide as its synapse count allows, in the color of its kind. |
See Also
champalimaud.between_types.network_edges : Picks the edges.
Examples:
>>> import polars as pl
>>> edges = pl.DataFrame(
... {
... "src": ["LC16", "X"],
... "dst": ["X", "LC16"],
... "synapses": [900, 40],
... "kind": ["out", "in"],
... }
... )
>>> network = network_figure(edges, ["LC16"])
>>> sorted(network.get_nodes())
['LC16', 'X']
Source code in champalimaud/plots.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 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 | |
plot_neurons(neurons, colors=TYPE_COLORS)
¶
Plot skeletons in 3D, colored by cell type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
neurons
|
sequence of navis.TreeNeuron
|
Named |
required |
colors
|
dict of str to str
|
Color of each type; |
TYPE_COLORS
|
Returns:
| Type | Description |
|---|---|
Figure
|
Drag to rotate, scroll to zoom. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If navis returns no figure. |
Examples:
>>> import pandas as pd
>>> nodes = pd.DataFrame(
... {
... "node_id": [1, 2],
... "parent_id": [-1, 1],
... "x": [0.0, 1.0],
... "y": [0.0, 0.0],
... "z": [0.0, 0.0],
... "radius": [1.0, 1.0],
... }
... )
>>> neuron = navis.TreeNeuron(nodes, name="LC16_1", units="nm")
>>> figure = plot_neurons([neuron])
>>> type(figure).__name__
'Figure'
Source code in champalimaud/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
>>> mass = pl.DataFrame(
... {
... "type": ["LC16", "LC16"],
... "partner_type": ["X", "Y"],
... "synapses": [9, 4],
... }
... )
>>> figure = top_partners_figure(mass, mass, ["LC16"])
>>> len(figure.axes)
2