@@ -8,7 +8,7 @@ vignette: >
88 %\VignetteEncoding{UTF-8}
99---
1010
11- ``` {r, include = FALSE}
11+ ``` {r setup , include = FALSE}
1212knitr::opts_chunk$set(
1313 collapse = TRUE,
1414 comment = "#>"
@@ -17,7 +17,7 @@ knitr::opts_chunk$set(
1717
1818Load packages
1919
20- ``` {r}
20+ ``` {r packages }
2121library(nat.ggplot)
2222library(ggplot2)
2323library(dplyr)
@@ -29,7 +29,7 @@ library(dplyr)
2929
3030A minimal 2D view of neuron meshes with a predefined rotation matrix.
3131
32- ``` {r}
32+ ``` {r basic }
3333nat.ggplot::ggneuron(banc.meshes, rotation_matrix = banc_view)
3434```
3535
@@ -39,7 +39,7 @@ nat.ggplot::ggneuron(banc.meshes, rotation_matrix = banc_view)
3939
4040Layer meshes, a brain outline, and smoothed skeletons.
4141
42- ``` {r}
42+ ``` {r brain_and_smooth }
4343# Smooth skeletons for presentation
4444banc.skels_smoothed <- nat::nlapply(banc.skels, nat::smooth_neuron, sigma = 5000)
4545
@@ -72,7 +72,7 @@ nat.ggplot::g.anat +
7272
7373Use ` nat::plot3d() ` and ` rgl ` to rotate interactively, then capture the view. Disabled during build.
7474
75- ``` {r, eval=FALSE}
75+ ``` {r rgl , eval=FALSE}
7676if (requireNamespace("rgl", quietly = TRUE)) {
7777 nat::plot3d(banc.brain_neuropil, alpha = 0.3, col = "grey")
7878 nat::plot3d(banc.skels_smoothed)
@@ -87,7 +87,7 @@ if (requireNamespace("rgl", quietly = TRUE)) {
8787
8888Define rotation matrices and reuse them to render consistent views.
8989
90- ``` {r}
90+ ``` {r views }
9191views <- list(
9292 side = structure(c(0.000764884985983372, 0.0153511334210634,
9393 -0.99988180398941, 0, -0.940421104431152, -0.339961022138596,
@@ -124,7 +124,7 @@ nat.ggplot::ggneuron(
124124
125125Render the neuropil mesh as a translucent context layer.
126126
127- ``` {r}
127+ ``` {r backdrop }
128128nat.ggplot::ggneuron(
129129 banc.brain_neuropil,
130130 rotation_matrix = banc_view,
@@ -139,7 +139,7 @@ nat.ggplot::ggneuron(
139139
140140Single colour, gradient, and per-neuron palettes.
141141
142- ``` {r}
142+ ``` {r single }
143143# Single colour
144144nat.ggplot::g.anat +
145145 nat.ggplot::geom_neuron(
@@ -149,7 +149,7 @@ nat.ggplot::g.anat +
149149 )
150150```
151151
152- ``` {r}
152+ ``` {r gradient }
153153# Gradient along arbour / depth
154154nat.ggplot::g.anat +
155155 nat.ggplot::geom_neuron(
@@ -159,7 +159,7 @@ nat.ggplot::g.anat +
159159 )
160160```
161161
162- ``` {r}
162+ ``` {r multicolour }
163163# Distinct colours per neuron
164164neuron_colours <- c("#FF6B6B", "#4ECDC4", "#45B7D1", "#FFA07A", "#98D8C8")
165165
@@ -183,7 +183,7 @@ nat.ggplot::g.anat +
183183
184184Overlay synaptic sites as points; separate by ` prepost ` (0 = outputs, 1 = inputs).
185185
186- ``` {r}
186+ ``` {r synapses }
187187syns_pre <- dplyr::filter(banc.syns, prepost == 0)
188188syns_post <- dplyr::filter(banc.syns, prepost == 1)
189189
@@ -216,7 +216,7 @@ nat.ggplot::g.anat +
216216
217217Colour compartments using flow-centrality-based identities.
218218
219- ``` {r}
219+ ``` {r flow }
220220# Single neuron
221221nat.ggplot::ggneuron(
222222 banc.neurons.flow[[1]],
@@ -226,7 +226,7 @@ nat.ggplot::ggneuron(
226226)
227227```
228228
229- ``` {r}
229+ ``` {r many_flow }
230230# Multiple neurons (with optional brain volume)
231231nat.ggplot::ggneuron(
232232 banc.neurons.flow,
@@ -243,7 +243,7 @@ nat.ggplot::ggneuron(
243243
244244Compute a bounding box in the rotated plane; zoom with ` ggplot2::coord_fixed() ` .
245245
246- ``` {r}
246+ ``` {r bounded }
247247mesh_bounds <- do.call(rbind, lapply(banc.meshes, function(mesh) {
248248 vertices <- t(mesh$vb[-4, ])
249249 if (!is.null(banc_view)) {
0 commit comments