OSCR

Medial entorhinal-hippocampal desynchronization parallels the emergence of memory impairment in a mouse model of Alzheimer's disease pathology.

Code ↔ Paper

14 matches between paragraphs of the paper and lines of its authors' code, computed by the harvester (lexical-v1). Click a colored paragraph or line to see its counterpart.

The 14 matches · 4 of them tie a paragraph to a whole file, not to given lines: weak matches, whose lines are not tinted
  1. [1] § EXPERIMENTAL MODEL AND STUDY PARTICIPANT DETAILS › METHOD DETAILS › Analysis of local field potential and single-unit data ↔ externalPackages/FMAToolbox/Analyses/FilterLFP.m, the whole file · a weak match · score 0.74 · 10–20 cm, filtered LFPs, local field potential, frequency band, MATLAB, theta
  2. [2] § RESULTS › Reduced hippocampal theta power emerges between 6 and 8 months of age in 3xTg mice ↔ LFP_Analysis/Coherence/coherency_allregions_multi_drift.m, lines 145–222 · score 0.73 · 30–50 Hz, 90–130 Hz, Fast gamma, slow gamma, 90 Hz, theta
  3. [3] § RESULTS › Reduced hippocampal theta power emerges between 6 and 8 months of age in 3xTg mice ↔ LFP_Analysis/Coherence/coherency_allregions_multi_drift_byspeed.m, lines 147–228 · score 0.73 · 30–50 Hz, 90–130 Hz, Fast gamma, slow gamma, 90 Hz, theta
  4. [4] § EXPERIMENTAL MODEL AND STUDY PARTICIPANT DETAILS › METHOD DETAILS › Analysis of local field potential and single-unit data ↔ All Code and Data to Generate Plots and Stats/Vetere_2026_AllPlotsAndStats.Rmd, lines 3629–3711 · score 0.71 · Unit LFP frequency, spike train frequency, theta LFP frequency, precession, speeds, CA1
  5. [5] § EXPERIMENTAL MODEL AND STUDY PARTICIPANT DETAILS › METHOD DETAILS › Analysis of local field potential and single-unit data ↔ LFP_Analysis/Coherence/coherency_test_all_regions_multi_drift_bylyr_noweighting.m, lines 1–37 · score 0.63 · coherency function, Chronux, chosen, concatenated, bins, LFP
  6. [6] § EXPERIMENTAL MODEL AND STUDY PARTICIPANT DETAILS › METHOD DETAILS › Virtual reality training ↔ preprocessing/metadata/BWMetadataSystem/bz_SessionMetadataTextTemplate.m, lines 35–116 · score 0.60 · motion tracker, linear track, surgery, weight, animals
  7. [7] § EXPERIMENTAL MODEL AND STUDY PARTICIPANT DETAILS › METHOD DETAILS › Analysis of local field potential and single-unit data ↔ externalPackages/FMAToolbox/FMAToolbox.m, the whole file · a weak match · score 0.56 · phase precession, place cells, cutting, behavior, neurons, LFP
  8. [8] § EXPERIMENTAL MODEL AND STUDY PARTICIPANT DETAILS › METHOD DETAILS › Analysis of local field potential and single-unit data ↔ externalPackages/CircularStats/circ_plot.m, the whole file · a weak match · score 0.56 · circular statistics toolbox, resultant vector, MATLAB
  9. [9] § EXPERIMENTAL MODEL AND STUDY PARTICIPANT DETAILS › METHOD DETAILS › Headbar surgery ↔ preprocessing/metadata/BWMetadataSystem/bz_AnimalMetadataTextTemplate.m, lines 34–77 · score 0.54 · skin, anesthetized, isoflurane, carprofen, kg, subcutanerously
  10. [10] § RESULTS › Spatial memory impairments emerge between 6 and 8 months of age in 3xTg mice ↔ All Code and Data to Generate Plots and Stats/Vetere_2026_AllPlotsAndStats.Rmd, lines 916–1037 · score 0.54 · amyloid plaques, way ANOVA, subiculum, Sex, Genotype, immunohistochemistry
  11. [11] § EXPERIMENTAL MODEL AND STUDY PARTICIPANT DETAILS › QUANTIFICATION AND STATISTICAL ANALYSIS ↔ All Code and Data to Generate Plots and Stats/Vetere_2026_AllPlotsAndStats.Rmd, lines 3355–3426 · score 0.53 · Watson Williams, equal kappa, Kuiper, mu, circular, Genotypes
  12. [12] § RESULTS › Progressive disruptions in hippocampal phase locking in 3xTg mice ↔ Single_Unit_Analysis/HIPP_SpikeProcessing_LV_all_2023_V3_Aonly.m, lines 84–126 · score 0.52 · DG units, CA1 units, phase locking, broader, waveforms, layer
  13. [13] § EXPERIMENTAL MODEL AND STUDY PARTICIPANT DETAILS › METHOD DETAILS › Analysis of local field potential and single-unit data ↔ Single_Unit_Analysis/SingleUnitProcessing.m, lines 52–74 · score 0.52 · background subtracted, Phy, Kilosort, clusters, waveform, animal
  14. [14] § RESULTS › Progressive disruptions in hippocampal phase locking in 3xTg mice ↔ externalPackages/FMAToolbox/FMAToolbox.m, the whole file · a weak match · score 0.51 · Phase precession, place cells, firing rates, detection, neurons, LFP

Paper

Loaded from Europe PMC by your browser, not stored by OSCR: doi.org · Europe PMC

The paper is loaded when this pane is shown.

The authors' code

R Markdown · 4,284 lines · 172 KB · GPL-3.0 · 3 matches

  1. ---
  2. title: "Vetere_2026_AllPlotsAndStats_V2"
  3. output: word_document
  4. date: "2026-05-03"
  5. ---
  6. ```{r setup, echo=FALSE, warning=FALSE}
  7. # load libraries and set up color palettes and general functions
  8. library(readxl)
  9. library(data.table)
  10. library(dplyr)
  11. library(tidyverse)
  12. library(plyr)
  13. library(plotrix)
  14. library(car)
  15. library(broom)
  16. library(reshape2)
  17. library(RColorBrewer)
  18. library(writexl)
  19. library(multcomp)
  20. library(emmeans)
  21. library(ez)
  22. library(rstatix)
  23. library(lme4)
  24. library(lmtest)
  25. library(lmerTest)
  26. library(circular)
  27. library(rlang)
  28. library(twosamples)
  29. library(kuiper.2samp)
  30. library(ggforce)
  31. library(ggbeeswarm)
  32. library(R.matlab)
  33. library(pracma)
  34. library(knitr)
  35. scale_fill_palette = c(
  36. "6wt" = "#509FE9",
  37. "8wt" ="#355CA7",
  38. "63x" ="#de9cbf",
  39. "83x" ="#AE86B6"
  40. )
  41. scale_colour_palette = c(
  42. "6wt" = "#509FE9",
  43. "8wt" ="#355CA7",
  44. "63x" = "#de9cbf",
  45. "83x" ="#AE86B6"
  46. )
  47. scale_fill_palette_6mo = c(
  48. "WT" = "#509FE9",
  49. "3xTg" ="#de9cbf"
  50. )
  51. scale_colour_palette_6mo = c(
  52. "WT" = "#509FE9",
  53. "3xTg" ="#de9cbf"
  54. )
  55. scale_colour_palette_8mo = c(
  56. "WT" ="#355CA7",
  57. "3xTg" ="#AE86B6"
  58. )
  59. scale_fill_palette_8mo = c(
  60. "WT" ="#355CA7",
  61. "3xTg" ="#AE86B6"
  62. )
  63. ################
  64. AnyPlotbygroupandsex_adjaxis_facet <- function(df, y, title, ytitle, ymin, ymax) { # ymin =0, ymax=50){
  65. plot <-ggplot(df ,aes(x=Genotype, y={{y}}))
  66. plot +geom_sina(aes(col= Group_name, shape = Sex), alpha = 0.5, na.rm = TRUE, show.legend=TRUE, jitter_y = FALSE) +
  67. geom_bar(position= "dodge", stat = "summary", width = 0.9, fun.y = "mean", alpha = 0.4, aes(fill=Group_name), color = 'black') +
  68. stat_summary( color = "black", fun.data = mean_se, geom = "errorbar", width = 0.4, alpha = 0.8, show.legend=FALSE) +
  69. ggtitle(title) + ylab(ytitle) +
  70. scale_fill_manual("legend", values = scale_fill_palette, guide = "none")+
  71. scale_color_manual("legend", values = scale_colour_palette, guide = "none")+
  72. scale_y_continuous(expand = c(0,0)) +
  73. coord_cartesian(ylim=c(ymin, ymax))+
  74. scale_alpha(guide = 'none') +
  75. facet_grid(.~Age, switch = "x", labeller = as_labeller(c('6' = "6 mo", '8' = "8 mo"))) +
  76. theme(plot.title = element_text(hjust = 0.5, size = 22, face = "bold"),
  77. axis.text.x = element_text(size = 16, colour = "black"),
  78. axis.text.y = element_text(size = 18, face="bold", colour = "black"),
  79. axis.title.y = element_text(size = 20, face = "bold", colour = "black"),
  80. axis.title.x = element_blank(),
  81. legend.text=element_text(size=16),
  82. legend.title=element_text(size=18),
  83. panel.grid.major = element_blank(),
  84. panel.grid.minor = element_blank(),
  85. panel.background = element_blank(),
  86. axis.line = element_line(colour = "black"),
  87. strip.text.x = element_text(size = 18, face = "bold"),
  88. strip.background = element_rect( fill="white"),
  89. panel.spacing.x = unit(1.4, "lines"),
  90. strip.placement = "outside")
  91. }
  92. General_AOVbyanim_ez <- function(data, y, agevar, subjectvar) {
  93. avar <- substitute(agevar)
  94. svar <-substitute(subjectvar)
  95. gvar <- substitute(Genotype)
  96. yvar <- substitute(y)
  97. df<- substitute(data)
  98. aov <- eval.parent(substitute(ezANOVA(data = df, wid = svar, dv = yvar, between = .(gvar, avar), type = 3, observed = .(gvar, avar), return_aov=TRUE), list(avar = avar, gvar=gvar, svar = svar, yvar=yvar, df=df)))
  99. return(aov)
  100. }
  101. #age x genotype posthocs
  102. General_byanim_holm <- function(data, y, agevar) {
  103. avar <- substitute(agevar)
  104. gvar <- substitute(Genotype)
  105. yvar <- substitute(y)
  106. df<- substitute(data)
  107. formula <-substitute(yvar ~ avar * gvar, list(yvar=yvar, avar=avar, gvar = gvar))
  108. model <-eval.parent(substitute(aov(fm, data=df), list(fm=formula, df=df)))
  109. anova <- eval.parent(substitute(aov(fm, data=df), list(fm=formula, df=df))) %>% summary()
  110. emmtest <- eval.parent(emmeans(model, ~ Genotype * Age_Broad))
  111. #posthoc_genotype <- pairs(emmtest, simple = "Genotype") %>%
  112. #rbind() %>%
  113. #summary(adjust = "holm")
  114. #posthoc_age <- pairs(emmtest, simple = "Age_Broad") %>%
  115. #rbind() %>%
  116. #summary(adjust = "holm")
  117. #posthoc_all <- pairs(emmtest) %>%
  118. #rbind() %>%
  119. #summary(adjust = 'holm')
  120. posthoc_all2 <- rbind(pairs(emmtest, simple = "Age_Broad") , pairs(emmtest, simple = "Genotype")) %>% summary(adjust ="holm")
  121. outlist <-list(posthoc_all2)
  122. return(outlist)
  123. }
  124. General_byanim_holm_sex <- function(data, y, sexvar) {
  125. svar <- substitute(sexvar)
  126. gvar <- substitute(Genotype)
  127. yvar <- substitute(y)
  128. df<- substitute(data)
  129. formula <-substitute(yvar ~ svar * gvar, list(yvar=yvar, svar=svar, gvar = gvar))
  130. model <-eval.parent(substitute(aov(fm, data=df), list(fm=formula, df=df)))
  131. #anova <- eval.parent(substitute(aov(fm, data=df), list(fm=formula, df=df))) %>% summary()
  132. emmtest <- eval.parent(emmeans(model, ~ Genotype * Sex))
  133. posthoc_all <- rbind(pairs(emmtest, simple = "Sex") , pairs(emmtest, simple = "Genotype")) %>% summary(adjust ="holm")
  134. outlist <-list(posthoc_all)
  135. return(outlist)
  136. }
  137. General_byanim_holm_protocol <- function(data, y, protvar) {
  138. pvar <- substitute(protvar)
  139. gvar <- substitute(Genotype)
  140. yvar <- substitute(y)
  141. df<- substitute(data)
  142. formula <-substitute(yvar ~ pvar * gvar, list(yvar=yvar, pvar=pvar, gvar = gvar))
  143. model <-eval.parent(substitute(aov(fm, data=df), list(fm=formula, df=df)))
  144. #anova <- eval.parent(substitute(aov(fm, data=df), list(fm=formula, df=df))) %>% summary()
  145. emmtest <- eval.parent(emmeans(model, ~ Genotype * Protocol))
  146. #posthoc_genotype <- pairs(emmtest, simple = "Genotype") %>%
  147. #rbind() %>%
  148. #summary(adjust = "holm")
  149. #posthoc_age <- pairs(emmtest, simple = "Age_Broad") %>%
  150. #rbind() %>%
  151. #summary(adjust = "holm")
  152. #posthoc_all <- pairs(emmtest) %>%
  153. #rbind() %>%
  154. #summary(adjust = 'holm')
  155. posthoc_all2 <- rbind(pairs(emmtest, simple = "Protocol") , pairs(emmtest, simple = "Genotype")) %>% summary(adjust ="holm")
  156. outlist <-list(posthoc_all2)
  157. return(outlist)
  158. }
  159. ################
  160. PowerCohPhaseStats_3way <- function(data, y, agevar, layervar, subjectvar){
  161. #3 way age x genotype x layer anova
  162. #agevar = Age_Broad or Age, layervar = Layer_name or Layername or similar, subject var = Animals, Animalname or similar, y = Coh, Run_thresh_power etc.
  163. avar <- substitute(agevar)
  164. gvar <- substitute(Genotype)
  165. svar <- substitute(subjectvar)
  166. lvar <-substitute(layervar)
  167. yvar <- substitute(y)
  168. df<- substitute(data)
  169. aov <- eval.parent(substitute(ezANOVA(data = df, wid = svar, dv = yvar, within = lvar, between = .(gvar, avar), type = 3, observed = .(gvar, avar, lvar), return_aov=TRUE), list(avar = avar, gvar=gvar, svar = svar, lvar= lvar, yvar=yvar, df=df)))
  170. return(aov)
  171. }
  172. #2 way genotype by layer, input data already subsetted for age
  173. PowerCohPhaseStats_2waygl <- function(data_age, y, layervar, subjectvar){
  174. gvar <- substitute(Genotype)
  175. svar <- substitute(subjectvar)
  176. lvar <-substitute(layervar)
  177. yvar <- substitute(y)
  178. df<- substitute(data_age)
  179. aov <- eval.parent(substitute(ezANOVA(data = df, wid = svar, dv = yvar, within = lvar, between = gvar, type = 3, observed = .(gvar, lvar), return_aov=TRUE), list(gvar=gvar, svar = svar, lvar= lvar, yvar=yvar, df=df)))
  180. return(aov)
  181. }
  182. #2 way layer x age, input data already subsetted for genotype
  183. PowerCohPhaseStats_2wayal <- function(data_genotype, y, agevar, layervar, subjectvar){
  184. #agevar = Age_Broad or Age, layervar = Layer_name or Layername or similar, subject var = Animals, Animalname or similar, y = Coh, Run_thresh_power etc.
  185. avar <- substitute(agevar)
  186. svar <- substitute(subjectvar)
  187. lvar <-substitute(layervar)
  188. yvar <- substitute(y)
  189. df<- substitute(data_genotype)
  190. aov <- eval.parent(substitute(ezANOVA(data = df, wid = svar, dv = yvar, within = lvar, between = .(avar), type = 3, observed = .(avar, lvar), return_aov=TRUE), list(avar = avar, svar = svar, lvar= lvar, yvar=yvar, df=df)))
  191. return(aov)
  192. }
  193. #3 way layer x genotype x sex, input data already subsetted for age
  194. PowerCohPhaseStats_3waygls <- function(data_age, y, layervar, subjectvar){
  195. #agevar = Age_Broad or Age, layervar = Layer_name or Layername or similar, subject var = Animals, Animalname or similar, y = Coh, Run_thresh_power etc.
  196. gvar <- substitute(Genotype)
  197. svar <- substitute(subjectvar)
  198. sexvar <- substitute(Sex)
  199. lvar <-substitute(layervar)
  200. yvar <- substitute(y)
  201. df<- substitute(data_age)
  202. aov <- eval.parent(substitute(ezANOVA(data = df, wid = svar, dv = yvar, within = lvar, between = .(gvar, sexvar), type = 3, observed = .(gvar, lvar, sexvar), return_aov=TRUE), list(gvar = gvar, svar = svar, lvar= lvar, sexvar=sexvar, yvar=yvar, df=df)))
  203. return(aov)
  204. }
  205. Posthocs_byage <- function(data_age, y, layervar){
  206. #is there a difference between genotypes for each layer at the given age?
  207. #agevar = Age_Broad or Age, layervar = Layer_name or Layername or similar, subject var = Animals, Animalname or similar, y = Coh, Run_thresh_power etc.
  208. gvar <- substitute(Genotype)
  209. lvar <-substitute(layervar)
  210. yvar <- substitute(y)
  211. df<- substitute(data_age)
  212. posthoc <- eval.parent(substitute(df %>% dplyr::group_by(lvar) %>% t_test(yvar ~gvar, p.adjust.method = "none") %>% adjust_pvalue(method = "holm"), list(df =df, lvar=lvar, yvar=yvar, gvar=gvar))) #THIS MATCHES PRISM!!
  213. return(posthoc)
  214. }
  215. #Alternate method that can deal with missing data - matches output from graphpad prism
  216. MECthetastats <- function(MECtheta_age_df) {
  217. df = substitute(MECtheta_age_df)
  218. avar = substitute(Age_Broad)
  219. gvar = substitute(Genotype)
  220. lvar = substitute(Layer_name)
  221. svar = substitute(animals)
  222. yvar = substitute(Run_thresh_power)
  223. #2 way
  224. fm <- substitute(yvar ~ gvar *lvar + (1|svar), list(yvar=yvar, gvar= gvar, svar=svar, lvar=lvar))
  225. model<- eval.parent(substitute(lmer(fm , REML = T, data = df), list(fm = fm, df =df)))
  226. lm <- eval.parent(substitute(lmer(fm , REML = T, data = df), list(fm = fm, df =df))) %>% summary()
  227. lm_aov <- eval.parent(substitute(lmer(fm, REML = T, data=df), list(fm=fm, df=df))) %>% anova()
  228. emmtest <- eval.parent(emmeans(model, ~ Genotype * Layer_name))
  229. posthoc_emmeans <- pairs(emmtest, simple = "Genotype") %>%
  230. rbind() %>%
  231. summary(adjust = "bonferroni")
  232. posthoc_ttest <- eval.parent(substitute(df %>% dplyr::group_by(lvar) %>% t_test(yvar ~gvar, p.adjust.method = "none") %>% adjust_pvalue(method = "bonferroni"), list(df =df, lvar=lvar, yvar=yvar, gvar=gvar)))
  233. outlist <-list(lm, lm_aov, posthoc_emmeans, posthoc_ttest)
  234. return(outlist)
  235. }
  236. #mixed model to account for missing data - ended up using prism for final version?
  237. CSDstats <- function(CSD_age_df) {
  238. df = substitute(CSD_age_df)
  239. avar = substitute(Age_Broad)
  240. gvar = substitute(Genotype)
  241. lvar = substitute(Layer)
  242. svar = substitute(Animal)
  243. yvar = substitute(Value)
  244. #2 way
  245. fm <- substitute(yvar ~ gvar *lvar + (1|svar), list(yvar=yvar, gvar= gvar, svar=svar, lvar=lvar))
  246. model<- eval.parent(substitute(lmer(fm , REML = T, data = df), list(fm = fm, df =df)))
  247. lm <- eval.parent(substitute(lmer(fm , REML = T, data = df), list(fm = fm, df =df))) %>% summary()
  248. lm_aov <- eval.parent(substitute(lmer(fm, REML = T, data=df), list(fm=fm, df=df))) %>% anova()
  249. emmtest <- eval.parent(emmeans(model, ~ Genotype * Layer))
  250. posthoc_emmeans <- pairs(emmtest, simple = "Genotype") %>%
  251. rbind() %>%
  252. summary(adjust = "holm")
  253. posthoc_ttest <- eval.parent(substitute(df %>% dplyr::group_by(lvar) %>% t_test(yvar ~gvar, p.adjust.method = "none") %>% adjust_pvalue(method = "holm"), list(df =df, lvar=lvar, yvar=yvar, gvar=gvar)))
  254. outlist <-list(lm, lm_aov, posthoc_emmeans, posthoc_ttest)
  255. return(outlist)
  256. }
  257. #
  258. CSDstats_3way <- function(CSD_age_df) {
  259. df = substitute(CSD_age_df)
  260. sexvar = substitute(Sex)
  261. gvar = substitute(Genotype)
  262. lvar = substitute(Layer)
  263. svar = substitute(Animal)
  264. yvar = substitute(Value)
  265. #3 way
  266. fm <- substitute(yvar ~ gvar * sexvar *lvar + (1|svar), list(yvar=yvar, gvar= gvar, sexvar = sexvar, svar=svar, lvar = lvar))
  267. model<- eval.parent(substitute(lmer(fm , REML = T, data = df), list(fm = fm, df =df)))
  268. lm <- eval.parent(substitute(lmer(fm , REML = T, data = df), list(fm = fm, df =df))) %>% summary()
  269. lm_aov <- eval.parent(substitute(lmer(fm, REML = T, data=df), list(fm=fm, df=df))) %>% anova()
  270. outlist <-list(lm, lm_aov)
  271. return(outlist)
  272. }
  273. ################
  274. #for r values and firing rates
  275. Singleunit_nonparametric <- function(celltype, y){
  276. #CALCULATE P VALS CORRECTED FOR MULTIPLE COMPARISONS
  277. df <- substitute(celltype)
  278. y <- substitute(y)
  279. yvar <- substitute(df$y, list(y=y, df = df))
  280. gvar <- substitute(Genotype)
  281. grpvar <-substitute(Groupname)
  282. xvar <- substitute(df$x, list(x=grpvar, df = df))
  283. wilcox <- eval.parent(substitute(pairwise_wilcox_test(df, y~grpvar, p.adjust.method="holm", comparisons = list(c("63x", "6wt"), c("83x", "8wt"), c("6wt", "8wt"), c("63x", "83x"))), list(y = y, grpvar = grpvar, df = df)))
  284. return(wilcox)
  285. }
  286. #circular statistics for firing phase/mu values
  287. Circstats_full <- function(celltype_6, celltype_8, y, celltype_6_WT, celltype_6_Tg, celltype_8_WT, celltype_8_Tg){
  288. #CALCULATE P VALS CORRECTED FOR MULTIPLE COMPARISONS
  289. df <- substitute(celltype)
  290. df6 <- substitute(celltype_6)
  291. df8 <- substitute(celltype_8)
  292. WT6data <-substitute(celltype_6_WT)
  293. Tg6data <- substitute(celltype_6_Tg)
  294. WT8data <-substitute(celltype_8_WT)
  295. Tg8data <- substitute(celltype_8_Tg)
  296. y <- substitute(y)
  297. yvar <- substitute(df$y, list(y=y, df = df))
  298. yvar6 <- substitute(df6$y, list(y=y, df6 = df6))
  299. yvar8 <- substitute(df8$y, list(y=y, df8 = df8))
  300. gvar <- substitute(Genotype)
  301. xvar <- substitute(df$x, list(x=gvar, df = df))
  302. xvar6 <- substitute(df6$x, list(x=gvar, df6 = df6))
  303. xvar8 <- substitute(df8$x, list(x=gvar, df8 = df8))
  304. #kuiper test - is anything different about these distributions? (Not sure about this)
  305. kuiper_6 <- eval.parent(substitute(kuiper_test(Tg6data$y, WT6data$y), list(y = y, Tg6data = Tg6data, WT6data = WT6data)))
  306. #equal kappa test - are concentration parameters different?
  307. equalkappa_6 <- eval.parent(substitute(equal.kappa.test(yvar6, xvar6), list(yvar6=yvar6, xvar6=xvar6)))
  308. #watson williams - are means different?
  309. watwill_6 <- eval.parent(substitute(watson.williams.test(yvar6, xvar6), list(yvar6=yvar6, xvar6=xvar6)))
  310. #watson wheeler - are distribution of angles different? unclear if this is the same as watson williams? non-parametric?
  311. watwheel_6 <-eval.parent(substitute(watson.wheeler.test(yvar6, xvar6), list(yvar6=yvar6, xvar6=xvar6)))
  312. aovcirc_6 <- eval.parent(substitute(aov.circular(yvar6, xvar6), list(yvar6=yvar6, xvar6=xvar6)))
  313. #kuiper test - is anything different about these distributions? (Not sure about this)
  314. kuiper_8 <- eval.parent(substitute(kuiper_test(Tg8data$y, WT8data$y), list(y = y, Tg8data = Tg8data, WT8data = WT8data)))
  315. #equal kappa test - are concentration parameters different?
  316. equalkappa_8 <- eval.parent(substitute(equal.kappa.test(yvar8, xvar8), list(yvar8=yvar8, xvar8=xvar8)))
  317. #watson williams - are means different?
  318. watwill_8 <- eval.parent(substitute(watson.williams.test(yvar8, xvar8), list(yvar8=yvar8, xvar8=xvar8)))
  319. #watson wheeler - are distribution of angles different? unclear if this is the same as watson williams? non-parametric?
  320. watwheel_8 <-eval.parent(substitute(watson.wheeler.test(yvar8, xvar8), list(yvar8=yvar8, xvar8=xvar8)))
  321. aovcirc_8 <- eval.parent(substitute(aov.circular(yvar8, xvar8), list(yvar8=yvar8, xvar8=xvar8)))
  322. kuiper_pvals <- c(kuiper_6[[2]], kuiper_8[[2]]) %>% p.adjust(method = 'bonferroni')
  323. equalkappa_pvals <- c(equalkappa_6[[7]], equalkappa_8[[7]]) %>% p.adjust(method = 'bonferroni')
  324. watwill_pvals <- c(watwill_6[[4]], watwill_8[[4]]) %>% p.adjust(method = 'bonferroni')
  325. watwheel_pvals <- c(watwheel_6[[4]], watwheel_8[[4]]) %>% p.adjust(method = 'bonferroni')
  326. aovcirc_pvals <- c(aovcirc_6[[12]], aovcirc_8[[12]]) %>% p.adjust(method = 'bonferroni')
  327. outlist <- list(kuiper_pvals, equalkappa_pvals, watwill_pvals,
  328. watwheel_pvals,aovcirc_pvals)
  329. return(outlist)
  330. }
  331. ################
  332. Bar_graph_t_tests <- function(df, y, agevar) {
  333. df = substitute(df)
  334. yvar = substitute(y)
  335. gvar = substitute(Genotype)
  336. avar = substitute(agevar)
  337. genotype <- eval.parent(substitute(df %>% dplyr::group_by(avar) %>% t_test(yvar ~gvar, p.adjust.method = "none"), list(df =df, yvar=yvar, gvar=gvar, avar=avar)))
  338. age <- eval.parent(substitute(df %>% dplyr::group_by(gvar) %>% t_test(yvar ~avar, p.adjust.method = "none"), list(df =df, yvar=yvar, gvar=gvar, avar=avar)))
  339. #
  340. posthoc_all <- bind_rows(genotype, age) %>% adjust_pvalue(method = "holm")
  341. posthoc_all <- posthoc_all[,-c(2)]
  342. outlist <- list( posthoc_all)
  343. return(outlist)
  344. }
  345. knitr::opts_chunk$set(dpi=300,fig.width=7, warning = FALSE, echo = FALSE)
  346. ```
  347. # Behavior
  348. ## Novel Object Location (Main Figure 1)
  349. ```{r behavior, echo=FALSE, warning = FALSE}
  350. #STILL NEED TO CHECK
  351. #BEHAVIOR
  352. #load data
  353. rawdata <- read_xlsx("NOL_Table_020826_forR_All.xlsx")
  354. #put WT first so it gets plotted on the left
  355. rawdata$Genotype = factor(rawdata$Genotype, levels = c('WT', '3xTg'))
  356. rawdata$Age_Group = factor(rawdata$Age_Group, levels = c('6', '8'))
  357. rawdata <- mutate(rawdata, group = case_when(Genotype == 'WT' & Age_Group == '6' ~ 'WT6',
  358. Genotype == '3xTg' & Age_Group == '6' ~ '3xTg6',
  359. Genotype == 'WT' & Age_Group == '8' ~ 'WT8',
  360. Genotype == '3xTg' & Age_Group == '8' ~ '3xTg8'))
  361. rawdata <- mutate(rawdata, group2 = case_when(Genotype == 'WT'~ 'WT',
  362. Genotype == '3xTg' & Age_Group == '6' ~ '3xTg6',
  363. Genotype == '3xTg' & Age_Group == '8' ~ '3xTg8'))
  364. rawdata <- mutate(rawdata, Protocol = as.factor(Protocol)) #don't treat protocol as numeric
  365. rawdata <-mutate(rawdata, Age_Broad = Age_Group) #create duplicate variable called Age_Broad to get along with all functions
  366. rawdata$Age_Broad= factor(rawdata$Age_Broad, levels = c('6', '8'))
  367. rawdata_P2<-subset(rawdata,Protocol == 2)
  368. rawdata_P2_8mo<-subset(rawdata_P2,Age_Group == 8)
  369. rawdata_P1 <-subset(rawdata, Protocol == 1)
  370. rawdata_P1_6mo <-subset(rawdata_P1, Age_Group == 6)
  371. #Plot 6 month data protocol 1
  372. plot <-ggplot(rawdata_P1_6mo ,aes(x=Genotype, y=NOL_Score)) #Test_Score_Original_20s
  373. behavior_6moP1 <- plot +geom_sina(aes(col= Genotype, shape = Sex), position = position_jitter(width = 0.2), alpha = 0.5, na.rm = TRUE, show.legend=TRUE, jitter_y = FALSE, maxwidth = 0.4, scale = 'width') +
  374. geom_bar(position= "dodge", stat = "summary", width = 0.9, fun = "mean", alpha = 0.4, aes(fill=Genotype), colour = "black") +
  375. stat_summary(fun.data = mean_se, geom = "errorbar", width = 0.4, alpha = 1, show.legend=FALSE, colour = "black") +
  376. geom_hline(yintercept = 0.5, linetype = "dotted", color = "black") +
  377. ggtitle("Novel Object Location \n 6 mo") + ylab('Novel/Total Exploration') +
  378. scale_fill_manual("legend", values = scale_fill_palette_6mo, labels = c("WT", "3xTg"))+
  379. guides(fill=guide_legend("Genotype"), guide = "none") +
  380. scale_color_manual("legend", values = scale_colour_palette_6mo, guide = "none")+
  381. #scale_color_manual(values = c("#509FE9", "#de9cbf"))+
  382. scale_y_continuous(expand = c(0,0), limits = c(0, 1.1)) + #, limits = c(ymin,ymax), breaks = seq(0, 14, by = 2))+
  383. scale_alpha(guide = 'none') +
  384. #facet_grid(.~Age_Group, switch = "x", labeller = as_labeller(c('6' = "6 mo", '8' = "8 mo"))) +
  385. theme(plot.title = element_text(hjust = 0.5, size = 22, face = "bold"),
  386. axis.text.x = element_text(size = 18, colour = "black"),
  387. #axis.text.x = element_blank(),
  388. #axis.ticks.x=element_blank(),
  389. axis.text.y = element_text(size = 18, face="bold", colour = "black"),
  390. axis.title.y = element_text(size = 20, face = "bold", colour = "black"),
  391. axis.title.x = element_blank(),
  392. legend.text=element_text(size=16),
  393. legend.title=element_text(size=18),
  394. panel.grid.major = element_blank(),
  395. panel.grid.minor = element_blank(),
  396. panel.background = element_blank(),
  397. axis.line = element_line(colour = "black"),
  398. strip.text.x = element_text(size = 18, face = "bold"),
  399. strip.background = element_rect( fill="white"),
  400. panel.spacing.x = unit(1.4, "lines"),
  401. strip.placement = "outside")
  402. #Plot 8 month data protocol 2
  403. plot <-ggplot(rawdata_P2_8mo ,aes(x=Genotype, y=NOL_Score)) #Test_Score_Original_20s
  404. behavior_8moP2 <- plot +geom_sina(aes(col= Genotype, shape = Sex), position = position_jitter(width = 0.2), alpha = 0.5, na.rm = TRUE, show.legend=TRUE, jitter_y = FALSE, maxwidth = 0.4, scale = 'width') +
  405. geom_bar(position= "dodge", stat = "summary", width = 0.9, fun = "mean", alpha = 0.4, aes(fill=Genotype), colour = "black") +
  406. stat_summary(fun.data = mean_se, geom = "errorbar", width = 0.4, alpha = 1, show.legend=FALSE, colour = "black") +
  407. geom_hline(yintercept = 0.5, linetype = "dotted", color = "black") +
  408. ggtitle("Novel Object Location \n 8 mo") + ylab('Novel/Total Exploration') +
  409. scale_fill_manual("legend", values = scale_fill_palette_8mo, labels = c("WT", "3xTg"))+
  410. guides(fill=guide_legend("Genotype"), guide = "none") +
  411. scale_color_manual("legend", values = scale_colour_palette_8mo, guide = "none")+
  412. #scale_color_manual(values = c("#509FE9", "#de9cbf"))+
  413. scale_y_continuous(expand = c(0,0), limits = c(0, 1.1)) + #, limits = c(ymin,ymax), breaks = seq(0, 14, by = 2))+
  414. scale_alpha(guide = 'none') +
  415. #facet_grid(.~Age_Group, switch = "x", labeller = as_labeller(c('6' = "6 mo", '8' = "8 mo"))) +
  416. theme(plot.title = element_text(hjust = 0.5, size = 22, face = "bold"),
  417. axis.text.x = element_text(size = 18, colour = "black"),
  418. #axis.text.x = element_blank(),
  419. #axis.ticks.x=element_blank(),
  420. axis.text.y = element_text(size = 18, face="bold", colour = "black"),
  421. axis.title.y = element_text(size = 20, face = "bold", colour = "black"),
  422. axis.title.x = element_blank(),
  423. legend.text=element_text(size=16),
  424. legend.title=element_text(size=18),
  425. panel.grid.major = element_blank(),
  426. panel.grid.minor = element_blank(),
  427. panel.background = element_blank(),
  428. axis.line = element_line(colour = "black"),
  429. strip.text.x = element_text(size = 18, face = "bold"),
  430. strip.background = element_rect( fill="white"),
  431. panel.spacing.x = unit(1.4, "lines"),
  432. strip.placement = "outside")
  433. ggsave(
  434. "NOL_6moP1.svg",
  435. behavior_6moP1,
  436. width = 4,
  437. height = 5,
  438. dpi = 600
  439. )
  440. ggsave(
  441. "NOL_8moP2.svg",
  442. behavior_8moP2,
  443. width = 4,
  444. height = 5,
  445. dpi = 600
  446. )
  447. behavior_6moP1
  448. behavior_8moP2
  449. wt_p1 <-subset(rawdata_P1, Genotype == 'WT')
  450. tg_p1 <-subset(rawdata_P1, Genotype == '3xTg')
  451. wt6_p1 <-subset(rawdata_P1, Age_Group ==6 & Genotype == 'WT')
  452. wt8_p1 <-subset(rawdata_P1, Age_Group ==8 & Genotype == 'WT')
  453. tg6_p1 <-subset(rawdata_P1, Age_Group ==6 & Genotype == '3xTg')
  454. tg8_p1 <-subset(rawdata_P1, Age_Group ==8 & Genotype == '3xTg')
  455. wt_p2 <-subset(rawdata_P2, Genotype == 'WT')
  456. tg_p2 <-subset(rawdata_P2, Genotype == '3xTg')
  457. wt6_p2 <-subset(rawdata_P2, Age_Group ==6 & Genotype == 'WT')
  458. wt8_p2 <-subset(rawdata_P2, Age_Group ==8 & Genotype == 'WT')
  459. tg6_p2 <-subset(rawdata_P2, Age_Group ==6 & Genotype == '3xTg')
  460. tg8_p2 <-subset(rawdata_P2, Age_Group ==8 & Genotype == '3xTg')
  461. WT_P1_P2 <-subset(rawdata, Genotype == "WT")
  462. Tg_P1_P2 <-subset(rawdata, Genotype == "3xTg")
  463. P1_P2_6mo <-subset(rawdata, Age_Group == 6)
  464. P1_P2_8mo <-subset(rawdata, Age_Group == 8)
  465. WT_P1_P2_6mo <- subset(rawdata, Age_Group == 6)
  466. Tg_P1_P2_6mo <- subset(rawdata, Age_Group == 6)
  467. WT_P1_P2_8mo <- subset(rawdata, Age_Group == 8)
  468. Tg_P1_P2_8mo <- subset(rawdata, Age_Group == 8)
  469. print("T test at 6 mo - WT vs 3xTg")
  470. t.test(NOL_Score~Genotype, data = rawdata_P1_6mo)
  471. print("T test at 8 mo - WT vs 3xTg")
  472. t.test(NOL_Score ~Genotype, data = rawdata_P2_8mo)
  473. print("Behavior different from chance? (by group)")
  474. print("For Main Fig1")
  475. print("WT 6mo P1")
  476. t.test(wt6_p1$NOL_Score, mu = 0.5)
  477. print("3xTg 6mo P1")
  478. t.test(tg6_p1$NOL_Score, mu=0.5)
  479. print("WT 8 mo P2")
  480. t.test(wt8_p2$NOL_Score, mu=0.5)
  481. print("3xTg 8 mo P2")
  482. t.test(tg8_p1$NOL_Score, mu=0.5)
  483. #Sex differences in 8 mo animals?
  484. print("Sex Diffs? ")
  485. General_AOVbyanim_ez(rawdata_P2_8mo, NOL_Score, Sex, Mouse)
  486. # Plot WT 6 mo vs 8 mo - facet by protocol
  487. plot <-ggplot(WT_P1_P2 ,aes(x=Age_Group, y=NOL_Score))
  488. behavior3 <- plot +geom_sina(aes(col= Age_Group, shape = Sex), position = position_jitter(width = 0.2), alpha = 0.5, na.rm = TRUE, show.legend=TRUE, jitter_y = FALSE, maxwidth = 0.5, scale = 'width') +
  489. geom_bar(position= "dodge", stat = "summary", width = 0.9, fun = "mean", alpha = 0.4, aes(fill=Age_Group), colour = "black") +
  490. stat_summary(fun.data = mean_se, geom = "errorbar", width = 0.4, alpha = 1, show.legend=FALSE, colour = "black") +
  491. geom_hline(yintercept = 0.5, linetype = "dotted", color = "black") +
  492. ggtitle("Novel Object Location \n by Protocol - WT") + ylab('Novel/Total Exploration') +
  493. scale_fill_manual(values = c("#509FE9", "#355CA7"), labels = c("6 mo", "8 mo"))+
  494. scale_color_manual( values = c("#509FE9", "#355CA7"), labels = c("6 mo", "8 mo"))+
  495. scale_y_continuous(expand = c(0,0), limits = c(0, 1.1)) + #, limits = c(ymin,ymax), breaks = seq(0, 14, by = 2))+
  496. scale_alpha(guide = 'none') +
  497. labs(color = "Age", fill = "Age") +
  498. scale_x_discrete(labels = c("6 mo", "8 mo")) +
  499. facet_grid(.~Protocol, switch = "x", labeller = as_labeller(c('1' = "Protocol 1", '2' = "Protocol 2"))) +
  500. theme(plot.title = element_text(hjust = 0.5, size = 22, face = "bold"),
  501. axis.text.x = element_text(size = 18, colour = "black"),
  502. #axis.text.x = element_blank(),
  503. #axis.ticks.x=element_blank(),
  504. axis.text.y = element_text(size = 18, face="bold", colour = "black"),
  505. axis.title.y = element_text(size = 20, face = "bold", colour = "black"),
  506. axis.title.x = element_blank(),
  507. legend.text=element_text(size=16),
  508. legend.title=element_text(size=18),
  509. panel.grid.major = element_blank(),
  510. panel.grid.minor = element_blank(),
  511. panel.background = element_blank(),
  512. axis.line = element_line(colour = "black"),
  513. strip.text.x = element_text(size = 18, face = "bold"),
  514. strip.background = element_rect( fill="white"),
  515. panel.spacing.x = unit(1.4, "lines"),
  516. strip.placement = "outside")
  517. # Plot Tg Protocol 1 vs. Protocol 2
  518. plot <-ggplot(Tg_P1_P2 ,aes(x=Age_Group, y=NOL_Score))
  519. behavior4 <- plot +geom_sina(aes(col= Age_Group, shape = Sex), position = position_jitter(width = 0.2), alpha = 0.5, na.rm = TRUE, show.legend=TRUE, jitter_y = FALSE, maxwidth = 0.5, scale = 'width') +
  520. geom_bar(position= "dodge", stat = "summary", width = 0.9, fun = "mean", alpha = 0.4, aes(fill=Age_Group), colour = "black") +
  521. stat_summary(fun.data = mean_se, geom = "errorbar", width = 0.4, alpha = 1, show.legend=FALSE, colour = "black") +
  522. geom_hline(yintercept = 0.5, linetype = "dotted", color = "black") +
  523. ggtitle("Novel Object Location \n by Protocol - 3xTg") + ylab('Novel/Total Exploration') +
  524. scale_fill_manual(values = c("#de9cbf", "#AE86B6"), labels = c("6 mo", "8 mo"))+
  525. scale_color_manual( values = c("#de9cbf", "#AE86B6"), labels = c("6 mo", "8 mo"))+
  526. scale_y_continuous(expand = c(0,0), limits = c(0, 1.1)) + #, limits = c(ymin,ymax), breaks = seq(0, 14, by = 2))+
  527. scale_alpha(guide = 'none') +
  528. labs(color = "Age", fill = "Age") +
  529. scale_x_discrete(labels = c("6 mo", "8 mo")) +
  530. facet_grid(.~Protocol, switch = "x", labeller = as_labeller(c('1' = "Protocol 1", '2' = "Protocol 2"))) +
  531. theme(plot.title = element_text(hjust = 0.5, size = 22, face = "bold"),
  532. axis.text.x = element_text(size = 18, colour = "black"),
  533. #axis.text.x = element_blank(),
  534. #axis.ticks.x=element_blank(),
  535. axis.text.y = element_text(size = 18, face="bold", colour = "black"),
  536. axis.title.y = element_text(size = 20, face = "bold", colour = "black"),
  537. axis.title.x = element_blank(),
  538. legend.text=element_text(size=16),
  539. legend.title=element_text(size=18),
  540. panel.grid.major = element_blank(),
  541. panel.grid.minor = element_blank(),
  542. panel.background = element_blank(),
  543. axis.line = element_line(colour = "black"),
  544. strip.text.x = element_text(size = 18, face = "bold"),
  545. strip.background = element_rect( fill="white"),
  546. panel.spacing.x = unit(1.4, "lines"),
  547. strip.placement = "outside")
  548. ggsave(
  549. "NOL_supp1.svg",
  550. behavior3,
  551. width = 6,
  552. height = 5,
  553. dpi = 600
  554. )
  555. ggsave(
  556. "NOL_supp2.svg",
  557. behavior4,
  558. width = 6,
  559. height = 5,
  560. dpi = 600
  561. )
  562. behavior3
  563. behavior4
  564. print("All Protocol 1 - Is performance different from chance?")
  565. print("WT 6mo P1")
  566. t.test(wt6_p1$NOL_Score, mu = 0.5)
  567. print("WT 8mo P1")
  568. t.test(wt8_p1$NOL_Score, mu=0.5)
  569. print("3xTg 6mo P1")
  570. t.test(tg6_p1$NOL_Score, mu=0.5)
  571. print("3xTg 8mo P1")
  572. t.test(tg8_p1$NOL_Score, mu=0.5)
  573. print("All Protocol 2 - Is performance different from chance?")
  574. print("WT 6mo P2")
  575. t.test(wt6_p2$NOL_Score, mu = 0.5)
  576. print("WT 8mo P2")
  577. t.test(wt8_p2$NOL_Score, mu=0.5)
  578. print("3xTg 6mo P2")
  579. t.test(tg6_p2$NOL_Score, mu=0.5)
  580. print("3xTg 8mo P2")
  581. t.test(tg8_p2$NOL_Score, mu=0.5)
  582. #
  583. print("Extra stats for group/protocol comparisons")
  584. print("6 months Protocol x Genotype ANOVA")
  585. General_AOVbyanim_ez(P1_P2_6mo, NOL_Score, Protocol, Mouse)
  586. print("8 months Protocol x Genotype ANOVA + Posthocs")
  587. General_AOVbyanim_ez(P1_P2_8mo, NOL_Score, Protocol, Mouse)
  588. General_byanim_holm_protocol(P1_P2_8mo, NOL_Score, Protocol)
  589. print("Protocol 1 Age x Genotype ANOVA + Posthocs")
  590. General_AOVbyanim_ez(rawdata_P1, NOL_Score, Age_Group, Mouse)
  591. General_byanim_holm(rawdata_P1, NOL_Score, Age_Broad)
  592. print("Protocol 2 Age x Genotype ANOVA + Posthocs")
  593. General_AOVbyanim_ez(rawdata_P2, NOL_Score, Age_Group, Mouse)
  594. General_byanim_holm(rawdata_P2, NOL_Score, Age_Broad)
  595. #print("Protocol 1 Genotype ANOVA")
  596. #General_AOVbyanim_ez(rawdata_P1, NOL_Score, Genotype, Mouse)
  597. #print("Protocol 2 Genotype ANOVA")
  598. #General_AOVbyanim_ez(rawdata_P2, NOL_Score, Genotype, Mouse)
  599. print("Average Age P1")
  600. age_by_group_P1<- rawdata_P1_6mo %>%
  601. dplyr::group_by(Age_Group, Genotype) %>%
  602. dplyr::summarise(mean = mean(Age_Months),
  603. sem = plotrix::std.error(Age_Months),
  604. min = min(Age_Months),
  605. max = max(Age_Months))
  606. age_by_group_P1
  607. print("Average Age P2")
  608. age_by_group_P2<- rawdata_P2_8mo %>%
  609. dplyr::group_by(Age_Group, Genotype) %>%
  610. dplyr::summarise(mean = mean(Age_Months),
  611. sem = plotrix::std.error(Age_Months),
  612. min = min(Age_Months),
  613. max = max(Age_Months))
  614. age_by_group_P2
  615. #Ns for figure 1
  616. print("Ns for Behavior Figure 1")
  617. print("3xTg 6mo (M, F) - P1")
  618. sum(rawdata_P1_6mo$Genotype == "3xTg" )
  619. sum(rawdata_P1_6mo$Genotype == "3xTg" & rawdata_P1_6mo$Sex == 'M')
  620. sum(rawdata_P1_6mo$Genotype == "3xTg" & rawdata_P1_6mo$Sex == 'F')
  621. print("WT 6mo (M, F) - P1")
  622. sum(rawdata_P1_6mo$Genotype == "WT" )
  623. sum(rawdata_P1_6mo$Genotype == "WT" & rawdata_P1_6mo$Sex == 'M')
  624. sum(rawdata_P1_6mo$Genotype == "WT" & rawdata_P1_6mo$Sex == 'F')
  625. print("3xTg 8mo (M, F) - P1")
  626. sum(rawdata_P2_8mo$Genotype == "3xTg" )
  627. sum(rawdata_P2_8mo$Genotype == "3xTg" & rawdata_P2_8mo$Sex == 'M')
  628. sum(rawdata_P2_8mo$Genotype == "3xTg" & rawdata_P2_8mo$Sex == 'F')
  629. print("WT 8mo (M, F) - P1")
  630. sum(rawdata_P2_8mo$Genotype == "WT")
  631. sum(rawdata_P2_8mo$Genotype == "WT" & rawdata_P2_8mo$Sex == 'M')
  632. sum(rawdata_P2_8mo$Genotype == "WT" & rawdata_P2_8mo$Sex == 'F')
  633. #Ns from 6 mo P1 and 8 month P2 (supplemental only)
  634. print("Ns for additional groups in figure S1")
  635. print("3xTg 6mo (M, F) - P2")
  636. sum(tg6_p2$Genotype == "3xTg" )
  637. sum(tg6_p2$Sex == 'M')
  638. sum(tg6_p2$Sex == 'F')
  639. print("WT 6mo (M, F) - P2")
  640. sum(wt6_p2$Genotype == "WT")
  641. sum(wt6_p2$Sex == 'M')
  642. sum(wt6_p2$Sex == 'F')
  643. print("3xTg 8mo (M, F) - P1")
  644. sum(tg8_p1$Genotype == "3xTg")
  645. sum(tg8_p1$Sex == 'M')
  646. sum(tg8_p1$Sex == 'F')
  647. print("WT 8mo (M, F) - P1")
  648. sum(wt8_p1$Genotype == "WT")
  649. sum(wt8_p1$Sex == 'M')
  650. sum(wt8_p1$Sex == 'F')
  651. ```
  652. ## Locomotion During Habituation (Figure S1)
  653. ```{r behavior2, echo=FALSE, warning = FALSE}
  654. #load data
  655. rawdata <- read_xlsx("NOL_Revision_2025_habituation.xlsx")
  656. #set genotype and age variables
  657. rawdata <- mutate(rawdata, Group_name = case_when(Genotype == 'WT' & Age_Group == '6' ~ '6wt',
  658. Genotype == '3xTg' & Age_Group == '6' ~ '63x',
  659. Genotype == 'WT' & Age_Group == '8' ~ '8wt',
  660. Genotype == '3xTg' & Age_Group == '8' ~ '83x'))
  661. rawdata <- mutate(rawdata, group2 = case_when(Genotype == 'WT'~ 'WT',
  662. Genotype == '3xTg' & Age_Group == '6' ~ '3xTg6',
  663. Genotype == '3xTg' & Age_Group == '8' ~ '3xTg8'))
  664. rawdata <- mutate(rawdata, Age = Age_Group) #rename to work with plotting functions expected input
  665. rawdata <- mutate(rawdata, Age_Broad = Age_Group) #rename to work with stats functions expected input
  666. rawdata$Genotype = factor(rawdata$Genotype, levels = c('WT', '3xTg'))
  667. rawdata$Age = factor(rawdata$Age, levels = c('6', '8'))
  668. rawdata$Age_Broad = factor(rawdata$Age_Broad, levels = c('6', '8'))
  669. rawdata$Group_name = factor(rawdata$Group_name, levels = c('6wt', '8wt', '63x', '83x'))
  670. rawdata$Distance_traveled_hab2 = as.numeric(rawdata$Distance_traveled_hab2)
  671. AnyPlotbygroupandsex_adjaxis_facet (rawdata , Distance_traveled_hab2, 'Distance Traveled', 'Distance (cm)', 0, 4000)
  672. General_AOVbyanim_ez(rawdata, Distance_traveled_hab2, Age_Broad, Animal)
  673. General_byanim_holm(rawdata, Distance_traveled_hab2, Age_Broad)
  674. rawdata$Avg_Velocity_Moving_Hab2 = as.numeric(rawdata$Avg_Velocity_Moving_Hab2)
  675. AnyPlotbygroupandsex_adjaxis_facet (rawdata, Avg_Velocity_Moving_Hab2, 'Movement Velocity', 'Velocity (m/s)', 0, 0.25)
  676. General_AOVbyanim_ez(rawdata, Avg_Velocity_Moving_Hab2, Age_Broad, Animal)
  677. General_byanim_holm(rawdata, Avg_Velocity_Moving_Hab2, Age_Broad)
  678. rawdata$Ratio_Mobility_Hab2 = as.numeric(rawdata$Ratio_Mobility_Hab2)
  679. AnyPlotbygroupandsex_adjaxis_facet (rawdata , Ratio_Mobility_Hab2, 'Proportion of Time \n Mobile', 'Time Moving/Total Time', 0, 0.31)
  680. General_AOVbyanim_ez(rawdata, Ratio_Mobility_Hab2, Age_Broad, Animal)
  681. General_byanim_holm(rawdata, Ratio_Mobility_Hab2, Age_Broad)
  682. #save plots
  683. ggsave(
  684. "Distance_Traveled_Hab_2.svg",
  685. AnyPlotbygroupandsex_adjaxis_facet (rawdata , Distance_traveled_hab2, 'Distance Traveled', 'Distance (cm)', 0, 4000),
  686. width = 4,
  687. height = 5,
  688. dpi = 600
  689. )
  690. rawdata <- mutate(rawdata, Avg_Velocity_Moving_Hab2 = as.numeric(Avg_Velocity_Moving_Hab2))
  691. ggsave(
  692. "Velocity_Hab2.svg",
  693. AnyPlotbygroupandsex_adjaxis_facet (rawdata, Avg_Velocity_Moving_Hab2, 'Movement Velocity', 'Velocity (m/s)', 0, 0.25),
  694. width = 4,
  695. height = 5,
  696. dpi = 600
  697. )
  698. ggsave(
  699. "Ratio_Mobility_Hab2.svg",
  700. AnyPlotbygroupandsex_adjaxis_facet (rawdata , Ratio_Mobility_Hab2, 'Proportion of Time \n Mobile', 'Time Moving/Total Time', 0, 0.31),
  701. width = 4,
  702. height = 5,
  703. dpi = 600
  704. )
  705. ```
  706. # Amyloid-Beta Immunohistochemistry (Figure 1)
  707. ```{r amyloid, echo=FALSE, warning = FALSE}
  708. PlaqueCounts<- read_xlsx("amyloid_quantification.xlsx")
  709. PlaqueCounts$Genotype = factor(PlaqueCounts$Genotype, levels = c('WT', '3xTg'))
  710. PlaqueCounts$Age_Broad = factor(PlaqueCounts$Age_Broad, levels = c('6', '8', '15'))
  711. PlaqueCounts <- mutate(PlaqueCounts, Groupname = case_when(Genotype == 'WT' & Age_Broad == '6' ~ 'WT6',
  712. Genotype == '3xTg' & Age_Broad == '6' ~ '3xTg6',
  713. Genotype == 'WT' & Age_Broad == '8' ~ 'WT8',
  714. Genotype == '3xTg' & Age_Broad == '8' ~ '3xTg8',
  715. Genotype == 'WT' & Age_Broad == '15' ~ 'WT15',
  716. Genotype == '3xTg' & Age_Broad == '15' ~ '3xTg15'
  717. ))
  718. PlaqueCounts$Groupname = factor(PlaqueCounts$Groupname, levels = c('WT6', 'WT8', 'WT15', '3xTg6', '3xTg8','3xTg15'))
  719. #reformat data to get dataframes with values by animal instead of by slice
  720. PlaqueCounts <- mutate(PlaqueCounts, Slice= as.factor(Slice))
  721. PlaqueCounts_byanimal <- PlaqueCounts %>%
  722. dplyr::select(Animal, Genotype, Sex, Age_Broad, Age_months, Groupname, Wave, Slice, Plaquespermmsq)
  723. PlaqueCounts_byanimal<- dcast(PlaqueCounts_byanimal, Animal + Genotype + Sex + Age_Broad + Age_months + Groupname + Wave ~ Slice, na.rm=TRUE)
  724. PlaqueCounts_byanimal <- mutate(PlaqueCounts_byanimal, Avg = rowMeans(dplyr::select(PlaqueCounts_byanimal,'1','2','3','4','5', '6', '7', '8', '9'), na.rm =TRUE))
  725. PlotPlaques_byageandsex <- function(df, y, title, ymin = -0.25, ymax = 20) {
  726. plot <-ggplot(df ,aes(x=Genotype, y={{y}}))
  727. plot+ geom_jitter(aes(col= Genotype, shape = Sex), alpha = 0.6, width = 0.1, show.legend = TRUE) +
  728. geom_bar(position="dodge", stat = "summary", width = 1, fun.y = "mean", alpha = 0.4, aes(fill=Genotype), colour = 'black') +
  729. stat_summary(fun.data = mean_se, geom = "errorbar", width = 0.25, colour= 'black', show.legend = FALSE) +
  730. ggtitle(title) +labs(y= expression(bold("Plaques per" ~mm^2))) +
  731. facet_grid(.~Age_Broad, switch = "x", labeller = as_labeller(c('6' = "6 mo", '8' = "8 mo", '15' = "15 mo"))) +
  732. theme(plot.title = element_text(hjust = 0.5, size = 24, face = "bold"),
  733. axis.text.x = element_text(size = 19, colour = "black"),
  734. axis.text.y = element_text(size = 19, colour = "black", face = "bold"),
  735. axis.title.y = element_text(size = 21, colour = "black", face = "bold"),
  736. axis.title.x = element_blank(),
  737. legend.text=element_text(size=16),
  738. legend.title=element_text(size=18),
  739. strip.background = element_rect(colour="white", fill="white"),
  740. panel.grid.major = element_blank(),
  741. panel.grid.minor = element_blank(),
  742. panel.background = element_blank(),
  743. strip.text.x = element_text(size = 19, face = "bold"),
  744. panel.spacing.x = unit(1.4, "lines"),
  745. strip.placement = "outside",
  746. axis.line = element_line(colour = "black")) +
  747. scale_y_continuous(limits = c(ymin, ymax), expand = c(0, 0)) + #+
  748. #scale_fill_manual("legend", values = scale_fill_palette_8mo, labels = c("WT", "3xTg"))+
  749. scale_fill_manual("legend", values = scale_fill_palette_8mo, guide = "none")+
  750. guides(fill=guide_legend("Genotype")) +
  751. scale_color_manual("legend", values = scale_colour_palette_8mo, guide = "none")
  752. }
  753. PlotPlaques_byageandsex(PlaqueCounts_byanimal, Avg, "Amyloid Plaque Counts \n Hippocampus + Subiculum", ymin= -0.25, ymax = 15)
  754. General_AOVbyanim_ez(PlaqueCounts_byanimal, Avg, Age_Broad, Animal)
  755. CellCounts_nonparametric <- function(df, y){
  756. #CALCULATE P VALS CORRECTED FOR MULTIPLE COMPARISONS
  757. df <- substitute(df)
  758. y <- substitute(y)
  759. yvar <- substitute(df$y, list(y=y, df = df))
  760. gvar <- substitute(Genotype)
  761. grpvar <-substitute(Groupname)
  762. xvar <- substitute(df$x, list(x=grpvar, df = df))
  763. wilcox <- eval.parent(substitute(pairwise_wilcox_test(df, y~grpvar, p.adjust.method="holm", comparisons = list(c("WT6", "3xTg6"), c("WT8", "3xTg8"), c("WT15", "3xTg15"))), list(y = y, grpvar = grpvar, df = df)))
  764. #wilcox_6 <- eval.parent(substitute(wilcox.test(celltype_6, y~gvar, p.adjust.method="none"), list(y = y, gvar = gvar, celltype_6 = celltype_6)))
  765. return(wilcox)
  766. }
  767. Immuno_AOV_3way <- function(data, y, agevar, subjectvar){
  768. #3 way age x genotype x sex anova
  769. avar <- substitute(agevar)
  770. gvar <- substitute(Genotype)
  771. svar <- substitute(subjectvar)
  772. sexvar <-substitute(Sex)
  773. yvar <- substitute(y)
  774. df<- substitute(data)
  775. aov <- eval.parent(substitute(ezANOVA(data = df, wid = svar, dv = yvar, between = .(gvar, avar, sexvar), type = 3, observed = .(gvar, avar, sexvar), return_aov=TRUE), list(avar = avar, gvar=gvar, svar = svar, sexvar= sexvar, yvar=yvar, df=df)))
  776. return(aov)
  777. }
  778. #3 way age x genotype x sex anova
  779. print("3 way ANOVA Age x Genotype x Sex - Amyloid Plaque Counts")
  780. Immuno_AOV_3way(PlaqueCounts_byanimal, Avg, Age_Broad, Animal)
  781. CellCounts_nonparametric(PlaqueCounts_byanimal, Avg)
  782. PlaqueCounts_byanimal %>%
  783. dplyr::group_by(Groupname) %>%
  784. dplyr::summarise(mean = mean(Age_months),
  785. sem = plotrix::std.error(Age_months),
  786. min = min(Age_months),
  787. max = max(Age_months))
  788. ggsave(
  789. "PlaqueCounts.svg",
  790. PlotPlaques_byageandsex(PlaqueCounts_byanimal, Avg, "Amyloid Plaque Counts \n Hippocampus + Subiculum", ymin= -0.25, ymax = 15),
  791. width = 7,
  792. height = 5,
  793. dpi = 600
  794. )
  795. ```
  796. # Ephys Results
  797. ## Running in VR (Figure S3)
  798. ```{r running-speed, echo=FALSE, warning = FALSE}
  799. theta_data <- read.csv("Running_Power_Theta_HIPP.csv")
  800. theta_data$Group_name <- factor(theta_data$Group_name , # Reordering factor levels
  801. levels = c("6wt", "8wt", "63x", "83x"))
  802. theta_data<-mutate(theta_data, Genotype = ifelse(Group_name =='6wt'|Group_name =='8wt', "WT", "3xTg"))
  803. theta_data<-mutate(theta_data, Age = ifelse(Group_name =='6wt'|Group_name =='63x', 6, 8))
  804. theta_data$Age <- factor(theta_data$Age, # Reordering factor levels
  805. levels = c("6", "8"))
  806. theta_data<-mutate(theta_data, Age_Broad = ifelse(Group_name =='6wt'|Group_name =='63x', 6, 8)) #duplicate variables to get along with all functions that expect either Age or Age_Broad
  807. theta_data$Age_Broad <- factor(theta_data$Age_Broad, # Reordering factor levels
  808. levels = c("6", "8"))
  809. theta_data$Layer_name <- factor(theta_data$Layer_name, # Reordering region factor levels
  810. levels = c("Hil", "GC", "Mol", "LM", "Rad", "Pyr", "Or"))
  811. theta_data$Genotype <- factor(theta_data$Genotype, # Reordering genotype factor levels
  812. levels = c("WT", "3xTg"))
  813. theta_data$Sex <- factor(theta_data$Sex, levels = c("F", "M"))
  814. theta_data <-subset(theta_data, Track =='all')
  815. theta_data_6mo <-subset(theta_data, Age =='6')
  816. theta_data_8mo <-subset(theta_data, Age =='8')
  817. age_data <- subset(theta_data, Layer_name == 'Or')
  818. age_by_group_df <- age_data %>%
  819. dplyr::group_by(Group_name) %>%
  820. dplyr::summarise(mean = mean(Age_months),
  821. sem = plotrix::std.error(Age_months),
  822. min = min(Age_months),
  823. max = max(Age_months))
  824. runspeed_data <-subset(theta_data, Layer_name == 'LM') #only one value per animal for speed
  825. runspeed_data <- mutate(runspeed_data, relativespeed_all = RunSpeed-Run_baseline ) #re-calculate speed by subtracting ball tracker baseline
  826. runspeed_data <- mutate(runspeed_data, relativespeed_thresh = RunSpeedinThresh-Run_baseline )
  827. runspeed_data <- mutate(runspeed_data, percent_run = as.numeric(LengthRun/(LengthRun + LengthNonRun)))
  828. #all subjects sex = shape
  829. Run1 <- AnyPlotbygroupandsex_adjaxis_facet(runspeed_data, relativespeed_all, 'Run Speed' , 'Speed (m/s)', 0, 0.6)
  830. Run2 <- AnyPlotbygroupandsex_adjaxis_facet(runspeed_data, relativespeed_thresh, 'Run Speed \nAfter Subsampling' , 'Speed (m/s)', 0, 0.31)
  831. Run3 <- AnyPlotbygroupandsex_adjaxis_facet(runspeed_data, percent_run, 'Time Spent \n Running' , 'Ratio', 0, 1)
  832. Run1
  833. General_AOVbyanim_ez(runspeed_data, relativespeed_all, Age_Broad, animals)
  834. Run2
  835. General_AOVbyanim_ez(runspeed_data, relativespeed_thresh, Age_Broad, animals)
  836. Run3
  837. General_AOVbyanim_ez(runspeed_data, percent_run, Age_Broad, animals)
  838. plot_list = list(Run1, Run2, Run3)
  839. ID = 1
  840. for (p in plot_list) {
  841. ggsave(
  842. p,
  843. filename=paste("running",ID,".svg",sep=""),
  844. width = 4,
  845. height = 5,
  846. dpi = 600)
  847. ID = ID + 1
  848. }
  849. print("Ns for Running Speed/LFP Analysis")
  850. print("3xTg 6mo (M, F)")
  851. sum(runspeed_data$Genotype == "3xTg" & runspeed_data$Age_Broad == '6')
  852. sum(runspeed_data$Genotype == "3xTg" & runspeed_data$Age_Broad == '6' & runspeed_data$Sex == 'M')
  853. sum(runspeed_data$Genotype == "3xTg" & runspeed_data$Age_Broad == '6' & runspeed_data$Sex == 'F')
  854. print("3xTg 8mo (M, F)")
  855. sum(runspeed_data$Genotype == "3xTg" & runspeed_data$Age_Broad == '8')
  856. sum(runspeed_data$Genotype == "3xTg" & runspeed_data$Age_Broad == '8' & runspeed_data$Sex == 'M')
  857. sum(runspeed_data$Genotype == "3xTg" & runspeed_data$Age_Broad == '8' & runspeed_data$Sex == 'F')
  858. print("WT 6mo (M, F)")
  859. sum(runspeed_data$Genotype == "WT" & runspeed_data$Age_Broad == '6')
  860. sum(runspeed_data$Genotype == "WT" & runspeed_data$Age_Broad == '6' & runspeed_data$Sex == 'M')
  861. sum(runspeed_data$Genotype == "WT" & runspeed_data$Age_Broad == '6' & runspeed_data$Sex == 'F')
  862. print("WT 8mo (M, F)")
  863. sum(runspeed_data$Genotype == "WT" & runspeed_data$Age_Broad == '8')
  864. sum(runspeed_data$Genotype == "WT" & runspeed_data$Age_Broad == '8' & runspeed_data$Sex == 'M')
  865. sum(runspeed_data$Genotype == "WT" & runspeed_data$Age_Broad == '8' & runspeed_data$Sex == 'F')
  866. print("Age Ranges")
  867. age_data
  868. ```
  869. ```{r lfp-functions, echo=FALSE, warning = FALSE}
  870. #LOAD FUNCTIONS FOR LFP PLOTS AND ADDED STATS
  871. Powerbygroup_6mo <- function(freq_df_6mo, state_power, title, ytitle, ymin, ymax) {
  872. plot <-ggplot(freq_df_6mo, aes(x=Layer_name, y={{state_power}}))
  873. plot + geom_line(aes(x = Layer_name, y = {{state_power}}, group = Genotype, colour=Genotype), stat="summary", fun.y = "mean", size = 1.2, alpha =1) +
  874. geom_point(aes(x = Layer_name, y = {{state_power}}, group = Genotype, colour=Genotype), stat="summary", fun.y = "mean", alpha = 0.7, size = 0.7) +
  875. stat_summary(fun.data = mean_se, geom = "pointrange", size = 0.7, alpha = 0.7, linewidth = 1.2, aes(x=Layer_name, y={{state_power}}, group = Genotype, colour=Genotype), show.legend = FALSE) +
  876. theme(panel.grid.major = element_blank(),
  877. panel.grid.minor = element_blank(),
  878. panel.background = element_blank(),
  879. axis.line = element_line(colour = "black"),
  880. plot.title = element_text(size = 22, face ="bold", hjust = 0.5),
  881. axis.text=element_text(size=20, face="bold", colour = "black"),
  882. axis.title=element_text(size=22, face="bold", colour = "black"),
  883. legend.text=element_text(size=16),
  884. legend.title=element_text(size=18),
  885. strip.text.x = element_text(size = 18, face = "bold"),
  886. strip.background = element_rect( fill="white"),
  887. panel.spacing.x = unit(1.4, "lines"),
  888. legend.key=element_rect(fill="white", colour =NA),
  889. strip.placement = "outside") +
  890. ggtitle(title) + xlab("Layer") + ylab(ytitle)+
  891. scale_color_manual("legend", values = scale_colour_palette_6mo, labels = c("WT 6 mo", "3xTg 6 mo"))+
  892. guides(colour=guide_legend("Group", override.aes = list(size = 4))) +
  893. coord_flip(ylim=c(ymin, ymax)) +
  894. labs(colour= "Group") +
  895. scale_alpha(guide = 'none')
  896. }
  897. Powerbygroup_8mo <- function(freq_df_8mo, state_power, title, ytitle, ymin, ymax) {
  898. plot <-ggplot(freq_df_8mo, aes(x=Layer_name, y={{state_power}}))
  899. plot + geom_line(aes(x = Layer_name, y = {{state_power}}, group = Genotype, colour=Genotype), stat="summary", fun.y = "mean", size = 1.2, alpha =1) +
  900. geom_point(aes(x = Layer_name, y = {{state_power}}, group = Genotype, colour=Genotype), stat="summary", fun.y = "mean", alpha = 0.7, size = 0.7) +
  901. stat_summary(fun.data = mean_se, geom = "pointrange", size = 0.7, alpha = 0.7, linewidth = 1.2,
  902. aes(x=Layer_name, y={{state_power}}, group = Genotype, colour=Genotype), show.legend = FALSE) +
  903. theme(panel.grid.major = element_blank(),
  904. panel.grid.minor = element_blank(),
  905. panel.background = element_blank(),
  906. axis.line = element_line(colour = "black"),
  907. plot.title = element_text(size = 22, face ="bold", hjust = 0.5),
  908. axis.text=element_text(size=20, face="bold", colour = "black"),
  909. axis.title=element_text(size=22, face="bold", colour = "black"),
  910. legend.text=element_text(size=16),
  911. legend.title=element_text(size=18),
  912. strip.text.x = element_text(size = 18, face = "bold"),
  913. strip.background = element_rect( fill="white"),
  914. panel.spacing.x = unit(1.4, "lines"),
  915. legend.key=element_rect(fill="white", colour =NA),
  916. strip.placement = "outside") +
  917. ggtitle(title) + xlab("Layer") + ylab(ytitle)+
  918. scale_color_manual("legend", values = scale_colour_palette_8mo, labels = c("WT 8 mo", "3xTg 8 mo"))+
  919. guides(colour=guide_legend("Group",override.aes = list(size = 4))) +
  920. coord_flip(ylim=c(ymin, ymax)) +
  921. labs(colour= "Group") +
  922. scale_alpha(guide = 'none')
  923. }
  924. Posthocs_byage <- function(data_age, y, layervar){
  925. #is there a difference between genotypes for each layer at the given age?
  926. #agevar = Age_Broad or Age, layervar = Layer_name or Layername or similar, subject var = Animals, Animalname or similar, y = Coh, Run_thresh_power etc.
  927. gvar <- substitute(Genotype)
  928. lvar <-substitute(layervar)
  929. yvar <- substitute(y)
  930. df<- substitute(data_age)
  931. posthoc <- eval.parent(substitute(df %>% dplyr::group_by(lvar) %>% t_test(yvar ~gvar, p.adjust.method = "none") %>% adjust_pvalue(method = "holm"), list(df =df, lvar=lvar, yvar=yvar, gvar=gvar))) #THIS MATCHES PRISM!!
  932. return(posthoc)
  933. }
  934. ```
  935. ### Theta Power - Hippocampus (Figure 3)
  936. ```{r theta-power-h, echo=FALSE, warning = FALSE}
  937. Power1 <- Powerbygroup_6mo(theta_data_6mo, Run_thresh_power, 'Hippocampus \n Theta Power (5-12 Hz)', "Power", 0, 350)
  938. Power2 <- Powerbygroup_8mo(theta_data_8mo, Run_thresh_power, 'Hippocampus \n Theta Power (5-12 Hz)', "Power", 0, 350)
  939. Power1
  940. print("2 way Genotype x Layer ANOVA - 6mo")
  941. PowerCohPhaseStats_2waygl(theta_data_6mo, Run_thresh_power, Layer_name, animals)
  942. print("6 mo posthocs")
  943. Posthocs_byage(theta_data_6mo, Run_thresh_power, Layer_name)
  944. Power2
  945. print("2 way Genotype x Layer ANOVA - 8mo")
  946. PowerCohPhaseStats_2waygl(theta_data_8mo, Run_thresh_power, Layer_name, animals)
  947. print("8 mo posthocs")
  948. Posthocs_byage(theta_data_8mo, Run_thresh_power, Layer_name)
  949. print("8 mo Genotype x Layer x Sex")
  950. PowerCohPhaseStats_3waygls(theta_data_8mo, Run_thresh_power, Layer_name, animals)
  951. ```
  952. ### Gamma Power - Hippocampus (Figure S5)
  953. ```{r gamma-power-h, echo=FALSE, warning = FALSE}
  954. slow_gamma_data <- read.csv("Running_Power_slow_gamma_HIPP.csv")
  955. slow_gamma_data$Group_name <- factor(slow_gamma_data$Group_name , # Reordering factor levels
  956. levels = c("6wt", "8wt", "63x", "83x"))
  957. slow_gamma_data<-mutate(slow_gamma_data, Genotype = ifelse(Group_name =='6wt'|Group_name =='8wt', "WT", "3xTg"))
  958. slow_gamma_data<-mutate(slow_gamma_data, Age = ifelse(Group_name =='6wt'|Group_name =='63x', 6, 8))
  959. slow_gamma_data$Layer_name <- factor(slow_gamma_data$Layer_name, # Reordering region factor levels
  960. levels = c("Hil", "GC", "Mol", "LM", "Rad", "Pyr", "Or"))
  961. slow_gamma_data$Genotype <- factor(slow_gamma_data$Genotype, # Reordering genotype factor levels
  962. levels = c("WT", "3xTg"))
  963. slow_gamma_data$Age <- factor(slow_gamma_data$Age, # Reordering factor levels
  964. levels = c("6", "8"))
  965. slow_gamma_data <-subset(slow_gamma_data, Track =='all')
  966. slow_gamma_data_6mo <-subset(slow_gamma_data, Age =='6')
  967. slow_gamma_data_8mo <-subset(slow_gamma_data, Age =='8')
  968. Power3 <- Powerbygroup_6mo(slow_gamma_data_6mo, Run_thresh_power, 'Hippocampus \n Slow Gamma Power (30-50 Hz)', "Power", 0, 100)
  969. Power4 <- Powerbygroup_8mo(slow_gamma_data_8mo, Run_thresh_power, 'Hippocampus \n Slow Gamma Power (30-50 Hz)', "Power", 0, 100)
  970. Power3
  971. print("2 way Genotype x Layer ANOVA - 6mo")
  972. PowerCohPhaseStats_2waygl(slow_gamma_data_6mo, Run_thresh_power, Layer_name, animals)
  973. print("6 mo posthocs")
  974. Posthocs_byage(slow_gamma_data_6mo, Run_thresh_power, Layer_name)
  975. Power4
  976. print("2 way Genotype x Layer ANOVA - 8mo")
  977. PowerCohPhaseStats_2waygl(slow_gamma_data_8mo, Run_thresh_power, Layer_name, animals)
  978. print("8 mo posthocs")
  979. Posthocs_byage(slow_gamma_data_8mo, Run_thresh_power, Layer_name)
  980. ##############
  981. fast_gamma_data <- read.csv("Running_Power_fast_gamma_HIPP.csv")
  982. fast_gamma_data$Group_name <- factor(fast_gamma_data$Group_name , # Reordering factor levels
  983. levels = c("6wt", "8wt", "63x", "83x"))
  984. fast_gamma_data<-mutate(fast_gamma_data, Genotype = ifelse(Group_name =='6wt'|Group_name =='8wt', "WT", "3xTg"))
  985. fast_gamma_data<-mutate(fast_gamma_data, Age = ifelse(Group_name =='6wt'|Group_name =='63x', 6, 8))
  986. fast_gamma_data$Layer_name <- factor(fast_gamma_data$Layer_name, # Reordering region factor levels
  987. levels = c("Hil", "GC", "Mol", "LM", "Rad", "Pyr", "Or"))
  988. fast_gamma_data$Genotype <- factor(fast_gamma_data$Genotype, # Reordering genotype factor levels
  989. levels = c("WT", "3xTg"))
  990. fast_gamma_data$Age <- factor(fast_gamma_data$Age, # Reordering factor levels
  991. levels = c("6", "8"))
  992. fast_gamma_data <-subset(fast_gamma_data, Track =='all')
  993. fast_gamma_data_6mo <-subset(fast_gamma_data, Age =='6')
  994. fast_gamma_data_8mo <-subset(fast_gamma_data, Age =='8')
  995. Power5 <- Powerbygroup_6mo(fast_gamma_data_6mo, Run_thresh_power, 'Hippocampus \n Fast Gamma Power (90-130 Hz)', "Power",0, 30)
  996. Power6 <- Powerbygroup_8mo(fast_gamma_data_8mo, Run_thresh_power, 'Hippocampus \n Fast Gamma Power (90-130 Hz)', "Power",0, 30)
  997. Power5
  998. print("2 way Genotype x Layer ANOVA - 6mo")
  999. PowerCohPhaseStats_2waygl(fast_gamma_data_6mo, Run_thresh_power, Layer_name, animals)
  1000. print("6 mo posthocs")
  1001. Posthocs_byage(fast_gamma_data_6mo, Run_thresh_power, Layer_name)
  1002. Power6
  1003. print("2 way Genotype x Layer ANOVA - 8mo")
  1004. PowerCohPhaseStats_2waygl(fast_gamma_data_8mo, Run_thresh_power, Layer_name, animals)
  1005. print("8 mo posthocs")
  1006. Posthocs_byage(fast_gamma_data_8mo, Run_thresh_power, Layer_name)
  1007. ```
  1008. ### Theta Power - MEC (Figure S4)
  1009. ```{r theta-power-m, echo=FALSE, warning = FALSE}
  1010. theta_data <- read.csv("Running_Power_theta_MEC.csv")
  1011. theta_data$Group_name <- factor(theta_data$Group_name , # Reordering factor levels
  1012. levels = c("6wt", "8wt", "63x", "83x"))
  1013. theta_data<-mutate(theta_data, Genotype = ifelse(Group_name =='6wt'|Group_name =='8wt', "WT", "3xTg"))
  1014. theta_data<-mutate(theta_data, Age = ifelse(Group_name =='6wt'|Group_name =='63x', 6, 8))
  1015. theta_data$Age <- factor(theta_data$Age, # Reordering factor levels
  1016. levels = c("6", "8"))
  1017. theta_data$Layer_name <- factor(theta_data$Layer_name, # Reordering region factor levels
  1018. levels = c("MEC2", "MEC3"))
  1019. theta_data$Genotype <- factor(theta_data$Genotype, # Reordering genotype factor levels
  1020. levels = c("WT", "3xTg"))
  1021. theta_data <-subset(theta_data, Track =='all')
  1022. theta_data_6mo <-subset(theta_data, Age =='6')
  1023. theta_data_8mo <-subset(theta_data, Age =='8')
  1024. Power7 <- Powerbygroup_6mo(theta_data_6mo, Run_thresh_power, 'MEC \n Theta Power (5-12 Hz)', "Power", 0, 80)
  1025. Power8 <- Powerbygroup_8mo(theta_data_8mo, Run_thresh_power, 'MEC \n Theta Power (5-12 Hz)', "Power", 0, 80)
  1026. Power7
  1027. Power8
  1028. MECthetastats <- function(MECtheta_age_df) {
  1029. df = substitute(MECtheta_age_df)
  1030. avar = substitute(Age_Broad)
  1031. gvar = substitute(Genotype)
  1032. lvar = substitute(Layer_name)
  1033. svar = substitute(animals)
  1034. yvar = substitute(Run_thresh_power)
  1035. #2 way
  1036. fm <- substitute(yvar ~ gvar *lvar + (1|svar), list(yvar=yvar, gvar= gvar, svar=svar, lvar=lvar))
  1037. model<- eval.parent(substitute(lmer(fm , REML = T, data = df), list(fm = fm, df =df)))
  1038. lm <- eval.parent(substitute(lmer(fm , REML = T, data = df), list(fm = fm, df =df))) %>% summary()
  1039. lm_aov <- eval.parent(substitute(lmer(fm, REML = T, data=df), list(fm=fm, df=df))) %>% anova()
  1040. emmtest <- eval.parent(emmeans(model, ~ Genotype * Layer_name))
  1041. posthoc_emmeans <- pairs(emmtest, simple = "Genotype") %>%
  1042. rbind() %>%
  1043. summary(adjust = "bonferroni")
  1044. posthoc_ttest <- eval.parent(substitute(df %>% dplyr::group_by(lvar) %>% t_test(yvar ~gvar, p.adjust.method = "none") %>% adjust_pvalue(method = "bonferroni"), list(df =df, lvar=lvar, yvar=yvar, gvar=gvar))) #THIS MATCHES PRISM!!
  1045. outlist <-list(lm, lm_aov, posthoc_emmeans, posthoc_ttest)
  1046. return(outlist)
  1047. }
  1048. MECthetastats(theta_data_6mo)
  1049. MECthetastats(theta_data_8mo)
  1050. ```
  1051. ```{r theta-gamma-power-export, echo=FALSE, warning = FALSE}
  1052. #export all power plots
  1053. plot_list = list(Power1, Power2, Power3, Power4, Power5, Power6, Power7, Power8)
  1054. ID = 1
  1055. for (p in plot_list) {
  1056. ggsave(
  1057. p,
  1058. filename=paste("Power",ID,".svg",sep=""),
  1059. width = 6,
  1060. height = 7,
  1061. dpi = 600)
  1062. ID = ID + 1
  1063. }
  1064. ```
  1065. ### Theta CSD - Hippocampus (Figure 3)
  1066. note:heatmaps were made in matlab
  1067. ```{r theta-csd-h, echo=FALSE, warning = FALSE}
  1068. CSDbygroup_6mo <- function(df_6mo, y, title, ytitle, ymin, ymax) {
  1069. plot <-ggplot(df_6mo, aes(x=Layer, y={{y}}))
  1070. plot + geom_line(aes(x = Layer, y = {{y}}, group = Genotype, colour=Genotype), stat="summary", fun.y = "mean", size = 1.2, alpha =1) +
  1071. geom_point(aes(x = Layer, y = {{y}}, group = Genotype, colour=Genotype), stat="summary", fun.y = "mean", alpha = 0.7, size = 0.7) +
  1072. stat_summary(fun.data = mean_se, geom = "pointrange", size = 0.7, alpha = 0.7, linewidth = 1.2,
  1073. aes(x=Layer, y={{y}}, group = Genotype, colour=Genotype), show.legend = FALSE) +
  1074. theme(panel.grid.major = element_blank(),
  1075. panel.grid.minor = element_blank(),
  1076. panel.background = element_blank(),
  1077. axis.line = element_line(colour = "black"),
  1078. plot.title = element_text(size = 22, face ="bold", hjust = 0.5),
  1079. axis.text=element_text(size=20, face="bold", colour = "black"),
  1080. axis.title=element_text(size=22, face="bold", colour = "black"),
  1081. legend.text=element_text(size=16),
  1082. legend.title=element_text(size=18),
  1083. strip.text.x = element_text(size = 18, face = "bold"),
  1084. strip.background = element_rect( fill="white"),
  1085. panel.spacing.x = unit(1.4, "lines"),
  1086. legend.key=element_rect(fill="white"),
  1087. strip.placement = "outside") +
  1088. ggtitle(title) + xlab("Layer") + ylab(ytitle)+
  1089. scale_color_manual("legend", values = scale_colour_palette_6mo, labels = c("WT 6 mo", "3xTg 6 mo"))+
  1090. coord_flip(ylim=c(ymin, ymax)) +
  1091. guides(colour=guide_legend("Group",override.aes = list(size = 4))) +
  1092. scale_alpha(guide = 'none')
  1093. }
  1094. CSDbygroup_8mo <- function(df_8mo, y, title, ytitle, ymin, ymax) {
  1095. plot <-ggplot(df_8mo, aes(x=Layer, y={{y}}))
  1096. plot + geom_line(aes(x = Layer, y = {{y}}, group = Genotype, colour=Genotype), stat="summary", fun.y = "mean", size = 1.2, alpha =1) +
  1097. geom_point(aes(x = Layer, y = {{y}}, group = Genotype, colour=Genotype), stat="summary", fun.y = "mean", alpha = 0.7, size = 0.7) +
  1098. stat_summary(fun.data = mean_se, geom = "pointrange", size = 0.7, alpha = 0.7, linewidth = 1.2,
  1099. aes(x=Layer, y={{y}}, group = Genotype, colour=Genotype), show.legend = FALSE) +
  1100. theme(panel.grid.major = element_blank(),
  1101. panel.grid.minor = element_blank(),
  1102. panel.background = element_blank(),
  1103. axis.line = element_line(colour = "black"),
  1104. plot.title = element_text(size = 22, face ="bold", hjust = 0.5),
  1105. axis.text=element_text(size=20, face="bold", colour = "black"),
  1106. axis.title=element_text(size=22, face="bold", colour = "black"),
  1107. legend.text=element_text(size=16),
  1108. legend.title=element_text(size=18),
  1109. strip.text.x = element_text(size = 18, face = "bold"),
  1110. strip.background = element_rect( fill="white"),
  1111. panel.spacing.x = unit(1.4, "lines"),
  1112. legend.key=element_rect(fill="white"),
  1113. strip.placement = "outside") +
  1114. ggtitle(title) + xlab("Layer") + ylab(ytitle)+
  1115. scale_color_manual("legend", values = scale_colour_palette_8mo, labels = c( "WT 8 mo", "3xTg 8 mo"))+
  1116. coord_flip(ylim=c(ymin, ymax)) +
  1117. guides(colour=guide_legend("Group",override.aes = list(size = 4))) +
  1118. scale_alpha(guide = 'none')
  1119. }
  1120. #mixed model to account for missing data - ultimately used prism for this (?)
  1121. CSDstats <- function(CSD_age_df) {
  1122. df = substitute(CSD_age_df)
  1123. avar = substitute(Age_Broad)
  1124. gvar = substitute(Genotype)
  1125. lvar = substitute(Layer)
  1126. svar = substitute(Animal)
  1127. yvar = substitute(Value)
  1128. #2 way
  1129. fm <- substitute(yvar ~ gvar *lvar + (1|svar), list(yvar=yvar, gvar= gvar, svar=svar, lvar=lvar))
  1130. model<- eval.parent(substitute(lmer(fm , REML = T, data = df), list(fm = fm, df =df)))
  1131. lm <- eval.parent(substitute(lmer(fm , REML = T, data = df), list(fm = fm, df =df))) %>% summary()
  1132. lm_aov <- eval.parent(substitute(lmer(fm, REML = T, data=df), list(fm=fm, df=df))) %>% anova()
  1133. emmtest <- eval.parent(emmeans(model, ~ Genotype * Layer))
  1134. posthoc_emmeans <- pairs(emmtest, simple = "Genotype") %>%
  1135. rbind() %>%
  1136. summary(adjust = "holm")
  1137. posthoc_ttest <- eval.parent(substitute(df %>% dplyr::group_by(lvar) %>% t_test(yvar ~gvar, p.adjust.method = "none") %>% adjust_pvalue(method = "holm"), list(df =df, lvar=lvar, yvar=yvar, gvar=gvar)))
  1138. outlist <-list(lm, lm_aov, posthoc_emmeans, posthoc_ttest)
  1139. return(outlist)
  1140. }
  1141. #
  1142. CSDstats_3way <- function(CSD_age_df) {
  1143. df = substitute(CSD_age_df)
  1144. sexvar = substitute(Sex)
  1145. gvar = substitute(Genotype)
  1146. lvar = substitute(Layer)
  1147. svar = substitute(Animal)
  1148. yvar = substitute(Value)
  1149. #3 way
  1150. fm <- substitute(yvar ~ gvar * sexvar *lvar + (1|svar), list(yvar=yvar, gvar= gvar, sexvar = sexvar, svar=svar, lvar = lvar))
  1151. model<- eval.parent(substitute(lmer(fm , REML = T, data = df), list(fm = fm, df =df)))
  1152. lm <- eval.parent(substitute(lmer(fm , REML = T, data = df), list(fm = fm, df =df))) %>% summary()
  1153. lm_aov <- eval.parent(substitute(lmer(fm, REML = T, data=df), list(fm=fm, df=df))) %>% anova()
  1154. outlist <-list(lm, lm_aov)
  1155. return(outlist)
  1156. }
  1157. CSD_data <- read.csv("CSDrunthreshoutput_HIPP_theta.csv")
  1158. CSD_data$Animal <- factor(CSD_data$Animal)
  1159. CSD_data <- gather(CSD_data, Layer, Value, Hil:Or, factor_key=TRUE) #convert data wide to long
  1160. CSD_data$Group <- factor(CSD_data$Group , # Reordering factor levels
  1161. # levels = c("6wt", "8wt", "63x", "83x"))
  1162. levels = c("6wt", "8wt", "63x", "83x"))
  1163. CSD_data<-mutate(CSD_data, Genotype = ifelse(Group =='6wt'|Group =='8wt', "WT", "3xTg"))
  1164. CSD_data<-mutate(CSD_data, Age_Broad = ifelse(Group =='6wt'|Group =='63x', 6, 8))
  1165. CSD_data$Age <- factor(CSD_data$Age_Broad, # Reordering factor levels
  1166. levels = c("6", "8"))
  1167. CSD_data$Layer <- factor(CSD_data$Layer, # Reordering region factor levels
  1168. levels = c("Hil", "GC", "Mol", "LM", "Rad", "Pyr", "Or"))
  1169. CSD_data$Genotype <- factor(CSD_data$Genotype, # Reordering genotype factor levels
  1170. levels = c("WT", "3xTg"))
  1171. CSD_data_maxbylyr_cycle = subset(CSD_data, DataType == 'maxbylyr_cycle')
  1172. CSD_data_maxbylyr_cycle_6mo = subset(CSD_data_maxbylyr_cycle, Age_Broad == '6')
  1173. CSD_data_maxbylyr_cycle_8mo = subset(CSD_data_maxbylyr_cycle, Age_Broad == '8')
  1174. ggsave(
  1175. "CSDtheta_6mo.svg",
  1176. CSDbygroup_6mo(CSD_data_maxbylyr_cycle_6mo, Value, 'CSD Magnitude', 'CSD Magnitude', 0, 100),
  1177. width = 6,
  1178. height = 7,
  1179. dpi = 600)
  1180. ggsave(
  1181. "CSDtheta_8mo.svg",
  1182. CSDbygroup_8mo(CSD_data_maxbylyr_cycle_8mo, Value, 'CSD Magnitude', 'CSD Magnitude', 0, 100),
  1183. width = 6,
  1184. height = 7,
  1185. dpi = 600)
  1186. CSDbygroup_6mo(CSD_data_maxbylyr_cycle_6mo, Value, 'CSD Magnitude', 'CSD Magnitude', 0, 100)
  1187. CSDbygroup_8mo(CSD_data_maxbylyr_cycle_8mo, Value, 'CSD Magnitude', 'CSD Magnitude', 0, 100)
  1188. print("used prism for CSD stats due to missing data")
  1189. print("3 way Sex x Genotype x Layer for CSD data from 8 mo animals")
  1190. CSDstats_3way(CSD_data_maxbylyr_cycle_8mo)
  1191. ```
  1192. ### Theta Coherence Within and Between MEC and Hippocampus (Figure 3, S4)
  1193. ```{r theta-coh, echo=FALSE, warning = FALSE}
  1194. Cohbygroup_6mo <- function(region_freq_statedf_6mo, y, title, ytitle, ymin, ymax) {
  1195. plot <-ggplot(region_freq_statedf_6mo, aes(x=Region2, y={{y}}))
  1196. plot + geom_line(aes(x = Region2, y = {{y}}, group = Genotype, colour=Genotype), stat="summary", fun.y = "mean", size = 1.2, alpha =1) +
  1197. geom_point(aes(x = Region2, y = {{y}}, group = Genotype, colour=Genotype), stat="summary", fun.y = "mean", alpha = 0.7, size = 0.7) +
  1198. stat_summary(fun.data = mean_se, geom = "pointrange", size = 0.7, alpha = 0.7, linewidth = 1.2,
  1199. aes(x=Region2, y={{y}}, group = Genotype, colour=Genotype), show.legend = FALSE) +
  1200. theme(panel.grid.major = element_blank(),
  1201. panel.grid.minor = element_blank(),
  1202. panel.background = element_blank(),
  1203. axis.line = element_line(colour = "black"),
  1204. plot.title = element_text(size = 22, face ="bold", hjust = 0.5),
  1205. axis.text=element_text(size=20, face="bold", colour = "black"),
  1206. axis.title=element_text(size=22, face="bold", colour = "black"),
  1207. legend.text=element_text(size=16),
  1208. legend.title=element_text(size=18),
  1209. strip.text.x = element_text(size = 18, face = "bold"),
  1210. strip.background = element_rect( fill="white"),
  1211. panel.spacing.x = unit(1.4, "lines"),
  1212. legend.key=element_rect(fill="white", colour = NA),
  1213. strip.placement = "outside") +
  1214. ggtitle(title) + xlab("Layer") + ylab(ytitle)+
  1215. scale_color_manual("legend", values = scale_colour_palette_6mo, labels = c("WT 6 mo", "3xTg 6 mo"))+
  1216. coord_flip(ylim=c(ymin, ymax)) +
  1217. guides(colour=guide_legend("Group",override.aes = list(size = 4))) +
  1218. labs(colour= "Group") +
  1219. scale_alpha(guide = 'none')
  1220. }
  1221. Cohbygroup_8mo <- function(region_freq_statedf_8mo, y, title, ytitle, ymin, ymax) {
  1222. plot <-ggplot(region_freq_statedf_8mo, aes(x=Region2, y={{y}}))
  1223. plot + geom_line(aes(x = Region2, y = {{y}}, group = Genotype, colour=Genotype), stat="summary", fun.y = "mean", size = 1.2, alpha =1) +
  1224. geom_point(aes(x = Region2, y = {{y}}, group = Genotype, colour=Genotype), stat="summary", fun.y = "mean", alpha = 0.7, size = 0.7) +
  1225. stat_summary(fun.data = mean_se, geom = "pointrange", size = 0.7, alpha = 0.7, linewidth = 1.2,
  1226. aes(x=Region2, y={{y}}, group = Genotype, colour=Genotype), show.legend = FALSE) +
  1227. theme(panel.grid.major = element_blank(),
  1228. panel.grid.minor = element_blank(),
  1229. panel.background = element_blank(),
  1230. axis.line = element_line(colour = "black"),
  1231. plot.title = element_text(size = 22, face ="bold", hjust = 0.5),
  1232. axis.text=element_text(size=20, face="bold", colour = "black"),
  1233. axis.title=element_text(size=22, face="bold", colour = "black"),
  1234. legend.text=element_text(size=16),
  1235. legend.title=element_text(size=18),
  1236. strip.text.x = element_text(size = 18, face = "bold"),
  1237. strip.background = element_rect( fill="white"),
  1238. panel.spacing.x = unit(1.4, "lines"),
  1239. legend.key=element_rect(fill="white", colour = NA),
  1240. strip.placement = "outside") +
  1241. ggtitle(title) + xlab("Layer") + ylab(ytitle)+
  1242. scale_color_manual("legend", values = scale_colour_palette_8mo, labels = c( "WT 8 mo", "3xTg 8 mo"))+
  1243. coord_flip(ylim=c(ymin, ymax)) +
  1244. guides(colour=guide_legend("Group",override.aes = list(size = 4))) +
  1245. labs(colour= "Group") +
  1246. scale_alpha(guide = 'none')
  1247. }
  1248. theta_data <- read.csv('Coherence_average_by_layer.csv')
  1249. theta_data$Group <- factor(theta_data$Group , # Reordering factor levels
  1250. levels = c("6wt", "8wt", "63x", "83x"))
  1251. theta_data$Region2 <- factor(theta_data$Region2 , # Reordering factor levels
  1252. levels = c("Hil", "GC", "Mol", "LM", "Rad" , "Pyr", "Or", "MEC2", "MEC3"))
  1253. theta_data$Region1 <- factor(theta_data$Region1 , # Reordering factor levels
  1254. levels = c("Hil", "GC", "Mol", "LM", "Rad" , "Pyr", "Or", "MEC2", "MEC3"))
  1255. theta_data <- mutate(theta_data, Genotype = ifelse(Group =='6wt'|Group =='8wt', "WT", "3xTg"))
  1256. theta_data<-mutate(theta_data, Age_Broad = ifelse(Group =='6wt'|Group =='63x', 6, 8))
  1257. theta_data$Age_Broad <- factor(theta_data$Age_Broad, # Reordering factor levels
  1258. levels = c("6", "8"))
  1259. theta_data$Genotype <- factor(theta_data$Genotype, # Reordering factor levels
  1260. levels = c("WT", "3xTg"))
  1261. theta_data <-mutate(theta_data, Speed_over_baseline = Avg_speed-Run_bl)
  1262. theta_data_runthresh <-subset(theta_data, Run_state == 'runthresh')
  1263. hil_theta_runthresh <- subset(theta_data_runthresh, Region1 == 'Hil')
  1264. gc_theta_runthresh <- subset(theta_data_runthresh, Region1 == 'GC')
  1265. mol_theta_runthresh <- subset(theta_data_runthresh, Region1 == 'Mol')
  1266. lm_theta_runthresh <- subset(theta_data_runthresh, Region1 == 'LM')
  1267. rad_theta_runthresh <- subset(theta_data_runthresh, Region1 == 'Rad')
  1268. pyr_theta_runthresh <- subset(theta_data_runthresh, Region1 == 'Pyr')
  1269. or_theta_runthresh <- subset(theta_data_runthresh, Region1 == 'Or')
  1270. mec2_theta_runthresh <- subset(theta_data_runthresh, Region1 == 'MEC2')
  1271. mec3_theta_runthresh <- subset(theta_data_runthresh, Region1 == 'MEC3')
  1272. mec2_theta_runthresh_HIPP = subset(mec2_theta_runthresh, Region2 != 'MEC3' & Region2 != 'MEC2') # get all MEC vs. HIPP rows
  1273. mec2_theta_runthresh_HIPP = subset(mec2_theta_runthresh_HIPP, Animal != 'AD-WT-44-1' & Animal != '3xTg132') #Exclude animals with missing MEC data
  1274. pyr_theta_runthresh_HIPP = subset(pyr_theta_runthresh, Region2 != 'MEC3' & Region2 != 'MEC2') #get within hippocampus coherence
  1275. #split by age group
  1276. mec2_theta_runthresh_HIPP_6mo = subset(mec2_theta_runthresh_HIPP, Age_Broad == '6')
  1277. mec2_theta_runthresh_HIPP_8mo = subset(mec2_theta_runthresh_HIPP, Age_Broad == '8')
  1278. pyr_theta_runthresh_HIPP_6mo = subset(pyr_theta_runthresh_HIPP, Age_Broad == '6')
  1279. pyr_theta_runthresh_HIPP_8mo = subset(pyr_theta_runthresh_HIPP, Age_Broad == '8')
  1280. Coh1 <-Cohbygroup_6mo(mec2_theta_runthresh_HIPP_6mo, Coh, 'Hippocampus \n Theta Coherence vs. MEC', 'Coherence', 0.5, 1)
  1281. Coh2 <-Cohbygroup_8mo(mec2_theta_runthresh_HIPP_8mo, Coh, 'Hippocampus \n Theta Coherence vs. MEC', 'Coherence', 0.5, 1)
  1282. Coh3 <-Cohbygroup_6mo(pyr_theta_runthresh_HIPP_6mo, Coh, 'Hippocampus \n Theta Coherence vs. Pyr', 'Coherence', 0.5, 1)
  1283. Coh4 <-Cohbygroup_8mo(pyr_theta_runthresh_HIPP_8mo, Coh, 'Hippocampus \n Theta Coherence vs. Pyr', 'Coherence', 0.5, 1)
  1284. plot_list = list(Coh1, Coh2, Coh3, Coh4)
  1285. ID = 1
  1286. for (p in plot_list) {
  1287. ggsave(
  1288. p,
  1289. filename=paste("Coh",ID,".svg",sep=""),
  1290. width = 6,
  1291. height = 7,
  1292. dpi = 600)
  1293. ID = ID + 1
  1294. }
  1295. Coh1
  1296. Coh2
  1297. print("Theta Coh vs MEC")
  1298. print("3 way Age x Genotype x Layer ANOVA")
  1299. PowerCohPhaseStats_3way(mec2_theta_runthresh_HIPP, Coh, Age_Broad, Region2, Animal)
  1300. mec2_theta_runthresh_HIPP_WT = subset(mec2_theta_runthresh_HIPP, Genotype == 'WT')
  1301. mec2_theta_runthresh_HIPP_Tg = subset(mec2_theta_runthresh_HIPP, Genotype == '3xTg')
  1302. print("2 way Genotype x Layer ANOVA - 6mo")
  1303. PowerCohPhaseStats_2waygl(mec2_theta_runthresh_HIPP_6mo, Coh, Region2, Animal)
  1304. print("2 way Genotype x Layer ANOVA - 8mo")
  1305. PowerCohPhaseStats_2waygl(mec2_theta_runthresh_HIPP_8mo, Coh, Region2, Animal)
  1306. #print("2 way Age x Layer ANOVA - WT")
  1307. #PowerCohPhaseStats_2wayal(mec2_theta_runthresh_HIPP_WT, Coh, Age_Broad, Region2, Animal)
  1308. #print("2 way Age x Layer ANOVA - 3xTg")
  1309. #PowerCohPhaseStats_2wayal(mec2_theta_runthresh_HIPP_Tg, Coh, Age_Broad, Region2, Animal)
  1310. print("6 mo posthocs")
  1311. Posthocs_byage(mec2_theta_runthresh_HIPP_6mo, Coh, Region2)
  1312. print("8 mo posthocs")
  1313. Posthocs_byage(mec2_theta_runthresh_HIPP_8mo, Coh, Region2)
  1314. print("8 mo Sex + Geontype x Layer ANOVA")
  1315. PowerCohPhaseStats_3waygls(mec2_theta_runthresh_HIPP_8mo, Coh, Region2, Animal)
  1316. Coh3
  1317. Coh4
  1318. print("Theta Coh vs Pyr")
  1319. print("3 way Age x Genotype x Layer ANOVA")
  1320. PowerCohPhaseStats_3way(pyr_theta_runthresh_HIPP, Coh, Age_Broad, Region2, Animal)
  1321. pyr_theta_runthresh_HIPP_WT = subset(pyr_theta_runthresh_HIPP, Genotype == 'WT')
  1322. pyr_theta_runthresh_HIPP_Tg = subset(pyr_theta_runthresh_HIPP, Genotype == '3xTg')
  1323. print("2 way Genotype x Layer ANOVA - 6mo")
  1324. PowerCohPhaseStats_2waygl(pyr_theta_runthresh_HIPP_6mo, Coh, Region2, Animal)
  1325. print("2 way Genotype x Layer ANOVA - 8mo")
  1326. PowerCohPhaseStats_2waygl(pyr_theta_runthresh_HIPP_8mo, Coh, Region2, Animal)
  1327. #print("2 way Age x Layer ANOVA - WT")
  1328. #PowerCohPhaseStats_2wayal(pyr_theta_runthresh_HIPP_WT, Coh, Age_Broad, Region2, Animal)
  1329. #print("2 way Age x Layer ANOVA - 3xTg")
  1330. #PowerCohPhaseStats_2wayal(pyr_theta_runthresh_HIPP_Tg, Coh, Age_Broad, Region2, Animal)
  1331. print("6 mo posthocs")
  1332. Posthocs_byage(pyr_theta_runthresh_HIPP_6mo, Coh, Region2)
  1333. print("8 mo posthocs")
  1334. Posthocs_byage(pyr_theta_runthresh_HIPP_8mo, Coh, Region2)
  1335. # Within MEC Coherence (Fig S4)
  1336. mec2_mec3_theta_runthresh <-subset(theta_data_runthresh, Region1 == 'MEC2' & Region2 == 'MEC3')
  1337. mec2_mec3_theta_runthresh = subset(mec2_mec3_theta_runthresh, Animal != 'AD-WT-44-1' & Animal != '3xTg132' & Animal != 'WT45-1')
  1338. #rename group variable so plotting function can find it
  1339. mec2_mec3_theta_runthresh <- mutate(mec2_mec3_theta_runthresh, Group_name = Group)
  1340. mec2_mec3_theta_runthresh <- mutate(mec2_mec3_theta_runthresh, Age = Age_Broad)
  1341. mec2_mec3_theta_runthresh$Group_name <- factor(mec2_mec3_theta_runthresh$Group_name,
  1342. levels =c("6wt", "8wt", "63x", "83x"))
  1343. mec2_mec3_theta_runthresh$Age <- factor(mec2_mec3_theta_runthresh$Age,
  1344. levels =c("6", "8"))
  1345. mec2_mec3_theta_runthresh$Sex <- factor(mec2_mec3_theta_runthresh$Sex, levels = c("F", "M"))
  1346. ggsave(
  1347. "MEC2vMEC3Coh.svg",
  1348. AnyPlotbygroupandsex_adjaxis_facet(mec2_mec3_theta_runthresh, Coh, 'Theta Coherence \n MEC2 vs MEC3', 'Coherence', 0.5, 1),
  1349. width = 4,
  1350. height = 5,
  1351. dpi = 600)
  1352. AnyPlotbygroupandsex_adjaxis_facet(mec2_mec3_theta_runthresh, Coh, 'Theta Coherence \n MEC2 vs MEC3', 'Coherence', 0.5, 1)
  1353. print("Theta Coh within MEC")
  1354. mec2_mec3_theta_runthresh <-subset(mec2_mec3_theta_runthresh, !(is.na(Coh)))
  1355. General_AOVbyanim_ez(mec2_mec3_theta_runthresh, Coh, Age_Broad, Animal)
  1356. ```
  1357. ### Main LFP findings plotted by running speed (Fig S3)
  1358. ```{r lfp-by-speed, echo=FALSE, warning = FALSE}
  1359. Plotbygroup_setaxislabels <- function(df, x, y, title, xtitle, ytitle, ymin, ymax) { #ymin, ymax
  1360. plot <-ggplot(df, aes(x={{x}}, y={{y}}))
  1361. plot + geom_line(aes(x = {{x}}, y = {{y}}, group = Group, colour=Group), stat="summary", fun.y = "mean", linewidth = 1.2, alpha =1) +
  1362. geom_point(aes(x={{x}}, y={{y}}, group = Group, colour=Group), stat="summary", fun.y = "mean", alpha = 0.7, size = 0.7) +
  1363. stat_summary(fun.data = mean_se, geom = "pointrange", size = 0.7, alpha = 0.7, linewidth = 1.2, aes(x={{x}}, y={{y}}, group = Group, colour=Group), show.legend = FALSE) +
  1364. theme(panel.grid.major = element_blank(),
  1365. panel.grid.minor = element_blank(),
  1366. panel.background = element_blank(),
  1367. axis.line = element_line(colour = "black"),
  1368. plot.title = element_text(size = 22, face ="bold", hjust = 0.5),
  1369. axis.text.x =element_text(size=16, face="bold", colour = "black"), #angle = 45, hjust = 1
  1370. axis.text.y=element_text(size=18, face="bold", colour = "black"),
  1371. axis.title=element_text(size=20, face="bold", colour = "black"),
  1372. legend.text=element_text(size=16),
  1373. legend.title=element_text(size=18),
  1374. legend.key = element_rect(fill = "white", color ="white"),
  1375. strip.text.x = element_text(size = 18, face = "bold"),
  1376. strip.background = element_rect( fill="white"),
  1377. strip.placement = "outside") +
  1378. ggtitle(title) + xlab(xtitle) + ylab(ytitle)+
  1379. scale_color_manual("legend", values = scale_colour_palette, labels = c("WT 6 mo", "WT 8 mo", "3xTg 6 mo","3xTg 8 mo"))+
  1380. guides(colour=guide_legend("Group", override.aes = list(size = 4))) +
  1381. #scale_color_manual(values = c("#509FE9","#1721A6","#E8B7EB", "#8817BD"), labels = c("WT 6 mo", "WT 8 mo", "3xTg 6 mo","3xTg 8 mo"))+
  1382. coord_cartesian(ylim=c(ymin, ymax)) +
  1383. #scale_x_continuous(breaks = numbreaks, labels=xlabels)
  1384. #coord_flip() +
  1385. labs(colour= "Group") +
  1386. scale_alpha(guide = 'none')
  1387. }
  1388. # theta power in LM by speed
  1389. data <-read.csv("Power_by_speed_theta_HIPP_LM.csv")
  1390. data <- mutate(data, Genotype = ifelse(Group =='6wt'|Group =='8wt', "WT", "3xTg"))
  1391. data <- mutate(data, Age_broad = ifelse(Group =='6wt'|Group =='63x', 6, 8))
  1392. data$Genotype <- factor(data$Genotype , # Reordering group factor levels
  1393. levels = c("WT", "3xTg"))
  1394. data$Age_broad <- factor(data$Age_broad, # Reordering group factor levels
  1395. levels = c("6", "8"))
  1396. data$Sex <- factor(data$Sex, # Reordering group factor levels
  1397. levels = c("F", "M"))
  1398. data$Group <- factor(data$Group, # Reordering group factor levels
  1399. levels = c("6wt", "8wt", "63x", "83x"))
  1400. data_wideLM<-data
  1401. data_wideLM <- data_wideLM %>%
  1402. dplyr::select(Animal, Genotype, Group, Sex, Age_broad, Power_in_range, Speed_bin_min)
  1403. data_wideLM <- dcast(data_wideLM , Animal + Genotype +Group +Sex + Age_broad ~ Speed_bin_min , value.var = "Power_in_range", na.rm=TRUE)
  1404. data_wideLM[data_wideLM == "NaN"] <- NA
  1405. data_longLM <- melt(data_wideLM, id = c("Animal", "Genotype", "Group", "Sex", "Age_broad" ))
  1406. colnames(data_longLM) <- c("Animal", "Genotype", "Group", "Sex", "Age_broad", "Speed_bin", "Power")
  1407. data_long_numLM <- mutate(data_longLM, Speed_bin = as.numeric(as.character(Speed_bin)))
  1408. data_long_subLM_0.7 <-subset(data_long_numLM, Speed_bin < 0.7)
  1409. LMPower_0.7 <- Plotbygroup_setaxislabels(data_long_subLM_0.7, Speed_bin, Power, "LM Power vs. Speed", "Speed (m/s)", "Theta Power", 0, 400)
  1410. LMPower_0.7 <- LMPower_0.7 + scale_x_continuous(breaks = seq(0, 0.6, 0.1), labels=c("0", "0.1", "0.2", "0.3", "0.4", "0.5", "0.6"))
  1411. LMPower_0.7
  1412. ggsave(
  1413. "LMPower_0.7.svg",
  1414. LMPower_0.7,
  1415. width = 7,
  1416. height = 5,
  1417. dpi = 600
  1418. )
  1419. data_long_subLM_0.7_fac <- data_long_subLM_0.7
  1420. #make speed bin a factor and set contrasts for type 3 anova
  1421. data_long_subLM_0.7_fac$Speed_bin <- factor(data_long_subLM_0.7_fac$Speed_bin)
  1422. contrasts(data_long_subLM_0.7_fac$Speed_bin) <- contr.sum
  1423. contrasts(data_long_subLM_0.7_fac$Group) <- contr.sum
  1424. #generate linear model
  1425. lmpowertest <- lm(Power ~ Group + Speed_bin + Group:Speed_bin, data = data_long_subLM_0.7_fac)
  1426. #get anova table
  1427. anova_test(lmpowertest, type = 3)
  1428. # plot time in each speed bin
  1429. data_wide_length <- data%>%
  1430. dplyr::select(Animal, Genotype, Group, Sex, Age_broad, Speed_bin_min, Length_time_s)
  1431. data_wide_length <- dcast(data_wide_length , Animal + Genotype +Group +Sex + Age_broad ~ Speed_bin_min , value.var = "Length_time_s", na.rm=TRUE)
  1432. data_wide_length [data_wide_length == "NaN"] <- NA
  1433. data_long_length <- melt(data_wide_length, id = c("Animal", "Genotype", "Group", "Sex", "Age_broad" ))
  1434. colnames(data_long_length) <- c("Animal", "Genotype", "Group", "Sex", "Age_broad", "Speed_bin", "Length_s")
  1435. data_long_length <- mutate(data_long_length , Speed_bin = as.numeric(as.character(Speed_bin)))
  1436. data_long_length_sub <- subset(data_long_length , Speed_bin < 1)
  1437. data_long_length_sub <- subset(data_long_length_sub , Speed_bin > 0)
  1438. LengthbySpeed <- Plotbygroup_setaxislabels(data_long_length_sub, Speed_bin, Length_s, "Time in Speed Bin", "Speed (m/s)", "Time (s)", 0, 500)
  1439. LengthbySpeed <- LengthbySpeed + scale_x_continuous(breaks = seq(0.1, 0.9, 0.1), labels=c("0.1", "0.2", "0.3", "0.4", "0.5", "0.6", "0.7", "0.8", "0.9"))
  1440. LengthbySpeed
  1441. ggsave(
  1442. "LengthbySpeed.svg",
  1443. LengthbySpeed ,
  1444. width = 7,
  1445. height = 5,
  1446. dpi = 600
  1447. )
  1448. data_long_length_sub_fac <- data_long_length_sub
  1449. #make speed bin a factor and set contrasts for type 3 anova
  1450. data_long_length_sub_fac$Speed_bin <- factor(data_long_length_sub_fac$Speed_bin)
  1451. contrasts(data_long_length_sub_fac$Speed_bin) <- contr.sum
  1452. contrasts(data_long_length_sub_fac$Group) <- contr.sum
  1453. #generate linear model
  1454. lengthtest <- lm(Length_s ~ Group + Speed_bin + Group:Speed_bin, data = data_long_length_sub_fac)
  1455. #get anova table
  1456. anova_test(lengthtest, type = 3) #Anova gives same p values
  1457. # plot LM CSD magnitude by speed bin
  1458. data <-read.csv("CSDrunoutput_byspeed_HIPP.csv")
  1459. data <- mutate(data, Genotype = ifelse(Group =='6wt'|Group =='8wt', "WT", "3xTg"))
  1460. data <- mutate(data, Age_broad = ifelse(Group =='6wt'|Group =='63x', 6, 8))
  1461. data$Genotype <- factor(data$Genotype , # Reordering group factor levels
  1462. levels = c("WT", "3xTg"))
  1463. data$Age_broad <- factor(data$Age_broad, # Reordering group factor levels
  1464. levels = c("6", "8"))
  1465. data$Sex <- factor(data$Sex, # Reordering group factor levels
  1466. levels = c("F", "M"))
  1467. data$Group <- factor(data$Group, # Reordering group factor levels
  1468. levels = c("6wt", "8wt", "63x", "83x"))
  1469. data <- subset(data, DataType == "maxbylyr_cycle")
  1470. data_wide<- mutate(data, Binmin= as.numeric(Binmin))
  1471. data_wide_LM <- data_wide %>%
  1472. dplyr::select(Animal, Genotype, Group, Sex, Age_broad, Binmin, LM)
  1473. data_wide_LM <- dcast(data_wide_LM , Animal + Genotype +Group +Sex + Age_broad ~ Binmin , value.var = "LM", na.rm=TRUE)
  1474. data_wide_LM [data_wide_LM == "NaN"] <- NA
  1475. data_long_LM <- melt(data_wide_LM , id = c("Animal", "Genotype", "Group", "Sex", "Age_broad" ))
  1476. colnames(data_long_LM ) <- c("Animal", "Genotype", "Group", "Sex", "Age_broad", "Speed_bin", "CSD_Mag_LM")
  1477. data_long_LM_num <- mutate(data_long_LM, Speed_bin = as.numeric(as.character(Speed_bin)))
  1478. data_long_LM_sub <-subset(data_long_LM_num, Speed_bin < 0.7)
  1479. LMCSD <- Plotbygroup_setaxislabels(data_long_LM_sub, Speed_bin, CSD_Mag_LM, "LM CSD Magnitude vs. Speed", "Speed (m/s)", "Theta CSD Mag", 0, 100)
  1480. LMCSD <- LMCSD + scale_x_continuous(breaks = seq(0, 0.6, 0.1), labels=c("0", "0.1", "0.2", "0.3", "0.4", "0.5", "0.6"))
  1481. LMCSD
  1482. ggsave(
  1483. "LMCSD.svg",
  1484. LMCSD,
  1485. width = 7,
  1486. height = 5,
  1487. dpi = 600
  1488. )
  1489. data_long_LM_sub_fac <- data_long_LM_sub
  1490. #make speed bin a factor and set contrasts for type 3 anova
  1491. data_long_LM_sub_fac$Speed_bin <- factor(data_long_LM_sub_fac$Speed_bin)
  1492. contrasts(data_long_LM_sub_fac$Speed_bin) <- contr.sum
  1493. contrasts(data_long_LM_sub_fac$Group) <- contr.sum
  1494. #generate linear model
  1495. lmcsd<- lm(CSD_Mag_LM ~ Group + Speed_bin + Group:Speed_bin, data = data_long_LM_sub_fac)
  1496. #get anova table
  1497. anova_test(lmcsd, type = 3) #Anova gives same p values
  1498. # MEC vs CA1 coherence by speed
  1499. #load data
  1500. coh_data <- read.csv("Coherence_byspeed_PyrvMEC2.csv")
  1501. #set up grouping variables
  1502. coh_data <- mutate(coh_data, Genotype = ifelse(Group =='6wt'|Group =='8wt', "WT", "3xTg"))
  1503. coh_data <- mutate(coh_data, Age_broad = ifelse(Group =='6wt'|Group =='63x', 6, 8))
  1504. coh_data$Genotype <- factor(coh_data$Genotype , # Reordering group factor levels
  1505. levels = c("WT", "3xTg"))
  1506. coh_data$Age_broad <- factor(coh_data$Age_broad, # Reordering group factor levels
  1507. levels = c("6", "8"))
  1508. coh_data$Sex <- factor(coh_data$Sex, # Reordering group factor levels
  1509. levels = c("F", "M"))
  1510. coh_data$Group <- factor(coh_data$Group, # Reordering group factor levels
  1511. levels = c("6wt", "8wt", "63x", "83x"))
  1512. coh_data<- mutate(coh_data, RunThresh_Low= as.numeric(RunThresh_Low))
  1513. #make data frame with lengths of windows in each speed threshold
  1514. coh_data_wide_length <- coh_data %>%
  1515. dplyr::select(Animal, Genotype, Group, Sex, Age_broad, RunThresh_Low, Length_Run_Thresh)
  1516. coh_data_wide_length <- dcast(coh_data_wide_length , Animal + Genotype +Group +Sex + Age_broad ~ RunThresh_Low , value.var = "Length_Run_Thresh", na.rm=TRUE)
  1517. coh_data_wide_length [coh_data_wide_length == "NaN"] <- NA
  1518. coh_data_long_length <- melt(coh_data_wide_length, id = c("Animal", "Genotype", "Group", "Sex", "Age_broad" ))
  1519. colnames(coh_data_long_length) <- c("Animal", "Genotype", "Group", "Sex", "Age_broad", "Speed_bin", "Length_s")
  1520. #make data frame with coherence at each speed threshold
  1521. coh_data_wide<- coh_data %>%
  1522. dplyr::select(Animal, Genotype, Group, Sex, Age_broad, RunThresh_Low, Coh_RunThresh)
  1523. coh_data_wide <- dcast(coh_data_wide , Animal + Genotype +Group +Sex + Age_broad ~ RunThresh_Low , value.var = "Coh_RunThresh", na.rm=TRUE)
  1524. coh_data_wide [coh_data_wide == "NaN"] <- NA
  1525. coh_data_long <- melt(coh_data_wide, id = c("Animal", "Genotype", "Group", "Sex", "Age_broad" ))
  1526. colnames(coh_data_long) <- c("Animal", "Genotype", "Group", "Sex", "Age_broad", "Speed_bin", "Coh")
  1527. coh_data_long <- mutate(coh_data_long , Speed_bin = as.numeric(as.character(Speed_bin)))
  1528. coh_data_long_sub <- subset(coh_data_long , Speed_bin < 0.7)
  1529. CohbySpeed <- Plotbygroup_setaxislabels(coh_data_long_sub, Speed_bin, Coh, "MEC-CA1 \n Coherence vs. Speed ", "Speed (m/s)", "MEC-CA1 Theta Coh ", 0.5, 1)
  1530. CohbySpeed<- CohbySpeed + scale_x_continuous(breaks = seq(0, 0.6, 0.1), labels=c("0", "0.1", "0.2", "0.3", "0.4", "0.5", "0.6"))
  1531. CohbySpeed
  1532. ggsave(
  1533. "MEC-CA1CohbySpeed.svg",
  1534. CohbySpeed ,
  1535. width = 7,
  1536. height = 5,
  1537. dpi = 600
  1538. )
  1539. coh_data_long_sub_fac <- coh_data_long_sub
  1540. #make speed bin a factor and set contrasts for type 3 anova
  1541. coh_data_long_sub_fac$Speed_bin <- factor(coh_data_long_sub_fac$Speed_bin)
  1542. contrasts(coh_data_long_sub_fac$Speed_bin) <- contr.sum
  1543. contrasts(coh_data_long_sub_fac$Group) <- contr.sum
  1544. #generate linear model
  1545. mecca1cohtest <- lm(Coh~ Group + Speed_bin + Group:Speed_bin, data = coh_data_long_sub_fac)
  1546. #get anova table
  1547. anova_test(mecca1cohtest, type = 3) #Anova gives same p values
  1548. ```
  1549. ### Theta Frequency (PSD) (Figure S6)
  1550. ```{r theta-psd, echo=FALSE, warning = FALSE}
  1551. PeakFreq_bygroupandsex_final <- function(df, y, title, ytitle, ymin, ymax) {
  1552. plot <-ggplot(df ,aes(x=Groupname, y={{y}}))
  1553. plot <-ggplot(df ,aes(x=Genotype, y={{y}}))
  1554. plot +geom_sina(aes(col= Groupname, shape = Sex), alpha = 0.5, na.rm = TRUE, show.legend=TRUE, jitter_y = FALSE) +
  1555. geom_bar(position= "dodge", stat = "summary", width = 0.9, fun.y = "mean", alpha = 0.4, aes(fill=Groupname), color = "black") +
  1556. stat_summary( color = "black", fun.data = mean_se, geom = "errorbar", width = 0.4, alpha = 0.8, show.legend=FALSE) +
  1557. ggtitle(title) + ylab(ytitle) + # + xlab("Age”)+
  1558. scale_fill_manual("legend", values = scale_fill_palette, labels = c("WT 6 mo", "WT 8 mo", "3xTg 6 mo", "3xTg 8 mo"))+
  1559. guides(fill=guide_legend("Group")) +
  1560. scale_color_manual("legend", values = scale_colour_palette, guide = "none")+
  1561. scale_y_continuous(expand = c(0,0)) + #, limits = c(ymin,ymax), breaks = seq(0, 14, by = 2))
  1562. coord_cartesian(ylim=c(ymin, ymax))+
  1563. scale_alpha(guide = 'none') +
  1564. facet_grid(.~Age_Broad, switch = "x", labeller = as_labeller(c('6' = "6 mo", '8' = "8 mo"))) +
  1565. theme(plot.title = element_text(hjust = 0.5, size = 22, face = "bold"),
  1566. axis.text.x = element_text(size = 16, colour = "black"),
  1567. axis.text.y = element_text(size = 18, face="bold", colour = "black"),
  1568. axis.title.y = element_text(size = 20, face = "bold", colour = "black"),
  1569. axis.title.x = element_blank(),
  1570. legend.text=element_text(size=12),
  1571. legend.title=element_text(size=14),
  1572. panel.grid.major = element_blank(),
  1573. panel.grid.minor = element_blank(),
  1574. panel.background = element_blank(),
  1575. axis.line = element_line(colour = "black"),
  1576. strip.text.x = element_text(size = 18, face = "bold"),
  1577. strip.background = element_rect( fill="white"),
  1578. panel.spacing.x = unit(1.4, "lines"),
  1579. strip.placement = "outside")
  1580. }
  1581. #Oriens
  1582. data <- readMat("WaveletPSD_trackAlyrOr_theta.mat")
  1583. data <- data[[1]]
  1584. animals = data[[1]]
  1585. animals<- matrix(unlist(animals),byrow=TRUE)
  1586. group = data[[2]]
  1587. group<- matrix(unlist(group),byrow=TRUE)
  1588. sex = data[[3]]
  1589. sex<- matrix(unlist(sex),byrow=TRUE)
  1590. age = data[[4]]
  1591. age<- matrix(unlist(age),byrow=TRUE)
  1592. ###
  1593. Peakfreq_runthresh = data[[22]]
  1594. Peakfreq_runthresh<- unlist(Peakfreq_runthresh,recursive=FALSE)
  1595. Peakfreq_runthresh <- t(as.data.frame(do.call(cbind, Peakfreq_runthresh)))
  1596. Peakfreq_runthresh_df<- cbind(animals, group, sex, age, Peakfreq_runthresh)
  1597. colnames(Peakfreq_runthresh_df) <- c("Animal" ,"Groupname", "Sex", "Age", "PeakThetaFreq")
  1598. Peakfreq_runthresh_df <- as.data.frame(Peakfreq_runthresh_df)
  1599. Peakfreq_runthresh_df$Groupname<- factor(Peakfreq_runthresh_df$Groupname, # Reordering group factor levels
  1600. levels = c("6wt", "8wt", "63x", "83x"))
  1601. Peakfreq_runthresh_df$PeakThetaFreq<- as.numeric(Peakfreq_runthresh_df$PeakThetaFreq)
  1602. #add for stats
  1603. Peakfreq_runthresh_df <- mutate(Peakfreq_runthresh_df, Genotype = ifelse(Groupname =='6wt'|Groupname =='8wt', "WT", "3xTg"))
  1604. Peakfreq_runthresh_df<-mutate(Peakfreq_runthresh_df, Age_Broad = ifelse(Groupname =='6wt'|Groupname =='63x', 6, 8))
  1605. Peakfreq_runthresh_df$Genotype <- factor(Peakfreq_runthresh_df$Genotype ,
  1606. levels = c("WT", "3xTg"))
  1607. Peakfreq_runthresh_df$Age_Broad <- factor(Peakfreq_runthresh_df$Age_Broad,
  1608. levels = c("6", "8"))
  1609. PeakFreq_bygroupandsex_final(Peakfreq_runthresh_df, PeakThetaFreq, 'Peak Theta (5-12 Hz) \n Frequency Oriens', 'Frequency (Hz)', 0, 8.5)
  1610. General_AOVbyanim_ez(Peakfreq_runthresh_df, PeakThetaFreq, Age_Broad, Animal)
  1611. General_byanim_holm(Peakfreq_runthresh_df, PeakThetaFreq, Age_Broad)
  1612. ggsave(
  1613. "PSDfreqbygroupOr_sex.svg",
  1614. PeakFreq_bygroupandsex_final(Peakfreq_runthresh_df, PeakThetaFreq, 'Peak Theta (5-12 Hz) \n Frequency Oriens', 'Frequency (Hz)', 0, 8.5),
  1615. width = 5,
  1616. height = 5,
  1617. dpi = 600
  1618. )
  1619. #PYRAMIDAL LAYER
  1620. data <- readMat("WaveletPSD_trackAlyrPyr_theta.mat")
  1621. data <- data[[1]]
  1622. animals = data[[1]]
  1623. animals<- matrix(unlist(animals),byrow=TRUE)
  1624. group = data[[2]]
  1625. group<- matrix(unlist(group),byrow=TRUE)
  1626. sex = data[[3]]
  1627. sex<- matrix(unlist(sex),byrow=TRUE)
  1628. age = data[[4]]
  1629. age<- matrix(unlist(age),byrow=TRUE)
  1630. ###
  1631. Peakfreq_runthresh = data[[22]]
  1632. Peakfreq_runthresh<- unlist(Peakfreq_runthresh,recursive=FALSE)
  1633. Peakfreq_runthresh <- t(as.data.frame(do.call(cbind, Peakfreq_runthresh)))
  1634. Peakfreq_runthresh_df<- cbind(animals, group, sex, age, Peakfreq_runthresh)
  1635. colnames(Peakfreq_runthresh_df) <- c("Animal" ,"Groupname", "Sex", "Age", "PeakThetaFreq")
  1636. Peakfreq_runthresh_df <- as.data.frame(Peakfreq_runthresh_df)
  1637. Peakfreq_runthresh_df$Groupname<- factor(Peakfreq_runthresh_df$Groupname, # Reordering group factor levels
  1638. levels = c("6wt", "8wt", "63x", "83x"))
  1639. Peakfreq_runthresh_df$PeakThetaFreq<- as.numeric(Peakfreq_runthresh_df$PeakThetaFreq)
  1640. #add for stats
  1641. Peakfreq_runthresh_df <- mutate(Peakfreq_runthresh_df, Genotype = ifelse(Groupname =='6wt'|Groupname =='8wt', "WT", "3xTg"))
  1642. Peakfreq_runthresh_df<-mutate(Peakfreq_runthresh_df, Age_Broad = ifelse(Groupname =='6wt'|Groupname =='63x', 6, 8))
  1643. Peakfreq_runthresh_df$Genotype <- factor(Peakfreq_runthresh_df$Genotype ,
  1644. levels = c("WT", "3xTg"))
  1645. Peakfreq_runthresh_df$Age_Broad <- factor(Peakfreq_runthresh_df$Age_Broad,
  1646. levels = c("6", "8"))
  1647. PeakFreq_bygroupandsex_final(Peakfreq_runthresh_df, PeakThetaFreq, 'Peak Theta (5-12 Hz) \n Frequency Pyr', 'Frequency (Hz)', 0, 8.5)
  1648. General_AOVbyanim_ez(Peakfreq_runthresh_df, PeakThetaFreq, Age_Broad, Animal)
  1649. General_byanim_holm(Peakfreq_runthresh_df, PeakThetaFreq, Age_Broad)
  1650. ggsave(
  1651. "PSDfreqbygroupPyr_sex.svg",
  1652. PeakFreq_bygroupandsex_final(Peakfreq_runthresh_df, PeakThetaFreq, 'Peak Theta (5-12 Hz) \n Frequency Pyr', 'Frequency (Hz)', 0, 8.5),
  1653. width = 5,
  1654. height = 5,
  1655. dpi = 600
  1656. )
  1657. #RADIATUM
  1658. data <- readMat("WaveletPSD_trackAlyrRad_theta.mat")
  1659. data <- data[[1]]
  1660. animals = data[[1]]
  1661. animals<- matrix(unlist(animals),byrow=TRUE)
  1662. group = data[[2]]
  1663. group<- matrix(unlist(group),byrow=TRUE)
  1664. sex = data[[3]]
  1665. sex<- matrix(unlist(sex),byrow=TRUE)
  1666. age = data[[4]]
  1667. age<- matrix(unlist(age),byrow=TRUE)
  1668. ###
  1669. Peakfreq_runthresh = data[[22]]
  1670. Peakfreq_runthresh<- unlist(Peakfreq_runthresh,recursive=FALSE)
  1671. Peakfreq_runthresh <- t(as.data.frame(do.call(cbind, Peakfreq_runthresh)))
  1672. Peakfreq_runthresh_df<- cbind(animals, group, sex, age, Peakfreq_runthresh)
  1673. colnames(Peakfreq_runthresh_df) <- c("Animal" ,"Groupname", "Sex", "Age", "PeakThetaFreq")
  1674. Peakfreq_runthresh_df <- as.data.frame(Peakfreq_runthresh_df)
  1675. Peakfreq_runthresh_df$Groupname<- factor(Peakfreq_runthresh_df$Groupname, # Reordering group factor levels
  1676. levels = c("6wt", "8wt", "63x", "83x"))
  1677. Peakfreq_runthresh_df$PeakThetaFreq<- as.numeric(Peakfreq_runthresh_df$PeakThetaFreq)
  1678. #add for stats
  1679. Peakfreq_runthresh_df <- mutate(Peakfreq_runthresh_df, Genotype = ifelse(Groupname =='6wt'|Groupname =='8wt', "WT", "3xTg"))
  1680. Peakfreq_runthresh_df<-mutate(Peakfreq_runthresh_df, Age_Broad = ifelse(Groupname =='6wt'|Groupname =='63x', 6, 8))
  1681. Peakfreq_runthresh_df$Genotype <- factor(Peakfreq_runthresh_df$Genotype ,
  1682. levels = c("WT", "3xTg"))
  1683. Peakfreq_runthresh_df$Age_Broad <- factor(Peakfreq_runthresh_df$Age_Broad,
  1684. levels = c("6", "8"))
  1685. PeakFreq_bygroupandsex_final(Peakfreq_runthresh_df, PeakThetaFreq, 'Peak Theta (5-12 Hz) \n Frequency Rad', 'Frequency (Hz)', 0, 8.5)
  1686. General_AOVbyanim_ez(Peakfreq_runthresh_df, PeakThetaFreq, Age_Broad, Animal)
  1687. General_byanim_holm(Peakfreq_runthresh_df, PeakThetaFreq, Age_Broad)
  1688. ggsave(
  1689. "PSDfreqbygroupRad_sex.svg",
  1690. PeakFreq_bygroupandsex_final(Peakfreq_runthresh_df, PeakThetaFreq, 'Peak Theta (5-12 Hz) \n Frequency Rad', 'Frequency (Hz)', 0, 8.5),
  1691. width = 5,
  1692. height = 5,
  1693. dpi = 600
  1694. )
  1695. ## LACUNOSUM MOLECULARE
  1696. data <- readMat("WaveletPSD_trackAlyrLM_theta.mat")
  1697. data <- data[[1]]
  1698. animals = data[[1]]
  1699. animals<- matrix(unlist(animals),byrow=TRUE)
  1700. group = data[[2]]
  1701. group<- matrix(unlist(group),byrow=TRUE)
  1702. sex = data[[3]]
  1703. sex<- matrix(unlist(sex),byrow=TRUE)
  1704. age = data[[4]]
  1705. age<- matrix(unlist(age),byrow=TRUE)
  1706. ###
  1707. Peakfreq_runthresh = data[[22]]
  1708. Peakfreq_runthresh<- unlist(Peakfreq_runthresh,recursive=FALSE)
  1709. Peakfreq_runthresh <- t(as.data.frame(do.call(cbind, Peakfreq_runthresh)))
  1710. Peakfreq_runthresh_df<- cbind(animals, group, sex, age, Peakfreq_runthresh)
  1711. colnames(Peakfreq_runthresh_df) <- c("Animal" ,"Groupname", "Sex", "Age", "PeakThetaFreq")
  1712. Peakfreq_runthresh_df <- as.data.frame(Peakfreq_runthresh_df)
  1713. Peakfreq_runthresh_df$Groupname<- factor(Peakfreq_runthresh_df$Groupname, # Reordering group factor levels
  1714. levels = c("6wt", "8wt", "63x", "83x"))
  1715. Peakfreq_runthresh_df$PeakThetaFreq<- as.numeric(Peakfreq_runthresh_df$PeakThetaFreq)
  1716. #add for stats
  1717. Peakfreq_runthresh_df <- mutate(Peakfreq_runthresh_df, Genotype = ifelse(Groupname =='6wt'|Groupname =='8wt', "WT", "3xTg"))
  1718. Peakfreq_runthresh_df<-mutate(Peakfreq_runthresh_df, Age_Broad = ifelse(Groupname =='6wt'|Groupname =='63x', 6, 8))
  1719. Peakfreq_runthresh_df$Genotype <- factor(Peakfreq_runthresh_df$Genotype ,
  1720. levels = c("WT", "3xTg"))
  1721. Peakfreq_runthresh_df$Age_Broad <- factor(Peakfreq_runthresh_df$Age_Broad,
  1722. levels = c("6", "8"))
  1723. PeakFreq_bygroupandsex_final(Peakfreq_runthresh_df, PeakThetaFreq, 'Peak Theta (5-12 Hz) \n Frequency LM', 'Frequency (Hz)', 0, 8.5)
  1724. General_AOVbyanim_ez(Peakfreq_runthresh_df, PeakThetaFreq, Age_Broad, Animal)
  1725. General_byanim_holm(Peakfreq_runthresh_df, PeakThetaFreq, Age_Broad)
  1726. ggsave(
  1727. "PSDfreqbygroupLM_sex.svg",
  1728. PeakFreq_bygroupandsex_final(Peakfreq_runthresh_df, PeakThetaFreq, 'Peak Theta (5-12 Hz) \n Frequency LM', 'Frequency (Hz)', 0, 8.5),
  1729. width = 5,
  1730. height = 5,
  1731. dpi = 600
  1732. )
  1733. #MOLECULAR LAYER
  1734. data <- readMat("WaveletPSD_trackAlyrMol_theta.mat")
  1735. data <- data[[1]]
  1736. animals = data[[1]]
  1737. animals<- matrix(unlist(animals),byrow=TRUE)
  1738. group = data[[2]]
  1739. group<- matrix(unlist(group),byrow=TRUE)
  1740. sex = data[[3]]
  1741. sex<- matrix(unlist(sex),byrow=TRUE)
  1742. age = data[[4]]
  1743. age<- matrix(unlist(age),byrow=TRUE)
  1744. ###
  1745. Peakfreq_runthresh = data[[22]]
  1746. Peakfreq_runthresh<- unlist(Peakfreq_runthresh,recursive=FALSE)
  1747. Peakfreq_runthresh <- t(as.data.frame(do.call(cbind, Peakfreq_runthresh)))
  1748. Peakfreq_runthresh_df<- cbind(animals, group, sex, age, Peakfreq_runthresh)
  1749. colnames(Peakfreq_runthresh_df) <- c("Animal" ,"Groupname", "Sex", "Age", "PeakThetaFreq")
  1750. Peakfreq_runthresh_df <- as.data.frame(Peakfreq_runthresh_df)
  1751. Peakfreq_runthresh_df$Groupname<- factor(Peakfreq_runthresh_df$Groupname, # Reordering group factor levels
  1752. levels = c("6wt", "8wt", "63x", "83x"))
  1753. Peakfreq_runthresh_df$PeakThetaFreq<- as.numeric(Peakfreq_runthresh_df$PeakThetaFreq)
  1754. #add for stats
  1755. Peakfreq_runthresh_df <- mutate(Peakfreq_runthresh_df, Genotype = ifelse(Groupname =='6wt'|Groupname =='8wt', "WT", "3xTg"))
  1756. Peakfreq_runthresh_df<-mutate(Peakfreq_runthresh_df, Age_Broad = ifelse(Groupname =='6wt'|Groupname =='63x', 6, 8))
  1757. Peakfreq_runthresh_df$Genotype <- factor(Peakfreq_runthresh_df$Genotype ,
  1758. levels = c("WT", "3xTg"))
  1759. Peakfreq_runthresh_df$Age_Broad <- factor(Peakfreq_runthresh_df$Age_Broad,
  1760. levels = c("6", "8"))
  1761. PeakFreq_bygroupandsex_final(Peakfreq_runthresh_df, PeakThetaFreq, 'Peak Theta (5-12 Hz) \n Frequency Mol', 'Frequency (Hz)', 0, 8.5)
  1762. General_AOVbyanim_ez(Peakfreq_runthresh_df, PeakThetaFreq, Age_Broad, Animal)
  1763. General_byanim_holm(Peakfreq_runthresh_df, PeakThetaFreq, Age_Broad)
  1764. ggsave(
  1765. "PSDfreqbygroupMol_sex.svg",
  1766. PeakFreq_bygroupandsex_final(Peakfreq_runthresh_df, PeakThetaFreq, 'Peak Theta (5-12 Hz) \n Frequency Mol', 'Frequency (Hz)', 0, 8.5),
  1767. width = 5,
  1768. height = 5,
  1769. dpi = 600
  1770. )
  1771. #HILUS
  1772. data <- readMat("WaveletPSD_trackAlyrHil_theta.mat")
  1773. data <- data[[1]]
  1774. animals = data[[1]]
  1775. animals<- matrix(unlist(animals),byrow=TRUE)
  1776. group = data[[2]]
  1777. group<- matrix(unlist(group),byrow=TRUE)
  1778. sex = data[[3]]
  1779. sex<- matrix(unlist(sex),byrow=TRUE)
  1780. age = data[[4]]
  1781. age<- matrix(unlist(age),byrow=TRUE)
  1782. ###
  1783. Peakfreq_runthresh = data[[22]]
  1784. Peakfreq_runthresh<- unlist(Peakfreq_runthresh,recursive=FALSE)
  1785. Peakfreq_runthresh <- t(as.data.frame(do.call(cbind, Peakfreq_runthresh)))
  1786. Peakfreq_runthresh_df<- cbind(animals, group, sex, age, Peakfreq_runthresh)
  1787. colnames(Peakfreq_runthresh_df) <- c("Animal" ,"Groupname", "Sex", "Age", "PeakThetaFreq")
  1788. Peakfreq_runthresh_df <- as.data.frame(Peakfreq_runthresh_df)
  1789. Peakfreq_runthresh_df$Groupname<- factor(Peakfreq_runthresh_df$Groupname, # Reordering group factor levels
  1790. levels = c("6wt", "8wt", "63x", "83x"))
  1791. Peakfreq_runthresh_df$PeakThetaFreq<- as.numeric(Peakfreq_runthresh_df$PeakThetaFreq)
  1792. #add for stats
  1793. Peakfreq_runthresh_df <- mutate(Peakfreq_runthresh_df, Genotype = ifelse(Groupname =='6wt'|Groupname =='8wt', "WT", "3xTg"))
  1794. Peakfreq_runthresh_df<-mutate(Peakfreq_runthresh_df, Age_Broad = ifelse(Groupname =='6wt'|Groupname =='63x', 6, 8))
  1795. Peakfreq_runthresh_df$Genotype <- factor(Peakfreq_runthresh_df$Genotype ,
  1796. levels = c("WT", "3xTg"))
  1797. Peakfreq_runthresh_df$Age_Broad <- factor(Peakfreq_runthresh_df$Age_Broad,
  1798. levels = c("6", "8"))
  1799. PeakFreq_bygroupandsex_final(Peakfreq_runthresh_df, PeakThetaFreq, 'Peak Theta (5-12 Hz) \n Frequency Hil', 'Frequency (Hz)', 0, 8.5)
  1800. General_AOVbyanim_ez(Peakfreq_runthresh_df, PeakThetaFreq, Age_Broad, Animal)
  1801. General_byanim_holm(Peakfreq_runthresh_df, PeakThetaFreq, Age_Broad)
  1802. ggsave(
  1803. "PSDfreqbygroupHil_sex.svg",
  1804. PeakFreq_bygroupandsex_final(Peakfreq_runthresh_df, PeakThetaFreq, 'Peak Theta (5-12 Hz) \n Frequency Hil', 'Frequency (Hz)', 0, 8.5),
  1805. width = 5,
  1806. height = 5,
  1807. dpi = 600
  1808. )
  1809. #MEC2
  1810. data <- readMat("WaveletPSD_trackAlyrMEC2_theta.mat")
  1811. data <- data[[1]]
  1812. animals = data[[1]]
  1813. animals<- matrix(unlist(animals),byrow=TRUE)
  1814. group = data[[2]]
  1815. group<- matrix(unlist(group),byrow=TRUE)
  1816. sex = data[[3]]
  1817. sex<- matrix(unlist(sex),byrow=TRUE)
  1818. age = data[[4]]
  1819. age<- matrix(unlist(age),byrow=TRUE)
  1820. ###
  1821. Peakfreq_runthresh = data[[22]]
  1822. Peakfreq_runthresh<- unlist(Peakfreq_runthresh,recursive=FALSE)
  1823. Peakfreq_runthresh <- t(as.data.frame(do.call(cbind, Peakfreq_runthresh)))
  1824. Peakfreq_runthresh_df<- cbind(animals, group, sex, age, Peakfreq_runthresh)
  1825. colnames(Peakfreq_runthresh_df) <- c("Animal" ,"Groupname", "Sex", "Age", "PeakThetaFreq")
  1826. Peakfreq_runthresh_df <- as.data.frame(Peakfreq_runthresh_df)
  1827. Peakfreq_runthresh_df$Groupname<- factor(Peakfreq_runthresh_df$Groupname, # Reordering group factor levels
  1828. levels = c("6wt", "8wt", "63x", "83x"))
  1829. Peakfreq_runthresh_df$PeakThetaFreq<- as.numeric(Peakfreq_runthresh_df$PeakThetaFreq)
  1830. #add for stats
  1831. Peakfreq_runthresh_df <- mutate(Peakfreq_runthresh_df, Genotype = ifelse(Groupname =='6wt'|Groupname =='8wt', "WT", "3xTg"))
  1832. Peakfreq_runthresh_df<-mutate(Peakfreq_runthresh_df, Age_Broad = ifelse(Groupname =='6wt'|Groupname =='63x', 6, 8))
  1833. Peakfreq_runthresh_df$Genotype <- factor(Peakfreq_runthresh_df$Genotype ,
  1834. levels = c("WT", "3xTg"))
  1835. Peakfreq_runthresh_df$Age_Broad <- factor(Peakfreq_runthresh_df$Age_Broad,
  1836. levels = c("6", "8"))
  1837. PeakFreq_bygroupandsex_final(Peakfreq_runthresh_df, PeakThetaFreq, 'Peak Theta (5-12 Hz) \n Frequency MEC', 'Frequency (Hz)', 0, 8.5)
  1838. General_AOVbyanim_ez(Peakfreq_runthresh_df, PeakThetaFreq, Age_Broad, Animal)
  1839. General_byanim_holm(Peakfreq_runthresh_df, PeakThetaFreq, Age_Broad)
  1840. ggsave(
  1841. "PSDfreqbygroupMEC2_sex.svg",
  1842. PeakFreq_bygroupandsex_final(Peakfreq_runthresh_df, PeakThetaFreq, 'Peak Theta (5-12 Hz) \n Frequency MEC', 'Frequency (Hz)', 0, 8.5),
  1843. width = 5,
  1844. height = 5,
  1845. dpi = 600
  1846. )
  1847. ```
  1848. ## Single Unit Results (Figure 4, 5, 6, S8D-G)
  1849. note: fig S7 and parts of fig S8 generated in matlab
  1850. ```{r single-unit, echo=FALSE, warning = FALSE}
  1851. #firing rates, phase locking, precession
  1852. Singleunit_nonparametric <- function(celltype, y){
  1853. #CALCULATE P VALS CORRECTED FOR MULTIPLE COMPARISONS
  1854. df <- substitute(celltype)
  1855. y <- substitute(y)
  1856. yvar <- substitute(df$y, list(y=y, df = df))
  1857. gvar <- substitute(Genotype)
  1858. grpvar <-substitute(Groupname)
  1859. xvar <- substitute(df$x, list(x=grpvar, df = df))
  1860. wilcox <- eval.parent(substitute(pairwise_wilcox_test(df, y~grpvar, p.adjust.method="holm", comparisons = list(c("63x", "6wt"), c("83x", "8wt"), c("6wt", "8wt"), c("63x", "83x"))), list(y = y, grpvar = grpvar, df = df)))
  1861. return(wilcox)
  1862. }
  1863. #get non adjusted p values
  1864. Circstats_age <- function(celltype_age, y, celltype_age_WT, celltype_age_Tg){
  1865. #using aov.circular
  1866. df <- substitute(celltype_age)
  1867. WTdata <-substitute(celltype_age_WT)
  1868. Tgdata <- substitute(celltype_age_Tg)
  1869. y = substitute(y)
  1870. yvar <- substitute(df$y, list(y=y, df = df))
  1871. gvar = substitute(Genotype)
  1872. xvar <- substitute(df$x, list(x=gvar, df = df))
  1873. #kuiper test - is anything different about these distributions? (Not sure about this)
  1874. kuiper <- eval.parent(substitute(kuiper_test(Tgdata$y, WTdata$y), list(y = y, Tgdata = Tgdata, WTdata = WTdata)))
  1875. #equal kappa test - are concentration parameters different?
  1876. equalkappa <- eval.parent(substitute(equal.kappa.test(yvar, xvar), list(yvar=yvar, xvar=xvar)))
  1877. #watson williams - are means different?
  1878. watwill <- eval.parent(substitute(watson.williams.test(yvar, xvar), list(yvar=yvar, xvar=xvar)))
  1879. #watson wheeler - are distribution of angles different? unclear if this is the same as watson williams? non-parametric?
  1880. watwheel <-eval.parent(substitute(watson.wheeler.test(yvar, xvar), list(yvar=yvar, xvar=xvar)))
  1881. aovcirc <- eval.parent(substitute(aov.circular(yvar, xvar), list(yvar=yvar, xvar=xvar)))
  1882. outlist <- list(kuiper, equalkappa, watwill, watwheel, aovcirc)
  1883. return(outlist)
  1884. }
  1885. #get final adjusted p values
  1886. Circstats_full <- function(celltype_6, celltype_8, y, celltype_6_WT, celltype_6_Tg, celltype_8_WT, celltype_8_Tg){
  1887. #CALCULATE P VALS CORRECTED FOR MULTIPLE COMPARISONS - For Mu values
  1888. df <- substitute(celltype)
  1889. df6 <- substitute(celltype_6)
  1890. df8 <- substitute(celltype_8)
  1891. WT6data <-substitute(celltype_6_WT)
  1892. Tg6data <- substitute(celltype_6_Tg)
  1893. WT8data <-substitute(celltype_8_WT)
  1894. Tg8data <- substitute(celltype_8_Tg)
  1895. y <- substitute(y)
  1896. yvar <- substitute(df$y, list(y=y, df = df))
  1897. yvar6 <- substitute(df6$y, list(y=y, df6 = df6))
  1898. yvar8 <- substitute(df8$y, list(y=y, df8 = df8))
  1899. gvar <- substitute(Genotype)
  1900. xvar <- substitute(df$x, list(x=gvar, df = df))
  1901. xvar6 <- substitute(df6$x, list(x=gvar, df6 = df6))
  1902. xvar8 <- substitute(df8$x, list(x=gvar, df8 = df8))
  1903. #kuiper test - is anything different about these distributions? (Not sure about this)
  1904. kuiper_6 <- eval.parent(substitute(kuiper_test(Tg6data$y, WT6data$y), list(y = y, Tg6data = Tg6data, WT6data = WT6data)))
  1905. #equal kappa test - are concentration parameters different?
  1906. equalkappa_6 <- eval.parent(substitute(equal.kappa.test(yvar6, xvar6), list(yvar6=yvar6, xvar6=xvar6)))
  1907. #watson williams - are means different?
  1908. watwill_6 <- eval.parent(substitute(watson.williams.test(yvar6, xvar6), list(yvar6=yvar6, xvar6=xvar6)))
  1909. #watson wheeler - are distribution of angles different? unclear if this is the same as watson williams? non-parametric?
  1910. watwheel_6 <-eval.parent(substitute(watson.wheeler.test(yvar6, xvar6), list(yvar6=yvar6, xvar6=xvar6)))
  1911. aovcirc_6 <- eval.parent(substitute(aov.circular(yvar6, xvar6), list(yvar6=yvar6, xvar6=xvar6)))
  1912. #kuiper test - is anything different about these distributions? (Not sure about this)
  1913. kuiper_8 <- eval.parent(substitute(kuiper_test(Tg8data$y, WT8data$y), list(y = y, Tg8data = Tg8data, WT8data = WT8data)))
  1914. #equal kappa test - are concentration parameters different?
  1915. equalkappa_8 <- eval.parent(substitute(equal.kappa.test(yvar8, xvar8), list(yvar8=yvar8, xvar8=xvar8)))
  1916. #watson williams - are means different?
  1917. watwill_8 <- eval.parent(substitute(watson.williams.test(yvar8, xvar8), list(yvar8=yvar8, xvar8=xvar8)))
  1918. #watson wheeler - are distribution of angles different? unclear if this is the same as watson williams? non-parametric?
  1919. watwheel_8 <-eval.parent(substitute(watson.wheeler.test(yvar8, xvar8), list(yvar8=yvar8, xvar8=xvar8)))
  1920. aovcirc_8 <- eval.parent(substitute(aov.circular(yvar8, xvar8), list(yvar8=yvar8, xvar8=xvar8)))
  1921. kuiper_pvals <- c(kuiper_6[[2]], kuiper_8[[2]]) %>% p.adjust(method = 'bonferroni')
  1922. equalkappa_pvals <- c(equalkappa_6[[7]], equalkappa_8[[7]]) %>% p.adjust(method = 'bonferroni')
  1923. watwill_pvals <- c(watwill_6[[4]], watwill_8[[4]]) %>% p.adjust(method = 'bonferroni')
  1924. watwheel_pvals <- c(watwheel_6[[4]], watwheel_8[[4]]) %>% p.adjust(method = 'bonferroni')
  1925. aovcirc_pvals <- c(aovcirc_6[[12]], aovcirc_8[[12]]) %>% p.adjust(method = 'bonferroni')
  1926. outlist <- list(kuiper_pvals, equalkappa_pvals, watwill_pvals,
  1927. watwheel_pvals,aovcirc_pvals)
  1928. return(outlist)
  1929. }
  1930. hipp_data <- read.csv('HIPP Single Unit Data.csv')
  1931. mec_data <-read.csv('MEC Single Unit Data.csv')
  1932. hipp_data$Animalname <-factor(hipp_data$Animalname)
  1933. mec_data$Animalname <-factor(mec_data$Animalname)
  1934. hipp_data$Groupname <- factor(hipp_data$Groupname , # Reordering group factor levels
  1935. levels = c("6wt", "8wt", "63x", "83x"))
  1936. mec_data$Groupname <- factor(mec_data$Groupname , # Reordering group factor levels
  1937. levels = c("6wt", "8wt", "63x", "83x"))
  1938. hipp_data <- mutate(hipp_data, Genotype = ifelse(Groupname =='6wt'|Groupname =='8wt', "WT", "3xTg"))
  1939. hipp_data<-mutate(hipp_data, Age_Broad = ifelse(Groupname =='6wt'|Groupname =='63x', 6, 8))
  1940. mec_data <- mutate(mec_data, Genotype = ifelse(Groupname =='6wt'|Groupname =='8wt', "WT", "3xTg"))
  1941. mec_data<-mutate(mec_data, Age_Broad = ifelse(Groupname =='6wt'|Groupname =='63x', 6, 8))
  1942. hipp_data$Genotype <- factor(hipp_data$Genotype, # Reordering group factor levels
  1943. levels = c("WT", "3xTg"))
  1944. mec_data$Genotype <- factor(mec_data$Genotype , # Reordering group factor levels
  1945. levels = c("WT", "3xTg"))
  1946. hipp_data$Age_Broad <- factor(hipp_data$Age_Broad, # Reordering group factor levels
  1947. levels = c("6", "8"))
  1948. mec_data$Age_Broad <- factor(mec_data$Age_Broad , # Reordering group factor levels
  1949. levels = c("6", "8"))
  1950. hipp_data <- mutate(hipp_data, mu2MECtheta_run_thresh = as.circular(mu2MECtheta_run_thresh + pi, units = 'radians'))
  1951. hipp_data <- mutate(hipp_data, mu2CA1theta_run_thresh = as.circular(mu2CA1theta_run_thresh + pi, units = 'radians'))
  1952. mec_data <- mutate(mec_data, mu2MECtheta_run_thresh = as.circular(mu2MECtheta_run_thresh + pi, units = 'radians'))
  1953. mec_data <- mutate(mec_data, mu2CA1theta_run_thresh = as.circular(mu2CA1theta_run_thresh + pi, units = 'radians'))
  1954. mec_data <- mutate(mec_data, mu2LMtheta_run_thresh = as.circular(mu2LMtheta_run_thresh + pi, units = 'radians'))
  1955. ##
  1956. iDG = subset(hipp_data, Region == 'DG' & CellType == 'i')
  1957. eDG= subset(hipp_data, Region == 'DG' & CellType == 'e')
  1958. iCA1 = subset(hipp_data, Region == 'CA1' & CellType == 'i')
  1959. eCA1 = subset(hipp_data, Region == 'CA1' & CellType == 'e')
  1960. iMEC2 = subset(mec_data, Region == 'MEC2' & CellType == 'i')
  1961. eMEC2 = subset(mec_data, Region == 'MEC2' & CellType == 'e')
  1962. iMEC3 = subset(mec_data, Region == 'MEC3' & CellType == 'i')
  1963. eMEC3 = subset(mec_data, Region == 'MEC3' & CellType == 'e')
  1964. eMEC3 <- subset(eMEC3, mFR_all_run < 25) #remove cells with overly high firing rates that were incorrectly clustered as excitatory based on waveform shape
  1965. hipp_8mo = subset(hipp_data, Groupname =='83x' | Groupname == '8wt')
  1966. hipp_6mo = subset(hipp_data, Groupname =='63x' | Groupname == '6wt')
  1967. mec_8mo = subset(mec_data, Groupname =='83x' | Groupname == '8wt')
  1968. mec_6mo = subset(mec_data, Groupname =='63x' | Groupname == '6wt')
  1969. hipp_tg = subset(hipp_data, Groupname == '83x' | Groupname == '63x')
  1970. hipp_wt = subset(hipp_data, Groupname == '8wt' | Groupname == '6wt')
  1971. mec_tg = subset(mec_data, Groupname == '83x' | Groupname == '63x')
  1972. mec_wt = subset(mec_data, Groupname == '8wt' | Groupname == '6wt')
  1973. ##subset by genotype
  1974. iDG_Tg = subset(iDG, Genotype == '3xTg')
  1975. iDG_WT = subset(iDG, Genotype == 'WT')
  1976. eDG_Tg = subset(eDG, Genotype == '3xTg')
  1977. eDG_WT = subset(eDG, Genotype == 'WT')
  1978. iCA1_Tg = subset(iCA1, Genotype == '3xTg')
  1979. iCA1_WT = subset(iCA1, Genotype == 'WT')
  1980. eCA1_Tg = subset(eCA1, Genotype == '3xTg')
  1981. eCA1_WT = subset(eCA1, Genotype == 'WT')
  1982. iMEC2_Tg = subset(iMEC2, Genotype == '3xTg')
  1983. iMEC2_WT = subset(iMEC2, Genotype == 'WT')
  1984. eMEC2_Tg = subset(eMEC2, Genotype == '3xTg')
  1985. eMEC2_WT = subset(eMEC2, Genotype == 'WT')
  1986. iMEC3_Tg = subset(iMEC3, Genotype == '3xTg')
  1987. iMEC3_WT = subset(iMEC2, Genotype == 'WT')
  1988. eMEC3_Tg = subset(eMEC3, Genotype == '3xTg')
  1989. eMEC3_WT = subset(eMEC3, Genotype == 'WT')
  1990. ##subset by age
  1991. iDG_8mo = subset(iDG, Age_Broad == '8')
  1992. iDG_6mo = subset(iDG, Age_Broad == '6')
  1993. eDG_8mo = subset(eDG, Age_Broad == '8')
  1994. eDG_6mo = subset(eDG, Age_Broad == '6')
  1995. iCA1_8mo = subset(iCA1, Age_Broad == '8')
  1996. iCA1_6mo = subset(iCA1, Age_Broad == '6')
  1997. eCA1_8mo = subset(eCA1, Age_Broad == '8')
  1998. eCA1_6mo = subset(eCA1, Age_Broad == '6')
  1999. iMEC2_8mo = subset(iMEC2, Age_Broad == '8')
  2000. iMEC2_6mo = subset(iMEC2, Age_Broad == '6')
  2001. eMEC2_8mo = subset(eMEC2, Age_Broad == '8')
  2002. eMEC2_6mo = subset(eMEC2, Age_Broad == '6')
  2003. iMEC3_8mo = subset(iMEC3, Age_Broad == '8')
  2004. iMEC3_6mo = subset(iMEC3, Age_Broad == '6')
  2005. eMEC3_8mo = subset(eMEC3, Age_Broad == '8')
  2006. eMEC3_6mo = subset(eMEC3, Age_Broad == '6')
  2007. #subset by genotype and age
  2008. iDG_8mo_Tg = subset(iDG, Age_Broad == '8' & Genotype == '3xTg')
  2009. iDG_6mo_Tg = subset(iDG, Age_Broad == '6' & Genotype == '3xTg')
  2010. eDG_8mo_Tg = subset(eDG, Age_Broad == '8' & Genotype == '3xTg')
  2011. eDG_6mo_Tg = subset(eDG, Age_Broad == '6' & Genotype == '3xTg')
  2012. iCA1_8mo_Tg = subset(iCA1, Age_Broad == '8' & Genotype == '3xTg')
  2013. iCA1_6mo_Tg = subset(iCA1, Age_Broad == '6' & Genotype == '3xTg')
  2014. eCA1_8mo_Tg = subset(eCA1, Age_Broad == '8' & Genotype == '3xTg')
  2015. eCA1_6mo_Tg = subset(eCA1, Age_Broad == '6' & Genotype == '3xTg')
  2016. iMEC2_8mo_Tg = subset(iMEC2, Age_Broad == '8' & Genotype == '3xTg')
  2017. iMEC2_6mo_Tg = subset(iMEC2, Age_Broad == '6' & Genotype == '3xTg')
  2018. eMEC2_8mo_Tg = subset(eMEC2, Age_Broad == '8' & Genotype == '3xTg')
  2019. eMEC2_6mo_Tg = subset(eMEC2, Age_Broad == '6' & Genotype == '3xTg')
  2020. iMEC3_8mo_Tg = subset(iMEC3, Age_Broad == '8' & Genotype == '3xTg')
  2021. iMEC3_6mo_Tg = subset(iMEC3, Age_Broad == '6' & Genotype == '3xTg')
  2022. eMEC3_8mo_Tg = subset(eMEC3, Age_Broad == '8' & Genotype == '3xTg')
  2023. eMEC3_6mo_Tg = subset(eMEC3, Age_Broad == '6' & Genotype == '3xTg')
  2024. iDG_8mo_WT = subset(iDG, Age_Broad == '8' & Genotype == 'WT')
  2025. iDG_6mo_WT = subset(iDG, Age_Broad == '6' & Genotype == 'WT')
  2026. eDG_8mo_WT = subset(eDG, Age_Broad == '8' & Genotype == 'WT')
  2027. eDG_6mo_WT = subset(eDG, Age_Broad == '6' & Genotype == 'WT')
  2028. iCA1_8mo_WT = subset(iCA1, Age_Broad == '8' & Genotype == 'WT')
  2029. iCA1_6mo_WT = subset(iCA1, Age_Broad == '6' & Genotype == 'WT')
  2030. eCA1_8mo_WT = subset(eCA1, Age_Broad == '8' & Genotype == 'WT')
  2031. eCA1_6mo_WT = subset(eCA1, Age_Broad == '6' & Genotype == 'WT')
  2032. iMEC2_8mo_WT = subset(iMEC2, Age_Broad == '8' & Genotype == 'WT')
  2033. iMEC2_6mo_WT = subset(iMEC2, Age_Broad == '6' & Genotype == 'WT')
  2034. eMEC2_8mo_WT = subset(eMEC2, Age_Broad == '8' & Genotype == 'WT')
  2035. eMEC2_6mo_WT = subset(eMEC2, Age_Broad == '6' & Genotype == 'WT')
  2036. iMEC3_8mo_WT = subset(iMEC3, Age_Broad == '8' & Genotype == 'WT')
  2037. iMEC3_6mo_WT = subset(iMEC3, Age_Broad == '6' & Genotype == 'WT')
  2038. eMEC3_8mo_WT = subset(eMEC3, Age_Broad == '8' & Genotype == 'WT')
  2039. eMEC3_6mo_WT = subset(eMEC3, Age_Broad == '6' & Genotype == 'WT')
  2040. lvls <- levels(mec_data$Groupname)
  2041. lvlsA <- levels(mec_data$Age_Broad)
  2042. lvlsG <- levels(mec_data$Genotype)
  2043. AnyPlotbygroup_adjaxis_facet <- function(df, y, title, ytitle, ymin, ymax) { # ymin =0, ymax=50){
  2044. plot <-ggplot(df ,aes(x=Genotype, y={{y}}))
  2045. plot +geom_sina(aes(col= Groupname), alpha = 0.5, na.rm = TRUE, show.legend=FALSE, jitter_y = FALSE) +
  2046. geom_bar(position= "dodge", stat = "summary", width = 0.9, fun.y = "mean", alpha = 0.4, aes(fill=Groupname), colour = "black") +
  2047. stat_summary(color = 'black', fun.data = mean_se, geom = "errorbar", width = 0.4, alpha = 1, show.legend=FALSE) +
  2048. ggtitle(title) + ylab(ytitle) +
  2049. scale_fill_manual("legend", values = scale_fill_palette, labels = c("WT 6 mo", "WT 8 mo", "3xTg 6 mo", "3xTg 8 mo"))+
  2050. guides(fill=guide_legend("Group")) +
  2051. scale_color_manual("legend", values = scale_colour_palette, guide = "none")+
  2052. scale_y_continuous(expand = c(0,0)) +
  2053. coord_cartesian(ylim=c(ymin, ymax))+
  2054. scale_alpha(guide = 'none') +
  2055. facet_grid(.~Age_Broad, switch = "x", labeller = as_labeller(c('6' = "6 mo", '8' = "8 mo"))) +
  2056. theme(plot.title = element_text(hjust = 0.5, size = 22, face = "bold"),
  2057. axis.text.x = element_text(size = 15, colour = "black"),
  2058. axis.text.y = element_text(size = 18, face="bold", colour = "black"),
  2059. axis.title.y = element_text(size = 20, face = "bold", colour = "black"),
  2060. axis.title.x = element_blank(),
  2061. legend.text=element_text(size=16),
  2062. legend.title=element_text(size=18),
  2063. panel.grid.major = element_blank(),
  2064. panel.grid.minor = element_blank(),
  2065. panel.background = element_blank(),
  2066. axis.line = element_line(colour = "black"),
  2067. strip.text.x = element_text(size = 18, face = "bold"),
  2068. strip.background = element_rect( fill="white"),
  2069. panel.spacing.x = unit(1.4, "lines"),
  2070. strip.placement = "outside")
  2071. }
  2072. print("eMEC2 Ns")
  2073. print("3xTg 6mo (M, F)")
  2074. sum(eMEC2$Genotype == "3xTg" & eMEC2$Age_Broad == '6')
  2075. sum(eMEC2$Genotype == "3xTg" & eMEC2$Age_Broad == '6' & eMEC2$Sex == 'M')
  2076. sum(eMEC2$Genotype == "3xTg" & eMEC2$Age_Broad == '6' & eMEC2$Sex == 'F')
  2077. print("3xTg 8mo (M, F)")
  2078. sum(eMEC2$Genotype == "3xTg" & eMEC2$Age_Broad == '8')
  2079. sum(eMEC2$Genotype == "3xTg" & eMEC2$Age_Broad == '8' & eMEC2$Sex == 'M')
  2080. sum(eMEC2$Genotype == "3xTg" & eMEC2$Age_Broad == '8' & eMEC2$Sex == 'F')
  2081. print("WT 6mo (M, F)")
  2082. sum(eMEC2$Genotype == "WT" & eMEC2$Age_Broad == '6')
  2083. sum(eMEC2$Genotype == "WT" & eMEC2$Age_Broad == '6' & eMEC2$Sex == 'M')
  2084. sum(eMEC2$Genotype == "WT" & eMEC2$Age_Broad == '6' & eMEC2$Sex == 'F')
  2085. print("WT 8mo (M, F)")
  2086. sum(eMEC2$Genotype == "WT" & eMEC2$Age_Broad == '8')
  2087. sum(eMEC2$Genotype == "WT" & eMEC2$Age_Broad == '8' & eMEC2$Sex == 'M')
  2088. sum(eMEC2$Genotype == "WT" & eMEC2$Age_Broad == '8' & eMEC2$Sex == 'F')
  2089. print("eMEC3 Ns")
  2090. print("3xTg 6mo (M, F)")
  2091. sum(eMEC3$Genotype == "3xTg" & eMEC3$Age_Broad == '6')
  2092. sum(eMEC3$Genotype == "3xTg" & eMEC3$Age_Broad == '6' & eMEC3$Sex == 'M')
  2093. sum(eMEC3$Genotype == "3xTg" & eMEC3$Age_Broad == '6' & eMEC3$Sex == 'F')
  2094. print("3xTg 8mo (M, F)")
  2095. sum(eMEC3$Genotype == "3xTg" & eMEC3$Age_Broad == '8')
  2096. sum(eMEC3$Genotype == "3xTg" & eMEC3$Age_Broad == '8' & eMEC3$Sex == 'M')
  2097. sum(eMEC3$Genotype == "3xTg" & eMEC3$Age_Broad == '8' & eMEC3$Sex == 'F')
  2098. print("WT 6mo (M, F)")
  2099. sum(eMEC3$Genotype == "WT" & eMEC3$Age_Broad == '6')
  2100. sum(eMEC3$Genotype == "WT" & eMEC3$Age_Broad == '6' & eMEC3$Sex == 'M')
  2101. sum(eMEC3$Genotype == "WT" & eMEC3$Age_Broad == '6' & eMEC3$Sex == 'F')
  2102. print("WT 8mo (M, F)")
  2103. sum(eMEC3$Genotype == "WT" & eMEC3$Age_Broad == '8')
  2104. sum(eMEC3$Genotype == "WT" & eMEC3$Age_Broad == '8' & eMEC3$Sex == 'M')
  2105. sum(eMEC3$Genotype == "WT" & eMEC3$Age_Broad == '8' & eMEC3$Sex == 'F')
  2106. print("iMEC2 Ns")
  2107. print("3xTg 6mo (M, F)")
  2108. sum(iMEC2$Genotype == "3xTg" & iMEC2$Age_Broad == '6')
  2109. sum(iMEC2$Genotype == "3xTg" & iMEC2$Age_Broad == '6' & iMEC2$Sex == 'M')
  2110. sum(iMEC2$Genotype == "3xTg" & iMEC2$Age_Broad == '6' & iMEC2$Sex == 'F')
  2111. print("3xTg 8mo (M, F)")
  2112. sum(iMEC2$Genotype == "3xTg" & iMEC2$Age_Broad == '8')
  2113. sum(iMEC2$Genotype == "3xTg" & iMEC2$Age_Broad == '8' & iMEC2$Sex == 'M')
  2114. sum(iMEC2$Genotype == "3xTg" & iMEC2$Age_Broad == '8' & iMEC2$Sex == 'F')
  2115. print("WT 6mo (M, F)")
  2116. sum(iMEC2$Genotype == "WT" & iMEC2$Age_Broad == '6')
  2117. sum(iMEC2$Genotype == "WT" & iMEC2$Age_Broad == '6' & iMEC2$Sex == 'M')
  2118. sum(iMEC2$Genotype == "WT" & iMEC2$Age_Broad == '6' & iMEC2$Sex == 'F')
  2119. print("WT 8mo (M, F)")
  2120. sum(iMEC2$Genotype == "WT" & iMEC2$Age_Broad == '8')
  2121. sum(iMEC2$Genotype == "WT" & iMEC2$Age_Broad == '8' & iMEC2$Sex == 'M')
  2122. sum(iMEC2$Genotype == "WT" & iMEC2$Age_Broad == '8' & iMEC2$Sex == 'F')
  2123. print("iMEC3 Ns")
  2124. print("3xTg 6mo (M, F)")
  2125. sum(iMEC3$Genotype == "3xTg" & iMEC3$Age_Broad == '6')
  2126. sum(iMEC3$Genotype == "3xTg" & iMEC3$Age_Broad == '6' & iMEC3$Sex == 'M')
  2127. sum(iMEC3$Genotype == "3xTg" & iMEC3$Age_Broad == '6' & iMEC3$Sex == 'F')
  2128. print("3xTg 8mo (M, F)")
  2129. sum(iMEC3$Genotype == "3xTg" & iMEC3$Age_Broad == '8')
  2130. sum(iMEC3$Genotype == "3xTg" & iMEC3$Age_Broad == '8' & iMEC3$Sex == 'M')
  2131. sum(iMEC3$Genotype == "3xTg" & iMEC3$Age_Broad == '8' & iMEC3$Sex == 'F')
  2132. print("WT 6mo (M, F)")
  2133. sum(iMEC3$Genotype == "WT" & iMEC3$Age_Broad == '6')
  2134. sum(iMEC3$Genotype == "WT" & iMEC3$Age_Broad == '6' & iMEC3$Sex == 'M')
  2135. sum(iMEC3$Genotype == "WT" & iMEC3$Age_Broad == '6' & iMEC3$Sex == 'F')
  2136. print("WT 8mo (M, F)")
  2137. sum(iMEC3$Genotype == "WT" & iMEC3$Age_Broad == '8')
  2138. sum(iMEC3$Genotype == "WT" & iMEC3$Age_Broad == '8' & iMEC3$Sex == 'M')
  2139. sum(iMEC3$Genotype == "WT" & iMEC3$Age_Broad == '8' & iMEC3$Sex == 'F')
  2140. print("eDG Ns")
  2141. print("3xTg 6mo (M, F)")
  2142. sum(eDG$Genotype == "3xTg" & eDG$Age_Broad == '6')
  2143. sum(eDG$Genotype == "3xTg" & eDG$Age_Broad == '6' & eDG$Sex == 'M')
  2144. sum(eDG$Genotype == "3xTg" & eDG$Age_Broad == '6' & eDG$Sex == 'F')
  2145. print("3xTg 8mo (M, F)")
  2146. sum(eDG$Genotype == "3xTg" & eDG$Age_Broad == '8')
  2147. sum(eDG$Genotype == "3xTg" & eDG$Age_Broad == '8' & eDG$Sex == 'M')
  2148. sum(eDG$Genotype == "3xTg" & eDG$Age_Broad == '8' & eDG$Sex == 'F')
  2149. print("WT 6mo (M, F)")
  2150. sum(eDG$Genotype == "WT" & eDG$Age_Broad == '6')
  2151. sum(eDG$Genotype == "WT" & eDG$Age_Broad == '6' & eDG$Sex == 'M')
  2152. sum(eDG$Genotype == "WT" & eDG$Age_Broad == '6' & eDG$Sex == 'F')
  2153. print("WT 8mo (M, F)")
  2154. sum(eDG$Genotype == "WT" & eDG$Age_Broad == '8')
  2155. sum(eDG$Genotype == "WT" & eDG$Age_Broad == '8' & eDG$Sex == 'M')
  2156. sum(eDG$Genotype == "WT" & eDG$Age_Broad == '8' & eDG$Sex == 'F')
  2157. print("eCA1 Ns")
  2158. print("3xTg 6mo (M, F)")
  2159. sum(eCA1$Genotype == "3xTg" & eCA1$Age_Broad == '6')
  2160. sum(eCA1$Genotype == "3xTg" & eCA1$Age_Broad == '6' & eCA1$Sex == 'M')
  2161. sum(eCA1$Genotype == "3xTg" & eCA1$Age_Broad == '6' & eCA1$Sex == 'F')
  2162. print("3xTg 8mo (M, F)")
  2163. sum(eCA1$Genotype == "3xTg" & eCA1$Age_Broad == '8')
  2164. sum(eCA1$Genotype == "3xTg" & eCA1$Age_Broad == '8' & eCA1$Sex == 'M')
  2165. sum(eCA1$Genotype == "3xTg" & eCA1$Age_Broad == '8' & eCA1$Sex == 'F')
  2166. print("WT 6mo (M, F)")
  2167. sum(eCA1$Genotype == "WT" & eCA1$Age_Broad == '6')
  2168. sum(eCA1$Genotype == "WT" & eCA1$Age_Broad == '6' & eCA1$Sex == 'M')
  2169. sum(eCA1$Genotype == "WT" & eCA1$Age_Broad == '6' & eCA1$Sex == 'F')
  2170. print("WT 8mo (M, F)")
  2171. sum(eCA1$Genotype == "WT" & eCA1$Age_Broad == '8')
  2172. sum(eCA1$Genotype == "WT" & eCA1$Age_Broad == '8' & eCA1$Sex == 'M')
  2173. sum(eCA1$Genotype == "WT" & eCA1$Age_Broad == '8' & eCA1$Sex == 'F')
  2174. print("iDG Ns")
  2175. print("3xTg 6mo (M, F)")
  2176. sum(iDG$Genotype == "3xTg" & iDG$Age_Broad == '6')
  2177. sum(iDG$Genotype == "3xTg" & iDG$Age_Broad == '6' & iDG$Sex == 'M')
  2178. sum(iDG$Genotype == "3xTg" & iDG$Age_Broad == '6' & iDG$Sex == 'F')
  2179. print("3xTg 8mo (M, F)")
  2180. sum(iDG$Genotype == "3xTg" & iDG$Age_Broad == '8')
  2181. sum(iDG$Genotype == "3xTg" & iDG$Age_Broad == '8' & iDG$Sex == 'M')
  2182. sum(iDG$Genotype == "3xTg" & iDG$Age_Broad == '8' & iDG$Sex == 'F')
  2183. print("WT 6mo (M, F)")
  2184. sum(iDG$Genotype == "WT" & iDG$Age_Broad == '6')
  2185. sum(iDG$Genotype == "WT" & iDG$Age_Broad == '6' & iDG$Sex == 'M')
  2186. sum(iDG$Genotype == "WT" & iDG$Age_Broad == '6' & iDG$Sex == 'F')
  2187. print("WT 8mo (M, F)")
  2188. sum(iDG$Genotype == "WT" & iDG$Age_Broad == '8')
  2189. sum(iDG$Genotype == "WT" & iDG$Age_Broad == '8' & iDG$Sex == 'M')
  2190. sum(iDG$Genotype == "WT" & iDG$Age_Broad == '8' & iDG$Sex == 'F')
  2191. print("iCA1 Ns")
  2192. print("3xTg 6mo (M, F)")
  2193. sum(iCA1$Genotype == "3xTg" & iCA1$Age_Broad == '6')
  2194. sum(iCA1$Genotype == "3xTg" & iCA1$Age_Broad == '6' & iCA1$Sex == 'M')
  2195. sum(iCA1$Genotype == "3xTg" & iCA1$Age_Broad == '6' & iCA1$Sex == 'F')
  2196. print("3xTg 8mo (M, F)")
  2197. sum(iCA1$Genotype == "3xTg" & iCA1$Age_Broad == '8')
  2198. sum(iCA1$Genotype == "3xTg" & iCA1$Age_Broad == '8' & iCA1$Sex == 'M')
  2199. sum(iCA1$Genotype == "3xTg" & iCA1$Age_Broad == '8' & iCA1$Sex == 'F')
  2200. print("WT 6mo (M, F)")
  2201. sum(iCA1$Genotype == "WT" & iCA1$Age_Broad == '6')
  2202. sum(iCA1$Genotype == "WT" & iCA1$Age_Broad == '6' & iCA1$Sex == 'M')
  2203. sum(iCA1$Genotype == "WT" & iCA1$Age_Broad == '6' & iCA1$Sex == 'F')
  2204. print("WT 8mo (M, F)")
  2205. sum(iCA1$Genotype == "WT" & iCA1$Age_Broad == '8')
  2206. sum(iCA1$Genotype == "WT" & iCA1$Age_Broad == '8' & iCA1$Sex == 'M')
  2207. sum(iCA1$Genotype == "WT" & iCA1$Age_Broad == '8' & iCA1$Sex == 'F')
  2208. print("eMEC2 cells by animal")
  2209. kable(table(unlist(eMEC2$Animalname)))
  2210. print("iMEC2 cells by animal")
  2211. kable(table(unlist(iMEC2$Animalname)))
  2212. print("eMEC3 cells by animal")
  2213. kable(table(unlist(eMEC3$Animalname)))
  2214. print("iMEC3 cells by animal")
  2215. kable(table(unlist(iMEC3$Animalname)))
  2216. print("eCA1 cells by animal")
  2217. kable(table(unlist(eCA1$Animalname)))
  2218. print("iCA1 cells by animal")
  2219. kable(table(unlist(iCA1$Animalname)))
  2220. print("eDG cells by animal")
  2221. kable(table(unlist(eDG$Animalname)))
  2222. print("iDG cells by animal")
  2223. kable(table(unlist(iDG$Animalname)))
  2224. ##### MEC R values and Firing Rates Figure 4 + 5 and S8
  2225. fr_mec_p1 <- AnyPlotbygroup_adjaxis_facet(eMEC3, mFR_run_thresh, 'Excitatory MEC3 \n Firing Rates',"Firing Rate (Hz)", 0, 12)
  2226. fr_mec_p1
  2227. print('eMEC3 FR')
  2228. print('Check Normality')
  2229. shapiro.test(eMEC3_6mo_WT$mFR_run_thresh)
  2230. shapiro.test(eMEC3_6mo_Tg$mFR_run_thresh)
  2231. shapiro.test(eMEC3_8mo_WT$mFR_run_thresh)
  2232. shapiro.test(eMEC3_8mo_Tg$mFR_run_thresh)
  2233. print('nonparametric')
  2234. Singleunit_nonparametric(eMEC3, mFR_run_thresh)
  2235. fr_mec_p2 <- AnyPlotbygroup_adjaxis_facet(iMEC3, mFR_run_thresh, 'Inhibitory MEC3 \nFiring Rates', "Firing Rate (Hz)", 0, 125)
  2236. fr_mec_p2
  2237. print("iMEC3 FR")
  2238. ('check normality')
  2239. shapiro.test(iMEC3_6mo_WT$mFR_run_thresh)
  2240. shapiro.test(iMEC3_6mo_Tg$mFR_run_thresh)
  2241. shapiro.test(iMEC3_8mo_WT$mFR_run_thresh)
  2242. shapiro.test(iMEC3_8mo_Tg$mFR_run_thresh)
  2243. print('nonparametric')
  2244. Singleunit_nonparametric(iMEC3, mFR_run_thresh)
  2245. r_mec_p1 <- AnyPlotbygroup_adjaxis_facet(eMEC3, r2MECtheta_run_thresh, 'Excitatory MEC3 R-vals \n(ref:MEC Theta)' ,'R', 0, 1)
  2246. r_mec_p1
  2247. print('eMEC3 R to MEC theta')
  2248. print('nonparametric')
  2249. Singleunit_nonparametric(eMEC3, r2MECtheta_run_thresh)
  2250. r_mec_p2 <- AnyPlotbygroup_adjaxis_facet(eMEC3, r2CA1theta_run_thresh, 'Excitatory MEC3 R-vals \n(ref:CA1 Pyr Theta)' ,'R', 0, 1)
  2251. r_mec_p2
  2252. print('eMEC3 R to CA1 theta')
  2253. print('nonparametric')
  2254. Singleunit_nonparametric(eMEC3, r2CA1theta_run_thresh)
  2255. r_mec_p3 <- AnyPlotbygroup_adjaxis_facet(iMEC3, r2MECtheta_run_thresh, 'Inhibitory MEC3 R-values \n(ref:MEC Theta)' ,'R', 0, 1)
  2256. r_mec_p3
  2257. print("iMEC3 R to MEC theta")
  2258. print('nonparametric')
  2259. Singleunit_nonparametric(iMEC3, r2MECtheta_run_thresh)
  2260. r_mec_p4 <- AnyPlotbygroup_adjaxis_facet(iMEC3, r2CA1theta_run_thresh, 'Inhibitory MEC3 R-values \n(ref:CA1 Pyr Theta)' ,'R', 0, 1)
  2261. r_mec_p4
  2262. print("iMEC3 R to CA1 theta")
  2263. print('nonparametric')
  2264. Singleunit_nonparametric(iMEC3, r2CA1theta_run_thresh)
  2265. fr_mec_p3 <- AnyPlotbygroup_adjaxis_facet(eMEC2, mFR_run_thresh, 'Excitatory MEC2 \n Firing Rates', "Firing Rate (Hz)", 0, 12)
  2266. fr_mec_p3
  2267. print('eMEC2 FR')
  2268. print('Check Normality')
  2269. shapiro.test(eMEC2_6mo_WT$mFR_run_thresh)
  2270. shapiro.test(eMEC2_6mo_Tg$mFR_run_thresh)
  2271. shapiro.test(eMEC2_8mo_WT$mFR_run_thresh)
  2272. shapiro.test(eMEC2_8mo_Tg$mFR_run_thresh)
  2273. print('nonparametric')
  2274. Singleunit_nonparametric(eMEC2, mFR_run_thresh)
  2275. fr_mec_p4 <- AnyPlotbygroup_adjaxis_facet(iMEC2, mFR_run_thresh, 'Inhibitory MEC2 \nFiring Rates', "Firing Rate (Hz)", 0, 125)
  2276. fr_mec_p4
  2277. print("iMEC2 FR")
  2278. print('Check normality')
  2279. shapiro.test(iMEC2_6mo_WT$mFR_run_thresh)
  2280. shapiro.test(iMEC2_6mo_Tg$mFR_run_thresh)
  2281. shapiro.test(iMEC2_8mo_WT$mFR_run_thresh)
  2282. shapiro.test(iMEC2_8mo_Tg$mFR_run_thresh)
  2283. print('nonparametric')
  2284. Singleunit_nonparametric(iMEC2, mFR_run_thresh)
  2285. r_mec_p5 <- AnyPlotbygroup_adjaxis_facet(eMEC2, r2MECtheta_run_thresh, 'Excitatory MEC2 R-vals \n(ref: MEC Theta)' , 'R', 0, 1)
  2286. r_mec_p5
  2287. print('eMEC2 R to MEC theta')
  2288. print('nonparametric')
  2289. Singleunit_nonparametric(eMEC2, r2MECtheta_run_thresh)
  2290. r_mec_p6 <- AnyPlotbygroup_adjaxis_facet(eMEC2, r2CA1theta_run_thresh, 'Excitatory MEC2 R-vals \n(ref: CA1 Pyr Theta)' ,'R', 0, 1)
  2291. r_mec_p6
  2292. print('eMEC2 R to CA1 theta')
  2293. print('Check normality')
  2294. shapiro.test(eMEC2_6mo_WT$r2CA1theta_run_thresh)
  2295. shapiro.test(eMEC2_6mo_Tg$r2CA1theta_run_thresh)
  2296. shapiro.test(eMEC2_8mo_WT$r2CA1theta_run_thresh)
  2297. shapiro.test(eMEC2_8mo_Tg$r2CA1theta_run_thresh)
  2298. print('nonparametric')
  2299. Singleunit_nonparametric(eMEC2, r2CA1theta_run_thresh)
  2300. r_mec_p7 <- AnyPlotbygroup_adjaxis_facet(iMEC2, r2MECtheta_run_thresh, 'Inhibitory MEC2 R-values \n(ref: MEC Theta)' ,'R', 0, 1)
  2301. r_mec_p7
  2302. print("iMEC2 R to MEC theta")
  2303. ('check normality')
  2304. shapiro.test(iMEC2_6mo_WT$r2MECtheta_run_thresh)
  2305. shapiro.test(iMEC2_6mo_Tg$r2MECtheta_run_thresh)
  2306. shapiro.test(iMEC2_8mo_WT$r2MECtheta_run_thresh)
  2307. shapiro.test(iMEC2_8mo_Tg$r2MECtheta_run_thresh)
  2308. print('nonparametric')
  2309. Singleunit_nonparametric(iMEC2, r2MECtheta_run_thresh)
  2310. r_mec_p8 <- AnyPlotbygroup_adjaxis_facet(iMEC2, r2CA1theta_run_thresh, 'Inhibitory MEC2 R-values \n(ref: CA1 Pyr Theta)' ,'R', 0, 1)
  2311. r_mec_p8
  2312. print("iMEC2 R to CA1 theta")
  2313. ('check normality')
  2314. shapiro.test(iMEC2_6mo_WT$r2CA1theta_run_thresh)
  2315. shapiro.test(iMEC2_6mo_Tg$r2CA1theta_run_thresh)
  2316. shapiro.test(iMEC2_8mo_WT$r2CA1theta_run_thresh)
  2317. shapiro.test(iMEC2_8mo_Tg$r2CA1theta_run_thresh)
  2318. print('nonparametric')
  2319. Singleunit_nonparametric(iMEC2, r2CA1theta_run_thresh)
  2320. #### Hippocampus R values and Firing Rates - Figure 6 and S10
  2321. fr_hipp_p1 <- AnyPlotbygroup_adjaxis_facet(eDG, mFR_run_thresh, 'Excitatory DG \n Firing Rates', "Firing Rate (Hz)", 0, 12)
  2322. fr_hipp_p1
  2323. print("eDG FR")
  2324. print('check normality')
  2325. shapiro.test(eDG_6mo_WT$mFR_run_thresh)
  2326. shapiro.test(eDG_6mo_Tg$mFR_run_thresh)
  2327. shapiro.test(eDG_8mo_WT$mFR_run_thresh)
  2328. shapiro.test(eDG_8mo_Tg$mFR_run_thresh)
  2329. print('nonparametric')
  2330. Singleunit_nonparametric(eDG, mFR_run_thresh)
  2331. fr_hipp_p2 <- AnyPlotbygroup_adjaxis_facet(iDG, mFR_run_thresh, 'Inhibitory DG \n Firing Rates', "Firing Rate (Hz)", 0, 100)
  2332. fr_hipp_p2
  2333. print("iDG FR")
  2334. ('check normality')
  2335. shapiro.test(iDG_6mo_WT$mFR_run_thresh)
  2336. shapiro.test(iDG_6mo_Tg$mFR_run_thresh)
  2337. shapiro.test(iDG_8mo_WT$mFR_run_thresh)
  2338. shapiro.test(iDG_8mo_Tg$mFR_run_thresh)
  2339. print('nonparametric')
  2340. Singleunit_nonparametric(iDG, mFR_run_thresh)
  2341. fr_hipp_p3 <- AnyPlotbygroup_adjaxis_facet(eCA1, mFR_run_thresh, 'Excitatory CA1 \n Firing Rates', "Firing Rate (Hz)", 0, 12)
  2342. fr_hipp_p3
  2343. print("eCA1 FR")
  2344. print('check normality')
  2345. shapiro.test(eCA1_6mo_WT$mFR_run_thresh)
  2346. shapiro.test(eCA1_6mo_Tg$mFR_run_thresh)
  2347. shapiro.test(eCA1_8mo_WT$mFR_run_thresh)
  2348. shapiro.test(eCA1_8mo_Tg$mFR_run_thresh)
  2349. print('nonparametric')
  2350. Singleunit_nonparametric(eCA1, mFR_run_thresh)
  2351. fr_hipp_p4 <- AnyPlotbygroup_adjaxis_facet(iCA1, mFR_run_thresh, 'Inhibitory CA1 \n Firing Rates', "Firing Rate (Hz)", 0, 100)
  2352. fr_hipp_p4
  2353. print("iCA1 FR")
  2354. ('check normality')
  2355. shapiro.test(iCA1_6mo_WT$mFR_run_thresh)
  2356. shapiro.test(iCA1_6mo_Tg$mFR_run_thresh)
  2357. shapiro.test(iCA1_8mo_WT$mFR_run_thresh)
  2358. shapiro.test(iCA1_8mo_Tg$mFR_run_thresh)
  2359. print('nonparametric')
  2360. Singleunit_nonparametric(iCA1, mFR_run_thresh)
  2361. r_hipp_p1 <- AnyPlotbygroup_adjaxis_facet(iCA1, r2CA1theta_run_thresh, 'Inhibitory CA1 R-values \n(ref:CA1 Pyr Theta)' ,'R', 0, 1)
  2362. r_hipp_p1
  2363. print("iCA1 R to CA1 theta")
  2364. print('nonparametric')
  2365. Singleunit_nonparametric(iCA1, r2CA1theta_run_thresh)
  2366. r_hipp_p2 <-AnyPlotbygroup_adjaxis_facet(iDG, r2CA1theta_run_thresh, 'Inhibitory DG R-values \n(ref:CA1 Pyr Theta)' ,'R', 0, 1)
  2367. r_hipp_p2
  2368. print("iDG R to CA1 theta")
  2369. print('check normality')
  2370. shapiro.test(iDG_6mo_WT$r2CA1theta_run_thresh)
  2371. shapiro.test(iDG_6mo_Tg$r2CA1theta_run_thresh)
  2372. shapiro.test(iDG_8mo_WT$r2CA1theta_run_thresh)
  2373. shapiro.test(iDG_8mo_Tg$r2CA1theta_run_thresh)
  2374. print('nonparametric')
  2375. Singleunit_nonparametric(iDG, r2CA1theta_run_thresh)
  2376. r_hipp_p3 <- AnyPlotbygroup_adjaxis_facet(eCA1, r2CA1theta_run_thresh, 'Excitatory CA1 R-values \n(ref:CA1 Pyr Theta)' ,'R', 0, 1)
  2377. r_hipp_p3
  2378. print("eCA1 R to CA1 theta")
  2379. print('check normality')
  2380. shapiro.test(eCA1_6mo_WT$r2CA1theta_run_thresh)
  2381. shapiro.test(eCA1_6mo_Tg$r2CA1theta_run_thresh)
  2382. shapiro.test(eCA1_8mo_WT$r2CA1theta_run_thresh)
  2383. shapiro.test(eCA1_8mo_Tg$r2CA1theta_run_thresh)
  2384. print('nonparametric')
  2385. Singleunit_nonparametric(eCA1, r2CA1theta_run_thresh)
  2386. r_hipp_p4 <- AnyPlotbygroup_adjaxis_facet(eDG, r2CA1theta_run_thresh, 'Excitatory DG R-values \n(ref:CA1 Pyr Theta)' ,'R', 0, 1)
  2387. r_hipp_p4
  2388. print("eDG R to CA1 theta")
  2389. print('check normality')
  2390. shapiro.test(eDG_6mo_WT$r2CA1theta_run_thresh)
  2391. shapiro.test(eDG_6mo_Tg$r2CA1theta_run_thresh)
  2392. shapiro.test(eDG_8mo_WT$r2CA1theta_run_thresh)
  2393. shapiro.test(eDG_8mo_Tg$r2CA1theta_run_thresh)
  2394. print('nonparametric')
  2395. Singleunit_nonparametric(eDG, r2CA1theta_run_thresh)
  2396. Mubygroup_2 <- function(df, y, title, showmean, means, var=circmean){
  2397. if (showmean ==1 ){
  2398. plot <-ggplot(df ,aes(x=Genotype, y={{y}}))
  2399. plot+ geom_sina(aes(col = Groupname, y = {{y}}), alpha = 0.3, size =2, na.rm=TRUE, jitter_y = FALSE, show.legend=FALSE) +
  2400. ggtitle(title) + ylab("Phase of Theta (Degrees)") +
  2401. facet_grid(rows = vars(Age_Broad), labeller = as_labeller(c('6' = "6 mo", '8' = "8 mo"))) +
  2402. theme(panel.grid.major = element_blank(),
  2403. panel.grid.minor = element_blank(),
  2404. panel.background = element_blank(),
  2405. axis.line = element_line(colour = "black"),
  2406. plot.title = element_text(size = 22, face ="bold", hjust = 0.5),
  2407. axis.text=element_text(size=20, face="bold", colour = 'black'),
  2408. axis.title.x=element_text(size=20, colour = 'black', face = "bold"),
  2409. axis.title.y=element_blank(),
  2410. legend.text=element_text(size=18),
  2411. legend.title=element_text(size=20),
  2412. strip.text = element_text(size = 18, face = "bold"),
  2413. strip.background = element_rect( fill="white"),
  2414. panel.spacing = unit(2.5, "lines"),
  2415. strip.placement = "outside") +
  2416. scale_fill_manual("legend", values = scale_fill_palette, labels = c("WT 6 mo", "WT 8 mo", "3xTg 6 mo", "3xTg 8 mo"))+
  2417. guides(fill=guide_legend("Group")) +
  2418. scale_color_manual("legend", values = scale_colour_palette, guide = "none")+
  2419. scale_y_continuous(limits=c(0,2*pi), breaks=c(0, pi, 2*pi), labels = c(0,180,360))+
  2420. coord_flip() +
  2421. labs(colour= "Genotype") +
  2422. geom_hline(yintercept=pi, alpha = 0.3, linetype = 'dashed')+
  2423. geom_tile(data = means, mapping = aes(x=Genotype, y={{var}}, col=Groupname), alpha = 1, width = 0.5, linetype = 1, linewidth = 1, height = 0, show.legend = FALSE)
  2424. }
  2425. else if (showmean == 0) {
  2426. plot <-ggplot(df ,aes(x=Genotype, y={{y}}))
  2427. plot+ geom_sina(aes(col = Groupname, y = {{y}}), alpha = 0.3, size =2, na.rm=TRUE, jitter_y = FALSE, show.legend=FALSE) +
  2428. ggtitle(title) + ylab("Phase of Theta (Degrees)") +
  2429. facet_grid(rows = vars(Age_Broad), labeller = as_labeller(c('6' = "6 mo", '8' = "8 mo"))) +
  2430. theme(panel.grid.major = element_blank(),
  2431. panel.grid.minor = element_blank(),
  2432. panel.background = element_blank(),
  2433. axis.line = element_line(colour = "black"),
  2434. plot.title = element_text(size = 22, face ="bold", hjust = 0.5),
  2435. axis.text=element_text(size=20, face="bold", colour = 'black'),
  2436. axis.title.x=element_text(size=20, colour = 'black', face = "bold"),
  2437. axis.title.y=element_blank(),
  2438. legend.text=element_text(size=18),
  2439. legend.title=element_text(size=20),
  2440. strip.text = element_text(size = 18, face = "bold"),
  2441. strip.background = element_rect( fill="white"),
  2442. panel.spacing = unit(2.5, "lines"),
  2443. strip.placement = "outside") +
  2444. scale_fill_manual("legend", values = scale_fill_palette, labels = c("6 mo WT", "8 mo WT", "6 mo 3xTg", "8 mo 3xTg"))+
  2445. guides(fill=guide_legend("Group")) +
  2446. scale_color_manual("legend", values = scale_colour_palette, guide = "none")+
  2447. scale_y_continuous(limits=c(0,2*pi), breaks=c(0, pi, 2*pi), labels = c(0,180,360))+
  2448. coord_flip() +
  2449. labs(colour= "Genotype") +
  2450. geom_hline(yintercept=pi, alpha = 0.3, linetype = 'dashed')
  2451. }
  2452. }
  2453. #flip levels to get WT to plot on top in facet_grid layout - no longer needed?
  2454. eMEC2$Genotype <- factor(eMEC2$Genotype, levels = c("3xTg", "WT"))
  2455. iMEC2$Genotype <- factor(iMEC2$Genotype, levels = c("3xTg", "WT"))
  2456. eMEC3$Genotype <- factor(eMEC3$Genotype, levels = c("3xTg", "WT"))
  2457. iMEC3$Genotype <- factor(iMEC3$Genotype, levels = c("3xTg", "WT"))
  2458. eDG$Genotype <- factor(eDG$Genotype, levels = c("3xTg", "WT"))
  2459. iDG$Genotype <- factor(iDG$Genotype, levels = c("3xTg", "WT"))
  2460. eCA1$Genotype <- factor(eCA1$Genotype, levels = c("3xTg", "WT"))
  2461. iCA1$Genotype <- factor(iCA1$Genotype, levels = c("3xTg", "WT"))
  2462. ##### MEC Mu Values Figure S8
  2463. circ_means_eMEC2vCA1 <- eMEC2 %>%
  2464. dplyr::group_by(Groupname, Genotype, Age_Broad) %>%
  2465. dplyr::summarise(circmean = mean.circular(mu2CA1theta_run_thresh, na.rm=TRUE))
  2466. circ_means_eMEC2vCA1 <-mutate(circ_means_eMEC2vCA1 , circmean = ifelse(circmean <'0', circmean + 2*pi, circmean))
  2467. mu_mec_p1 <- Mubygroup_2(eMEC2, mu2CA1theta_run_thresh, 'Excitatory MEC2 Mu \n(ref:CA1 theta)',1, circ_means_eMEC2vCA1)
  2468. mu_mec_p1
  2469. print('Circ Stats eMEC2 Mu vs CA1 theta (kuiper, equal-kappa, watson-williams, watson-wheeler, aov-circular)')
  2470. print('eMEC2 6mo')
  2471. Circstats_age(eMEC2_6mo, mu2CA1theta_run_thresh, eMEC2_6mo_WT, eMEC2_6mo_Tg)
  2472. print('eMEC2 8mo')
  2473. Circstats_age(eMEC2_8mo, mu2CA1theta_run_thresh, eMEC2_8mo_WT, eMEC2_8mo_Tg)
  2474. print('Corrected P-Vals')
  2475. Circstats_full(eMEC2_6mo, eMEC2_8mo, mu2CA1theta_run_thresh, eMEC2_6mo_WT, eMEC2_6mo_Tg, eMEC2_8mo_WT, eMEC2_8mo_Tg)
  2476. circ_means_eMEC3vCA1 <- eMEC3 %>%
  2477. dplyr::group_by(Groupname, Genotype, Age_Broad) %>%
  2478. dplyr::summarise(circmean = mean.circular(mu2CA1theta_run_thresh, na.rm=TRUE))
  2479. circ_means_eMEC3vCA1 <-mutate(circ_means_eMEC3vCA1 , circmean = ifelse(circmean <'0', circmean + 2*pi, circmean))
  2480. mu_mec_p2 <- Mubygroup_2(eMEC3, mu2CA1theta_run_thresh, 'Excitatory MEC3 Mu \n(ref:CA1 theta)',0, circ_means_eMEC3vCA1)
  2481. mu_mec_p2
  2482. print('Circ Stats eMEC3 Mu vs CA1 theta (kuiper, equal-kappa, watson-williams, watson-wheeler, aov-circular)')
  2483. print('eMEC3 6mo')
  2484. Circstats_age(eMEC3_6mo, mu2CA1theta_run_thresh, eMEC3_6mo_WT, eMEC3_6mo_Tg)
  2485. print('eMEC3 8mo')
  2486. Circstats_age(eMEC3_8mo, mu2CA1theta_run_thresh, eMEC3_8mo_WT, eMEC3_8mo_Tg)
  2487. print('Corrected P-Vals')
  2488. Circstats_full(eMEC3_6mo, eMEC3_8mo, mu2CA1theta_run_thresh, eMEC3_6mo_WT, eMEC3_6mo_Tg, eMEC3_8mo_WT, eMEC3_8mo_Tg)
  2489. circ_means_iMEC2vCA1 <- iMEC2 %>%
  2490. dplyr::group_by(Groupname, Genotype, Age_Broad) %>%
  2491. dplyr::summarise(circmean = mean.circular(mu2CA1theta_run_thresh, na.rm=TRUE))
  2492. circ_means_iMEC2vCA1 <-mutate(circ_means_iMEC2vCA1 , circmean = ifelse(circmean <'0', circmean + 2*pi, circmean))
  2493. mu_mec_p3 <- Mubygroup_2(iMEC2, mu2CA1theta_run_thresh, 'Inhibitory MEC2 Mu \n(ref:CA1 theta)',1, circ_means_iMEC2vCA1)
  2494. mu_mec_p3
  2495. print('Circ Stats iMEC2 Mu vs CA1 theta (kuiper, equal-kappa, watson-williams, watson-wheeler, aov-circular)')
  2496. print('iMEC2 6mo')
  2497. Circstats_age(iMEC2_6mo, mu2CA1theta_run_thresh, iMEC2_6mo_WT, iMEC2_6mo_Tg)
  2498. print('iMEC2 8mo')
  2499. Circstats_age(iMEC2_8mo, mu2CA1theta_run_thresh, iMEC2_8mo_WT, iMEC2_8mo_Tg)
  2500. print('Corrected P-Vals')
  2501. Circstats_full(iMEC2_6mo, iMEC2_8mo, mu2CA1theta_run_thresh, iMEC2_6mo_WT, iMEC2_6mo_Tg, iMEC2_8mo_WT, iMEC2_8mo_Tg)
  2502. circ_means_iMEC3vCA1 <- iMEC3 %>%
  2503. dplyr::group_by(Groupname, Genotype, Age_Broad) %>%
  2504. dplyr::summarise(circmean = mean.circular(mu2CA1theta_run_thresh, na.rm=TRUE))
  2505. circ_means_iMEC3vCA1 <-mutate(circ_means_iMEC3vCA1 , circmean = ifelse(circmean <'0', circmean + 2*pi, circmean))
  2506. mu_mec_p4 <- Mubygroup_2(iMEC3, mu2CA1theta_run_thresh, 'Inhibitory MEC3 Mu \n(ref:CA1 theta)', 1, circ_means_iMEC3vCA1)
  2507. mu_mec_p4
  2508. print('Circ Stats iMEC3 Mu vs CA1 theta (kuiper, equal-kappa, watson-williams, watson-wheeler, aov-circular)')
  2509. print('iMEC3 6mo')
  2510. Circstats_age(iMEC3_6mo, mu2CA1theta_run_thresh, iMEC3_6mo_WT, iMEC3_6mo_Tg)
  2511. print('iMEC3 8mo')
  2512. Circstats_age(iMEC3_8mo, mu2CA1theta_run_thresh, iMEC3_8mo_WT, iMEC3_8mo_Tg)
  2513. print('Corrected P-Vals')
  2514. Circstats_full(iMEC3_6mo, iMEC3_8mo, mu2CA1theta_run_thresh, iMEC3_6mo_WT, iMEC3_6mo_Tg, iMEC3_8mo_WT, iMEC3_8mo_Tg)
  2515. ##### Hippocampus Mu Values Figure 6
  2516. circ_means_eDGvCA1 <- eDG %>%
  2517. dplyr::group_by(Groupname, Genotype, Age_Broad) %>%
  2518. dplyr::summarise(circmean = mean.circular(mu2CA1theta_run_thresh, na.rm=TRUE))
  2519. circ_means_eDGvCA1 <-mutate(circ_means_eDGvCA1, circmean = ifelse(circmean <'0', circmean + 2*pi, circmean))
  2520. mu_hipp_p1 <- Mubygroup_2(eDG, mu2CA1theta_run_thresh, 'Excitatory DG Mu \n(ref:CA1 theta)', 1, circ_means_eDGvCA1)
  2521. mu_hipp_p1
  2522. print('Circ Stats eDG Mu vs CA1 theta (kuiper, equal-kappa, watson-williams, watson-wheeler, aov-circular)')
  2523. print('eDG 6mo')
  2524. Circstats_age(eDG_6mo, mu2CA1theta_run_thresh, eDG_6mo_WT, eDG_6mo_Tg)
  2525. print('eDG 8mo')
  2526. Circstats_age(eDG_8mo, mu2CA1theta_run_thresh, eDG_8mo_WT, eDG_8mo_Tg)
  2527. print('Corrected P-Vals')
  2528. Circstats_full(eDG_6mo, eDG_8mo, mu2CA1theta_run_thresh, eDG_6mo_WT, eDG_6mo_Tg, eDG_8mo_WT, eDG_8mo_Tg)
  2529. circ_means_eCA1vCA1 <- eCA1 %>%
  2530. dplyr::group_by(Groupname, Genotype, Age_Broad) %>%
  2531. dplyr::summarise(circmean = mean.circular(mu2CA1theta_run_thresh, na.rm=TRUE))
  2532. circ_means_eCA1vCA1 <-mutate(circ_means_eCA1vCA1, circmean = ifelse(circmean <'0', circmean + 2*pi, circmean))
  2533. mu_hipp_p2 <- Mubygroup_2(eCA1, mu2CA1theta_run_thresh, 'Excitatory CA1 Mu \n (ref:CA1 theta)', 1, circ_means_eCA1vCA1)
  2534. mu_hipp_p2
  2535. print('Circ Stats eCA1 Mu vs CA1 theta (kuiper, equal-kappa, watson-williams, watson-wheeler, aov-circular)')
  2536. print('eCA1 6mo')
  2537. Circstats_age(eCA1_6mo, mu2CA1theta_run_thresh, eCA1_6mo_WT, eCA1_6mo_Tg)
  2538. print('eCA1 8mo')
  2539. Circstats_age(eCA1_8mo, mu2CA1theta_run_thresh, eCA1_8mo_WT, eCA1_8mo_Tg)
  2540. print('Corrected P-Vals')
  2541. Circstats_full(eCA1_6mo, eCA1_8mo, mu2CA1theta_run_thresh, eCA1_6mo_WT, eCA1_6mo_Tg, eCA1_8mo_WT, eCA1_8mo_Tg)
  2542. circ_means_iDGvCA1 <- iDG %>%
  2543. dplyr::group_by(Groupname, Genotype, Age_Broad) %>%
  2544. dplyr::summarise(circmean = mean.circular(mu2CA1theta_run_thresh, na.rm=TRUE))
  2545. circ_means_iDGvCA1 <-mutate(circ_means_iDGvCA1, ifelse(circmean <'0', circmean + 2*pi, circmean))
  2546. mu_hipp_p3 <- Mubygroup_2(iDG, mu2CA1theta_run_thresh, 'Inhibitory DG Mu \n (ref:CA1 theta)',1, circ_means_iDGvCA1)
  2547. mu_hipp_p3
  2548. print('Circ Stats iDG Mu vs CA1 theta (kuiper, equal-kappa, watson-williams, watson-wheeler, aov-circular)')
  2549. print('iDG 6mo')
  2550. Circstats_age(iDG_6mo, mu2CA1theta_run_thresh, iDG_6mo_WT, iDG_6mo_Tg)
  2551. print('iDG 8mo')
  2552. Circstats_age(iDG_8mo, mu2CA1theta_run_thresh, iDG_8mo_WT, iDG_8mo_Tg)
  2553. print('Corrected P-Vals')
  2554. Circstats_full(iDG_6mo, iDG_8mo, mu2CA1theta_run_thresh, iDG_6mo_WT, iDG_6mo_Tg, iDG_8mo_WT, iDG_8mo_Tg)
  2555. circ_means_iCA1vCA1 <- iCA1 %>%
  2556. dplyr::group_by(Groupname, Genotype, Age_Broad) %>%
  2557. dplyr::summarise(circmean = mean.circular(mu2CA1theta_run_thresh, na.rm=TRUE))
  2558. circ_means_iCA1vCA1 <-mutate(circ_means_iCA1vCA1, circmean = ifelse(circmean <'0', circmean + 2*pi, circmean))
  2559. mu_hipp_p4 <- Mubygroup_2(iCA1, mu2CA1theta_run_thresh, 'Inhibitory CA1 Mu \n(ref:CA1 theta)',1,circ_means_iCA1vCA1)
  2560. mu_hipp_p4
  2561. print('Circ Stats iCA1 Mu vs CA1 theta (kuiper, equal-kappa, watson-williams, watson-wheeler, aov-circular)')
  2562. print('iCA1 6mo')
  2563. Circstats_age(iCA1_6mo, mu2CA1theta_run_thresh, iCA1_6mo_WT, iCA1_6mo_Tg)
  2564. print('iCA1 8mo')
  2565. Circstats_age(iCA1_8mo, mu2CA1theta_run_thresh, iCA1_8mo_WT, iCA1_8mo_Tg)
  2566. print('Corrected P-Vals')
  2567. Circstats_full(iCA1_6mo, iCA1_8mo, mu2CA1theta_run_thresh, iCA1_6mo_WT, iCA1_6mo_Tg, iCA1_8mo_WT, iCA1_8mo_Tg)
  2568. # circ_means_eMEC2vMEC <- eMEC2 %>%
  2569. # dplyr::group_by(Groupname, Genotype, Age_Broad) %>%
  2570. # dplyr::summarise(circmean = mean.circular(mu2MECtheta_run_thresh, na.rm=TRUE))
  2571. # circ_means_eMEC2vMEC <-mutate(circ_means_eMEC2vMEC , circmean = ifelse(circmean <'0', circmean + 2*pi, circmean))
  2572. # Mubygroup_2(eMEC2, mu2MECtheta_run_thresh, 'Excitatory MEC2 Mu \n(ref:MEC theta)',1, circ_means_eMEC2vMEC)
  2573. #
  2574. # print('Circ Stats eMEC2 Mu vs MEC theta (kuiper, equal-kappa, watson-williams, watson-wheeler, aov-circular)')
  2575. # print('eMEC2 6mo')
  2576. # Circstats_age(eMEC2_6mo, mu2MECtheta_run_thresh, eMEC2_6mo_WT, eMEC2_6mo_Tg)
  2577. # print('eMEC2 8mo')
  2578. # Circstats_age(eMEC2_8mo, mu2MECtheta_run_thresh, eMEC2_8mo_WT, eMEC2_8mo_Tg)
  2579. # print('Corrected P-Vals')
  2580. # Circstats_full(eMEC2_6mo, eMEC2_8mo, mu2MECtheta_run_thresh, eMEC2_6mo_WT, eMEC2_6mo_Tg, eMEC2_8mo_WT, eMEC2_8mo_Tg)
  2581. #
  2582. # circ_means_eMEC3vMEC <- eMEC3 %>%
  2583. # dplyr::group_by(Groupname, Genotype, Age_Broad) %>%
  2584. # dplyr::summarise(circmean = mean.circular(mu2MECtheta_run_thresh, na.rm=TRUE))
  2585. # circ_means_eMEC3vMEC <-mutate(circ_means_eMEC3vMEC , circmean = ifelse(circmean <'0', circmean + 2*pi, circmean))
  2586. # Mubygroup_2(eMEC3, mu2MECtheta_run_thresh, 'Excitatory MEC3 Mu \n(ref:MEC theta)',0, circ_means_eMEC3vMEC)
  2587. #
  2588. # print('Circ Stats eMEC3 Mu vs MEC theta (kuiper, equal-kappa, watson-williams, watson-wheeler, aov-circular)')
  2589. # print('eMEC3 6mo')
  2590. # Circstats_age(eMEC3_6mo, mu2MECtheta_run_thresh, eMEC3_6mo_WT, eMEC3_6mo_Tg)
  2591. # print('eMEC3 8mo')
  2592. # Circstats_age(eMEC3_8mo, mu2MECtheta_run_thresh, eMEC3_8mo_WT, eMEC3_8mo_Tg)
  2593. # print('Corrected P-Vals')
  2594. # Circstats_full(eMEC3_6mo, eMEC3_8mo, mu2MECtheta_run_thresh, eMEC3_6mo_WT, eMEC3_6mo_Tg, eMEC3_8mo_WT, eMEC3_8mo_Tg)
  2595. #
  2596. # circ_means_iMEC2vMEC <- iMEC2 %>%
  2597. # dplyr::group_by(Groupname, Genotype, Age_Broad) %>%
  2598. # dplyr::summarise(circmean = mean.circular(mu2MECtheta_run_thresh, na.rm=TRUE))
  2599. # circ_means_iMEC2vMEC <-mutate(circ_means_iMEC2vMEC , circmean = ifelse(circmean <'0', circmean + 2*pi, circmean))
  2600. # Mubygroup_2(iMEC2, mu2MECtheta_run_thresh, 'Inhibitory MEC2 Mu \n(ref:MEC theta)',1, circ_means_iMEC2vMEC)
  2601. #
  2602. # print('Circ Stats iMEC2 Mu vs MEC theta (kuiper, equal-kappa, watson-williams, watson-wheeler, aov-circular)')
  2603. # print('iMEC2 6mo')
  2604. # Circstats_age(iMEC2_6mo, mu2MECtheta_run_thresh, iMEC2_6mo_WT, iMEC2_6mo_Tg)
  2605. # print('iMEC2 8mo')
  2606. # Circstats_age(iMEC2_8mo, mu2MECtheta_run_thresh, iMEC2_8mo_WT, iMEC2_8mo_Tg)
  2607. # print('Corrected P-Vals')
  2608. # Circstats_full(iMEC2_6mo, iMEC2_8mo, mu2MECtheta_run_thresh, iMEC2_6mo_WT, iMEC2_6mo_Tg, iMEC2_8mo_WT, iMEC2_8mo_Tg)
  2609. #
  2610. #
  2611. # circ_means_iMEC3vMEC <- iMEC3 %>%
  2612. # dplyr::group_by(Groupname, Genotype, Age_Broad) %>%
  2613. # dplyr::summarise(circmean = mean.circular(mu2MECtheta_run_thresh, na.rm=TRUE))
  2614. # circ_means_iMEC3vMEC <-mutate(circ_means_iMEC3vMEC , circmean = ifelse(circmean <'0', circmean + 2*pi, circmean))
  2615. # Mubygroup_2(iMEC3, mu2MECtheta_run_thresh, 'Inhibitory MEC3 Mu \n(ref:MEC theta)', 1, circ_means_iMEC3vMEC)
  2616. #
  2617. # print('Circ Stats iMEC3 Mu vs MEC theta (kuiper, equal-kappa, watson-williams, watson-wheeler, aov-circular)')
  2618. # print('iMEC3 6mo')
  2619. # Circstats_age(iMEC3_6mo, mu2MECtheta_run_thresh, iMEC3_6mo_WT, iMEC3_6mo_Tg)
  2620. # print('iMEC3 8mo')
  2621. # Circstats_age(iMEC3_8mo, mu2MECtheta_run_thresh, iMEC3_8mo_WT, iMEC3_8mo_Tg)
  2622. # print('Corrected P-Vals')
  2623. # Circstats_full(iMEC3_6mo, iMEC3_8mo, mu2MECtheta_run_thresh, iMEC3_6mo_WT, iMEC3_6mo_Tg, iMEC3_8mo_WT, iMEC3_8mo_Tg)
  2624. #
  2625. plot_list_fr_mec= list(fr_mec_p1, fr_mec_p2)
  2626. plot_list_fr_hipp= list(fr_hipp_p1, fr_hipp_p2, fr_hipp_p3, fr_hipp_p4)
  2627. plot_list_r_mec= list(r_mec_p1, r_mec_p2, r_mec_p3, r_mec_p4, r_mec_p5, r_mec_p6, r_mec_p7, r_mec_p8)
  2628. plot_list_r_hipp= list(r_hipp_p1, r_hipp_p2, r_hipp_p3, r_hipp_p4)
  2629. plot_list_mu_mec= list(mu_mec_p1, mu_mec_p2, mu_mec_p3, mu_mec_p4 )
  2630. plot_list_mu_hipp= list(mu_hipp_p1, mu_hipp_p2, mu_hipp_p3, mu_hipp_p4)
  2631. ID = 1
  2632. for (p in plot_list_fr_mec) {
  2633. ggsave(
  2634. p,
  2635. filename=paste("FR_MEC_Plot",ID,".svg",sep=""),
  2636. width = 5,
  2637. height = 5,
  2638. dpi = 600)
  2639. ID = ID + 1
  2640. }
  2641. ID = 1
  2642. for (p in plot_list_fr_hipp) {
  2643. ggsave(
  2644. p,
  2645. filename=paste("FR_HIPP_Plot",ID,".svg",sep=""),
  2646. width = 5,
  2647. height = 5,
  2648. dpi = 600)
  2649. ID = ID + 1
  2650. }
  2651. ID = 1
  2652. for (p in plot_list_r_mec) {
  2653. ggsave(
  2654. p,
  2655. filename=paste("R_MEC_Plot",ID,".svg",sep=""),
  2656. width = 5,
  2657. height = 5,
  2658. dpi = 600)
  2659. ID = ID + 1
  2660. }
  2661. ID = 1
  2662. for (p in plot_list_r_hipp) {
  2663. ggsave(
  2664. p,
  2665. filename=paste("R_HIPP_Plot",ID,".svg",sep=""),
  2666. width = 5,
  2667. height = 5,
  2668. dpi = 600)
  2669. ID = ID + 1
  2670. }
  2671. ID = 1
  2672. for (p in plot_list_mu_mec) {
  2673. ggsave(
  2674. p,
  2675. filename=paste("Mu_MEC_Plot",ID,".svg",sep=""),
  2676. width = 5,
  2677. height = 5,
  2678. dpi = 600)
  2679. ID = ID + 1
  2680. }
  2681. ID = 1
  2682. for (p in plot_list_mu_hipp) {
  2683. ggsave(
  2684. p,
  2685. filename=paste("Mu_HIPP_Plot",ID,".svg",sep=""),
  2686. width = 5,
  2687. height = 5,
  2688. dpi = 600)
  2689. ID = ID + 1
  2690. }
  2691. #Precession - Figure S10
  2692. dataHIPP <-read.csv("precession_HIPP.csv")
  2693. dataHIPP <- subset(dataHIPP, Celltype != 'unknown')
  2694. dataHIPP<- mutate(dataHIPP, Genotype = case_when(Group == '83x' | Group == '63x' ~ '3xTg',
  2695. Group == '6wt' | Group == '8wt' ~ 'WT'))
  2696. dataHIPP<- mutate(dataHIPP, Age_Broad = case_when(Group == '83x' | Group == '8wt' ~ '8',
  2697. Group == '63x' | Group == '6wt' ~ '6'))
  2698. dataHIPP$Groupname = factor(dataHIPP$Group, levels = c('6wt', '8wt', '63x', '83x'))
  2699. dataHIPP$Genotype = factor(dataHIPP$Genotype, levels = c('WT', '3xTg'))
  2700. dataHIPP$Age_Broad = factor(dataHIPP$Age_Broad, levels = c('6', '8'))
  2701. #get frequency values from my wavelet calculation - 1 channel in mid HIPP
  2702. WaveletdataHIPP <-read.csv("Wavelet_Freq_by_Speed_Theta_midPyr_HIPP.csv") #this sheet has a bunch of other excessive info - maybe edit - just pulling out column for all running time for each animal here
  2703. WaveletdataHIPP_runall <- WaveletdataHIPP %>% distinct(Animal, .keep_all=TRUE)
  2704. WaveletdataHIPP_runall = subset(WaveletdataHIPP_runall, select = c(Animal, Group, Sex, Subregion, Length_run, PFreq5to12_run))
  2705. data2HIPP <- mutate(dataHIPP, wavelet_freq = 1) #create new column
  2706. for (row in 1:nrow(data2HIPP)) { #add theta lfp frequency info to dataframe
  2707. animal <- data2HIPP[row, "Animal"]
  2708. anim_data <- subset(WaveletdataHIPP_runall, Animal == animal)
  2709. waveletfreq = anim_data$PFreq5to12_run
  2710. data2HIPP[row, 19] <- waveletfreq
  2711. }
  2712. data2HIPP$wavelet_freq = as.numeric(data2HIPP$wavelet_freq)
  2713. data2HIPP <- mutate(data2HIPP, unitvswaveletfreq = Unitfreq - wavelet_freq) #get difference between unit and wavelet freq
  2714. data2HIPP<- mutate(data2HIPP, unit_waveletfreq_ratio = Unitfreq/wavelet_freq) #ratio
  2715. #subset
  2716. CA1 <- subset(data2HIPP, Region == 'CA1')
  2717. DG <-subset(data2HIPP, Region == 'DG')
  2718. eHIPP <-subset(data2HIPP, Celltype == 'exc')
  2719. iHIPP <-subset(data2HIPP, Celltype == 'inh')
  2720. eCA1 <-subset(CA1, Celltype == 'exc')
  2721. eDG <-subset(DG, Celltype == 'exc')
  2722. iCA1 <-subset(CA1, Celltype == 'inh')
  2723. iDG <-subset(DG, Celltype == 'inh')
  2724. #plot
  2725. #UNIT VS WAVELET FREQ
  2726. AnyPlotbygroup_adjaxis_facet(eCA1,unitvswaveletfreq, "Unit vs LFP frequency - All CA1 Exc Cells", "Unit - LFP freq", -20, 20)
  2727. Singleunit_nonparametric(eCA1, unitvswaveletfreq)
  2728. ggsave(
  2729. "UnitvLFPfreq_eCA1.svg",
  2730. AnyPlotbygroup_adjaxis_facet(eCA1,unitvswaveletfreq, "Excitatory CA1 \n Unit vs LFP frequency", "Unit - LFP freq (Hz)", -2, 15),
  2731. width = 5,
  2732. height = 5,
  2733. dpi = 600
  2734. )
  2735. #UNIT FREQ
  2736. AnyPlotbygroup_adjaxis_facet(eCA1, Unitfreq, "Unit frequency exc CA1", "Unit freq", 0, 20)
  2737. ggsave(
  2738. "Unitfreq_eCA1.svg",
  2739. AnyPlotbygroup_adjaxis_facet(eCA1,Unitfreq, "Excitatory CA1 \n Spike Train Frequency", "Spike Train Frequency (Hz)", 0, 20),
  2740. width = 5,
  2741. height = 5,
  2742. dpi = 600
  2743. )
  2744. Singleunit_nonparametric(eCA1, Unitfreq)
  2745. ```
  2746. # PV + NeuN Immunohistochemistry
  2747. ```{r pv-neun, echo=FALSE, warning = FALSE}
  2748. #TO DO: Remove wave 0 hippocampus
  2749. #remove 15 mo animals
  2750. #Figure S9
  2751. CellCountsbygroup_adjaxis<- function(df, y, title, ytitle, ymin, ymax) { # ymin =0, ymax=50){
  2752. plot <-ggplot(df ,aes(x=Genotype, y={{y}}))
  2753. plot +geom_sina(aes(col= Groupname, shape = Sex), alpha = 0.5, na.rm = TRUE, jitter_y = FALSE) +
  2754. geom_bar(position= "dodge", stat = "summary", width = 0.9, fun.y = "mean", alpha = 0.4, aes(fill=Groupname), color = "black") +
  2755. stat_summary( color = 'black', fun.data = mean_se, geom = "errorbar", width = 0.4, alpha = 0.8, show.legend=FALSE) +
  2756. ggtitle(title) + ylab(ytitle) +
  2757. scale_fill_manual("legend", values = scale_fill_palette, labels = c("WT 6 mo", "WT 8 mo", "3xTg 6 mo", "3xTg 8 mo"))+
  2758. guides(fill=guide_legend("Group")) +
  2759. #scale_fill_manual("legend", values = scale_fill_palette, guide = "none")+
  2760. scale_color_manual("legend", values = scale_colour_palette, guide = "none")+
  2761. scale_y_continuous(expand = c(0,0)) + #, limits = c(ymin,ymax), breaks = seq(0, 14, by = 2))
  2762. coord_cartesian(ylim=c(ymin, ymax))+
  2763. scale_alpha(guide = 'none') +
  2764. facet_grid(.~Age_Broad, switch = "x", labeller = as_labeller(c('6' = "6 mo", '8' = "8 mo"))) +
  2765. theme(plot.title = element_text(hjust = 0.5, size = 22, face = "bold"),
  2766. axis.text.x = element_text(size = 15, colour = "black"),
  2767. #axis.text.x = element_blank(),
  2768. #axis.ticks.x=element_blank(),
  2769. axis.text.y = element_text(size = 18, face="bold", colour = "black"),
  2770. axis.title.y = element_text(size = 20, face = "bold", colour = "black"),
  2771. axis.title.x = element_blank(),
  2772. legend.text=element_text(size=16),
  2773. legend.title=element_text(size=18),
  2774. panel.grid.major = element_blank(),
  2775. panel.grid.minor = element_blank(),
  2776. panel.background = element_blank(),
  2777. axis.line = element_line(colour = "black"),
  2778. strip.text.x = element_text(size = 18, face = "bold"),
  2779. strip.background = element_rect( fill="white"),
  2780. panel.spacing.x = unit(1.4, "lines"),
  2781. strip.placement = "outside")
  2782. }
  2783. #PV
  2784. CellCounts <- read_xlsx("PV_IHC_MEC_HIPP_final.xlsx")
  2785. CellCounts$Genotype = factor(CellCounts$Genotype, levels = c('WT', '3xTg'))
  2786. CellCounts <- mutate(CellCounts, Age_Broad = ifelse(Age < 7.5, "6",
  2787. ifelse(Age > 7.5 & Age < 10, "8", "NA")))
  2788. CellCounts <- mutate(CellCounts, Groupname = case_when(Genotype == 'WT' & Age_Broad == '6' ~ '6wt',
  2789. Genotype == '3xTg' & Age_Broad == '6' ~ '63x',
  2790. Genotype == 'WT' & Age_Broad == '8' ~ '8wt',
  2791. Genotype == '3xTg' & Age_Broad == '8' ~ '83x',
  2792. ))
  2793. MEC2_Counts <- subset(CellCounts, Subregion == 'MEC2')
  2794. MEC3_Counts <- subset(CellCounts, Subregion == 'MEC3')
  2795. DG_Counts <- subset(CellCounts, Subregion == 'DG')
  2796. CA1_Counts <- subset(CellCounts, Subregion == 'CA1')
  2797. CA3_Counts <- subset(CellCounts, Subregion == 'CA3')
  2798. #reformat data to get dataframes with values by animal instead of by slice
  2799. MEC2_Counts <- mutate(MEC2_Counts, Slice= as.factor(Slice))
  2800. MEC2_byanimal <- MEC2_Counts %>%
  2801. dplyr::select(Mouse, Genotype, Groupname, Sex, Age_Broad, Age, Wave, Cage, Slice, CellsPerSqmm)
  2802. MEC2_byanimal<- dcast(MEC2_byanimal, Mouse + Genotype + Groupname + Sex + Age_Broad + Age + Wave + Cage ~ Slice, na.rm=TRUE)
  2803. MEC2_byanimal <- mutate(MEC2_byanimal, Avg = rowMeans(dplyr::select(MEC2_byanimal,'1','2','3','4','5'), na.rm =TRUE))
  2804. MEC3_Counts <- mutate(MEC3_Counts, Slice= as.factor(Slice))
  2805. MEC3_byanimal <- MEC3_Counts %>%
  2806. dplyr::select(Mouse, Genotype, Groupname, Sex, Age_Broad, Age, Wave, Cage, Slice, CellsPerSqmm)
  2807. MEC3_byanimal<- dcast(MEC3_byanimal, Mouse + Genotype + Groupname + Sex + Age_Broad + Age + Wave + Cage ~ Slice, na.rm=TRUE)
  2808. MEC3_byanimal <- mutate(MEC3_byanimal, Avg = rowMeans(dplyr::select(MEC3_byanimal,'1','2','3','4','5'), na.rm =TRUE))
  2809. DG_Counts <- mutate(DG_Counts, Slice= as.factor(Slice))
  2810. DG_byanimal <- DG_Counts %>%
  2811. dplyr::select(Mouse, Genotype, Groupname, Sex, Age_Broad, Age, Wave, Cage, Slice, CellsPerSqmm)
  2812. DG_byanimal<- dcast(DG_byanimal, Mouse + Genotype + Groupname + Sex + Age_Broad + Age + Wave + Cage ~ Slice, na.rm=TRUE)
  2813. DG_byanimal <- mutate(DG_byanimal, Avg = rowMeans(dplyr::select(DG_byanimal,'1','2','3','4'), na.rm =TRUE))
  2814. CA1_Counts <- mutate(CA1_Counts, Slice= as.factor(Slice))
  2815. CA1_byanimal <- CA1_Counts %>%
  2816. dplyr::select(Mouse, Genotype, Groupname, Sex, Age_Broad, Age, Wave, Cage, Slice, CellsPerSqmm)
  2817. CA1_byanimal<- dcast(CA1_byanimal, Mouse + Genotype + Groupname + Sex + Age_Broad + Age + Wave + Cage ~ Slice, na.rm=TRUE)
  2818. CA1_byanimal <- mutate(CA1_byanimal, Avg = rowMeans(dplyr::select(CA1_byanimal,'1','2','3','4'), na.rm =TRUE))
  2819. CA3_Counts <- mutate(CA3_Counts, Slice= as.factor(Slice))
  2820. CA3_byanimal <- CA3_Counts %>%
  2821. dplyr::select(Mouse, Genotype, Groupname, Sex, Age_Broad, Age, Wave, Cage, Slice, CellsPerSqmm)
  2822. CA3_byanimal<- dcast(CA3_byanimal, Mouse + Genotype + Groupname + Sex + Age_Broad + Age + Wave + Cage ~ Slice, na.rm=TRUE)
  2823. CA3_byanimal <- mutate(CA3_byanimal, Avg = rowMeans(dplyr::select(CA3_byanimal,'1','2','3','4'), na.rm =TRUE))
  2824. MEC2_byanimal$Groupname= factor(MEC2_byanimal$Groupname, levels = c('6wt', '8wt', '63x', '83x'))
  2825. MEC3_byanimal$Groupname= factor(MEC3_byanimal$Groupname, levels = c('6wt', '8wt', '63x', '83x'))
  2826. CA1_byanimal$Groupname= factor(CA1_byanimal$Groupname, levels = c('6wt', '8wt', '63x', '83x'))
  2827. DG_byanimal$Groupname= factor(DG_byanimal$Groupname, levels = c('6wt', '8wt', '63x', '83x'))
  2828. CA3_byanimal$Groupname= factor(CA3_byanimal$Groupname, levels = c('6wt', '8wt', '63x', '83x'))
  2829. PV1 <- CellCountsbygroup_adjaxis(MEC2_byanimal, Avg, "PV+ Counts MEC2", expression(bold("Cells per" ~mm^2)), ymin= -0.25, ymax = 150)
  2830. PV1
  2831. print("PV MEC2 age x genotype anova")
  2832. General_AOVbyanim_ez(MEC2_byanimal, Avg, Age_Broad, Mouse)
  2833. General_byanim_holm(MEC2_byanimal, Avg, Age_Broad)
  2834. PV2 <-CellCountsbygroup_adjaxis(MEC3_byanimal, Avg, "PV+ Counts MEC3", expression(bold("Cells per" ~mm^2)), ymin= -0.25, ymax = 150)
  2835. PV2
  2836. print("PV MEC3 age x genotype anova")
  2837. General_AOVbyanim_ez(MEC3_byanimal, Avg, Age_Broad, Mouse)
  2838. General_byanim_holm(MEC3_byanimal, Avg, Age_Broad)
  2839. PV3 <- CellCountsbygroup_adjaxis(DG_byanimal, Avg, "PV+ Counts DG", expression(bold("Cells per" ~mm^2)), ymin= -0.25, ymax = 50)
  2840. PV3
  2841. print("PV DG age x genotype anova")
  2842. General_AOVbyanim_ez(DG_byanimal, Avg, Age_Broad, Mouse)
  2843. PV4 <- CellCountsbygroup_adjaxis(CA1_byanimal, Avg, "PV+ Counts CA1", expression(bold("Cells per" ~mm^2)), ymin= -0.25, ymax = 100)
  2844. PV4
  2845. print("PV CA1 age x genotype anova")
  2846. General_AOVbyanim_ez(CA1_byanimal, Avg, Age_Broad, Mouse)
  2847. General_byanim_holm(CA1_byanimal, Avg, Age_Broad)
  2848. PV5 <- CellCountsbygroup_adjaxis(CA3_byanimal, Avg, "PV+ Counts CA3", expression(bold("Cells per" ~mm^2)), ymin= -0.25, ymax = 150)
  2849. PV5
  2850. print("PV CA3 age x genotype anova")
  2851. General_AOVbyanim_ez(CA3_byanimal, Avg, Age_Broad, Mouse)
  2852. MEC3_byanimal_6mo <- subset(MEC3_byanimal, Age_Broad == '6')
  2853. MEC3_byanimal_8mo <- subset(MEC3_byanimal, Age_Broad == '8')
  2854. MEC2_byanimal_6mo <- subset(MEC2_byanimal, Age_Broad == '6')
  2855. MEC2_byanimal_8mo <- subset(MEC2_byanimal, Age_Broad == '8')
  2856. DG_byanimal_6mo <- subset(DG_byanimal, Age_Broad == '6')
  2857. DG_byanimal_8mo <- subset(DG_byanimal, Age_Broad == '8')
  2858. CA1_byanimal_6mo <- subset(CA1_byanimal, Age_Broad == '6')
  2859. CA1_byanimal_8mo <- subset(CA1_byanimal, Age_Broad == '8')
  2860. CA3_byanimal_6mo <- subset(CA3_byanimal, Age_Broad == '6')
  2861. CA3_byanimal_8mo <- subset(CA3_byanimal, Age_Broad == '8')
  2862. #Sex differences
  2863. print("PV MEC2 6 mo Genotype x Sex ANOVA")
  2864. General_AOVbyanim_ez(MEC2_byanimal_6mo, Avg, Sex, Mouse)
  2865. print("PV MEC3 6 mo Genotype x Sex ANOVA")
  2866. General_AOVbyanim_ez(MEC3_byanimal_6mo, Avg, Sex, Mouse)
  2867. print("PV MEC2 8 mo Genotype x Sex ANOVA")
  2868. General_AOVbyanim_ez(MEC2_byanimal_8mo, Avg, Sex, Mouse)
  2869. General_byanim_holm_sex(MEC2_byanimal_8mo, Avg, Sex)
  2870. print("PV MEC3 8 mo Genotype x Sex ANOVA")
  2871. General_AOVbyanim_ez(MEC3_byanimal_8mo, Avg, Sex, Mouse)
  2872. print("PV CA1 6 mo Genotype x Sex ANOVA")
  2873. General_AOVbyanim_ez(CA1_byanimal_6mo, Avg, Sex, Mouse)
  2874. print("PV DG 6 mo Genotype x Sex ANOVA")
  2875. General_AOVbyanim_ez(DG_byanimal_6mo, Avg, Sex, Mouse)
  2876. print("PV CA3 6 mo Genotype x Sex ANOVA")
  2877. General_AOVbyanim_ez(CA3_byanimal_6mo, Avg, Sex, Mouse)
  2878. print("PV CA1 8 mo Genotype x Sex ANOVA")
  2879. General_AOVbyanim_ez(CA1_byanimal_8mo, Avg, Sex, Mouse)
  2880. print("PV DG 8 mo Genotype x Sex ANOVA")
  2881. General_AOVbyanim_ez(DG_byanimal_8mo, Avg, Sex, Mouse)
  2882. print("PV CA3 8 mo Genotype x Sex ANOVA")
  2883. General_AOVbyanim_ez(CA3_byanimal_8mo, Avg, Sex, Mouse)
  2884. #Sample Sizes and Mean Ages
  2885. ###MEC2
  2886. print("Ns PV MEC2")
  2887. print("WT 6mo (M, F)")
  2888. sum(MEC2_byanimal_6mo$Genotype == "WT" & MEC2_byanimal_6mo$Age_Broad == '6')
  2889. sum(MEC2_byanimal_6mo$Genotype == "WT" & MEC2_byanimal_6mo$Age_Broad == '6' & MEC2_byanimal_6mo$Sex == 'M')
  2890. sum(MEC2_byanimal_6mo$Genotype == "WT" & MEC2_byanimal_6mo$Age_Broad == '6' & MEC2_byanimal_6mo$Sex == 'F')
  2891. print("WT 8mo (M, F)")
  2892. sum(MEC2_byanimal_8mo$Genotype == "WT" & MEC2_byanimal_8mo$Age_Broad == '8')
  2893. sum(MEC2_byanimal_8mo$Genotype == "WT" & MEC2_byanimal_8mo$Age_Broad == '8' & MEC2_byanimal_8mo$Sex == 'M')
  2894. sum(MEC2_byanimal_8mo$Genotype == "WT" & MEC2_byanimal_8mo$Age_Broad == '8' & MEC2_byanimal_8mo$Sex == 'F')
  2895. print("3xTg 6mo (M, F)")
  2896. sum(MEC2_byanimal_6mo$Genotype == "3xTg" & MEC2_byanimal_6mo$Age_Broad == '6')
  2897. sum(MEC2_byanimal_6mo$Genotype == "3xTg" & MEC2_byanimal_6mo$Age_Broad == '6' & MEC2_byanimal_6mo$Sex == 'M')
  2898. sum(MEC2_byanimal_6mo$Genotype == "3xTg" & MEC2_byanimal_6mo$Age_Broad == '6' & MEC2_byanimal_6mo$Sex == 'F')
  2899. print("3xTg 8mo (M, F)")
  2900. sum(MEC2_byanimal_8mo$Genotype == "3xTg" & MEC2_byanimal_8mo$Age_Broad == '8')
  2901. sum(MEC2_byanimal_8mo$Genotype == "3xTg" & MEC2_byanimal_8mo$Age_Broad == '8' & MEC2_byanimal_8mo$Sex == 'M')
  2902. sum(MEC2_byanimal_8mo$Genotype == "3xTg" & MEC2_byanimal_8mo$Age_Broad == '8' & MEC2_byanimal_8mo$Sex == 'F')
  2903. print("Age MEC2 6 mo")
  2904. MEC2_byanimal_6mo %>%
  2905. dplyr::group_by(Groupname) %>%
  2906. dplyr::summarise(mean = mean(Age),
  2907. sem = plotrix::std.error(Age),
  2908. min = min(Age),
  2909. max = max(Age))
  2910. print("Age MEC2 8 mo")
  2911. MEC2_byanimal_8mo %>%
  2912. dplyr::group_by(Groupname) %>%
  2913. dplyr::summarise(mean = mean(Age),
  2914. sem = plotrix::std.error(Age),
  2915. min = min(Age),
  2916. max = max(Age))
  2917. ###MEC3
  2918. print("Ns PV MEC3")
  2919. print("WT 6mo (M, F)")
  2920. sum(MEC3_byanimal_6mo$Genotype == "WT" & MEC3_byanimal_6mo$Age_Broad == '6')
  2921. sum(MEC3_byanimal_6mo$Genotype == "WT" & MEC3_byanimal_6mo$Age_Broad == '6' & MEC3_byanimal_6mo$Sex == 'M')
  2922. sum(MEC3_byanimal_6mo$Genotype == "WT" & MEC3_byanimal_6mo$Age_Broad == '6' & MEC3_byanimal_6mo$Sex == 'F')
  2923. print("WT 8mo (M, F)")
  2924. sum(MEC3_byanimal_8mo$Genotype == "WT" & MEC3_byanimal_8mo$Age_Broad == '8')
  2925. sum(MEC3_byanimal_8mo$Genotype == "WT" & MEC3_byanimal_8mo$Age_Broad == '8' & MEC3_byanimal_8mo$Sex == 'M')
  2926. sum(MEC3_byanimal_8mo$Genotype == "WT" & MEC3_byanimal_8mo$Age_Broad == '8' & MEC3_byanimal_8mo$Sex == 'F')
  2927. print("3xTg 6mo (M, F)")
  2928. sum(MEC3_byanimal_6mo$Genotype == "3xTg" & MEC3_byanimal_6mo$Age_Broad == '6')
  2929. sum(MEC3_byanimal_6mo$Genotype == "3xTg" & MEC3_byanimal_6mo$Age_Broad == '6' & MEC3_byanimal_6mo$Sex == 'M')
  2930. sum(MEC3_byanimal_6mo$Genotype == "3xTg" & MEC3_byanimal_6mo$Age_Broad == '6' & MEC3_byanimal_6mo$Sex == 'F')
  2931. print("3xTg 8mo (M, F)")
  2932. sum(MEC3_byanimal_8mo$Genotype == "3xTg" & MEC3_byanimal_8mo$Age_Broad == '8')
  2933. sum(MEC3_byanimal_8mo$Genotype == "3xTg" & MEC3_byanimal_8mo$Age_Broad == '8' & MEC3_byanimal_8mo$Sex == 'M')
  2934. sum(MEC3_byanimal_8mo$Genotype == "3xTg" & MEC3_byanimal_8mo$Age_Broad == '8' & MEC3_byanimal_8mo$Sex == 'F')
  2935. print("Age MEC3 6 mo")
  2936. MEC3_byanimal_6mo %>%
  2937. dplyr::group_by(Groupname) %>%
  2938. dplyr::summarise(mean = mean(Age),
  2939. sem = plotrix::std.error(Age),
  2940. min = min(Age),
  2941. max = max(Age))
  2942. print("Age MEC3 8 mo")
  2943. MEC3_byanimal_8mo %>%
  2944. dplyr::group_by(Groupname) %>%
  2945. dplyr::summarise(mean = mean(Age),
  2946. sem = plotrix::std.error(Age),
  2947. min = min(Age),
  2948. max = max(Age))
  2949. ###CA1
  2950. print("Ns PV CA1")
  2951. print("WT 6mo (M, F)")
  2952. sum(CA1_byanimal_6mo$Genotype == "WT" & CA1_byanimal_6mo$Age_Broad == '6')
  2953. sum(CA1_byanimal_6mo$Genotype == "WT" & CA1_byanimal_6mo$Age_Broad == '6' & CA1_byanimal_6mo$Sex == 'M')
  2954. sum(CA1_byanimal_6mo$Genotype == "WT" & CA1_byanimal_6mo$Age_Broad == '6' & CA1_byanimal_6mo$Sex == 'F')
  2955. print("WT 8mo (M, F)")
  2956. sum(CA1_byanimal_8mo$Genotype == "WT" & CA1_byanimal_8mo$Age_Broad == '8')
  2957. sum(CA1_byanimal_8mo$Genotype == "WT" & CA1_byanimal_8mo$Age_Broad == '8' & CA1_byanimal_8mo$Sex == 'M')
  2958. sum(CA1_byanimal_8mo$Genotype == "WT" & CA1_byanimal_8mo$Age_Broad == '8' & CA1_byanimal_8mo$Sex == 'F')
  2959. print("3xTg 6mo (M, F)")
  2960. sum(CA1_byanimal_6mo$Genotype == "3xTg" & CA1_byanimal_6mo$Age_Broad == '6')
  2961. sum(CA1_byanimal_6mo$Genotype == "3xTg" & CA1_byanimal_6mo$Age_Broad == '6' & CA1_byanimal_6mo$Sex == 'M')
  2962. sum(CA1_byanimal_6mo$Genotype == "3xTg" & CA1_byanimal_6mo$Age_Broad == '6' & CA1_byanimal_6mo$Sex == 'F')
  2963. print("3xTg 8mo (M, F)")
  2964. sum(CA1_byanimal_8mo$Genotype == "3xTg" & CA1_byanimal_8mo$Age_Broad == '8')
  2965. sum(CA1_byanimal_8mo$Genotype == "3xTg" & CA1_byanimal_8mo$Age_Broad == '8' & CA1_byanimal_8mo$Sex == 'M')
  2966. sum(CA1_byanimal_8mo$Genotype == "3xTg" & CA1_byanimal_8mo$Age_Broad == '8' & CA1_byanimal_8mo$Sex == 'F')
  2967. print("Age CA1 6 mo")
  2968. CA1_byanimal_6mo %>%
  2969. dplyr::group_by(Groupname) %>%
  2970. dplyr::summarise(mean = mean(Age),
  2971. sem = plotrix::std.error(Age),
  2972. min = min(Age),
  2973. max = max(Age))
  2974. print("Age CA1 8 mo")
  2975. CA1_byanimal_8mo %>%
  2976. dplyr::group_by(Groupname) %>%
  2977. dplyr::summarise(mean = mean(Age),
  2978. sem = plotrix::std.error(Age),
  2979. min = min(Age),
  2980. max = max(Age))
  2981. ###DG
  2982. print("Ns PV DG")
  2983. print("WT 6mo (M, F)")
  2984. sum(DG_byanimal_6mo$Genotype == "WT" & DG_byanimal_6mo$Age_Broad == '6')
  2985. sum(DG_byanimal_6mo$Genotype == "WT" & DG_byanimal_6mo$Age_Broad == '6' & DG_byanimal_6mo$Sex == 'M')
  2986. sum(DG_byanimal_6mo$Genotype == "WT" & DG_byanimal_6mo$Age_Broad == '6' & DG_byanimal_6mo$Sex == 'F')
  2987. print("WT 8mo (M, F)")
  2988. sum(DG_byanimal_8mo$Genotype == "WT" & DG_byanimal_8mo$Age_Broad == '8')
  2989. sum(DG_byanimal_8mo$Genotype == "WT" & DG_byanimal_8mo$Age_Broad == '8' & DG_byanimal_8mo$Sex == 'M')
  2990. sum(DG_byanimal_8mo$Genotype == "WT" & DG_byanimal_8mo$Age_Broad == '8' & DG_byanimal_8mo$Sex == 'F')
  2991. print("3xTg 6mo (M, F)")
  2992. sum(DG_byanimal_6mo$Genotype == "3xTg" & DG_byanimal_6mo$Age_Broad == '6')
  2993. sum(DG_byanimal_6mo$Genotype == "3xTg" & DG_byanimal_6mo$Age_Broad == '6' & DG_byanimal_6mo$Sex == 'M')
  2994. sum(DG_byanimal_6mo$Genotype == "3xTg" & DG_byanimal_6mo$Age_Broad == '6' & DG_byanimal_6mo$Sex == 'F')
  2995. print("3xTg 8mo (M, F)")
  2996. sum(DG_byanimal_8mo$Genotype == "3xTg" & DG_byanimal_8mo$Age_Broad == '8')
  2997. sum(DG_byanimal_8mo$Genotype == "3xTg" & DG_byanimal_8mo$Age_Broad == '8' & DG_byanimal_8mo$Sex == 'M')
  2998. sum(DG_byanimal_8mo$Genotype == "3xTg" & DG_byanimal_8mo$Age_Broad == '8' & DG_byanimal_8mo$Sex == 'F')
  2999. print("Age DG 6 mo")
  3000. DG_byanimal_6mo %>%
  3001. dplyr::group_by(Groupname) %>%
  3002. dplyr::summarise(mean = mean(Age),
  3003. sem = plotrix::std.error(Age),
  3004. min = min(Age),
  3005. max = max(Age))
  3006. print("Age DG 8 mo")
  3007. DG_byanimal_8mo %>%
  3008. dplyr::group_by(Groupname) %>%
  3009. dplyr::summarise(mean = mean(Age),
  3010. sem = plotrix::std.error(Age),
  3011. min = min(Age),
  3012. max = max(Age))
  3013. ###CA3
  3014. print("Ns PV CA3")
  3015. print("WT 6mo (M, F)")
  3016. sum(CA3_byanimal_6mo$Genotype == "WT" & CA3_byanimal_6mo$Age_Broad == '6')
  3017. sum(CA3_byanimal_6mo$Genotype == "WT" & CA3_byanimal_6mo$Age_Broad == '6' & CA3_byanimal_6mo$Sex == 'M')
  3018. sum(CA3_byanimal_6mo$Genotype == "WT" & CA3_byanimal_6mo$Age_Broad == '6' & CA3_byanimal_6mo$Sex == 'F')
  3019. print("WT 8mo (M, F)")
  3020. sum(CA3_byanimal_8mo$Genotype == "WT" & CA3_byanimal_8mo$Age_Broad == '8')
  3021. sum(CA3_byanimal_8mo$Genotype == "WT" & CA3_byanimal_8mo$Age_Broad == '8' & CA3_byanimal_8mo$Sex == 'M')
  3022. sum(CA3_byanimal_8mo$Genotype == "WT" & CA3_byanimal_8mo$Age_Broad == '8' & CA3_byanimal_8mo$Sex == 'F')
  3023. print("3xTg 6mo (M, F)")
  3024. sum(CA3_byanimal_6mo$Genotype == "3xTg" & CA3_byanimal_6mo$Age_Broad == '6')
  3025. sum(CA3_byanimal_6mo$Genotype == "3xTg" & CA3_byanimal_6mo$Age_Broad == '6' & CA3_byanimal_6mo$Sex == 'M')
  3026. sum(CA3_byanimal_6mo$Genotype == "3xTg" & CA3_byanimal_6mo$Age_Broad == '6' & CA3_byanimal_6mo$Sex == 'F')
  3027. print("3xTg 8mo (M, F)")
  3028. sum(CA3_byanimal_8mo$Genotype == "3xTg" & CA3_byanimal_8mo$Age_Broad == '8')
  3029. sum(CA3_byanimal_8mo$Genotype == "3xTg" & CA3_byanimal_8mo$Age_Broad == '8' & CA3_byanimal_8mo$Sex == 'M')
  3030. sum(CA3_byanimal_8mo$Genotype == "3xTg" & CA3_byanimal_8mo$Age_Broad == '8' & CA3_byanimal_8mo$Sex == 'F')
  3031. print("Age CA3 6 mo")
  3032. CA3_byanimal_6mo %>%
  3033. dplyr::group_by(Groupname) %>%
  3034. dplyr::summarise(mean = mean(Age),
  3035. sem = plotrix::std.error(Age),
  3036. min = min(Age),
  3037. max = max(Age))
  3038. print("Age CA3 8 mo")
  3039. CA3_byanimal_8mo %>%
  3040. dplyr::group_by(Groupname) %>%
  3041. dplyr::summarise(mean = mean(Age),
  3042. sem = plotrix::std.error(Age),
  3043. min = min(Age),
  3044. max = max(Age))
  3045. #REPEAT FOR NEUN
  3046. CellCounts<- read_xlsx("NeuN_IHC_MEC_final.xlsx")
  3047. CellCounts <- mutate(CellCounts, Genotype = case_when(Genotype == '3x-Tg' ~ '3xTg',
  3048. Genotype == '3xTg' ~ '3xTg',
  3049. Genotype == 'WT' ~ 'WT'))
  3050. CellCounts$Genotype = factor(CellCounts$Genotype, levels = c('WT', '3xTg'))
  3051. CellCounts <- mutate(CellCounts, Age_Broad = ifelse(Age < 7.5, "6",
  3052. ifelse(Age > 7.5 & Age < 10, "8", "NA")))
  3053. CellCounts <- mutate(CellCounts, Groupname = case_when(Genotype == 'WT' & Age_Broad == '6' ~ '6wt',
  3054. Genotype == '3xTg' & Age_Broad == '6' ~ '63x',
  3055. Genotype == 'WT' & Age_Broad == '8' ~ '8wt',
  3056. Genotype == '3xTg' & Age_Broad == '8' ~ '83x'
  3057. ))
  3058. #removed slices with 0 cells labeled due to poor staining caused by experimental errors - mostly in wave 2
  3059. MEC2_Counts <- subset(CellCounts, Subregion == 'MEC2')
  3060. MEC3_Counts <- subset(CellCounts, Subregion == 'MEC3')
  3061. #reformat data to get dataframes with values by animal instead of by slice
  3062. MEC2_Counts <- mutate(MEC2_Counts, Slice= as.factor(Slice))
  3063. MEC2_byanimal <- MEC2_Counts %>%
  3064. dplyr::select(Mouse, Genotype, Groupname, Sex, Age_Broad, Age, Wave, Cage, Slice, CellsPerSqmm)
  3065. MEC2_byanimal<- dcast(MEC2_byanimal, Mouse + Genotype + Groupname + Sex + Age_Broad + Age + Wave + Cage ~ Slice, na.rm=TRUE)
  3066. MEC2_byanimal <- mutate(MEC2_byanimal, Avg = rowMeans(dplyr::select(MEC2_byanimal,'1','2','3','4','5','6'), na.rm =TRUE))
  3067. MEC3_Counts <- mutate(MEC3_Counts, Slice= as.factor(Slice))
  3068. MEC3_byanimal <- MEC3_Counts %>%
  3069. dplyr::select(Mouse, Genotype, Groupname, Sex, Age_Broad, Age, Wave, Cage, Slice, CellsPerSqmm)
  3070. MEC3_byanimal<- dcast(MEC3_byanimal, Mouse + Genotype + Groupname + Sex + Age_Broad + Age + Wave + Cage ~ Slice, na.rm=TRUE)
  3071. MEC3_byanimal <- mutate(MEC3_byanimal, Avg = rowMeans(dplyr::select(MEC3_byanimal,'1','2','3','4','5','6'), na.rm =TRUE))
  3072. MEC2_byanimal$Groupname= factor(MEC2_byanimal$Groupname, levels = c('6wt', '8wt', '63x', '83x'))
  3073. MEC3_byanimal$Groupname= factor(MEC3_byanimal$Groupname, levels = c('6wt', '8wt', '63x', '83x'))
  3074. NeuN1 <- CellCountsbygroup_adjaxis(MEC2_byanimal, Avg, "NeuN+ Counts MEC2", expression(bold("Cells per" ~mm^2)), ymin= -0.25, ymax = 800)
  3075. NeuN1
  3076. print("NeuN MEC2 age x genotype anova")
  3077. General_AOVbyanim_ez(MEC2_byanimal, Avg, Age_Broad, Mouse)
  3078. General_byanim_holm(MEC2_byanimal, Avg, Age_Broad)
  3079. NeuN2 <- CellCountsbygroup_adjaxis(MEC3_byanimal, Avg, "NeuN+ Counts MEC3", expression(bold("Cells per" ~mm^2)), ymin= -0.25, ymax = 800)
  3080. NeuN2
  3081. print("NeuN MEC3 age x genotype anova")
  3082. General_AOVbyanim_ez(MEC3_byanimal, Avg, Age_Broad, Mouse)
  3083. General_byanim_holm(MEC3_byanimal, Avg, Age_Broad)
  3084. #Sex diffs
  3085. MEC3_byanimal_6mo <- subset(MEC3_byanimal, Age_Broad == '6')
  3086. MEC3_byanimal_8mo <- subset(MEC3_byanimal, Age_Broad == '8')
  3087. MEC2_byanimal_6mo <- subset(MEC2_byanimal, Age_Broad == '6')
  3088. MEC2_byanimal_8mo <- subset(MEC2_byanimal, Age_Broad == '8')
  3089. print("NeuN MEC2 6 mo Genotype x Sex ANOVA")
  3090. General_AOVbyanim_ez(MEC2_byanimal_6mo, Avg, Sex, Mouse)
  3091. print("NeuN MEC3 6 mo Genotype x Sex ANOVA")
  3092. General_AOVbyanim_ez(MEC3_byanimal_6mo, Avg, Sex, Mouse)
  3093. print("NeuN MEC2 8 mo Genotype x Sex ANOVA")
  3094. General_AOVbyanim_ez(MEC2_byanimal_8mo, Avg, Sex, Mouse)
  3095. print("NeuN MEC3 8 mo Genotype x Sex ANOVA")
  3096. General_AOVbyanim_ez(MEC3_byanimal_8mo, Avg, Sex, Mouse)
  3097. #Sample Sizes and Mean Ages
  3098. ###MEC2
  3099. print("Ns NeuN MEC2")
  3100. print("WT 6mo (M, F)")
  3101. sum(MEC2_byanimal_6mo$Genotype == "WT" & MEC2_byanimal_6mo$Age_Broad == '6')
  3102. sum(MEC2_byanimal_6mo$Genotype == "WT" & MEC2_byanimal_6mo$Age_Broad == '6' & MEC2_byanimal_6mo$Sex == 'M')
  3103. sum(MEC2_byanimal_6mo$Genotype == "WT" & MEC2_byanimal_6mo$Age_Broad == '6' & MEC2_byanimal_6mo$Sex == 'F')
  3104. print("WT 8mo (M, F)")
  3105. sum(MEC2_byanimal_8mo$Genotype == "WT" & MEC2_byanimal_8mo$Age_Broad == '8')
  3106. sum(MEC2_byanimal_8mo$Genotype == "WT" & MEC2_byanimal_8mo$Age_Broad == '8' & MEC2_byanimal_8mo$Sex == 'M')
  3107. sum(MEC2_byanimal_8mo$Genotype == "WT" & MEC2_byanimal_8mo$Age_Broad == '8' & MEC2_byanimal_8mo$Sex == 'F')
  3108. print("3xTg 6mo (M, F)")
  3109. sum(MEC2_byanimal_6mo$Genotype == "3xTg" & MEC2_byanimal_6mo$Age_Broad == '6')
  3110. sum(MEC2_byanimal_6mo$Genotype == "3xTg" & MEC2_byanimal_6mo$Age_Broad == '6' & MEC2_byanimal_6mo$Sex == 'M')
  3111. sum(MEC2_byanimal_6mo$Genotype == "3xTg" & MEC2_byanimal_6mo$Age_Broad == '6' & MEC2_byanimal_6mo$Sex == 'F')
  3112. print("3xTg 8mo (M, F)")
  3113. sum(MEC2_byanimal_8mo$Genotype == "3xTg" & MEC2_byanimal_8mo$Age_Broad == '8')
  3114. sum(MEC2_byanimal_8mo$Genotype == "3xTg" & MEC2_byanimal_8mo$Age_Broad == '8' & MEC2_byanimal_8mo$Sex == 'M')
  3115. sum(MEC2_byanimal_8mo$Genotype == "3xTg" & MEC2_byanimal_8mo$Age_Broad == '8' & MEC2_byanimal_8mo$Sex == 'F')
  3116. print("Age MEC2 6 mo")
  3117. MEC2_byanimal_6mo %>%
  3118. dplyr::group_by(Groupname) %>%
  3119. dplyr::summarise(mean = mean(Age),
  3120. sem = plotrix::std.error(Age),
  3121. min = min(Age),
  3122. max = max(Age))
  3123. print("Age MEC2 8 mo")
  3124. MEC2_byanimal_8mo %>%
  3125. dplyr::group_by(Groupname) %>%
  3126. dplyr::summarise(mean = mean(Age),
  3127. sem = plotrix::std.error(Age),
  3128. min = min(Age),
  3129. max = max(Age))
  3130. ###MEC3
  3131. print("Ns NeuN MEC3")
  3132. print("WT 6mo (M, F)")
  3133. sum(MEC3_byanimal_6mo$Genotype == "WT" & MEC3_byanimal_6mo$Age_Broad == '6')
  3134. sum(MEC3_byanimal_6mo$Genotype == "WT" & MEC3_byanimal_6mo$Age_Broad == '6' & MEC3_byanimal_6mo$Sex == 'M')
  3135. sum(MEC3_byanimal_6mo$Genotype == "WT" & MEC3_byanimal_6mo$Age_Broad == '6' & MEC3_byanimal_6mo$Sex == 'F')
  3136. print("WT 8mo (M, F)")
  3137. sum(MEC3_byanimal_8mo$Genotype == "WT" & MEC3_byanimal_8mo$Age_Broad == '8')
  3138. sum(MEC3_byanimal_8mo$Genotype == "WT" & MEC3_byanimal_8mo$Age_Broad == '8' & MEC3_byanimal_8mo$Sex == 'M')
  3139. sum(MEC3_byanimal_8mo$Genotype == "WT" & MEC3_byanimal_8mo$Age_Broad == '8' & MEC3_byanimal_8mo$Sex == 'F')
  3140. print("3xTg 6mo (M, F)")
  3141. sum(MEC3_byanimal_6mo$Genotype == "3xTg" & MEC3_byanimal_6mo$Age_Broad == '6')
  3142. sum(MEC3_byanimal_6mo$Genotype == "3xTg" & MEC3_byanimal_6mo$Age_Broad == '6' & MEC3_byanimal_6mo$Sex == 'M')
  3143. sum(MEC3_byanimal_6mo$Genotype == "3xTg" & MEC3_byanimal_6mo$Age_Broad == '6' & MEC3_byanimal_6mo$Sex == 'F')
  3144. print("3xTg 8mo (M, F)")
  3145. sum(MEC3_byanimal_8mo$Genotype == "3xTg" & MEC3_byanimal_8mo$Age_Broad == '8')
  3146. sum(MEC3_byanimal_8mo$Genotype == "3xTg" & MEC3_byanimal_8mo$Age_Broad == '8' & MEC3_byanimal_8mo$Sex == 'M')
  3147. sum(MEC3_byanimal_8mo$Genotype == "3xTg" & MEC3_byanimal_8mo$Age_Broad == '8' & MEC3_byanimal_8mo$Sex == 'F')
  3148. print("Age MEC3 6 mo")
  3149. MEC3_byanimal_6mo %>%
  3150. dplyr::group_by(Groupname) %>%
  3151. dplyr::summarise(mean = mean(Age),
  3152. sem = plotrix::std.error(Age),
  3153. min = min(Age),
  3154. max = max(Age))
  3155. print("Age MEC3 8 mo")
  3156. MEC3_byanimal_8mo %>%
  3157. dplyr::group_by(Groupname) %>%
  3158. dplyr::summarise(mean = mean(Age),
  3159. sem = plotrix::std.error(Age),
  3160. min = min(Age),
  3161. max = max(Age))
  3162. plot_list = list(PV1, PV2, PV3, PV4, PV5)
  3163. ID = 1
  3164. for (p in plot_list) {
  3165. ggsave(
  3166. p,
  3167. filename=paste("PVcounts",ID,".svg",sep=""),
  3168. width = 5,
  3169. height = 5,
  3170. dpi = 600)
  3171. ID = ID + 1
  3172. }
  3173. plot_list = list(NeuN1, NeuN2)
  3174. ID = 1
  3175. for (p in plot_list) {
  3176. ggsave(
  3177. p,
  3178. filename=paste("NeuNcounts",ID,".svg",sep=""),
  3179. width = 5,
  3180. height = 5,
  3181. dpi = 600)
  3182. ID = ID + 1
  3183. }
  3184. ```

Vetere_2026_AllPlotsAndStats.Rmd at commit 66e5072, under GPL-3.0 · at the source

Overview

Authors: Lauren M. Vetere1, Angelina M. Galas1, Nick Vaughan1, Cassidy Kohler1, Yu Feng1, Zoé Christenson Wick1, Paul A. Philipsberg1, Olga Liobimova1, Kathryn E. Gordon1, Antonio Fernandez-Ruiz2, Denise J. Cai1, Tristan Shuman1,3
ORCID iDs: Tristan Shuman
  1. Icahn School of Medicine at Mount Sinai, New York, NY, USA
  2. Cornell University, Ithaca, NY, USA
  3. Lead contact
Institutions: Icahn School of Medicine at Mount Sinai (United States); Cornell University (United States)
Journal: Cell reports, volume 45, issue 7, article 117646
Dates: published online 13 July 2026; in print 28 July 2026
Type: Research article · Language: English
License: CC BY-NC-ND
Identifiers: DOI 10.1016/j.celrep.2026.117646 · PMID 42441402 · PMCID PMC13502474 · OpenAlex W4406546687
Open access: gold, a free copy (OpenAlex)
Status: code verified
Categories: mouse (organism), Alzheimer's / dementia (population), systems (subfield)
Keywords: Hippocampus, Electrophysiology, Learning and memory, Alzheimer's disease, Entorhinal Cortex, Phase-locking, Theta Oscillations, Cp: Neuroscience, Circuit Desynchronization
MeSH: Alzheimer Disease*, Entorhinal Cortex*, Hippocampus*, Memory Disorders*, Animals, Disease Models, Animal, Male, Mice, Mice, Transgenic, Neurons, Theta Rhythm (* major topic)
Topic: Memory and Neural Mechanisms (Cognitive Neuroscience, Neuroscience), according to OpenAlex
Funding: NINDS NIH HHS (R01 NS136590, F32 NS116416, R03 NS111493, F31 NS134301, R01 NS116357); NIA NIH HHS (RF1 AG072497, T32 AG049688, R01 AG072497, F31 AG069496); National Institute of Neurological Disorders and Stroke; NIMH NIH HHS (DP2 MH122399, R01 MH120162, R56 MH132959); National Institute of Mental Health; Simons Foundation; National Institute on Aging; American Epilepsy Society
Citations: not cited yet (Europe PMC); 161 references in the paper
Research resources: Rabbit anti-NeuN RRID:AB_10807945, Alexa Goat Anti-Rabbit 488 RRID:AB_143165, Rabbit anti-Amyloid-Beta RRID:AB_2056585, Rabbit anti-PV RRID:AB_2173898, Alexa Goat Anti-Rabbit 555 RRID:AB_2535850

Abstract

The abstract is not reproduced here: the paper's license (CC BY-NC-ND) does not allow it. Read it in the paper, at the publisher or on Europe PMC.

Repositories

Its files are read in the Code ↔ Paper reader above, with 14 matches between paragraphs and lines of code.

ZachPenn/CellCounting

License: none: the authors keep all their rights
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Commit: 6de8105d8945c2e88cb6cfdfc10c1198e7235b1e, 23 August 2026
Languages: Jupyter (4), Python (1)
Size: 7 files, 5 scripts
Software Heritage: not archived
Found in: the text, “Immunohistochemistry”
Holds: README, 4 notebooks
Not found: license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: Matplotlib (3 files), NumPy (3 files), OpenCV (3 files), pandas (3 files), scikit-image (1 file), SciPy (1 file)
Availability: 1 check, the latest on 27 September 2026: the link answers
  • 27 September 2026: the link answers
6 files

buzsakilab/buzcode

License: GPL-3.0
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Commit: 0969ddf7f55ccaca8c71969bee4b21f310840047, 27 August 2026
Languages: MATLAB (1980), C (29), C/C++ (15), Jupyter (5), C++ (1)
Size: 3,062 files, 2,030 scripts
Software Heritage: archived
Found in: the text, “Analysis of local field potential and single-uni”
Holds: README, license file, tests, documentation, 4 notebooks
Not found: CITATION.cff, environment file, continuous integration
Tools: EEGLAB (172 files), Statistics and Machine Learning Toolbox (97 files), Chronux (74 files), Signal Processing Toolbox (64 files), CircStat (41 files), Image Processing Toolbox (12 files), FieldTrip (9 files), Matplotlib (5 files), NumPy (5 files), Optimization Toolbox (4 files), Parallel Computing Toolbox (4 files), Neurodata Without Borders (PyNWB, MatNWB) (3 files), SciPy (3 files), boundedline (2 files), scikit-image (2 files), export_fig (1 file), Curve Fitting Toolbox (1 file)
Availability: 1 check, the latest on 27 September 2026: the link answers
  • 27 September 2026: the link answers
2,000 files

Zenodo 20314327

License: GPL-3.0
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Size: 1 file
Software Heritage: not checked
Found in: “Data and code availability”
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: CircStat (32 files), Statistics and Machine Learning Toolbox (17 files), Signal Processing Toolbox (12 files), Chronux (5 files), broom (1 file), car (1 file), data.table (1 file), emmeans (1 file), lme4 (1 file), lmerTest (1 file), multcomp (1 file), reshape2 (1 file), rstatix (1 file), tidyverse (1 file)
Availability: 1 check, the latest on 27 September 2026: the link answers (HTTP 200)
  • 27 September 2026: the link answers (HTTP 200)
107 files

shumanlab/vetere-et-al-2026-cell-reports

License: GPL-3.0
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Commit: 66e5072810e0f0e6f73db6d65309d1ae083ddd0c, 19 May 2026
Languages: MATLAB (104), R (1)
Size: 165 files, 105 scripts
Software Heritage: not archived
Found in: the Zenodo archive record
Holds: README, license file, 1 notebook
Not found: CITATION.cff, environment file, tests, continuous integration, documentation
Tools: CircStat (32 files), Statistics and Machine Learning Toolbox (17 files), Signal Processing Toolbox (12 files), Chronux (5 files), broom (1 file), car (1 file), data.table (1 file), emmeans (1 file), lme4 (1 file), lmerTest (1 file), multcomp (1 file), reshape2 (1 file), rstatix (1 file), tidyverse (1 file)
Availability: 1 check, the latest on 27 September 2026: the link answers
  • 27 September 2026: the link answers
107 files

The paper's code and data availability statement is in the Data section.

Tracing map

Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.

What the map holds:

  • 4 repositories of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
  • 2,213 scripts, each with its path and the digest of its content;
  • 14 matches between paragraphs of the paper and lines of the code (method lexical-v1);
  • neither the text of the paper nor the code itself.

Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.

Data

No dataset and no data link were found in the paper.

Code and data availability statement

The paper has a code and data availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:

  • it points to the authors' code: Zenodo 20314327
  • it says that the data are available on request
  • it says that the code is available on request

Read it in the paper: doi.org/10.1016/j.celrep.2026.117646.

Versions

The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.

Version 2, 28 September 2026

  • Publisher: n/a → Cell Press
  • Authors: added Tristan Shuman (0000-0003-2310-6142); removed Tristan Shuman

Version 1, 27 September 2026: the first record

Recorded: type, language, journal, volume, issue, pages, dates, 12 authors, 9 keywords, 11 MeSH terms, 8 funders, 161 references, 5 RRIDs.

Cite

This paper

Vetere, L. M., Galas, A. M., Vaughan, N., Kohler, C., Feng, Y., Wick, Z. C., Philipsberg, P. A., Liobimova, O., Gordon, K. E., Fernandez-Ruiz, A., Cai, D. J., & Shuman, T. (2026). Medial entorhinal-hippocampal desynchronization parallels the emergence of memory impairment in a mouse model of Alzheimer's disease pathology. Cell reports, 45(7), 117646. https://doi.org/10.1016/j.celrep.2026.117646

BibTeX

@article{vetere2026medial,
author = {Vetere, Lauren M. and Galas, Angelina M. and Vaughan, Nick and Kohler, Cassidy and Feng, Yu and Wick, Zoé Christenson and Philipsberg, Paul A. and Liobimova, Olga and Gordon, Kathryn E. and Fernandez-Ruiz, Antonio and Cai, Denise J. and Shuman, Tristan},
title = {{Medial entorhinal-hippocampal desynchronization parallels the emergence of memory impairment in a mouse model of Alzheimer's disease pathology}},
journal = {Cell reports},
year = {2026},
month = jul,
volume = {45},
number = {7},
pages = {117646},
publisher = {Cell Press},
issn = {2211-1247},
doi = {10.1016/j.celrep.2026.117646},
url = {https://doi.org/10.1016/j.celrep.2026.117646},
pmid = {42441402},
pmcid = {PMC13502474}
}

RIS

TY - JOUR
AU - Vetere, Lauren M.
AU - Galas, Angelina M.
AU - Vaughan, Nick
AU - Kohler, Cassidy
AU - Feng, Yu
AU - Wick, Zoé Christenson
AU - Philipsberg, Paul A.
AU - Liobimova, Olga
AU - Gordon, Kathryn E.
AU - Fernandez-Ruiz, Antonio
AU - Cai, Denise J.
AU - Shuman, Tristan
TI - Medial entorhinal-hippocampal desynchronization parallels the emergence of memory impairment in a mouse model of Alzheimer's disease pathology
T2 - Cell reports
J2 - Cell Rep
PY - 2026
DA - 2026/07/13
VL - 45
IS - 7
SP - 117646
SN - 2211-1247
PB - Cell Press
DO - 10.1016/j.celrep.2026.117646
UR - https://doi.org/10.1016/j.celrep.2026.117646
LA - en
ER -

CSL-JSON

{
"id": "10.1016/j.celrep.2026.117646",
"type": "article-journal",
"title": "Medial entorhinal-hippocampal desynchronization parallels the emergence of memory impairment in a mouse model of Alzheimer's disease pathology",
"container-title": "Cell reports",
"author": [
{
"family": "Vetere",
"given": "Lauren M."
},
{
"family": "Galas",
"given": "Angelina M."
},
{
"family": "Vaughan",
"given": "Nick"
},
{
"family": "Kohler",
"given": "Cassidy"
},
{
"family": "Feng",
"given": "Yu"
},
{
"family": "Wick",
"given": "Zoé Christenson"
},
{
"family": "Philipsberg",
"given": "Paul A."
},
{
"family": "Liobimova",
"given": "Olga"
},
{
"family": "Gordon",
"given": "Kathryn E."
},
{
"family": "Fernandez-Ruiz",
"given": "Antonio"
},
{
"family": "Cai",
"given": "Denise J."
},
{
"family": "Shuman",
"given": "Tristan"
}
],
"container-title-short": "Cell Rep",
"volume": "45",
"issue": "7",
"page": "117646",
"DOI": "10.1016/j.celrep.2026.117646",
"PMID": "42441402",
"PMCID": "PMC13502474",
"ISSN": "2211-1247",
"publisher": "Cell Press",
"URL": "https://doi.org/10.1016/j.celrep.2026.117646",
"language": "en",
"issued": {
"date-parts": [
[
2026,
7,
13
]
]
}
}

The tracing map gets a citation of its own once an author has validated it and it has a DOI.

Similar papers

The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.

[1] doi:10.1016/j.celrep.2026.117505 [code]
Impaired spatial coding and neuronal hyperactivity in the medial entorhinal cortex of aged APP knock-in mice.
Journal: Cell reports
In common: car, broom, emmeans, 7 other tools, Alzheimer's / dementia, mouse, 19 references
[2] doi:10.1038/s41467-026-73106-z [code]
Respiratory pauses highlight sleep architecture in mice.
Journal: Nature communications
In common: Chronux, Neurodata Without Borders (PyNWB, MatNWB), export_fig, 14 other tools, mouse, 2 references
[3] doi:10.1038/s41467-026-75347-4 [code]
Sleep reveals dynamics integrating and segregating movement and stimulus representations in V1.
Journal: Nature communications
In common: Chronux, Neurodata Without Borders (PyNWB, MatNWB), export_fig, 15 other tools, systems, mouse, 1 reference
[4] doi:10.1038/s41593-026-02357-2 [code]
Experience reorganizes content-specific memory traces in macaques.
Journal: Nature neuroscience
In common: Chronux, export_fig, boundedline, 14 other tools, 3 references
[5] doi:10.1016/j.neuron.2026.03.034 [code]
Dentate gyrus interneurons modulate winner-take-all network dynamics in freely behaving mice.
Journal: Neuron
In common: Chronux, boundedline, CircStat, 11 other tools, systems, mouse, 4 references
[6] doi:10.1523/jneurosci.2001-25.2026 [code]
Dynamics of Dentate Gyrus Place Cells and Dentate Spikes during Spatial and Nonspatial Changes in Environments.
Journal: The Journal of neuroscience : the official journal of the Society for Neuroscience
In common: Chronux, export_fig, CircStat, 10 other tools, systems, 4 references
[7] doi:10.1038/s41593-026-02232-0 [code]
Entorhinal cortex represents task-relevant remote locations independently of CA1.
Journal: Nature neuroscience
In common: Neurodata Without Borders (PyNWB, MatNWB), CircStat, Optimization Toolbox, 9 other tools, systems, mouse, 5 references
[8] doi:10.7554/elife.100642 [code]
Disrupted hippocampal theta-gamma coupling and spike-field coherence following experimental traumatic brain injury.
Journal: eLife
In common: CircStat, Curve Fitting Toolbox, Parallel Computing Toolbox, 2 other tools, systems, 7 references
[9] doi:10.1162/imag.a.105 [code]
Right posterior theta reflects human parahippocampal phase resetting by salient cues during goal-directed navigation
Journal: n/a
In common: CircStat, car, EEGLAB, 9 other tools, 2 references
[10] doi:10.1126/sciadv.aea1037 [code]
Distinct cortical spatial representations learned along disparate visual pathways.
Journal: Science advances
In common: Chronux, CircStat, Curve Fitting Toolbox, 7 other tools, systems, 3 references

Contribute

The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.

Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.

Request its removal

To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).

Discussion, reproductions, activity

Discussion: questions and error reports about this paper and its code, from signed-in readers and its authors. It opens with sign-in.

Reproductions: reports from readers who ran the authors' code: what they reproduced, with which environment, commit and data. It opens with sign-in.

Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.