OSCR

The TREM2 R47H variant is associated with liver-plasma-brain axis dyshomeostasis in the 5xFAD mouse model of Alzheimer's disease.

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] § Methods › Statistical analysis ↔ TREM2-metabolomics-figures-final-v3.R, lines 4423–4472 · score 0.72 · Venn diagrams, ggVennDiagram, brain liver, brain plasma, Genes, heatmaps
  2. [2] § Results › Effects of genotype along the liver-plasma-brain axis ↔ TREM2-metabolomics-figures-final-v3.R, lines 4423–4472 · score 0.56 · Venn diagrams, comparing brain liver, brain plasma, analytes, xFAD, Spearman

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 · 4,577 lines · 195 KB · MIT · 2 matches

  1. rm(list=ls())
  2. library(tidyverse)
  3. library(readxl)
  4. library(vegan)
  5. library(pairwiseAdonis)
  6. library(pheatmap)
  7. library(ggpubr)
  8. library(dplyr)
  9. library(RColorBrewer)
  10. library(FSA)
  11. library(viridis)
  12. #setwd("/media/gfaraci/model-AD/TREM2")
  13. setwd("C:/Users/Gina Faraci/Documents/R/model-AD/TREM2 metabolome/From Julio")
  14. #z-score function
  15. z_score <- function(x){
  16. (x - mean(x)) / sd(x)
  17. }
  18. #save_pheatmap function by mathzero: https://gist.github.com/mathzero/a2070a24a6b418740c44a5c023f5c01e
  19. save_pheatmap <- function(x, filename, width=12, height=12){
  20. stopifnot(!missing(x))
  21. stopifnot(!missing(filename))
  22. if(grepl(".png",filename)){
  23. png(filename, width=width, height=height, units = "in", res=600)
  24. grid::grid.newpage()
  25. grid::grid.draw(x$gtable)
  26. dev.off()
  27. }
  28. else if(grepl(".pdf",filename)){
  29. pdf(filename, width=width, height=height)
  30. grid::grid.newpage()
  31. grid::grid.draw(x$gtable)
  32. dev.off()
  33. }
  34. else{
  35. print("Filename did not contain '.png' or '.pdf'")
  36. }
  37. }
  38. ##############Preparing data##############
  39. #Metadata
  40. metadata = read.delim("metadata.txt")
  41. metadata$Name = as.character(metadata$Name)
  42. metadata$Age = as.character(metadata$Age)
  43. #SampleIDs
  44. SampleIDs = read_excel("u54-ad-sample-list.xlsx",
  45. col_types = c("text", "text", "skip",
  46. "skip", "skip", "skip"))
  47. #Importing and wrangling data
  48. plasma_lip_df = as.data.frame(t(read.csv("u54_ad_batch_corrected_data_TL_raw.csv", row.names = 1, check.names = F))) %>%
  49. replace(is.na(.), 0) %>%
  50. rownames_to_column(var = "tm_id") %>%
  51. inner_join(SampleIDs) %>%
  52. select(!tm_id) %>%
  53. pivot_longer(!sample_id) %>%
  54. mutate(sample_id = paste0(sample_id, "_plasma"))
  55. plasma_tar_df = as.data.frame(t(read.csv("u54_ad_batch_corrected_data_TM_raw.csv", row.names = 1, check.names = F))) %>%
  56. replace(is.na(.), 0) %>%
  57. rownames_to_column(var = "tm_id") %>%
  58. inner_join(SampleIDs) %>%
  59. select(!tm_id) %>%
  60. pivot_longer(!sample_id) %>%
  61. mutate(sample_id = paste0(sample_id, "_plasma"))
  62. liver_df = read_excel("20220519_mapstone_ad_model_liver_107_5500QTRAP_data_combined.xlsx", col_names = F)
  63. names(liver_df) = liver_df[2,]
  64. names(liver_df)[2:3] = c("Common name", "Mode")
  65. liver_df = liver_df[-(1:2),]
  66. liver_lip_df = liver_df %>%
  67. filter(Mode == "Targeted lipidomics") %>%
  68. select(!c(`Common name`, Mode)) %>%
  69. column_to_rownames(var = "Sample IDs")
  70. liver_lip_df = as.data.frame(t(liver_lip_df)) %>%
  71. replace(is.na(.), 0) %>%
  72. rownames_to_column(var = "sample_id") %>%
  73. pivot_longer(!sample_id) %>%
  74. mutate(sample_id = paste0(sample_id, "_liver"))
  75. liver_lip_df$value = as.numeric(liver_lip_df$value) #Abundance was character
  76. liver_tar_df = liver_df %>%
  77. filter(Mode == "Tarrgeted Metabolomics") %>%
  78. select(!c(`Common name`, Mode)) %>%
  79. column_to_rownames(var = "Sample IDs")
  80. liver_tar_df = as.data.frame(t(liver_tar_df)) %>%
  81. replace(is.na(.), 0) %>%
  82. rownames_to_column(var = "sample_id") %>%
  83. pivot_longer(!sample_id) %>%
  84. mutate(sample_id = paste0(sample_id, "_liver"))
  85. liver_tar_df$value = as.numeric(liver_tar_df$value) #Abundance was character
  86. brain_df = read_excel("20220519_mapstone_ad_model_cortex_159_5500QTRAP_combined_data.xlsx", col_names = F)
  87. names(brain_df) = brain_df[2,]
  88. brain_df = brain_df[-(1:2),]
  89. brain_lip_df = brain_df %>%
  90. select(!`9732`) %>% #This sample ID is duplicated for whatever reason
  91. filter(Mode == "Targeted lipidomics") %>%
  92. select(!c(`Sample IDs`, Mode)) %>%
  93. column_to_rownames(var = "Metabolites")
  94. brain_lip_df = as.data.frame(t(brain_lip_df)) %>%
  95. replace(is.na(.), 0) %>%
  96. rownames_to_column(var = "sample_id") %>%
  97. pivot_longer(!sample_id) %>%
  98. mutate(sample_id = paste0(sample_id, "_brain"))
  99. brain_tar_df = brain_df %>%
  100. select(!`9732`) %>% #This sample ID is duplicated for whatever reason
  101. filter(Mode == "Targeted Metabolomics") %>%
  102. select(!c(`Sample IDs`, Mode)) %>%
  103. column_to_rownames(var = "Metabolites")
  104. brain_tar_df = as.data.frame(t(brain_tar_df)) %>%
  105. replace(is.na(.), 0) %>%
  106. rownames_to_column(var = "sample_id") %>%
  107. pivot_longer(!sample_id) %>%
  108. mutate(sample_id = paste0(sample_id, "_brain"))
  109. #Combining dataframes
  110. #Keeping targeted metabolomics and lipidomics seperate.
  111. lip_df_combined = bind_rows(plasma_lip_df, brain_lip_df, liver_lip_df) %>%
  112. pivot_wider(id_cols = "sample_id", names_from = "name", values_from = "value") %>%
  113. separate_wider_delim(cols = sample_id, names = c("Name", "Mode"), delim = "_", cols_remove = F) %>%
  114. inner_join(metadata) %>%
  115. filter(!sample_id %in% c("9379_plasma", "7772_plasma", "20740_brain"), !Age == "18") %>%
  116. relocate(CageID:Background, .after = sample_id)
  117. lip_df_combined[,-(1:12)] = lip_df_combined[,-(1:12)] %>% #No normalization
  118. replace(is.na(.), 0)
  119. #Use the following lines instead for PERMANOVAs and PCAs
  120. # lip_df_combined[,-(1:12)] = log10(lip_df_combined[,-(1:12)]) %>% #Normalization
  121. # replace(is.na(.), 0)
  122. #Export for future microbiome studies
  123. write.table(lip_df_combined, "./lip_df_combined.txt", sep = "\t", row.names = TRUE, quote=FALSE)
  124. #Shapiro-Wilk normality test
  125. #if p < 0.05 the data is not normally distributed
  126. #if p > 0.05 the data is normally distributed
  127. s.test <- as.data.frame(sapply(lip_df_combined[,-(1:12)], as.numeric))
  128. shapiro_results <- apply(s.test, 2, shapiro.test)
  129. s.list <- numeric(length(967))
  130. for (i in 1:967){
  131. if (shapiro_results[[i]]$p.value > 0.05){
  132. s.list[[i]] <- 1
  133. } else {
  134. s.list[[i]] <- 0
  135. }
  136. }
  137. # data is NOT normally distributed
  138. tar_df_combined = bind_rows(plasma_tar_df, brain_tar_df, liver_tar_df) %>%
  139. pivot_wider(id_cols = "sample_id", names_from = "name", values_from = "value") %>%
  140. separate_wider_delim(cols = sample_id, names = c("Name", "Mode"), delim = "_", cols_remove = F) %>%
  141. inner_join(metadata) %>%
  142. filter(!Age == "18") %>%
  143. relocate(CageID:Background, .after = sample_id)
  144. tar_df_combined[,-(1:12)] = tar_df_combined[,-(1:12)] %>% #No normalization
  145. replace(is.na(.), 0)
  146. #Use the following lines instead for PERMANOVAs and PCAs
  147. # tar_df_combined[,-(1:12)] = log10(tar_df_combined[,-(1:12)]) %>% #Normalization
  148. # replace(is.na(.), 0)
  149. #Export for future microbiome studies
  150. write.table(tar_df_combined, "./tar_df_combined.txt", sep = "\t", row.names = TRUE, quote=FALSE)
  151. #Shapiro-Wilk normality test
  152. #if p < 0.05 the data is not normally distributed
  153. #if p > 0.05 the data is normally distributed
  154. s.test <- as.data.frame(sapply(tar_df_combined[,-(1:12)], as.numeric))
  155. shapiro_results <- apply(s.test, 2, shapiro.test)
  156. s.list <- numeric(length(324))
  157. for (i in 1:324){
  158. if (shapiro_results[[i]]$p.value > 0.05){
  159. s.list[[i]] <- 1
  160. } else {
  161. s.list[[i]] <- 0
  162. }
  163. }
  164. # data is NOT normally distributed
  165. ##############
  166. ##############Metadata analysis (misc)##############
  167. ##Count sample numbers (Table 1) AND
  168. ##Are there sig. differences in mouse weight between genotypes?
  169. metadata_wt = read_excel("metadata-weights.xlsx")
  170. weight_df = metadata_wt[metadata_wt$Age != 18, ] #182 samples
  171. wt_counts <- weight_df[weight_df$Group2 == "WT 5xFAD", ] #65 WT
  172. wt_4mo_counts <- wt_counts[wt_counts$Age == "4", ] #27 4mo
  173. wt_4mo_f_counts <- wt_4mo_counts[wt_4mo_counts$Sex == "F", ] #13 females
  174. wt_4mo_m_counts <- wt_4mo_counts[wt_4mo_counts$Sex == "M", ] #14 males
  175. wt_12mo_counts <- wt_counts[wt_counts$Age == "12", ] #38 12mo
  176. wt_12mo_f_counts <- wt_12mo_counts[wt_12mo_counts$Sex == "F", ] #17 females
  177. wt_12mo_m_counts <- wt_12mo_counts[wt_12mo_counts$Sex == "M", ] #21 males
  178. fad_counts <- weight_df[weight_df$Group2 == "HEMI 5xFAD", ] #65 5xFAD
  179. #note, 20737 and 20735 we did not collect data for (both 12mo females)
  180. fad_4mo_counts <- fad_counts[fad_counts$Age == "4", ] #28 4mo
  181. fad_4mo_f_counts <- fad_4mo_counts[fad_4mo_counts$Sex == "F", ] #14 females
  182. fad_4mo_m_counts <- fad_4mo_counts[fad_4mo_counts$Sex == "M", ] #14 males
  183. fad_12mo_counts <- fad_counts[fad_counts$Age == "12", ] #37->35 12mo
  184. fad_12mo_f_counts <- fad_12mo_counts[fad_12mo_counts$Sex == "F", ] #19->17 females
  185. fad_12mo_m_counts <- fad_12mo_counts[fad_12mo_counts$Sex == "M", ] #18 males
  186. t2_counts <- weight_df[weight_df$Group2 == "WT 5xFAD_TREM2", ] #27 TREM2
  187. t2_4mo_counts <- t2_counts[t2_counts$Age == "4", ] #10 4mo
  188. t2_4mo_f_counts <- t2_4mo_counts[t2_4mo_counts$Sex == "F", ] #5 females
  189. t2_4mo_m_counts <- t2_4mo_counts[t2_4mo_counts$Sex == "M", ] #5 males
  190. t2_12mo_counts <- t2_counts[t2_counts$Age == "12", ] #17 12mo
  191. t2_12mo_f_counts <- t2_12mo_counts[t2_12mo_counts$Sex == "F", ] #8 females
  192. t2_12mo_m_counts <- t2_12mo_counts[t2_12mo_counts$Sex == "M", ] #9 males
  193. fadt2_counts <- weight_df[weight_df$Group2 == "HEMI 5xFAD_TREM2", ] #25 5xFAD, TREM2
  194. fadt2_4mo_counts <- fadt2_counts[fadt2_counts$Age == "4", ] #10 4mo
  195. fadt2_4mo_f_counts <- fadt2_4mo_counts[fadt2_4mo_counts$Sex == "F", ] #5 females
  196. fadt2_4mo_m_counts <- fadt2_4mo_counts[fadt2_4mo_counts$Sex == "M", ] #5 males
  197. fadt2_12mo_counts <- fadt2_counts[fadt2_counts$Age == "12", ] #15 12mo
  198. fadt2_12mo_f_counts <- fadt2_12mo_counts[fadt2_12mo_counts$Sex == "F", ] #8 females
  199. fadt2_12mo_m_counts <- fadt2_12mo_counts[fadt2_12mo_counts$Sex == "M", ] #7 males
  200. plasma_counts <- tar_df_combined[tar_df_combined$Mode == "plasma", ] #164 plasma samples
  201. wt_plasma_counts <- plasma_counts[plasma_counts$Group2 == "WT 5xFAD", ] #58 WT samples
  202. wt_4mo_plasma_counts <- wt_plasma_counts[wt_plasma_counts$Age == "4", ] #25 4mo
  203. wt_4mo_f_plasma_counts <- wt_4mo_plasma_counts[wt_4mo_plasma_counts$Sex == "F", ] #12 females
  204. wt_4mo_m_plasma_counts <- wt_4mo_plasma_counts[wt_4mo_plasma_counts$Sex == "M", ] #13 males
  205. wt_12mo_plasma_counts <- wt_plasma_counts[wt_plasma_counts$Age == "12", ] #33 12mo
  206. wt_12mo_f_plasma_counts <- wt_12mo_plasma_counts[wt_12mo_plasma_counts$Sex == "F", ] #15 females
  207. wt_12mo_m_plasma_counts <- wt_12mo_plasma_counts[wt_12mo_plasma_counts$Sex == "M", ] #18 males
  208. fad_plasma_counts <- plasma_counts[plasma_counts$Group2 == "HEMI 5xFAD", ] #56 5xFAD samples
  209. fad_4mo_plasma_counts <- fad_plasma_counts[fad_plasma_counts$Age == "4", ] #26 4mo
  210. fad_4mo_f_plasma_counts <- fad_4mo_plasma_counts[fad_4mo_plasma_counts$Sex == "F", ] #13 females
  211. fad_4mo_m_plasma_counts <- fad_4mo_plasma_counts[fad_4mo_plasma_counts$Sex == "M", ] #13 males
  212. fad_12mo_plasma_counts <- fad_plasma_counts[fad_plasma_counts$Age == "12", ] #30 12mo
  213. fad_12mo_f_plasma_counts <- fad_12mo_plasma_counts[fad_12mo_plasma_counts$Sex == "F", ] #15 females
  214. fad_12mo_m_plasma_counts <- fad_12mo_plasma_counts[fad_12mo_plasma_counts$Sex == "M", ] #15 males
  215. t2_plasma_counts <- plasma_counts[plasma_counts$Group2 == "WT 5xFAD_TREM2", ] #27 TREM2 samples
  216. t2_4mo_plasma_counts <- t2_plasma_counts[t2_plasma_counts$Age == "4", ] #10 4mo
  217. t2_4mo_f_plasma_counts <- t2_4mo_plasma_counts[t2_4mo_plasma_counts$Sex == "F", ] #5 females
  218. t2_4mo_m_plasma_counts <- t2_4mo_plasma_counts[t2_4mo_plasma_counts$Sex == "M", ] #5 males
  219. t2_12mo_plasma_counts <- t2_plasma_counts[t2_plasma_counts$Age == "12", ] #17 12mo
  220. t2_12mo_f_plasma_counts <- t2_12mo_plasma_counts[t2_12mo_plasma_counts$Sex == "F", ] #8 females
  221. t2_12mo_m_plasma_counts <- t2_12mo_plasma_counts[t2_12mo_plasma_counts$Sex == "M", ] #9 males
  222. fadt2_plasma_counts <- plasma_counts[plasma_counts$Group2 == "HEMI 5xFAD_TREM2", ] #23 5xFAD, TREM2 samples
  223. fadt2_4mo_plasma_counts <- fadt2_plasma_counts[fadt2_plasma_counts$Age == "4", ] #10 4mo
  224. fadt2_4mo_f_plasma_counts <- fadt2_4mo_plasma_counts[fadt2_4mo_plasma_counts$Sex == "F", ] #5 females
  225. fadt2_4mo_m_plasma_counts <- fadt2_4mo_plasma_counts[fadt2_4mo_plasma_counts$Sex == "M", ] #5 males
  226. fadt2_12mo_plasma_counts <- fadt2_plasma_counts[fadt2_plasma_counts$Age == "12", ] #13 12mo
  227. fadt2_12mo_f_plasma_counts <- fadt2_12mo_plasma_counts[fadt2_12mo_plasma_counts$Sex == "F", ] #6 females
  228. fadt2_12mo_m_plasma_counts <- fadt2_12mo_plasma_counts[fadt2_12mo_plasma_counts$Sex == "M", ] #7 males
  229. liver_counts <- tar_df_combined[tar_df_combined$Mode == "liver", ] #105 liver samples
  230. wt_liver_counts <- liver_counts[liver_counts$Group2 == "WT 5xFAD", ] #34 WT samples
  231. wt_4mo_liver_counts <- wt_liver_counts[wt_liver_counts$Age == "4", ] #17 4mo
  232. wt_4mo_f_liver_counts <- wt_4mo_liver_counts[wt_4mo_liver_counts$Sex == "F", ] #8 females
  233. wt_4mo_m_liver_counts <- wt_4mo_liver_counts[wt_4mo_liver_counts$Sex == "M", ] #9 males
  234. wt_12mo_liver_counts <- wt_liver_counts[wt_liver_counts$Age == "12", ] #17 12mo
  235. wt_12mo_f_liver_counts <- wt_12mo_liver_counts[wt_12mo_liver_counts$Sex == "F", ] #7 females
  236. wt_12mo_m_liver_counts <- wt_12mo_liver_counts[wt_12mo_liver_counts$Sex == "M", ] #10 males
  237. fad_liver_counts <- liver_counts[liver_counts$Group2 == "HEMI 5xFAD", ] #31 5xFAD samples
  238. fad_4mo_liver_counts <- fad_liver_counts[fad_liver_counts$Age == "4", ] #18 4mo
  239. fad_4mo_f_liver_counts <- fad_4mo_liver_counts[fad_4mo_liver_counts$Sex == "F", ] #9 females
  240. fad_4mo_m_liver_counts <- fad_4mo_liver_counts[fad_4mo_liver_counts$Sex == "M", ] #9 males
  241. fad_12mo_liver_counts <- fad_liver_counts[fad_liver_counts$Age == "12", ] #13 12mo
  242. fad_12mo_f_liver_counts <- fad_12mo_liver_counts[fad_12mo_liver_counts$Sex == "F", ] #6 females
  243. fad_12mo_m_liver_counts <- fad_12mo_liver_counts[fad_12mo_liver_counts$Sex == "M", ] #7 males
  244. t2_liver_counts <- liver_counts[liver_counts$Group2 == "WT 5xFAD_TREM2", ] #21 TREM2 samples
  245. t2_4mo_liver_counts <- t2_liver_counts[t2_liver_counts$Age == "4", ] #10 4mo
  246. t2_4mo_f_liver_counts <- t2_4mo_liver_counts[t2_4mo_liver_counts$Sex == "F", ] #5 females
  247. t2_4mo_m_liver_counts <- t2_4mo_liver_counts[t2_4mo_liver_counts$Sex == "M", ] #5 males
  248. t2_12mo_liver_counts <- t2_liver_counts[t2_liver_counts$Age == "12", ] #11 12mo
  249. t2_12mo_f_liver_counts <- t2_12mo_liver_counts[t2_12mo_liver_counts$Sex == "F", ] #2 females
  250. t2_12mo_m_liver_counts <- t2_12mo_liver_counts[t2_12mo_liver_counts$Sex == "M", ] #9 males
  251. fadt2_liver_counts <- liver_counts[liver_counts$Group2 == "HEMI 5xFAD_TREM2", ] #19 5xFAD, TREM2 samples
  252. fadt2_4mo_liver_counts <- fadt2_liver_counts[fadt2_liver_counts$Age == "4", ] #10 4mo
  253. fadt2_4mo_f_liver_counts <- fadt2_4mo_liver_counts[fadt2_4mo_liver_counts$Sex == "F", ] #5 females
  254. fadt2_4mo_m_liver_counts <- fadt2_4mo_liver_counts[fadt2_4mo_liver_counts$Sex == "M", ] #5 males
  255. fadt2_12mo_liver_counts <- fadt2_liver_counts[fadt2_liver_counts$Age == "12", ] #9 12mo
  256. fadt2_12mo_f_liver_counts <- fadt2_12mo_liver_counts[fadt2_12mo_liver_counts$Sex == "F", ] #2 females
  257. fadt2_12mo_m_liver_counts <- fadt2_12mo_liver_counts[fadt2_12mo_liver_counts$Sex == "M", ] #7 males
  258. brain_counts <- tar_df_combined[tar_df_combined$Mode == "brain", ] #133 brain samples
  259. wt_brain_counts <- brain_counts[brain_counts$Group2 == "WT 5xFAD", ] #45 WT samples
  260. wt_4mo_brain_counts <- wt_brain_counts[wt_brain_counts$Age == "4", ] #17 4mo
  261. wt_4mo_f_brain_counts <- wt_4mo_brain_counts[wt_4mo_brain_counts$Sex == "F", ] #8 females
  262. wt_4mo_m_brain_counts <- wt_4mo_brain_counts[wt_4mo_brain_counts$Sex == "M", ] #9 males
  263. wt_12mo_brain_counts <- wt_brain_counts[wt_brain_counts$Age == "12", ] #28 12mo
  264. wt_12mo_f_brain_counts <- wt_12mo_brain_counts[wt_12mo_brain_counts$Sex == "F", ] #12 females
  265. wt_12mo_m_brain_counts <- wt_12mo_brain_counts[wt_12mo_brain_counts$Sex == "M", ] #16 males
  266. fad_brain_counts <- brain_counts[brain_counts$Group2 == "HEMI 5xFAD", ] #42 5xFAD samples
  267. fad_4mo_brain_counts <- fad_brain_counts[fad_brain_counts$Age == "4", ] #17 4mo
  268. fad_4mo_f_brain_counts <- fad_4mo_brain_counts[fad_4mo_brain_counts$Sex == "F", ] #9 females
  269. fad_4mo_m_brain_counts <- fad_4mo_brain_counts[fad_4mo_brain_counts$Sex == "M", ] #8 males
  270. fad_12mo_brain_counts <- fad_brain_counts[fad_brain_counts$Age == "12", ] #25 12mo
  271. fad_12mo_f_brain_counts <- fad_12mo_brain_counts[fad_12mo_brain_counts$Sex == "F", ] #12 females
  272. fad_12mo_m_brain_counts <- fad_12mo_brain_counts[fad_12mo_brain_counts$Sex == "M", ] #13 males
  273. t2_brain_counts <- brain_counts[brain_counts$Group2 == "WT 5xFAD_TREM2", ] #24 TREM2 samples
  274. t2_4mo_brain_counts <- t2_brain_counts[t2_brain_counts$Age == "4", ] #10 4mo
  275. t2_4mo_f_brain_counts <- t2_4mo_brain_counts[t2_4mo_brain_counts$Sex == "F", ] #5 females
  276. t2_4mo_m_brain_counts <- t2_4mo_brain_counts[t2_4mo_brain_counts$Sex == "M", ] #5 males
  277. t2_12mo_brain_counts <- t2_brain_counts[t2_brain_counts$Age == "12", ] #14 12mo
  278. t2_12mo_f_brain_counts <- t2_12mo_brain_counts[t2_12mo_brain_counts$Sex == "F", ] #8 females
  279. t2_12mo_m_brain_counts <- t2_12mo_brain_counts[t2_12mo_brain_counts$Sex == "M", ] #6 males
  280. fadt2_brain_counts <- brain_counts[brain_counts$Group2 == "HEMI 5xFAD_TREM2", ] #22 5xFAD, TREM2 samples
  281. fadt2_4mo_brain_counts <- fadt2_brain_counts[fadt2_brain_counts$Age == "4", ] #9 4mo
  282. fadt2_4mo_f_brain_counts <- fadt2_4mo_brain_counts[fadt2_4mo_brain_counts$Sex == "F", ] #4 females
  283. fadt2_4mo_m_brain_counts <- fadt2_4mo_brain_counts[fadt2_4mo_brain_counts$Sex == "M", ] #5 males
  284. fadt2_12mo_brain_counts <- fadt2_brain_counts[fadt2_brain_counts$Age == "12", ] #13 12mo
  285. fadt2_12mo_f_brain_counts <- fadt2_12mo_brain_counts[fadt2_12mo_brain_counts$Sex == "F", ] #8 females
  286. fadt2_12mo_m_brain_counts <- fadt2_12mo_brain_counts[fadt2_12mo_brain_counts$Sex == "M", ] #5 males
  287. ##Table S1
  288. library(ggVennDiagram)
  289. set.seed(20231214)
  290. #WT tissues
  291. brain <- wt_brain_counts$Name
  292. plasma <- wt_plasma_counts$Name
  293. liver <- wt_liver_counts$Name
  294. wt <- list(brain=brain,
  295. plasma=plasma,
  296. liver=liver)
  297. ggVennDiagram(wt) +
  298. scale_fill_gradient(low="grey90",high ="red")
  299. ggVennDiagram(wt, show_intersect = TRUE)
  300. #5xFAD tissues
  301. brain <- fad_brain_counts$Name
  302. plasma <- fad_plasma_counts$Name
  303. liver <- fad_liver_counts$Name
  304. fad <- list(brain=brain,
  305. plasma=plasma,
  306. liver=liver)
  307. ggVennDiagram(fad) +
  308. scale_fill_gradient(low="grey90",high ="red")
  309. ggVennDiagram(fad, show_intersect = TRUE)
  310. #TREM2 tissues
  311. brain <- t2_brain_counts$Name
  312. plasma <- t2_plasma_counts$Name
  313. liver <- t2_liver_counts$Name
  314. t2 <- list(brain=brain,
  315. plasma=plasma,
  316. liver=liver)
  317. ggVennDiagram(t2) +
  318. scale_fill_gradient(low="grey90",high ="red")
  319. ggVennDiagram(t2, show_intersect = TRUE)
  320. #5xFAD, TREM2 tissues
  321. brain <- fadt2_brain_counts$Name
  322. plasma <- fadt2_plasma_counts$Name
  323. liver <- fadt2_liver_counts$Name
  324. fadt2 <- list(brain=brain,
  325. plasma=plasma,
  326. liver=liver)
  327. ggVennDiagram(fadt2) +
  328. scale_fill_gradient(low="grey90",high ="red")
  329. ggVennDiagram(fadt2, show_intersect = TRUE)
  330. ##Kruskal-Wallis test with post-hoc Dunn’s test (all ages)
  331. #Extract relevant columns
  332. kw_df <- weight_df[, c("Group2", "Age", "Sex", "Weight (g)")]
  333. kw_df <- na.omit(kw_df)
  334. #Shapiro-Wilk normality test
  335. #if p < 0.05 the data is not normally distributed
  336. #if p > 0.05 the data is normally distributed
  337. shapiro.test(kw_df$`Weight (g)`)
  338. # W = 0.98562, p-value = 0.104
  339. # data IS normally distributed
  340. anova <- aov(`Weight (g)` ~ Group2, data=kw_df)
  341. summary(anova)
  342. # Df Sum Sq Mean Sq F value Pr(>F)
  343. # Group2 3 537 179.00 5.692 0.00101 **
  344. # Residuals 153 4812 31.45
  345. TukeyHSD(anova)
  346. # diff lwr upr p adj
  347. # HEMI 5xFAD_TREM2-HEMI 5xFAD -2.8470588 -6.4035394 0.7094217 0.1645015
  348. # WT 5xFAD-HEMI 5xFAD 2.2177560 -0.6265834 5.0620954 0.1832385
  349. # WT 5xFAD_TREM2-HEMI 5xFAD 2.3455338 -1.1214281 5.8124956 0.2980466
  350. # WT 5xFAD-HEMI 5xFAD_TREM2 5.0648148 1.5409812 8.5886484 0.0015034 **
  351. # WT 5xFAD_TREM2-HEMI 5xFAD_TREM2 5.1925926 1.1494550 9.2357302 0.0058232 **
  352. # WT 5xFAD_TREM2-WT 5xFAD 0.1277778 -3.3056861 3.5612416 0.9996751
  353. ##Violin plot
  354. TREM2_tar_df = kw_df
  355. TREM2_tar_df <- TREM2_tar_df %>%
  356. mutate(., Group2 = stringr::str_replace(Group2, "WT 5xFAD_TREM2", "TREM2")) %>%
  357. mutate(., Group2 = stringr::str_replace(Group2, "WT 5xFAD", "WT")) %>%
  358. mutate(., Group2 = stringr::str_replace(Group2, "HEMI 5xFAD_TREM2", "5xFAD*TREM2")) %>%
  359. mutate(., Group2 = stringr::str_replace(Group2, "HEMI 5xFAD", "5xFAD"))
  360. gwsC <- c("forestgreen", "gold", "steelblue1", "firebrick3")
  361. p <- ggplot(TREM2_tar_df, aes(x=Group2, y=`Weight (g)`, fill=Group2)) +
  362. geom_violin(trim=FALSE, scale="area") +
  363. theme_bw() +
  364. #ylim(-3.2,2.2) +
  365. stat_summary(fun=mean, geom="point", shape=23, size=2, fill="yellow") +
  366. geom_point(aes(shape=Sex), position=position_jitter(0.2)) +
  367. scale_fill_manual(breaks=c("TREM2", "WT", "5xFAD*TREM2", "5xFAD"), values = gwsC) +
  368. labs(y = "Weight (g)") +
  369. scale_x_discrete(limits=c("TREM2", "WT", "5xFAD*TREM2", "5xFAD")) +
  370. theme(axis.title.y = element_text(margin = margin(t = 0, r = 10, b = 0, l = 0)),
  371. axis.title.x=element_blank(),
  372. panel.grid.major = element_blank(),
  373. panel.grid.minor = element_blank())
  374. p
  375. ##Kruskal-Wallis test with post-hoc Dunn’s test (4-months)
  376. #Extract relevant columns
  377. kw_df <- weight_df[, c("Group2", "Age", "Sex", "Weight (g)")]
  378. kw_df <- na.omit(kw_df)
  379. kw_df = kw_df %>% filter(Age == 4)
  380. #Shapiro-Wilk normality test
  381. #if p < 0.05 the data is not normally distributed
  382. #if p > 0.05 the data is normally distributed
  383. shapiro.test(kw_df$`Weight (g)`)
  384. # W = 0.97723, p-value = 0.1951
  385. # data IS normally distributed
  386. anova <- aov(`Weight (g)` ~ Group2, data=kw_df)
  387. summary(anova)
  388. # Df Sum Sq Mean Sq F value Pr(>F)
  389. # Group2 3 78.5 26.16 0.842 0.475
  390. # Residuals 71 2204.9 31.05
  391. ##Violin plot
  392. TREM2_tar_df = kw_df
  393. TREM2_tar_df <- TREM2_tar_df %>%
  394. mutate(., Group2 = stringr::str_replace(Group2, "WT 5xFAD_TREM2", "TREM2")) %>%
  395. mutate(., Group2 = stringr::str_replace(Group2, "WT 5xFAD", "WT")) %>%
  396. mutate(., Group2 = stringr::str_replace(Group2, "HEMI 5xFAD_TREM2", "5xFAD*TREM2")) %>%
  397. mutate(., Group2 = stringr::str_replace(Group2, "HEMI 5xFAD", "5xFAD"))
  398. gwsC <- c("forestgreen", "gold", "steelblue1", "firebrick3")
  399. p1 <- ggplot(TREM2_tar_df, aes(x=Group2, y=`Weight (g)`, fill=Group2)) +
  400. geom_boxplot(trim=FALSE, scale="area") +
  401. theme_bw() +
  402. #ylim(-3.2,2.2) +
  403. stat_summary(fun=mean, geom="point", shape=23, size=2, fill="yellow") +
  404. geom_point(aes(shape=Sex), position=position_jitter(0.2)) +
  405. scale_fill_manual(breaks=c("TREM2", "WT", "5xFAD*TREM2", "5xFAD"), values = gwsC) +
  406. labs(y = "Weight (g)") +
  407. scale_x_discrete(limits=c("TREM2", "WT", "5xFAD*TREM2", "5xFAD")) +
  408. theme(axis.title.y = element_text(margin = margin(t = 0, r = 10, b = 0, l = 0)),
  409. axis.title.x=element_blank(),
  410. panel.grid.major = element_blank(),
  411. panel.grid.minor = element_blank())
  412. p1
  413. ##Kruskal-Wallis test with post-hoc Dunn’s test (12-months)
  414. #Extract relevant columns
  415. kw_df <- weight_df[, c("Group2", "Age", "Sex", "Weight (g)")]
  416. kw_df <- na.omit(kw_df)
  417. kw_df = kw_df %>% filter(Age == 12)
  418. #Shapiro-Wilk normality test
  419. #if p < 0.05 the data is not normally distributed
  420. #if p > 0.05 the data is normally distributed
  421. shapiro.test(kw_df$`Weight (g)`)
  422. # W = 0.98039, p-value = 0.2429
  423. # data IS normally distributed
  424. anova <- aov(`Weight (g)` ~ Group2, data=kw_df)
  425. summary(anova)
  426. # Df Sum Sq Mean Sq F value Pr(>F)
  427. # Group2 3 648 216.00 7.488 0.000181 ***
  428. # Residuals 78 2250 28.85
  429. TukeyHSD(anova)
  430. # diff lwr upr p adj
  431. # HEMI 5xFAD_TREM2-HEMI 5xFAD -2.6681159 -7.3477490 2.011517 0.4443203
  432. # WT 5xFAD-HEMI 5xFAD 4.4429952 0.4419933 8.443997 0.0235102 *
  433. # WT 5xFAD_TREM2-HEMI 5xFAD 4.0416880 -0.4682562 8.551632 0.0950913
  434. # WT 5xFAD-HEMI 5xFAD_TREM2 7.1111111 2.5703706 11.651852 0.0005502 ***
  435. # WT 5xFAD_TREM2-HEMI 5xFAD_TREM2 6.7098039 1.7148159 11.704792 0.0038780 **
  436. # WT 5xFAD_TREM2-WT 5xFAD -0.4013072 -4.7669635 3.964349 0.9950176
  437. ##Violin plot
  438. TREM2_tar_df = kw_df
  439. TREM2_tar_df <- TREM2_tar_df %>%
  440. mutate(., Group2 = stringr::str_replace(Group2, "WT 5xFAD_TREM2", "TREM2")) %>%
  441. mutate(., Group2 = stringr::str_replace(Group2, "WT 5xFAD", "WT")) %>%
  442. mutate(., Group2 = stringr::str_replace(Group2, "HEMI 5xFAD_TREM2", "5xFAD*TREM2")) %>%
  443. mutate(., Group2 = stringr::str_replace(Group2, "HEMI 5xFAD", "5xFAD"))
  444. gwsC <- c("forestgreen", "gold", "steelblue1", "firebrick3")
  445. p2 <- ggplot(TREM2_tar_df, aes(x=Group2, y=`Weight (g)`, fill=Group2)) +
  446. geom_boxplot(trim=FALSE, scale="area") +
  447. theme_bw() +
  448. #ylim(-3.2,2.2) +
  449. stat_summary(fun=mean, geom="point", shape=23, size=2, fill="yellow") +
  450. geom_point(aes(shape=Sex), position=position_jitter(0.2)) +
  451. scale_fill_manual(breaks=c("TREM2", "WT", "5xFAD*TREM2", "5xFAD"), values = gwsC) +
  452. labs(y = "Weight (g)") +
  453. scale_x_discrete(limits=c("TREM2", "WT", "5xFAD*TREM2", "5xFAD")) +
  454. theme(axis.title.y = element_text(margin = margin(t = 0, r = 10, b = 0, l = 0)),
  455. axis.title.x=element_blank(),
  456. panel.grid.major = element_blank(),
  457. panel.grid.minor = element_blank())
  458. p2
  459. ggarrange(p1, p2, ncol=2, nrow=1, common.legend = TRUE, legend="right")
  460. ggsave("Figure_for_review.png", width = 11, height = 4.5)
  461. ##############
  462. ##############PERMANOVAs##############
  463. #PERMANOVA (Supplemental Figures 1, 2, and 3)
  464. #Repeat for all Mode-Age combinations (liver, plasma, brain - 4, 12)
  465. #To calculate for males and females separately, add Sex == "M" or "F" to lines 155 and 160, and use ~ Group2 in lines 157 and 162
  466. lip_perma_df = lip_df_combined %>%
  467. filter(Mode == "brain", Age == 12) %>%
  468. column_to_rownames(var = "sample_id")
  469. pairwise.adonis2(select(lip_perma_df, !Name:Background) ~ Group2*Sex, data = lip_perma_df, nperm = 999, method = "euclidean")
  470. tar_perma_df = tar_df_combined %>%
  471. filter(Mode == "brain", Age == 12) %>%
  472. column_to_rownames(var = "sample_id")
  473. pairwise.adonis2(select(tar_perma_df, !Name:Background) ~ Group2*Sex, data = tar_perma_df, nperm = 999, method = "euclidean")
  474. #MAIN EFFECTS PERMANOVA (Figure 1C)
  475. #Repeat for all Modes (liver, plasma, brain)
  476. lip_perma_df = na.omit(lip_df_combined) %>%
  477. filter(Mode == "brain") %>% # Comment this line out when comparing all tissues, use ~ Group2+Sex+Age+Mode in line 168 below
  478. column_to_rownames(var = "sample_id")
  479. adonis2(select(lip_perma_df, !Name:Background) ~ Group2+Sex+Age, data = lip_perma_df, permutations = 9999, method = "euclidean")
  480. tar_perma_df = na.omit(tar_df_combined) %>%
  481. filter(Mode == "brain") %>% # Comment this line out when comparing all tissues, use ~ Group2+Sex+Age+Mode in line 173 below
  482. column_to_rownames(var = "sample_id")
  483. adonis2(select(tar_perma_df, !Name:Background) ~ Group2+Sex+Age, data = tar_perma_df, permutations = 9999, method = "euclidean")
  484. ##############
  485. ##############PCAs##############
  486. #Metadata
  487. tar_metadata <- tar_df_combined[,c(1:12)]
  488. lip_metadata <- lip_df_combined[,c(1:12)]
  489. tar_data_pcoa <- tar_df_combined %>% remove_rownames %>% column_to_rownames(var="sample_id")
  490. lip_data_pcoa <- lip_df_combined %>% remove_rownames %>% column_to_rownames(var="sample_id")
  491. ##Targmet
  492. dist_matrix = tar_data_pcoa %>%
  493. select(!Name:Background) %>%
  494. vegdist(., method = "euclidean")
  495. #PCoA - euclidean, with eigenvalues, calculated and normalized variance
  496. pcoa = cmdscale(dist_matrix, eig = T, k = nrow(tar_data_pcoa)-1, add = T)
  497. pcoa_eig = eigenvals(pcoa)
  498. pcoa_var = pcoa_eig/sum(pcoa_eig)
  499. pcoa_var[1:3] #First 3 axes
  500. pcoa_plot_df = as.data.frame(pcoa$points[,1:2]) %>%
  501. rownames_to_column(var = "sample_id") %>%
  502. inner_join(tar_metadata)
  503. shape_values<-c(21,24,22,3)
  504. gwsC <- c("firebrick3", "steelblue1", "gold", "forestgreen")
  505. ggplot(data = pcoa_plot_df, aes(x = V1, y = V2, fill = Group2)) +
  506. #stat_ellipse(aes(group = Mode, linetype = Mode, color = Group2), level = 0.95, show.legend = F, linewidth = 0.6) +
  507. geom_point(size = 3, alpha = 0.75, aes(shape=Mode)) +
  508. #geom_text(aes(label = sample_id)) +
  509. theme_bw() +
  510. guides(fill = guide_legend(override.aes = list(shape = 21))) +
  511. labs(fill = "Genotype") +
  512. labs(shape = "Tissue") +
  513. scale_shape_manual(values=shape_values) +
  514. scale_color_manual(values=gwsC) + scale_fill_manual(values=gwsC)+
  515. labs(x = bquote("PC1:"~.(round(pcoa_var[1]*100, digits = 1))~"%"),
  516. y = bquote("PC2:"~.(round(pcoa_var[2]*100, digits = 1))~"%"),
  517. title = "Targeted Metabolomics",
  518. subtitle = "Log10 normalized")
  519. ggsave("PCA-targmet.png", width = 6, height = 4.25)
  520. #PERMDISP (repeat for brain, plasma, and liver)
  521. permdisp = tar_data_pcoa %>%
  522. filter(Mode == "liver")
  523. dist_matrix = permdisp %>%
  524. select(!Name:Background) %>%
  525. vegdist(., method = "euclidean")
  526. pcoa.permdisp <- betadisper(dist_matrix,
  527. permdisp$Group2,
  528. type = c("median", "centroid"),
  529. bias.adjust = FALSE,
  530. sqrt.dist = FALSE,
  531. add = FALSE)
  532. anova(pcoa.permdisp)
  533. # Brain:
  534. # Response: Distances
  535. # Df Sum Sq Mean Sq F value Pr(>F)
  536. # Groups 3 0.963 0.32113 0.7277 0.5372
  537. # Residuals 129 56.925 0.44128
  538. #
  539. # Plasma:
  540. # Response: Distances
  541. # Df Sum Sq Mean Sq F value Pr(>F)
  542. # Groups 3 7.96 2.6521 0.9803 0.4036
  543. # Residuals 160 432.86 2.7054
  544. #
  545. # Liver:
  546. # Response: Distances
  547. # Df Sum Sq Mean Sq F value Pr(>F)
  548. # Groups 3 23.067 7.6889 3.1431 0.02852 *
  549. # Residuals 101 247.075 2.4463
  550. #
  551. # TukeyHSD(pcoa.permdisp)
  552. # diff lwr upr p adj
  553. # HEMI 5xFAD_TREM2-HEMI 5xFAD -0.4917491 -1.682191 0.6986930 0.7030365
  554. # WT 5xFAD-HEMI 5xFAD -0.7358761 -1.750528 0.2787763 0.2368776
  555. # WT 5xFAD_TREM2-HEMI 5xFAD -1.3257969 -2.480558 -0.1710360 0.0176508 *
  556. # WT 5xFAD-HEMI 5xFAD_TREM2 -0.2441270 -1.414441 0.9261875 0.9477112
  557. # WT 5xFAD_TREM2-HEMI 5xFAD_TREM2 -0.8340478 -2.127721 0.4596250 0.3373487
  558. # WT 5xFAD_TREM2-WT 5xFAD -0.5899208 -1.723921 0.5440794 0.5279217
  559. #
  560. # (Only the TREM2 vs 5xFAD genotype comparison was significant after post-hoc testing)
  561. ##Lipid
  562. dist_matrix = lip_data_pcoa %>%
  563. select(!Name:Background) %>%
  564. vegdist(., method = "euclidean")
  565. #PCoA - euclidean, with eigenvalues, calculated and normalized variance
  566. pcoa = cmdscale(dist_matrix, eig = T, k = nrow(lip_data_pcoa)-1, add = T)
  567. pcoa_eig = eigenvals(pcoa)
  568. pcoa_var = pcoa_eig/sum(pcoa_eig)
  569. pcoa_var[1:3] #First 3 axes
  570. pcoa_plot_df = as.data.frame(pcoa$points[,1:2]) %>%
  571. rownames_to_column(var = "sample_id") %>%
  572. inner_join(tar_metadata)
  573. shape_values<-c(21,24,22,3)
  574. gwsC <- c("firebrick3", "steelblue1", "gold", "forestgreen")
  575. ggplot(data = pcoa_plot_df, aes(x = V1, y = V2, fill = Group2)) +
  576. #stat_ellipse(aes(group = Mode, linetype = Mode, color = Group2), level = 0.95, show.legend = F, linewidth = 0.6) +
  577. geom_point(size = 3, alpha = 0.75, aes(shape=Mode)) +
  578. #geom_text(aes(label = sample_id)) +
  579. theme_bw() +
  580. guides(fill = guide_legend(override.aes = list(shape = 21))) +
  581. labs(fill = "Genotype") +
  582. labs(shape = "Tissue") +
  583. scale_shape_manual(values=shape_values) +
  584. scale_color_manual(values=gwsC) + scale_fill_manual(values=gwsC)+
  585. labs(x = bquote("PC1:"~.(round(pcoa_var[1]*100, digits = 1))~"%"),
  586. y = bquote("PC2:"~.(round(pcoa_var[2]*100, digits = 1))~"%"),
  587. title = "Lipidomics",
  588. subtitle = "Log10 normalized")
  589. ggsave("PCA-lip.png", width = 6, height = 4.25)
  590. #PERMDISP (repeat for brain, plasma, and liver)
  591. permdisp = lip_data_pcoa %>%
  592. filter(Mode == "brain")
  593. dist_matrix = permdisp %>%
  594. select(!Name:Background) %>%
  595. vegdist(., method = "euclidean")
  596. pcoa.permdisp <- betadisper(dist_matrix,
  597. permdisp$Group2,
  598. type = c("median", "centroid"),
  599. bias.adjust = FALSE,
  600. sqrt.dist = FALSE,
  601. add = FALSE)
  602. anova(pcoa.permdisp)
  603. # Brain:
  604. # Response: Distances
  605. # Df Sum Sq Mean Sq F value Pr(>F)
  606. # Groups 3 24.14 8.0474 1.1985 0.3131
  607. # Residuals 128 859.50 6.7148
  608. #
  609. # Plasma:
  610. # Response: Distances
  611. # Df Sum Sq Mean Sq F value Pr(>F)
  612. # Groups 3 42.16 14.054 1.2023 0.3108
  613. # Residuals 159 1858.60 11.689
  614. #
  615. # Liver:
  616. # Response: Distances
  617. # Df Sum Sq Mean Sq F value Pr(>F)
  618. # Groups 3 25.69 8.5625 1.2408 0.299
  619. # Residuals 101 696.99 6.9009
  620. ##############
  621. ##############Volcano plots and DA metabolite lists#############
  622. ##Figure2
  623. #Liver Trem2 v WT 4 months targ.met
  624. TREM2_tar_df = tar_df_combined %>%
  625. filter(Group2 %in% c("WT 5xFAD", "WT 5xFAD_TREM2"), Age == 4, Mode == "liver") %>%
  626. column_to_rownames(var = "sample_id")
  627. #Note: its named t test but its using a wilcox test
  628. t_test_df = TREM2_tar_df %>%
  629. select(`1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1`) %>%
  630. map_df(~ broom::tidy(wilcox.test(. ~ TREM2_tar_df$Group2)), .id = 'var') %>%
  631. select(var, p.value)
  632. t_test_df$padj = p.adjust(t_test_df$p.value, method = "fdr") #changed to FDR, less stringent
  633. #Need to calc fold change
  634. log2fc = TREM2_tar_df %>%
  635. group_by(Group2) %>%
  636. summarise(across(`1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1`, mean)) %>%
  637. column_to_rownames(var = "Group2") %>%
  638. t(.)
  639. log2fc = as.data.frame(log2fc)
  640. log2fc$Ratio = log2fc$`WT 5xFAD_TREM2` / log2fc$`WT 5xFAD`
  641. log2fc$Log2FC = log(log2fc$Ratio, base = 2)
  642. log2fc[is.na(log2fc)] <- 0 #change any NaN to 0
  643. log2fc = log2fc %>%
  644. rownames_to_column(var = "var") %>%
  645. left_join(t_test_df)
  646. #Volcano plot
  647. log2fc = log2fc %>%
  648. mutate(color = case_when(
  649. padj < 0.05 & Log2FC > 0.58496250072 ~ "color2",
  650. padj < 0.05 & Log2FC < -0.58496250072 ~ "color3",
  651. padj > 0.05 ~ "color1",
  652. Log2FC > -1 ~ "color1",
  653. Log2FC < 1 ~ "color1"
  654. ))
  655. LTM4_volc <- ggplot(data = log2fc) +
  656. aes(x = Log2FC, y = -log10(padj), color = color) +
  657. geom_hline(yintercept = -log10(0.05), lty = 2) +
  658. geom_vline(xintercept = 0.58496250072, lty = 3) +
  659. geom_vline(xintercept = -0.58496250072, lty = 3) +
  660. geom_point(alpha = 0.5, size = 2) +
  661. scale_color_manual(values = c("gray", "#BF0D3E", "steelblue"), labels = c("N.S.", "Increased", "Decreased")) +
  662. labs(x = expression("log"[2]*"(FC)"), y = expression("-log"[10]*"(p-adj)"), color = "Abundance") +
  663. theme_bw() +
  664. #theme(plot.title = element_text(size = 18)) +
  665. ggrepel::geom_text_repel(aes(x = Log2FC, y = -log10(padj), label = var), color = "black", size = 2.6, max.overlaps = 8) #+
  666. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 2, vjust = -8.25, label = bquote("Total:"~.(sum(TREM2_tar_res_df$qval < 0.05)))) +
  667. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.525, vjust = -6.75, label = bquote("Increased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef > 0)))) +
  668. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.55, vjust = -5, label = bquote("Decreased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef < 0))))
  669. LTM4_volc
  670. LTM4_DF <- log2fc %>% filter((padj < 0.05 & Log2FC > 0.58496250072) | (padj < 0.05 & Log2FC < -0.58496250072))
  671. LTM4_DF <-select(LTM4_DF, var, Log2FC, padj)
  672. write.csv(LTM4_DF, "Figure2D.csv", row.names=FALSE)
  673. ggsave("Figure2C.png", LTM4_volc, width = 7, height = 4)
  674. #Plasma Trem2 vs WT 4 months targ.met
  675. TREM2_tar_df = tar_df_combined %>%
  676. filter(Group2 %in% c("WT 5xFAD", "WT 5xFAD_TREM2"), Age == 4, Mode == "plasma") %>%
  677. column_to_rownames(var = "sample_id")
  678. #Note: its named t test but its using a wilcox test
  679. t_test_df = TREM2_tar_df %>%
  680. select(`1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1`) %>%
  681. map_df(~ broom::tidy(wilcox.test(. ~ TREM2_tar_df$Group2)), .id = 'var') %>%
  682. select(var, p.value)
  683. t_test_df$padj = p.adjust(t_test_df$p.value, method = "fdr") #changed to FDR, less stringent
  684. #Need to calc fold change
  685. log2fc = TREM2_tar_df %>%
  686. group_by(Group2) %>%
  687. summarise(across(`1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1`, mean)) %>%
  688. column_to_rownames(var = "Group2") %>%
  689. t(.)
  690. log2fc = as.data.frame(log2fc)
  691. log2fc$Ratio = log2fc$`WT 5xFAD_TREM2` / log2fc$`WT 5xFAD`
  692. log2fc$Log2FC = log(log2fc$Ratio, base = 2)
  693. log2fc[is.na(log2fc)] <- 0 #change any NaN to 0
  694. log2fc = log2fc %>%
  695. rownames_to_column(var = "var") %>%
  696. left_join(t_test_df)
  697. #Volcano plot
  698. log2fc = log2fc %>%
  699. mutate(color = case_when(
  700. padj < 0.05 & Log2FC > 0.58496250072 ~ "color2",
  701. padj < 0.05 & Log2FC < -0.58496250072 ~ "color3",
  702. padj > 0.05 ~ "color1",
  703. Log2FC > -1 ~ "color1",
  704. Log2FC < 1 ~ "color1"
  705. ))
  706. PTM4_volc <- ggplot(data = log2fc) +
  707. aes(x = Log2FC, y = -log10(padj), color = color) +
  708. geom_hline(yintercept = -log10(0.05), lty = 2) +
  709. geom_vline(xintercept = 0.58496250072, lty = 3) +
  710. geom_vline(xintercept = -0.58496250072, lty = 3) +
  711. geom_point(alpha = 0.5, size = 2) +
  712. scale_color_manual(values = c("gray", "#BF0D3E", "steelblue"), labels = c("N.S.", "Increased", "Decreased")) +
  713. labs(x = expression("log"[2]*"(FC)"), y = expression("-log"[10]*"(p-adj)"), color = "Abundance") +
  714. theme_bw() +
  715. #theme(plot.title = element_text(size = 18)) +
  716. ggrepel::geom_text_repel(aes(x = Log2FC, y = -log10(padj), label = var), color = "black", size = 2.6, max.overlaps = 8) #+
  717. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 2, vjust = -8.25, label = bquote("Total:"~.(sum(TREM2_tar_res_df$qval < 0.05)))) +
  718. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.525, vjust = -6.75, label = bquote("Increased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef > 0)))) +
  719. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.55, vjust = -5, label = bquote("Decreased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef < 0))))
  720. PTM4_volc
  721. PTM4_DF <- log2fc %>% filter((padj < 0.05 & Log2FC > 0.58496250072) | (padj < 0.05 & Log2FC < -0.58496250072))
  722. PTM4_DF <-select(PTM4_DF, var, Log2FC, padj)
  723. write.csv(PTM4_DF, "Figure2F.csv", row.names=FALSE)
  724. ggsave("Figure2E.png", PTM4_volc, width = 7, height = 4)
  725. #Brain Trem2 vs WT 4 months targ.met
  726. TREM2_tar_df = tar_df_combined %>%
  727. filter(Group2 %in% c("WT 5xFAD", "WT 5xFAD_TREM2"), Age == 4, Mode == "brain") %>%
  728. column_to_rownames(var = "sample_id")
  729. #Note: its named t test but its using a wilcox test
  730. t_test_df = TREM2_tar_df %>%
  731. select(`1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1`) %>%
  732. map_df(~ broom::tidy(wilcox.test(. ~ TREM2_tar_df$Group2)), .id = 'var') %>%
  733. select(var, p.value)
  734. t_test_df$padj = p.adjust(t_test_df$p.value, method = "fdr") #changed to FDR, less stringent
  735. #Need to calc fold change
  736. log2fc = TREM2_tar_df %>%
  737. group_by(Group2) %>%
  738. summarise(across(`1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1`, mean)) %>%
  739. column_to_rownames(var = "Group2") %>%
  740. t(.)
  741. log2fc = as.data.frame(log2fc)
  742. log2fc$Ratio = log2fc$`WT 5xFAD_TREM2` / log2fc$`WT 5xFAD`
  743. log2fc$Log2FC = log(log2fc$Ratio, base = 2)
  744. log2fc[is.na(log2fc)] <- 0 #change any NaN to 0
  745. log2fc = log2fc %>%
  746. rownames_to_column(var = "var") %>%
  747. left_join(t_test_df)
  748. #Volcano plot
  749. log2fc = log2fc %>%
  750. mutate(color = case_when(
  751. padj < 0.05 & Log2FC > 0.58496250072 ~ "color2",
  752. padj < 0.05 & Log2FC < -0.58496250072 ~ "color3",
  753. padj > 0.05 ~ "color1",
  754. Log2FC > -1 ~ "color1",
  755. Log2FC < 1 ~ "color1"
  756. ))
  757. BTM4_volc <- ggplot(data = log2fc) +
  758. aes(x = Log2FC, y = -log10(padj), color = color) +
  759. geom_hline(yintercept = -log10(0.05), lty = 2) +
  760. geom_vline(xintercept = 0.58496250072, lty = 3) +
  761. geom_vline(xintercept = -0.58496250072, lty = 3) +
  762. geom_point(alpha = 0.5, size = 2) +
  763. scale_color_manual(values = c("gray", "#BF0D3E"), labels = c("N.S.", "Increased")) +
  764. labs(x = expression("log"[2]*"(FC)"), y = expression("-log"[10]*"(p-adj)"), color = "Abundance") +
  765. theme_bw() +
  766. #theme(plot.title = element_text(size = 18)) +
  767. ggrepel::geom_text_repel(aes(x = Log2FC, y = -log10(padj), label = var), color = "black", size = 2.6, max.overlaps = 8) #+
  768. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 2, vjust = -8.25, label = bquote("Total:"~.(sum(TREM2_tar_res_df$qval < 0.05)))) +
  769. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.525, vjust = -6.75, label = bquote("Increased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef > 0)))) +
  770. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.55, vjust = -5, label = bquote("Decreased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef < 0))))
  771. BTM4_volc
  772. BTM4_DF <- log2fc %>% filter((padj < 0.05 & Log2FC > 0.58496250072) | (padj < 0.05 & Log2FC < -0.58496250072))
  773. BTM4_DF <-select(BTM4_DF, var, Log2FC, padj)
  774. write.csv(BTM4_DF, "Figure2H.csv", row.names=FALSE)
  775. ggsave("Figure2G.png", BTM4_volc, width = 7, height = 4)
  776. ##SuppFigure5
  777. #Liver targ.met 5xFAD*Trem2 vs Trem2
  778. TREM2_tar_df = tar_df_combined %>%
  779. filter(Group2 %in% c("WT 5xFAD_TREM2", "HEMI 5xFAD_TREM2"), Mode == "liver") %>%
  780. column_to_rownames(var = "sample_id")
  781. #Note: its named t test but its using a wilcox test
  782. t_test_df = TREM2_tar_df %>%
  783. select(`1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1`) %>%
  784. map_df(~ broom::tidy(wilcox.test(. ~ TREM2_tar_df$Group2)), .id = 'var') %>%
  785. select(var, p.value)
  786. t_test_df$padj = p.adjust(t_test_df$p.value, method = "fdr") #changed to FDR, less stringent
  787. #Need to calc fold change
  788. log2fc = TREM2_tar_df %>%
  789. group_by(Group2) %>%
  790. summarise(across(`1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1`, mean)) %>%
  791. column_to_rownames(var = "Group2") %>%
  792. t(.)
  793. log2fc = as.data.frame(log2fc)
  794. log2fc$Ratio = log2fc$`HEMI 5xFAD_TREM2` / log2fc$`WT 5xFAD_TREM2`
  795. log2fc$Log2FC = log(log2fc$Ratio, base = 2)
  796. log2fc[is.na(log2fc)] <- 0 #change any NaN to 0
  797. log2fc = log2fc %>%
  798. rownames_to_column(var = "var") %>%
  799. left_join(t_test_df)
  800. #Volcano plot
  801. log2fc = log2fc %>%
  802. mutate(color = case_when(
  803. padj < 0.05 & Log2FC > 0.58496250072 ~ "color2",
  804. padj < 0.05 & Log2FC < -0.58496250072 ~ "color3",
  805. padj > 0.05 ~ "color1",
  806. Log2FC > -1 ~ "color1",
  807. Log2FC < 1 ~ "color1"
  808. ))
  809. LTM4_12_T2_5xT2_volc <- ggplot(data = log2fc) +
  810. aes(x = Log2FC, y = -log10(padj), color = color) +
  811. geom_hline(yintercept = -log10(0.05), lty = 2) +
  812. geom_vline(xintercept = 0.58496250072, lty = 3) +
  813. geom_vline(xintercept = -0.58496250072, lty = 3) +
  814. geom_point(alpha = 0.5, size = 2) +
  815. scale_color_manual(values = c("gray", "steelblue"), labels = c("N.S.", "Decreased")) +
  816. labs(x = expression("log"[2]*"(FC)"), y = expression("-log"[10]*"(p-adj)"), color = "Abundance") +
  817. theme_bw() +
  818. ggrepel::geom_text_repel(aes(x = Log2FC, y = -log10(padj), label = var), color = "black", size = 2.2, max.overlaps = 8) #+
  819. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 2, vjust = -8.25, label = bquote("Total:"~.(sum(TREM2_tar_res_df$qval < 0.05)))) +
  820. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.525, vjust = -6.75, label = bquote("Increased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef > 0)))) +
  821. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.55, vjust = -5, label = bquote("Decreased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef < 0))))
  822. LTM4_12_T2_5xT2_volc
  823. # LTM4_12_T2_5xT2_DF <- log2fc %>% filter((padj < 0.05 & Log2FC > 0.58496250072) | (padj < 0.05 & Log2FC < -0.58496250072))
  824. # LTM4_12_T2_5xT2_DF <-select(LTM4_12_T2_5xT2_DF, var, Log2FC, padj)
  825. # write.csv(LTM4_12_T2_5xT2_DF, "LTM4_12_T2_5xT2_DF_Fig3.csv", row.names=FALSE)
  826. ggsave("SuppFig5A.png", LTM4_12_T2_5xT2_volc, width = 7, height = 4)
  827. #Plasma targ.met Trem2 vs 5xFAD*Trem2 (no signifigant metabolites)
  828. #Brain targ.met Trem2 vs 5xFAD*Trem2 (no signifigant metabolites)
  829. #*Liver lipid 5xFAD*Trem2 vs Trem2
  830. TREM2_lip_df = lip_df_combined %>%
  831. filter(Group2 %in% c("WT 5xFAD_TREM2", "HEMI 5xFAD_TREM2"), Mode == "liver") %>%
  832. column_to_rownames(var = "sample_id")
  833. #Note: its named t test but its using a wilcox test
  834. t_test_df = TREM2_lip_df %>%
  835. select(`CE(12:0)`:`TAG56:1-FA18:1`) %>%
  836. map_df(~ broom::tidy(wilcox.test(. ~ TREM2_lip_df$Group2)), .id = 'var') %>%
  837. select(var, p.value)
  838. t_test_df$padj = p.adjust(t_test_df$p.value, method = "fdr") #changed to FDR, less stringent
  839. #Need to calc fold change
  840. log2fc = TREM2_lip_df %>%
  841. group_by(Group2) %>%
  842. summarise(across(`CE(12:0)`:`TAG56:1-FA18:1`, mean)) %>%
  843. column_to_rownames(var = "Group2") %>%
  844. t(.)
  845. log2fc = as.data.frame(log2fc)
  846. log2fc$Ratio = log2fc$`HEMI 5xFAD_TREM2` / log2fc$`WT 5xFAD_TREM2`
  847. log2fc$Log2FC = log(log2fc$Ratio, base = 2)
  848. log2fc[is.na(log2fc)] <- 0 #change any NaN to 0
  849. log2fc = log2fc %>%
  850. rownames_to_column(var = "var") %>%
  851. left_join(t_test_df)
  852. #Volcano plot
  853. log2fc = log2fc %>%
  854. mutate(color = case_when(
  855. padj < 0.05 & Log2FC > 0.58496250072 ~ "color2",
  856. padj < 0.05 & Log2FC < -0.58496250072 ~ "color3",
  857. padj > 0.05 ~ "color1",
  858. Log2FC > -1 ~ "color1",
  859. Log2FC < 1 ~ "color1"
  860. ))
  861. LL4_12_T2_5xT2_volc <- ggplot(data = log2fc) +
  862. aes(x = Log2FC, y = -log10(padj), color = color) +
  863. geom_hline(yintercept = -log10(0.05), lty = 2) +
  864. geom_vline(xintercept = 0.58496250072, lty = 3) +
  865. geom_vline(xintercept = -0.58496250072, lty = 3) +
  866. geom_point(alpha = 0.5, size = 2) +
  867. scale_color_manual(values = c("gray", "#BF0D3E", "steelblue"), labels = c("N.S.", "Increased", "Decreased")) +
  868. labs(x = expression("log"[2]*"(FC)"), y = expression("-log"[10]*"(p-adj)"), color = "Abundance") +
  869. theme_bw() +
  870. #theme(plot.title = element_text(size = 18)) +
  871. ggrepel::geom_text_repel(aes(x = Log2FC, y = -log10(padj), label = var), color = "black", size = 2.2, max.overlaps = 8) #+
  872. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 2, vjust = -8.25, label = bquote("Total:"~.(sum(TREM2_tar_res_df$qval < 0.05)))) +
  873. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.525, vjust = -6.75, label = bquote("Increased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef > 0)))) +
  874. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.55, vjust = -5, label = bquote("Decreased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef < 0))))
  875. LL4_12_T2_5xT2_volc
  876. # LL4_12_T2_5xT2_DF <- log2fc %>% filter((padj < 0.05 & Log2FC > 0.58496250072) | (padj < 0.05 & Log2FC < -0.58496250072))
  877. # LL4_12_T2_5xT2_DF <-select(LL4_12_T2_5xT2_DF, var, Log2FC, padj)
  878. # write.csv(LL4_12_T2_5xT2_DF, "LL4_12_T2_5xT2_DF_Fig3.csv", row.names=FALSE)
  879. ggsave("SuppFig5B.png", LL4_12_T2_5xT2_volc, width = 7, height = 4)
  880. #Plasma lipid Trem2 vs 5xFAD*Trem2 (no signifigant metabolites)
  881. #*Brain lipid Trem2 vs 5xFAD*Trem2 (no signifigant metabolites)
  882. ##Figure2
  883. #Liver targ.met WT vs TREM2
  884. TREM2_tar_df = tar_df_combined %>%
  885. filter(Group2 %in% c("WT 5xFAD", "WT 5xFAD_TREM2"), Mode == "liver") %>%
  886. column_to_rownames(var = "sample_id")
  887. #Note: its named t test but its using a wilcox test
  888. t_test_df = TREM2_tar_df %>%
  889. select(`1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1`) %>%
  890. map_df(~ broom::tidy(wilcox.test(. ~ TREM2_tar_df$Group2)), .id = 'var') %>%
  891. select(var, p.value)
  892. t_test_df$padj = p.adjust(t_test_df$p.value, method = "fdr") #changed to FDR, less stringent
  893. #Need to calc fold change
  894. log2fc = TREM2_tar_df %>%
  895. group_by(Group2) %>%
  896. summarise(across(`1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1`, mean)) %>%
  897. column_to_rownames(var = "Group2") %>%
  898. t(.)
  899. log2fc = as.data.frame(log2fc)
  900. log2fc$Ratio = log2fc$`WT 5xFAD_TREM2` / log2fc$`WT 5xFAD`
  901. log2fc$Log2FC = log(log2fc$Ratio, base = 2)
  902. log2fc[is.na(log2fc)] <- 0 #change any NaN to 0
  903. log2fc = log2fc %>%
  904. rownames_to_column(var = "var") %>%
  905. left_join(t_test_df)
  906. #Volcano plot
  907. log2fc = log2fc %>%
  908. mutate(color = case_when(
  909. padj < 0.05 & Log2FC > 0.58496250072 ~ "color2",
  910. padj < 0.05 & Log2FC < -0.58496250072 ~ "color3",
  911. padj > 0.05 ~ "color1",
  912. Log2FC > -1 ~ "color1",
  913. Log2FC < 1 ~ "color1"
  914. ))
  915. LTM4_12_WT_T2_volc <- ggplot(data = log2fc) +
  916. aes(x = Log2FC, y = -log10(padj), color = color) +
  917. geom_hline(yintercept = -log10(0.05), lty = 2) +
  918. geom_vline(xintercept = 0.58496250072, lty = 3) +
  919. geom_vline(xintercept = -0.58496250072, lty = 3) +
  920. geom_point(alpha = 0.5, size = 2, show.legend = TRUE) +
  921. scale_color_manual(values = c("gray", "#BF0D3E"), labels = c("N.S.", "Increased")) +
  922. labs(x = expression("log"[2]*"(FC)"), y = expression("-log"[10]*"(p-adj)"), color = "Abundance") +
  923. theme_bw() +
  924. #theme(plot.title = element_text(size = 18)) +
  925. ggrepel::geom_text_repel(aes(x = Log2FC, y = -log10(padj), label = var), color = "black", size = 2.6, max.overlaps = 8) #+
  926. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 2, vjust = -8.25, label = bquote("Total:"~.(sum(TREM2_tar_res_df$qval < 0.05)))) +
  927. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.525, vjust = -6.75, label = bquote("Increased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef > 0)))) +
  928. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.55, vjust = -5, label = bquote("Decreased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef < 0))))
  929. LTM4_12_WT_T2_volc
  930. # LTM4_12_WT_T2_DF <- log2fc %>% filter(padj < 0.05)
  931. # LTM4_12_WT_T2_DF <-select(LTM4_12_WT_T2_DF, var, Log2FC, padj)
  932. # write.csv(LTM4_12_WT_T2_DF, "LTM4_12_WT_T2_DF_Fig3.csv", row.names=FALSE)
  933. ggsave("Figure2A.png", LTM4_12_WT_T2_volc, width = 7, height = 4)
  934. #Plasma targ.met WT vs TREM2 (no signifigant metabolites)
  935. #Brain targ.met WT vs TREM2
  936. TREM2_tar_df = tar_df_combined %>%
  937. filter(Group2 %in% c("WT 5xFAD", "WT 5xFAD_TREM2"), Mode == "brain") %>%
  938. column_to_rownames(var = "sample_id")
  939. #Note: its named t test but its using a wilcox test
  940. t_test_df = TREM2_tar_df %>%
  941. select(`1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1`) %>%
  942. map_df(~ broom::tidy(wilcox.test(. ~ TREM2_tar_df$Group2)), .id = 'var') %>%
  943. select(var, p.value)
  944. t_test_df$padj = p.adjust(t_test_df$p.value, method = "fdr") #changed to FDR, less stringent
  945. #Need to calc fold change
  946. log2fc = TREM2_tar_df %>%
  947. group_by(Group2) %>%
  948. summarise(across(`1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1`, mean)) %>%
  949. column_to_rownames(var = "Group2") %>%
  950. t(.)
  951. log2fc = as.data.frame(log2fc)
  952. log2fc$Ratio = log2fc$`WT 5xFAD_TREM2` / log2fc$`WT 5xFAD`
  953. log2fc$Log2FC = log(log2fc$Ratio, base = 2)
  954. log2fc[is.na(log2fc)] <- 0 #change any NaN to 0
  955. log2fc = log2fc %>%
  956. rownames_to_column(var = "var") %>%
  957. left_join(t_test_df)
  958. #Volcano plot
  959. log2fc = log2fc %>%
  960. mutate(color = case_when(
  961. padj < 0.05 & Log2FC > 0.58496250072 ~ "color2",
  962. padj < 0.05 & Log2FC < -0.58496250072 ~ "color3",
  963. padj > 0.05 ~ "color1",
  964. Log2FC > -1 ~ "color1",
  965. Log2FC < 1 ~ "color1"
  966. ))
  967. BTM4_12_WT_T2_volc <- ggplot(data = log2fc) +
  968. aes(x = Log2FC, y = -log10(padj), color = color) +
  969. geom_hline(yintercept = -log10(0.05), lty = 2) +
  970. geom_vline(xintercept = 0.58496250072, lty = 3) +
  971. geom_vline(xintercept = -0.58496250072, lty = 3) +
  972. geom_point(alpha = 0.5, size = 2, show.legend = TRUE) +
  973. scale_color_manual(values = c("gray", "#BF0D3E"), labels = c("N.S.", "Increased")) +
  974. labs(x = expression("log"[2]*"(FC)"), y = expression("-log"[10]*"(p-adj)"), color = "Abundance") +
  975. theme_bw() +
  976. #theme(plot.title = element_text(size = 18)) +
  977. ggrepel::geom_text_repel(aes(x = Log2FC, y = -log10(padj), label = var), color = "black", size = 2.6, max.overlaps = 8) #+
  978. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 2, vjust = -8.25, label = bquote("Total:"~.(sum(TREM2_tar_res_df$qval < 0.05)))) +
  979. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.525, vjust = -6.75, label = bquote("Increased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef > 0)))) +
  980. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.55, vjust = -5, label = bquote("Decreased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef < 0))))
  981. BTM4_12_WT_T2_volc
  982. # BTM4_12_WT_T2_DF <- log2fc %>% filter(padj < 0.05)
  983. # BTM4_12_WT_T2_DF <-select(BTM4_12_WT_T2_DF, var, Log2FC, padj)
  984. # write.csv(BTM4_12_WT_T2_DF, "BTM4_12_WT_T2_DF_Fig3.csv", row.names=FALSE)
  985. ggsave("Figure2B.png", BTM4_12_WT_T2_volc, width = 7, height = 4)
  986. #Liver lipid WT vs TREM2 (no signifigant metabolites)
  987. #Plasma lipid WT vs TREM2 (no signifigant metabolites)
  988. #Brain lipid WT vs TREM2 (no signifigant metabolites)
  989. #Liver targ.met WT vs 5xFAD (no signifigant metabolites)
  990. #Plasma targ.met WT vs 5xFAD (no signifigant metabolites)
  991. #Brain targ.met WT vs 5xFAD (no signifigant metabolites)
  992. #Liver lipid WT vs 5xFAD (no signifigant metabolites)
  993. #Brain lipid WT vs 5xFAD (no signifigant metabolites)
  994. #Plasma lipid WT vs 5xFAD (no signifigant metabolites)
  995. ##Figure4
  996. #Liver targ.met 5xFAD*Trem2 vs 5xFAD
  997. TREM2_tar_df = tar_df_combined %>%
  998. filter(Group2 %in% c("HEMI 5xFAD", "HEMI 5xFAD_TREM2"), Mode == "liver") %>%
  999. column_to_rownames(var = "sample_id")
  1000. #Note: its named t test but its using a wilcox test
  1001. t_test_df = TREM2_tar_df %>%
  1002. select(`1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1`) %>%
  1003. map_df(~ broom::tidy(wilcox.test(. ~ TREM2_tar_df$Group2)), .id = 'var') %>%
  1004. select(var, p.value)
  1005. t_test_df$padj = p.adjust(t_test_df$p.value, method = "fdr") #changed to FDR, less stringent
  1006. #Need to calc fold change
  1007. log2fc = TREM2_tar_df %>%
  1008. group_by(Group2) %>%
  1009. summarise(across(`1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1`, mean)) %>%
  1010. column_to_rownames(var = "Group2") %>%
  1011. t(.)
  1012. log2fc = as.data.frame(log2fc)
  1013. log2fc$Ratio = log2fc$`HEMI 5xFAD_TREM2` / log2fc$`HEMI 5xFAD`
  1014. log2fc$Log2FC = log(log2fc$Ratio, base = 2)
  1015. log2fc[is.na(log2fc)] <- 0 #change any NaN to 0
  1016. log2fc = log2fc %>%
  1017. rownames_to_column(var = "var") %>%
  1018. left_join(t_test_df)
  1019. #Volcano plot
  1020. log2fc = log2fc %>%
  1021. mutate(color = case_when(
  1022. padj < 0.05 & Log2FC > 0.58496250072 ~ "color2",
  1023. padj < 0.05 & Log2FC < -0.58496250072 ~ "color3",
  1024. padj > 0.05 ~ "color1",
  1025. Log2FC > -1 ~ "color1",
  1026. Log2FC < 1 ~ "color1"
  1027. ))
  1028. LTM4_12_5x_5xT2_volc <- ggplot(data = log2fc) +
  1029. aes(x = Log2FC, y = -log10(padj), color = color) +
  1030. geom_hline(yintercept = -log10(0.05), lty = 2) +
  1031. geom_vline(xintercept = 0.58496250072, lty = 3) +
  1032. geom_vline(xintercept = -0.58496250072, lty = 3) +
  1033. geom_point(alpha = 0.5, size = 2, show.legend = FALSE) +
  1034. scale_color_manual(values = c("gray", "steelblue"), labels = c("N.S.", "Decreased")) +
  1035. labs(title = "", subtitle = "", x = expression("log"[2]*"(FC)"), y = expression("-log"[10]*"(p-adj)"), color = "Abundance") +
  1036. theme_bw() +
  1037. #theme(plot.title = element_text(size = 18)) +
  1038. ggrepel::geom_text_repel(aes(x = Log2FC, y = -log10(padj), label = var), color = "black", size = 2.2, max.overlaps = 8) #+
  1039. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 2, vjust = -8.25, label = bquote("Total:"~.(sum(TREM2_tar_res_df$qval < 0.05)))) +
  1040. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.525, vjust = -6.75, label = bquote("Increased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef > 0)))) +
  1041. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.55, vjust = -5, label = bquote("Decreased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef < 0))))
  1042. LTM4_12_5x_5xT2_volc
  1043. ggsave("Figure4A.png", LTM4_12_5x_5xT2_volc, width = 4.5, height = 4)
  1044. #Plasma targ.met 5xFAD*Trem2 vs 5xFAD
  1045. TREM2_tar_df = tar_df_combined %>%
  1046. filter(Group2 %in% c("HEMI 5xFAD", "HEMI 5xFAD_TREM2"), Mode == "plasma") %>%
  1047. column_to_rownames(var = "sample_id")
  1048. #Note: its named t test but its using a wilcox test
  1049. t_test_df = TREM2_tar_df %>%
  1050. select(`1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1`) %>%
  1051. map_df(~ broom::tidy(wilcox.test(. ~ TREM2_tar_df$Group2)), .id = 'var') %>%
  1052. select(var, p.value)
  1053. t_test_df$padj = p.adjust(t_test_df$p.value, method = "fdr") #changed to FDR, less stringent
  1054. #Need to calc fold change
  1055. log2fc = TREM2_tar_df %>%
  1056. group_by(Group2) %>%
  1057. summarise(across(`1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1`, mean)) %>%
  1058. column_to_rownames(var = "Group2") %>%
  1059. t(.)
  1060. log2fc = as.data.frame(log2fc)
  1061. log2fc$Ratio = log2fc$`HEMI 5xFAD_TREM2` / log2fc$`HEMI 5xFAD`
  1062. log2fc$Log2FC = log(log2fc$Ratio, base = 2)
  1063. log2fc[is.na(log2fc)] <- 0 #change any NaN to 0
  1064. log2fc = log2fc %>%
  1065. rownames_to_column(var = "var") %>%
  1066. left_join(t_test_df)
  1067. #Volcano plot
  1068. log2fc = log2fc %>%
  1069. mutate(color = case_when(
  1070. padj < 0.05 & Log2FC > 0.58496250072 ~ "color2",
  1071. padj < 0.05 & Log2FC < -0.58496250072 ~ "color3",
  1072. padj > 0.05 ~ "color1",
  1073. Log2FC > -1 ~ "color1",
  1074. Log2FC < 1 ~ "color1"
  1075. ))
  1076. PTM4_12_5x_5xT2_volc <- ggplot(data = log2fc) +
  1077. aes(x = Log2FC, y = -log10(padj), color = color) +
  1078. geom_hline(yintercept = -log10(0.05), lty = 2) +
  1079. geom_vline(xintercept = 0.58496250072, lty = 3) +
  1080. geom_vline(xintercept = -0.58496250072, lty = 3) +
  1081. geom_point(alpha = 0.5, size = 2, show.legend = FALSE) +
  1082. scale_color_manual(values = c("gray", "#BF0D3E"), labels = c("N.S.", "Increased")) +
  1083. labs(title = "", subtitle = "", x = expression("log"[2]*"(FC)"), y = expression("-log"[10]*"(p-adj)"), color = "Abundance") +
  1084. theme_bw() +
  1085. #theme(plot.title = element_text(size = 18)) +
  1086. ggrepel::geom_text_repel(aes(x = Log2FC, y = -log10(padj), label = var), color = "black", size = 2.2, max.overlaps = 8) #+
  1087. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 2, vjust = -8.25, label = bquote("Total:"~.(sum(TREM2_tar_res_df$qval < 0.05)))) +
  1088. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.525, vjust = -6.75, label = bquote("Increased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef > 0)))) +
  1089. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.55, vjust = -5, label = bquote("Decreased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef < 0))))
  1090. PTM4_12_5x_5xT2_volc
  1091. ggsave("Figure4B.png", PTM4_12_5x_5xT2_volc, width = 4.5, height = 4)
  1092. #Brain targ.met 5xFAD*Trem2 vs 5xFAD
  1093. TREM2_tar_df = tar_df_combined %>%
  1094. filter(Group2 %in% c("HEMI 5xFAD", "HEMI 5xFAD_TREM2"), Mode == "brain") %>%
  1095. column_to_rownames(var = "sample_id")
  1096. #Note: its named t test but its using a wilcox test
  1097. t_test_df = TREM2_tar_df %>%
  1098. select(`1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1`) %>%
  1099. map_df(~ broom::tidy(wilcox.test(. ~ TREM2_tar_df$Group2)), .id = 'var') %>%
  1100. select(var, p.value)
  1101. t_test_df$padj = p.adjust(t_test_df$p.value, method = "fdr") #changed to FDR, less stringent
  1102. #Need to calc fold change
  1103. log2fc = TREM2_tar_df %>%
  1104. group_by(Group2) %>%
  1105. summarise(across(`1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1`, mean)) %>%
  1106. column_to_rownames(var = "Group2") %>%
  1107. t(.)
  1108. log2fc = as.data.frame(log2fc)
  1109. log2fc$Ratio = log2fc$`HEMI 5xFAD_TREM2` / log2fc$`HEMI 5xFAD`
  1110. log2fc$Log2FC = log(log2fc$Ratio, base = 2)
  1111. log2fc[is.na(log2fc)] <- 0 #change any NaN to 0
  1112. log2fc = log2fc %>%
  1113. rownames_to_column(var = "var") %>%
  1114. left_join(t_test_df)
  1115. #Volcano plot
  1116. log2fc = log2fc %>%
  1117. mutate(color = case_when(
  1118. padj < 0.05 & Log2FC > 0.58496250072 ~ "color2",
  1119. padj < 0.05 & Log2FC < -0.58496250072 ~ "color3",
  1120. padj > 0.05 ~ "color1",
  1121. Log2FC > -1 ~ "color1",
  1122. Log2FC < 1 ~ "color1"
  1123. ))
  1124. BTM4_12_5x_5xT2_volc <- ggplot(data = log2fc) +
  1125. aes(x = Log2FC, y = -log10(padj), color = color) +
  1126. geom_hline(yintercept = -log10(0.05), lty = 2) +
  1127. geom_vline(xintercept = 0.58496250072, lty = 3) +
  1128. geom_vline(xintercept = -0.58496250072, lty = 3) +
  1129. geom_point(alpha = 0.5, size = 2, show.legend = FALSE) +
  1130. scale_color_manual(values = c("gray", "#BF0D3E"), labels = c("N.S.", "Increased")) +
  1131. labs(title = "", subtitle = "", x = expression("log"[2]*"(FC)"), y = expression("-log"[10]*"(p-adj)"), color = "Abundance") +
  1132. theme_bw() +
  1133. #theme(plot.title = element_text(size = 18)) +
  1134. ggrepel::geom_text_repel(aes(x = Log2FC, y = -log10(padj), label = var), color = "black", size = 2.2, max.overlaps = 8) #+
  1135. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 2, vjust = -8.25, label = bquote("Total:"~.(sum(TREM2_tar_res_df$qval < 0.05)))) +
  1136. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.525, vjust = -6.75, label = bquote("Increased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef > 0)))) +
  1137. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.55, vjust = -5, label = bquote("Decreased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef < 0))))
  1138. BTM4_12_5x_5xT2_volc
  1139. ggsave("Figure4C.png", BTM4_12_5x_5xT2_volc, width = 4.5, height = 4)
  1140. #Liver lipid 5xFAD vs 5xFAD_TREM2 (no signifigant metabolites)
  1141. #Plasma lipid 5xFAD vs 5xFAD_TREM2 (no signifigant metabolites)
  1142. #Brain lipid 5xFAD vs 5xFAD_TREM2 (no signifigant metabolites)
  1143. #Liver targ.met Trem2 vs 5xFAD (no signifigant metabolites)
  1144. ##SuppFigure4
  1145. #Plasma targ.met 5xFAD vs Trem2
  1146. TREM2_tar_df = tar_df_combined %>%
  1147. filter(Group2 %in% c("WT 5xFAD_TREM2", "HEMI 5xFAD"), Mode == "plasma") %>%
  1148. column_to_rownames(var = "sample_id")
  1149. #Note: its named t test but its using a wilcox test
  1150. t_test_df = TREM2_tar_df %>%
  1151. select(`1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1`) %>%
  1152. map_df(~ broom::tidy(wilcox.test(. ~ TREM2_tar_df$Group2)), .id = 'var') %>%
  1153. select(var, p.value)
  1154. t_test_df$padj = p.adjust(t_test_df$p.value, method = "fdr") #changed to FDR, less stringent
  1155. #Need to calc fold change
  1156. log2fc = TREM2_tar_df %>%
  1157. group_by(Group2) %>%
  1158. summarise(across(`1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1`, mean)) %>%
  1159. column_to_rownames(var = "Group2") %>%
  1160. t(.)
  1161. log2fc = as.data.frame(log2fc)
  1162. log2fc$Ratio = log2fc$`HEMI 5xFAD` / log2fc$`WT 5xFAD_TREM2`
  1163. log2fc$Log2FC = log(log2fc$Ratio, base = 2)
  1164. log2fc[is.na(log2fc)] <- 0 #change any NaN to 0
  1165. log2fc = log2fc %>%
  1166. rownames_to_column(var = "var") %>%
  1167. left_join(t_test_df)
  1168. #Volcano plot
  1169. log2fc = log2fc %>%
  1170. mutate(color = case_when(
  1171. padj < 0.05 & Log2FC > 0.58496250072 ~ "color2",
  1172. padj < 0.05 & Log2FC < -0.58496250072 ~ "color3",
  1173. padj > 0.05 ~ "color1",
  1174. Log2FC > -1 ~ "color1",
  1175. Log2FC < 1 ~ "color1"
  1176. ))
  1177. PTM4_12_T2_5x_volc <- ggplot(data = log2fc) +
  1178. aes(x = Log2FC, y = -log10(padj), color = color) +
  1179. geom_hline(yintercept = -log10(0.05), lty = 2) +
  1180. geom_vline(xintercept = 0.58496250072, lty = 3) +
  1181. geom_vline(xintercept = -0.58496250072, lty = 3) +
  1182. geom_point(alpha = 0.5, size = 2, show.legend = FALSE) +
  1183. scale_color_manual(values = c("gray", "steelblue"), labels = c("N.S.", "Decreased")) +
  1184. labs(title = "5xFAD vs. TREM2", subtitle = "Plasma polar metabolites", x = expression("log"[2]*"(FC)"), y = expression("-log"[10]*"(p-adj)"), color = "Abundance") +
  1185. theme_bw() +
  1186. #theme(plot.title = element_text(size = 18)) +
  1187. ggrepel::geom_text_repel(aes(x = Log2FC, y = -log10(padj), label = var), color = "black", size = 2.2, max.overlaps = 8) #+
  1188. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 2, vjust = -8.25, label = bquote("Total:"~.(sum(TREM2_tar_res_df$qval < 0.05)))) +
  1189. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.525, vjust = -6.75, label = bquote("Increased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef > 0)))) +
  1190. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.55, vjust = -5, label = bquote("Decreased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef < 0))))
  1191. PTM4_12_T2_5x_volc
  1192. ggsave("SuppFig4A.png", PTM4_12_T2_5x_volc, width = 4.5, height = 4)
  1193. #Brain targ.met 5xFAD vs Trem2
  1194. TREM2_tar_df = tar_df_combined %>%
  1195. filter(Group2 %in% c("WT 5xFAD_TREM2", "HEMI 5xFAD"), Mode == "brain") %>%
  1196. column_to_rownames(var = "sample_id")
  1197. #Note: its named t test but its using a wilcox test
  1198. t_test_df = TREM2_tar_df %>%
  1199. select(`1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1`) %>%
  1200. map_df(~ broom::tidy(wilcox.test(. ~ TREM2_tar_df$Group2)), .id = 'var') %>%
  1201. select(var, p.value)
  1202. t_test_df$padj = p.adjust(t_test_df$p.value, method = "fdr") #changed to FDR, less stringent
  1203. #Need to calc fold change
  1204. log2fc = TREM2_tar_df %>%
  1205. group_by(Group2) %>%
  1206. summarise(across(`1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1`, mean)) %>%
  1207. column_to_rownames(var = "Group2") %>%
  1208. t(.)
  1209. log2fc = as.data.frame(log2fc)
  1210. log2fc$Ratio = log2fc$`HEMI 5xFAD` / log2fc$`WT 5xFAD_TREM2`
  1211. log2fc$Log2FC = log(log2fc$Ratio, base = 2)
  1212. log2fc[is.na(log2fc)] <- 0 #change any NaN to 0
  1213. log2fc = log2fc %>%
  1214. rownames_to_column(var = "var") %>%
  1215. left_join(t_test_df)
  1216. #Volcano plot
  1217. log2fc = log2fc %>%
  1218. mutate(color = case_when(
  1219. padj < 0.05 & Log2FC > 0.58496250072 ~ "color2",
  1220. padj < 0.05 & Log2FC < -0.58496250072 ~ "color3",
  1221. padj > 0.05 ~ "color1",
  1222. Log2FC > -1 ~ "color1",
  1223. Log2FC < 1 ~ "color1"
  1224. ))
  1225. BTM4_12_T2_5x_volc <- ggplot(data = log2fc) +
  1226. aes(x = Log2FC, y = -log10(padj), color = color) +
  1227. geom_hline(yintercept = -log10(0.05), lty = 2) +
  1228. geom_vline(xintercept = 0.58496250072, lty = 3) +
  1229. geom_vline(xintercept = -0.58496250072, lty = 3) +
  1230. geom_point(alpha = 0.5, size = 2, show.legend = FALSE) +
  1231. scale_color_manual(values = c("gray", "steelblue"), labels = c("N.S.", "Decreased")) +
  1232. labs(title = "", subtitle = "Brain polar metabolites", x = expression("log"[2]*"(FC)"), y = expression("-log"[10]*"(p-adj)"), color = "Abundance") +
  1233. theme_bw() +
  1234. #theme(plot.title = element_text(size = 18)) +
  1235. ggrepel::geom_text_repel(aes(x = Log2FC, y = -log10(padj), label = var), color = "black", size = 2.2, max.overlaps = 8) #+
  1236. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 2, vjust = -8.25, label = bquote("Total:"~.(sum(TREM2_tar_res_df$qval < 0.05)))) +
  1237. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.525, vjust = -6.75, label = bquote("Increased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef > 0)))) +
  1238. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.55, vjust = -5, label = bquote("Decreased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef < 0))))
  1239. BTM4_12_T2_5x_volc
  1240. ggsave("SuppFig4B.png", BTM4_12_T2_5x_volc, width = 4.5, height = 4)
  1241. #Liver lipid 5xFAD vs Trem2
  1242. TREM2_lip_df = lip_df_combined %>%
  1243. filter(Group2 %in% c("WT 5xFAD_TREM2", "HEMI 5xFAD"), Mode == "liver") %>%
  1244. column_to_rownames(var = "sample_id")
  1245. #Note: its named t test but its using a wilcox test
  1246. t_test_df = TREM2_lip_df %>%
  1247. select(`CE(12:0)`:`TAG56:1-FA18:1`) %>%
  1248. map_df(~ broom::tidy(wilcox.test(. ~ TREM2_lip_df$Group2)), .id = 'var') %>%
  1249. select(var, p.value)
  1250. t_test_df$padj = p.adjust(t_test_df$p.value, method = "fdr") #changed to FDR, less stringent
  1251. #Need to calc fold change
  1252. log2fc = TREM2_lip_df %>%
  1253. group_by(Group2) %>%
  1254. summarise(across(`CE(12:0)`:`TAG56:1-FA18:1`, mean)) %>%
  1255. column_to_rownames(var = "Group2") %>%
  1256. t(.)
  1257. log2fc = as.data.frame(log2fc)
  1258. log2fc$Ratio = log2fc$`HEMI 5xFAD` / log2fc$`WT 5xFAD_TREM2`
  1259. log2fc$Log2FC = log(log2fc$Ratio, base = 2)
  1260. log2fc[is.na(log2fc)] <- 0 #change any NaN to 0
  1261. log2fc = log2fc %>%
  1262. rownames_to_column(var = "var") %>%
  1263. left_join(t_test_df)
  1264. #Volcano plot
  1265. log2fc = log2fc %>%
  1266. mutate(color = case_when(
  1267. padj < 0.05 & Log2FC > 0.58496250072 ~ "color2",
  1268. padj < 0.05 & Log2FC < -0.58496250072 ~ "color3",
  1269. padj > 0.05 ~ "color1",
  1270. Log2FC > -1 ~ "color1",
  1271. Log2FC < 1 ~ "color1"
  1272. ))
  1273. LL4_12_T2_5x_volc <- ggplot(data = log2fc) +
  1274. aes(x = Log2FC, y = -log10(padj), color = color) +
  1275. geom_hline(yintercept = -log10(0.05), lty = 2) +
  1276. geom_vline(xintercept = 0.58496250072, lty = 3) +
  1277. geom_vline(xintercept = -0.58496250072, lty = 3) +
  1278. geom_point(alpha = 0.5, size = 2, show.legend = FALSE) +
  1279. scale_color_manual(values = c("gray", "steelblue", "#BF0D3E"), labels = c("N.S.", "Decreased", "Increased")) +
  1280. labs(title = "", subtitle = "Liver lipids", x = expression("log"[2]*"(FC)"), y = expression("-log"[10]*"(p-adj)"), color = "Abundance") +
  1281. theme_bw() +
  1282. #theme(plot.title = element_text(size = 18)) +
  1283. ggrepel::geom_text_repel(aes(x = Log2FC, y = -log10(padj), label = var), color = "black", size = 2.2, max.overlaps = 8) #+
  1284. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 2, vjust = -8.25, label = bquote("Total:"~.(sum(TREM2_tar_res_df$qval < 0.05)))) +
  1285. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.525, vjust = -6.75, label = bquote("Increased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef > 0)))) +
  1286. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.55, vjust = -5, label = bquote("Decreased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef < 0))))
  1287. LL4_12_T2_5x_volc
  1288. ggsave("SuppFig4C.png", LL4_12_T2_5x_volc, width = 4.5, height = 4)
  1289. #Plasma lipid Trem2 vs 5xFAD (no signifigant metabolites)
  1290. #Brain lipid Trem2 vs 5xFAD (no signifigant metabolites)
  1291. #Liver targ.met 5xFAD*TREM2 vs WT
  1292. TREM2_tar_df = tar_df_combined %>%
  1293. filter(Group2 %in% c("WT 5xFAD", "HEMI 5xFAD_TREM2"), Mode == "liver") %>%
  1294. column_to_rownames(var = "sample_id")
  1295. #Note: its named t test but its using a wilcox test
  1296. t_test_df = TREM2_tar_df %>%
  1297. select(`1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1`) %>%
  1298. map_df(~ broom::tidy(wilcox.test(. ~ TREM2_tar_df$Group2)), .id = 'var') %>%
  1299. select(var, p.value)
  1300. t_test_df$padj = p.adjust(t_test_df$p.value, method = "fdr") #changed to FDR, less stringent
  1301. #Need to calc fold change
  1302. log2fc = TREM2_tar_df %>%
  1303. group_by(Group2) %>%
  1304. summarise(across(`1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1`, mean)) %>%
  1305. column_to_rownames(var = "Group2") %>%
  1306. t(.)
  1307. log2fc = as.data.frame(log2fc)
  1308. log2fc$Ratio = log2fc$`HEMI 5xFAD_TREM2` / log2fc$`WT 5xFAD`
  1309. log2fc$Log2FC = log(log2fc$Ratio, base = 2)
  1310. log2fc[is.na(log2fc)] <- 0 #change any NaN to 0
  1311. log2fc = log2fc %>%
  1312. rownames_to_column(var = "var") %>%
  1313. left_join(t_test_df)
  1314. #Volcano plot
  1315. log2fc = log2fc %>%
  1316. mutate(color = case_when(
  1317. padj < 0.05 & Log2FC > 0.58496250072 ~ "color2",
  1318. padj < 0.05 & Log2FC < -0.58496250072 ~ "color3",
  1319. padj > 0.05 ~ "color1",
  1320. Log2FC > -1 ~ "color1",
  1321. Log2FC < 1 ~ "color1"
  1322. ))
  1323. LTM4_12_WT_5xT2_volc <- ggplot(data = log2fc) +
  1324. aes(x = Log2FC, y = -log10(padj), color = color) +
  1325. geom_hline(yintercept = -log10(0.05), lty = 2) +
  1326. geom_vline(xintercept = 0.58496250072, lty = 3) +
  1327. geom_vline(xintercept = -0.58496250072, lty = 3) +
  1328. geom_point(alpha = 0.5, size = 2, show.legend = FALSE) +
  1329. scale_color_manual(values = c("gray", "steelblue"), labels = c("N.S.", "Decreased")) +
  1330. labs(title = "5xFAD*TREM2 vs. WT", subtitle = "Liver polar metabolites", x = expression("log"[2]*"(FC)"), y = expression("-log"[10]*"(p-adj)"), color = "Abundance") +
  1331. theme_bw() +
  1332. #theme(plot.title = element_text(size = 18)) +
  1333. ggrepel::geom_text_repel(aes(x = Log2FC, y = -log10(padj), label = var), color = "black", size = 2.2, max.overlaps = 8) #+
  1334. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 2, vjust = -8.25, label = bquote("Total:"~.(sum(TREM2_tar_res_df$qval < 0.05)))) +
  1335. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.525, vjust = -6.75, label = bquote("Increased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef > 0)))) +
  1336. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.55, vjust = -5, label = bquote("Decreased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef < 0))))
  1337. LTM4_12_WT_5xT2_volc
  1338. ggsave("SuppFig4D.png", LTM4_12_WT_5xT2_volc, width = 4.5, height = 4)
  1339. #Plasma targ.met WT vs 5xFAD*TREM2 (no signifigant metabolites)
  1340. #Brain targ.met 5xFAD*TREM2 vs WT
  1341. TREM2_tar_df = tar_df_combined %>%
  1342. filter(Group2 %in% c("WT 5xFAD", "HEMI 5xFAD_TREM2"), Mode == "brain") %>%
  1343. column_to_rownames(var = "sample_id")
  1344. #Note: its named t test but its using a wilcox test
  1345. t_test_df = TREM2_tar_df %>%
  1346. select(`1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1`) %>%
  1347. map_df(~ broom::tidy(wilcox.test(. ~ TREM2_tar_df$Group2)), .id = 'var') %>%
  1348. select(var, p.value)
  1349. t_test_df$padj = p.adjust(t_test_df$p.value, method = "fdr") #changed to FDR, less stringent
  1350. #Need to calc fold change
  1351. log2fc = TREM2_tar_df %>%
  1352. group_by(Group2) %>%
  1353. summarise(across(`1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1`, mean)) %>%
  1354. column_to_rownames(var = "Group2") %>%
  1355. t(.)
  1356. log2fc = as.data.frame(log2fc)
  1357. log2fc$Ratio = log2fc$`HEMI 5xFAD_TREM2` / log2fc$`WT 5xFAD`
  1358. log2fc$Log2FC = log(log2fc$Ratio, base = 2)
  1359. log2fc[is.na(log2fc)] <- 0 #change any NaN to 0
  1360. log2fc = log2fc %>%
  1361. rownames_to_column(var = "var") %>%
  1362. left_join(t_test_df)
  1363. #Volcano plot
  1364. log2fc = log2fc %>%
  1365. mutate(color = case_when(
  1366. padj < 0.05 & Log2FC > 0.58496250072 ~ "color2",
  1367. padj < 0.05 & Log2FC < -0.58496250072 ~ "color3",
  1368. padj > 0.05 ~ "color1",
  1369. Log2FC > -1 ~ "color1",
  1370. Log2FC < 1 ~ "color1"
  1371. ))
  1372. BTM4_12_WT_5xT2_volc <- ggplot(data = log2fc) +
  1373. aes(x = Log2FC, y = -log10(padj), color = color) +
  1374. geom_hline(yintercept = -log10(0.05), lty = 2) +
  1375. geom_vline(xintercept = 0.58496250072, lty = 3) +
  1376. geom_vline(xintercept = -0.58496250072, lty = 3) +
  1377. geom_point(alpha = 0.5, size = 2, show.legend = FALSE) +
  1378. scale_color_manual(values = c("gray", "#BF0D3E"), labels = c("N.S.", "Increased")) +
  1379. labs(title = "", subtitle = "Brain polar metabolites", x = expression("log"[2]*"(FC)"), y = expression("-log"[10]*"(p-adj)"), color = "Abundance") +
  1380. theme_bw() +
  1381. #theme(plot.title = element_text(size = 18)) +
  1382. ggrepel::geom_text_repel(aes(x = Log2FC, y = -log10(padj), label = var), color = "black", size = 2.2, max.overlaps = 8) #+
  1383. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 2, vjust = -8.25, label = bquote("Total:"~.(sum(TREM2_tar_res_df$qval < 0.05)))) +
  1384. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.525, vjust = -6.75, label = bquote("Increased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef > 0)))) +
  1385. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.55, vjust = -5, label = bquote("Decreased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef < 0))))
  1386. BTM4_12_WT_5xT2_volc
  1387. ggsave("SuppFig4E.png", BTM4_12_WT_5xT2_volc, width = 4.5, height = 4)
  1388. #Liver lipid 5xFAD*Trem2 vs WT
  1389. TREM2_lip_df = lip_df_combined %>%
  1390. filter(Group2 %in% c("WT 5xFAD", "HEMI 5xFAD_TREM2"), Mode == "liver") %>%
  1391. column_to_rownames(var = "sample_id")
  1392. #Note: its named t test but its using a wilcox test
  1393. t_test_df = TREM2_lip_df %>%
  1394. select(`CE(12:0)`:`TAG56:1-FA18:1`) %>%
  1395. map_df(~ broom::tidy(wilcox.test(. ~ TREM2_lip_df$Group2)), .id = 'var') %>%
  1396. select(var, p.value)
  1397. t_test_df$padj = p.adjust(t_test_df$p.value, method = "fdr") #changed to FDR, less stringent
  1398. #Need to calc fold change
  1399. log2fc = TREM2_lip_df %>%
  1400. group_by(Group2) %>%
  1401. summarise(across(`CE(12:0)`:`TAG56:1-FA18:1`, mean)) %>%
  1402. column_to_rownames(var = "Group2") %>%
  1403. t(.)
  1404. log2fc = as.data.frame(log2fc)
  1405. log2fc$Ratio = log2fc$`HEMI 5xFAD_TREM2` / log2fc$`WT 5xFAD`
  1406. log2fc$Log2FC = log(log2fc$Ratio, base = 2)
  1407. log2fc[is.na(log2fc)] <- 0 #change any NaN to 0
  1408. log2fc = log2fc %>%
  1409. rownames_to_column(var = "var") %>%
  1410. left_join(t_test_df)
  1411. #Volcano plot
  1412. log2fc = log2fc %>%
  1413. mutate(color = case_when(
  1414. padj < 0.05 & Log2FC > 0.58496250072 ~ "color2",
  1415. padj < 0.05 & Log2FC < -0.58496250072 ~ "color3",
  1416. padj > 0.05 ~ "color1",
  1417. Log2FC > -1 ~ "color1",
  1418. Log2FC < 1 ~ "color1"
  1419. ))
  1420. LL4_12_WT_5xT2_volc <- ggplot(data = log2fc) +
  1421. aes(x = Log2FC, y = -log10(padj), color = color) +
  1422. geom_hline(yintercept = -log10(0.05), lty = 2) +
  1423. geom_vline(xintercept = 0.58496250072, lty = 3) +
  1424. geom_vline(xintercept = -0.58496250072, lty = 3) +
  1425. geom_point(alpha = 0.5, size = 2, show.legend = FALSE) +
  1426. scale_color_manual(values = c("gray", "steelblue", "#BF0D3E"), labels = c("N.S.", "Decreased", "Increased")) +
  1427. labs(title = "", subtitle = "Liver lipids", x = expression("log"[2]*"(FC)"), y = expression("-log"[10]*"(p-adj)"), color = "Abundance") +
  1428. theme_bw() +
  1429. #theme(plot.title = element_text(size = 18)) +
  1430. ggrepel::geom_text_repel(aes(x = Log2FC, y = -log10(padj), label = var), color = "black", size = 2.2, max.overlaps = 8) #+
  1431. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 2, vjust = -8.25, label = bquote("Total:"~.(sum(TREM2_tar_res_df$qval < 0.05)))) +
  1432. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.525, vjust = -6.75, label = bquote("Increased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef > 0)))) +
  1433. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.55, vjust = -5, label = bquote("Decreased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef < 0))))
  1434. LL4_12_WT_5xT2_volc
  1435. ggsave("SuppFig4F.png", LL4_12_WT_5xT2_volc, width = 4.5, height = 4)
  1436. #Plasma lipid WT vs 5xFAD*Trem2 (no signifigant metabolites)
  1437. #Brain lipid 5xFAD*Trem2 vs WT
  1438. TREM2_lip_df = lip_df_combined %>%
  1439. filter(Group2 %in% c("WT 5xFAD", "HEMI 5xFAD_TREM2"), Mode == "brain") %>%
  1440. column_to_rownames(var = "sample_id")
  1441. #Note: its named t test but its using a wilcox test
  1442. t_test_df = TREM2_lip_df %>%
  1443. select(`CE(12:0)`:`TAG56:1-FA18:1`) %>%
  1444. map_df(~ broom::tidy(wilcox.test(. ~ TREM2_lip_df$Group2)), .id = 'var') %>%
  1445. select(var, p.value)
  1446. t_test_df$padj = p.adjust(t_test_df$p.value, method = "fdr") #changed to FDR, less stringent
  1447. #Need to calc fold change
  1448. log2fc = TREM2_lip_df %>%
  1449. group_by(Group2) %>%
  1450. summarise(across(`CE(12:0)`:`TAG56:1-FA18:1`, mean)) %>%
  1451. column_to_rownames(var = "Group2") %>%
  1452. t(.)
  1453. log2fc = as.data.frame(log2fc)
  1454. log2fc$Ratio = log2fc$`HEMI 5xFAD_TREM2` / log2fc$`WT 5xFAD`
  1455. log2fc$Log2FC = log(log2fc$Ratio, base = 2)
  1456. log2fc[is.na(log2fc)] <- 0 #change any NaN to 0
  1457. log2fc = log2fc %>%
  1458. rownames_to_column(var = "var") %>%
  1459. left_join(t_test_df)
  1460. #Volcano plot
  1461. log2fc = log2fc %>%
  1462. mutate(color = case_when(
  1463. padj < 0.05 & Log2FC > 0.58496250072 ~ "color2",
  1464. padj < 0.05 & Log2FC < -0.58496250072 ~ "color3",
  1465. padj > 0.05 ~ "color1",
  1466. Log2FC > -1 ~ "color1",
  1467. Log2FC < 1 ~ "color1"
  1468. ))
  1469. BL4_12_WT_5xT2_volc <- ggplot(data = log2fc) +
  1470. aes(x = Log2FC, y = -log10(padj), color = color) +
  1471. geom_hline(yintercept = -log10(0.05), lty = 2) +
  1472. geom_vline(xintercept = 0.58496250072, lty = 3) +
  1473. geom_vline(xintercept = -0.58496250072, lty = 3) +
  1474. geom_point(alpha = 0.5, size = 2, show.legend = FALSE) +
  1475. scale_color_manual(values = c("gray", "#BF0D3E", "steelblue"), labels = c("N.S.", "Increased", "Decreased")) +
  1476. labs(title = "", subtitle = "Brain lipids", x = expression("log"[2]*"(FC)"), y = expression("-log"[10]*"(p-adj)"), color = "Abundance") +
  1477. theme_bw() +
  1478. #theme(plot.title = element_text(size = 18)) +
  1479. ggrepel::geom_text_repel(aes(x = Log2FC, y = -log10(padj), label = var), color = "black", size = 2.2, max.overlaps = 8) #+
  1480. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 2, vjust = -8.25, label = bquote("Total:"~.(sum(TREM2_tar_res_df$qval < 0.05)))) +
  1481. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.525, vjust = -6.75, label = bquote("Increased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef > 0)))) +
  1482. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.55, vjust = -5, label = bquote("Decreased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef < 0))))
  1483. BL4_12_WT_5xT2_volc
  1484. ggsave("SuppFig4G.png", BL4_12_WT_5xT2_volc, width = 4.5, height = 4)
  1485. ##Figure3
  1486. #Liver 5xFAD vs WT 12mo. lipid
  1487. TREM2_lip_df = lip_df_combined %>%
  1488. filter(Group2 %in% c("WT 5xFAD", "HEMI 5xFAD"), Age == 12, Mode == "liver") %>%
  1489. column_to_rownames(var = "sample_id")
  1490. #Note: its named t test but its using a wilcox test
  1491. t_test_df = TREM2_lip_df %>%
  1492. select(`CE(12:0)`:`TAG56:1-FA18:1`) %>%
  1493. map_df(~ broom::tidy(wilcox.test(. ~ TREM2_lip_df$Group2)), .id = 'var') %>%
  1494. select(var, p.value)
  1495. t_test_df$padj = p.adjust(t_test_df$p.value, method = "fdr") #changed to FDR, less stringent
  1496. #Need to calc fold change
  1497. log2fc = TREM2_lip_df %>%
  1498. group_by(Group2) %>%
  1499. summarise(across(`CE(12:0)`:`TAG56:1-FA18:1`, mean)) %>%
  1500. column_to_rownames(var = "Group2") %>%
  1501. t(.)
  1502. log2fc = as.data.frame(log2fc)
  1503. log2fc$Ratio = log2fc$`HEMI 5xFAD` / log2fc$`WT 5xFAD`
  1504. log2fc$Log2FC = log(log2fc$Ratio, base = 2)
  1505. log2fc[is.na(log2fc)] <- 0 #change any NaN to 0
  1506. log2fc = log2fc %>%
  1507. rownames_to_column(var = "var") %>%
  1508. left_join(t_test_df)
  1509. #Volcano plot
  1510. log2fc = log2fc %>%
  1511. mutate(color = case_when(
  1512. padj < 0.05 & Log2FC > 0.58496250072 ~ "color2",
  1513. padj < 0.05 & Log2FC < -0.58496250072 ~ "color3",
  1514. padj > 0.05 ~ "color1",
  1515. Log2FC > -1 ~ "color1",
  1516. Log2FC < 1 ~ "color1"
  1517. ))
  1518. LL12_volc <- ggplot(data = log2fc) +
  1519. aes(x = Log2FC, y = -log10(padj), color = color) +
  1520. geom_hline(yintercept = -log10(0.05), lty = 2) +
  1521. geom_vline(xintercept = 0.58496250072, lty = 3) +
  1522. geom_vline(xintercept = -0.58496250072, lty = 3) +
  1523. geom_point(alpha = 0.5, size = 2) +
  1524. scale_color_manual(values = c("gray", "#BF0D3E", "steelblue"), labels = c("N.S.", "Increased", "Decreased")) +
  1525. labs(x = expression("log"[2]*"(FC)"), y = expression("-log"[10]*"(p-adj)"), color = "Abundance") +
  1526. theme_bw() +
  1527. #theme(plot.title = element_text(size = 18)) +
  1528. ggrepel::geom_text_repel(aes(x = Log2FC, y = -log10(padj), label = var), color = "black", size = 2.6, max.overlaps = 8) #+
  1529. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 2, vjust = -8.25, label = bquote("Total:"~.(sum(TREM2_tar_res_df$qval < 0.05)))) +
  1530. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.525, vjust = -6.75, label = bquote("Increased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef > 0)))) +
  1531. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.55, vjust = -5, label = bquote("Decreased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef < 0))))
  1532. LL12_volc
  1533. LL12_DF <- log2fc %>% filter((padj < 0.05 & Log2FC > 0.58496250072) | (padj < 0.05 & Log2FC < -0.58496250072))
  1534. LL12_DF <-select(LL12_DF, var, Log2FC, padj)
  1535. write.csv(LL12_DF, "Figure3B.csv", row.names=FALSE)
  1536. ggsave("Figure3A.png", LL12_volc, width = 7, height = 4)
  1537. ##Figure5
  1538. #Brain 5xFAD*TREM2 vs. 5xFAD 4mo. lipid
  1539. TREM2_lip_df = lip_df_combined %>%
  1540. filter(Group2 %in% c("HEMI 5xFAD", "HEMI 5xFAD_TREM2"), Age == 4, Mode == "brain") %>%
  1541. column_to_rownames(var = "sample_id")
  1542. #Note: its named t test but its using a wilcox test
  1543. t_test_df = TREM2_lip_df %>%
  1544. select(`CE(12:0)`:`TAG56:1-FA18:1`) %>%
  1545. map_df(~ broom::tidy(wilcox.test(. ~ TREM2_lip_df$Group2)), .id = 'var') %>%
  1546. select(var, p.value)
  1547. t_test_df$padj = p.adjust(t_test_df$p.value, method = "fdr") #changed to FDR, less stringent
  1548. #Need to calc fold change
  1549. log2fc = TREM2_lip_df %>%
  1550. group_by(Group2) %>%
  1551. summarise(across(`CE(12:0)`:`TAG56:1-FA18:1`, mean)) %>%
  1552. column_to_rownames(var = "Group2") %>%
  1553. t(.)
  1554. log2fc = as.data.frame(log2fc)
  1555. log2fc$Ratio = log2fc$`HEMI 5xFAD_TREM2` / log2fc$`HEMI 5xFAD`
  1556. log2fc$Log2FC = log(log2fc$Ratio, base = 2)
  1557. log2fc[is.na(log2fc)] <- 0 #change any NaN to 0
  1558. log2fc = log2fc %>%
  1559. rownames_to_column(var = "var") %>%
  1560. left_join(t_test_df)
  1561. #Volcano plot
  1562. log2fc = log2fc %>%
  1563. mutate(color = case_when(
  1564. padj < 0.05 & Log2FC > 0.58496250072 ~ "color2",
  1565. padj < 0.05 & Log2FC < -0.58496250072 ~ "color3",
  1566. padj > 0.05 ~ "color1",
  1567. Log2FC > -1 ~ "color1",
  1568. Log2FC < 1 ~ "color1"
  1569. ))
  1570. BL12_volc <- ggplot(data = log2fc) +
  1571. aes(x = Log2FC, y = -log10(padj), color = color) +
  1572. geom_hline(yintercept = -log10(0.05), lty = 2) +
  1573. geom_vline(xintercept = 0.58496250072, lty = 3) +
  1574. geom_vline(xintercept = -0.58496250072, lty = 3) +
  1575. geom_point(alpha = 0.5, size = 2) +
  1576. scale_color_manual(values = c("gray", "#BF0D3E", "steelblue"), labels = c("N.S.", "Increased", "Decreased")) +
  1577. labs(x = expression("log"[2]*"(FC)"), y = expression("-log"[10]*"(p-adj)"), color = "Abundance") +
  1578. theme_bw() +
  1579. #theme(plot.title = element_text(size = 18)) +
  1580. ggrepel::geom_text_repel(aes(x = Log2FC, y = -log10(padj), label = var), color = "black", size = 2.6, max.overlaps = 8) #+
  1581. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 2, vjust = -8.25, label = bquote("Total:"~.(sum(TREM2_tar_res_df$qval < 0.05)))) +
  1582. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.525, vjust = -6.75, label = bquote("Increased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef > 0)))) +
  1583. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.55, vjust = -5, label = bquote("Decreased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef < 0))))
  1584. BL12_volc
  1585. BL12_DF <- log2fc %>% filter((padj < 0.05 & Log2FC > 0.58496250072) | (padj < 0.05 & Log2FC < -0.58496250072))
  1586. BL12_DF <-select(BL12_DF, var, Log2FC, padj)
  1587. write.csv(BL12_DF, "Figure5H.csv", row.names=FALSE)
  1588. ggsave("Figure5G.png", BL12_volc, width = 7, height = 4)
  1589. #Liver 5xFAD*Trem2 vs 5xFAD 4mo. targ.met
  1590. TREM2_tar_df = tar_df_combined %>%
  1591. filter(Group2 %in% c("HEMI 5xFAD", "HEMI 5xFAD_TREM2"), Age == 4, Mode == "liver") %>%
  1592. column_to_rownames(var = "sample_id")
  1593. #Note: its named t test but its using a wilcox test
  1594. t_test_df = TREM2_tar_df %>%
  1595. select(`1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1`) %>%
  1596. map_df(~ broom::tidy(wilcox.test(. ~ TREM2_tar_df$Group2)), .id = 'var') %>%
  1597. select(var, p.value)
  1598. t_test_df$padj = p.adjust(t_test_df$p.value, method = "fdr") #changed to FDR, less stringent
  1599. #Need to calc fold change
  1600. log2fc = TREM2_tar_df %>%
  1601. group_by(Group2) %>%
  1602. summarise(across(`1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1`, mean)) %>%
  1603. column_to_rownames(var = "Group2") %>%
  1604. t(.)
  1605. log2fc = as.data.frame(log2fc)
  1606. log2fc$Ratio = log2fc$`HEMI 5xFAD_TREM2` / log2fc$`HEMI 5xFAD`
  1607. log2fc$Log2FC = log(log2fc$Ratio, base = 2)
  1608. log2fc[is.na(log2fc)] <- 0 #change any NaN to 0
  1609. log2fc = log2fc %>%
  1610. rownames_to_column(var = "var") %>%
  1611. left_join(t_test_df)
  1612. #Volcano plot
  1613. log2fc = log2fc %>%
  1614. mutate(color = case_when(
  1615. padj < 0.05 & Log2FC > 0.58496250072 ~ "color2",
  1616. padj < 0.05 & Log2FC < -0.58496250072 ~ "color3",
  1617. padj > 0.05 ~ "color1",
  1618. Log2FC > -1 ~ "color1",
  1619. Log2FC < 1 ~ "color1"
  1620. ))
  1621. LTM4_volc_2 <- ggplot(data = log2fc) +
  1622. aes(x = Log2FC, y = -log10(padj), color = color) +
  1623. geom_hline(yintercept = -log10(0.05), lty = 2) +
  1624. geom_vline(xintercept = 0.58496250072, lty = 3) +
  1625. geom_vline(xintercept = -0.58496250072, lty = 3) +
  1626. geom_point(alpha = 0.5, size = 2) +
  1627. scale_color_manual(values = c("gray", "steelblue"), labels = c("N.S.", "Decreased")) +
  1628. labs(x = expression("log"[2]*"(FC)"), y = expression("-log"[10]*"(p-adj)"), color = "Abundance") +
  1629. theme_bw() +
  1630. #theme(plot.title = element_text(size = 18)) +
  1631. ggrepel::geom_text_repel(aes(x = Log2FC, y = -log10(padj), label = var), color = "black", size = 2.6, max.overlaps = 8) #+
  1632. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 2, vjust = -8.25, label = bquote("Total:"~.(sum(TREM2_tar_res_df$qval < 0.05)))) +
  1633. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.525, vjust = -6.75, label = bquote("Increased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef > 0)))) +
  1634. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.55, vjust = -5, label = bquote("Decreased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef < 0))))
  1635. LTM4_volc_2
  1636. LTM4_DF_2 <- log2fc %>% filter((padj < 0.05 & Log2FC > 0.58496250072) | (padj < 0.05 & Log2FC < -0.58496250072))
  1637. LTM4_DF_2 <-select(LTM4_DF_2, var, Log2FC, padj)
  1638. write.csv(LTM4_DF_2, "Figure5B.csv", row.names=FALSE)
  1639. ggsave("Figure5A.png", LTM4_volc_2, width = 7, height = 4)
  1640. #Plasma 5xFAD*Trem2 vs 5xFAD 4mo. targ.met
  1641. TREM2_tar_df = tar_df_combined %>%
  1642. filter(Group2 %in% c("HEMI 5xFAD", "HEMI 5xFAD_TREM2"), Age == 4, Mode == "plasma") %>%
  1643. column_to_rownames(var = "sample_id")
  1644. #Note: its named t test but its using a wilcox test
  1645. t_test_df = TREM2_tar_df %>%
  1646. select(`1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1`) %>%
  1647. map_df(~ broom::tidy(wilcox.test(. ~ TREM2_tar_df$Group2)), .id = 'var') %>%
  1648. select(var, p.value)
  1649. t_test_df$padj = p.adjust(t_test_df$p.value, method = "fdr") #changed to FDR, less stringent
  1650. #Need to calc fold change
  1651. log2fc = TREM2_tar_df %>%
  1652. group_by(Group2) %>%
  1653. summarise(across(`1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1`, mean)) %>%
  1654. column_to_rownames(var = "Group2") %>%
  1655. t(.)
  1656. log2fc = as.data.frame(log2fc)
  1657. log2fc$Ratio = log2fc$`HEMI 5xFAD_TREM2` / log2fc$`HEMI 5xFAD`
  1658. log2fc$Log2FC = log(log2fc$Ratio, base = 2)
  1659. log2fc[is.na(log2fc)] <- 0 #change any NaN to 0
  1660. log2fc = log2fc %>%
  1661. rownames_to_column(var = "var") %>%
  1662. left_join(t_test_df)
  1663. #Volcano plot
  1664. log2fc = log2fc %>%
  1665. mutate(color = case_when(
  1666. padj < 0.05 & Log2FC > 0.58496250072 ~ "color2",
  1667. padj < 0.05 & Log2FC < -0.58496250072 ~ "color3",
  1668. padj > 0.05 ~ "color1",
  1669. Log2FC > -1 ~ "color1",
  1670. Log2FC < 1 ~ "color1"
  1671. ))
  1672. PTM4_volc_2 <- ggplot(data = log2fc) +
  1673. aes(x = Log2FC, y = -log10(padj), color = color) +
  1674. geom_hline(yintercept = -log10(0.05), lty = 2) +
  1675. geom_vline(xintercept = 0.58496250072, lty = 3) +
  1676. geom_vline(xintercept = -0.58496250072, lty = 3) +
  1677. geom_point(alpha = 0.5, size = 2) +
  1678. scale_color_manual(values = c("gray", "#BF0D3E", "steelblue"), labels = c("N.S.", "Increased", "Decreased")) +
  1679. labs(x = expression("log"[2]*"(FC)"), y = expression("-log"[10]*"(p-adj)"), color = "Abundance") +
  1680. theme_bw() +
  1681. #theme(plot.title = element_text(size = 18)) +
  1682. ggrepel::geom_text_repel(aes(x = Log2FC, y = -log10(padj), label = var), color = "black", size = 2.6, max.overlaps = 8) #+
  1683. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 2, vjust = -8.25, label = bquote("Total:"~.(sum(TREM2_tar_res_df$qval < 0.05)))) +
  1684. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.525, vjust = -6.75, label = bquote("Increased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef > 0)))) +
  1685. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.55, vjust = -5, label = bquote("Decreased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef < 0))))
  1686. PTM4_volc_2
  1687. PTM4_DF_2 <- log2fc %>% filter((padj < 0.05 & Log2FC > 0.58496250072) | (padj < 0.05 & Log2FC < -0.58496250072))
  1688. PTM4_DF_2 <-select(PTM4_DF_2, var, Log2FC, padj)
  1689. write.csv(PTM4_DF_2, "Figure5D.csv", row.names=FALSE)
  1690. ggsave("Figure5C.png", PTM4_volc_2, width = 7, height = 4)
  1691. #Brain 5xFAD*Trem2 vs. 5xFAD 4mo. targ.met
  1692. TREM2_tar_df = tar_df_combined %>%
  1693. filter(Group2 %in% c("HEMI 5xFAD", "HEMI 5xFAD_TREM2"), Age == 4, Mode == "brain") %>%
  1694. column_to_rownames(var = "sample_id")
  1695. #Note: its named t test but its using a wilcox test
  1696. t_test_df = TREM2_tar_df %>%
  1697. select(`1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1`) %>%
  1698. map_df(~ broom::tidy(wilcox.test(. ~ TREM2_tar_df$Group2)), .id = 'var') %>%
  1699. select(var, p.value)
  1700. t_test_df$padj = p.adjust(t_test_df$p.value, method = "fdr") #changed to FDR, less stringent
  1701. #Need to calc fold change
  1702. log2fc = TREM2_tar_df %>%
  1703. group_by(Group2) %>%
  1704. summarise(across(`1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1`, mean)) %>%
  1705. column_to_rownames(var = "Group2") %>%
  1706. t(.)
  1707. log2fc = as.data.frame(log2fc)
  1708. log2fc$Ratio = log2fc$`HEMI 5xFAD_TREM2` / log2fc$`HEMI 5xFAD`
  1709. log2fc$Log2FC = log(log2fc$Ratio, base = 2)
  1710. log2fc[is.na(log2fc)] <- 0 #change any NaN to 0
  1711. log2fc = log2fc %>%
  1712. rownames_to_column(var = "var") %>%
  1713. left_join(t_test_df)
  1714. #Volcano plot
  1715. log2fc = log2fc %>%
  1716. mutate(color = case_when(
  1717. padj < 0.05 & Log2FC > 0.58496250072 ~ "color2",
  1718. padj < 0.05 & Log2FC < -0.58496250072 ~ "color3",
  1719. padj > 0.05 ~ "color1",
  1720. Log2FC > -1 ~ "color1",
  1721. Log2FC < 1 ~ "color1"
  1722. ))
  1723. BTM4_volc_2 <- ggplot(data = log2fc) +
  1724. aes(x = Log2FC, y = -log10(padj), color = color) +
  1725. geom_hline(yintercept = -log10(0.05), lty = 2) +
  1726. geom_vline(xintercept = 0.58496250072, lty = 3) +
  1727. geom_vline(xintercept = -0.58496250072, lty = 3) +
  1728. geom_point(alpha = 0.5, size = 2) +
  1729. scale_color_manual(values = c("gray", "#BF0D3E", "steelblue"), labels = c("N.S.", "Increased", "Decreased")) +
  1730. labs(x = expression("log"[2]*"(FC)"), y = expression("-log"[10]*"(p-adj)"), color = "Abundance") +
  1731. theme_bw() +
  1732. #theme(plot.title = element_text(size = 18)) +
  1733. ggrepel::geom_text_repel(aes(x = Log2FC, y = -log10(padj), label = var), color = "black", size = 2.6, max.overlaps = 8) #+
  1734. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 2, vjust = -8.25, label = bquote("Total:"~.(sum(TREM2_tar_res_df$qval < 0.05)))) +
  1735. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.525, vjust = -6.75, label = bquote("Increased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef > 0)))) +
  1736. #annotate("text", x = Inf, y = -Inf, size = 3, hjust = 1.55, vjust = -5, label = bquote("Decreased:"~.(sum(TREM2_tar_res_df$qval < 0.05 & TREM2_tar_res_df$coef < 0))))
  1737. BTM4_volc_2
  1738. BTM4_DF_2 <- log2fc %>% filter((padj < 0.05 & Log2FC > 0.58496250072) | (padj < 0.05 & Log2FC < -0.58496250072))
  1739. BTM4_DF_2 <-select(BTM4_DF_2, var, Log2FC, padj)
  1740. write.csv(BTM4_DF_2, "Figure5F.csv", row.names=FALSE)
  1741. ggsave("Figure5E.png", BTM4_volc_2, width = 7, height = 4)
  1742. ##############
  1743. ##############5-MTHF abundance p-values and Violin plots##############
  1744. ##Kruskal-Wallis test with post-hoc Dunn’s test
  1745. #Extract 4-month brain samples
  1746. TREM2_tar_df = tar_df_combined %>%
  1747. filter(Mode == "brain", Age == "4") %>%
  1748. column_to_rownames(var = "sample_id")
  1749. #Extract relevant columns
  1750. kw_df <- TREM2_tar_df[, c("Group2", "5-METHYLTETRAHYDROFOLIC ACID_pos_4")]
  1751. #Shapiro-Wilk normality test
  1752. #if p < 0.05 the data is not normally distributed
  1753. #if p > 0.05 the data is normally distributed
  1754. shapiro.test(kw_df$`5-METHYLTETRAHYDROFOLIC ACID_pos_4`)
  1755. # W = 0.49383, p-value = 2.953e-12
  1756. # data is NOT normally distributed
  1757. kruskal.test(`5-METHYLTETRAHYDROFOLIC ACID_pos_4` ~ Group2, data=kw_df)
  1758. # Kruskal-Wallis chi-squared = 32.924, df = 3,
  1759. # p-value = 3.342e-07
  1760. dunnTest(`5-METHYLTETRAHYDROFOLIC ACID_pos_4` ~ Group2, data=kw_df, method="bonferroni")
  1761. # Comparison Z P.unadj P.adj
  1762. # 1 HEMI 5xFAD - HEMI 5xFAD_TREM2 -3.9341319 8.349791e-05 5.009875e-04 ***
  1763. # 2 HEMI 5xFAD - WT 5xFAD 0.4664076 6.409238e-01 1.000000e+00 n.s.
  1764. # 3 HEMI 5xFAD_TREM2 - WT 5xFAD 4.3222065 1.544765e-05 9.268589e-05 ***
  1765. # 4 HEMI 5xFAD - WT 5xFAD_TREM2 -3.7570979 1.718953e-04 1.031372e-03 **
  1766. # 5 HEMI 5xFAD_TREM2 - WT 5xFAD_TREM2 0.2708968 7.864704e-01 1.000000e+00 n.s.
  1767. # 6 WT 5xFAD - WT 5xFAD_TREM2 -4.1585176 3.203195e-05 1.921917e-04 ***
  1768. #Extract 12-month brain samples
  1769. TREM2_tar_df = tar_df_combined %>%
  1770. filter(Mode == "brain", Age == "12") %>%
  1771. column_to_rownames(var = "sample_id")
  1772. #Extract relevant columns
  1773. kw_df <- TREM2_tar_df[, c("Group2", "5-METHYLTETRAHYDROFOLIC ACID_pos_4")]
  1774. #Shapiro-Wilk normality test
  1775. #if p < 0.05 the data is not normally distributed
  1776. #if p > 0.05 the data is normally distributed
  1777. shapiro.test(kw_df$`5-METHYLTETRAHYDROFOLIC ACID_pos_4`)
  1778. # W = 0.47607, p-value = 2.088e-15
  1779. # data is NOT normally distributed
  1780. kruskal.test(`5-METHYLTETRAHYDROFOLIC ACID_pos_4` ~ Group2, data=kw_df)
  1781. # Kruskal-Wallis chi-squared = 7.0677, df = 3,
  1782. # p-value = 0.06977
  1783. dunnTest(`5-METHYLTETRAHYDROFOLIC ACID_pos_4` ~ Group2, data=kw_df, method="bonferroni")
  1784. # Comparison Z P.unadj P.adj
  1785. # 1 HEMI 5xFAD - HEMI 5xFAD_TREM2 -1.9675186 0.04912346 0.29474076 n.s.
  1786. # 2 HEMI 5xFAD - WT 5xFAD 0.4890598 0.62479939 1.00000000 n.s.
  1787. # 3 HEMI 5xFAD_TREM2 - WT 5xFAD 2.4055679 0.01614735 0.09688412 n.s.
  1788. # 4 HEMI 5xFAD - WT 5xFAD_TREM2 -1.1300357 0.25846120 1.00000000 n.s.
  1789. # 5 HEMI 5xFAD_TREM2 - WT 5xFAD_TREM2 0.7673536 0.44287128 1.00000000 n.s.
  1790. # 6 WT 5xFAD - WT 5xFAD_TREM2 -1.5635354 0.11792672 0.70756034 n.s.
  1791. ##Violin plots
  1792. #4-months
  1793. TREM2_tar_df = tar_df_combined %>%
  1794. filter(Mode == "brain", Age == "4") %>%
  1795. column_to_rownames(var = "sample_id")
  1796. #Adjust names and values
  1797. TREM2_tar_df[,-(1:12)] = log10(TREM2_tar_df[,-(1:12)]) %>% #Normalization
  1798. replace(is.na(.), 0)
  1799. TREM2_tar_df = subset(TREM2_tar_df, select = -c(Genotype))
  1800. names(TREM2_tar_df) [8] <- c("Genotype")
  1801. TREM2_tar_df <- TREM2_tar_df %>%
  1802. mutate(., Genotype = stringr::str_replace(Genotype, "WT 5xFAD_TREM2", "TREM2")) %>%
  1803. mutate(., Genotype = stringr::str_replace(Genotype, "WT 5xFAD", "WT")) %>%
  1804. mutate(., Genotype = stringr::str_replace(Genotype, "HEMI 5xFAD_TREM2", "5xFAD*TREM2")) %>%
  1805. mutate(., Genotype = stringr::str_replace(Genotype, "HEMI 5xFAD", "5xFAD"))
  1806. gwsC <- c("forestgreen", "gold", "steelblue1", "firebrick3")
  1807. p1 <- ggplot(TREM2_tar_df, aes(x=Genotype, y=`5-METHYLTETRAHYDROFOLIC ACID_pos_4`, fill=Genotype)) +
  1808. geom_violin(trim=FALSE, scale="area") +
  1809. theme_bw() +
  1810. ylim(-3.2,2.2) +
  1811. stat_summary(fun=mean, geom="point", shape=23, size=2, fill="yellow") +
  1812. geom_point(aes(shape=Sex), position=position_jitter(0.2)) +
  1813. scale_fill_manual(breaks=c("TREM2", "WT", "5xFAD*TREM2", "5xFAD"), values = gwsC) +
  1814. labs(y = expression("Log"[10]*" 5-MTHF Abundance")) +
  1815. scale_x_discrete(limits=c("TREM2", "WT", "5xFAD*TREM2", "5xFAD")) +
  1816. theme(axis.title.y = element_text(margin = margin(t = 0, r = 10, b = 0, l = 0)),
  1817. axis.title.x=element_blank(),
  1818. panel.grid.major = element_blank(),
  1819. panel.grid.minor = element_blank())
  1820. p1
  1821. ggsave("Figure8a.png", p, width = 8.5, height = 4.5)
  1822. #TREM2 and WT only (Figure2H)
  1823. TREM2_tar_df2 <- TREM2_tar_df %>%
  1824. filter(Genotype %in% c("TREM2", "WT"))
  1825. q <- ggplot(TREM2_tar_df2, aes(x=Genotype, y=`5-METHYLTETRAHYDROFOLIC ACID_pos_4`, fill=Genotype)) +
  1826. geom_violin(trim=FALSE, scale="area") +
  1827. theme_bw() +
  1828. stat_summary(fun.y=mean, geom="point", shape=23, size=2, fill="yellow") +
  1829. geom_point(aes(shape=Sex), position=position_jitter(0.2)) +
  1830. scale_fill_manual(breaks=c("TREM2", "WT"), values = gwsC) +
  1831. labs(y = expression("Log"[10]*" 5-MTHF Abundance")) +
  1832. scale_x_discrete(limits=c("TREM2", "WT")) +
  1833. theme(axis.title.y = element_text(margin = margin(t = 0, r = 10, b = 0, l = 0)),
  1834. axis.title.x=element_blank(),
  1835. panel.grid.major = element_blank(),
  1836. panel.grid.minor = element_blank())
  1837. q
  1838. ggsave("Figure2H.png", q, width = 5, height = 4)
  1839. #12-months
  1840. TREM2_tar_df = tar_df_combined %>%
  1841. filter(Mode == "brain", Age == "12") %>%
  1842. column_to_rownames(var = "sample_id")
  1843. #Adjust names and values
  1844. TREM2_tar_df[,-(1:12)] = log10(TREM2_tar_df[,-(1:12)]) %>% #Normalization
  1845. replace(is.na(.), 0)
  1846. TREM2_tar_df = subset(TREM2_tar_df, select = -c(Genotype))
  1847. names(TREM2_tar_df) [8] <- c("Genotype")
  1848. TREM2_tar_df <- TREM2_tar_df %>%
  1849. mutate(., Genotype = stringr::str_replace(Genotype, "WT 5xFAD_TREM2", "TREM2")) %>%
  1850. mutate(., Genotype = stringr::str_replace(Genotype, "WT 5xFAD", "WT")) %>%
  1851. mutate(., Genotype = stringr::str_replace(Genotype, "HEMI 5xFAD_TREM2", "5xFAD*TREM2")) %>%
  1852. mutate(., Genotype = stringr::str_replace(Genotype, "HEMI 5xFAD", "5xFAD"))
  1853. gwsC <- c("forestgreen", "gold", "steelblue1", "firebrick3")
  1854. p2 <- ggplot(TREM2_tar_df, aes(x=Genotype, y=`5-METHYLTETRAHYDROFOLIC ACID_pos_4`, fill=Genotype)) +
  1855. geom_violin(trim=FALSE, scale="area") +
  1856. theme_bw() +
  1857. ylim(-3.2,2.2) +
  1858. stat_summary(fun=mean, geom="point", shape=23, size=2, fill="yellow") +
  1859. geom_point(aes(shape=Sex), position=position_jitter(0.2)) +
  1860. scale_fill_manual(breaks=c("TREM2", "WT", "5xFAD*TREM2", "5xFAD"), values = gwsC) +
  1861. labs(y = expression("Log"[10]*" 5-MTHF Abundance")) +
  1862. scale_x_discrete(limits=c("TREM2", "WT", "5xFAD*TREM2", "5xFAD")) +
  1863. theme(axis.title.y = element_text(margin = margin(t = 0, r = 10, b = 0, l = 0)),
  1864. axis.title.x=element_blank(),
  1865. panel.grid.major = element_blank(),
  1866. panel.grid.minor = element_blank())
  1867. p2
  1868. ggsave("Figure8b.png", p, width = 8.5, height = 4.5)
  1869. ggarrange(p1, p2, ncol=2, nrow=1, common.legend = TRUE, legend="right")
  1870. ggsave("Figure8.png", width = 11, height = 4.5)
  1871. ##############
  1872. ##############Plasma lipid DA analysis by Sex##############
  1873. #Lipid plasma
  1874. TREM2_lip_df = lip_df_combined %>%
  1875. filter(Mode == "plasma") %>%
  1876. column_to_rownames(var = "sample_id")
  1877. #Note: its named t test but its using a wilcox test
  1878. t_test_df = TREM2_lip_df %>%
  1879. select(`CE(12:0)`:`TAG56:1-FA18:1`) %>%
  1880. map_df(~ broom::tidy(wilcox.test(. ~ TREM2_lip_df$Sex)), .id = 'var') %>%
  1881. select(var, p.value)
  1882. t_test_df$padj = p.adjust(t_test_df$p.value, method = "fdr") #changed to FDR, less stringent
  1883. #Need to calc fold change
  1884. log2fc = TREM2_lip_df %>%
  1885. group_by(Sex) %>%
  1886. summarise(across(`CE(12:0)`:`TAG56:1-FA18:1`, mean)) %>%
  1887. column_to_rownames(var = "Sex") %>%
  1888. t(.)
  1889. log2fc = as.data.frame(log2fc)
  1890. log2fc$Ratio = log2fc$`M`/ log2fc$`F`
  1891. log2fc$Log2FC = log(log2fc$Ratio, base = 2)
  1892. log2fc[is.na(log2fc)] <- 0 #change any NaN to 0
  1893. log2fc = log2fc %>%
  1894. rownames_to_column(var = "var") %>%
  1895. left_join(t_test_df)
  1896. log2fc = log2fc %>%
  1897. mutate(color = case_when(
  1898. padj < 0.05 & Log2FC > 0.58496250072 ~ "color2",
  1899. padj < 0.05 & Log2FC < -0.58496250072 ~ "color3",
  1900. padj > 0.05 ~ "color1",
  1901. Log2FC > -1 ~ "color1",
  1902. Log2FC < 1 ~ "color1"
  1903. ))
  1904. # only significant (X significant DA metabolites)
  1905. SEX1 <- log2fc %>% filter(color %in% c("color2", "color3"))
  1906. write.csv(SEX1, "plasma-sex.csv", row.names=FALSE)
  1907. ##############
  1908. ##############Heatmaps##############
  1909. #Figure 6
  1910. ###Top100 M vs. F
  1911. #Repeat for all Modes (liver-plasma-brain) for both lipids and polar metabolites
  1912. TREM2_tar_df = tar_df_combined %>% #use tar_df_combined for targ.met, and lip_df_combined for lipids
  1913. filter(Mode == "brain") %>%
  1914. column_to_rownames(var = "sample_id")
  1915. #Note: its named t test but its using a wilcox test
  1916. t_test_df = TREM2_tar_df %>%
  1917. select(`1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1`) %>% #use `1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1` for targ.met and `CE(12:0)`:`TAG56:1-FA18:1` for lipids
  1918. map_df(~ broom::tidy(wilcox.test(. ~ TREM2_tar_df$Sex)), .id = 'var') %>%
  1919. select(var, p.value)
  1920. t_test_df$padj = p.adjust(t_test_df$p.value, method = "fdr") #changed to FDR, less stringent
  1921. #Need to calc fold change
  1922. log2fc = TREM2_tar_df %>%
  1923. group_by(Sex) %>%
  1924. summarise(across(`1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1`, mean)) %>% #use 1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1` for targ.met and `CE(12:0)`:`TAG56:1-FA18:1` for lipids
  1925. column_to_rownames(var = "Sex") %>%
  1926. t(.)
  1927. log2fc = as.data.frame(log2fc)
  1928. log2fc$Ratio = log2fc$`M`/ log2fc$`F`
  1929. log2fc$Log2FC = log(log2fc$Ratio, base = 2)
  1930. log2fc[is.na(log2fc)] <- 0 #change any NaN to 0
  1931. log2fc = log2fc %>%
  1932. rownames_to_column(var = "var") %>%
  1933. left_join(t_test_df)
  1934. #top 100 most differential based on Log2FC
  1935. top_100_tar = log2fc %>%
  1936. slice_max(order_by = abs(Log2FC), n = 100)
  1937. #Plot relative abundances (log10 transformed)
  1938. test = tar_df_combined %>% #use tar_df_combined for targ.met, and lip_df_combined for lipids
  1939. column_to_rownames(var = "sample_id") %>%
  1940. filter(Mode == "brain") %>%
  1941. select(top_100_tar$var)
  1942. tar_zscore_df = test
  1943. tar_zscore_df = log10(tar_zscore_df) %>% #Normalization
  1944. replace(is.na(.), 0)
  1945. rownames(tar_zscore_df) = rownames(test)
  1946. tar_zscore_df = as.data.frame(tar_zscore_df)
  1947. tar_zscore_df = replace(tar_zscore_df, is.na(tar_zscore_df), 0)
  1948. #Make heatmap
  1949. ann_colors = list(Sex = c(`F`="lightpink", `M`="lightblue"),
  1950. Genotype = c(`HEMI 5xFAD`="firebrick3", `HEMI 5xFAD_TREM2`="steelblue1", `WT 5xFAD`="gold", `WT 5xFAD_TREM2`="forestgreen"),
  1951. Age = c(`12`="azure3", `4`="steelblue4")
  1952. )
  1953. tar_merged_zscores = tar_zscore_df %>%
  1954. select(which(!colSums(.) == 0)) %>%
  1955. rownames_to_column(var = "sample_id") %>%
  1956. separate_wider_delim(cols = sample_id, names = c("Name", "Mode"), delim = "_", cols_remove = F) %>%
  1957. inner_join(metadata) %>%
  1958. relocate(CageID:Background, .after = sample_id) %>%
  1959. column_to_rownames(var = "sample_id") %>%
  1960. select(-Genotype) %>%
  1961. rename(Genotype=Group2) %>%
  1962. arrange(Mode, Sex, Genotype, Age)
  1963. hm2 <- pheatmap(t(select(tar_merged_zscores, !Name:Background)), border_color = "NA",
  1964. annotation_col = data.frame(rownames_to_column(tar_merged_zscores, var = "sample_id") %>% select(sample_id, Age) %>% column_to_rownames(var = "sample_id"),
  1965. rownames_to_column(tar_merged_zscores, var = "sample_id") %>% select(sample_id, Genotype) %>% column_to_rownames(var = "sample_id"),
  1966. rownames_to_column(tar_merged_zscores, var = "sample_id") %>% select(sample_id, Sex) %>% column_to_rownames(var = "sample_id")
  1967. ),
  1968. annotation_colors = ann_colors,
  1969. show_colnames = F, fontsize = 12, fontsize_row = 5.5, cluster_rows = T, cluster_cols = F, cutree_rows = 5, main = "Brain - metabolites")
  1970. save_pheatmap(hm2, "HM-Figure6F.png", width=7.5, height=8.5)
  1971. #for plasma: use breaks to make tables more different
  1972. my.breaks <- c(seq(-1.5, 1.5, by=0.1))
  1973. hm3 <- pheatmap(t(select(tar_merged_zscores, !Name:Background)),
  1974. border_color = "NA",
  1975. color = colorRampPalette(rev(brewer.pal(n = 7, name = "RdYlBu")))(length(my.breaks)),
  1976. breaks = my.breaks,
  1977. annotation_col = data.frame(rownames_to_column(tar_merged_zscores, var = "sample_id") %>% select(sample_id, Age) %>% column_to_rownames(var = "sample_id"),
  1978. rownames_to_column(tar_merged_zscores, var = "sample_id") %>% select(sample_id, Genotype) %>% column_to_rownames(var = "sample_id"),
  1979. rownames_to_column(tar_merged_zscores, var = "sample_id") %>% select(sample_id, Sex) %>% column_to_rownames(var = "sample_id")
  1980. ),
  1981. annotation_colors = ann_colors,
  1982. show_colnames = F, fontsize = 12, fontsize_row = 5.5, cluster_rows = T, cluster_cols = F, cutree_rows = 2, main = "Plasma - metabolites") #fontsize row 6 for lipids and 5.5 for targmet
  1983. save_pheatmap(hm3, "HM-Figure6D.png", width=7.5, height=8.5)
  1984. #Figure S6
  1985. ###Top100 5xFAD vs. 5xFAD*TREM2
  1986. #Repeat for all Modes (liver-plasma-brain) for both lipids and polar metabolites
  1987. TREM2_tar_df = lip_df_combined %>% #use tar_df_combined for targ.met, and lip_df_combined for lipids
  1988. filter(Group2 %in% c("HEMI 5xFAD", "HEMI 5xFAD_TREM2"), Mode == "brain") %>%
  1989. column_to_rownames(var = "sample_id")
  1990. #Note: its named t test but its using a wilcox test
  1991. t_test_df = TREM2_tar_df %>%
  1992. select(`CE(12:0)`:`TAG56:1-FA18:1`) %>% #use `1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1` for targ.met and `CE(12:0)`:`TAG56:1-FA18:1` for lipids
  1993. map_df(~ broom::tidy(wilcox.test(. ~ TREM2_tar_df$Group2)), .id = 'var') %>%
  1994. select(var, p.value)
  1995. t_test_df$padj = p.adjust(t_test_df$p.value, method = "fdr") #changed to FDR, less stringent
  1996. #Need to calc fold change
  1997. log2fc = TREM2_tar_df %>%
  1998. group_by(Group2) %>%
  1999. summarise(across(`CE(12:0)`:`TAG56:1-FA18:1`, mean)) %>% #use 1-METHYLADENOSINE_pos_1`:`RIBOFLAVIN_neg_1` for targ.met and `CE(12:0)`:`TAG56:1-FA18:1` for lipids
  2000. column_to_rownames(var = "Group2") %>%
  2001. t(.)
  2002. log2fc = as.data.frame(log2fc)
  2003. log2fc$Ratio = log2fc$`HEMI 5xFAD`/ log2fc$`HEMI 5xFAD_TREM2`
  2004. log2fc$Log2FC = log(log2fc$Ratio, base = 2)
  2005. log2fc[is.na(log2fc)] <- 0 #change any NaN to 0
  2006. log2fc = log2fc %>%
  2007. rownames_to_column(var = "var") %>%
  2008. left_join(t_test_df)
  2009. #top 100 most differential based on Log2FC
  2010. top_100_tar = log2fc %>%
  2011. slice_max(order_by = abs(Log2FC), n = 100)
  2012. #Plot relative abundances (log10 transformed)
  2013. test = lip_df_combined %>% #use tar_df_combined for targ.met, and lip_df_combined for lipids
  2014. column_to_rownames(var = "sample_id") %>%
  2015. filter(Mode == "brain") %>%
  2016. select(top_100_tar$var)
  2017. tar_zscore_df = test
  2018. tar_zscore_df = log10(tar_zscore_df) %>% #Normalization
  2019. replace(is.na(.), 0)
  2020. rownames(tar_zscore_df) = rownames(test)
  2021. tar_zscore_df = as.data.frame(tar_zscore_df)
  2022. tar_zscore_df = replace(tar_zscore_df, is.na(tar_zscore_df), 0)
  2023. #Make heatmap
  2024. ann_colors = list(Sex = c(`F`="lightpink", `M`="lightblue"),
  2025. Genotype = c(`HEMI 5xFAD`="firebrick3", `HEMI 5xFAD_TREM2`="steelblue1", `WT 5xFAD`="gold", `WT 5xFAD_TREM2`="forestgreen"),
  2026. Age = c(`12`="azure3", `4`="steelblue4")
  2027. )
  2028. tar_merged_zscores = tar_zscore_df %>%
  2029. select(which(!colSums(.) == 0)) %>%
  2030. rownames_to_column(var = "sample_id") %>%
  2031. separate_wider_delim(cols = sample_id, names = c("Name", "Mode"), delim = "_", cols_remove = F) %>%
  2032. inner_join(metadata) %>%
  2033. relocate(CageID:Background, .after = sample_id) %>%
  2034. column_to_rownames(var = "sample_id") %>%
  2035. select(-Genotype) %>%
  2036. rename(Genotype=Group2) %>%
  2037. arrange(Mode, Genotype, Sex, Age)
  2038. hm1 <- pheatmap(t(select(tar_merged_zscores, !Name:Background)), border_color = "NA",
  2039. annotation_col = data.frame(rownames_to_column(tar_merged_zscores, var = "sample_id") %>% select(sample_id, Age) %>% column_to_rownames(var = "sample_id"),
  2040. rownames_to_column(tar_merged_zscores, var = "sample_id") %>% select(sample_id, Sex) %>% column_to_rownames(var = "sample_id"),
  2041. rownames_to_column(tar_merged_zscores, var = "sample_id") %>% select(sample_id, Genotype) %>% column_to_rownames(var = "sample_id")
  2042. ),
  2043. annotation_colors = ann_colors,
  2044. show_colnames = F, fontsize = 12, fontsize_row = 5.5, cluster_rows = T, cluster_cols = F, cutree_rows = 4, main = "Brain - lipids") #fontsize row 6 for lipids and 5.5 for targmet
  2045. save_pheatmap(hm1, "HM-FigureS6C.png", width=7.5, height=8.5)
  2046. #for plasma: use breaks to make tables more different
  2047. my.breaks <- c(seq(-1.5, 1.5, by=0.1))
  2048. hm4 <- pheatmap(t(select(tar_merged_zscores, !Name:Background)),
  2049. border_color = "NA",
  2050. color = colorRampPalette(rev(brewer.pal(n = 7, name = "RdYlBu")))(length(my.breaks)),
  2051. breaks = my.breaks,
  2052. annotation_col = data.frame(rownames_to_column(tar_merged_zscores, var = "sample_id") %>% select(sample_id, Age) %>% column_to_rownames(var = "sample_id"),
  2053. rownames_to_column(tar_merged_zscores, var = "sample_id") %>% select(sample_id, Sex) %>% column_to_rownames(var = "sample_id"),
  2054. rownames_to_column(tar_merged_zscores, var = "sample_id") %>% select(sample_id, Genotype) %>% column_to_rownames(var = "sample_id")
  2055. ),
  2056. annotation_colors = ann_colors,
  2057. show_colnames = F, fontsize = 12, fontsize_row = 5.5, cluster_rows = T, cluster_cols = F, cutree_rows = 2, main = "Plasma - lipids") #fontsize row 6 for lipids and 5.5 for targmet
  2058. save_pheatmap(hm4, "HM-FigureS6A.png", width=7.5, height=8.5)
  2059. ##############
  2060. ##############Correlation analyses - 4 months##############
  2061. #Import DA metabolites
  2062. liver_da <- read.csv("Figure7A.csv")
  2063. plasma_da <- read.csv("Figure7C.csv")
  2064. brain_da <- read.csv("Figure7E.csv")
  2065. ############## . WT brain-liver metabolites##############
  2066. #WT 4 months targ.met
  2067. TREM2_tar_df = tar_df_combined %>%
  2068. filter(Group2 %in% c("WT 5xFAD"), Age == 4) %>%
  2069. column_to_rownames(var = "sample_id")
  2070. brain_df = TREM2_tar_df %>%
  2071. filter(Mode == "brain")
  2072. liver_df = TREM2_tar_df %>%
  2073. filter(Mode == "liver")
  2074. #Only keep brain data from Mouse IDs that we have liver data for
  2075. brain_df_cor <- brain_df[brain_df$Name %in% liver_df$Name, ]
  2076. #Only keep liver data from Mouse IDs that we have brain data for
  2077. liver_df_cor <- liver_df[liver_df$Name %in% brain_df$Name, ]
  2078. #Reassign rownames
  2079. rownames(brain_df_cor) <- NULL
  2080. rownames(brain_df_cor) <- brain_df_cor$Name
  2081. rownames(liver_df_cor) <- NULL
  2082. rownames(liver_df_cor) <- liver_df_cor$Name
  2083. #Arrange metadata
  2084. brain_df_cor <- brain_df_cor %>%
  2085. arrange(Name)
  2086. liver_df_cor <- liver_df_cor %>%
  2087. arrange(Name)
  2088. #Mantel significance test
  2089. set.seed <- 0123456789
  2090. brain.dist <- vegdist(brain_df_cor[,-(1:11)], method="bray")
  2091. liver.dist <- vegdist(liver_df_cor[,-(1:11)], method="bray")
  2092. mantel(brain.dist, liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2093. # Call:
  2094. # mantel(xdis = brain.dist, ydis = liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2095. #
  2096. # Mantel statistic r: 0.1477
  2097. # Significance: 0.1481
  2098. #
  2099. # Upper quantiles of permutations (null model):
  2100. # 90% 95% 97.5% 99%
  2101. # 0.190 0.255 0.309 0.370
  2102. # Permutation: free
  2103. # Number of permutations: 9999
  2104. #correlation analysis
  2105. correlation <- t(cor(brain_df_cor[,-(1:11)], liver_df_cor[,-(1:11)], method = c('spearman')))
  2106. correlation[is.na(correlation)] <- 0
  2107. #only keep brain analytes (columns) with at least one rho value > threshold
  2108. #135 @ rho>0.4, 41 @ rho>0.6, 8 @ rho>0.7
  2109. correlation_df <- as.data.frame(correlation)
  2110. columns_to_keep <- sapply(correlation_df, function(x) {
  2111. max_val <- max(x, na.rm = TRUE)
  2112. min_val <- min(x, na.rm = TRUE)
  2113. return(max_val > 0.7 | min_val < -0.7)
  2114. })
  2115. correlation_df <- correlation_df[, columns_to_keep]
  2116. #only keep liver analytes (rows) with at least one rho value > threshold
  2117. #270 lipids @ rho>0.4, 94 @ rho>0.6, 14 @ rho>0.7
  2118. correlation_df <- correlation_df[apply(correlation_df, 1, max) > 0.7 |
  2119. apply(correlation_df, 1, min) < -0.7, ]
  2120. #heatmap w/ thresholds
  2121. correlation <- as.matrix(correlation_df)
  2122. cor <- pheatmap(correlation, cluster_cols = TRUE, clustering_method = 'average', cluster_rows = TRUE,
  2123. gaps_col = FALSE, color = viridis(10), show_colnames = TRUE, show_rownames = TRUE,
  2124. fontsize = 8, fontsize_col = 6, cutree_cols = 2, angle_col = 90,
  2125. cutree_rows = 2, fontsize_row = 6, silent = FALSE)#, breaks = my.breaks)
  2126. save_pheatmap(cor, "WT_brain-v-liver.png", width=10, height=5)
  2127. #if rho<0.4, then make it grey (find clusters of lipids and proteins)
  2128. bk1 <- c(seq(-0.78, -0.39, by=0.02)) #spearman rho ranges from -0.39 to 0.49
  2129. bk2 <- c(seq(0.39, 0.76, by=0.02))
  2130. bk <- c(bk1,bk2) #combine the break limits for purpose of graphing
  2131. my_palette <- c(colorRampPalette(colors = c("#440154", "#2E6DA4"))(n = length(bk1)-1),
  2132. "gray60",
  2133. c(colorRampPalette(colors = c("#9DDE4B", "#FDE725"))(n = length(bk2)-1)))
  2134. cor <- pheatmap(correlation, cluster_cols = TRUE, clustering_method = 'average', cluster_rows = TRUE,
  2135. gaps_col = FALSE, color = my_palette, show_colnames = TRUE, show_rownames = TRUE,
  2136. fontsize = 8, fontsize_col = 6, cutree_cols = 2, angle_col = 90,
  2137. cutree_rows = 2, fontsize_row = 6, silent = FALSE, breaks = bk)
  2138. save_pheatmap(cor, "WT_brain-v-liver_grey.png", width=10, height=5)
  2139. write.csv(colnames(correlation_df), "WT_brain.csv", row.names=FALSE)
  2140. write.csv(rownames(correlation_df), "WT_liver.csv", row.names=FALSE)
  2141. #Mantel significance test (analytes in heatmap only)
  2142. set.seed <- 0123456789
  2143. brain_subset <- brain_df_cor[,colnames(correlation_df)]
  2144. liver_subset <- liver_df_cor[,rownames(correlation_df)]
  2145. brain.dist <- vegdist(brain_subset, method="bray")
  2146. liver.dist <- vegdist(liver_subset, method="bray")
  2147. mantel(brain.dist, liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2148. # Call:
  2149. # mantel(xdis = brain.dist, ydis = liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2150. #
  2151. # Mantel statistic r: -0.09216
  2152. # Significance: 0.7906
  2153. #
  2154. # Upper quantiles of permutations (null model):
  2155. # 90% 95% 97.5% 99%
  2156. # 0.144 0.186 0.223 0.270
  2157. # Permutation: free
  2158. # Number of permutations: 9999
  2159. ############## . 5xFAD brain-liver metabolites##############
  2160. #5xFAD 4 months targ.met
  2161. TREM2_tar_df = tar_df_combined %>%
  2162. filter(Group2 %in% c("HEMI 5xFAD"), Age == 4) %>%
  2163. column_to_rownames(var = "sample_id")
  2164. brain_df = TREM2_tar_df %>%
  2165. filter(Mode == "brain")
  2166. liver_df = TREM2_tar_df %>%
  2167. filter(Mode == "liver")
  2168. #Only keep brain data from Mouse IDs that we have liver data for
  2169. brain_df_cor <- brain_df[brain_df$Name %in% liver_df$Name, ]
  2170. #Only keep liver data from Mouse IDs that we have brain data for
  2171. liver_df_cor <- liver_df[liver_df$Name %in% brain_df$Name, ]
  2172. #Reassign rownames
  2173. rownames(brain_df_cor) <- NULL
  2174. rownames(brain_df_cor) <- brain_df_cor$Name
  2175. rownames(liver_df_cor) <- NULL
  2176. rownames(liver_df_cor) <- liver_df_cor$Name
  2177. #Arrange metadata
  2178. brain_df_cor <- brain_df_cor %>%
  2179. arrange(Name)
  2180. liver_df_cor <- liver_df_cor %>%
  2181. arrange(Name)
  2182. #Mantel significance test
  2183. set.seed <- 0123456789
  2184. brain.dist <- vegdist(brain_df_cor[,-(1:11)], method="bray")
  2185. liver.dist <- vegdist(liver_df_cor[,-(1:11)], method="bray")
  2186. mantel(brain.dist, liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2187. # Call:
  2188. # mantel(xdis = brain.dist, ydis = liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2189. #
  2190. # Mantel statistic r: 0.07397
  2191. # Significance: 0.2767
  2192. #
  2193. # Upper quantiles of permutations (null model):
  2194. # 90% 95% 97.5% 99%
  2195. # 0.182 0.242 0.293 0.351
  2196. # Permutation: free
  2197. # Number of permutations: 9999
  2198. #correlation analysis
  2199. correlation <- t(cor(brain_df_cor[,-(1:11)], liver_df_cor[,-(1:11)], method = c('spearman')))
  2200. correlation[is.na(correlation)] <- 0
  2201. #only keep brain analytes (columns) with at least one rho value > threshold
  2202. #35 @ rho>0.7
  2203. correlation_df <- as.data.frame(correlation)
  2204. columns_to_keep <- sapply(correlation_df, function(x) {
  2205. max_val <- max(x, na.rm = TRUE)
  2206. min_val <- min(x, na.rm = TRUE)
  2207. return(max_val > 0.7 | min_val < -0.7)
  2208. })
  2209. correlation_df <- correlation_df[, columns_to_keep]
  2210. #only keep liver analytes (rows) with at least one rho value > threshold
  2211. #49 @ rho>0.7
  2212. correlation_df <- correlation_df[apply(correlation_df, 1, max) > 0.7 |
  2213. apply(correlation_df, 1, min) < -0.7, ]
  2214. #heatmap w/ thresholds
  2215. correlation <- as.matrix(correlation_df)
  2216. cor <- pheatmap(correlation, cluster_cols = TRUE, clustering_method = 'average', cluster_rows = TRUE,
  2217. gaps_col = FALSE, color = viridis(10), show_colnames = TRUE, show_rownames = TRUE,
  2218. fontsize = 8, fontsize_col = 6, cutree_cols = 2, angle_col = 90,
  2219. cutree_rows = 2, fontsize_row = 6, silent = FALSE)#, breaks = my.breaks)
  2220. save_pheatmap(cor, "5x_brain-v-liver.png", width=10, height=5)
  2221. write.csv(colnames(correlation_df), "5x_brain.csv", row.names=FALSE)
  2222. write.csv(rownames(correlation_df), "5x_liver.csv", row.names=FALSE)
  2223. # #if rho<0.4, then make it grey (find clusters of lipids and proteins)
  2224. # bk1 <- c(seq(-0.78, -0.39, by=0.02)) #spearman rho ranges from -0.39 to 0.49
  2225. # bk2 <- c(seq(0.39, 0.76, by=0.02))
  2226. # bk <- c(bk1,bk2) #combine the break limits for purpose of graphing
  2227. #
  2228. # my_palette <- c(colorRampPalette(colors = c("#440154", "#2E6DA4"))(n = length(bk1)-1),
  2229. # "gray60",
  2230. # c(colorRampPalette(colors = c("#9DDE4B", "#FDE725"))(n = length(bk2)-1)))
  2231. #
  2232. # cor <- pheatmap(correlation, cluster_cols = TRUE, clustering_method = 'average', cluster_rows = TRUE,
  2233. # gaps_col = FALSE, color = my_palette, show_colnames = TRUE, show_rownames = TRUE,
  2234. # fontsize = 8, fontsize_col = 6, cutree_cols = 2, angle_col = 90,
  2235. # cutree_rows = 2, fontsize_row = 6, silent = FALSE, breaks = bk)
  2236. #
  2237. # save_pheatmap(cor, "WT_brain-v-liver_grey.png", width=10, height=5)
  2238. #Mantel significance test (analytes in heatmap only)
  2239. set.seed <- 0123456789
  2240. brain_subset <- brain_df_cor[,colnames(correlation_df)]
  2241. liver_subset <- liver_df_cor[,rownames(correlation_df)]
  2242. brain.dist <- vegdist(brain_subset, method="bray")
  2243. liver.dist <- vegdist(liver_subset, method="bray")
  2244. mantel(brain.dist, liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2245. # Call:
  2246. # mantel(xdis = brain.dist, ydis = liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2247. #
  2248. # Mantel statistic r: 0.01922
  2249. # Significance: 0.3929
  2250. #
  2251. # Upper quantiles of permutations (null model):
  2252. # 90% 95% 97.5% 99%
  2253. # 0.212 0.284 0.342 0.418
  2254. # Permutation: free
  2255. # Number of permutations: 9999
  2256. ############## . TREM2 brain-liver metabolites##############
  2257. #TREM2 4 months targ.met
  2258. TREM2_tar_df = tar_df_combined %>%
  2259. filter(Group2 %in% c("WT 5xFAD_TREM2"), Age == 4) %>%
  2260. column_to_rownames(var = "sample_id")
  2261. brain_df = TREM2_tar_df %>%
  2262. filter(Mode == "brain")
  2263. liver_df = TREM2_tar_df %>%
  2264. filter(Mode == "liver")
  2265. #Only keep brain data from Mouse IDs that we have liver data for
  2266. brain_df_cor <- brain_df[brain_df$Name %in% liver_df$Name, ]
  2267. #Only keep liver data from Mouse IDs that we have brain data for
  2268. liver_df_cor <- liver_df[liver_df$Name %in% brain_df$Name, ]
  2269. #Reassign rownames
  2270. rownames(brain_df_cor) <- NULL
  2271. rownames(brain_df_cor) <- brain_df_cor$Name
  2272. rownames(liver_df_cor) <- NULL
  2273. rownames(liver_df_cor) <- liver_df_cor$Name
  2274. #Arrange metadata
  2275. brain_df_cor <- brain_df_cor %>%
  2276. arrange(Name)
  2277. liver_df_cor <- liver_df_cor %>%
  2278. arrange(Name)
  2279. #Mantel significance test
  2280. set.seed <- 0123456789
  2281. brain.dist <- vegdist(brain_df_cor[,-(1:11)], method="bray")
  2282. liver.dist <- vegdist(liver_df_cor[,-(1:11)], method="bray")
  2283. mantel(brain.dist, liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2284. # Call:
  2285. # mantel(xdis = brain.dist, ydis = liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2286. #
  2287. # Mantel statistic r: -0.1132
  2288. # Significance: 0.7244
  2289. #
  2290. # Upper quantiles of permutations (null model):
  2291. # 90% 95% 97.5% 99%
  2292. # 0.229 0.303 0.364 0.442
  2293. # Permutation: free
  2294. # Number of permutations: 9999
  2295. #correlation analysis
  2296. correlation <- t(cor(brain_df_cor[,-(1:11)], liver_df_cor[,-(1:11)], method = c('spearman')))
  2297. correlation[is.na(correlation)] <- 0
  2298. #only keep brain analytes (columns) with at least one rho value > threshold
  2299. #120 @ rho>0.7
  2300. correlation_df <- as.data.frame(correlation)
  2301. columns_to_keep <- sapply(correlation_df, function(x) {
  2302. max_val <- max(x, na.rm = TRUE)
  2303. min_val <- min(x, na.rm = TRUE)
  2304. return(max_val > 0.7 | min_val < -0.7)
  2305. })
  2306. correlation_df <- correlation_df[, columns_to_keep]
  2307. #only keep liver analytes (rows) with at least one rho value > threshold
  2308. #251 @ rho>0.7
  2309. correlation_df <- correlation_df[apply(correlation_df, 1, max) > 0.7 |
  2310. apply(correlation_df, 1, min) < -0.7, ]
  2311. #heatmap w/ thresholds
  2312. correlation <- as.matrix(correlation_df)
  2313. cor <- pheatmap(correlation, cluster_cols = TRUE, clustering_method = 'average', cluster_rows = TRUE,
  2314. gaps_col = FALSE, color = viridis(10), show_colnames = TRUE, show_rownames = TRUE,
  2315. fontsize = 8, fontsize_col = 8, cutree_cols = 6, angle_col = 90,
  2316. cutree_rows = 6, fontsize_row = 8, silent = FALSE)#, breaks = my.breaks)
  2317. save_pheatmap(cor, "T2_brain-v-liver.png", width=14, height=28)
  2318. write.csv(colnames(correlation_df), "T2_brain.csv", row.names=FALSE)
  2319. write.csv(rownames(correlation_df), "T2_liver.csv", row.names=FALSE)
  2320. # #if rho<0.4, then make it grey (find clusters of lipids and proteins)
  2321. # bk1 <- c(seq(-0.78, -0.39, by=0.02)) #spearman rho ranges from -0.39 to 0.49
  2322. # bk2 <- c(seq(0.39, 0.76, by=0.02))
  2323. # bk <- c(bk1,bk2) #combine the break limits for purpose of graphing
  2324. #
  2325. # my_palette <- c(colorRampPalette(colors = c("#440154", "#2E6DA4"))(n = length(bk1)-1),
  2326. # "gray60",
  2327. # c(colorRampPalette(colors = c("#9DDE4B", "#FDE725"))(n = length(bk2)-1)))
  2328. #
  2329. # cor <- pheatmap(correlation, cluster_cols = TRUE, clustering_method = 'average', cluster_rows = TRUE,
  2330. # gaps_col = FALSE, color = my_palette, show_colnames = TRUE, show_rownames = TRUE,
  2331. # fontsize = 8, fontsize_col = 6, cutree_cols = 2, angle_col = 90,
  2332. # cutree_rows = 2, fontsize_row = 6, silent = FALSE, breaks = bk)
  2333. #
  2334. # save_pheatmap(cor, "WT_brain-v-liver_grey.png", width=10, height=5)
  2335. #Mantel significance test (analytes in heatmap only)
  2336. set.seed <- 0123456789
  2337. brain_subset <- brain_df_cor[,colnames(correlation_df)]
  2338. liver_subset <- liver_df_cor[,rownames(correlation_df)]
  2339. brain.dist <- vegdist(brain_subset, method="bray")
  2340. liver.dist <- vegdist(liver_subset, method="bray")
  2341. mantel(brain.dist, liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2342. # Call:
  2343. # mantel(xdis = brain.dist, ydis = liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2344. #
  2345. # Mantel statistic r: -0.2175
  2346. # Significance: 0.8302
  2347. #
  2348. # Upper quantiles of permutations (null model):
  2349. # 90% 95% 97.5% 99%
  2350. # 0.353 0.448 0.505 0.566
  2351. # Permutation: free
  2352. # Number of permutations: 9999
  2353. ############## . 5xFAD*TREM2 brain-liver metabolites##############
  2354. #5xFAD*TREM2 4 months targ.met
  2355. TREM2_tar_df = tar_df_combined %>%
  2356. filter(Group2 %in% c("HEMI 5xFAD_TREM2"), Age == 4) %>%
  2357. column_to_rownames(var = "sample_id")
  2358. brain_df = TREM2_tar_df %>%
  2359. filter(Mode == "brain")
  2360. liver_df = TREM2_tar_df %>%
  2361. filter(Mode == "liver")
  2362. #Only keep brain data from Mouse IDs that we have liver data for
  2363. brain_df_cor <- brain_df[brain_df$Name %in% liver_df$Name, ]
  2364. #Only keep liver data from Mouse IDs that we have brain data for
  2365. liver_df_cor <- liver_df[liver_df$Name %in% brain_df$Name, ]
  2366. #Reassign rownames
  2367. rownames(brain_df_cor) <- NULL
  2368. rownames(brain_df_cor) <- brain_df_cor$Name
  2369. rownames(liver_df_cor) <- NULL
  2370. rownames(liver_df_cor) <- liver_df_cor$Name
  2371. #Arrange metadata
  2372. brain_df_cor <- brain_df_cor %>%
  2373. arrange(Name)
  2374. liver_df_cor <- liver_df_cor %>%
  2375. arrange(Name)
  2376. #Mantel significance test
  2377. set.seed <- 0123456789
  2378. brain.dist <- vegdist(brain_df_cor[,-(1:11)], method="bray")
  2379. liver.dist <- vegdist(liver_df_cor[,-(1:11)], method="bray")
  2380. mantel(brain.dist, liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2381. # Call:
  2382. # mantel(xdis = brain.dist, ydis = liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2383. #
  2384. # Mantel statistic r: -0.2762
  2385. # Significance: 0.9121
  2386. #
  2387. # Upper quantiles of permutations (null model):
  2388. # 90% 95% 97.5% 99%
  2389. # 0.392 0.504 0.561 0.619
  2390. # Permutation: free
  2391. # Number of permutations: 9999
  2392. #correlation analysis
  2393. correlation <- t(cor(brain_df_cor[,-(1:11)], liver_df_cor[,-(1:11)], method = c('spearman')))
  2394. correlation[is.na(correlation)] <- 0
  2395. #only keep brain analytes (columns) with at least one rho value > threshold
  2396. #104 @ rho>0.7
  2397. correlation_df <- as.data.frame(correlation)
  2398. columns_to_keep <- sapply(correlation_df, function(x) {
  2399. max_val <- max(x, na.rm = TRUE)
  2400. min_val <- min(x, na.rm = TRUE)
  2401. return(max_val > 0.7 | min_val < -0.7)
  2402. })
  2403. correlation_df <- correlation_df[, columns_to_keep]
  2404. #only keep liver analytes (rows) with at least one rho value > threshold
  2405. #239 @ rho>0.7
  2406. correlation_df <- correlation_df[apply(correlation_df, 1, max) > 0.7 |
  2407. apply(correlation_df, 1, min) < -0.7, ]
  2408. #heatmap w/ thresholds
  2409. correlation <- as.matrix(correlation_df)
  2410. cor <- pheatmap(correlation, cluster_cols = TRUE, clustering_method = 'average', cluster_rows = TRUE,
  2411. gaps_col = FALSE, color = viridis(10), show_colnames = TRUE, show_rownames = TRUE,
  2412. fontsize = 8, fontsize_col = 8, cutree_cols = 6, angle_col = 90,
  2413. cutree_rows = 6, fontsize_row = 8, silent = FALSE)#, breaks = my.breaks)
  2414. save_pheatmap(cor, "5xT2_brain-v-liver.png", width=14, height=28)
  2415. write.csv(colnames(correlation_df), "5xT2_brain.csv", row.names=FALSE)
  2416. write.csv(rownames(correlation_df), "5xT2_liver.csv", row.names=FALSE)
  2417. # #if rho<0.4, then make it grey (find clusters of lipids and proteins)
  2418. # bk1 <- c(seq(-0.78, -0.39, by=0.02)) #spearman rho ranges from -0.39 to 0.49
  2419. # bk2 <- c(seq(0.39, 0.76, by=0.02))
  2420. # bk <- c(bk1,bk2) #combine the break limits for purpose of graphing
  2421. #
  2422. # my_palette <- c(colorRampPalette(colors = c("#440154", "#2E6DA4"))(n = length(bk1)-1),
  2423. # "gray60",
  2424. # c(colorRampPalette(colors = c("#9DDE4B", "#FDE725"))(n = length(bk2)-1)))
  2425. #
  2426. # cor <- pheatmap(correlation, cluster_cols = TRUE, clustering_method = 'average', cluster_rows = TRUE,
  2427. # gaps_col = FALSE, color = my_palette, show_colnames = TRUE, show_rownames = TRUE,
  2428. # fontsize = 8, fontsize_col = 6, cutree_cols = 2, angle_col = 90,
  2429. # cutree_rows = 2, fontsize_row = 6, silent = FALSE, breaks = bk)
  2430. #
  2431. # save_pheatmap(cor, "WT_brain-v-liver_grey.png", width=10, height=5)
  2432. #Mantel significance test (analytes in heatmap only)
  2433. set.seed <- 0123456789
  2434. brain_subset <- brain_df_cor[,colnames(correlation_df)]
  2435. liver_subset <- liver_df_cor[,rownames(correlation_df)]
  2436. brain.dist <- vegdist(brain_subset, method="bray")
  2437. liver.dist <- vegdist(liver_subset, method="bray")
  2438. mantel(brain.dist, liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2439. # Call:
  2440. # mantel(xdis = brain.dist, ydis = liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2441. #
  2442. # Mantel statistic r: -0.2175
  2443. # Significance: 0.8302
  2444. #
  2445. # Upper quantiles of permutations (null model):
  2446. # 90% 95% 97.5% 99%
  2447. # 0.353 0.448 0.505 0.566
  2448. # Permutation: free
  2449. # Number of permutations: 9999
  2450. ############## . . Comparing brain-liver metabolites##############
  2451. WT_brain <- read.csv("WT_brain.csv")
  2452. WT_liver <- read.csv("WT_liver.csv")
  2453. Fad_brain <- read.csv("5x_brain.csv")
  2454. Fad_liver <- read.csv("5x_liver.csv")
  2455. T2_brain <- read.csv("T2_brain.csv")
  2456. T2_liver <- read.csv("T2_liver.csv")
  2457. FadT2_brain <- read.csv("5xT2_brain.csv")
  2458. FadT2_liver <- read.csv("5xT2_liver.csv")
  2459. #venn diagrams
  2460. library(ggVennDiagram)
  2461. genes <- paste("gene",1:1000,sep="")
  2462. set.seed(20231214)
  2463. # b <- list(WT=WT_brain$x,
  2464. # `5xFAD`=Fad_brain$x,
  2465. # Trem2=T2_brain$x,
  2466. # `5xFAD, Trem2`=FadT2_brain$x)
  2467. # ggVennDiagram(b) +#, set_size = 4) +
  2468. # scale_fill_gradient(low="grey90",high ="red")
  2469. # ggsave("venn_diagram_brain.png", width = 6, height = 5)
  2470. #
  2471. # l <- list(WT=WT_liver$x,
  2472. # `5xFAD`=Fad_liver$x,
  2473. # Trem2=T2_liver$x,
  2474. # `5xFAD, Trem2`=FadT2_liver$x)
  2475. # ggVennDiagram(l) +#, set_size = 4) +
  2476. # scale_fill_gradient(low="grey90",high ="red")
  2477. # ggsave("venn_diagram_liver.png", width = 6, height = 5)
  2478. #Combine brain-liver lists to show in one venn diagram
  2479. WT <- unique(c(WT_brain$x, WT_liver$x)) #20
  2480. Fad <- unique(c(Fad_brain$x, Fad_liver$x)) #74
  2481. T2 <- unique(c(T2_brain$x, T2_liver$x)) #267
  2482. FadT2 <- unique(c(FadT2_brain$x, FadT2_liver$x)) #268
  2483. bl <- list(WT=WT,
  2484. `5xFAD`=Fad,
  2485. Trem2=T2,
  2486. `5xFAD, Trem2`=FadT2)
  2487. ggVennDiagram(bl) +#, set_size = 4) +
  2488. scale_fill_gradient(low="grey90",high ="red")
  2489. ggsave("venn_diagram_brain-liver.png", width = 6, height = 5)
  2490. ############## . WT brain-plasma metabolites##############
  2491. #WT 4 months targ.met
  2492. TREM2_tar_df = tar_df_combined %>%
  2493. filter(Group2 %in% c("WT 5xFAD"), Age == 4) %>%
  2494. column_to_rownames(var = "sample_id")
  2495. brain_df = TREM2_tar_df %>%
  2496. filter(Mode == "brain")
  2497. plasma_df = TREM2_tar_df %>%
  2498. filter(Mode == "plasma")
  2499. #Only keep brain data from Mouse IDs that we have plasma data for
  2500. brain_df_cor <- brain_df[brain_df$Name %in% plasma_df$Name, ]
  2501. #Only keep plasma data from Mouse IDs that we have brain data for
  2502. plasma_df_cor <- plasma_df[plasma_df$Name %in% brain_df$Name, ]
  2503. #Reassign rownames
  2504. rownames(brain_df_cor) <- NULL
  2505. rownames(brain_df_cor) <- brain_df_cor$Name
  2506. rownames(plasma_df_cor) <- NULL
  2507. rownames(plasma_df_cor) <- plasma_df_cor$Name
  2508. #Arrange metadata
  2509. brain_df_cor <- brain_df_cor %>%
  2510. arrange(Name)
  2511. plasma_df_cor <- plasma_df_cor %>%
  2512. arrange(Name)
  2513. #Mantel significance test
  2514. set.seed <- 0123456789
  2515. brain.dist <- vegdist(brain_df_cor[,-(1:11)], method="euclidean")
  2516. plasma.dist <- vegdist(plasma_df_cor[,-(1:11)], method="euclidean")
  2517. mantel(brain.dist, plasma.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2518. # Call:
  2519. # mantel(xdis = brain.dist, ydis = plasma.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2520. #
  2521. # Mantel statistic r: 0.01563
  2522. # Significance: 0.44
  2523. #
  2524. # Upper quantiles of permutations (null model):
  2525. # 90% 95% 97.5% 99%
  2526. # 0.284 0.368 0.451 0.537
  2527. # Permutation: free
  2528. # Number of permutations: 9999
  2529. #correlation analysis
  2530. correlation <- t(cor(brain_df_cor[,-(1:11)], plasma_df_cor[,-(1:11)], method = c('spearman')))
  2531. correlation[is.na(correlation)] <- 0
  2532. #only keep brain analytes (columns) with at least one rho value > threshold
  2533. #79 @ rho>0.7
  2534. correlation_df <- as.data.frame(correlation)
  2535. columns_to_keep <- sapply(correlation_df, function(x) {
  2536. max_val <- max(x, na.rm = TRUE)
  2537. min_val <- min(x, na.rm = TRUE)
  2538. return(max_val > 0.7 | min_val < -0.7)
  2539. })
  2540. correlation_df <- correlation_df[, columns_to_keep]
  2541. #only keep plasma analytes (rows) with at least one rho value > threshold
  2542. #64 @ rho>0.7
  2543. correlation_df <- correlation_df[apply(correlation_df, 1, max) > 0.7 |
  2544. apply(correlation_df, 1, min) < -0.7, ]
  2545. #heatmap w/ thresholds
  2546. correlation <- as.matrix(correlation_df)
  2547. cor <- pheatmap(correlation, cluster_cols = TRUE, clustering_method = 'average', cluster_rows = TRUE,
  2548. gaps_col = FALSE, color = viridis(10), show_colnames = TRUE, show_rownames = TRUE,
  2549. fontsize = 8, fontsize_col = 6, cutree_cols = 2, angle_col = 90,
  2550. cutree_rows = 2, fontsize_row = 6, silent = FALSE)#, breaks = my.breaks)
  2551. save_pheatmap(cor, "WT_brain-v-plasma.png", width=10, height=5)
  2552. write.csv(colnames(correlation_df), "WT_brain-v-plasma.csv", row.names=FALSE)
  2553. write.csv(rownames(correlation_df), "WT_plasma-v-brain.csv", row.names=FALSE)
  2554. #Mantel significance test (analytes in heatmap only)
  2555. set.seed <- 0123456789
  2556. brain_subset <- brain_df_cor[,colnames(correlation_df)]
  2557. plasma_subset <- plasma_df_cor[,rownames(correlation_df)]
  2558. brain.dist <- vegdist(brain_subset, method="euclidean")
  2559. plasma.dist <- vegdist(plasma_subset, method="euclidean")
  2560. mantel(brain.dist, plasma.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2561. # Call:
  2562. # mantel(xdis = brain.dist, ydis = plasma.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2563. #
  2564. # Mantel statistic r: 0.04355
  2565. # Significance: 0.3567
  2566. #
  2567. # Upper quantiles of permutations (null model):
  2568. # 90% 95% 97.5% 99%
  2569. # 0.255 0.341 0.403 0.458
  2570. # Permutation: free
  2571. # Number of permutations: 9999
  2572. ############## . 5xFAD brain-plasma metabolites##############
  2573. #WT 4 months targ.met
  2574. TREM2_tar_df = tar_df_combined %>%
  2575. filter(Group2 %in% c("HEMI 5xFAD"), Age == 4) %>%
  2576. column_to_rownames(var = "sample_id")
  2577. brain_df = TREM2_tar_df %>%
  2578. filter(Mode == "brain")
  2579. plasma_df = TREM2_tar_df %>%
  2580. filter(Mode == "plasma")
  2581. #Only keep brain data from Mouse IDs that we have plasma data for
  2582. brain_df_cor <- brain_df[brain_df$Name %in% plasma_df$Name, ]
  2583. #Only keep plasma data from Mouse IDs that we have brain data for
  2584. plasma_df_cor <- plasma_df[plasma_df$Name %in% brain_df$Name, ]
  2585. #Reassign rownames
  2586. rownames(brain_df_cor) <- NULL
  2587. rownames(brain_df_cor) <- brain_df_cor$Name
  2588. rownames(plasma_df_cor) <- NULL
  2589. rownames(plasma_df_cor) <- plasma_df_cor$Name
  2590. #Arrange metadata
  2591. brain_df_cor <- brain_df_cor %>%
  2592. arrange(Name)
  2593. plasma_df_cor <- plasma_df_cor %>%
  2594. arrange(Name)
  2595. #Mantel significance test
  2596. set.seed <- 0123456789
  2597. brain.dist <- vegdist(brain_df_cor[,-(1:11)], method="euclidean")
  2598. plasma.dist <- vegdist(plasma_df_cor[,-(1:11)], method="euclidean")
  2599. mantel(brain.dist, plasma.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2600. # Call:
  2601. # mantel(xdis = brain.dist, ydis = plasma.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2602. #
  2603. # Mantel statistic r: 0.04648
  2604. # Significance: 0.396
  2605. #
  2606. # Upper quantiles of permutations (null model):
  2607. # 90% 95% 97.5% 99%
  2608. # 0.304 0.393 0.467 0.548
  2609. # Permutation: free
  2610. # Number of permutations: 9999
  2611. #correlation analysis
  2612. correlation <- t(cor(brain_df_cor[,-(1:11)], plasma_df_cor[,-(1:11)], method = c('spearman')))
  2613. correlation[is.na(correlation)] <- 0
  2614. #only keep brain analytes (columns) with at least one rho value > threshold
  2615. #71 @ rho>0.7
  2616. correlation_df <- as.data.frame(correlation)
  2617. columns_to_keep <- sapply(correlation_df, function(x) {
  2618. max_val <- max(x, na.rm = TRUE)
  2619. min_val <- min(x, na.rm = TRUE)
  2620. return(max_val > 0.7 | min_val < -0.7)
  2621. })
  2622. correlation_df <- correlation_df[, columns_to_keep]
  2623. #only keep plasma analytes (rows) with at least one rho value > threshold
  2624. #69 @ rho>0.7
  2625. correlation_df <- correlation_df[apply(correlation_df, 1, max) > 0.7 |
  2626. apply(correlation_df, 1, min) < -0.7, ]
  2627. #heatmap w/ thresholds
  2628. correlation <- as.matrix(correlation_df)
  2629. cor <- pheatmap(correlation, cluster_cols = TRUE, clustering_method = 'average', cluster_rows = TRUE,
  2630. gaps_col = FALSE, color = viridis(10), show_colnames = TRUE, show_rownames = TRUE,
  2631. fontsize = 8, fontsize_col = 6, cutree_cols = 2, angle_col = 90,
  2632. cutree_rows = 2, fontsize_row = 6, silent = FALSE)#, breaks = my.breaks)
  2633. save_pheatmap(cor, "5x_brain-v-plasma.png", width=10, height=5)
  2634. write.csv(colnames(correlation_df), "5x_brain-v-plasma.csv", row.names=FALSE)
  2635. write.csv(rownames(correlation_df), "5x_plasma-v-brain.csv", row.names=FALSE)
  2636. #Mantel significance test (analytes in heatmap only)
  2637. set.seed <- 0123456789
  2638. brain_subset <- brain_df_cor[,colnames(correlation_df)]
  2639. plasma_subset <- plasma_df_cor[,rownames(correlation_df)]
  2640. brain.dist <- vegdist(brain_subset, method="euclidean")
  2641. plasma.dist <- vegdist(plasma_subset, method="euclidean")
  2642. mantel(brain.dist, plasma.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2643. # Call:
  2644. # mantel(xdis = brain.dist, ydis = plasma.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2645. #
  2646. # Mantel statistic r: 0.04355
  2647. # Significance: 0.3567
  2648. #
  2649. # Upper quantiles of permutations (null model):
  2650. # 90% 95% 97.5% 99%
  2651. # 0.255 0.341 0.403 0.458
  2652. # Permutation: free
  2653. # Number of permutations: 9999
  2654. ############## . TREM2 brain-plasma metabolites##############
  2655. #WT 4 months targ.met
  2656. TREM2_tar_df = tar_df_combined %>%
  2657. filter(Group2 %in% c("WT 5xFAD_TREM2"), Age == 4) %>%
  2658. column_to_rownames(var = "sample_id")
  2659. brain_df = TREM2_tar_df %>%
  2660. filter(Mode == "brain")
  2661. plasma_df = TREM2_tar_df %>%
  2662. filter(Mode == "plasma")
  2663. #Only keep brain data from Mouse IDs that we have plasma data for
  2664. brain_df_cor <- brain_df[brain_df$Name %in% plasma_df$Name, ]
  2665. #Only keep plasma data from Mouse IDs that we have brain data for
  2666. plasma_df_cor <- plasma_df[plasma_df$Name %in% brain_df$Name, ]
  2667. #Reassign rownames
  2668. rownames(brain_df_cor) <- NULL
  2669. rownames(brain_df_cor) <- brain_df_cor$Name
  2670. rownames(plasma_df_cor) <- NULL
  2671. rownames(plasma_df_cor) <- plasma_df_cor$Name
  2672. #Arrange metadata
  2673. brain_df_cor <- brain_df_cor %>%
  2674. arrange(Name)
  2675. plasma_df_cor <- plasma_df_cor %>%
  2676. arrange(Name)
  2677. #Mantel significance test
  2678. set.seed <- 0123456789
  2679. brain.dist <- vegdist(brain_df_cor[,-(1:11)], method="euclidean")
  2680. plasma.dist <- vegdist(plasma_df_cor[,-(1:11)], method="euclidean")
  2681. mantel(brain.dist, plasma.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2682. # Call:
  2683. # mantel(xdis = brain.dist, ydis = plasma.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2684. #
  2685. # Mantel statistic r: -0.0722
  2686. # Significance: 0.651
  2687. #
  2688. # Upper quantiles of permutations (null model):
  2689. # 90% 95% 97.5% 99%
  2690. # 0.218 0.287 0.340 0.461
  2691. # Permutation: free
  2692. # Number of permutations: 9999
  2693. #correlation analysis
  2694. correlation <- t(cor(brain_df_cor[,-(1:11)], plasma_df_cor[,-(1:11)], method = c('spearman')))
  2695. correlation[is.na(correlation)] <- 0
  2696. #only keep brain analytes (columns) with at least one rho value > threshold
  2697. #131 @ rho>0.7
  2698. correlation_df <- as.data.frame(correlation)
  2699. columns_to_keep <- sapply(correlation_df, function(x) {
  2700. max_val <- max(x, na.rm = TRUE)
  2701. min_val <- min(x, na.rm = TRUE)
  2702. return(max_val > 0.7 | min_val < -0.7)
  2703. })
  2704. correlation_df <- correlation_df[, columns_to_keep]
  2705. #only keep plasma analytes (rows) with at least one rho value > threshold
  2706. #258 @ rho>0.7
  2707. correlation_df <- correlation_df[apply(correlation_df, 1, max) > 0.7 |
  2708. apply(correlation_df, 1, min) < -0.7, ]
  2709. #heatmap w/ thresholds
  2710. correlation <- as.matrix(correlation_df)
  2711. cor <- pheatmap(correlation, cluster_cols = TRUE, clustering_method = 'average', cluster_rows = TRUE,
  2712. gaps_col = FALSE, color = viridis(10), show_colnames = TRUE, show_rownames = TRUE,
  2713. fontsize = 8, fontsize_col = 6, cutree_cols = 2, angle_col = 90,
  2714. cutree_rows = 2, fontsize_row = 6, silent = FALSE)#, breaks = my.breaks)
  2715. save_pheatmap(cor, "T2_brain-v-plasma.png", width=10, height=5)
  2716. write.csv(colnames(correlation_df), "T2_brain-v-plasma.csv", row.names=FALSE)
  2717. write.csv(rownames(correlation_df), "T2_plasma-v-brain.csv", row.names=FALSE)
  2718. #Mantel significance test (analytes in heatmap only)
  2719. set.seed <- 0123456789
  2720. brain_subset <- brain_df_cor[,colnames(correlation_df)]
  2721. plasma_subset <- plasma_df_cor[,rownames(correlation_df)]
  2722. brain.dist <- vegdist(brain_subset, method="euclidean")
  2723. plasma.dist <- vegdist(plasma_subset, method="euclidean")
  2724. mantel(brain.dist, plasma.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2725. # Call:
  2726. # mantel(xdis = brain.dist, ydis = plasma.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2727. #
  2728. # Mantel statistic r: -0.04783
  2729. # Significance: 0.5925
  2730. #
  2731. # Upper quantiles of permutations (null model):
  2732. # 90% 95% 97.5% 99%
  2733. # 0.212 0.278 0.335 0.438
  2734. # Permutation: free
  2735. # Number of permutations: 9999
  2736. ############## . 5xFAD*TREM2 brain-plasma metabolites##############
  2737. #WT 4 months targ.met
  2738. TREM2_tar_df = tar_df_combined %>%
  2739. filter(Group2 %in% c("HEMI 5xFAD_TREM2"), Age == 4) %>%
  2740. column_to_rownames(var = "sample_id")
  2741. brain_df = TREM2_tar_df %>%
  2742. filter(Mode == "brain")
  2743. plasma_df = TREM2_tar_df %>%
  2744. filter(Mode == "plasma")
  2745. #Only keep brain data from Mouse IDs that we have plasma data for
  2746. brain_df_cor <- brain_df[brain_df$Name %in% plasma_df$Name, ]
  2747. #Only keep plasma data from Mouse IDs that we have brain data for
  2748. plasma_df_cor <- plasma_df[plasma_df$Name %in% brain_df$Name, ]
  2749. #Reassign rownames
  2750. rownames(brain_df_cor) <- NULL
  2751. rownames(brain_df_cor) <- brain_df_cor$Name
  2752. rownames(plasma_df_cor) <- NULL
  2753. rownames(plasma_df_cor) <- plasma_df_cor$Name
  2754. #Arrange metadata
  2755. brain_df_cor <- brain_df_cor %>%
  2756. arrange(Name)
  2757. plasma_df_cor <- plasma_df_cor %>%
  2758. arrange(Name)
  2759. #Mantel significance test
  2760. set.seed <- 0123456789
  2761. brain.dist <- vegdist(brain_df_cor[,-(1:11)], method="euclidean")
  2762. plasma.dist <- vegdist(plasma_df_cor[,-(1:11)], method="euclidean")
  2763. mantel(brain.dist, plasma.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2764. # mantel(xdis = brain.dist, ydis = plasma.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2765. #
  2766. # Mantel statistic r: 0.4512
  2767. # Significance: 0.0492
  2768. #
  2769. # Upper quantiles of permutations (null model):
  2770. # 90% 95% 97.5% 99%
  2771. # 0.358 0.448 0.526 0.591
  2772. # Permutation: free
  2773. # Number of permutations: 9999
  2774. #correlation analysis
  2775. correlation <- t(cor(brain_df_cor[,-(1:11)], plasma_df_cor[,-(1:11)], method = c('spearman')))
  2776. correlation[is.na(correlation)] <- 0
  2777. #only keep brain analytes (columns) with at least one rho value > threshold
  2778. #135 @ rho>0.7
  2779. correlation_df <- as.data.frame(correlation)
  2780. columns_to_keep <- sapply(correlation_df, function(x) {
  2781. max_val <- max(x, na.rm = TRUE)
  2782. min_val <- min(x, na.rm = TRUE)
  2783. return(max_val > 0.7 | min_val < -0.7)
  2784. })
  2785. correlation_df <- correlation_df[, columns_to_keep]
  2786. #only keep plasma analytes (rows) with at least one rho value > threshold
  2787. #263 @ rho>0.7
  2788. correlation_df <- correlation_df[apply(correlation_df, 1, max) > 0.7 |
  2789. apply(correlation_df, 1, min) < -0.7, ]
  2790. #heatmap w/ thresholds
  2791. correlation <- as.matrix(correlation_df)
  2792. cor <- pheatmap(correlation, cluster_cols = TRUE, clustering_method = 'average', cluster_rows = TRUE,
  2793. gaps_col = FALSE, color = viridis(10), show_colnames = TRUE, show_rownames = TRUE,
  2794. fontsize = 8, fontsize_col = 6, cutree_cols = 2, angle_col = 90,
  2795. cutree_rows = 2, fontsize_row = 6, silent = FALSE)#, breaks = my.breaks)
  2796. save_pheatmap(cor, "5xT2_brain-v-plasma.png", width=10, height=5)
  2797. write.csv(colnames(correlation_df), "5xT2_brain-v-plasma.csv", row.names=FALSE)
  2798. write.csv(rownames(correlation_df), "5xT2_plasma-v-brain.csv", row.names=FALSE)
  2799. #Mantel significance test (analytes in heatmap only)
  2800. set.seed <- 0123456789
  2801. brain_subset <- brain_df_cor[,colnames(correlation_df)]
  2802. plasma_subset <- plasma_df_cor[,rownames(correlation_df)]
  2803. brain.dist <- vegdist(brain_subset, method="euclidean")
  2804. plasma.dist <- vegdist(plasma_subset, method="euclidean")
  2805. mantel(brain.dist, plasma.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2806. # Call:
  2807. # mantel(xdis = brain.dist, ydis = plasma.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2808. #
  2809. # Mantel statistic r: 0.4399
  2810. # Significance: 0.0532
  2811. #
  2812. # Upper quantiles of permutations (null model):
  2813. # 90% 95% 97.5% 99%
  2814. # 0.349 0.449 0.524 0.590
  2815. # Permutation: free
  2816. # Number of permutations: 9999
  2817. ############## . . Comparing brain-plasma metabolites##############
  2818. WT_brain <- read.csv("WT_brain-v-plasma.csv")
  2819. WT_plasma <- read.csv("WT_plasma-v-brain.csv")
  2820. Fad_brain <- read.csv("5x_brain-v-plasma.csv")
  2821. Fad_plasma <- read.csv("5x_plasma-v-brain.csv")
  2822. T2_brain <- read.csv("T2_brain-v-plasma.csv")
  2823. T2_plasma <- read.csv("T2_plasma-v-brain.csv")
  2824. FadT2_brain <- read.csv("5xT2_brain-v-plasma.csv")
  2825. FadT2_plasma <- read.csv("5xT2_plasma-v-brain.csv")
  2826. #venn diagrams
  2827. library(ggVennDiagram)
  2828. genes <- paste("gene",1:1000,sep="")
  2829. set.seed(20231214)
  2830. #Combine brain-liver lists to show in one venn diagram
  2831. WT <- unique(c(WT_brain$x, WT_plasma$x)) #124
  2832. Fad <- unique(c(Fad_brain$x, Fad_plasma$x)) #121
  2833. T2 <- unique(c(T2_brain$x, T2_plasma$x)) #280
  2834. FadT2 <- unique(c(FadT2_brain$x, FadT2_plasma$x)) #293
  2835. bp <- list(WT=WT,
  2836. `5xFAD`=Fad,
  2837. Trem2=T2,
  2838. `5xFAD, Trem2`=FadT2)
  2839. ggVennDiagram(bp) +#, set_size = 4) +
  2840. scale_fill_gradient(low="grey90",high ="red")
  2841. ggsave("venn_diagram_brain-plasma.png", width = 6, height = 5)
  2842. ############## . . Extracting 5xFAD, TREM2 (only) brain-plasma metabolites##############
  2843. WT_brain <- read.csv("WT_brain-v-plasma.csv")
  2844. WT_plasma <- read.csv("WT_plasma-v-brain.csv")
  2845. Fad_brain <- read.csv("5x_brain-v-plasma.csv")
  2846. Fad_plasma <- read.csv("5x_plasma-v-brain.csv")
  2847. T2_brain <- read.csv("T2_brain-v-plasma.csv")
  2848. T2_plasma <- read.csv("T2_plasma-v-brain.csv")
  2849. FadT2_brain <- read.csv("5xT2_brain-v-plasma.csv")
  2850. FadT2_plasma <- read.csv("5xT2_plasma-v-brain.csv")
  2851. WT <- unique(c(WT_brain$x, WT_plasma$x)) #124
  2852. Fad <- unique(c(Fad_brain$x, Fad_plasma$x)) #121
  2853. T2 <- unique(c(T2_brain$x, T2_plasma$x)) #280
  2854. FadT2 <- unique(c(FadT2_brain$x, FadT2_plasma$x)) #293
  2855. all_exclusions <- c(WT, Fad, T2)
  2856. FadT2_only <- FadT2[!FadT2 %in% all_exclusions]
  2857. write.csv(FadT2_only, "5xT2_only_brain-v-plasma.csv", row.names=FALSE)
  2858. ############## . WT plasma-liver metabolites##############
  2859. #WT 4 months targ.met
  2860. TREM2_tar_df = tar_df_combined %>%
  2861. filter(Group2 %in% c("WT 5xFAD"), Age == 4) %>%
  2862. column_to_rownames(var = "sample_id")
  2863. plasma_df = TREM2_tar_df %>%
  2864. filter(Mode == "plasma")
  2865. liver_df = TREM2_tar_df %>%
  2866. filter(Mode == "liver")
  2867. #Only keep plasma data from Mouse IDs that we have liver data for
  2868. plasma_df_cor <- plasma_df[plasma_df$Name %in% liver_df$Name, ]
  2869. #Only keep liver data from Mouse IDs that we have plasma data for
  2870. liver_df_cor <- liver_df[liver_df$Name %in% plasma_df$Name, ]
  2871. #Reassign rownames
  2872. rownames(plasma_df_cor) <- NULL
  2873. rownames(plasma_df_cor) <- plasma_df_cor$Name
  2874. rownames(liver_df_cor) <- NULL
  2875. rownames(liver_df_cor) <- liver_df_cor$Name
  2876. #Arrange metadata
  2877. plasma_df_cor <- plasma_df_cor %>%
  2878. arrange(Name)
  2879. liver_df_cor <- liver_df_cor %>%
  2880. arrange(Name)
  2881. #Mantel significance test
  2882. set.seed <- 0123456789
  2883. plasma.dist <- vegdist(plasma_df_cor[,-(1:11)], method="euclidean")
  2884. liver.dist <- vegdist(liver_df_cor[,-(1:11)], method="euclidean")
  2885. mantel(plasma.dist, liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2886. # Call:
  2887. # mantel(xdis = plasma.dist, ydis = liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2888. #
  2889. # Mantel statistic r: 0.106
  2890. # Significance: 0.293
  2891. #
  2892. # Upper quantiles of permutations (null model):
  2893. # 90% 95% 97.5% 99%
  2894. # 0.297 0.390 0.471 0.548
  2895. # Permutation: free
  2896. # Number of permutations: 9999
  2897. #correlation analysis
  2898. correlation <- t(cor(plasma_df_cor[,-(1:11)], liver_df_cor[,-(1:11)], method = c('spearman')))
  2899. correlation[is.na(correlation)] <- 0
  2900. #only keep plasma analytes (columns) with at least one rho value > threshold
  2901. #109 @ rho>0.7
  2902. correlation_df <- as.data.frame(correlation)
  2903. columns_to_keep <- sapply(correlation_df, function(x) {
  2904. max_val <- max(x, na.rm = TRUE)
  2905. min_val <- min(x, na.rm = TRUE)
  2906. return(max_val > 0.7 | min_val < -0.7)
  2907. })
  2908. correlation_df <- correlation_df[, columns_to_keep]
  2909. #only keep liver analytes (rows) with at least one rho value > threshold
  2910. #176 @ rho>0.7
  2911. correlation_df <- correlation_df[apply(correlation_df, 1, max) > 0.7 |
  2912. apply(correlation_df, 1, min) < -0.7, ]
  2913. #heatmap w/ thresholds
  2914. correlation <- as.matrix(correlation_df)
  2915. cor <- pheatmap(correlation, cluster_cols = TRUE, clustering_method = 'average', cluster_rows = TRUE,
  2916. gaps_col = FALSE, color = viridis(10), show_colnames = TRUE, show_rownames = TRUE,
  2917. fontsize = 8, fontsize_col = 6, cutree_cols = 2, angle_col = 90,
  2918. cutree_rows = 2, fontsize_row = 6, silent = FALSE)#, breaks = my.breaks)
  2919. save_pheatmap(cor, "WT_plasma-v-liver.png", width=10, height=5)
  2920. write.csv(colnames(correlation_df), "WT_plasma-v-liver.csv", row.names=FALSE)
  2921. write.csv(rownames(correlation_df), "WT_liver-v-plasma.csv", row.names=FALSE)
  2922. #Mantel significance test (analytes in heatmap only)
  2923. set.seed <- 0123456789
  2924. plasma_subset <- plasma_df_cor[,colnames(correlation_df)]
  2925. liver_subset <- liver_df_cor[,rownames(correlation_df)]
  2926. plasma.dist <- vegdist(plasma_subset, method="euclidean")
  2927. liver.dist <- vegdist(liver_subset, method="euclidean")
  2928. mantel(plasma.dist, liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2929. # Call:
  2930. # mantel(xdis = plasma.dist, ydis = liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2931. #
  2932. # Mantel statistic r: -0.1723
  2933. # Significance: 0.7679
  2934. #
  2935. # Upper quantiles of permutations (null model):
  2936. # 90% 95% 97.5% 99%
  2937. # 0.292 0.382 0.463 0.550
  2938. # Permutation: free
  2939. # Number of permutations: 9999
  2940. ############## . 5xFAD plasma-liver metabolites##############
  2941. #WT 4 months targ.met
  2942. TREM2_tar_df = tar_df_combined %>%
  2943. filter(Group2 %in% c("HEMI 5xFAD"), Age == 4) %>%
  2944. column_to_rownames(var = "sample_id")
  2945. plasma_df = TREM2_tar_df %>%
  2946. filter(Mode == "plasma")
  2947. liver_df = TREM2_tar_df %>%
  2948. filter(Mode == "liver")
  2949. #Only keep plasma data from Mouse IDs that we have liver data for
  2950. plasma_df_cor <- plasma_df[plasma_df$Name %in% liver_df$Name, ]
  2951. #Only keep liver data from Mouse IDs that we have plasma data for
  2952. liver_df_cor <- liver_df[liver_df$Name %in% plasma_df$Name, ]
  2953. #Reassign rownames
  2954. rownames(plasma_df_cor) <- NULL
  2955. rownames(plasma_df_cor) <- plasma_df_cor$Name
  2956. rownames(liver_df_cor) <- NULL
  2957. rownames(liver_df_cor) <- liver_df_cor$Name
  2958. #Arrange metadata
  2959. plasma_df_cor <- plasma_df_cor %>%
  2960. arrange(Name)
  2961. liver_df_cor <- liver_df_cor %>%
  2962. arrange(Name)
  2963. #Mantel significance test
  2964. set.seed <- 0123456789
  2965. plasma.dist <- vegdist(plasma_df_cor[,-(1:11)], method="euclidean")
  2966. liver.dist <- vegdist(liver_df_cor[,-(1:11)], method="euclidean")
  2967. mantel(plasma.dist, liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2968. # Call:
  2969. # mantel(xdis = plasma.dist, ydis = liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  2970. #
  2971. # Mantel statistic r: -0.2044
  2972. # Significance: 0.8402
  2973. #
  2974. # Upper quantiles of permutations (null model):
  2975. # 90% 95% 97.5% 99%
  2976. # 0.276 0.363 0.434 0.533
  2977. # Permutation: free
  2978. # Number of permutations: 9999
  2979. #correlation analysis
  2980. correlation <- t(cor(plasma_df_cor[,-(1:11)], liver_df_cor[,-(1:11)], method = c('spearman')))
  2981. correlation[is.na(correlation)] <- 0
  2982. #only keep plasma analytes (columns) with at least one rho value > threshold
  2983. #126 @ rho>0.7
  2984. correlation_df <- as.data.frame(correlation)
  2985. columns_to_keep <- sapply(correlation_df, function(x) {
  2986. max_val <- max(x, na.rm = TRUE)
  2987. min_val <- min(x, na.rm = TRUE)
  2988. return(max_val > 0.7 | min_val < -0.7)
  2989. })
  2990. correlation_df <- correlation_df[, columns_to_keep]
  2991. #only keep liver analytes (rows) with at least one rho value > threshold
  2992. #219 @ rho>0.7
  2993. correlation_df <- correlation_df[apply(correlation_df, 1, max) > 0.7 |
  2994. apply(correlation_df, 1, min) < -0.7, ]
  2995. #heatmap w/ thresholds
  2996. correlation <- as.matrix(correlation_df)
  2997. cor <- pheatmap(correlation, cluster_cols = TRUE, clustering_method = 'average', cluster_rows = TRUE,
  2998. gaps_col = FALSE, color = viridis(10), show_colnames = TRUE, show_rownames = TRUE,
  2999. fontsize = 8, fontsize_col = 6, cutree_cols = 2, angle_col = 90,
  3000. cutree_rows = 2, fontsize_row = 6, silent = FALSE)#, breaks = my.breaks)
  3001. save_pheatmap(cor, "5x_plasma-v-liver.png", width=10, height=5)
  3002. write.csv(colnames(correlation_df), "5x_plasma-v-liver.csv", row.names=FALSE)
  3003. write.csv(rownames(correlation_df), "5x_liver-v-plasma.csv", row.names=FALSE)
  3004. #Mantel significance test (analytes in heatmap only)
  3005. set.seed <- 0123456789
  3006. plasma_subset <- plasma_df_cor[,colnames(correlation_df)]
  3007. liver_subset <- liver_df_cor[,rownames(correlation_df)]
  3008. plasma.dist <- vegdist(plasma_subset, method="euclidean")
  3009. liver.dist <- vegdist(liver_subset, method="euclidean")
  3010. mantel(plasma.dist, liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3011. # Call:
  3012. # mantel(xdis = plasma.dist, ydis = liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3013. #
  3014. # Mantel statistic r: 0.1992
  3015. # Significance: 0.1571
  3016. #
  3017. # Upper quantiles of permutations (null model):
  3018. # 90% 95% 97.5% 99%
  3019. # 0.259 0.354 0.436 0.524
  3020. # Permutation: free
  3021. # Number of permutations: 9999
  3022. ############## . TREM2 plasma-liver metabolites##############
  3023. #WT 4 months targ.met
  3024. TREM2_tar_df = tar_df_combined %>%
  3025. filter(Group2 %in% c("WT 5xFAD_TREM2"), Age == 4) %>%
  3026. column_to_rownames(var = "sample_id")
  3027. plasma_df = TREM2_tar_df %>%
  3028. filter(Mode == "plasma")
  3029. liver_df = TREM2_tar_df %>%
  3030. filter(Mode == "liver")
  3031. #Only keep plasma data from Mouse IDs that we have liver data for
  3032. plasma_df_cor <- plasma_df[plasma_df$Name %in% liver_df$Name, ]
  3033. #Only keep liver data from Mouse IDs that we have plasma data for
  3034. liver_df_cor <- liver_df[liver_df$Name %in% plasma_df$Name, ]
  3035. #Reassign rownames
  3036. rownames(plasma_df_cor) <- NULL
  3037. rownames(plasma_df_cor) <- plasma_df_cor$Name
  3038. rownames(liver_df_cor) <- NULL
  3039. rownames(liver_df_cor) <- liver_df_cor$Name
  3040. #Arrange metadata
  3041. plasma_df_cor <- plasma_df_cor %>%
  3042. arrange(Name)
  3043. liver_df_cor <- liver_df_cor %>%
  3044. arrange(Name)
  3045. #Mantel significance test
  3046. set.seed <- 0123456789
  3047. plasma.dist <- vegdist(plasma_df_cor[,-(1:11)], method="euclidean")
  3048. liver.dist <- vegdist(liver_df_cor[,-(1:11)], method="euclidean")
  3049. mantel(plasma.dist, liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3050. # Call:
  3051. # mantel(xdis = plasma.dist, ydis = liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3052. #
  3053. # Mantel statistic r: -0.1271
  3054. # Significance: 0.7674
  3055. #
  3056. # Upper quantiles of permutations (null model):
  3057. # 90% 95% 97.5% 99%
  3058. # 0.200 0.259 0.352 0.503
  3059. # Permutation: free
  3060. # Number of permutations: 9999
  3061. #correlation analysis
  3062. correlation <- t(cor(plasma_df_cor[,-(1:11)], liver_df_cor[,-(1:11)], method = c('spearman')))
  3063. correlation[is.na(correlation)] <- 0
  3064. #only keep plasma analytes (columns) with at least one rho value > threshold
  3065. #254 @ rho>0.7
  3066. correlation_df <- as.data.frame(correlation)
  3067. columns_to_keep <- sapply(correlation_df, function(x) {
  3068. max_val <- max(x, na.rm = TRUE)
  3069. min_val <- min(x, na.rm = TRUE)
  3070. return(max_val > 0.7 | min_val < -0.7)
  3071. })
  3072. correlation_df <- correlation_df[, columns_to_keep]
  3073. #only keep liver analytes (rows) with at least one rho value > threshold
  3074. #269 @ rho>0.7
  3075. correlation_df <- correlation_df[apply(correlation_df, 1, max) > 0.7 |
  3076. apply(correlation_df, 1, min) < -0.7, ]
  3077. #heatmap w/ thresholds
  3078. correlation <- as.matrix(correlation_df)
  3079. cor <- pheatmap(correlation, cluster_cols = TRUE, clustering_method = 'average', cluster_rows = TRUE,
  3080. gaps_col = FALSE, color = viridis(10), show_colnames = TRUE, show_rownames = TRUE,
  3081. fontsize = 8, fontsize_col = 6, cutree_cols = 2, angle_col = 90,
  3082. cutree_rows = 2, fontsize_row = 6, silent = FALSE)#, breaks = my.breaks)
  3083. save_pheatmap(cor, "T2_plasma-v-liver.png", width=10, height=5)
  3084. write.csv(colnames(correlation_df), "T2_plasma-v-liver.csv", row.names=FALSE)
  3085. write.csv(rownames(correlation_df), "T2_liver-v-plasma.csv", row.names=FALSE)
  3086. #Mantel significance test (analytes in heatmap only)
  3087. set.seed <- 0123456789
  3088. plasma_subset <- plasma_df_cor[,colnames(correlation_df)]
  3089. liver_subset <- liver_df_cor[,rownames(correlation_df)]
  3090. plasma.dist <- vegdist(plasma_subset, method="euclidean")
  3091. liver.dist <- vegdist(liver_subset, method="euclidean")
  3092. mantel(plasma.dist, liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3093. # Call:
  3094. # mantel(xdis = plasma.dist, ydis = liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3095. #
  3096. # Mantel statistic r: -0.1227
  3097. # Significance: 0.767
  3098. #
  3099. # Upper quantiles of permutations (null model):
  3100. # 90% 95% 97.5% 99%
  3101. # 0.205 0.269 0.353 0.508
  3102. # Permutation: free
  3103. # Number of permutations: 9999
  3104. ############## . 5xFAD*TREM2 plasma-liver metabolites##############
  3105. #WT 4 months targ.met
  3106. TREM2_tar_df = tar_df_combined %>%
  3107. filter(Group2 %in% c("HEMI 5xFAD_TREM2"), Age == 4) %>%
  3108. column_to_rownames(var = "sample_id")
  3109. plasma_df = TREM2_tar_df %>%
  3110. filter(Mode == "plasma")
  3111. liver_df = TREM2_tar_df %>%
  3112. filter(Mode == "liver")
  3113. #Only keep plasma data from Mouse IDs that we have liver data for
  3114. plasma_df_cor <- plasma_df[plasma_df$Name %in% liver_df$Name, ]
  3115. #Only keep liver data from Mouse IDs that we have plasma data for
  3116. liver_df_cor <- liver_df[liver_df$Name %in% plasma_df$Name, ]
  3117. #Reassign rownames
  3118. rownames(plasma_df_cor) <- NULL
  3119. rownames(plasma_df_cor) <- plasma_df_cor$Name
  3120. rownames(liver_df_cor) <- NULL
  3121. rownames(liver_df_cor) <- liver_df_cor$Name
  3122. #Arrange metadata
  3123. plasma_df_cor <- plasma_df_cor %>%
  3124. arrange(Name)
  3125. liver_df_cor <- liver_df_cor %>%
  3126. arrange(Name)
  3127. #Mantel significance test
  3128. set.seed <- 0123456789
  3129. plasma.dist <- vegdist(plasma_df_cor[,-(1:11)], method="euclidean")
  3130. liver.dist <- vegdist(liver_df_cor[,-(1:11)], method="euclidean")
  3131. mantel(plasma.dist, liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3132. # Call:
  3133. # mantel(xdis = plasma.dist, ydis = liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3134. #
  3135. # Mantel statistic r: 0.09592
  3136. # Significance: 0.3275
  3137. #
  3138. # Upper quantiles of permutations (null model):
  3139. # 90% 95% 97.5% 99%
  3140. # 0.305 0.383 0.488 0.589
  3141. # Permutation: free
  3142. # Number of permutations: 9999
  3143. #correlation analysis
  3144. correlation <- t(cor(plasma_df_cor[,-(1:11)], liver_df_cor[,-(1:11)], method = c('spearman')))
  3145. correlation[is.na(correlation)] <- 0
  3146. #only keep plasma analytes (columns) with at least one rho value > threshold
  3147. #250 @ rho>0.7
  3148. correlation_df <- as.data.frame(correlation)
  3149. columns_to_keep <- sapply(correlation_df, function(x) {
  3150. max_val <- max(x, na.rm = TRUE)
  3151. min_val <- min(x, na.rm = TRUE)
  3152. return(max_val > 0.7 | min_val < -0.7)
  3153. })
  3154. correlation_df <- correlation_df[, columns_to_keep]
  3155. #only keep liver analytes (rows) with at least one rho value > threshold
  3156. #266 @ rho>0.7
  3157. correlation_df <- correlation_df[apply(correlation_df, 1, max) > 0.7 |
  3158. apply(correlation_df, 1, min) < -0.7, ]
  3159. #heatmap w/ thresholds
  3160. correlation <- as.matrix(correlation_df)
  3161. cor <- pheatmap(correlation, cluster_cols = TRUE, clustering_method = 'average', cluster_rows = TRUE,
  3162. gaps_col = FALSE, color = viridis(10), show_colnames = TRUE, show_rownames = TRUE,
  3163. fontsize = 8, fontsize_col = 6, cutree_cols = 2, angle_col = 90,
  3164. cutree_rows = 2, fontsize_row = 6, silent = FALSE)#, breaks = my.breaks)
  3165. save_pheatmap(cor, "5xT2_plasma-v-liver.png", width=10, height=5)
  3166. write.csv(colnames(correlation_df), "5xT2_plasma-v-liver.csv", row.names=FALSE)
  3167. write.csv(rownames(correlation_df), "5xT2_liver-v-plasma.csv", row.names=FALSE)
  3168. #Mantel significance test (analytes in heatmap only)
  3169. set.seed <- 0123456789
  3170. plasma_subset <- plasma_df_cor[,colnames(correlation_df)]
  3171. liver_subset <- liver_df_cor[,rownames(correlation_df)]
  3172. plasma.dist <- vegdist(plasma_subset, method="euclidean")
  3173. liver.dist <- vegdist(liver_subset, method="euclidean")
  3174. mantel(plasma.dist, liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3175. # Call:
  3176. # mantel(xdis = plasma.dist, ydis = liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3177. #
  3178. # Mantel statistic r: 0.1884
  3179. # Significance: 0.1885
  3180. #
  3181. # Upper quantiles of permutations (null model):
  3182. # 90% 95% 97.5% 99%
  3183. # 0.275 0.346 0.400 0.455
  3184. # Permutation: free
  3185. # Number of permutations: 9999
  3186. ############## . . Comparing plasma-liver metabolites##############
  3187. WT_liver <- read.csv("WT_liver-v-plasma.csv")
  3188. WT_plasma <- read.csv("WT_plasma-v-liver.csv")
  3189. Fad_liver <- read.csv("5x_liver-v-plasma.csv")
  3190. Fad_plasma <- read.csv("5x_plasma-v-liver.csv")
  3191. T2_liver <- read.csv("T2_liver-v-plasma.csv")
  3192. T2_plasma <- read.csv("T2_plasma-v-liver.csv")
  3193. FadT2_liver <- read.csv("5xT2_liver-v-plasma.csv")
  3194. FadT2_plasma <- read.csv("5xT2_plasma-v-liver.csv")
  3195. #venn diagrams
  3196. library(ggVennDiagram)
  3197. genes <- paste("gene",1:1000,sep="")
  3198. set.seed(20231214)
  3199. #Combine brain-liver lists to show in one venn diagram
  3200. WT <- unique(c(WT_liver$x, WT_plasma$x)) #229
  3201. Fad <- unique(c(Fad_liver$x, Fad_plasma$x)) #255
  3202. T2 <- unique(c(T2_liver$x, T2_plasma$x)) #314
  3203. FadT2 <- unique(c(FadT2_liver$x, FadT2_plasma$x)) #308
  3204. pl <- list(WT=WT,
  3205. `5xFAD`=Fad,
  3206. Trem2=T2,
  3207. `5xFAD, Trem2`=FadT2)
  3208. ggVennDiagram(pl) +#, set_size = 4) +
  3209. scale_fill_gradient(low="grey90",high ="red")
  3210. ggsave("venn_diagram_plasma-liver.png", width = 6, height = 5)
  3211. ############## . WT brain-liver lipids##############
  3212. #WT 4 months targ.met
  3213. TREM2_tar_df = lip_df_combined %>%
  3214. filter(Group2 %in% c("WT 5xFAD"), Age == 4) %>%
  3215. column_to_rownames(var = "sample_id")
  3216. brain_df = TREM2_tar_df %>%
  3217. filter(Mode == "brain")
  3218. liver_df = TREM2_tar_df %>%
  3219. filter(Mode == "liver")
  3220. #Only keep brain data from Mouse IDs that we have liver data for
  3221. brain_df_cor <- brain_df[brain_df$Name %in% liver_df$Name, ]
  3222. #Only keep liver data from Mouse IDs that we have brain data for
  3223. liver_df_cor <- liver_df[liver_df$Name %in% brain_df$Name, ]
  3224. #Reassign rownames
  3225. rownames(brain_df_cor) <- NULL
  3226. rownames(brain_df_cor) <- brain_df_cor$Name
  3227. rownames(liver_df_cor) <- NULL
  3228. rownames(liver_df_cor) <- liver_df_cor$Name
  3229. #Arrange metadata
  3230. brain_df_cor <- brain_df_cor %>%
  3231. arrange(Name)
  3232. liver_df_cor <- liver_df_cor %>%
  3233. arrange(Name)
  3234. #Mantel significance test
  3235. set.seed <- 0123456789
  3236. brain.dist <- vegdist(brain_df_cor[,-(1:11)], method="bray")
  3237. liver.dist <- vegdist(liver_df_cor[,-(1:11)], method="bray")
  3238. mantel(brain.dist, liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3239. # Call:
  3240. # mantel(xdis = brain.dist, ydis = liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3241. #
  3242. # Mantel statistic r: -0.2867
  3243. # Significance: 0.9936
  3244. #
  3245. # Upper quantiles of permutations (null model):
  3246. # 90% 95% 97.5% 99%
  3247. # 0.188 0.247 0.307 0.375
  3248. # Permutation: free
  3249. # Number of permutations: 9999
  3250. #correlation analysis
  3251. correlation <- t(cor(brain_df_cor[,-(1:11)], liver_df_cor[,-(1:11)], method = c('spearman')))
  3252. correlation[is.na(correlation)] <- 0
  3253. #only keep brain analytes (columns) with at least one rho value > threshold
  3254. #81 @ rho>0.7
  3255. correlation_df <- as.data.frame(correlation)
  3256. columns_to_keep <- sapply(correlation_df, function(x) {
  3257. max_val <- max(x, na.rm = TRUE)
  3258. min_val <- min(x, na.rm = TRUE)
  3259. return(max_val > 0.7 | min_val < -0.7)
  3260. })
  3261. correlation_df <- correlation_df[, columns_to_keep]
  3262. #only keep liver analytes (rows) with at least one rho value > threshold
  3263. #135 @ rho>0.7
  3264. correlation_df <- correlation_df[apply(correlation_df, 1, max) > 0.7 |
  3265. apply(correlation_df, 1, min) < -0.7, ]
  3266. #heatmap w/ thresholds
  3267. correlation <- as.matrix(correlation_df)
  3268. cor <- pheatmap(correlation, cluster_cols = TRUE, clustering_method = 'average', cluster_rows = TRUE,
  3269. gaps_col = FALSE, color = viridis(10), show_colnames = TRUE, show_rownames = TRUE,
  3270. fontsize = 8, fontsize_col = 6, cutree_cols = 2, angle_col = 90,
  3271. cutree_rows = 2, fontsize_row = 6, silent = FALSE)#, breaks = my.breaks)
  3272. save_pheatmap(cor, "WT_brain-v-liver-lip.png", width=10, height=5)
  3273. write.csv(colnames(correlation_df), "WT_brain-lip.csv", row.names=FALSE)
  3274. write.csv(rownames(correlation_df), "WT_liver-lip.csv", row.names=FALSE)
  3275. #Mantel significance test (analytes in heatmap only)
  3276. set.seed <- 0123456789
  3277. brain_subset <- brain_df_cor[,colnames(correlation_df)]
  3278. liver_subset <- liver_df_cor[,rownames(correlation_df)]
  3279. brain.dist <- vegdist(brain_subset, method="bray")
  3280. liver.dist <- vegdist(liver_subset, method="bray")
  3281. mantel(brain.dist, liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3282. # Call:
  3283. # mantel(xdis = brain.dist, ydis = liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3284. #
  3285. # Mantel statistic r: -0.1578
  3286. # Significance: 0.8656
  3287. #
  3288. # Upper quantiles of permutations (null model):
  3289. # 90% 95% 97.5% 99%
  3290. # 0.187 0.255 0.307 0.360
  3291. # Permutation: free
  3292. # Number of permutations: 9999
  3293. ############## . 5xFAD brain-liver lipids##############
  3294. #5xFAD 4 months targ.met
  3295. TREM2_tar_df = lip_df_combined %>%
  3296. filter(Group2 %in% c("HEMI 5xFAD"), Age == 4) %>%
  3297. column_to_rownames(var = "sample_id")
  3298. brain_df = TREM2_tar_df %>%
  3299. filter(Mode == "brain")
  3300. liver_df = TREM2_tar_df %>%
  3301. filter(Mode == "liver")
  3302. #Only keep brain data from Mouse IDs that we have liver data for
  3303. brain_df_cor <- brain_df[brain_df$Name %in% liver_df$Name, ]
  3304. #Only keep liver data from Mouse IDs that we have brain data for
  3305. liver_df_cor <- liver_df[liver_df$Name %in% brain_df$Name, ]
  3306. #Reassign rownames
  3307. rownames(brain_df_cor) <- NULL
  3308. rownames(brain_df_cor) <- brain_df_cor$Name
  3309. rownames(liver_df_cor) <- NULL
  3310. rownames(liver_df_cor) <- liver_df_cor$Name
  3311. #Arrange metadata
  3312. brain_df_cor <- brain_df_cor %>%
  3313. arrange(Name)
  3314. liver_df_cor <- liver_df_cor %>%
  3315. arrange(Name)
  3316. #Mantel significance test
  3317. set.seed <- 0123456789
  3318. brain.dist <- vegdist(brain_df_cor[,-(1:11)], method="bray")
  3319. liver.dist <- vegdist(liver_df_cor[,-(1:11)], method="bray")
  3320. mantel(brain.dist, liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3321. # Call:
  3322. # mantel(xdis = brain.dist, ydis = liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3323. #
  3324. # Mantel statistic r: 0.07266
  3325. # Significance: 0.2829
  3326. #
  3327. # Upper quantiles of permutations (null model):
  3328. # 90% 95% 97.5% 99%
  3329. # 0.191 0.252 0.305 0.362
  3330. # Permutation: free
  3331. # Number of permutations: 9999
  3332. #correlation analysis
  3333. correlation <- t(cor(brain_df_cor[,-(1:11)], liver_df_cor[,-(1:11)], method = c('spearman')))
  3334. correlation[is.na(correlation)] <- 0
  3335. #only keep brain analytes (columns) with at least one rho value > threshold
  3336. #243 @ rho>0.7
  3337. correlation_df <- as.data.frame(correlation)
  3338. columns_to_keep <- sapply(correlation_df, function(x) {
  3339. max_val <- max(x, na.rm = TRUE)
  3340. min_val <- min(x, na.rm = TRUE)
  3341. return(max_val > 0.7 | min_val < -0.7)
  3342. })
  3343. correlation_df <- correlation_df[, columns_to_keep]
  3344. #only keep liver analytes (rows) with at least one rho value > threshold
  3345. #227 @ rho>0.7
  3346. correlation_df <- correlation_df[apply(correlation_df, 1, max) > 0.7 |
  3347. apply(correlation_df, 1, min) < -0.7, ]
  3348. #heatmap w/ thresholds
  3349. correlation <- as.matrix(correlation_df)
  3350. cor <- pheatmap(correlation, cluster_cols = TRUE, clustering_method = 'average', cluster_rows = TRUE,
  3351. gaps_col = FALSE, color = viridis(10), show_colnames = TRUE, show_rownames = TRUE,
  3352. fontsize = 8, fontsize_col = 6, cutree_cols = 2, angle_col = 90,
  3353. cutree_rows = 2, fontsize_row = 6, silent = FALSE)#, breaks = my.breaks)
  3354. save_pheatmap(cor, "5x_brain-v-liver-lip.png", width=10, height=5)
  3355. write.csv(colnames(correlation_df), "5x_brain-lip.csv", row.names=FALSE)
  3356. write.csv(rownames(correlation_df), "5x_liver-lip.csv", row.names=FALSE)
  3357. #Mantel significance test (analytes in heatmap only)
  3358. set.seed <- 0123456789
  3359. brain_subset <- brain_df_cor[,colnames(correlation_df)]
  3360. liver_subset <- liver_df_cor[,rownames(correlation_df)]
  3361. brain.dist <- vegdist(brain_subset, method="bray")
  3362. liver.dist <- vegdist(liver_subset, method="bray")
  3363. mantel(brain.dist, liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3364. # Call:
  3365. # mantel(xdis = brain.dist, ydis = liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3366. #
  3367. # Mantel statistic r: 0.1887
  3368. # Significance: 0.1124
  3369. #
  3370. # Upper quantiles of permutations (null model):
  3371. # 90% 95% 97.5% 99%
  3372. # 0.201 0.262 0.314 0.371
  3373. # Permutation: free
  3374. # Number of permutations: 9999
  3375. ############## . TREM2 brain-liver lipids##############
  3376. #TREM2 4 months targ.met
  3377. TREM2_tar_df = lip_df_combined %>%
  3378. filter(Group2 %in% c("WT 5xFAD_TREM2"), Age == 4) %>%
  3379. column_to_rownames(var = "sample_id")
  3380. brain_df = TREM2_tar_df %>%
  3381. filter(Mode == "brain")
  3382. liver_df = TREM2_tar_df %>%
  3383. filter(Mode == "liver")
  3384. #Only keep brain data from Mouse IDs that we have liver data for
  3385. brain_df_cor <- brain_df[brain_df$Name %in% liver_df$Name, ]
  3386. #Only keep liver data from Mouse IDs that we have brain data for
  3387. liver_df_cor <- liver_df[liver_df$Name %in% brain_df$Name, ]
  3388. #Reassign rownames
  3389. rownames(brain_df_cor) <- NULL
  3390. rownames(brain_df_cor) <- brain_df_cor$Name
  3391. rownames(liver_df_cor) <- NULL
  3392. rownames(liver_df_cor) <- liver_df_cor$Name
  3393. #Arrange metadata
  3394. brain_df_cor <- brain_df_cor %>%
  3395. arrange(Name)
  3396. liver_df_cor <- liver_df_cor %>%
  3397. arrange(Name)
  3398. #Mantel significance test
  3399. set.seed <- 0123456789
  3400. brain.dist <- vegdist(brain_df_cor[,-(1:11)], method="bray")
  3401. liver.dist <- vegdist(liver_df_cor[,-(1:11)], method="bray")
  3402. mantel(brain.dist, liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3403. # Call:
  3404. # mantel(xdis = brain.dist, ydis = liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3405. #
  3406. # Mantel statistic r: -0.05507
  3407. # Significance: 0.5745
  3408. #
  3409. # Upper quantiles of permutations (null model):
  3410. # 90% 95% 97.5% 99%
  3411. # 0.278 0.350 0.422 0.508
  3412. # Permutation: free
  3413. # Number of permutations: 9999
  3414. #correlation analysis
  3415. correlation <- t(cor(brain_df_cor[,-(1:11)], liver_df_cor[,-(1:11)], method = c('spearman')))
  3416. correlation[is.na(correlation)] <- 0
  3417. #only keep brain analytes (columns) with at least one rho value > threshold
  3418. #495 @ rho>0.7
  3419. correlation_df <- as.data.frame(correlation)
  3420. columns_to_keep <- sapply(correlation_df, function(x) {
  3421. max_val <- max(x, na.rm = TRUE)
  3422. min_val <- min(x, na.rm = TRUE)
  3423. return(max_val > 0.7 | min_val < -0.7)
  3424. })
  3425. correlation_df <- correlation_df[, columns_to_keep]
  3426. #only keep liver analytes (rows) with at least one rho value > threshold
  3427. #586 @ rho>0.7
  3428. correlation_df <- correlation_df[apply(correlation_df, 1, max) > 0.7 |
  3429. apply(correlation_df, 1, min) < -0.7, ]
  3430. #heatmap w/ thresholds
  3431. correlation <- as.matrix(correlation_df)
  3432. cor <- pheatmap(correlation, cluster_cols = TRUE, clustering_method = 'average', cluster_rows = TRUE,
  3433. gaps_col = FALSE, color = viridis(10), show_colnames = TRUE, show_rownames = TRUE,
  3434. fontsize = 8, fontsize_col = 8, cutree_cols = 6, angle_col = 90,
  3435. cutree_rows = 6, fontsize_row = 8, silent = FALSE)#, breaks = my.breaks)
  3436. save_pheatmap(cor, "T2_brain-v-liver-lip.png", width=14, height=28)
  3437. write.csv(colnames(correlation_df), "T2_brain-lip.csv", row.names=FALSE)
  3438. write.csv(rownames(correlation_df), "T2_liver-lip.csv", row.names=FALSE)
  3439. #Mantel significance test (analytes in heatmap only)
  3440. set.seed <- 0123456789
  3441. brain_subset <- brain_df_cor[,colnames(correlation_df)]
  3442. liver_subset <- liver_df_cor[,rownames(correlation_df)]
  3443. brain.dist <- vegdist(brain_subset, method="bray")
  3444. liver.dist <- vegdist(liver_subset, method="bray")
  3445. mantel(brain.dist, liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3446. # Call:
  3447. # mantel(xdis = brain.dist, ydis = liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3448. #
  3449. # Mantel statistic r: -0.07839
  3450. # Significance: 0.5926
  3451. #
  3452. # Upper quantiles of permutations (null model):
  3453. # 90% 95% 97.5% 99%
  3454. # 0.273 0.361 0.448 0.528
  3455. # Permutation: free
  3456. # Number of permutations: 9999
  3457. ############## . 5xFAD*TREM2 brain-liver lipids##############
  3458. #5xFAD*TREM2 4 months targ.met
  3459. TREM2_tar_df = lip_df_combined %>%
  3460. filter(Group2 %in% c("HEMI 5xFAD_TREM2"), Age == 4) %>%
  3461. column_to_rownames(var = "sample_id")
  3462. brain_df = TREM2_tar_df %>%
  3463. filter(Mode == "brain")
  3464. liver_df = TREM2_tar_df %>%
  3465. filter(Mode == "liver")
  3466. #Only keep brain data from Mouse IDs that we have liver data for
  3467. brain_df_cor <- brain_df[brain_df$Name %in% liver_df$Name, ]
  3468. #Only keep liver data from Mouse IDs that we have brain data for
  3469. liver_df_cor <- liver_df[liver_df$Name %in% brain_df$Name, ]
  3470. #Reassign rownames
  3471. rownames(brain_df_cor) <- NULL
  3472. rownames(brain_df_cor) <- brain_df_cor$Name
  3473. rownames(liver_df_cor) <- NULL
  3474. rownames(liver_df_cor) <- liver_df_cor$Name
  3475. #Arrange metadata
  3476. brain_df_cor <- brain_df_cor %>%
  3477. arrange(Name)
  3478. liver_df_cor <- liver_df_cor %>%
  3479. arrange(Name)
  3480. #Mantel significance test
  3481. set.seed <- 0123456789
  3482. brain.dist <- vegdist(brain_df_cor[,-(1:11)], method="bray")
  3483. liver.dist <- vegdist(liver_df_cor[,-(1:11)], method="bray")
  3484. mantel(brain.dist, liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3485. # Call:
  3486. # mantel(xdis = brain.dist, ydis = liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3487. #
  3488. # Mantel statistic r: -0.2273
  3489. # Significance: 0.816
  3490. #
  3491. # Upper quantiles of permutations (null model):
  3492. # 90% 95% 97.5% 99%
  3493. # 0.339 0.434 0.520 0.586
  3494. # Permutation: free
  3495. # Number of permutations: 9999
  3496. #correlation analysis
  3497. correlation <- t(cor(brain_df_cor[,-(1:11)], liver_df_cor[,-(1:11)], method = c('spearman')))
  3498. correlation[is.na(correlation)] <- 0
  3499. #only keep brain analytes (columns) with at least one rho value > threshold
  3500. #494 @ rho>0.7
  3501. correlation_df <- as.data.frame(correlation)
  3502. columns_to_keep <- sapply(correlation_df, function(x) {
  3503. max_val <- max(x, na.rm = TRUE)
  3504. min_val <- min(x, na.rm = TRUE)
  3505. return(max_val > 0.7 | min_val < -0.7)
  3506. })
  3507. correlation_df <- correlation_df[, columns_to_keep]
  3508. #only keep liver analytes (rows) with at least one rho value > threshold
  3509. #703 @ rho>0.7
  3510. correlation_df <- correlation_df[apply(correlation_df, 1, max) > 0.7 |
  3511. apply(correlation_df, 1, min) < -0.7, ]
  3512. #heatmap w/ thresholds
  3513. correlation <- as.matrix(correlation_df)
  3514. cor <- pheatmap(correlation, cluster_cols = TRUE, clustering_method = 'average', cluster_rows = TRUE,
  3515. gaps_col = FALSE, color = viridis(10), show_colnames = TRUE, show_rownames = TRUE,
  3516. fontsize = 8, fontsize_col = 8, cutree_cols = 6, angle_col = 90,
  3517. cutree_rows = 6, fontsize_row = 8, silent = FALSE)#, breaks = my.breaks)
  3518. save_pheatmap(cor, "5xT2_brain-v-liver-lip.png", width=14, height=28)
  3519. write.csv(colnames(correlation_df), "5xT2_brain-lip.csv", row.names=FALSE)
  3520. write.csv(rownames(correlation_df), "5xT2_liver-lip.csv", row.names=FALSE)
  3521. #Mantel significance test (analytes in heatmap only)
  3522. set.seed <- 0123456789
  3523. brain_subset <- brain_df_cor[,colnames(correlation_df)]
  3524. liver_subset <- liver_df_cor[,rownames(correlation_df)]
  3525. brain.dist <- vegdist(brain_subset, method="bray")
  3526. liver.dist <- vegdist(liver_subset, method="bray")
  3527. mantel(brain.dist, liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3528. # Call:
  3529. # mantel(xdis = brain.dist, ydis = liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3530. #
  3531. # Mantel statistic r: -0.2268
  3532. # Significance: 0.8229
  3533. #
  3534. # Upper quantiles of permutations (null model):
  3535. # 90% 95% 97.5% 99%
  3536. # 0.338 0.438 0.522 0.591
  3537. # Permutation: free
  3538. # Number of permutations: 9999
  3539. ############## . . Comparing brain-liver lipids##############
  3540. WT_brain <- read.csv("WT_brain-lip.csv")
  3541. WT_liver <- read.csv("WT_liver-lip.csv")
  3542. Fad_brain <- read.csv("5x_brain-lip.csv")
  3543. Fad_liver <- read.csv("5x_liver-lip.csv")
  3544. T2_brain <- read.csv("T2_brain-lip.csv")
  3545. T2_liver <- read.csv("T2_liver-lip.csv")
  3546. FadT2_brain <- read.csv("5xT2_brain-lip.csv")
  3547. FadT2_liver <- read.csv("5xT2_liver-lip.csv")
  3548. #venn diagrams
  3549. library(ggVennDiagram)
  3550. genes <- paste("gene",1:1000,sep="")
  3551. set.seed(20231214)
  3552. #Combine brain-liver lists to show in one venn diagram
  3553. WT <- unique(c(WT_brain$x, WT_liver$x)) #205
  3554. Fad <- unique(c(Fad_brain$x, Fad_liver$x)) #411
  3555. T2 <- unique(c(T2_brain$x, T2_liver$x)) #750
  3556. FadT2 <- unique(c(FadT2_brain$x, FadT2_liver$x)) #803
  3557. bl <- list(WT=WT,
  3558. `5xFAD`=Fad,
  3559. Trem2=T2,
  3560. `5xFAD, Trem2`=FadT2)
  3561. ggVennDiagram(bl) +#, set_size = 4) +
  3562. scale_fill_gradient(low="grey90",high ="red")
  3563. ggsave("venn_diagram_brain-liver-lip.png", width = 6, height = 5)
  3564. ############## . WT brain-plasma lipids##############
  3565. #WT 4 months targ.met
  3566. TREM2_tar_df = lip_df_combined %>%
  3567. filter(Group2 %in% c("WT 5xFAD"), Age == 4) %>%
  3568. column_to_rownames(var = "sample_id")
  3569. brain_df = TREM2_tar_df %>%
  3570. filter(Mode == "brain")
  3571. plasma_df = TREM2_tar_df %>%
  3572. filter(Mode == "plasma")
  3573. #Only keep brain data from Mouse IDs that we have plasma data for
  3574. brain_df_cor <- brain_df[brain_df$Name %in% plasma_df$Name, ]
  3575. #Only keep plasma data from Mouse IDs that we have brain data for
  3576. plasma_df_cor <- plasma_df[plasma_df$Name %in% brain_df$Name, ]
  3577. #Reassign rownames
  3578. rownames(brain_df_cor) <- NULL
  3579. rownames(brain_df_cor) <- brain_df_cor$Name
  3580. rownames(plasma_df_cor) <- NULL
  3581. rownames(plasma_df_cor) <- plasma_df_cor$Name
  3582. #Arrange metadata
  3583. brain_df_cor <- brain_df_cor %>%
  3584. arrange(Name)
  3585. plasma_df_cor <- plasma_df_cor %>%
  3586. arrange(Name)
  3587. #Mantel significance test
  3588. set.seed <- 0123456789
  3589. brain.dist <- vegdist(brain_df_cor[,-(1:11)], method="euclidean")
  3590. plasma.dist <- vegdist(plasma_df_cor[,-(1:11)], method="euclidean")
  3591. mantel(brain.dist, plasma.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3592. # Call:
  3593. # mantel(xdis = brain.dist, ydis = plasma.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3594. #
  3595. # Mantel statistic r: 0.2525
  3596. # Significance: 0.0815
  3597. #
  3598. # Upper quantiles of permutations (null model):
  3599. # 90% 95% 97.5% 99%
  3600. # 0.229 0.313 0.370 0.437
  3601. # Permutation: free
  3602. # Number of permutations: 9999
  3603. #correlation analysis
  3604. correlation <- t(cor(brain_df_cor[,-(1:11)], plasma_df_cor[,-(1:11)], method = c('spearman')))
  3605. correlation[is.na(correlation)] <- 0
  3606. #only keep brain analytes (columns) with at least one rho value > threshold
  3607. #264 @ rho>0.7
  3608. correlation_df <- as.data.frame(correlation)
  3609. columns_to_keep <- sapply(correlation_df, function(x) {
  3610. max_val <- max(x, na.rm = TRUE)
  3611. min_val <- min(x, na.rm = TRUE)
  3612. return(max_val > 0.7 | min_val < -0.7)
  3613. })
  3614. correlation_df <- correlation_df[, columns_to_keep]
  3615. #only keep plasma analytes (rows) with at least one rho value > threshold
  3616. #352 @ rho>0.7
  3617. correlation_df <- correlation_df[apply(correlation_df, 1, max) > 0.7 |
  3618. apply(correlation_df, 1, min) < -0.7, ]
  3619. #heatmap w/ thresholds
  3620. correlation <- as.matrix(correlation_df)
  3621. cor <- pheatmap(correlation, cluster_cols = TRUE, clustering_method = 'average', cluster_rows = TRUE,
  3622. gaps_col = FALSE, color = viridis(10), show_colnames = TRUE, show_rownames = TRUE,
  3623. fontsize = 8, fontsize_col = 6, cutree_cols = 2, angle_col = 90,
  3624. cutree_rows = 2, fontsize_row = 6, silent = FALSE)#, breaks = my.breaks)
  3625. save_pheatmap(cor, "WT_brain-v-plasma-lip.png", width=10, height=5)
  3626. write.csv(colnames(correlation_df), "WT_brain-v-plasma-lip.csv", row.names=FALSE)
  3627. write.csv(rownames(correlation_df), "WT_plasma-v-brain-lip.csv", row.names=FALSE)
  3628. #Mantel significance test (analytes in heatmap only)
  3629. set.seed <- 0123456789
  3630. brain_subset <- brain_df_cor[,colnames(correlation_df)]
  3631. plasma_subset <- plasma_df_cor[,rownames(correlation_df)]
  3632. brain.dist <- vegdist(brain_subset, method="euclidean")
  3633. plasma.dist <- vegdist(plasma_subset, method="euclidean")
  3634. mantel(brain.dist, plasma.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3635. # Call:
  3636. # mantel(xdis = brain.dist, ydis = plasma.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3637. #
  3638. # Mantel statistic r: 0.4273
  3639. # Significance: 0.0157 *
  3640. #
  3641. # Upper quantiles of permutations (null model):
  3642. # 90% 95% 97.5% 99%
  3643. # 0.232 0.308 0.382 0.464
  3644. # Permutation: free
  3645. # Number of permutations: 9999
  3646. ############## . 5xFAD brain-plasma lipids##############
  3647. #WT 4 months targ.met
  3648. TREM2_tar_df = lip_df_combined %>%
  3649. filter(Group2 %in% c("HEMI 5xFAD"), Age == 4) %>%
  3650. column_to_rownames(var = "sample_id")
  3651. brain_df = TREM2_tar_df %>%
  3652. filter(Mode == "brain")
  3653. plasma_df = TREM2_tar_df %>%
  3654. filter(Mode == "plasma")
  3655. #Only keep brain data from Mouse IDs that we have plasma data for
  3656. brain_df_cor <- brain_df[brain_df$Name %in% plasma_df$Name, ]
  3657. #Only keep plasma data from Mouse IDs that we have brain data for
  3658. plasma_df_cor <- plasma_df[plasma_df$Name %in% brain_df$Name, ]
  3659. #Reassign rownames
  3660. rownames(brain_df_cor) <- NULL
  3661. rownames(brain_df_cor) <- brain_df_cor$Name
  3662. rownames(plasma_df_cor) <- NULL
  3663. rownames(plasma_df_cor) <- plasma_df_cor$Name
  3664. #Arrange metadata
  3665. brain_df_cor <- brain_df_cor %>%
  3666. arrange(Name)
  3667. plasma_df_cor <- plasma_df_cor %>%
  3668. arrange(Name)
  3669. #Mantel significance test
  3670. set.seed <- 0123456789
  3671. brain.dist <- vegdist(brain_df_cor[,-(1:11)], method="euclidean")
  3672. plasma.dist <- vegdist(plasma_df_cor[,-(1:11)], method="euclidean")
  3673. mantel(brain.dist, plasma.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3674. # Call:
  3675. # mantel(xdis = brain.dist, ydis = plasma.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3676. #
  3677. # Mantel statistic r: -0.2319
  3678. # Significance: 0.9536
  3679. #
  3680. # Upper quantiles of permutations (null model):
  3681. # 90% 95% 97.5% 99%
  3682. # 0.209 0.280 0.341 0.403
  3683. # Permutation: free
  3684. # Number of permutations: 9999
  3685. #correlation analysis
  3686. correlation <- t(cor(brain_df_cor[,-(1:11)], plasma_df_cor[,-(1:11)], method = c('spearman')))
  3687. correlation[is.na(correlation)] <- 0
  3688. #only keep brain analytes (columns) with at least one rho value > threshold
  3689. #248 @ rho>0.7
  3690. correlation_df <- as.data.frame(correlation)
  3691. columns_to_keep <- sapply(correlation_df, function(x) {
  3692. max_val <- max(x, na.rm = TRUE)
  3693. min_val <- min(x, na.rm = TRUE)
  3694. return(max_val > 0.7 | min_val < -0.7)
  3695. })
  3696. correlation_df <- correlation_df[, columns_to_keep]
  3697. #only keep plasma analytes (rows) with at least one rho value > threshold
  3698. #176 @ rho>0.7
  3699. correlation_df <- correlation_df[apply(correlation_df, 1, max) > 0.7 |
  3700. apply(correlation_df, 1, min) < -0.7, ]
  3701. #heatmap w/ thresholds
  3702. correlation <- as.matrix(correlation_df)
  3703. cor <- pheatmap(correlation, cluster_cols = TRUE, clustering_method = 'average', cluster_rows = TRUE,
  3704. gaps_col = FALSE, color = viridis(10), show_colnames = TRUE, show_rownames = TRUE,
  3705. fontsize = 8, fontsize_col = 6, cutree_cols = 2, angle_col = 90,
  3706. cutree_rows = 2, fontsize_row = 6, silent = FALSE)#, breaks = my.breaks)
  3707. save_pheatmap(cor, "5x_brain-v-plasma-lip.png", width=10, height=5)
  3708. write.csv(colnames(correlation_df), "5x_brain-v-plasma-lip.csv", row.names=FALSE)
  3709. write.csv(rownames(correlation_df), "5x_plasma-v-brain-lip.csv", row.names=FALSE)
  3710. #Mantel significance test (analytes in heatmap only)
  3711. set.seed <- 0123456789
  3712. brain_subset <- brain_df_cor[,colnames(correlation_df)]
  3713. plasma_subset <- plasma_df_cor[,rownames(correlation_df)]
  3714. brain.dist <- vegdist(brain_subset, method="euclidean")
  3715. plasma.dist <- vegdist(plasma_subset, method="euclidean")
  3716. mantel(brain.dist, plasma.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3717. # Call:
  3718. # mantel(xdis = brain.dist, ydis = plasma.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3719. #
  3720. # Mantel statistic r: -0.1521
  3721. # Significance: 0.8285
  3722. #
  3723. # Upper quantiles of permutations (null model):
  3724. # 90% 95% 97.5% 99%
  3725. # 0.219 0.289 0.346 0.408
  3726. # Permutation: free
  3727. # Number of permutations: 9999
  3728. ############## . TREM2 brain-plasma lipids##############
  3729. #WT 4 months targ.met
  3730. TREM2_tar_df = lip_df_combined %>%
  3731. filter(Group2 %in% c("WT 5xFAD_TREM2"), Age == 4) %>%
  3732. column_to_rownames(var = "sample_id")
  3733. brain_df = TREM2_tar_df %>%
  3734. filter(Mode == "brain")
  3735. plasma_df = TREM2_tar_df %>%
  3736. filter(Mode == "plasma")
  3737. #Only keep brain data from Mouse IDs that we have plasma data for
  3738. brain_df_cor <- brain_df[brain_df$Name %in% plasma_df$Name, ]
  3739. #Only keep plasma data from Mouse IDs that we have brain data for
  3740. plasma_df_cor <- plasma_df[plasma_df$Name %in% brain_df$Name, ]
  3741. #Reassign rownames
  3742. rownames(brain_df_cor) <- NULL
  3743. rownames(brain_df_cor) <- brain_df_cor$Name
  3744. rownames(plasma_df_cor) <- NULL
  3745. rownames(plasma_df_cor) <- plasma_df_cor$Name
  3746. #Arrange metadata
  3747. brain_df_cor <- brain_df_cor %>%
  3748. arrange(Name)
  3749. plasma_df_cor <- plasma_df_cor %>%
  3750. arrange(Name)
  3751. #Mantel significance test
  3752. set.seed <- 0123456789
  3753. brain.dist <- vegdist(brain_df_cor[,-(1:11)], method="euclidean")
  3754. plasma.dist <- vegdist(plasma_df_cor[,-(1:11)], method="euclidean")
  3755. mantel(brain.dist, plasma.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3756. # Call:
  3757. # mantel(xdis = brain.dist, ydis = plasma.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3758. #
  3759. # Mantel statistic r: -0.1145
  3760. # Significance: 0.688
  3761. #
  3762. # Upper quantiles of permutations (null model):
  3763. # 90% 95% 97.5% 99%
  3764. # 0.282 0.358 0.426 0.488
  3765. # Permutation: free
  3766. # Number of permutations: 9999
  3767. #correlation analysis
  3768. correlation <- t(cor(brain_df_cor[,-(1:11)], plasma_df_cor[,-(1:11)], method = c('spearman')))
  3769. correlation[is.na(correlation)] <- 0
  3770. #only keep brain analytes (columns) with at least one rho value > threshold
  3771. #474 @ rho>0.7
  3772. correlation_df <- as.data.frame(correlation)
  3773. columns_to_keep <- sapply(correlation_df, function(x) {
  3774. max_val <- max(x, na.rm = TRUE)
  3775. min_val <- min(x, na.rm = TRUE)
  3776. return(max_val > 0.7 | min_val < -0.7)
  3777. })
  3778. correlation_df <- correlation_df[, columns_to_keep]
  3779. #only keep plasma analytes (rows) with at least one rho value > threshold
  3780. #652 @ rho>0.7
  3781. correlation_df <- correlation_df[apply(correlation_df, 1, max) > 0.7 |
  3782. apply(correlation_df, 1, min) < -0.7, ]
  3783. #heatmap w/ thresholds
  3784. correlation <- as.matrix(correlation_df)
  3785. cor <- pheatmap(correlation, cluster_cols = TRUE, clustering_method = 'average', cluster_rows = TRUE,
  3786. gaps_col = FALSE, color = viridis(10), show_colnames = TRUE, show_rownames = TRUE,
  3787. fontsize = 8, fontsize_col = 6, cutree_cols = 2, angle_col = 90,
  3788. cutree_rows = 2, fontsize_row = 6, silent = FALSE)#, breaks = my.breaks)
  3789. save_pheatmap(cor, "T2_brain-v-plasma-lip.png", width=10, height=5)
  3790. write.csv(colnames(correlation_df), "T2_brain-v-plasma-lip.csv", row.names=FALSE)
  3791. write.csv(rownames(correlation_df), "T2_plasma-v-brain-lip.csv", row.names=FALSE)
  3792. #Mantel significance test (analytes in heatmap only)
  3793. set.seed <- 0123456789
  3794. brain_subset <- brain_df_cor[,colnames(correlation_df)]
  3795. plasma_subset <- plasma_df_cor[,rownames(correlation_df)]
  3796. brain.dist <- vegdist(brain_subset, method="euclidean")
  3797. plasma.dist <- vegdist(plasma_subset, method="euclidean")
  3798. mantel(brain.dist, plasma.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3799. # Call:
  3800. # mantel(xdis = brain.dist, ydis = plasma.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3801. #
  3802. # Mantel statistic r: -0.003953
  3803. # Significance: 0.4918
  3804. #
  3805. # Upper quantiles of permutations (null model):
  3806. # 90% 95% 97.5% 99%
  3807. # 0.270 0.345 0.404 0.474
  3808. # Permutation: free
  3809. # Number of permutations: 9999
  3810. ############## . 5xFAD*TREM2 brain-plasma lipids##############
  3811. #WT 4 months targ.met
  3812. TREM2_tar_df = lip_df_combined %>%
  3813. filter(Group2 %in% c("HEMI 5xFAD_TREM2"), Age == 4) %>%
  3814. column_to_rownames(var = "sample_id")
  3815. brain_df = TREM2_tar_df %>%
  3816. filter(Mode == "brain")
  3817. plasma_df = TREM2_tar_df %>%
  3818. filter(Mode == "plasma")
  3819. #Only keep brain data from Mouse IDs that we have plasma data for
  3820. brain_df_cor <- brain_df[brain_df$Name %in% plasma_df$Name, ]
  3821. #Only keep plasma data from Mouse IDs that we have brain data for
  3822. plasma_df_cor <- plasma_df[plasma_df$Name %in% brain_df$Name, ]
  3823. #Reassign rownames
  3824. rownames(brain_df_cor) <- NULL
  3825. rownames(brain_df_cor) <- brain_df_cor$Name
  3826. rownames(plasma_df_cor) <- NULL
  3827. rownames(plasma_df_cor) <- plasma_df_cor$Name
  3828. #Arrange metadata
  3829. brain_df_cor <- brain_df_cor %>%
  3830. arrange(Name)
  3831. plasma_df_cor <- plasma_df_cor %>%
  3832. arrange(Name)
  3833. #Mantel significance test
  3834. set.seed <- 0123456789
  3835. brain.dist <- vegdist(brain_df_cor[,-(1:11)], method="euclidean")
  3836. plasma.dist <- vegdist(plasma_df_cor[,-(1:11)], method="euclidean")
  3837. mantel(brain.dist, plasma.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3838. # Call:
  3839. # mantel(xdis = brain.dist, ydis = plasma.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3840. #
  3841. # Mantel statistic r: -0.3506
  3842. # Significance: 0.894
  3843. #
  3844. # Upper quantiles of permutations (null model):
  3845. # 90% 95% 97.5% 99%
  3846. # 0.439 0.547 0.657 0.751
  3847. # Permutation: free
  3848. # Number of permutations: 9999
  3849. #correlation analysis
  3850. correlation <- t(cor(brain_df_cor[,-(1:11)], plasma_df_cor[,-(1:11)], method = c('spearman')))
  3851. correlation[is.na(correlation)] <- 0
  3852. #only keep brain analytes (columns) with at least one rho value > threshold
  3853. #505 @ rho>0.7
  3854. correlation_df <- as.data.frame(correlation)
  3855. columns_to_keep <- sapply(correlation_df, function(x) {
  3856. max_val <- max(x, na.rm = TRUE)
  3857. min_val <- min(x, na.rm = TRUE)
  3858. return(max_val > 0.7 | min_val < -0.7)
  3859. })
  3860. correlation_df <- correlation_df[, columns_to_keep]
  3861. #only keep plasma analytes (rows) with at least one rho value > threshold
  3862. #912 @ rho>0.7
  3863. correlation_df <- correlation_df[apply(correlation_df, 1, max) > 0.7 |
  3864. apply(correlation_df, 1, min) < -0.7, ]
  3865. #heatmap w/ thresholds
  3866. correlation <- as.matrix(correlation_df)
  3867. cor <- pheatmap(correlation, cluster_cols = TRUE, clustering_method = 'average', cluster_rows = TRUE,
  3868. gaps_col = FALSE, color = viridis(10), show_colnames = TRUE, show_rownames = TRUE,
  3869. fontsize = 8, fontsize_col = 6, cutree_cols = 2, angle_col = 90,
  3870. cutree_rows = 2, fontsize_row = 6, silent = FALSE)#, breaks = my.breaks)
  3871. save_pheatmap(cor, "5xT2_brain-v-plasma-lip.png", width=10, height=5)
  3872. write.csv(colnames(correlation_df), "5xT2_brain-v-plasma-lip.csv", row.names=FALSE)
  3873. write.csv(rownames(correlation_df), "5xT2_plasma-v-brain-lip.csv", row.names=FALSE)
  3874. #Mantel significance test (analytes in heatmap only)
  3875. set.seed <- 0123456789
  3876. brain_subset <- brain_df_cor[,colnames(correlation_df)]
  3877. plasma_subset <- plasma_df_cor[,rownames(correlation_df)]
  3878. brain.dist <- vegdist(brain_subset, method="euclidean")
  3879. plasma.dist <- vegdist(plasma_subset, method="euclidean")
  3880. mantel(brain.dist, plasma.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3881. # Call:
  3882. # mantel(xdis = brain.dist, ydis = plasma.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3883. #
  3884. # Mantel statistic r: -0.3514
  3885. # Significance: 0.8982
  3886. #
  3887. # Upper quantiles of permutations (null model):
  3888. # 90% 95% 97.5% 99%
  3889. # 0.452 0.573 0.661 0.750
  3890. # Permutation: free
  3891. # Number of permutations: 9999
  3892. ############## . . Comparing brain-plasma lipids##############
  3893. WT_brain <- read.csv("WT_brain-v-plasma-lip.csv")
  3894. WT_plasma <- read.csv("WT_plasma-v-brain-lip.csv")
  3895. Fad_brain <- read.csv("5x_brain-v-plasma-lip.csv")
  3896. Fad_plasma <- read.csv("5x_plasma-v-brain-lip.csv")
  3897. T2_brain <- read.csv("T2_brain-v-plasma-lip.csv")
  3898. T2_plasma <- read.csv("T2_plasma-v-brain-lip.csv")
  3899. FadT2_brain <- read.csv("5xT2_brain-v-plasma-lip.csv")
  3900. FadT2_plasma <- read.csv("5xT2_plasma-v-brain-lip.csv")
  3901. #venn diagrams
  3902. library(ggVennDiagram)
  3903. genes <- paste("gene",1:1000,sep="")
  3904. set.seed(20231214)
  3905. #Combine brain-liver lists to show in one venn diagram
  3906. WT <- unique(c(WT_brain$x, WT_plasma$x)) #528
  3907. Fad <- unique(c(Fad_brain$x, Fad_plasma$x)) #389
  3908. T2 <- unique(c(T2_brain$x, T2_plasma$x)) #815
  3909. FadT2 <- unique(c(FadT2_brain$x, FadT2_plasma$x)) #932
  3910. bp <- list(WT=WT,
  3911. `5xFAD`=Fad,
  3912. Trem2=T2,
  3913. `5xFAD, Trem2`=FadT2)
  3914. ggVennDiagram(bp) +#, set_size = 4) +
  3915. scale_fill_gradient(low="grey90",high ="red")
  3916. ggsave("venn_diagram_brain-plasma-lip.png", width = 6, height = 5)
  3917. ############## . . Extracting 5xFAD, TREM2 (only) brain-plasma lipids##############
  3918. WT_brain <- read.csv("WT_brain-v-plasma-lip.csv")
  3919. WT_plasma <- read.csv("WT_plasma-v-brain-lip.csv")
  3920. Fad_brain <- read.csv("5x_brain-v-plasma-lip.csv")
  3921. Fad_plasma <- read.csv("5x_plasma-v-brain-lip.csv")
  3922. T2_brain <- read.csv("T2_brain-v-plasma-lip.csv")
  3923. T2_plasma <- read.csv("T2_plasma-v-brain-lip.csv")
  3924. FadT2_brain <- read.csv("5xT2_brain-v-plasma-lip.csv")
  3925. FadT2_plasma <- read.csv("5xT2_plasma-v-brain-lip.csv")
  3926. WT <- unique(c(WT_brain$x, WT_plasma$x)) #528
  3927. Fad <- unique(c(Fad_brain$x, Fad_plasma$x)) #389
  3928. T2 <- unique(c(T2_brain$x, T2_plasma$x)) #815
  3929. FadT2 <- unique(c(FadT2_brain$x, FadT2_plasma$x)) #932
  3930. all_exclusions <- c(WT, Fad, T2)
  3931. FadT2_only <- FadT2[!FadT2 %in% all_exclusions]
  3932. write.csv(FadT2_only, "5xT2_only_brain-v-plasma-lip.csv", row.names=FALSE)
  3933. ############## . WT plasma-liver lipids##############
  3934. #WT 4 months targ.met
  3935. TREM2_tar_df = lip_df_combined %>%
  3936. filter(Group2 %in% c("WT 5xFAD"), Age == 4) %>%
  3937. column_to_rownames(var = "sample_id")
  3938. plasma_df = TREM2_tar_df %>%
  3939. filter(Mode == "plasma")
  3940. liver_df = TREM2_tar_df %>%
  3941. filter(Mode == "liver")
  3942. #Only keep plasma data from Mouse IDs that we have liver data for
  3943. plasma_df_cor <- plasma_df[plasma_df$Name %in% liver_df$Name, ]
  3944. #Only keep liver data from Mouse IDs that we have plasma data for
  3945. liver_df_cor <- liver_df[liver_df$Name %in% plasma_df$Name, ]
  3946. #Reassign rownames
  3947. rownames(plasma_df_cor) <- NULL
  3948. rownames(plasma_df_cor) <- plasma_df_cor$Name
  3949. rownames(liver_df_cor) <- NULL
  3950. rownames(liver_df_cor) <- liver_df_cor$Name
  3951. #Arrange metadata
  3952. plasma_df_cor <- plasma_df_cor %>%
  3953. arrange(Name)
  3954. liver_df_cor <- liver_df_cor %>%
  3955. arrange(Name)
  3956. #Mantel significance test
  3957. set.seed <- 0123456789
  3958. plasma.dist <- vegdist(plasma_df_cor[,-(1:11)], method="euclidean")
  3959. liver.dist <- vegdist(liver_df_cor[,-(1:11)], method="euclidean")
  3960. mantel(plasma.dist, liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3961. # Call:
  3962. # mantel(xdis = plasma.dist, ydis = liver.dist, method = "spearman", permutations = 9999, na.rm = TRUE)
  3963. #
  3964. # Mantel statistic r: 0.01878
  3965. # Significance: 0.4128
  3966. #
  3967. # Upper quantiles of permutations (null model):
  3968. # 90% 95% 97.5% 99%
  3969. # 0.247 0.325 0.400 0.488
  3970. # Permutation: free
  3971. # Number of permutations: 9999
  3972. #correlation analysis
  3973. correlation <- t(cor(plasma_df_cor[,-(1:11)], liver_df_cor[,-(1:11)], method = c('spearman')))
  3974. correlation[is.na(correlation)] <- 0
  3975. #only keep plasma analytes (columns) with at least one rho value > threshold
  3976. #714 @ rho>0.7
  3977. correlation_df <- as.data.frame(correlation)
  3978. columns_to_keep <- sapply(correlation_df, function(x) {
  3979. max_val <- max(x, na.rm = TRUE)
  3980. min_val <- min(x, na.rm = TRUE)
  3981. return(max_val > 0.7 | min_val < -0.7)
  3982. })
  3983. correlation_df <- correlation_df[, columns_to_keep]
  3984. #only keep liver analytes (rows) with at least one rho value > threshold
  3985. #449 @ rho>0.7
  3986. correlation_df <- correlation_df[apply(correlation_df, 1, max) > 0.7 |
  3987. apply(correlation_df, 1, min) < -0.7, ]
  3988. #heatmap w/ thresholds
  3989. correlation <- as.matrix(correlation_df)
  3990. cor <- pheatmap(correlation, cluster_cols = TRUE, clustering_method = 'average', cluster_rows = TRUE,
  3991. gaps_col = FALSE, color = viridis(10), show_colnames = TRUE, show_rownames = TRUE,
  3992. fontsize = 8, fontsize_col = 6, cutree_cols = 2, angle_col = 90,
  3993. cutree_rows = 2, fontsize_row = 6, silent = FALSE)#, breaks = my.breaks)
  3994. save_pheatmap(cor, "WT_plasma-v-liver-lip.png", width=10, height=5)
  3995. write.csv(colnames(correlation_df), "WT_plasma-v-liver-lip.csv", row.names=FALSE)
  3996. write.csv(rownames(correlation_df), "WT_liver-v-plasma-lip.csv", row.names=FALSE)
  3997. #Mantel significance test (analytes in heatmap only)
  3998. set.seed <- 0123456789
  3999. plasma_subse

TREM2-metabolomics-figures-final-v3.R at commit c38d0be, under MIT · at the source

Overview

Authors: Gina Faraci1,2,3, Benjamin Goodfriend1, Joseph Bishop1, Michael Vu1, Julio Avelar-Barragan2, Sage J.B. Dunham2, Jason A. Rothman4, Katrine L. Whiteson2, Amrita K. Cheema5, Giedre Milinkeviciute3, Andrea J. Tenner2,3,6,7, Frank M. LaFerla3,6, Grant R. MacGregor8,9, Kim N. Green3,6, Mark Mapstone1,3
  1. Department of Neurology, University of California, Irvine, CA 92617, USA
  2. Department of Molecular Biology and Biochemistry, University of California, Irvine, CA 92697, USA
  3. Institute for Memory Impairments and Neurological Disorders, University of California, Irvine, CA 92697, USA
  4. Department of Microbiology and Plant Pathology, University of California, Riverside, CA 92521, USA
  5. Department of Oncology, Georgetown University, Washington, DC 20007, USA
  6. Department of Neurobiology and Behavior, University of California, Irvine, CA 92697, USA
  7. Department of Pathology and Laboratory Medicine, University of California, Irvine, CA 92617, USA
  8. Transgenic Mouse Facility, ULAR, Office of Research, University of California, Irvine, CA 92697, USA
  9. Department of Developmental and Cell Biology, University of California, Irvine, CA 92697, USA
Institutions: University of California, Irvine (United States); University of California, Riverside (United States); Georgetown University (United States)
Journal: Neurobiology of aging, volume 165, pages 24-37
Dates: published online 29 April 2026; in print September 2026
Type: Research article · Language: English
License: CC BY
Identifiers: DOI 10.1016/j.neurobiolaging.2026.04.007 · PMID 42102578 · PMCID PMC13249471 · OpenAlex W7160013979
Open access: hybrid, a free copy (OpenAlex)
Status: code verified
Categories: genetics / omics (modality), human (organism), mouse (organism), Alzheimer's / dementia (population), cellular / molecular (subfield)
Methods: Statistics, Connectivity, Machine learning
Keywords: Alzheimer’s disease, Metabolomics, Lipid, Mouse, Brain, Plasma, Liver
MeSH: Alzheimer Disease*, Brain*, Genetic Association Studies*, Genetic Variation*, Homeostasis*, Liver*, Membrane Glycoproteins*, Receptors, Immunologic*, Animals, Disease Models, Animal, Female, Humans, Lipid Metabolism, Male, Mice, Transgenic, Triglycerides (* major topic)
Topic: Neuroinflammation and Neurodegeneration Mechanisms (Neurology, Neuroscience), according to OpenAlex
Funding: NCI NIH HHS (P30 CA062203); University of California, Irvine; National Institute on Aging (U54 AG054349); National Institutes of Health; NIA NIH HHS (U54 AG054349); National Institutes of Health National Cancer Institute (P30CA062203)
Citations: not cited yet (Europe PMC); 70 references in the paper

Abstract

The human Triggering Receptor Expressed on Myeloid cells 2 (TREM2) gene is expressed predominantly by microglia in the brain and the R47H coding variant of TREM2 is associated with increased risk for late-onset Alzheimer’s disease (LOAD). We performed lipidomic and metabolomic analysis of liver, plasma, and brain in 4- and 12-month-old Trem2R47H homozygous (n = 27), 5xFAD hemizygous (n = 63), 5xFAD hemizygous, Trem2R47H homozygous (n = 25), and wild type (n = 65) mice. Lipid and metabolite abundances differed significantly across tissue types with the most differences seen in the liver and plasma of Trem2R47H mice at the 4-month timepoint. Cross-tissue correlation analyses revealed increased metabolic crosstalk along the liver-plasma-brain axis in Trem2R47H mice. Plasma triacylglyceride levels were significantly lower in females compared to males regardless of genotype, and 5-methyltetrahydrofolic acid levels were elevated in the brains of animals homozygous for the Trem2R47H variant. Together, these findings demonstrate early dyshomeostasis of the liver-plasma-brain axis of Trem2R47H mice which impacts several key metabolic pathways involving lipids, cellular energy metabolism, and brain folate metabolism.

Reproduced under the paper's license (CC BY), from the paper cited above.

Repository

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

GinaFaraci/TREM2-Metabolomics

License: MIT
State: the link answers, verified on 30 September 2026
Evidence: files inventoried
Commit: c38d0be42ec0194add0c2f8af1f784ea86dfd452, 16 March 2026
Languages: R (1)
Size: 10 files, 1 script
Software Heritage: not archived
Found in: “Data availability”
Holds: README, license file
Not found: CITATION.cff, environment file, tests, continuous integration, documentation
Tools: broom (1 file), ggpubr (1 file), pheatmap (1 file), tidyverse (1 file)
Availability: 1 check, the latest on 30 September 2026: the link answers
  • 30 September 2026: the link answers
3 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:

  • 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

Datasets cited

Data availability

The datasets generated and/or analyzed during the current study are publicly available via Harvard Dataverse (https://doi.org/10.7910/DVN/XZZCDE). An identical version of these materials, including analysis code, is also available at GitHub (https://github.com/GinaFaraci/TREM2-Metabolomics).

Reproduced under the paper's license (CC BY), from the paper cited above.

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

Recorded: type, language, journal, volume, pages, dates, 15 authors, 7 keywords, 16 MeSH terms, 6 funders, 68 references.

Cite

This paper

Faraci, G., Goodfriend, B., Bishop, J., Vu, M., Avelar-Barragan, J., Dunham, S. J., Rothman, J. A., Whiteson, K. L., Cheema, A. K., Milinkeviciute, G., Tenner, A. J., LaFerla, F. M., MacGregor, G. R., Green, K. N., & Mapstone, M. (2026). The TREM2 R47H variant is associated with liver-plasma-brain axis dyshomeostasis in the 5xFAD mouse model of Alzheimer's disease. Neurobiology of aging, 165, 24-37. https://doi.org/10.1016/j.neurobiolaging.2026.04.007

BibTeX

@article{faraci2026trem2,
author = {Faraci, Gina and Goodfriend, Benjamin and Bishop, Joseph and Vu, Michael and Avelar-Barragan, Julio and Dunham, Sage J.B. and Rothman, Jason A. and Whiteson, Katrine L. and Cheema, Amrita K. and Milinkeviciute, Giedre and Tenner, Andrea J. and LaFerla, Frank M. and MacGregor, Grant R. and Green, Kim N. and Mapstone, Mark},
title = {{The TREM2 R47H variant is associated with liver-plasma-brain axis dyshomeostasis in the 5xFAD mouse model of Alzheimer's disease}},
journal = {Neurobiology of aging},
year = {2026},
month = apr,
volume = {165},
pages = {24--37},
publisher = {Elsevier BV},
issn = {0197-4580},
doi = {10.1016/j.neurobiolaging.2026.04.007},
url = {https://doi.org/10.1016/j.neurobiolaging.2026.04.007},
pmid = {42102578},
pmcid = {PMC13249471}
}

RIS

TY - JOUR
AU - Faraci, Gina
AU - Goodfriend, Benjamin
AU - Bishop, Joseph
AU - Vu, Michael
AU - Avelar-Barragan, Julio
AU - Dunham, Sage J.B.
AU - Rothman, Jason A.
AU - Whiteson, Katrine L.
AU - Cheema, Amrita K.
AU - Milinkeviciute, Giedre
AU - Tenner, Andrea J.
AU - LaFerla, Frank M.
AU - MacGregor, Grant R.
AU - Green, Kim N.
AU - Mapstone, Mark
TI - The TREM2 R47H variant is associated with liver-plasma-brain axis dyshomeostasis in the 5xFAD mouse model of Alzheimer's disease
T2 - Neurobiology of aging
J2 - Neurobiol Aging
PY - 2026
DA - 2026/04/29
VL - 165
SP - 24
EP - 37
SN - 0197-4580
PB - Elsevier BV
DO - 10.1016/j.neurobiolaging.2026.04.007
UR - https://doi.org/10.1016/j.neurobiolaging.2026.04.007
LA - en
ER -

CSL-JSON

{
"id": "10.1016/j.neurobiolaging.2026.04.007",
"type": "article-journal",
"title": "The TREM2 R47H variant is associated with liver-plasma-brain axis dyshomeostasis in the 5xFAD mouse model of Alzheimer's disease",
"container-title": "Neurobiology of aging",
"author": [
{
"family": "Faraci",
"given": "Gina"
},
{
"family": "Goodfriend",
"given": "Benjamin"
},
{
"family": "Bishop",
"given": "Joseph"
},
{
"family": "Vu",
"given": "Michael"
},
{
"family": "Avelar-Barragan",
"given": "Julio"
},
{
"family": "Dunham",
"given": "Sage J.B."
},
{
"family": "Rothman",
"given": "Jason A."
},
{
"family": "Whiteson",
"given": "Katrine L."
},
{
"family": "Cheema",
"given": "Amrita K."
},
{
"family": "Milinkeviciute",
"given": "Giedre"
},
{
"family": "Tenner",
"given": "Andrea J."
},
{
"family": "LaFerla",
"given": "Frank M."
},
{
"family": "MacGregor",
"given": "Grant R."
},
{
"family": "Green",
"given": "Kim N."
},
{
"family": "Mapstone",
"given": "Mark"
}
],
"container-title-short": "Neurobiol Aging",
"volume": "165",
"page": "24-37",
"DOI": "10.1016/j.neurobiolaging.2026.04.007",
"PMID": "42102578",
"PMCID": "PMC13249471",
"ISSN": "0197-4580",
"publisher": "Elsevier BV",
"URL": "https://doi.org/10.1016/j.neurobiolaging.2026.04.007",
"language": "en",
"issued": {
"date-parts": [
[
2026,
4,
29
]
]
}
}

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.1186/s40478-026-02287-x [code]
Cellular signatures of melanocortin pathway genes across the locus coeruleus.
Journal: Acta neuropathologica communications
In common: tidyverse, Alzheimer's / dementia, genetics / omics, mouse, 1 other category, 5 references
[2] doi:10.1186/s12974-026-03848-6 [code]
Iba1 deficiency impairs microglial synaptic remodeling and neuronal survival after axonal injury.
Journal: Journal of neuroinflammation
In common: pheatmap, tidyverse, genetics / omics, mouse, cellular / molecular, 4 references
[3] doi:10.1007/s00401-026-03036-z
Mechanisms of increased Alzheimer's disease pathology with R47H and R62H TREM2 variants.
Journal: Acta neuropathologica
In common: Alzheimer's / dementia, genetics / omics, cellular / molecular, 5 references
[4] doi:10.1038/s44400-026-00100-z [code]
Peripheral blood microarray-based transcriptomic and epigenetic analyses identify immune, inflammation, and metabolic dysregulation in Alzheimer's disease.
Journal: NPJ dementia
In common: broom, pheatmap, ggpubr, 1 other tool, Alzheimer's / dementia, genetics / omics, 1 reference
[5] doi:10.1093/bioinformatics/btag592 [code]
Network-based stratification of allele-specific expression reveals patient subgroups in Huntington's disease.
Journal: Bioinformatics (Oxford, England)
In common: broom, pheatmap, ggpubr, 1 other tool, genetics / omics, 1 reference
[6] doi:10.1016/j.isci.2026.115638 [code]
Genome-scale metabolic modeling uncovers cell-type specific signatures associated with APOE variants.
Journal: iScience
In common: tidyverse, Alzheimer's / dementia, genetics / omics, cellular / molecular, 3 references
[7] 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, pheatmap, ggpubr, 1 other tool, genetics / omics, mouse, cellular / molecular
[8] doi:10.1016/j.celrep.2026.117073 [code]
Single-cell epigenomics uncovers heterochromatin instability and transcription factor dysfunction during mouse brain aging.
Journal: Cell reports
In common: broom, pheatmap, ggpubr, 1 other tool, genetics / omics, mouse, cellular / molecular
[9] doi:10.1186/s12974-026-03897-x [code]
Ischemic injury triggers a protective microglial phenotype in models of Aβ pathology.
Journal: Journal of neuroinflammation
In common: pheatmap, ggpubr, tidyverse, Alzheimer's / dementia, mouse, cellular / molecular, 1 reference
[10] doi:10.1007/s12035-026-05859-z [code]
Uncovering Spatiotemporal and Functional Dynamics of Long Non-coding RNAs During Alzheimer's Progression in the Human Brain at Single-Cell Resolution.
Journal: Molecular neurobiology
In common: pheatmap, ggpubr, tidyverse, Alzheimer's / dementia, genetics / omics, cellular / molecular, 1 reference

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.