Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

figure_5_S2.Rmd 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. ---
  2. title: "Spacek et al., 2021, Figure 5-Supplement 2"
  3. output: pdf_document
  4. ---
  5. ```{r setup, include=FALSE}
  6. knitr::opts_chunk$set(echo = TRUE)
  7. library(arm)
  8. library(lmerTest)
  9. library(tidyverse)
  10. source('get_data.R')
  11. ```
  12. ```{r read_data, include=FALSE}
  13. # Read data
  14. tib = get_data("../csv/fig5S2.csv")
  15. ```
  16. ```{r tidy, include = FALSE}
  17. # Extract data for control condition
  18. tb_control <- tib %>% filter(opto == FALSE)
  19. # Extract data with suppression
  20. tb_supp <- tib %>% filter(opto == TRUE)
  21. ```
  22. # Figure 5-Supplement 2d
  23. ## Reliability - V1 control
  24. ```{r, tidy_for_5_S2d, include=FALSE}
  25. tb2d = tb_control %>% select(mid, sid, eid, uid, mseu, tqrel, bqrel)
  26. # Turn into long format, and create binary predictor for top vs bottom quartile
  27. tb2d = tb2d %>% pivot_longer(cols = c(tqrel, bqrel), names_to = "quartiles", values_to = "rel")
  28. tb2d = tb2d %>% mutate(bottom_quartile = ifelse(quartiles == "bqrel", 1, 0))
  29. ```
  30. ```{r fit_model_5_S2d}
  31. # Random intercept for single neurons,
  32. # random intercept for experiments, nested within series
  33. lmer.5_S2d = lmer(rel ~ bottom_quartile + (1 | uid) + (1 | sid/eid),
  34. data = tb2d %>% drop_na(rel))
  35. display(lmer.5_S2d)
  36. anova(lmer.5_S2d)
  37. ```
  38. ```{r get_predicted_average_effect_5_S2d, include=F}
  39. mTop = fixef(lmer.5_S2d)[1]
  40. diffMeans = fixef(lmer.5_S2d)[2]
  41. mBottom = fixef(lmer.5_S2d)[1] + diffMeans
  42. ```
  43. Top quartile: reliability of `r format(mTop, digits=2, nsmall=2)` \newline
  44. Bottom quartile: reliability of `r format(mBottom, digits=2, nsmall=2)` \newline
  45. n = `r nrow(tb2d %>% drop_na(rel) %>% count(uid))` neurons from `r nrow(tb2d %>% drop_na(rel) %>% count(mid))` mice
  46. \newpage
  47. # Figure 5-Supplement 2e
  48. ## Signal-to-noise ratio - V1 control
  49. ```{r, tidy_for_5_S2e, include=FALSE}
  50. tb2e = tb_control %>% select(mid, sid, eid, uid, mseu, tqsnr, bqsnr)
  51. # Turn into long format, and create binary predictor for top vs bottom quartile
  52. tb2e = tb2e %>% pivot_longer(cols = c(tqsnr, bqsnr), names_to = "quartiles", values_to = "snr")
  53. tb2e = tb2e %>% mutate(bottom_quartile = ifelse(quartiles == "bqsnr", 1, 0))
  54. ```
  55. ```{r fit_model_5_S2e}
  56. # Random intercept for single neurons,
  57. # random intercept for experiments
  58. lmer.5_S2e = lmer(snr ~ bottom_quartile + (1 | uid) + (1 | eid),
  59. data = tb2e %>% drop_na(snr))
  60. display(lmer.5_S2e)
  61. anova(lmer.5_S2e)
  62. ```
  63. ```{r get_predicted_average_effect_5_S2e, include=F}
  64. mTop = fixef(lmer.5_S2e)[1]
  65. diffMeans = fixef(lmer.5_S2e)[2]
  66. mBottom = fixef(lmer.5_S2e)[1] + diffMeans
  67. ```
  68. Top quartile: SNR of `r format(mTop, digits=2, nsmall=2)` \newline
  69. Bottom quartile: SNR of `r format(mBottom, digits=2, nsmall=2)` \newline
  70. n = `r nrow(tb2e %>% drop_na(snr) %>% count(uid))` neurons from `r nrow(tb2e %>% drop_na(snr) %>% count(mid))` mice
  71. \newpage
  72. # Figure 5-Supplement 2f
  73. ## Reliability - V1 suppressed
  74. ```{r, tidy_for_5_S2f, include=FALSE}
  75. tb2f = tb_supp %>% select(mid, sid, eid, uid, mseu, tqrel, bqrel)
  76. # Turn into long format, and create binary predictor for top vs bottom quartile
  77. tb2f = tb2f %>% pivot_longer(cols = c(tqrel, bqrel), names_to = "quartiles", values_to = "rel")
  78. tb2f = tb2f %>% mutate(bottom_quartile = ifelse(quartiles == "bqrel", 1, 0))
  79. ```
  80. ```{r fit_model_5_S2f}
  81. # Random intercept for single neurons,
  82. # random intercept for experiments, nested within series
  83. lmer.5_S2f = lmer(rel ~ bottom_quartile + (1 | uid) + (1 | sid/eid),
  84. data = tb2f %>% drop_na(rel))
  85. display(lmer.5_S2f)
  86. anova(lmer.5_S2f)
  87. ```
  88. ```{r get_predicted_average_effect_5_S2f, include=F}
  89. mTop = fixef(lmer.5_S2f)[1]
  90. diffMeans = fixef(lmer.5_S2f)[2]
  91. mBottom = fixef(lmer.5_S2f)[1] + diffMeans
  92. ```
  93. Top quartile: reliability of `r format(mTop, digits=2, nsmall=2)` \newline
  94. Bottom quartile: reliability of `r format(mBottom, digits=2, nsmall=2)` \newline
  95. n = `r nrow(tb2f %>% drop_na(rel) %>% count(uid))` neurons from `r nrow(tb2f %>% drop_na(rel) %>% count(mid))` mice
  96. \newpage
  97. # Figure 5-Supplement 2g
  98. ## Signal-to-noise ratio - V1 suppressed
  99. ```{r, tidy_for_5_S2g, include=FALSE}
  100. tb2g = tb_supp %>% select(mid, sid, eid, uid, mseu, tqsnr, bqsnr)
  101. # Turn into long format, and create binary predictor for top vs bottom quartile
  102. tb2g = tb2g %>% pivot_longer(cols = c(tqsnr, bqsnr), names_to = "quartiles", values_to = "snr")
  103. tb2g = tb2g %>% mutate(bottom_quartile = ifelse(quartiles == "bqsnr", 1, 0))
  104. ```
  105. ```{r fit_model_5_S2g}
  106. # Random intercept for single neurons,
  107. # random intercept for experiments, nested within series
  108. lmer.5_S2g = lmer(snr ~ bottom_quartile + (1 | uid) + (1 | sid/eid),
  109. data = tb2g %>% drop_na(snr))
  110. display(lmer.5_S2g)
  111. anova(lmer.5_S2g)
  112. ```
  113. ```{r get_predicted_average_effect_5_S2g, include=F}
  114. mTop = fixef(lmer.5_S2g)[1]
  115. diffMeans = fixef(lmer.5_S2g)[2]
  116. mBottom = fixef(lmer.5_S2g)[1] + diffMeans
  117. ```
  118. Top quartile: SNR of `r format(mTop, digits=2, nsmall=2)` \newline
  119. Bottom quartile: SNR of `r format(mBottom, digits=2, nsmall=2)` \newline
  120. n = `r nrow(tb2g %>% drop_na(snr) %>% count(uid))` neurons from `r nrow(tb2g %>% drop_na(snr) %>% count(mid))` mice