Code to replicate analyses in Herber et al. 2024
Instructions:
- Download data from the Dryad repository (https://doi.org/10.5061/dryad.8cz8w9h0d) locally and unzip subfolders. Clone this repository.
- Install & update conda. Ensure that Python version 3.8.16 is accessible to conda.
- Create an environment matching the content of the aging MEC environment (conda create --name agingmec --file agingmec_env.txt python = 3.8.16)
- In this environment, run all code in the notebook "Import & Filter MATLAB Data" adjusting paths to match your machine. This will generate a local filtered copy of the neural and behavioral data in Python accessible .npy files. This is a pre-requisite for any additional analysis and takes ~30-40 minutes to run for all sessions across both the Split Maze (SM) and Random Foraging (RF) tasks.
- Run the notebook "Shuffle Procedure" at least through the classification of putative inhibitory interneurons. After that, you have the option of using the output of the rest of the notebook (Dryad repo > shuffle_scores) or generating it yourself. If you would like to regenerate shuffle scores, note that the shuffle procedure required to identify functional cell types (e.g. spatial, grid, non-grid spatial, speed cells) is computationally intensive and/or time- consuming. This is a necessary step before proceeding with neural analyses starting in Figure 2. You may find it helpful to run the shuffle using a cluster.
- To recapitulate results in individual figures except Figure 4, run code in the corresponding Python notebooks using the agingmec env, adjusting paths as needed. It is recommended to run the figures in the following order: Figure 1/S1, Figure S2, Figure 2/S3, Figure 3/S4, Figure 5, Figure S5, Figure 6, and then Figure S6, followed by the Figure 7/8/S8 notebook. In particular, Figure 2/S3 uses Figure S2 outputs; Figure 3/S4 and Figure S5 results depend on Figure 2/S3 outputs; and Figure S5 results depend on Figure 3/S4 and Figure 5 outputs. The Figure 7/8/S8 notebook depends only on Figure 5 outputs.
- To recapitulate results in Figure 4, create an environment matching the context of the LFP world environment (conda create --name LFPworld --file LFPworld_env.txt python = 3.8.16). Then, run the corresponding Jupyter notebook for Figure 4 within that environment.
Important Notes:
A. Several computations, including thresholding against spike time shuffle scores to classify functional cell types (e.g. grid, non-grid spatial, spatial, speed cells) and k-means hyperparameter optimization, rely on randomized functions. This leads to modest stochasticity in results, particularly if users run all code from raw or pre-processed data. We have verified that overall results are not impacted by this stochasticity, though effect sizes and p-values may differ slightly within an order of magnitude (Figures 2/S3, 3/S4/S5, 5, and 6/S6). In particular, if users generate shuffle scores (see Step 4) instead of using the provided shuffle scores, which correspond to the iteration of the shuffle used to generate the results in the paper, users will observe that the exact n of each functional cell type will vary. Similarly, the optimal k to model grid networks' trial by trial spatial firing similarity via k-means clustering will occassionally change with iterations of the hyperparameter optimization procedure in the Figure 3/S4 notebook. As a result, users will reproduce overall results in Figure 3/S4 and Figure S5 with slightly differences in exact n values, odds ratios, p-values, and plots. This is because k is set by a procedure involving repetitations of a randomized cross-validation procedure. If two k values generated very similar average silhouette scores across repetitions, iterations of this procedure may result flip the result one way or another. Importantly, we view this as a feature, rather than a flaw, of our analytic approach because conclusions across the paper are not influenced on the inclusion or exclusion of particular cells or the modeling of particular sessions' network activity one way or another.
B. Code to generate figures addressing requests by peer reviewers pertinent to neural or behavior data that were omitted from the final manuscript is included in this repository. Reviewer Figure 1 related to transcriptomic data, so code to replicate it is not included. Some code is infolded in the notebooks above (annotated as the Reviewer Figure number and brief commentary on the motivation and conclusions the analysis); others are in stand-alone notebooks with a full analysis summary included. In particular, analysis of the impact of the cue tower in the first half of the Split Maze track on context discrimination across age groups (partially included in the paper as Figure S5K, complete in Reviewer Figure 2) is found in the Figure S5 notebook. Analysis of changes in Split Maze reward zone firing rates of grid and non-grid spatial cells over learning (Reviewer Figure 3) is found in the Reviewer Figure 3 notebook, which requires Figure S2 outputs. Most of Reviewer Figure 4 was included as Figure S2 in the paper; omitted panels are in the Figure S2 notebook. Recapitulation of Figure 2 analyses of grid cell spatial firing properties related to Split Maze performance in the larger pool of all MEC spatial cells (Reviewer Figure 5) and with a lower threshold to identify putative grid cells (Reviewer Figure 6A-D) are found in the notebooks named Reviewer Figures 5 and 6, respectively; both notebooks require Figure S2 outputs. Similar recapitulation of Figure S3 results with a lower threshold to identify non-grid spatial cells and Figure 6 results with a lower threshold to identify speed-tuned cells (Reviewer Figure 6E-I) are found in the Reviewer Figure 6 notebook. Reviewer Figure 6 analysis demonstrates that key results are resilient to altered thresholds.