OSCR

Intrathecal (G<sub>4</sub>C<sub>2</sub>)<sub>149</sub> delivery in C9orf72-deficient mice yields mild motor dysfunction and ALS/FTD pathological hallmarks.

Code ↔ Paper

2 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 2 matches
  1. [1] § Results › Mild hyperactivity observed in the open field; anxiety remains unchanged ↔ KAR_Acta_Neuro_Comm_v1.13.Rmd, lines 135–180 · score 0.70 · perimeter zone, center zone, open field, episodes, immobile, speed
  2. [2] § Results › Gait analysis identifies subtle signatures of motor dysfunction ↔ KAR_Acta_Neuro_Comm_v1.13.Rmd, lines 135–180 · score 0.61 · Paw Drag, body mass, Propel, Swing, Stance, Stride

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 · 1,195 lines · 40 KB · CC-BY-4.0 · 2 matches

  1. ---
  2. title: "20260620_Plotting_variables_and_groups_v1.12"
  3. author: "Aaron Haeusler"
  4. date: "`r Sys.Date()`"
  5. output: html_document
  6. ---
  7. ```{r setup, include=FALSE}
  8. if (!require("pacman")) install.packages("pacman")
  9. pacman::p_load(
  10. readr,
  11. dplyr,
  12. ggplot2,
  13. forcats,
  14. ggnewscale,
  15. RColorBrewer,
  16. reshape2,
  17. scales
  18. )
  19. wd <- getwd()
  20. data <- read_csv("Combined_Intrathecal_Data.csv")
  21. # Fix column names for merging (remove any stray spaces)
  22. colnames(data) <- gsub(" ", "_", colnames(data))
  23. # Ensure numeric and merge expression columns
  24. data <- data %>%
  25. mutate(
  26. across(c(Expression_12m, Expression_9m, Expression_6m), as.numeric),
  27. Expression_Merged = coalesce(Expression_12m, Expression_9m, Expression_6m, 0),
  28. Expression_Merged = ifelse(Treatment %in% c("None", "Control"), 0, Expression_Merged)
  29. )
  30. # Calculate quartiles (excluding zero)
  31. qtiles <- quantile(data$Expression_Merged[data$Expression_Merged > 0], probs = seq(0, 1, 0.25), na.rm = TRUE)
  32. data <- data %>%
  33. mutate(
  34. Expression_Quartile = case_when(
  35. is.na(Expression_Merged) | Expression_Merged == 0 ~ "0",
  36. Expression_Merged > 0 & Expression_Merged <= qtiles[2] ~ "Q1",
  37. Expression_Merged > qtiles[2] & Expression_Merged <= qtiles[3] ~ "Q2",
  38. Expression_Merged > qtiles[3] & Expression_Merged <= qtiles[4] ~ "Q3",
  39. Expression_Merged > qtiles[4] ~ "Q4"
  40. ),
  41. Expression_Quartile = factor(Expression_Quartile, levels = c("0", "Q1", "Q2", "Q3", "Q4"), ordered = TRUE)
  42. )
  43. # Set up your grayscale palette
  44. grayscale_pal <- c(
  45. "0" = "#FFFFFF", # white
  46. "Q1" = "#CECECE", # very light gray
  47. "Q2" = "#ABABAB", # light gray
  48. "Q3" = "#7D7D7D", # medium gray
  49. "Q4" = "#222222" # near black
  50. )
  51. # Set factors for better color/shape control
  52. data <- data %>%
  53. mutate(
  54. Genotype = factor(Genotype, levels = c("WT", "Het", "Homo")),
  55. Treatment = factor(Treatment, levels = c("Control", "Repeats", "None")),
  56. Sex = factor(Sex, levels = c("Female", "Male")),
  57. Condition = as.factor(Condition)
  58. )
  59. data <- data %>%
  60. mutate(
  61. distribution = case_when(
  62. Unit == "LBF" ~ "gaussian",
  63. Unit == "cm" ~ "gaussian",
  64. Unit == "coefficient" ~ "gaussian",
  65. Unit == "degrees" ~ "gaussian",
  66. Unit == "metric" ~ "gaussian",
  67. Unit == "percentage" ~ "gaussian",
  68. Unit == "cm_squared" ~ "Gamma",
  69. Unit == "cm_squared_per_sec" ~ "Gamma",
  70. Unit == "meters" ~ "Gamma",
  71. Unit == "meters_per_second" ~ "Gamma",
  72. Unit == "steps_per_sec" ~ "Gamma",
  73. Unit == "seconds" ~ "Gamma",
  74. Unit == "ratio" ~ "Gamma",
  75. Unit == "total_degrees" ~ "Gamma",
  76. Unit == "count" ~ "poisson",
  77. Unit == "mV" ~ "gaussian",
  78. Unit == "mV*ms" ~ "Gamma",
  79. Unit == "ms" ~ "gaussian",
  80. Unit == "mm" ~ "gaussian",
  81. StatsVariable == "All latency variables" ~ "Gamma",
  82. all(Value == floor(Value), na.rm = TRUE) ~ "poisson",
  83. TRUE ~ "gaussian"
  84. )
  85. )
  86. library(dplyr)
  87. # 1. Split Digigait from all other experiments
  88. digigait <- data %>% filter(Exp == "Digigait")
  89. data_other <- data %>% filter(Exp != "Digigait")
  90. # 2. Aggregate Digigait Left/Right by Fore/Hind, rename Side as Both
  91. digigait_agg <- digigait %>%
  92. filter(Side %in% c("Left", "Right"), Limb %in% c("Fore", "Hind")) %>%
  93. group_by(across(-c(Value, Stdev, SEM, Side, Condition))) %>%
  94. summarise(
  95. Value = mean(Value, na.rm = TRUE),
  96. Stdev = sd(Value, na.rm = TRUE),
  97. SEM = sd(Value, na.rm = TRUE) / sqrt(sum(!is.na(Value))),
  98. .groups = "drop"
  99. ) %>%
  100. mutate(Side = "Both",
  101. Condition = Limb
  102. )
  103. # 3. Remove original Left/Right Fore/Hind Digigait rows
  104. digigait_rest <- digigait %>%
  105. filter(!(Side %in% c("Left", "Right") & Limb %in% c("Fore", "Hind")))
  106. # 4. Combine everything back together
  107. data_combined <- bind_rows(data_other, digigait_rest, digigait_agg)
  108. # 5. (optional) Arrange for easy viewing
  109. data <- data_combined %>%
  110. arrange(Ear_Tag, Time_month, Exp, Limb, Side)
  111. # Now data_combined is your updated dataset
  112. df <- data
  113. write_csv(data, "combined_intrathecal_data_ave_digigait.csv")
  114. ```
  115. ``` {r publication_boxplots, include=FALSE}
  116. library(dplyr)
  117. library(ggplot2)
  118. library(ggnewscale)
  119. library(purrr)
  120. library(RColorBrewer)
  121. library(scales)
  122. library(tibble)
  123. df <- data # Replace with your actual data object name
  124. # ---- Subset Table ----
  125. subset_table <- tribble(
  126. ~Exp, ~Time_month, ~Condition, ~StatsVariable,
  127. "Grip", 12, NA, "Grip_Strength",
  128. "CMAP", 12, "Ankle", "Amplitude",
  129. "CMAP", 12, "Hip", "Area_Under_Curve",
  130. "OpenField", 10, NA, "Total_distance_travelled",
  131. "OpenField", 10, NA, "Average_speed",
  132. "OpenField", 10, NA, "Total_time_mobile",
  133. "OpenField", 10, NA, "Total_immobile episodes",
  134. "OpenField", 10, NA, "Average_speed_in_the_Perimeter_zone",
  135. "OpenField", 10, NA, "Time_in_the_Center_zone",
  136. "OpenField", 10, NA, "Distance_travelled_in_the_Perimeter_zone",
  137. "Rotarod", 12, NA, "Latency_to_Fall",
  138. "Body_mass", 12, NA, "Weight_grams",
  139. "Digigait", 12, "Hind", "Stride",
  140. "Digigait", 12, "Hind", "Swing",
  141. "Digigait", 12, "Hind", "Stance",
  142. "Digigait", 12, "Hind", "Stance/Swing",
  143. "Digigait", 12, "Hind", "PawDrag",
  144. "Digigait", 12, "Hind", "PercentSharedStance",
  145. "Digigait", 12, "Hind", "AbsolutePawAngle",
  146. "Digigait", 12, "Hind", "Propel",
  147. "GA", 12, NA, "Normalized_Area",
  148. "GP", 12, NA, "Normalized_Area",
  149. "GR", 12, NA, "Normalized_Area",
  150. "GFAP", 12, NA, "Normalized_Area",
  151. "Iba1", 12, NA, "Normalized_Area",
  152. "NeuN", 12, NA, "Normalized_Area",
  153. "pTDP43", 12, NA, "Normalized_Area",
  154. "TDP_CE", 12, NA, "Sort1_CE_normalized",
  155. "NeuN_count", 12, NA, "Mean_Total_Count",
  156. "spleen", 12, NA, "Weight_mg",
  157. )
  158. # ---- Subset and Clean ----
  159. plot_data <- pmap_dfr(subset_table, function(Exp, Time_month, Condition, StatsVariable) {
  160. df %>%
  161. filter(
  162. Exp == !!Exp,
  163. Time_month == !!Time_month,
  164. StatsVariable == !!StatsVariable,
  165. (is.na(Condition) & is.na(.data$Condition)) |
  166. (!is.na(Condition) & Condition == .data$Condition),
  167. !(Exp == "Digigait" & Limb == "Fore")
  168. )
  169. }) %>%
  170. mutate(
  171. Treatment_Combined = ifelse(Treatment %in% c("None", "Control"), "Control", "Repeats"),
  172. Treatment_Shape = factor(Treatment, levels = c("None", "Control", "Repeats")),
  173. Genotype = factor(Genotype, levels = c("WT", "Het", "Homo")),
  174. Sex = factor(Sex, levels = c("Female", "Male")),
  175. Genotype_Tx = factor(
  176. interaction(Genotype, Treatment_Combined, sep = "_"),
  177. levels = c("WT_Control", "Het_Control", "Homo_Control",
  178. "WT_Repeats", "Het_Repeats", "Homo_Repeats")
  179. ),
  180. facet_id = paste(Exp, Condition, StatsVariable, sep = "_")
  181. )
  182. # ---- Split Body_mass by Sex ----
  183. body_split <- plot_data %>%
  184. filter(Exp == "Body_mass") %>%
  185. mutate(facet_id = paste0("Body_mass_", Sex, "_Weight_grams"))
  186. plot_data <- plot_data %>%
  187. filter(!(Exp == "Body_mass" & StatsVariable == "Weight_grams")) %>%
  188. bind_rows(body_split)
  189. # ---- Additional filter ----
  190. imaging_exps <- c("GA", "GP", "GR", "GFAP", "Iba1", "NeuN", "pTDP43", "NeuN_count", "TDP_CE")
  191. plot_data <- plot_data %>%
  192. filter(
  193. !(Exp %in% imaging_exps & Genotype == "Het" & Treatment_Combined == "Repeats") |
  194. (Exp %in% imaging_exps & Genotype == "Het" & Treatment_Combined == "Repeats" &
  195. Expression_Quartile %in% c("Q2", "Q3"))
  196. )
  197. # ---- Facet Fillers ----
  198. facet_combinations <- plot_data %>%
  199. distinct(facet_id, Exp, Condition, StatsVariable)
  200. num_facets <- nrow(facet_combinations)
  201. num_per_page <- 12
  202. num_pages <- ceiling(num_facets / num_per_page)
  203. fillers_needed <- (num_pages * num_per_page) - num_facets
  204. if (fillers_needed > 0) {
  205. filler_data <- tibble(
  206. facet_id = paste0("filler_", seq_len(fillers_needed)),
  207. Exp = "Filler", Condition = NA, StatsVariable = "Empty",
  208. Genotype_Tx = factor(NA, levels = levels(plot_data$Genotype_Tx)),
  209. Value = NA
  210. )
  211. facet_combinations <- bind_rows(facet_combinations, filler_data)
  212. plot_data <- bind_rows(plot_data, filler_data)
  213. }
  214. # ---- Aesthetics ----
  215. sex_colors <- c("Female" = "red", "Male" = "blue")
  216. shape_values <- c("None" = 22, "Control" = 23, "Repeats" = 21)
  217. custom_fill_colors <- c(
  218. "WT_Repeats" = "#f15b60", # red
  219. "Het_Repeats" = "#f79151", # orange
  220. "Homo_Repeats" = "#ffcb38", # yellow
  221. "WT_Control" = "#00b04f", # green
  222. "Het_Control" = "#109ab3", # blue
  223. "Homo_Control" = "#8a77aa" # purple
  224. )
  225. # ---- Plot Loop ----
  226. pdf("Subset_Boxplot_GenoTx_SunsetOceanOrchid_3x4_Fillers.pdf", width = 5.5, height = 7)
  227. for (page in seq_len(num_pages)) {
  228. start_idx <- (page - 1) * num_per_page + 1
  229. end_idx <- min(page * num_per_page, nrow(facet_combinations))
  230. page_facets <- facet_combinations$facet_id[start_idx:end_idx]
  231. pd <- plot_data %>% filter(facet_id %in% page_facets) %>% droplevels()
  232. p <- ggplot(pd, aes(
  233. x = Genotype_Tx,
  234. y = Value,
  235. group = Genotype_Tx,
  236. fill = Genotype_Tx
  237. )) +
  238. geom_boxplot(
  239. position = position_dodge(width = 0.8),
  240. outlier.shape = NA,
  241. alpha = 1,
  242. width = 0.65
  243. ) +
  244. scale_fill_manual(values = custom_fill_colors, name = "Genotype × Treatment") +
  245. ggnewscale::new_scale_fill() +
  246. geom_jitter(
  247. aes(fill = Sex, shape = Treatment_Shape),
  248. color = "black", size = 1, stroke = 0.5, alpha = 0.85,
  249. position = position_jitter(width = 0.18, height = 0)
  250. ) +
  251. scale_fill_manual(values = sex_colors, name = "Sex") +
  252. scale_shape_manual(values = shape_values, name = "Original Treatment") +
  253. scale_x_discrete(drop = FALSE, na.translate = FALSE) +
  254. ylab("Value") +
  255. xlab("Genotype × Treatment Group") +
  256. facet_wrap(~ facet_id, scales = "free_y", ncol = 3, nrow = 4) +
  257. theme_classic(base_size = 8) +
  258. theme(
  259. strip.background = element_rect(fill = "grey90", color = "black"),
  260. strip.text = element_text(face = "bold", size = 4),
  261. axis.text.x = element_text(angle = 45, hjust = 1),
  262. legend.position = "right",
  263. axis.ticks.y = element_line(size = 0.3)
  264. )
  265. print(p)
  266. }
  267. dev.off()
  268. ```
  269. ```{r scatter_expression_correlations_publication, include=FALSE}
  270. ### -----------------------------------------------------------
  271. ### FACETED SCATTER PLOT WITH R², p, p_adj • 4×6 PAGE LAYOUT
  272. ### Genotype × Treatment Coloring (Repeats Only) + Fillers
  273. ### -----------------------------------------------------------
  274. library(dplyr)
  275. library(ggplot2)
  276. library(broom)
  277. library(purrr)
  278. library(tidyr)
  279. # ---- Subset and Clean ----
  280. plot_data <- pmap_dfr(subset_table, function(Exp, Time_month, Condition, StatsVariable) {
  281. df %>%
  282. filter(
  283. Exp == !!Exp,
  284. Time_month == !!Time_month,
  285. StatsVariable == !!StatsVariable,
  286. (is.na(Condition) & is.na(.data$Condition)) |
  287. (!is.na(Condition) & Condition == .data$Condition),
  288. !(Exp == "Digigait" & Limb == "Fore")
  289. )
  290. }) %>%
  291. mutate(
  292. Treatment_Combined = ifelse(Treatment %in% c("None", "Control"), "Control", "Repeats"),
  293. Treatment_Shape = factor(Treatment, levels = c("None", "Control", "Repeats")),
  294. Genotype = factor(Genotype, levels = c("WT", "Het", "Homo")),
  295. Sex = factor(Sex, levels = c("Female", "Male")),
  296. Genotype_Tx = factor(
  297. interaction(Genotype, Treatment_Combined, sep = "_"),
  298. levels = c("WT_Control", "Het_Control", "Homo_Control",
  299. "WT_Repeats", "Het_Repeats", "Homo_Repeats")
  300. ),
  301. facet_id = paste(Exp, Condition, StatsVariable, sep = "_")
  302. )
  303. # ---- Split Body_mass by Sex ----
  304. body_split <- plot_data %>%
  305. filter(Exp == "Body_mass") %>%
  306. mutate(facet_id = paste0("Body_mass_", Sex, "_Weight_grams"))
  307. plot_data <- plot_data %>%
  308. filter(!(Exp == "Body_mass" & StatsVariable == "Weight_grams")) %>%
  309. bind_rows(body_split)
  310. ### -----------------------------------------------------------
  311. ### 1. Prepare data with Genotype × Treatment factor
  312. ### -----------------------------------------------------------
  313. scatter_data <- plot_data %>%
  314. mutate(
  315. Treatment_Combined = ifelse(Treatment %in% c("None", "Control"),
  316. "Control", "Repeats"),
  317. Genotype_Tx = factor(
  318. interaction(Genotype, Treatment_Combined, sep = "_"),
  319. levels = c("WT_Control","Het_Control","Homo_Control",
  320. "WT_Repeats","Het_Repeats","Homo_Repeats")
  321. )
  322. ) %>%
  323. filter(
  324. Treatment == "Repeats",
  325. !is.na(Expression_Merged),
  326. Expression_Merged > 0,
  327. !is.na(Value)
  328. ) %>%
  329. mutate(
  330. Expression = as.numeric(Expression_Merged),
  331. Expression_log2 = log2(Expression_Merged)
  332. )
  333. ### -----------------------------------------------------------
  334. ### 2. Compute LM stats per facet (R², p, FDR)
  335. ### -----------------------------------------------------------
  336. facet_stats <- scatter_data %>%
  337. group_by(facet_id) %>%
  338. do({
  339. m <- lm(Value ~ Expression_log2, data = .)
  340. tibble(
  341. r2 = summary(m)$r.squared,
  342. p = glance(m)$p.value
  343. )
  344. }) %>%
  345. ungroup() %>%
  346. mutate(
  347. p_adj = p.adjust(p, method = "BH"),
  348. label = sprintf("R² = %.2f\np = %.3g\nFDR = %.3g",
  349. r2, p, p_adj)
  350. )
  351. scatter_plot_data <- scatter_data %>%
  352. left_join(facet_stats, by = "facet_id")
  353. ### -----------------------------------------------------------
  354. ### 3. Pagination + Fillers (4×6 = 24 plots per page)
  355. ### -----------------------------------------------------------
  356. facets <- sort(unique(scatter_plot_data$facet_id))
  357. n_per_page <- 24 # 4 columns × 6 rows
  358. n_pages <- ceiling(length(facets) / n_per_page)
  359. # Add filler facets to fill last page to 24 slots
  360. fillers_needed <- n_pages * n_per_page - length(facets)
  361. if (fillers_needed > 0) {
  362. filler_ids <- paste0("Filler_", seq_len(fillers_needed))
  363. # Create filler entries with NA values
  364. filler_df <- tibble(
  365. facet_id = rep(filler_ids, each = 1),
  366. Value = NA,
  367. Expression_log2 = NA,
  368. Genotype_Tx = factor(NA, levels = levels(scatter_plot_data$Genotype_Tx)),
  369. label = ""
  370. )
  371. facets <- c(facets, filler_ids)
  372. }
  373. ### -----------------------------------------------------------
  374. ### 4. Genotype × Treatment colors
  375. ### -----------------------------------------------------------
  376. genoTx_colors <- c(
  377. "WT_Repeats" = "#f15b60",
  378. "Het_Repeats" = "#f79151",
  379. "Homo_Repeats" = "#ffcb38",
  380. "WT_Control" = "#00b04f",
  381. "Het_Control" = "#109ab3",
  382. "Homo_Control" = "#8a77aa"
  383. )
  384. ### -----------------------------------------------------------
  385. ### 5. PDF loop (each page is 4×6 facets)
  386. ### -----------------------------------------------------------
  387. pdf("GenotypeTx_vs_Expression_log2_FacetedScatter_Paginated.pdf",
  388. width = 9, height = 10)
  389. for (page in seq_len(n_pages)) {
  390. start <- (page - 1) * n_per_page + 1
  391. end <- page * n_per_page
  392. these_facets <- facets[start:end]
  393. page_data <- scatter_plot_data %>%
  394. filter(facet_id %in% these_facets) %>%
  395. bind_rows(filler_df %>% filter(facet_id %in% these_facets)) %>%
  396. mutate(facet_id = factor(facet_id, levels = these_facets))
  397. p <- ggplot(page_data,
  398. aes(x = Expression_log2, y = Value)) +
  399. geom_point(
  400. aes(color = Genotype_Tx),
  401. size = 1.6, alpha = 0.85, na.rm = TRUE
  402. ) +
  403. geom_smooth(
  404. method = "lm", se = FALSE,
  405. color = "black", linewidth = 0.6, na.rm = TRUE
  406. ) +
  407. geom_text(
  408. aes(label = label),
  409. x = -Inf, y = Inf,
  410. hjust = -0.1, vjust = 1.1,
  411. size = 3, color = "black",
  412. lineheight = 0.9
  413. ) +
  414. facet_wrap(~ facet_id, ncol = 4, nrow = 6, scales = "free_y") +
  415. scale_color_manual(
  416. values = genoTx_colors,
  417. name = "Genotype × Treatment",
  418. na.translate = FALSE
  419. ) +
  420. scale_x_continuous(
  421. breaks = pretty(range(scatter_plot_data$Expression_log2), 5),
  422. labels = function(x) round(2^x, 1),
  423. name = "Expression (raw units, log2 scale)"
  424. ) +
  425. labs(
  426. y = "Phenotype Value",
  427. title = paste0("Genotype × Treatment Effects vs log2(Expression) — Page ", page)
  428. ) +
  429. theme_bw(base_size = 6) +
  430. theme(
  431. plot.title = element_text(face = "bold", size = 14, hjust = 0.5),
  432. strip.background = element_rect(fill = "white"),
  433. strip.text = element_text(face = "bold", size = 5),
  434. legend.position = "bottom",
  435. panel.grid = element_blank(),
  436. panel.spacing = unit(1.1, "lines")
  437. )
  438. print(p)
  439. }
  440. dev.off()
  441. ```
  442. ```{r correlation_matrix_dot_pot_publication, include=FALSE}
  443. library(dplyr)
  444. library(tidyr)
  445. library(ggplot2)
  446. library(reshape2)
  447. library(purrr)
  448. df <- data # Replace with your actual data object name
  449. # ---- Subset Table ----
  450. subset_table <- tribble(
  451. ~Exp, ~Time_month, ~Condition, ~StatsVariable,
  452. "Grip", 12, NA, "Grip_Strength",
  453. "CMAP", 12, "Ankle", "Amplitude",
  454. #"CMAP", 12, "Hip", "Area_Under_Curve",
  455. #"OpenField", 10, NA, "Total_distance_travelled",
  456. "OpenField", 10, NA, "Average_speed",
  457. #"OpenField", 10, NA, "Total_time_mobile",
  458. #"OpenField", 10, NA, "Total_immobile episodes",
  459. #"OpenField", 10, NA, "Average_speed_in_the_Perimeter_zone",
  460. "OpenField", 10, NA, "Time_in_the_Center_zone",
  461. #"OpenField", 10, NA, "Distance_travelled_in_the_Perimeter_zone",
  462. "Rotarod", 12, NA, "Latency_to_Fall",
  463. "Body_mass", 12, NA, "Weight_grams",
  464. "Digigait", 12, "Hind", "Stride",
  465. #"Digigait", 12, "Hind", "Swing",
  466. "Digigait", 12, "Hind", "Stance",
  467. #"Digigait", 12, "Hind", "StanceOverSwing",
  468. #"Digigait", 12, "Hind", "PawDrag",
  469. #"Digigait", 12, "Hind", "PercentSharedStance",
  470. #"Digigait", 12, "Hind", "AbsolutePawAngle",
  471. "GA", 12, NA, "Normalized_Area",
  472. "GP", 12, NA, "Normalized_Area",
  473. "GR", 12, NA, "Normalized_Area",
  474. "GFAP", 12, NA, "Normalized_Area",
  475. "Iba1", 12, NA, "Normalized_Area",
  476. "NeuN", 12, NA, "Normalized_Area",
  477. #"pTDP43", 12, NA, "Normalized_Area",
  478. "TDP_CE", 12, NA, "Sort1_CE_normalized",
  479. "NeuN_count", 12, NA, "Mean_Total_Count",
  480. #"NeuN_count", 12, NA, "Mean_Area_um2",
  481. )
  482. # ---- Subset and Clean ----
  483. plot_data <- pmap_dfr(subset_table, function(Exp, Time_month, Condition, StatsVariable) {
  484. df %>%
  485. filter(
  486. Exp == !!Exp,
  487. Time_month == !!Time_month,
  488. StatsVariable == !!StatsVariable,
  489. (is.na(Condition) & is.na(.data$Condition)) |
  490. (!is.na(Condition) & Condition == .data$Condition),
  491. !(Exp == "Digigait" & Limb == "Fore")
  492. )
  493. }) %>%
  494. mutate(
  495. Treatment_Combined = ifelse(Treatment %in% c("None", "Control"), "Control", "Repeats"),
  496. Treatment_Shape = factor(Treatment, levels = c("None", "Control", "Repeats")),
  497. Genotype = factor(Genotype, levels = c("WT", "Het", "Homo")),
  498. Sex = factor(Sex, levels = c("Female", "Male")),
  499. Genotype_Tx = factor(
  500. interaction(Genotype, Treatment_Combined, sep = "_"),
  501. levels = c("WT_Control", "Het_Control", "Homo_Control",
  502. "WT_Repeats", "Het_Repeats", "Homo_Repeats")
  503. ),
  504. facet_id = paste(Exp, Condition, StatsVariable, sep = "_")
  505. )
  506. #---------------------------------------------------------------#
  507. # 1. Summarize each Exp + StatsVariable to one value per mouse
  508. #---------------------------------------------------------------#
  509. exp_summary <- plot_data %>%
  510. mutate(Expression_Merged = ifelse(Treatment != "Repeats", NA, Expression_Merged)) %>%
  511. group_by(Ear_Tag, Exp, StatsVariable) %>%
  512. summarise(Exp_Value = mean(Value, na.rm = TRUE), .groups = "drop") %>%
  513. mutate(ExpVar = paste(Exp, StatsVariable, sep = "_")) %>%
  514. select(Ear_Tag, ExpVar, Exp_Value) %>%
  515. pivot_wider(
  516. names_from = ExpVar,
  517. values_from = Exp_Value
  518. )
  519. #---------------------------------------------------------------#
  520. # 2. Attach Expression_Merged directly (not summarized)
  521. #---------------------------------------------------------------#
  522. expr_values <- plot_data %>%
  523. distinct(Ear_Tag, Expression_Merged)
  524. combined_df <- exp_summary %>%
  525. left_join(expr_values, by = "Ear_Tag")
  526. #---------------------------------------------------------------#
  527. # 3. Prepare numeric vars (drop ID, keep sufficient non-NA vars)
  528. #---------------------------------------------------------------#
  529. numeric_vars <- combined_df %>%
  530. select(where(is.numeric)) %>%
  531. select(-Ear_Tag) %>% # ⭐ REMOVE EAR_TAG ⭐
  532. select(where(~ sum(!is.na(.)) >= 3))
  533. #---------------------------------------------------------------#
  534. # 4. Correlation + P-values
  535. #---------------------------------------------------------------#
  536. corr_mat <- cor(numeric_vars, use = "pairwise.complete.obs", method = "pearson")
  537. p_mat <- matrix(NA, ncol = ncol(numeric_vars), nrow = ncol(numeric_vars))
  538. colnames(p_mat) <- rownames(p_mat) <- colnames(numeric_vars)
  539. for (i in seq_len(ncol(numeric_vars))) {
  540. for (j in seq_len(ncol(numeric_vars))) {
  541. x <- numeric_vars[[i]]
  542. y <- numeric_vars[[j]]
  543. if (sum(complete.cases(x, y)) >= 3) {
  544. p_mat[i, j] <- cor.test(x, y)$p.value
  545. }
  546. }
  547. }
  548. # Adjusted p-values
  549. padj_mat <- matrix(
  550. p.adjust(as.vector(p_mat), method = "BH"),
  551. nrow = ncol(numeric_vars),
  552. dimnames = list(colnames(numeric_vars), colnames(numeric_vars))
  553. )
  554. #---------------------------------------------------------------#
  555. # 5. Melt matrices + hierarchical order
  556. #---------------------------------------------------------------#
  557. hc <- hclust(dist(corr_mat))
  558. ord <- hc$order
  559. corr_ord <- corr_mat[ord, ord]
  560. padj_ord <- padj_mat[ord, ord]
  561. df_plot <- reshape2::melt(corr_ord) %>%
  562. rename(Var1 = Var1, Var2 = Var2, cor = value) %>%
  563. mutate(
  564. padj = as.vector(padj_ord),
  565. size_value = -log10(padj), # ⭐ new transform
  566. size_value = pmin(size_value, 3) # ⭐ optional: cap extremes
  567. ) %>%
  568. filter(as.numeric(Var1) < as.numeric(Var2)) %>%
  569. filter(!is.na(cor))
  570. #---------------------------------------------------------------#
  571. # 6. Dot plot
  572. #---------------------------------------------------------------#
  573. p <- ggplot(df_plot, aes(Var1, Var2, color = cor, size = size_value)) +
  574. geom_point(alpha = 0.9) +
  575. scale_color_gradient2(
  576. low = "#b2182b",
  577. mid = "#f7f7f7",
  578. high = "#1f78b4",
  579. midpoint = 0,
  580. limits = c(-1, 1),
  581. name = "Correlation"
  582. ) +
  583. scale_size(
  584. range = c(2, 10),
  585. name = expression("-log"[10]*"(adj p)"),
  586. limits = c(0, 5) # explicitly bound scale
  587. ) +
  588. coord_fixed() +
  589. labs(title = "Correlation Matrix Across Experiment × Variable + Expression_Merged") +
  590. theme_minimal(base_size = 16) +
  591. theme(
  592. axis.title = element_blank(),
  593. axis.text.x = element_text(angle = 45, hjust = 1),
  594. axis.text.y = element_text(size = 12),
  595. panel.grid.major = element_line(color = "gray85", linewidth = 0.3),
  596. plot.title = element_text(size = 20, face = "bold", hjust = 0.5)
  597. )
  598. #---------------------------------------------------------------#
  599. # 7. Export as PDF
  600. #---------------------------------------------------------------#
  601. ggsave(
  602. filename = "correlation_matrix_experiment_variable_pairs.pdf",
  603. plot = p,
  604. width = 9,
  605. height = 9,
  606. units = "in",
  607. dpi = 300
  608. )
  609. ```
  610. ```{r plot_signifcant_correlations_publication,include=FALSE}
  611. ### -----------------------------------------------------------
  612. ### SIGNIFICANT PHENOTYPE–PHENOTYPE SCATTER PLOTS (R²-based)
  613. ### Paginated 4×6 Faceting + Fillers • Colored by Genotype × Treatment
  614. ### -----------------------------------------------------------
  615. library(dplyr)
  616. library(ggplot2)
  617. library(broom)
  618. library(purrr)
  619. library(tidyr)
  620. alpha <- 0.05 # FDR significance cutoff
  621. ### -----------------------------------------------------------
  622. ### 1. Identify significant NON-expression pairs
  623. ### -----------------------------------------------------------
  624. sig_pairs <- df_plot %>%
  625. filter(padj < alpha) %>%
  626. filter(!grepl("Expression", Var1),
  627. !grepl("Expression", Var2)) %>%
  628. select(Var1, Var2, cor, padj)
  629. if (nrow(sig_pairs) == 0) stop("No significant phenotype–phenotype correlations found.")
  630. ### -----------------------------------------------------------
  631. ### 2. Build phenotype matrix with Genotype × Treatment mapping
  632. ### -----------------------------------------------------------
  633. geno_tx_map <- plot_data %>%
  634. mutate(
  635. Treatment_Combined = ifelse(Treatment %in% c("None", "Control"), "Control", "Repeats"),
  636. Genotype_Tx = factor(
  637. interaction(Genotype, Treatment_Combined, sep = "_"),
  638. levels = c("WT_Control", "Het_Control", "Homo_Control",
  639. "WT_Repeats", "Het_Repeats", "Homo_Repeats")
  640. )
  641. ) %>%
  642. distinct(Ear_Tag, Genotype_Tx)
  643. scatter_wide <- exp_summary %>%
  644. left_join(geno_tx_map, by = "Ear_Tag")
  645. ### -----------------------------------------------------------
  646. ### 3. Build long format for each significant pair (with SAFETY CHECKS)
  647. ### -----------------------------------------------------------
  648. scatter_list <- list()
  649. for (i in seq_len(nrow(sig_pairs))) {
  650. v1 <- sig_pairs$Var1[i]
  651. v2 <- sig_pairs$Var2[i]
  652. # safety: skip comparisons whose variables are missing
  653. if (!(v1 %in% colnames(scatter_wide)) | !(v2 %in% colnames(scatter_wide))) {
  654. message("Skipping pair (missing column): ", v1, " -- ", v2)
  655. next
  656. }
  657. tmp <- scatter_wide %>%
  658. select(Ear_Tag, Genotype_Tx, all_of(v1), all_of(v2)) %>%
  659. rename(Value_x = all_of(v1),
  660. Value_y = all_of(v2)) %>%
  661. filter(!is.na(Value_x) & !is.na(Value_y)) %>%
  662. mutate(
  663. Var1 = v1,
  664. Var2 = v2,
  665. cor_original = sig_pairs$cor[i], padj_original = sig_pairs$padj[i], facet_id = paste(v1, "vs", v2)
  666. )
  667. scatter_list[[length(scatter_list) + 1]] <- tmp
  668. }
  669. scatter_df <- bind_rows(scatter_list)
  670. ### -----------------------------------------------------------
  671. ### 4. Compute R² per facet, but use original FDR from df_plot
  672. ### -----------------------------------------------------------
  673. pair_stats <- scatter_df %>%
  674. group_by(facet_id) %>%
  675. do({
  676. m <- lm(Value_y ~ Value_x, data = .)
  677. tibble(
  678. r2 = summary(m)$r.squared,
  679. p = glance(m)$p.value,
  680. cor_original = unique(.$cor_original),
  681. padj_original = unique(.$padj_original)
  682. )
  683. }) %>%
  684. ungroup() %>%
  685. mutate(
  686. label = sprintf(
  687. "R² = %.2f\np = %.3g\nFDR = %.3g",
  688. r2, p, padj_original
  689. )
  690. )
  691. scatter_df <- left_join(scatter_df, pair_stats, by = "facet_id")
  692. ### -----------------------------------------------------------
  693. ### 5. Genotype × Treatment Colors
  694. ### -----------------------------------------------------------
  695. genoTx_colors <- c(
  696. "WT_Repeats" = "#f15b60",
  697. "Het_Repeats" = "#f79151",
  698. "Homo_Repeats" = "#ffcb38",
  699. "WT_Control" = "#00b04f",
  700. "Het_Control" = "#109ab3",
  701. "Homo_Control" = "#8a77aa"
  702. )
  703. ### -----------------------------------------------------------
  704. ### 6. PAGINATION + FILLERS (4×6 layout)
  705. ### -----------------------------------------------------------
  706. facet_ids <- unique(scatter_df$facet_id)
  707. n_per_page <- 24 # 4 columns × 6 rows
  708. n_pages <- ceiling(length(facet_ids) / n_per_page)
  709. # filler facets to complete the last page
  710. fillers_needed <- n_pages * n_per_page - length(facet_ids)
  711. filler_df <- tibble()
  712. if (fillers_needed > 0) {
  713. filler_ids <- paste0("Filler_", seq_len(fillers_needed))
  714. filler_df <- tibble(
  715. facet_id = filler_ids,
  716. Value_x = NA,
  717. Value_y = NA,
  718. Genotype_Tx = factor(NA, levels = levels(scatter_df$Genotype_Tx)),
  719. label = ""
  720. )
  721. facet_ids <- c(facet_ids, filler_ids)
  722. }
  723. ### -----------------------------------------------------------
  724. ### 7. PDF output (each page is 4×6)
  725. ### -----------------------------------------------------------
  726. pdf("Significant_PhenotypePhenotype_ScatterPlots_R2_GenoTx_Paginated.pdf",
  727. width = 9, height = 10.5)
  728. for (page in seq_len(n_pages)) {
  729. start <- (page - 1) * n_per_page + 1
  730. end <- page * n_per_page
  731. these_facets <- facet_ids[start:end]
  732. page_data <- scatter_df %>%
  733. filter(facet_id %in% these_facets) %>%
  734. bind_rows(filler_df %>% filter(facet_id %in% these_facets)) %>%
  735. mutate(facet_id = factor(facet_id, levels = these_facets))
  736. p_page <- ggplot(page_data, aes(x = Value_x, y = Value_y)) +
  737. geom_point(aes(color = Genotype_Tx),
  738. size = 1.8, alpha = 0.85, na.rm = TRUE) +
  739. geom_smooth(method = "lm",
  740. se = FALSE,
  741. color = "black",
  742. linewidth = 0.7,
  743. na.rm = TRUE) +
  744. geom_text(
  745. aes(label = label),
  746. x = -Inf, y = Inf,
  747. hjust = -0.1, vjust = 1.2,
  748. size = 3,
  749. lineheight = 0.9,
  750. color = "black"
  751. ) +
  752. facet_wrap(~ facet_id, ncol = 4, nrow = 6, scales = "free") +
  753. scale_color_manual(
  754. name = "Genotype × Treatment",
  755. values = genoTx_colors,
  756. na.translate = FALSE
  757. ) +
  758. labs(
  759. title = paste("Significant Phenotype–Phenotype Scatter Plots (Page", page, ")"),
  760. x = "Phenotype A",
  761. y = "Phenotype B"
  762. ) +
  763. theme_bw(base_size = 6) +
  764. theme(
  765. plot.title = element_text(size = 14, face = "bold", hjust = 0.5),
  766. strip.background = element_rect(fill = "white", color = "black"),
  767. strip.text = element_text(size = 5, face = "bold"),
  768. legend.position = "bottom",
  769. panel.grid = element_blank()
  770. )
  771. print(p_page)
  772. }
  773. dev.off()
  774. ```
  775. ``` {r select_publication_boxplots_over_time}
  776. library(dplyr)
  777. library(ggplot2)
  778. library(ggnewscale)
  779. library(tibble)
  780. # --- Set parameters
  781. target_exps <- c("Iba1", "GR", "GP", "GFAP", "NeuN", "GA", "TDP_CE")
  782. target_stats <- c("Normalized_Area", "Sort1_CE_normalized")
  783. facet_ids_expected <- expand.grid(Exp = target_exps, StatsVariable = target_stats) %>%
  784. mutate(facet_id = paste(Exp, StatsVariable, sep = "_")) %>%
  785. pull(facet_id)
  786. # --- Filter + format base data
  787. plot_data <- data %>%
  788. filter(
  789. Exp %in% target_exps,
  790. Genotype == "Het",
  791. StatsVariable %in% target_stats
  792. ) %>%
  793. mutate(
  794. Treatment_Combined = ifelse(Treatment %in% c("None", "Control"), "Control", "Repeats"),
  795. Genotype_Tx = factor(interaction(Genotype, Treatment_Combined, sep = "_"),
  796. levels = c("Het_Control", "Het_Repeats")),
  797. Treatment_Shape = factor(Treatment, levels = c("None", "Control", "Repeats")),
  798. Sex = factor(Sex, levels = c("Female", "Male")),
  799. Time_month = factor(Time_month, levels = sort(unique(Time_month))),
  800. facet_id = paste(Exp, StatsVariable, sep = "_")
  801. ) %>%
  802. # ---- NEW FILTER: Keep only Het + Repeats imaging with Expression_Merged between 30–630 ----
  803. filter(
  804. # Keep ALL non-imaging OR non-Repeats rows
  805. !(Exp %in% imaging_exps & Treatment_Combined == "Repeats") |
  806. # Apply the 30–630 filter *only* for imaging × Repeats × Het rows
  807. (Exp %in% imaging_exps &
  808. Treatment_Combined == "Repeats" &
  809. Expression_Merged >= 30 &
  810. Expression_Merged <= 630)
  811. )
  812. # --- Fill in missing facets to ensure 3x4 layout
  813. existing_facets <- unique(plot_data$facet_id)
  814. missing_facets <- setdiff(facet_ids_expected, existing_facets)
  815. if (length(missing_facets) > 0) {
  816. filler_data <- tibble(
  817. Exp = gsub("_.*", "", missing_facets),
  818. StatsVariable = gsub(".*_", "", missing_facets),
  819. facet_id = missing_facets,
  820. Time_month = factor(NA, levels = levels(plot_data$Time_month)),
  821. Value = NA,
  822. Genotype_Tx = factor(NA, levels = c("Het_Control", "Het_Repeats")),
  823. Treatment_Shape = NA,
  824. Sex = NA
  825. )
  826. plot_data <- bind_rows(plot_data, filler_data)
  827. }
  828. # --- Add additional fillers to reach 12 panels (3x4)
  829. total_panels <- 12
  830. current_panels <- length(unique(plot_data$facet_id))
  831. if (current_panels < total_panels) {
  832. extra_fillers <- tibble(
  833. Exp = "Filler",
  834. StatsVariable = "Empty",
  835. facet_id = paste0("filler_", seq_len(total_panels - current_panels)),
  836. Time_month = factor(NA, levels = levels(plot_data$Time_month)),
  837. Value = NA,
  838. Genotype_Tx = factor(NA, levels = c("Het_Control", "Het_Repeats")),
  839. Treatment_Shape = NA,
  840. Sex = NA
  841. )
  842. plot_data <- bind_rows(plot_data, extra_fillers)
  843. }
  844. # --- Aesthetics
  845. custom_fill_colors <- c("Het_Control" = "#109ab3", "Het_Repeats" = "#f79151")
  846. sex_colors <- c("Female" = "red", "Male" = "blue")
  847. shape_values <- c("None" = 22, "Control" = 23, "Repeats" = 21)
  848. plot_data <- plot_data %>%
  849. mutate(
  850. facet_id = case_when(
  851. facet_id == "Iba1_Normalized_Area" ~ "Iba1\nNormalized\nArea",
  852. facet_id == "Iba1_Normalized_Count" ~ "Iba1\nNormalized\nCount",
  853. facet_id == "GR_Normalized_Area" ~ "GR\nNormalized\nArea",
  854. facet_id == "GR_Normalized_Count" ~ "GR\nNormalized\nCount",
  855. facet_id == "GFAP_Normalized_Area" ~ "GFAP\nNormalized\nArea",
  856. facet_id == "GFAP_Normalized_Count" ~ "GFAP\nNormalized\nCount",
  857. TRUE ~ facet_id
  858. )
  859. )
  860. # --- Plot
  861. pdf("Iba1_GR_GFAP_Het_AcrossTime_FIXED_3x4.pdf", width = 7, height = 9)
  862. p <- ggplot(plot_data, aes(
  863. x = Time_month,
  864. y = Value,
  865. fill = Genotype_Tx
  866. )) +
  867. geom_boxplot(
  868. aes(group = interaction(Time_month, Genotype_Tx)),
  869. position = position_dodge2(width = 0.75, preserve = "single"),
  870. outlier.shape = NA,
  871. width = 1,
  872. alpha = 0.9
  873. ) +
  874. scale_fill_manual(values = custom_fill_colors, name = "Genotype × Treatment") +
  875. ggnewscale::new_scale_fill() +
  876. geom_jitter(
  877. aes(
  878. fill = Sex,
  879. shape = Treatment_Shape,
  880. group = interaction(Time_month, Genotype_Tx)
  881. ),
  882. color = "black",
  883. size = 1.5,
  884. stroke = 0.5,
  885. alpha = 0.8,
  886. position = position_jitterdodge(dodge.width = 0.75, jitter.width = 0.2)
  887. ) +
  888. scale_fill_manual(values = sex_colors, name = "Sex") +
  889. scale_shape_manual(values = shape_values, name = "Original Treatment") +
  890. facet_wrap(~ facet_id, scales = "free_y", ncol = 3, nrow = 4) +
  891. labs(x = "Time (months)", y = "Value") +
  892. theme_classic(base_size = 10) +
  893. theme(
  894. strip.background = element_rect(fill = "grey90", color = "black"),
  895. strip.text = element_text(face = "bold", size = 9),
  896. axis.text.x = element_text(angle = 45, hjust = 1),
  897. legend.position = "right"
  898. )
  899. print(p)
  900. dev.off()
  901. ```
  902. ```{r Expression_distribution_plot_publication, include=FALSE}
  903. library(dplyr)
  904. library(tidyr)
  905. library(ggplot2)
  906. # ---------------------------------------------------------------
  907. # 1. PREPARE DATA (unique mice, log2-transform, compute stats)
  908. # ---------------------------------------------------------------
  909. repeats_data <- data %>%
  910. filter(
  911. Treatment == "Repeats",
  912. Expression_Merged > 0
  913. )
  914. # Extract Expression_* columns
  915. expression_cols <- grep("^Expression_", colnames(repeats_data), value = TRUE)
  916. repeats_data <- repeats_data %>%
  917. mutate(across(all_of(expression_cols), as.numeric))
  918. # Pivot Expression_* → one column, then keep UNIQUE mice
  919. unique_expression <- repeats_data %>%
  920. pivot_longer(
  921. cols = all_of(expression_cols),
  922. names_to = "Timepoint",
  923. values_to = "Expression"
  924. ) %>%
  925. filter(!is.na(Expression), Expression > 0) %>%
  926. distinct(Ear_Tag, .keep_all = TRUE) %>%
  927. select(Ear_Tag, Expression)
  928. # Raw-scale summary stats
  929. min_exp <- min(unique_expression$Expression)
  930. max_exp <- max(unique_expression$Expression)
  931. quart_raw <- quantile(unique_expression$Expression, probs = c(.25, .50, .75))
  932. mean_expression <- mean(unique_expression$Expression)
  933. median_expression <- median(unique_expression$Expression)
  934. # Convert everything to log2 space for plotting
  935. unique_expression <- unique_expression %>%
  936. mutate(Expression_log2 = log2(Expression))
  937. min_log <- log2(min_exp)
  938. max_log <- log2(max_exp)
  939. quart_log <- log2(quart_raw)
  940. mean_log <- log2(mean_expression)
  941. median_log <- log2(median_expression)
  942. # Dynamic bin width for histogram
  943. log_range <- max_log - min_log
  944. n_bins <- 20
  945. bin_width <- log_range / n_bins
  946. # ---------------------------------------------------------------
  947. # 2. HISTOGRAM PDF OUTPUT
  948. # ---------------------------------------------------------------
  949. pdf("Expression_Histogram_UniqueMice_log2.pdf", width = 3, height = 2)
  950. hist_plot <- ggplot(unique_expression, aes(x = Expression_log2)) +
  951. geom_rect(aes(xmin = min_log, xmax = quart_log[1], ymin = 0, ymax = Inf),
  952. fill = "lightblue", alpha = 0.4, inherit.aes = FALSE) +
  953. geom_rect(aes(xmin = quart_log[1], xmax = quart_log[2], ymin = 0, ymax = Inf),
  954. fill = "lightgreen", alpha = 0.4, inherit.aes = FALSE) +
  955. geom_rect(aes(xmin = quart_log[2], xmax = quart_log[3], ymin = 0, ymax = Inf),
  956. fill = "lightyellow", alpha = 0.4, inherit.aes = FALSE) +
  957. geom_rect(aes(xmin = quart_log[3], xmax = max_log, ymin = 0, ymax = Inf),
  958. fill = "lightpink", alpha = 0.4, inherit.aes = FALSE) +
  959. geom_histogram(binwidth = bin_width,
  960. color = "black", fill = "steelblue", alpha = 0.75) +
  961. geom_vline(xintercept = mean_log, color = "red", linetype = "dashed", linewidth = 1) +
  962. geom_vline(xintercept = median_log, color = "darkgreen", linetype = "dashed", linewidth = 1) +
  963. annotate("text", x = mean_log, y = 0,
  964. label = paste0("Mean: ", round(mean_expression,1)),
  965. hjust = -0.1, vjust = -1.5, color = "red", size = 3) +
  966. annotate("text", x = median_log, y = 0,
  967. label = paste0("Median: ", round(median_expression,1)),
  968. hjust = -0.1, vjust = -3, color = "darkgreen", size = 3) +
  969. scale_x_continuous(
  970. breaks = pretty(c(min_log, max_log), n = 5),
  971. labels = function(x) round(2^x, 1)
  972. ) +
  973. theme_classic() +
  974. labs(
  975. title = "Expression Histogram (Unique Mice, Repeats Only)",
  976. x = "Expression (raw units, log2 axis)",
  977. y = "Count"
  978. )
  979. print(hist_plot)
  980. dev.off()
  981. # ---------------------------------------------------------------
  982. # 3. DENSITY PDF OUTPUT
  983. # ---------------------------------------------------------------
  984. pdf("Expression_Density_UniqueMice_log2.pdf", width = 3, height = 2)
  985. density_plot <- ggplot(unique_expression, aes(x = Expression_log2)) +
  986. geom_rect(aes(xmin = min_log, xmax = quart_log[1], ymin = 0, ymax = Inf),
  987. fill = "lightblue", alpha = 0.4, inherit.aes = FALSE) +
  988. geom_rect(aes(xmin = quart_log[1], xmax = quart_log[2], ymin = 0, ymax = Inf),
  989. fill = "lightgreen", alpha = 0.4, inherit.aes = FALSE) +
  990. geom_rect(aes(xmin = quart_log[2], xmax = quart_log[3], ymin = 0, ymax = Inf),
  991. fill = "lightyellow", alpha = 0.4, inherit.aes = FALSE) +
  992. geom_rect(aes(xmin = quart_log[3], xmax = max_log, ymin = 0, ymax = Inf),
  993. fill = "lightpink", alpha = 0.4, inherit.aes = FALSE) +
  994. geom_density(fill = "steelblue", alpha = 0.6) +
  995. geom_vline(xintercept = mean_log, color = "red", linetype = "dashed", linewidth = 1) +
  996. geom_vline(xintercept = median_log, color = "darkgreen", linetype = "dashed", linewidth = 1) +
  997. annotate("text", x = mean_log, y = 0.01,
  998. label = paste0("Mean: ", round(mean_expression, 1)),
  999. hjust = -0.1, color = "red", size = 4) +
  1000. annotate("text", x = median_log, y = 0.015,
  1001. label = paste0("Median: ", round(median_expression, 1)),
  1002. hjust = -0.1, color = "darkgreen", size = 4) +
  1003. scale_x_continuous(
  1004. breaks = pretty(c(min_log, max_log), n = 5),
  1005. labels = function(x) round(2^x, 1)
  1006. ) +
  1007. theme_classic() +
  1008. labs(
  1009. title = "Expression Density (Unique Mice, Repeats Only)",
  1010. x = "Expression (raw units, log2 axis)",
  1011. y = "Density"
  1012. )
  1013. print(density_plot)
  1014. dev.off()
  1015. ```

KAR_Acta_Neuro_Comm_v1.13.Rmd, under CC-BY-4.0 · at the source

Overview

Authors: Katelyn A Russell1,2, Amelia A Shahrabi1,2, Suleyman C Akerman3,4, Matthew D Byrne1, Jeffrey D Rothstein3,4, Davide Trotti1,2, Brigid K Jensen1,2, Aaron R Haeusler1,2
  1. Department of Neuroscience, Vickie and Jack Farber Institute for Neuroscience, Thomas Jefferson University, Philadelphia, PA 19107 USA
  2. Jefferson Weinberg ALS Center, Vickie and Jack Farber Institute for Neuroscience, Thomas Jefferson University, Philadelphia, PA 19107 USA
  3. Department of Neurology, Johns Hopkins University School of Medicine, Baltimore, MD 21205 USA
  4. Brain Science Institute, Johns Hopkins University School of Medicine, Baltimore, MD 21205 USA
Institutions: Thomas Jefferson University (United States); Johns Hopkins University (United States); Johns Hopkins Medicine (United States)
Journal: Acta neuropathologica communications, volume 14, issue 1, article 167
Dates: received 11 February 2026; accepted 1 June 2026; published online 18 June 2026
Type: Research article · Language: English
License: CC BY-NC-ND
Identifiers: DOI 10.1186/s40478-026-02341-8 · PMID 42316301 · PMCID PMC13476920 · OpenAlex W7165190099
Open access: gold, a free copy (OpenAlex)
Status: code verified
Categories: human (organism), mouse (organism), other condition (population), Alzheimer's / dementia (population), cellular / molecular (subfield)
Methods: Preprocessing, Statistics, Machine learning, Evoked potentials, Connectivity, fMRI & imaging
Keywords: ALS, FTD, ALS/FTD, C9orf72, Mouse models, C9orf72 repeat expansions, Neurodegenerative disease, Motor neuron disease
MeSH: Amyotrophic Lateral Sclerosis*, C9orf72 Protein*, Frontotemporal Dementia*, Animals, Dependovirus, Disease Models, Animal, DNA Repeat Expansion, DNA-Binding Proteins, Humans, Injections, Spinal, Male, Mice, Mice, Inbred C57BL, Mice, Transgenic, Motor Neurons, Spinal Cord (* major topic)
Topic: Amyotrophic Lateral Sclerosis Research (Neurology, Medicine), according to OpenAlex
Funding: NCI NIH HHS (P30 CA056036); NINDS NIH HHS (R01 NS114128, R01 NS109150, R01NS109150, RF1 NS114128, RF1NS114128); National Institute of Neurological Disorders and Stroke (RF1NS114128, R01NS109150); Farber Family Foundation; Aldrich Foundation
Citations: not cited yet (Europe PMC); 97 references in the paper

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.

Repository

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

figshare 32825642

License: CC-BY-4.0
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Languages: R (1)
Size: 2 files, 1 script
Software Heritage: not checked
Found in: “Code availability”
Holds: 1 notebook
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: broom (1 file), ggplot2 (1 file), reshape2 (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)
1 file

Code availability statement

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

Read it in the paper: doi.org/10.1186/s40478-026-02341-8.

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:

  • 1 repository of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
  • 1 script, each with its path and the digest of its content;
  • 2 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.

Data availability statement

The paper has a 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 says that the data are available on request

Read it in the paper: doi.org/10.1186/s40478-026-02341-8.

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 1, 27 September 2026: the first record

Recorded: type, language, journal, volume, issue, pages, dates, 8 authors, 8 keywords, 16 MeSH terms, 5 funders, 94 references.

Cite

This paper

Russell, K. A., Shahrabi, A. A., Akerman, S. C., Byrne, M. D., Rothstein, J. D., Trotti, D., Jensen, B. K., & Haeusler, A. R. (2026). Intrathecal (G&lt;sub&gt;4&lt;/sub&gt;C&lt;sub&gt;2&lt;/sub&gt;)&lt;sub&gt;149&lt;/sub&gt; delivery in C9orf72-deficient mice yields mild motor dysfunction and ALS/FTD pathological hallmarks. Acta neuropathologica communications, 14(1), 167. https://doi.org/10.1186/s40478-026-02341-8

BibTeX

@article{russell2026intrathecal,
author = {Russell, Katelyn A and Shahrabi, Amelia A and Akerman, Suleyman C and Byrne, Matthew D and Rothstein, Jeffrey D and Trotti, Davide and Jensen, Brigid K and Haeusler, Aaron R},
title = {{Intrathecal (G\&lt;sub\&gt;4\&lt;/sub\&gt;C\&lt;sub\&gt;2\&lt;/sub\&gt;)\&lt;sub\&gt;149\&lt;/sub\&gt; delivery in C9orf72-deficient mice yields mild motor dysfunction and ALS/FTD pathological hallmarks}},
journal = {Acta neuropathologica communications},
year = {2026},
month = jun,
volume = {14},
number = {1},
pages = {167},
publisher = {BMC},
issn = {2051-5960},
doi = {10.1186/s40478-026-02341-8},
url = {https://doi.org/10.1186/s40478-026-02341-8},
pmid = {42316301},
pmcid = {PMC13476920}
}

RIS

TY - JOUR
AU - Russell, Katelyn A
AU - Shahrabi, Amelia A
AU - Akerman, Suleyman C
AU - Byrne, Matthew D
AU - Rothstein, Jeffrey D
AU - Trotti, Davide
AU - Jensen, Brigid K
AU - Haeusler, Aaron R
TI - Intrathecal (G&lt;sub&gt;4&lt;/sub&gt;C&lt;sub&gt;2&lt;/sub&gt;)&lt;sub&gt;149&lt;/sub&gt; delivery in C9orf72-deficient mice yields mild motor dysfunction and ALS/FTD pathological hallmarks
T2 - Acta neuropathologica communications
J2 - Acta Neuropathol Commun
PY - 2026
DA - 2026/06/18
VL - 14
IS - 1
SP - 167
SN - 2051-5960
PB - BMC
DO - 10.1186/s40478-026-02341-8
UR - https://doi.org/10.1186/s40478-026-02341-8
LA - en
ER -

CSL-JSON

{
"id": "10.1186/s40478-026-02341-8",
"type": "article-journal",
"title": "Intrathecal (G&lt;sub&gt;4&lt;/sub&gt;C&lt;sub&gt;2&lt;/sub&gt;)&lt;sub&gt;149&lt;/sub&gt; delivery in C9orf72-deficient mice yields mild motor dysfunction and ALS/FTD pathological hallmarks",
"container-title": "Acta neuropathologica communications",
"author": [
{
"family": "Russell",
"given": "Katelyn A"
},
{
"family": "Shahrabi",
"given": "Amelia A"
},
{
"family": "Akerman",
"given": "Suleyman C"
},
{
"family": "Byrne",
"given": "Matthew D"
},
{
"family": "Rothstein",
"given": "Jeffrey D"
},
{
"family": "Trotti",
"given": "Davide"
},
{
"family": "Jensen",
"given": "Brigid K"
},
{
"family": "Haeusler",
"given": "Aaron R"
}
],
"container-title-short": "Acta Neuropathol Commun",
"volume": "14",
"issue": "1",
"page": "167",
"DOI": "10.1186/s40478-026-02341-8",
"PMID": "42316301",
"PMCID": "PMC13476920",
"ISSN": "2051-5960",
"publisher": "BMC",
"URL": "https://doi.org/10.1186/s40478-026-02341-8",
"language": "en",
"issued": {
"date-parts": [
[
2026,
6,
18
]
]
}
}

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.1093/brain/awaf340
PU.1 restores microglial dysfunction caused by C9ORF72 repeat expansions in neural organoids.
Journal: Brain : a journal of neurology
In common: Alzheimer's / dementia, other condition, cellular / molecular, 9 references
[2] doi:10.1038/s41593-026-02300-5 [code]
Integrated single-cell and spatial transcriptomic profiling in ALS uncovers peripheral-to-central immune infiltration and reprogramming.
Journal: Nature neuroscience
In common: reshape2, ggplot2, tidyverse, other condition, cellular / molecular, 5 references
[3] doi:10.1038/s44318-026-00817-w
The C9orf72/SMCR8 complex maintains microglial homeostasis via RAB8A-ESCRT-mediated lysosomal repair.
Journal: The EMBO journal
In common: mouse, cellular / molecular, 6 references
[4] doi:10.1038/s41588-026-02570-6 [code]
Somatic mosaicism in ALS and FTD identifies focal mutations associated with widespread degeneration.
Journal: Nature genetics
In common: reshape2, ggplot2, tidyverse, Alzheimer's / dementia, other condition, cellular / molecular, 4 references
[5] doi:10.1186/s13024-026-00944-2
TDP-43: [GU]-ardian of the transcriptome.
Journal: Molecular neurodegeneration
In common: other condition, cellular / molecular, 6 references
[6] doi:10.1016/j.cell.2026.05.047 [code]
An emergent disease-associated motor neuron state precedes cell death in ALS.
Journal: Cell
In common: broom, ggplot2, tidyverse, other condition, mouse, cellular / molecular, 3 references
[7] doi:10.1371/journal.pgen.1011909
Glial cell toxicity in a Drosophila C9orf72 neurodegeneration model.
Journal: PLoS genetics
In common: Alzheimer's / dementia, other condition, cellular / molecular, 5 references
[8] doi:10.1038/s41597-026-07461-3
Multimodal ultra-high-field MRI, clinical, cognitive, and genetic profiles across the ALS-FTD spectrum.
Journal: Scientific data
In common: Alzheimer's / dementia, other condition, 5 references
[9] doi:10.1016/j.isci.2026.116054 [code]
Global transcriptional changes across multiple isogenic &lt;i&gt;C9orf72&lt;/i&gt; patient iPSC-derived neurons.
Journal: iScience
In common: cellular / molecular, 5 references
[10] doi:10.1093/braincomms/fcag272 [code]
Strenuous physical activity is associated with a younger age of amyotrophic lateral sclerosis onset in two independent cohorts.
Journal: Brain communications
In common: broom, ggplot2, tidyverse, other condition, 2 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.