This tutorial demonstrates population-level analysis of
processed fiber photometry dopamine data from juvenile songbirds. The
analysis examines temporal dynamics, amplitude shifts, and information
flow patterns across multiple animals using the VNS
package.
Install Required Packages
Load the population data created from the data processing and individual analysis pipeline.
This guide demonstrates how to generate population-level data by processing individual animal and combining them into a unified dataset. The workflow consists of four main steps:
For each animal, we calculate specific TD metrics (e.g., conditional entropy(cH))
B633_res <- npm |>
create_segment_table(region ="reg0",
window = c(-0.4, 0.4),
n_segments= 4,
min_epoch = 50) |>
analyze_directional_cH(source_seg = 1, target_seg = 4,
output ="data.frame")
Apply the same analysis pipeline to each animal in the dataset. This ensures consistent processing and comparable results across subjects.
Pool all individual animal results into a single data frame. ‘combine_animal_results’ function: - Merges individual data frames - Adds animal identifiers for tracking - Preserves all computed metrics for population-level analysis
cH_res <- combine_animal_results(
list(B633_res, P568_res, P569_res, R561_res,R562_res),
c("B633", "P568", "P569", "R561", "R562")
)
Population-level analysis of temporal difference learning metrics across vocal development.
Linear mixed-effects models (LMMs) showing developmental trajectories of dopamine transient characteristics (n = 49 observations from 5 birds, 63-91 dph). Median peak timing decreases with development (top-left). Backward shift rate increases with development (top-right). Temporal entropy decreases with development (lower-left). Gini coefficient increases with development (lower-right).
Each colored dot represents the
mean value for one animal at a given age, with colors indicating
individual animals.
Black lines show population-level fixed effects from LMMs with animal identity as random intercept.
td_res2 <- analyze_within_window_trends(temporal_shift_res,
test_method = "both",
window_size = 6,
plot_results = FALSE)
Paired comparison of temporal discrimination metrics between the first day (Day i) and last day (Day i + 6) of 6-day sliding windows across the experimental period. Median peak timing significantly decreased within windows (top-left).
Backward shift rate significantly increased within windows (top-right). Temporal entropy showed no significant change within windows (lower-left). Gini coefficient showed no significant change within windows (lower-right).
plot_paired_metric_panel(td_res2, window_size = 6,
metric_order = c("peak_timing","backward_shift", "entropy", "gini"),
ncol = 2)
Gray lines connect paired
observations from individual animals within the same temporal window (n
= 57 paired observations from 5 birds across 24 windows).
Red lines and symbols indicate group means ± SEM.
Population analysis of amplitude shift pattern across all animals.
Early peak amplitude showed no significant developmental change across the population (left). Late peak amplitude significantly decreased with development (middle). Early/late amplitude ratio significantly increased across development (right).
Individual animals shown in
different colors with fitted regression lines.
td_res4 <- analyze_within_window_trends2(amplitude_within_window_res,
model ="mixed_effects",
test_method = "both",
window_size = 6,
plot_results = FALSE)
Population-level within-window paired analysis using mixed-effects models across 6-day sliding windows.
Early amplitude showed no significant within-window change (left). Late amplitude decreased significantly within windows (middle). Amplitude ratio increased significantly within windows (right).
Points: individual
observations colored by animal
Gray lines: individual observations within each window (animal × window combinations).
Colored lines: mean trajectory for each animal across all windows.
Black line with ribbon: population-level trend with 95% confidence interval from fixed effects.
Population analysis of directional conditional entropy across all animals.
Forward conditional entropy significantly decreased with development (left), indicating population-level improvement in predictive capability from early to late temporal events.Backward conditional entropy showed no significant developmental change (middle). Prediction asymmetry significantly increased across development (right), with crossover from backward to forward dominance predicted at 66.2 dph.
Individual animals shown in
different colors with fitted regression lines.
td_res6 <- analyze_within_window_info_flow(cH_within_window_res,
model ="mixed_effects",
window_size = 6,
plot_results = FALSE)
Population-level within-window paired analysis using mixed-effects models across 6-day sliding windows.
Forward entropy decreased significantly within windows (left), indicating improved forward predictability. Backward entropy showed no significant within-window change (middle). Prediction asymmetry increased significantly within windows (right), demonstrating a shift toward forward prediction dominance.
Points: individual
observations colored by animal.
Gray lines: individual observations within each window (animal × window combinations).
Colored lines: mean trajectory for each animal across all windows.
Black line with ribbon: population-level trend with 95% confidence interval from fixed effects.
# Get all object names in the global environment
all_objects <- ls()
# Find objects that start with "td"
td_objects <- all_objects[grepl("^td", all_objects)]
# Save objects starting with "td" to results.rda
save(list = td_objects, file = "./data/results.rda")
# To review the results in a new session load("./data/results.rda")
This population analysis:
## R version 4.4.1 (2024-06-14)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 24.04.2 LTS
##
## Matrix products: default
## BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so; LAPACK version 3.12.0
##
## locale:
## [1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8
## [4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8
## [7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C
## [10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C
##
## time zone: UTC
## tzcode source: system (glibc)
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## loaded via a namespace (and not attached):
## [1] digest_0.6.37 R6_2.6.1 fastmap_1.2.0 xfun_0.52
## [5] cachem_1.1.0 knitr_1.50 htmltools_0.5.8.1 rmarkdown_2.29
## [9] lifecycle_1.0.4 cli_3.6.5 sass_0.4.10 jquerylib_0.1.4
## [13] compiler_4.4.1 tools_4.4.1 evaluate_1.0.4 bslib_0.9.0
## [17] yaml_2.3.10 rlang_1.1.6 jsonlite_2.0.0