OSCR

Transcriptional predictors of rescue behaviour in ants.

Code ↔ Paper

10 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 10 matches
  1. [1] § RESULTS › Gene expression differences per tissue ↔ Script_Rescue.R, lines 568–614 · score 0.97 · gene_13149, gene_1607, gene_3426, gene_3661, gene_3662, gene_5298
  2. [2] § RESULTS › Gene expression differences across tissues ↔ Script_Rescue.R, lines 662–731 · score 0.90 · gene_13318, gene_13632, gene_14429, gene_1997, gene_7603, gene_14458
  3. [3] § MATERIALS AND METHODS › RNA extraction and sequencing ↔ Script_Rescue.R, lines 618–660 · score 0.84 · antennal lobes, optic lobes, mushroom bodies, brain tissue, RNA, dissect
  4. [4] § MATERIALS AND METHODS › Analysis of gene expression ↔ Script_Rescue.R, lines 662–731 · score 0.77 · variance stabilizing transformation, reduced model, Colony ID, DESeq2, variable, PCA
  5. [5] § MATERIALS AND METHODS › RNA extraction and sequencing ↔ Script_Rescue.R, lines 618–660 · score 0.74 · mRNA, DESeq2, brain tissues, sequencing, antennae, CC
  6. [6] § RESULTS › Non-annotated DEGs and GO-term enrichment ↔ Script_Rescue.R, lines 1074–1122 · score 0.72 · cellular components, GO enrichment, GO terms, molecular functions, biological, upregulated
  7. [7] § RESULTS › Non-annotated DEGs and GO-term enrichment ↔ Script_Rescue.R, lines 1074–1122 · score 0.72 · InterPro, GO term, gene_1243, gene_9900, Pfam, protein
  8. [8] § RESULTS › Gene expression differences per tissue ↔ Script_Rescue.R, lines 847–906 · score 0.65 · Venn diagram, variance stabilized transformed, log2 fold change, PCA, LRT, tissues
  9. [9] § MATERIALS AND METHODS › Behavioural experiment ↔ Script_Rescue.R, lines 500–566 · score 0.64 · travelled distance, simulateResiduals, outer circle, glmmTMB, latency, anova
  10. [10] § MATERIALS AND METHODS › Sensitivity analysis ↔ Script_Rescue.R, lines 1–72 · score 0.57 · individual ID, sensitivity, interaction, glmmTMB, predictors, rescue behaviour

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 · 1,169 lines · 54 KB · no license · 10 matches

  1. ### Transcriptional predictors of rescue behaviour in ants
  2. ### Jaimes-Nino, Luisa Maria1, Bar, Adi2, Scharf, Inon2, Foitzik, Susanne1
  3. ### 1 Institute of Organismic and Molecular Evolution, Johannes Gutenberg University Mainz, Germany
  4. ### 2 School of Zoology, George S Wise Faculty of Life Sciences, Tel Aviv University, Tel Aviv, Israel
  5. #### Brain size rescuers vs non-rescuers ####
  6. library(glmmTMB)
  7. library(emmeans)
  8. library(DHARMa)
  9. library(openxlsx)
  10. library(ggplot2)
  11. library(ggbeeswarm)
  12. library(patchwork)
  13. size_rescue<- read.xlsx("~/Documents/04_Catag_rescue/MS_rescue/New_subm/JExpBio/Revision_JExpB_rescue/Supl_material_File2.xlsx", sheet = 2)
  14. ggplot(data=size_rescue, aes(x=LengthB, y =WidthB, color = Rescue))+
  15. geom_point()+
  16. geom_smooth(method=lm)+
  17. ylab("Width (mm)")+
  18. xlab("Length (mm)")+
  19. scale_color_manual(values=c("blue3", "red3"))+
  20. theme_minimal()
  21. sizeL.model <- glmmTMB(data = size_rescue, LengthB ~ Rescue + (1|Individual_id))
  22. sizeL.model.wo <- glmmTMB(data = size_rescue, LengthB ~ 1 + (1|Individual_id))
  23. summary(sizeL.model)
  24. car::Anova(sizeL.model, type = "III")
  25. anova(sizeL.model, sizeL.model.wo )
  26. ##### Sensitivity analysis#####
  27. HR_track<- read.xlsx("~/Documents/04_Catag_rescue/MS_rescue/New_subm/JExpBio/Revision_JExpB_rescue/Supl_material_File2.xlsx", sheet = 6)
  28. HR_track$Average_Speed <- as.numeric(HR_track$Average_Speed)
  29. HR_track$Average_Speed_i<- as.numeric(HR_track$Average_Speed_i)
  30. HR_track$Average_Speed_o<- as.numeric(HR_track$Average_Speed_o)
  31. table(HR_track$Resolution, HR_track$Rescue)
  32. HR_track$ID <- paste(HR_track$Video, HR_track$Individual, sep = "_")
  33. speed_o_lm <- glmmTMB(data= HR_track, log(Average_Speed_o) ~ Resolution * Rescue + (1|ID))
  34. speed_o_lm_woint <- glmmTMB(data= HR_track, log(Average_Speed_o) ~ Resolution + Rescue + (1|ID))
  35. anova(speed_o_lm_woint, speed_o_lm) #Testing interaction term
  36. # Data: HR_track
  37. # Models:
  38. # speed_o_lm_woint: log(Average_Speed_o) ~ Resolution + Rescue + (1 | ID), zi=~0, disp=~1
  39. # speed_o_lm: log(Average_Speed_o) ~ Resolution * Rescue + (1 | ID), zi=~0, disp=~1
  40. # Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq)
  41. # speed_o_lm_woint 5 70.560 79.481 -30.280 60.560
  42. # speed_o_lm 6 70.987 81.692 -29.494 58.987 1.5733 1 0.2097
  43. speed_o_lm_woRes <- glmmTMB(data= HR_track, log(Average_Speed_o) ~ Resolution + (1|ID))
  44. anova(speed_o_lm_woint, speed_o_lm_woRes) # Testing Rescue
  45. # Data: HR_track
  46. # Models:
  47. # speed_o_lm_woRes: log(Average_Speed_o) ~ Resolution + (1 | ID), zi=~0, disp=~1
  48. # speed_o_lm_woint: log(Average_Speed_o) ~ Resolution + Rescue + (1 | ID), zi=~0, disp=~1
  49. # Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq)
  50. # speed_o_lm_woRes 4 79.903 87.040 -35.951 71.903
  51. # speed_o_lm_woint 5 70.560 79.481 -30.280 60.560 11.343 1 0.0007575 ***
  52. speed_o_lm_woReso <- glmmTMB(data= HR_track, log(Average_Speed_o) ~ Rescue + (1|ID))
  53. anova(speed_o_lm_woint, speed_o_lm_woReso) # Testing Resolution
  54. # Data: HR_track
  55. # Models:
  56. # speed_o_lm_woReso: log(Average_Speed_o) ~ Rescue + (1 | ID), zi=~0, disp=~1
  57. # speed_o_lm_woint: log(Average_Speed_o) ~ Resolution + Rescue + (1 | ID), zi=~0, disp=~1
  58. # Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq)
  59. # speed_o_lm_woReso 4 72.896 80.033 -32.448 64.896
  60. # speed_o_lm_woint 5 70.560 79.481 -30.280 60.560 4.336 1 0.03731 *
  61. # Estimated marginal means
  62. emm.resc <- emmeans(speed_o_lm_woint, ~ Resolution , type = "response")
  63. # Resolution response SE df asymp.LCL asymp.UCL
  64. # HR 1.163 0.1670 Inf 0.878 1.541
  65. # LR 0.816 0.0711 Inf 0.688 0.968
  66. # Resolution Rescue response SE df asymp.LCL asymp.UCL
  67. # HR No 1.534 0.2520 Inf 1.111 2.116
  68. # LR No 1.076 0.1370 Inf 0.839 1.380
  69. # HR Yes 0.882 0.1410 Inf 0.644 1.207
  70. # LR Yes 0.619 0.0634 Inf 0.506 0.756
  71. simulateResiduals(speed_o_lm_woint, plot = T)
  72. summary(speed_o_lm_woint)
  73. HR_track$xpos <- interaction(HR_track$Resolution, HR_track$Rescue,
  74. sep = "_")
  75. HR_track$xpos <- factor(HR_track$xpos , levels = c("HR_No", "HR_Yes", "LR_No", "LR_Yes"))
  76. Resol_outer <- ggplot(HR_track, aes(x = xpos, y = log(Average_Speed_o), colour = Rescue)) +
  77. geom_beeswarm() +
  78. theme_minimal()+
  79. stat_summary(fun.y= median, fun.ymin=median, fun.ymax=median, geom="crossbar", width=0.3, linewidth =0.3)+
  80. #annotate("text", color = "black",label = "n.s", x = 1.45, y = 1.65) +
  81. scale_color_manual(values=c("blue3", "red3"))+
  82. theme_classic()+
  83. ylab("log (Average speed outer circle)")+
  84. xlab("Video resolution and Rescue")+
  85. theme(legend.position="none",
  86. legend.text=element_text(size=12),
  87. axis.title = element_text(size = 12),
  88. axis.text = element_text(size = 12))
  89. Resol_in <- ggplot(HR_track, aes(x = xpos, y = log(Average_Speed_i), colour = Rescue)) +
  90. geom_beeswarm() +
  91. scale_color_manual(values = c("blue3", "red3")) +
  92. theme_minimal()+
  93. stat_summary(fun.y= median, fun.ymin=median, fun.ymax=median, geom="crossbar", width=0.3, linewidth =0.3)+
  94. #annotate("text", color = "black",label = "n.s", x = 1.45, y = 1.65) +
  95. scale_color_manual(values=c("blue3", "red3"))+
  96. theme_classic()+
  97. ylab("log (Average speed inner circle)")+
  98. xlab("Video resolution and Rescue")+
  99. theme(legend.position="none",
  100. legend.text=element_text(size=12),
  101. axis.title = element_text(size = 12),
  102. axis.text = element_text(size = 12))
  103. speed_i_lm <- glmmTMB(data= HR_track, log(Average_Speed_i) ~ Resolution * Rescue + (1|ID))
  104. speed_i_lm_wo <- glmmTMB(data= HR_track, log(Average_Speed_i) ~ Resolution + Rescue + (1|ID))
  105. anova(speed_i_lm_wo, speed_i_lm)
  106. # Data: HR_track
  107. # Models:
  108. # speed_i_lm_wo: log(Average_Speed_i) ~ Resolution + Rescue + (1 | ID), zi=~0, disp=~1
  109. # speed_i_lm: log(Average_Speed_i) ~ Resolution * Rescue + (1 | ID), zi=~0, disp=~1
  110. # Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq)
  111. # speed_i_lm_wo 5 76.712 84.767 -33.356 66.712
  112. # speed_i_lm 6 77.810 87.475 -32.905 65.810 0.9023 1 0.3422
  113. simulateResiduals(speed_i_lm_wo, plot = T)
  114. speed_i_lm_wo_Resc <- glmmTMB(data= HR_track, log(Average_Speed_i) ~ Resolution + (1|ID))
  115. anova(speed_i_lm_wo, speed_i_lm_wo_Resc)
  116. # Data: HR_track
  117. # Models:
  118. # speed_i_lm_wo_Resc: log(Average_Speed_i) ~ Resolution + (1 | ID), zi=~0, disp=~1
  119. # speed_i_lm_wo: log(Average_Speed_i) ~ Resolution + Rescue + (1 | ID), zi=~0, disp=~1
  120. # Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq)
  121. # speed_i_lm_wo_Resc 4 80.911 87.355 -36.455 72.911
  122. # speed_i_lm_wo 5 76.712 84.767 -33.356 66.712 6.1989 1 0.01278 *
  123. speed_i_lm_wo_Resol <- glmmTMB(data= HR_track, log(Average_Speed_i) ~ Rescue + (1|ID))
  124. anova(speed_i_lm_wo, speed_i_lm_wo_Resol)
  125. # Data: HR_track
  126. # Models:
  127. # speed_i_lm_wo_Resol: log(Average_Speed_i) ~ Rescue + (1 | ID), zi=~0, disp=~1
  128. # speed_i_lm_wo: log(Average_Speed_i) ~ Resolution + Rescue + (1 | ID), zi=~0, disp=~1
  129. # Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq)
  130. # speed_i_lm_wo_Resol 4 81.222 87.666 -36.611 73.222
  131. # speed_i_lm_wo 5 76.712 84.767 -33.356 66.712 6.5106 1 0.01072 *
  132. summary(speed_i_lm)
  133. # Estimated marginal means
  134. emm.resc <- emmeans(speed_i_lm, ~ Resolution * Rescue, type = "response")
  135. # Resolution Rescue response SE df asymp.LCL asymp.UCL
  136. # HR No 1.018 0.2840 Inf 0.589 1.759
  137. # LR No 0.735 0.1760 Inf 0.460 1.177
  138. # HR Yes 0.618 0.1270 Inf 0.413 0.924
  139. # LR Yes 0.334 0.0492 Inf 0.250 0.446
  140. # Average speed
  141. HR_track$Rescue <- factor(HR_track$Rescue, levels=c("Yes", "No"))
  142. speed_lm <- glmmTMB(data= HR_track, log(Average_Speed) ~ Resolution * Rescue + (1|ID))
  143. speed_lm_wo <- glmmTMB(data= HR_track, log(Average_Speed) ~ Resolution + Rescue + (1|ID))
  144. anova(speed_lm_wo,speed_lm)
  145. # Data: HR_track
  146. # Models:
  147. # speed_lm_wo: log(Average_Speed) ~ Resolution + Rescue + (1 | ID), zi=~0, disp=~1
  148. # speed_lm: log(Average_Speed) ~ Resolution * Rescue + (1 | ID), zi=~0, disp=~1
  149. # Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq)
  150. # speed_lm_wo 5 36.722 45.972 -13.361 26.722
  151. # speed_lm 6 37.221 48.322 -12.611 25.221 1.5005 1 0.2206
  152. speed_lm_wo_Resc <- glmmTMB(data= HR_track, log(Average_Speed) ~ Resolution + (1|ID))
  153. anova(speed_lm_wo, speed_lm_wo_Resc) # Testing Rescue
  154. # Data: HR_track
  155. # Models:
  156. # speed_lm_wo_Resc: log(Average_Speed) ~ Resolution + (1 | ID), zi=~0, disp=~1
  157. # speed_lm_wo: log(Average_Speed) ~ Resolution + Rescue + (1 | ID), zi=~0, disp=~1
  158. # Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq)
  159. # speed_lm_wo_Resc 4 34.750 42.150 -13.375 26.750
  160. # speed_lm_wo 5 36.722 45.972 -13.361 26.722 0.0279 1 0.8672
  161. speed_lm_wo_Resol <- glmmTMB(data= HR_track, log(Average_Speed) ~ Rescue + (1|ID))
  162. anova(speed_lm_wo, speed_lm_wo_Resol) # Testing Resolution
  163. # Data: HR_track
  164. # Models:
  165. # speed_lm_wo_Resol: log(Average_Speed) ~ Rescue + (1 | ID), zi=~0, disp=~1
  166. # speed_lm_wo: log(Average_Speed) ~ Resolution + Rescue + (1 | ID), zi=~0, disp=~1
  167. # Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq)
  168. # speed_lm_wo_Resol 4 49.707 57.108 -20.854 41.707
  169. # speed_lm_wo 5 36.722 45.972 -13.361 26.722 14.986 1 0.0001083 ***
  170. emm.resc <- emmeans(speed_lm_wo, ~ Resolution , type = "response")
  171. # Resolution response SE df asymp.LCL asymp.UCL
  172. # HR 1.20 0.0934 Inf 1.030 1.398
  173. # LR 0.88 0.0563 Inf 0.777 0.998
  174. Resol_general <- ggplot(HR_track, aes(x = xpos, y = log(Average_Speed), colour = Rescue)) +
  175. geom_beeswarm() +
  176. scale_color_manual(values = c("blue3", "red3")) +
  177. theme_minimal()+
  178. stat_summary(fun.y= median, fun.ymin=median, fun.ymax=median, geom="crossbar", width=0.3, linewidth =0.3)+
  179. #annotate("text", color = "black",label = "n.s", x = 1.45, y = 1.65) +
  180. scale_color_manual(values=c("blue3", "red3"))+
  181. theme_classic()+
  182. ylab("log (Average speed)")+
  183. xlab("Video resolution and Rescue")+
  184. theme(legend.position="none",
  185. legend.text=element_text(size=12),
  186. axis.title = element_text(size = 12),
  187. axis.text = element_text(size = 12))
  188. simulateResiduals(speed_lm_wo, plot = T)
  189. summary(speed_lm_wo)
  190. Resol_general + Resol_outer + Resol_in + plot_annotation(tag_levels = 'A')
  191. library(sjPlot)
  192. library(sjmisc)
  193. plot_model(speed_o_lm, type = "pred", terms = c("Resolution", "Rescue"))
  194. emm.resc <- emmeans(speed_lm_wo, ~ Resolution * Rescue, type = "response")
  195. # Resolution Rescue response SE df asymp.LCL asymp.UCL
  196. # HR No 1.266 0.1290 Inf 1.036 1.55
  197. # LR No 0.868 0.0835 Inf 0.719 1.05
  198. # HR Yes 1.297 0.1220 Inf 1.079 1.56
  199. # LR Yes 0.890 0.0764 Inf 0.752 1.05
  200. pairs(emm.resc, by = "Resolution")
  201. #### General tracking analysis ####
  202. library(patchwork)
  203. library(ggplot2)
  204. library(ggbeeswarm)
  205. library(dplyr)
  206. general_track<- read.xlsx("~/Documents/04_Catag_rescue/MS_rescue/New_subm/JExpBio/Revision_JExpB_rescue/Supl_material_File_2.xlsx", sheet = 4)
  207. gen_rescuers <- subset(general_track, Rescue == "Yes")
  208. gen_nonrescuers <- subset(general_track, Rescue == "No")
  209. gen_rescue_track <- rbind(gen_rescuers, gen_nonrescuers)
  210. gen_rescue_track$Average_Speed <- as.numeric(gen_rescue_track$Average_Speed)
  211. gen_plotA <- ggplot(data=gen_rescue_track, aes(x=Rescue, y=Average_Speed, color = Rescue))+
  212. geom_beeswarm(priority = "none")+
  213. stat_summary(fun.y= mean, fun.ymin=mean, fun.ymax=mean, geom="crossbar", width=0.3, linewidth =0.3)+
  214. annotate("text", color = "black",label = "n.s", x = 1.45, y = 1.65) +
  215. scale_color_manual(values=c("blue3", "red3"))+
  216. theme_classic()+
  217. ylab("Speed (cm/sec)")+
  218. xlab("Rescue")+
  219. theme(legend.position="none")
  220. speed_gen_lm <- glmmTMB(data= gen_rescue_track, Average_Speed ~ Rescue + (1|Video))
  221. simulateResiduals(speed_gen_lm, plot = T)
  222. summary(speed_gen_lm)
  223. # Family: gaussian ( identity )
  224. # Formula: Average_Speed ~ Rescue + (1 | Video)
  225. # Data: gen_rescue_track
  226. #
  227. # AIC BIC logLik -2*log(L) df.resid
  228. # 26.6 32.9 -9.3 18.6 31
  229. #
  230. # Random effects:
  231. #
  232. # Conditional model:
  233. # Groups Name Variance Std.Dev.
  234. # Video (Intercept) 0.03561 0.1887
  235. # Residual 0.07880 0.2807
  236. # Number of obs: 35, groups: Video, 7
  237. #
  238. # Dispersion estimate for gaussian family (sigma^2): 0.0788
  239. #
  240. # Conditional model:
  241. # Estimate Std. Error z value Pr(>|z|)
  242. # (Intercept) 0.93005 0.10361 8.977 <2e-16 ***
  243. # RescueYes 0.01454 0.09967 0.146 0.884
  244. speed_gen_lm_wo <- glmmTMB(data= gen_rescue_track, Average_Speed ~ 1 + (1|Video))
  245. anova(speed_gen_lm, speed_gen_lm_wo)
  246. # Data: gen_rescue_track
  247. # Models:
  248. # speed_gen_lm_wo: Average_Speed ~ 1 + (1 | Video), zi=~0, disp=~1
  249. # speed_gen_lm: Average_Speed ~ Rescue + (1 | Video), zi=~0, disp=~1
  250. # Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq)
  251. # speed_gen_lm_wo 3 24.652 29.318 -9.3260 18.652
  252. # speed_gen_lm 4 26.631 32.852 -9.3154 18.631 0.0213 1 0.884
  253. circle_track<- read.xlsx("~/Documents/04_Catag_rescue/MS_rescue/New_subm/JExpBio/Revision_JExpB_rescue/Supl_material_File2.xlsx", sheet = 5)
  254. colnames(circle_track)
  255. rescuers <- subset(circle_track, Rescue == "Yes")
  256. nonrescuers <- subset(circle_track, Rescue == "No")
  257. rescue_track <- rbind(rescuers, nonrescuers)
  258. rescue_track$Latency_i<- as.numeric(rescue_track$Latency_i)
  259. rescue_track$Latency_o<- as.numeric(rescue_track$Latency_o)
  260. rescue_track$Average_Speed_i<- as.numeric(rescue_track$Average_Speed_i)
  261. rescue_track$Average_Speed_o<- as.numeric(rescue_track$Average_Speed_o)
  262. table( rescue_track$Rescue)
  263. #rescue_track$Rescue <- factor(rescue_track$Rescue, levels = c("Yes", "No"))
  264. inner_plot <- ggplot(data=rescue_track, aes(x=Rescue, y=Average_Speed_i, colour = Rescue))+
  265. geom_beeswarm(priority = "none")+
  266. stat_summary(fun.y= mean, fun.ymin=mean, fun.ymax=mean, geom="crossbar", width=0.3, linewidth =0.3)+
  267. scale_color_manual(values=c("blue3", "red3"))+
  268. theme_classic()+
  269. annotate("text", color = "black",label = "**", x = 1.45, y = 3, size = 7) +
  270. ylab("Speed inner circle (cm/sec)")+
  271. xlab("Rescue")+
  272. theme(legend.position="none")
  273. speed_i_lm <- glmmTMB(data= rescue_track, log(Average_Speed_i) ~ Rescue + (1|Video))
  274. simulateResiduals(speed_i_lm, plot = T)
  275. summary(speed_i_lm)
  276. # Family: gaussian ( identity )
  277. # Formula: log(Average_Speed_i) ~ Rescue + (1 | Video)
  278. # Data: rescue_track
  279. #
  280. # AIC BIC logLik -2*log(L) df.resid
  281. # 48.0 53.2 -20.0 40.0 23
  282. # Random effects:
  283. #
  284. # Conditional model:
  285. # Groups Name Variance Std.Dev.
  286. # Video (Intercept) 0.3268 0.5717
  287. # Residual 0.1430 0.3782
  288. # Number of obs: 27, groups: Video, 7
  289. #
  290. # Dispersion estimate for gaussian family (sigma^2): 0.143
  291. #
  292. # Conditional model:
  293. # Estimate Std. Error z value Pr(>|z|)
  294. # (Intercept) -0.5094 0.2649 -1.923 0.05446 .
  295. # RescueYes -0.5776 0.1776 -3.252 0.00114 **
  296. speed_i_lm_wo <- glmmTMB(data= rescue_track, log(Average_Speed_i) ~ 1 + (1|Video))
  297. anova(speed_i_lm, speed_i_lm_wo)
  298. # Data: rescue_track
  299. # Models:
  300. # speed_i_lm_wo: log(Average_Speed_i) ~ 1 + (1 | Video), zi=~0, disp=~1
  301. # speed_i_lm: log(Average_Speed_i) ~ Rescue + (1 | Video), zi=~0, disp=~1
  302. # Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq)
  303. # speed_i_lm_wo 3 54.751 58.639 -24.376 48.751
  304. # speed_i_lm 4 47.970 53.153 -19.985 39.970 8.7817 1 0.003043 **
  305. outer_plot <- ggplot(data=rescue_track, aes(x=Rescue, y=Average_Speed_o, colour = Rescue))+
  306. geom_beeswarm(priority = "none")+
  307. stat_summary(fun.y= mean, fun.ymin=mean, fun.ymax=mean, geom="crossbar", width=0.3, linewidth =0.3)+
  308. annotate("text", color = "black",label = "***", x = 1.45, y = 3, size = 7) +
  309. scale_color_manual(values=c("blue3", "red3"))+
  310. theme_classic()+
  311. ylab("Speed outer circle (cm/sec)")+
  312. xlab("Rescue")+
  313. theme(legend.position="none")
  314. speed_o_lm <- glmmTMB(data= rescue_track, log(Average_Speed_o) ~ Rescue + (1|Video))
  315. simulateResiduals(speed_o_lm, plot = T)
  316. summary(speed_o_lm)
  317. # Family: gaussian ( identity )
  318. # Formula: log(Average_Speed_o) ~ Rescue + (1 | Video)
  319. # Data: rescue_track
  320. #
  321. # AIC BIC logLik -2*log(L) df.resid
  322. # 52.5 58.2 -22.3 44.5 27
  323. #
  324. # Random effects:
  325. #
  326. # Conditional model:
  327. # Groups Name Variance Std.Dev.
  328. # Video (Intercept) 0.06873 0.2622
  329. # Residual 0.19971 0.4469
  330. # Number of obs: 31, groups: Video, 7
  331. #
  332. # Dispersion estimate for gaussian family (sigma^2): 0.2
  333. #
  334. # Conditional model:
  335. # Estimate Std. Error z value Pr(>|z|)
  336. # (Intercept) 0.1223 0.1726 0.709 0.478
  337. # RescueYes -0.6902 0.1773 -3.893 9.88e-05 ***
  338. coefficients(speed_o_lm)
  339. exp(0.2329)
  340. exp(-0.6902)
  341. speed_o_lm_wo <- glmmTMB(data= rescue_track, log(Average_Speed_o) ~ 1 + (1|Video))
  342. anova(speed_o_lm, speed_o_lm_wo)
  343. # Data: rescue_track
  344. # Models:
  345. # speed_o_lm_wo: log(Average_Speed_o) ~ 1 + (1 | Video), zi=~0, disp=~1
  346. # speed_o_lm: log(Average_Speed_o) ~ Rescue + (1 | Video), zi=~0, disp=~1
  347. # Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq)
  348. # speed_o_lm_wo 3 63.059 67.361 -28.529 57.059
  349. # speed_o_lm 4 52.503 58.239 -22.251 44.503 12.556 1 0.0003949 ***
  350. speed_plotC <- gen_plotA+ outer_plot + inner_plot + plot_annotation(tag_levels = 'A')
  351. inner_plot <- ggplot(data=rescue_track, aes(x=Rescue, y=Exploration_relative_value_i, colour = Rescue))+
  352. geom_beeswarm(priority = "none")+
  353. stat_summary(fun.y= mean, fun.ymin=mean, fun.ymax=mean, geom="crossbar", width=0.3, linewidth =0.3)+
  354. scale_color_manual(values=c("blue3", "red3"))+
  355. annotate("text", color = "black",label = "***", x = 1.45, y = 1, size = 7) +
  356. theme_classic()+
  357. ylab("Relative exploration inner circle")+
  358. xlab("Rescue")+
  359. theme(legend.position="none")
  360. explor_i_lm <- glmmTMB(data= rescue_track, Exploration_relative_value_i ~ Rescue + (1|Video))
  361. simulateResiduals(explor_i_lm, plot = T)
  362. summary(explor_i_lm)
  363. # Conditional model:
  364. # Estimate Std. Error z value Pr(>|z|)
  365. # (Intercept) 0.30077 0.07447 4.039 5.38e-05 ***
  366. # RescueYes 0.48710 0.08848 5.505 3.68e-08 ***
  367. explor_i_lm_wo <- glmmTMB(data= rescue_track, Exploration_relative_value_i ~ 1 + (1|Video))
  368. anova(explor_i_lm, explor_i_lm_wo)
  369. # Data: rescue_track
  370. # Models:
  371. # explor_i_lm_wo: Exploration_relative_value_i ~ 1 + (1 | Video), zi=~0, disp=~1
  372. # explor_i_lm: Exploration_relative_value_i ~ Rescue + (1 | Video), zi=~0, disp=~1
  373. # Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq)
  374. # explor_i_lm_wo 3 34.014 38.680 -14.007 28.014
  375. # explor_i_lm 4 14.640 20.861 -3.320 6.640 21.374 1 3.778e-06 ***
  376. table(rescue_track$Rescue)
  377. outer_plot <- ggplot(data=rescue_track, aes(x=Rescue, y=Exploration_relative_value_o, colour = Rescue))+
  378. geom_beeswarm(priority = "none")+
  379. stat_summary(fun.y= mean, fun.ymin=mean, fun.ymax=mean, geom="crossbar", width=0.3, linewidth =0.3)+
  380. scale_color_manual(values=c("blue3", "red3"))+
  381. theme_classic()+
  382. annotate("text", color = "black",label = "**", x = 1.45, y = 1, size = 7) +
  383. ylab("Relative exploration outer circle")+
  384. xlab("Rescue")+
  385. theme(legend.position="none")
  386. explor_o_lm <- glmmTMB(data= rescue_track, Exploration_relative_value_o ~ Rescue + (1|Video))
  387. simulateResiduals(explor_o_lm, plot = T)
  388. summary(explor_o_lm)
  389. # Conditional model:
  390. # Estimate Std. Error z value Pr(>|z|)
  391. # (Intercept) 0.31087 0.08519 3.649 0.000263 ***
  392. # RescueYes 0.23932 0.08581 2.789 0.005285 **
  393. explor_o_lm_wo <- glmmTMB(data= rescue_track, Exploration_relative_value_o ~ 1 + (1|Video))
  394. anova(explor_o_lm, explor_o_lm_wo)
  395. # Data: rescue_track
  396. # Models:
  397. # explor_o_lm_wo: Exploration_relative_value_o ~ 1 + (1 | Video), zi=~0, disp=~1
  398. # explor_o_lm: Exploration_relative_value_o ~ Rescue + (1 | Video), zi=~0, disp=~1
  399. # Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq)
  400. # explor_o_lm_wo 3 20.172 24.838 -7.0861 14.172
  401. # explor_o_lm 4 15.302 21.523 -3.6510 7.302 6.8703 1 0.008764 **
  402. generalExpl_plot <- ggplot(data=gen_rescue_track, aes(x=Rescue, y=Exploration_relative_value, colour = Rescue))+
  403. geom_beeswarm(priority = "none")+
  404. stat_summary(fun.y= mean, fun.ymin=mean, fun.ymax=mean, geom="crossbar", width=0.3, linewidth =0.3)+
  405. scale_color_manual(values=c("blue3", "red3"))+
  406. theme_classic()+
  407. annotate("text", color = "black",label = "n.s", x = 1.45, y = 1) +
  408. ylab("Relative exploration arena")+
  409. xlab("Rescue")+
  410. theme(legend.position="none")
  411. explor_lm <- glmmTMB(data= gen_rescue_track, Exploration_relative_value ~ Rescue + (1|Video))
  412. simulateResiduals(explor_lm, plot = T)
  413. summary(explor_lm)
  414. # Conditional model:
  415. # Estimate Std. Error z value Pr(>|z|)
  416. # (Intercept) 0.41451 0.06695 6.191 5.97e-10 ***
  417. # RescueYes 0.03151 0.06690 0.471 0.638
  418. explor_lm_wo <- glmmTMB(data= gen_rescue_track, Exploration_relative_value ~ 1 + (1|Video))
  419. anova(explor_lm, explor_lm_wo)
  420. # Data: gen_rescue_track
  421. # Models:
  422. # explor_lm_wo: Exploration_relative_value ~ 1 + (1 | Video), zi=~0, disp=~1
  423. # explor_lm: Exploration_relative_value ~ Rescue + (1 | Video), zi=~0, disp=~1
  424. # Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq)
  425. # explor_lm_wo 3 -3.8369 0.8292 4.9184 -9.8369
  426. # explor_lm 4 -2.0586 4.1628 5.0293 -10.0586 0.2218 1 0.6377
  427. Exploration_plot_D <- generalExpl_plot + outer_plot + inner_plot + plot_annotation(tag_levels = 'A')
  428. inner_lat_plot <- ggplot(data=rescue_track, aes(x=Rescue, y=Latency_i, colour = Rescue))+
  429. geom_beeswarm(priority = "none")+
  430. stat_summary(fun.y= mean, fun.ymin=mean, fun.ymax=mean, geom="crossbar", width=0.3, linewidth =0.3)+
  431. scale_color_manual(values=c("blue3", "red3"))+
  432. annotate("text", color = "black",label = "**", x = 1.45, y = 850, size = 7) +
  433. theme_classic()+
  434. ylab("Latency to reach inner circle (s)")+
  435. xlab("Rescue")+
  436. theme(legend.position="none")
  437. latenc_i_lm <- glmmTMB(data= rescue_track, Latency_i ~ Rescue + (1|Video))
  438. simulateResiduals(latenc_i_lm, plot = T)
  439. summary(latenc_i_lm)
  440. # Conditional model:
  441. # Estimate Std. Error z value Pr(>|z|)
  442. # (Intercept) 594.66 89.15 6.671 2.55e-11 ***
  443. # RescueYes -254.03 90.10 -2.819 0.00481 **
  444. latenc_i_lm_wo <- glmmTMB(data= rescue_track, Latency_i ~ 1 + (1|Video))
  445. anova(latenc_i_lm, latenc_i_lm_wo)
  446. # Data: rescue_track
  447. # Models:
  448. # latenc_i_lm_wo: Latency_i ~ 1 + (1 | Video), zi=~0, disp=~1
  449. # latenc_i_lm: Latency_i ~ Rescue + (1 | Video), zi=~0, disp=~1
  450. # Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq)
  451. # latenc_i_lm_wo 3 379.91 383.80 -186.96 373.91
  452. # latenc_i_lm 4 375.33 380.52 -183.67 367.33 6.5789 1 0.01032 *
  453. outer_lat_plot <- ggplot(data=rescue_track, aes(x=Rescue, y=Latency_o, colour = Rescue))+
  454. geom_beeswarm(priority = "none")+
  455. stat_summary(fun.y= mean, fun.ymin=mean, fun.ymax=mean, geom="crossbar", width=0.3, linewidth =0.3)+
  456. scale_color_manual(values=c("blue3", "red3"))+
  457. annotate("text", color = "black",label = "**", x = 1.45, y = 850, size = 7) +
  458. theme_classic()+
  459. ylab("Latency to reach outer circle (s)")+
  460. xlab("Rescue")+
  461. theme(legend.position="none")
  462. latenc_o_lm <- glmmTMB(data= rescue_track, Latency_o ~ Rescue + (1|Video))
  463. simulateResiduals(latenc_o_lm, plot = T)
  464. summary(latenc_o_lm)
  465. # Conditional model:
  466. # Estimate Std. Error z value Pr(>|z|)
  467. # (Intercept) 484.45 75.43 6.422 1.34e-10 ***
  468. # RescueYes -189.42 72.78 -2.603 0.00925 **
  469. inner_lat_plot + outer_lat_plot
  470. latenc_o_lm_wo <- glmmTMB(data= rescue_track, Latency_o ~ 1 + (1|Video))
  471. anova(latenc_o_lm, latenc_o_lm_wo)
  472. # Data: rescue_track
  473. # Models:
  474. # latenc_o_lm_wo: Latency_o ~ 1 + (1 | Video), zi=~0, disp=~1
  475. # latenc_o_lm: Latency_o ~ Rescue + (1 | Video), zi=~0, disp=~1
  476. # Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq)
  477. # latenc_o_lm_wo 3 431.25 435.55 -212.62 425.25
  478. # latenc_o_lm 4 427.30 433.04 -209.65 419.30 5.9477 1 0.01474 *
  479. gen_rescue_track<- gen_rescue_track %>%
  480. mutate(across(c(3:14), as.numeric))
  481. travDist_plot <- ggplot(data=gen_rescue_track, aes(x=Rescue, y=Traveled_Dist, colour = Rescue))+
  482. geom_beeswarm(priority = "none")+
  483. stat_summary(fun.y= mean, fun.ymin=mean, fun.ymax=mean, geom="crossbar", width=0.3, linewidth =0.3)+
  484. scale_color_manual(values=c("blue3", "red3"))+
  485. annotate("text", color = "black",label = "n.s", x = 1.45, y = 1150) +
  486. theme_classic()+
  487. ylab("Travelled distance (cm)")+
  488. xlab("Rescue")+
  489. theme(legend.position="none")
  490. dist_lm <- glmmTMB(data= gen_rescue_track, log(Traveled_Dist) ~ Rescue + (1|Video))
  491. simulateResiduals(dist_lm, plot = T)
  492. summary(dist_lm)
  493. # Conditional model:
  494. # Intercept) 4.9692 0.2533 19.619 <2e-16 ***
  495. # RescueYes 0.1112 0.3078 0.361 0.718
  496. ((generalExpl_plot + outer_plot + inner_plot) /
  497. (travDist_plot + outer_lat_plot + inner_lat_plot ) )+ plot_annotation(tag_levels = 'A')
  498. dist_lm_wo <- glmmTMB(data= gen_rescue_track, log(Traveled_Dist) ~ 1 + (1|Video))
  499. simulateResiduals(dist_lm, plot = T)
  500. anova(dist_lm, dist_lm_wo)
  501. # Data: gen_rescue_track
  502. # Models:
  503. # dist_lm_wo: log(Traveled_Dist) ~ 1 + (1 | Video), zi=~0, disp=~1
  504. # dist_lm: log(Traveled_Dist) ~ Rescue + (1 | Video), zi=~0, disp=~1
  505. # Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq)
  506. # dist_lm_wo 3 99.291 103.96 -46.645 93.291
  507. # dist_lm 4 101.160 107.38 -46.580 93.160 0.1305 1 0.7179
  508. ######################## GOterms #######################
  509. library(openxlsx)
  510. library(ggplot2)
  511. library(Rgraphviz)
  512. library(topGO)
  513. library("RColorBrewer")
  514. library(tagcloud)
  515. #### MBs rescuers vs non-rescuers ####
  516. MB_up_genes <- as.data.frame(c("gene_3661", "gene_3662", "gene_3426", "gene_1607", "gene_2555", "gene_1243" , "gene_930" , "gene_5298" , "gene_6089", "gene_5245", "gene_13149", "gene_9895", "gene_9900", "gene_8499", "gene_7997"))
  517. colnames(MB_up_genes) <- c("genes")
  518. #### GOterms Upregulated when prone to rescue
  519. #we start with an enrichment analysis
  520. #load the universe reference file you created above using bash
  521. universe <- readMappings("~/Documents/Catagl_cognition/From_Eyal/Cnig_gn3.1.fasta.transcripts.fasta.trinotate.report.topGOinput.txt")
  522. # add newly found annotations:
  523. universe$gene_3426 <- c("GO:0008061", "GO:0005576")
  524. universe$gene_5298 <- c("GO:0005549")
  525. universe$gene_1607 <- c("GO:0035176","GO:0005549", "GO:0005615")
  526. universe$gene_9900 <- c("GO:0006955","GO:0005164", "GO:0005515", "GO:0016020", "GO:0048018", "GO:0005615")
  527. universe$gene_5301 <- c("GO:0035176","GO:0005549", "GO:0005615")
  528. # generate list of the protein IDs
  529. universe_genelist <- names(universe)
  530. # generate a reference list of the protein IDs
  531. #testset_genelist_idown <- readLines(LD_down_genes)
  532. #determine matches between both datasets
  533. gene_list_iup <- factor(as.integer(universe_genelist %in% MB_up_genes$genes))
  534. names(gene_list_iup) <- universe_genelist
  535. #set the ontology type you want to investigate, we first choose "Biological Processes"=BP, '93Cellular Components'94=CC, '93Molecular Function'94=MF
  536. ontology_type = "BP" # or CC or MF
  537. GO_data_iup <- new("topGOdata", description="GO_Enrichment", ontology=ontology_type, allGenes=gene_list_iup, annot = annFUN.gene2GO, gene2GO=universe)
  538. result_topGO_w01_iup <- runTest(GO_data_iup, algorithm = "weight01", statistic = "fisher")
  539. result_table_w01_iup_BP <- GenTable(GO_data_iup, Fisher = result_topGO_w01_iup, orderBy = "Fisher", ranksOf = "Fisher", topNodes = numSigGenes(GO_data_iup))
  540. result_table_w01_iup_BP
  541. #### Graphics ####
  542. result_table_w01_iup_BP_sig <- result_table_w01_iup_BP[which(result_table_w01_iup_BP$Fisher<0.05),]
  543. setwd("~/Documents/Catag_rescue/")
  544. #write.csv(result_table_w01_idown_BP_sig, file=paste0("topGO_result_weight01_significant_OL_Corrprop_BP_down_cooks.csv")
  545. colors <- colorRampPalette( brewer.pal( 12, "Paired" ) )( length(result_table_w01_iup_BP_sig$Term))
  546. #Create the tag cloud
  547. tagcloud(strmultline(result_table_w01_iup_BP_sig$Term), weights = - log(as.numeric(result_table_w01_iup_BP_sig$Fisher)),col=colors)
  548. ## DESeq2 - mRNA sequencing data from Cat niger. 7 samples of rescuers and non-rescuers. The brain tissue was sequenced by separating the optic lobes (OL), the mushroom bodies (MB), the rest of the brain tissue including antennal lobes and central complex (CC), and the antennae (AA).
  549. tissues <- read.xlsx("~/Documents/Catag_rescue/Sequencing_rescue/Gene_counts/Rescue_rawcounts_perGene.xlsx", colNames = T)
  550. tissue_counts <- tissues[-c(1:4),]
  551. colnames(tissue_counts)[1] <- c("Gene_ID")
  552. rownames(tissue_counts) <- tissue_counts$Gene_ID
  553. tissue_counts <- tissue_counts[,-c(1)]
  554. colnames(tissue_counts)
  555. # [1] "Ant_A_727" "Ant_B_724" "Ant_C_723" "Ant_D_727" "Ant_E_718" "Ant_F_718" "Ant_G_720" "Ant_H_720"
  556. # [9] "Ant_I_723" "Ant_J_724" "Ant_K_725" "Ant_L_725" "Ant_M_726" "Ant_N_726" "CC_A_727" "CC_B_724"
  557. # [17] "CC_C_723" "CC_D_727" "CC_F_718" "CC_G_720" "CC_H_720" "CC_I_723" "CC_J_724" "CC_K_725"
  558. # [25] "CC_L_725" "CC_M_726" "CC_N_726" "MB_A_727" "MB_C_723" "MB_D_727" "MB_E_718" "MB_F_718"
  559. # [33] "MB_G_720" "MB_H_720" "MB_I_723" "MB_J_724" "MB_K_725" "MB_L_725" "MB_M_726" "MB_N_726"
  560. # [41] "OL_A_727" "OL_B_724" "OL_C_723" "OL_E_718" "OL_F_718" "OL_G_720" "OL_H_720" "OL_I_723"
  561. # [49] "OL_J_724" "OL_K_725" "OL_L_725" "OL_M_726" "OL_N_726"
  562. # First check differences among tissues to highlight any outliers, or if the dissection failed.
  563. design_rescue<- read.xlsx("~/Documents/Catag_rescue/Samples_rescue.xlsx", sheet = 6)
  564. head(design_rescue)
  565. # Sample_ID Tissue Pool Colony_ID Rescue
  566. # 1 Ant_A_727 Ant A 727 No
  567. # 2 Ant_B_724 Ant B 724 Yes
  568. # 3 Ant_C_723 Ant C 723 Yes
  569. # 4 Ant_D_727 Ant D 727 Yes
  570. # 5 Ant_E_718 Ant E 718 No
  571. # 6 Ant_F_718 Ant F 718 Yes
  572. design_rescue[,1]
  573. # [1] "Ant_A_727" "Ant_B_724" "Ant_C_723" "Ant_D_727" "Ant_E_718" "Ant_F_718" "Ant_G_720" "Ant_H_720"
  574. # [9] "Ant_I_723" "Ant_J_724" "Ant_K_725" "Ant_L_725" "Ant_M_726" "Ant_N_726" "CC_A_727" "CC_B_724"
  575. # [17] "CC_C_723" "CC_D_727" "CC_F_718" "CC_G_720" "CC_H_720" "CC_I_723" "CC_J_724" "CC_K_725"
  576. # [25] "CC_L_725" "CC_M_726" "CC_N_726" "MB_A_727" "MB_C_723" "MB_D_727" "MB_E_718" "MB_F_718"
  577. # [33] "MB_G_720" "MB_H_720" "MB_I_723" "MB_J_724" "MB_K_725" "MB_L_725" "MB_M_726" "MB_N_726"
  578. # [41] "OL_A_727" "OL_B_724" "OL_C_723" "OL_E_718" "OL_F_718" "OL_G_720" "OL_H_720" "OL_I_723"
  579. # [49] "OL_J_724" "OL_K_725" "OL_L_725" "OL_M_726" "OL_N_726"
  580. design_rescue$Colony_ID <- as.factor(design_rescue$Colony_ID)
  581. design_rescue$Rescue <- as.factor(design_rescue$Rescue)
  582. design_rescue$Tissue <- as.factor(design_rescue$Tissue)
  583. dds_alltissues <- DESeqDataSetFromMatrix(countData = tissue_counts, colData = design_rescue , design = ~ Tissue + Rescue)
  584. # converting counts to integer mode
  585. keep <- rowSums(counts(dds_alltissues) >= 10) >= 6
  586. dds_alltissues <- dds_alltissues[keep,]
  587. # Visualization - let's first have a look at the data in a PCA plot. For this the data need to be transformed, for which several methods are described within the manual. Choose one, e.g. varianceStabilizingTransformation and carry out the command on the dds object. Then run the command plotPCA on the new transformed object, naming the grouping variables with intgroup
  588. dds_vst_allTissues <- varianceStabilizingTransformation(dds_alltissues)
  589. pcaData_allTissues <- plotPCA(dds_vst_allTissues, intgroup = c("Tissue", "Colony_ID"), returnData = T)
  590. # using ntop=500 top features by variance
  591. pca_allTissues <- ggplot(pcaData_allTissues, aes(x = PC1, y = PC2, label =name, color = Tissue,shape =Colony_ID )) +
  592. geom_point(size=3) +
  593. # geom_label_repel(label.size = 0)+
  594. # geom_text(aes(label=name), vjust=3, size=4,nudge_x = 3, nudge_y = 3)+
  595. xlab("PC1: 85% variance")+
  596. ylab("PC2 : 9% variance")+
  597. ggtitle("PCA all Tissues Rescue")+
  598. scale_shape_manual(values = c(0, 5, 10, 14, 1,8,17))+
  599. theme_minimal()+
  600. theme(panel.border = element_blank(),
  601. panel.grid.major = element_blank(),
  602. panel.grid.minor = element_blank(),
  603. axis.line = element_line(colour="black"),
  604. legend.position = "bottom",
  605. legend.text=element_text(size=12),
  606. axis.title = element_text(size = 12),
  607. axis.text = element_text(size = 12))
  608. pca_allTissues
  609. # Wald test in all tissues, but then test one to one each tissue, better all tissues that have DEGs with an LRT test
  610. # dds_alltissues <- DESeq(dds_alltissues)
  611. # Wald_rescue_results <- results(dds_alltissues, contrast = c("Rescue", "Yes", "No"), alpha = 0.05)
  612. # Wald_rescue_results_sig <- subset(Wald_rescue_results , padj < 0.05)
  613. # Wald_rescue_results_sig # DataFrame with
  614. # A reduced model without the rescue variable
  615. dds_allTissue_LTR_rescue <- DESeq(dds_alltissues, test="LRT", full= ~ Tissue + Rescue , reduced = ~Tissue)
  616. LRT_results_allTissue_rescue <- results(dds_allTissue_LTR_rescue)
  617. #write.csv(LRT_results_allTissue_rescue, "DEGs_alltissues.csv")
  618. LRT_results_allTissue_rescue_sig <- subset(LRT_results_allTissue_rescue , padj < 0.05)
  619. LRT_results_allTissue_rescue_sig # DataFrame with 9 rows and 6 columns
  620. as.data.frame(LRT_results_allTissue_rescue_sig)
  621. # baseMean log2FoldChange lfcSE stat pvalue padj
  622. # gene_930 278.50568 2.8281217 0.47015841 27.54054 1.538359e-07 0.001583740
  623. # gene_2555 117.04428 2.7623696 0.53417219 23.27896 1.401249e-06 0.004808619
  624. # gene_5245 2322.00176 1.0977149 0.22555155 22.50527 2.095677e-06 0.005393748
  625. #non-shared with MBs genes
  626. # gene_1997 34.03176 0.7625534 0.17878296 17.96929 2.244977e-05 0.029849548
  627. # gene_13318 789.81013 0.7336380 0.17270608 17.68300 2.609480e-05 0.029849548
  628. # gene_13632 631.05258 -0.2551454 0.05794553 19.29975 1.117209e-05 0.023003325
  629. # gene_14429 450.17155 0.3543307 0.08393271 17.79513 2.460122e-05 0.029849548
  630. # gene_14458 2677.47760 0.5531638 0.10852223 25.92235 3.554297e-07 0.001829574
  631. # gene_7603 95.96581 0.5167914 0.11947306 18.71925 1.514459e-05 0.025985597
  632. LRT_results_allTissue_rescue_sig@rownames
  633. alltissues_genes <- c("gene_1997", "gene_2555", "gene_930", "gene_5245", "gene_13318", "gene_13632", "gene_14429", "gene_14458", "gene_7603")
  634. LRT_results_allTissue_rescue_sig$gene <- rownames(LRT_results_allTissue_rescue_sig)
  635. df_allT <- lapply(LRT_results_allTissue_rescue_sig$gene, (x) {
  636. y <- plotCounts(dds_allTissue_LTR_rescue, returnData=TRUE, x, intgroup = "Rescue")
  637. y$feature <- x
  638. return(y)
  639. })
  640. df_allTs <- do.call(rbind, df_allT)
  641. df_allTs<- df_allTs %>%
  642. group_by(feature) %>%
  643. mutate(y.position=max(count))
  644. padj_allTs <- as.data.frame(LRT_results_allTissue_rescue_sig[[6]])
  645. padj_allTs$feature <- LRT_results_allTissue_rescue_sig[[7]]
  646. padj_allTs$`LRT_results_allTissue_rescue_sig[[6]]` <- lapply(padj_allTs$`LRT_results_allTissue_rescue_sig[[6]]`, signif, digits=3)
  647. large_padj_allTs <- merge(padj_allTs, df_allTs, by = "feature", all= FALSE)
  648. padj_allTs_small <- large_padj_allTs[!duplicated(large_padj_allTs$feature), ]
  649. plot_a_list <- function(master_list_with_plots, no_of_rows, no_of_cols) {
  650. patchwork::wrap_plots(master_list_with_plots,
  651. nrow = no_of_rows, ncol = no_of_cols)
  652. }
  653. # apply seperately for each gene showing the mean
  654. p_allT <- lapply(LRT_results_allTissue_rescue_sig$gene, function(gene) {
  655. ggplot(df_allTs[df_allTs[, "feature"]==gene,]) +
  656. geom_beeswarm(aes(x=Rescue, y=count, color= Rescue),priority = "none")+
  657. stat_summary(aes(x=Rescue, y=count), fun.y= mean, fun.ymin=mean, fun.ymax=mean, geom="crossbar", width=0.3, linewidth =0.3)+
  658. # annotate("text", label= "Padj=", x= 1,y=(padj_MBs_small[match( gene, padj_MBs_small$feature),5]))+
  659. geom_text(data = as.data.frame(padj_allTs_small),
  660. aes(label = (padj_allTs_small[match( gene,feature),2]),
  661. x = 1.45, y = (padj_allTs_small[match( gene, feature),5]))) +
  662. ylab("Normalized count")+
  663. scale_color_manual(values=c("blue3", "red3"))+
  664. theme_classic()+
  665. ggtitle(paste(gene))+
  666. theme(axis.title.y=element_blank(),
  667. legend.position="none")
  668. })
  669. # finally print your plots
  670. plot_a_list(p_allT, 3, 3)
  671. ##### 15 genes in MB, how are they in other tissues? ###
  672. MB_genes
  673. df_allT_15MBs <- lapply(MB_genes, (x) {
  674. y <- plotCounts(dds_allTissue_LTR_rescue, returnData=TRUE, x, intgroup =c("Rescue","Tissue"))
  675. y$feature <- x
  676. return(y)
  677. })
  678. p_allT_15 <- lapply(df_allT_15MBs, function(df) {
  679. ggplot(df) +
  680. geom_beeswarm(aes(x=Tissue, y=count, color = Rescue),priority = "none")+
  681. stat_summary(aes(x=Tissue, y=count, color = Rescue), fun.y= mean, fun.ymin=mean, fun.ymax=mean, geom="crossbar", width=0.3, linewidth =0.3)+
  682. ylab("Normalized count")+
  683. scale_color_manual(values=c("blue3", "red3"))+
  684. theme_classic()+
  685. ggtitle(paste(df$feature))+
  686. theme(axis.title.y=element_blank(),
  687. legend.position="none")
  688. })
  689. plot_a_list(p_allT_15, 5, 3)
  690. gene_14458 <- plotCounts(dds_allTissue_LTR_rescue, returnData=TRUE, "gene_14458", intgroup =c("Rescue","Tissue"))
  691. ggplot(data = gene_14458) +
  692. geom_beeswarm(aes(x=Tissue, y=count, color = Rescue),priority = "none")+
  693. stat_summary(aes(x=Tissue, y=count, color = Rescue), fun.y= mean, fun.ymin=mean, fun.ymax=mean, geom="crossbar", width=0.3, linewidth =0.3)+
  694. ylab("Normalized count")+
  695. scale_color_manual(values=c("blue3", "red3"))+
  696. theme_classic()+
  697. # ggtitle(paste(df$feature))+
  698. theme(legend.position="right")
  699. # A reduced model without the tissue variable
  700. dds_allTissue_LTR_tissue <- DESeq(dds_alltissues, test="LRT", full= ~ Tissue +Rescue, reduced = ~Rescue)
  701. LRT_results_allTissue_tissue <- results(dds_allTissue_LTR_tissue)
  702. LRT_results_allTissue_tissue_sig <- subset(LRT_results_allTissue_tissue , padj < 0.05)
  703. LRT_results_allTissue_tissue_sig # DataFrame with 9913 rows and 6 columns
  704. LRT_results_allTissue_tissue_sig$gene <- rownames(LRT_results_allTissue_tissue_sig)
  705. LRT_results_allTissue_frame <- as.data.frame(LRT_results_allTissue_tissue_sig)
  706. #write.xlsx(LRT_results_allTissue_frame, "DEGs_alltissues.xlsx")
  707. # DESEq per tissue
  708. ##### Optic lobes ####
  709. design_OL <- subset(design_rescue, Tissue =="OL")
  710. OL_counts <- tissue_counts[,colnames(tissue_counts) %in% design_OL$Sample_ID]
  711. dds_OL <- DESeqDataSetFromMatrix(countData = OL_counts, colData = design_OL , design = ~ Colony_ID + Rescue)
  712. # converting counts to integer mode
  713. keep_OL <- rowSums(counts(dds_OL) >= 10) >= 6
  714. dds_OL <- dds_OL[keep_OL,]
  715. # A reduced model without the rescue factor
  716. dds_OL_ltr_rescue <- DESeq(dds_OL, test="LRT", full= ~ Colony_ID + Rescue , reduced = ~ Colony_ID)
  717. LRT_results_rescue_OL <- results(dds_OL_ltr_rescue)
  718. #write.csv(LRT_results_rescue_OL, "DEGs_OL.csv")
  719. LRT_results_rescue_OL_sig <- subset(LRT_results_rescue_OL, padj < 0.05)
  720. LRT_results_rescue_OL_sig # 1 gene "affected"
  721. # log2 fold change (MLE): Rescue Yes vs No
  722. # LRT p-value: '~ Colony_ID + Rescue' vs '~ Colony_ID'
  723. # DataFrame with 1 row and 6 columns
  724. # baseMean log2FoldChange lfcSE stat pvalue padj
  725. # <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
  726. # gene_5301 399.255 1.3244 0.240348 28.644 8.6982e-08 0.000842073
  727. opticlobes_genes <- c("gene_5301")
  728. LRT_results_rescue_OL_sig$gene <- rownames(LRT_results_rescue_OL_sig)
  729. y <- plotCounts(dds_OL_ltr_rescue , returnData=TRUE,opticlobes_genes , intgroup = "Rescue")
  730. y$feature <- c("gene_5301")
  731. y.position=max(y$count)
  732. padj_OLs <- as.data.frame(LRT_results_rescue_OL_sig[[6]])
  733. padj_OLs$feature <- LRT_results_rescue_OL_sig[[7]]
  734. padj_OLs$`LRT_results_rescue_OL_sig[[6]]` <- lapply(padj_OLs$`LRT_results_rescue_OL_sig[[6]]`, signif, digits=3)
  735. large_padj_OLs <- merge(padj_OLs, y, by = "feature", all= FALSE)
  736. padj_OLs_small <- large_padj_OLs[!duplicated(large_padj_OLs$feature), ]
  737. plot_a_list <- function(master_list_with_plots, no_of_rows, no_of_cols) {
  738. patchwork::wrap_plots(master_list_with_plots,
  739. nrow = no_of_rows, ncol = no_of_cols)
  740. }
  741. # apply seperately for each gene showing the mean
  742. p_OL <- ggplot(y) +
  743. geom_beeswarm(aes(x=Rescue, y=count, color= Rescue),priority = "none")+
  744. stat_summary(aes(x=Rescue, y=count), fun.y= mean, fun.ymin=mean, fun.ymax=mean, geom="crossbar", width=0.3, linewidth =0.3)+
  745. # annotate("text", label= "Padj=", x= 1,y=(padj_MBs_small[match( gene, padj_MBs_small$feature),5]))+
  746. geom_text(data = as.data.frame(padj_OLs_small),
  747. aes(label = (padj_OLs_small[1,2]),
  748. x = 1.45, y = y.position)) +
  749. ylab("Normalized count")+
  750. scale_color_manual(values=c("blue3", "red3"))+
  751. theme_classic()+
  752. ggtitle(paste("gene_5301"))+
  753. theme(axis.title.y=element_blank(),
  754. legend.position="none")
  755. # finally print your plots
  756. plot_a_list(p_MB, 4, 4)
  757. ##### Mushroom Bodies ####
  758. design_MB <- subset(design_rescue, Tissue =="MB")
  759. MB_counts <- tissue_counts[,colnames(tissue_counts) %in% design_MB$Sample_ID]
  760. dds_MB <- DESeqDataSetFromMatrix(countData = MB_counts, colData = design_MB , design = ~ Colony_ID + Rescue)
  761. # converting counts to integer mode
  762. keep_MB <- rowSums(counts(dds_MB) >= 10) >= 6
  763. dds_MB <- dds_MB[keep_MB,]
  764. # A reduced model without the rescue factor
  765. dds_MB_ltr_rescue <- DESeq(dds_MB, test="LRT", full= ~ Colony_ID + Rescue , reduced = ~ Colony_ID)
  766. LRT_results_rescue_MB <- results(dds_MB_ltr_rescue)
  767. #write.csv(LRT_results_rescue_MB, "DEGs_MB.csv")
  768. LRT_results_rescue_MB_sig <- subset(LRT_results_rescue_MB, padj < 0.05)
  769. LRT_results_rescue_MB_sig
  770. # log2 fold change (MLE): Rescue Yes vs No
  771. # LRT p-value: '~ Colony_ID + Rescue' vs '~ Colony_ID'
  772. # DataFrame with 15 rows and 6 columns
  773. # baseMean log2FoldChange lfcSE stat pvalue padj
  774. # <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
  775. # gene_3661 156.4731 2.496080 0.426528 28.9972 7.24820e-08 9.90312e-05
  776. # gene_3662 98.3451 1.977841 0.435669 17.4028 3.02374e-05 2.10276e-02
  777. # gene_3426 250.8087 0.962072 0.225606 17.3690 3.07807e-05 2.10276e-02
  778. # gene_1607 167.2192 1.373933 0.242181 30.4875 3.36027e-08 6.42752e-05
  779. # gene_2555 56.0721 2.647648 0.446123 30.8862 2.73609e-08 6.42752e-05
  780. # ... ... ... ... ... ... ...
  781. # gene_13149 1019.5838 0.505851 0.114291 19.4021 1.05890e-05 9.43983e-03
  782. # gene_9895 64.7391 2.145827 0.369639 31.1385 2.40262e-08 6.42752e-05
  783. # gene_9900 169.3375 0.948923 0.234393 15.7326 7.29542e-05 4.65156e-02
  784. # gene_8499 46.5866 1.933660 0.399757 21.4861 3.56396e-06 4.26071e-03
  785. # gene_7997 137.1182 1.403238 0.301844 19.9517 7.94241e-06 8.44014e-03
  786. LRT_results_rescue_MB_sig@rownames
  787. MB_genes <-c( "gene_3661", "gene_3662", "gene_3426", "gene_1607", "gene_2555", "gene_1243" , "gene_930" , "gene_5298" , "gene_6089", "gene_5245", "gene_13149", "gene_9895", "gene_9900", "gene_8499", "gene_7997")
  788. library(ggVennDiagram)
  789. list_genes <- list(alltissues_genes, opticlobes_genes, MB_genes)
  790. Venn_genes <- ggVennDiagram(list_genes, label = c("count"), label_alpha = 0, category.names = c("All tissues", "OL", "MB"))+
  791. scale_fill_gradient(low = "#FFFFFF", high = "#FF0033")
  792. dds_vst_MB <- varianceStabilizingTransformation(dds_MB)
  793. pcaData_MB <- plotPCA(dds_vst_MB, intgroup = c("Rescue", "Colony_ID", "Pool"), returnData = T)
  794. # using ntop=500 top features by variance
  795. pca_MB <- ggplot(pcaData_MB, aes(x = PC1, y = PC2, color = Rescue, shape = Colony_ID)) +
  796. geom_point(size=3) +
  797. # geom_label_repel(label.size = 0)+
  798. xlab("PC1: 33% variance")+
  799. ylab("PC2 : 19% variance")+
  800. ggtitle("PCA MB Rescue")+
  801. # scale_color_manual(values = c("#C77CFF", "#00BFC4", "#7CAE00", "#F8766D"))+
  802. theme_minimal()+
  803. scale_shape_manual(values = c(0, 5, 10, 14, 1,8,17))+
  804. scale_color_manual(values=c("blue3", "red3"))+
  805. theme(panel.border = element_blank(),
  806. panel.grid.major = element_blank(),
  807. panel.grid.minor = element_blank(),
  808. axis.line = element_line(colour="black"),
  809. legend.position = "bottom",
  810. legend.text=element_text(size=12),
  811. axis.title = element_text(size = 12),
  812. axis.text = element_text(size = 12))
  813. pca_MB
  814. Venn_genes + pca_MB + plot_layout(widths = c(1,2))
  815. plotMA(LRT_results_rescue_MB, ylim=c(-2,2), alpha = 0.05) # logarithmic fold change log2(yes/no).
  816. # resLFC <- lfcShrink(dds_MB_ltr_rescue, coef="Rescue_Yes_vs_No", type="apeglm")
  817. # plotMA(resLFC, ylim=c(-2,2), alpha = 0.05) # shrunken log2 fold changes, which remove the noise associated with log2 fold changes from low count genes without requiring arbitrary filtering thresholds.
  818. #### Plot MB DEGs count ###
  819. #The counts are which normalizes counts by the estimated size factors (or normalization factors if these were used) and adds a pseudocount of 1/2 to allow for log scale plotting.
  820. #plotCounts(dds_MB_ltr_rescue, gene=which.min(LRT_results_rescue_MB$padj), intgroup="Rescue")
  821. LRT_results_rescue_MB_sig$gene <- rownames(LRT_results_rescue_MB_sig)
  822. df_MB <- lapply(LRT_results_rescue_MB_sig$gene, (x) {
  823. y <- plotCounts(dds_MB_ltr_rescue, returnData=TRUE, x, intgroup = "Rescue")
  824. y$feature <- x
  825. return(y)
  826. })
  827. df_MBs <- do.call(rbind, df_MB)
  828. df_MBs<- df_MBs %>%
  829. group_by(feature) %>%
  830. mutate(y.position=max(count))
  831. df_MBs$sample <- rep(sort_samples_data19_compl$shortID,length(df_3))
  832. df_threeruns$number_runs <- rep(sort_samples_data19_compl$number_runs,length(df_3))
  833. padj_MBs <- as.data.frame(LRT_results_rescue_MB_sig[[6]])
  834. padj_MBs$feature <- LRT_results_rescue_MB_sig[[7]]
  835. padj_MBs$`LRT_results_rescue_MB_sig[[6]]` <- lapply(padj_MBs$`LRT_results_rescue_MB_sig[[6]]`, signif, digits=3)
  836. large_padj_MBs <- merge(padj_MBs, df_MBs, by = "feature", all= FALSE)
  837. padj_MBs_small <- large_padj_MBs[!duplicated(large_padj_MBs$feature), ]
  838. plot_a_list <- function(master_list_with_plots, no_of_rows, no_of_cols) {
  839. patchwork::wrap_plots(master_list_with_plots,
  840. nrow = no_of_rows, ncol = no_of_cols)
  841. }
  842. # apply seperately for each gene showing the mean
  843. p_MB <- lapply(LRT_results_rescue_MB_sig$gene, function(gene) {
  844. ggplot(df_MBs[df_MBs[, "feature"]==gene,]) +
  845. geom_beeswarm(aes(x=Rescue, y=count, color= Rescue),priority = "none")+
  846. stat_summary(aes(x=Rescue, y=count), fun.y= mean, fun.ymin=mean, fun.ymax=mean, geom="crossbar", width=0.3, linewidth =0.3)+
  847. # annotate("text", label= "Padj=", x= 1,y=(padj_MBs_small[match( gene, padj_MBs_small$feature),5]))+
  848. geom_text(data = as.data.frame(padj_MBs_small),
  849. aes(label = (padj_MBs_small[match( gene,feature),2]),
  850. x = 1.45, y = (padj_MBs_small[match( gene, feature),5]))) +
  851. ylab("Normalized count")+
  852. scale_color_manual(values=c("blue3", "red3"))+
  853. theme_classic()+
  854. ggtitle(paste(gene))+
  855. theme(axis.title.y=element_blank(),
  856. legend.position="none")
  857. })
  858. # finally print your plots
  859. plot_a_list(p_MB, 4, 4)
  860. ##### Central Complex+ ####
  861. design_CC <- subset(design_rescue, Tissue =="CC")
  862. CC_counts <- tissue_counts[,colnames(tissue_counts) %in% design_CC$Sample_ID]
  863. dds_CC <- DESeqDataSetFromMatrix(countData = CC_counts, colData = design_CC , design = ~ Colony_ID + Rescue)
  864. # converting counts to integer mode
  865. keep_CC <- rowSums(counts(dds_CC) >= 10) >= 6
  866. dds_CC <- dds_CC[keep_CC,]
  867. # A reduced model without the rescue factor
  868. dds_CC_ltr_rescue <- DESeq(dds_CC, test="LRT", full= ~ Colony_ID + Rescue , reduced = ~ Colony_ID)
  869. LRT_results_rescue_CC <- results(dds_CC_ltr_rescue)
  870. #write.csv(LRT_results_rescue_CC, "DEGs_CC.csv")
  871. LRT_results_rescue_CC_sig <- subset(LRT_results_rescue_CC, padj < 0.05)
  872. LRT_results_rescue_CC_sig
  873. # DataFrame with 0 rows and 6 columns
  874. ##### Antennae ####
  875. design_Ant <- subset(design_rescue, Tissue =="Ant")
  876. Ant_counts <- tissue_counts[,colnames(tissue_counts) %in% design_Ant$Sample_ID]
  877. dds_Ant <- DESeqDataSetFromMatrix(countData = Ant_counts, colData = design_Ant , design = ~ Colony_ID + Rescue)
  878. # converting counts to integer mode
  879. keep_Ant <- rowSums(counts(dds_Ant) >= 10) >= 6
  880. dds_Ant <- dds_Ant[keep_Ant,]
  881. # A reduced model without the rescue factor
  882. dds_Ant_ltr_rescue <- DESeq(dds_Ant, test="LRT", full= ~ Colony_ID + Rescue , reduced = ~ Colony_ID)
  883. LRT_results_rescue_Ant <- results(dds_Ant_ltr_rescue)
  884. #write.csv(LRT_results_rescue_Ant, "DEGs_antennae.csv")
  885. LRT_results_rescue_Ant_sig <- subset(LRT_results_rescue_Ant, padj < 0.05)
  886. LRT_results_rescue_Ant_sig
  887. # 0
  888. LRT_results_rescue_Ant_df<- as.data.frame(LRT_results_rescue_Ant)
  889. #### GOterms upregulated in MB
  890. ontology_type = "CC" # or CC or MF
  891. GO_data_iup <- new("topGOdata", description="GO_Enrichment", ontology=ontology_type, allGenes=gene_list_iup, annot = annFUN.gene2GO, gene2GO=universe)
  892. result_topGO_w01_iup <- runTest(GO_data_iup, algorithm = "weight01", statistic = "fisher")
  893. result_table_w01_iup_CC <- GenTable(GO_data_iup, Fisher = result_topGO_w01_iup, orderBy = "Fisher", ranksOf = "Fisher", topNodes = numSigGenes(GO_data_iup))
  894. result_table_w01_iup_CC
  895. ontology_type = "MF" # or CC or MF
  896. GO_data_iup <- new("topGOdata", description="GO_Enrichment", ontology=ontology_type, allGenes=gene_list_iup, annot = annFUN.gene2GO, gene2GO=universe)
  897. result_topGO_w01_iup <- runTest(GO_data_iup, algorithm = "weight01", statistic = "fisher")
  898. result_table_w01_iup_MF <- GenTable(GO_data_iup, Fisher = result_topGO_w01_iup, orderBy = "Fisher", ranksOf = "Fisher", topNodes = numSigGenes(GO_data_iup))
  899. result_table_w01_iup_MF
  900. ####### With the new annotation ####
  901. setwd("~/Documents/Catagl_cognition/From_Eyal")
  902. # Load InterProScan GO mappings
  903. go_raw <- read.delim("go_raw.tsv", header = FALSE, stringsAsFactors = FALSE)
  904. colnames(go_raw) <- c("transcript_id", "go_terms")
  905. head(go_raw)
  906. # Load gene-transcript mapping file
  907. mapping <- read.csv("Cnig_gn3.1.fasta.transcripts.fasta.trinotate.csv", header = TRUE, stringsAsFactors = FALSE)
  908. # Preview to confirm columns
  909. head(mapping[, 1:2])
  910. # Join GO annotations with gene mapping
  911. go_merged <- merge(go_raw, mapping[, c("X.gene_id", "transcript_id")], by = "transcript_id")
  912. head(go_merged)
  913. library(dplyr)
  914. library(tidyr)
  915. # Clean and collapse
  916. gene_go <- go_merged %>%
  917. filter(go_terms != "") %>%
  918. mutate(go_split = strsplit(go_terms, "[,|]")) %>%
  919. unnest(go_split) %>%
  920. group_by(X.gene_id) %>%
  921. summarise(go_terms = paste(unique(go_split), collapse = ",")) %>%
  922. ungroup()
  923. # Remove any suffixes like (InterPro), (Pfam), etc.
  924. gene_go$go_terms <- gsub("(.*?)", "", gene_go$go_terms)
  925. # Build geneID2GO Object for topGO
  926. geneID2GO <- setNames(strsplit(gene_go$go_terms, ","), gene_go$X.gene_id)
  927. write.table(geneID2GO, file = "geneID2GO_universe.tsv", sep = "t", quote = FALSE, row.names = FALSE)
  928. # generate list of the protein IDs
  929. universe_genelist <- names(geneID2GO)
  930. #### MBs rescuers vs non-rescuers ####
  931. MB_up_genes <- as.data.frame(c("gene_3661", "gene_3662", "gene_3426", "gene_1607", "gene_2555", "gene_1243" , "gene_930" , "gene_5298" , "gene_6089", "gene_5245", "gene_13149", "gene_9895", "gene_9900", "gene_8499", "gene_7997"))
  932. colnames(MB_up_genes) <- c("genes")
  933. # generate a reference list of the protein IDs
  934. #testset_genelist_idown <- readLines(LD_down_genes)
  935. #determine matches between both datasets
  936. gene_list_iup <- factor(as.integer(universe_genelist %in% MB_up_genes$genes))
  937. names(gene_list_iup) <- universe_genelist
  938. #set the ontology type you want to investigate, we first choose "Biological Processes"=BP, '93Cellular Components'94=CC, '93Molecular Function'94=MF
  939. ontology_type = "BP" # or CC or MF
  940. GO_data_iup <- new("topGOdata", description="GO_Enrichment", ontology=ontology_type, allGenes=gene_list_iup, annot = annFUN.gene2GO, gene2GO= geneID2GO)
  941. result_topGO_w01_iup <- runTest(GO_data_iup, algorithm = "weight01", statistic = "fisher")
  942. result_table_w01_iup_BP <- GenTable(GO_data_iup, Fisher = result_topGO_w01_iup, orderBy = "Fisher", ranksOf = "Fisher", topNodes = numSigGenes(GO_data_iup))
  943. result_table_w01_iup_BP
  944. #### Graphics ####
  945. result_table_w01_iup_BP_sig <- result_table_w01_iup_BP[which(result_table_w01_iup_BP$Fisher<0.05),]
  946. setwd("~/Documents/Catag_rescue/")
  947. #write.csv(result_table_w01_idown_BP_sig, file=paste0("topGO_result_weight01_significant_OL_Corrprop_BP_down_cooks.csv")
  948. colors <- colorRampPalette( brewer.pal( 12, "Paired" ) )( length(result_table_w01_iup_BP_sig$Term))
  949. #Create the tag cloud
  950. tagcloud(strmultline(result_table_w01_iup_BP_sig$Term), weights = - log(as.numeric(result_table_w01_iup_BP_sig$Fisher)),col=colors)
  951. #### GOterms upregulated in MB
  952. ontology_type = "CC" # or CC or MF
  953. GO_data_iup <- new("topGOdata", description="GO_Enrichment", ontology=ontology_type, allGenes=gene_list_iup, annot = annFUN.gene2GO, gene2GO=geneID2GO)
  954. result_topGO_w01_iup <- runTest(GO_data_iup, algorithm = "weight01", statistic = "fisher")
  955. result_table_w01_iup_CC <- GenTable(GO_data_iup, Fisher = result_topGO_w01_iup, orderBy = "Fisher", ranksOf = "Fisher", topNodes = numSigGenes(GO_data_iup))
  956. result_table_w01_iup_CC
  957. ontology_type = "MF" # or CC or MF
  958. GO_data_iup <- new("topGOdata", description="GO_Enrichment", ontology=ontology_type, allGenes=gene_list_iup, annot = annFUN.gene2GO, gene2GO=geneID2GO)
  959. result_topGO_w01_iup <- runTest(GO_data_iup, algorithm = "weight01", statistic = "fisher")
  960. result_table_w01_iup_MF <- GenTable(GO_data_iup, Fisher = result_topGO_w01_iup, orderBy = "Fisher", ranksOf = "Fisher", topNodes = numSigGenes(GO_data_iup))
  961. result_table_w01_iup_MF
  962. ############ reactome ##########
  963. # Load Reactome mappings
  964. reactome_raw <- read.delim("reactome_raw.tsv", header = FALSE, stringsAsFactors = FALSE)
  965. colnames(reactome_raw) <- c("transcript_id", "reactome_id")
  966. head(reactome_raw)
  967. # Load gene-transcript mapping file
  968. mapping <- read.csv("Cnig_gn3.1.fasta.transcripts.fasta.trinotate.csv", header = TRUE, stringsAsFactors = FALSE)
  969. # Preview to confirm columns
  970. head(mapping[, 1:2])
  971. # Join GO annotations with gene mapping
  972. reactome_merged <- merge(reactome_raw, mapping[, c("X.gene_id", "transcript_id")], by = "transcript_id")
  973. head(reactome_merged)
  974. # Clean and collapse
  975. gene_reactome <- reactome_merged %>%
  976. filter(reactome_id != "") %>%
  977. mutate(react_split = strsplit(reactome_id, "[,|]")) %>%
  978. unnest(react_split) %>%
  979. group_by(X.gene_id) %>%
  980. summarise(reactome_id = paste(unique(react_split), collapse = ",")) %>%
  981. ungroup()
  982. MB_up_reactome <- merge(MB_up_genes, gene_reactome, by.x = "genes", by.y="X.gene_id", all.x=T, all.y = F)
  983. MB_up_reactome_list <- setNames(strsplit(MB_up_reactome$reactome_id, ","), MB_up_reactome$genes)
  984. write.csv(MB_up_reactome, "MB_upDEGs_reactome_pathways.csv")
  985. library(ReactomeContentService4R)
  986. reactome_ids_gene9900 <- MB_up_reactome_list$gene_9900
  987. # Remove "Reactome:" prefix
  988. reactome_ids_gene9900clean <- sub("^Reactome:", "", reactome_ids_gene9900)
  989. # Get pathway info
  990. pathway_info <- lapply(reactome_ids_gene9900clean, function(id) {
  991. tryCatch(
  992. ReactomeContentService4R::getPathwaySummation(id),
  993. error = function(e) NA
  994. )
  995. })
  996. # Combine results
  997. names(pathway_info) <- reactome_ids_gene9900clean
  998. pathway_info

Script_Rescue.R at commit c2bd6a5, no license · at the source

Overview

  1. Institute of Organismic and Molecular Evolution, Johannes Gutenberg University Mainz, 55128 Mainz, Germany
  2. School of Zoology, George S Wise Faculty of Life Sciences, Tel Aviv University, Tel Aviv 6997801, Israel
Journal: The Journal of experimental biology, volume 229, issue 14, article jeb252086
Dates: received 19 December 2025; accepted 9 June 2026; published online 17 July 2026; in print July 2026
Type: Research article · Language: English
License: CC BY
Identifiers: DOI 10.1242/jeb.252086 · PMID 42332978 · PMCID PMC13405234 · OpenAlex W7165677441
Open access: hybrid, a free copy (OpenAlex)
Status: code verified
Categories: genetics / omics (modality), other (organism), cellular / molecular (subfield)
Methods: Statistics, Smoothing, state filtering, decompositions
Keywords: Altruistic behaviour, Brain activity, Gene expression, Helping behaviour, Juvenile hormone
MeSH: Ants*, Behavior, Animal*, Transcriptome*, Animals, Brain, Social Behavior (* major topic)
Topic: Insect and Arachnid Ecology and Behavior (Genetics, Biochemistry, Genetics and Molecular Biology), according to OpenAlex
Funding: Deutsche Forschungsgemeinschaft (FO 298/31-1, JA 3614/1-1); Israel Science Foundation (699/24); Johannes Gutenberg University of Mainz
Citations: not cited yet (Europe PMC); 88 references in the paper

Abstract

Some social animals can recognize and respond to the distress of group members. While well documented in mammals, such behaviour has also independently evolved in ants. To uncover the molecular basis of this social trait, we compared gene expression in the central and peripheral nervous system of Cataglyphis nigra workers differing in rescue propensity. RNA-seq of mushroom bodies, optic lobes, central brain and antennae revealed nine genes upregulated across all tissues of rescuers, including those encoding cytochrome P450-9e2 (CYP9E2) and arginase, and immune-related genes such as the defensin (DEFA) and serine protease snake (snk) genes. The mushroom bodies showed the strongest signal, including genes involved in juvenile hormone signalling, polyamine synthesis and immune function. These results suggest that the immune pathways and polyamine metabolism modulate social responsiveness or alarm-cue detection in ants. In contrast, morphological and physiological traits did not differ between rescuers and non-rescuers, indicating that rescue behaviour propensity is governed by the activity of the nervous system.

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 10 matches between paragraphs and lines of code.

ljaimesnino/RescueAnts

License: none: the authors keep all their rights
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Commit: c2bd6a5378e072d2a806fbd6dfb7ea6737235af5, 24 May 2026
Languages: R (1)
Size: 2 files, 1 script
Software Heritage: not archived
Found in: the end of the paper
Holds: README
Not found: license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: car (1 file), emmeans (1 file), ggplot2 (1 file), glmmTMB (1 file), patchwork (1 file), tidyverse (1 file)
Availability: 1 check, the latest on 27 September 2026: the link answers
  • 27 September 2026: the link answers
2 files

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;
  • 10 matches between paragraphs of the paper and lines of the code (method lexical-v1);
  • neither the text of the paper nor the code itself.

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

Data

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

Versions

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

Version 2, 28 September 2026

  • Publisher: n/a → The Company of Biologists

Version 1, 27 September 2026: the first record

Recorded: type, language, journal, volume, issue, pages, dates, 4 authors, 5 keywords, 6 MeSH terms, 3 funders, 88 references.

Cite

This paper

Jaimes-Nino, L. M., Bar, A., Scharf, I., & Foitzik, S. (2026). Transcriptional predictors of rescue behaviour in ants. The Journal of experimental biology, 229(14), jeb252086. https://doi.org/10.1242/jeb.252086

BibTeX

@article{jaimesnino2026transcriptional,
author = {Jaimes-Nino, Luisa Maria and Bar, Adi and Scharf, Inon and Foitzik, Susanne},
title = {{Transcriptional predictors of rescue behaviour in ants}},
journal = {The Journal of experimental biology},
year = {2026},
month = jul,
volume = {229},
number = {14},
pages = {jeb252086},
publisher = {The Company of Biologists},
issn = {0022-0949},
doi = {10.1242/jeb.252086},
url = {https://doi.org/10.1242/jeb.252086},
pmid = {42332978},
pmcid = {PMC13405234}
}

RIS

TY - JOUR
AU - Jaimes-Nino, Luisa Maria
AU - Bar, Adi
AU - Scharf, Inon
AU - Foitzik, Susanne
TI - Transcriptional predictors of rescue behaviour in ants
T2 - The Journal of experimental biology
J2 - J Exp Biol
PY - 2026
DA - 2026/07/17
VL - 229
IS - 14
SP - jeb252086
SN - 0022-0949
PB - The Company of Biologists
DO - 10.1242/jeb.252086
UR - https://doi.org/10.1242/jeb.252086
LA - en
ER -

CSL-JSON

{
"id": "10.1242/jeb.252086",
"type": "article-journal",
"title": "Transcriptional predictors of rescue behaviour in ants",
"container-title": "The Journal of experimental biology",
"author": [
{
"family": "Jaimes-Nino",
"given": "Luisa Maria"
},
{
"family": "Bar",
"given": "Adi"
},
{
"family": "Scharf",
"given": "Inon"
},
{
"family": "Foitzik",
"given": "Susanne"
}
],
"container-title-short": "J Exp Biol",
"volume": "229",
"issue": "14",
"page": "jeb252086",
"DOI": "10.1242/jeb.252086",
"PMID": "42332978",
"PMCID": "PMC13405234",
"ISSN": "0022-0949",
"publisher": "The Company of Biologists",
"URL": "https://doi.org/10.1242/jeb.252086",
"language": "en",
"issued": {
"date-parts": [
[
2026,
7,
17
]
]
}
}

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.1007/s12311-026-02006-1 [code]
Innovative 3D-Image Analysis of Cerebellar Vascularization Highlights Angiogenic Gene Dysregulations in a Murine Model of Apnea of Prematurity.
Journal: Cerebellum (London, England)
In common: glmmTMB, car, emmeans, 3 other tools, genetics / omics, 1 reference
[2] doi:10.3390/ijms27135713 [code]
Chronic Administration of Marinobufagenin in Mice Causes Hyperlocomotion and Decrease in Anxiety by Altering Monoamine Turnover Unaccompanied by Motor Deficits or Oxidative Stress.
Journal: International journal of molecular sciences
In common: glmmTMB, car, emmeans, 3 other tools, cellular / molecular
[3] doi:10.1038/s41467-026-76675-1 [code]
Long-read proteogenomic atlas of human neuronal differentiation reveals isoform diversity informing neurodevelopmental risk mechanisms.
Journal: Nature communications
In common: glmmTMB, emmeans, patchwork, 2 other tools, genetics / omics, 2 references
[4] doi:10.1016/j.celrep.2026.117505 [code]
Impaired spatial coding and neuronal hyperactivity in the medial entorhinal cortex of aged APP knock-in mice.
Journal: Cell reports
In common: glmmTMB, car, emmeans, 3 other tools
[5] doi:10.7554/elife.107088 [code]
Development of auditory and spontaneous movement responses to music over the first postnatal year.
Journal: eLife
In common: glmmTMB, car, emmeans, 2 other tools, 1 reference
[6] 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: car, emmeans, patchwork, 2 other tools, genetics / omics, 2 references
[7] doi:10.1038/s41514-026-00391-9 [code]
Region-specific transcriptional signatures of brain aging in the absence of neuropathology at the single-cell level.
Journal: npj aging
In common: glmmTMB, patchwork, ggplot2, 1 other tool, genetics / omics, cellular / molecular, 1 reference
[8] doi:10.1038/s41586-026-10444-4 [code]
A brain reward circuit inhibited by next-generation weight-loss drugs in mice.
Journal: Nature
In common: glmmTMB, emmeans, patchwork, 2 other tools
[9] doi:10.1038/s41467-026-73858-8 [code]
A pegivirus associated with encephalitis in red-legged partridges shows neurotropism across avian species.
Journal: Nature communications
In common: car, emmeans, patchwork, 2 other tools, other
[10] doi:10.1126/sciadv.aeb8106 [code]
A thyroid hormone-mediated opsin switch initiates metamorphosis in a proto-vertebrate.
Journal: Science advances
In common: car, emmeans, patchwork, 2 other tools, other

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.