OSCR

Ecological not social factors explain brain size in cephalopods.

Code ↔ Paper

13 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 13 matches
  1. [1] § STAR★Methods › Quantification and statistical analysis › Miscalculation in chung et al. (2023) › Variable definitions ↔ consensus_analyses.R, lines 41–128 · score 0.72 · matage.max, matage.min, minimum age, sexual maturity, st.cephdat, species
  2. [2] § STAR★Methods › Quantification and statistical analysis › Miscalculation in chung et al. (2023) › Variable definitions ↔ plots_nov24.R, lines 390–464 · score 0.70 · matage.max, matage.min, minimum age, sexual maturity, st.cephdat, Variable
  3. [3] § STAR★Methods › Method details ↔ consensus_analyses.R, lines 1–39 · score 0.69 · maximum clade credibility, correlations matrices, consensus, tree, phylogeny, cephalopod
  4. [4] § STAR★Methods › Method details ↔ sensitivity-checks/supplement_sensitivitychecks.R, lines 1–51 · score 0.68 · maximum clade credibility, correlations matrices, tree, consensus, phylogeny, cephalopod
  5. [5] § STAR★Methods › Quantification and statistical analysis › Causal graph ↔ dataprep_cephs.R, lines 17–105 · score 0.66 · encompasses cognition, adjustmentSets, cephdag, exposure, defense, foraging
  6. [6] § STAR★Methods › Quantification and statistical analysis › Additional analyses › Age at sexual maturity ↔ sensitivity-checks/supplement_sensitivitychecks.R, lines 53–91 · score 0.64 · sexual maturity, maximum age, sensitivity checks, somewhat, sociality, species
  7. [7] § STAR★Methods › Quantification and statistical analysis › Additional analyses › Dietary breadth and predation pressure ↔ consensus_analyses.R, lines 217–266 · score 0.61 · Dietary breadth, diet breadth, predator breadth, interaction, predictor, benthic
  8. [8] § STAR★Methods › Quantification and statistical analysis › Additional analyses › Age at sexual maturity ↔ consensus_analyses.R, lines 41–128 · score 0.56 · sexual maturity, maximum age, sociality, species, CNS, brain
  9. [9] § STAR★Methods › Quantification and statistical analysis ↔ consensus_analyses.R, lines 1–39 · score 0.56 · consensus phylogeny, correlation matrix, bf, brms, Cormat, Models
  10. [10] § STAR★Methods › Quantification and statistical analysis ↔ sensitivity-checks/supplement_sensitivitychecks.R, lines 378–438 · score 0.56 · diet breadth, Sensitivity checks, predator breadth, age, species
  11. [11] § STAR★Methods › Quantification and statistical analysis ↔ sensitivity-checks/supplement_sensitivitychecks.R, lines 1–51 · score 0.54 · consensus phylogeny, correlation matrix, Cormat, ML, CNS, brain
  12. [12] § STAR★Methods › Quantification and statistical analysis › Additional analyses › Behavioral repertoire ↔ consensus_analyses.R, lines 167–215 · score 0.52 · foraging repertoire, defense repertoire
  13. [13] § STAR★Methods › Quantification and statistical analysis › Miscalculation in chung et al. (2023) › Variable definitions ↔ consensus_analyses.R, lines 217–266 · score 0.52 · diet.breadth, Dietary breadth, family, st.cephdat, Cephalopods

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 · 468 lines · 23 KB · no license · 7 matches

  1. #using consensus phylogeny for all models, with the updated dataset April 10, 2024 excluding I. paradoxus
  2. #UPDATING november 19, 2024 with corrected depth data----
  3. #load packages----
  4. library(brms)
  5. library(ape)
  6. library(mice)
  7. library(tidyverse)
  8. library(cmdstanr)
  9. library(dagitty)
  10. options(scipen=999) #turn off scientific notation
  11. #set working directory----
  12. setwd("/Users/kiranbasava/nonhumans/di_cephproject/analyses/cephalopod_analyses/ceph-brain-evolution")
  13. getwd()
  14. #read in data and phylogenies
  15. cephtreeMCC <- read.nexus("cephtreeMCC.tree") #consensus (maximum clade credibility) tree
  16. cormat <- vcv(cephtreeMCC, corr=TRUE) #correlation matrix for consensus phylogeny
  17. st.cephdat <- read.csv("st.cephdat.csv") #logged and standardized data
  18. st.cephdat$benthic <- factor(st.cephdat$benthic)
  19. st.cephdat$sociality.bin <- factor(st.cephdat$sociality.bin)
  20. st.cephdat$sociality.3 <- factor(st.cephdat$sociality.3)
  21. st.cephdat$habitat3 <- factor(st.cephdat$habitat3)
  22. st.cephdat$depth_cat <- factor(st.cephdat$depth_cat)
  23. #ML baseline----
  24. m.MLst <- brm(bf(CNS.1 ~ mi(ML.1) + (1 | gr(phy.species, cov = cormat))) +
  25. bf(ML.1 | mi() ~ 1 + (1 | gr(phy.species, cov = cormat))),
  26. prior = c(prior(normal(0,1), class = Intercept),
  27. prior(normal(0,0.5), class = b)),
  28. data = st.cephdat,
  29. data2 = list(cormat = cormat),
  30. iter = 8000, chains = 4,
  31. control = list(adapt_delta = 0.89),
  32. backend = "cmdstanr",
  33. cores = 4)
  34. summary(m.MLst)
  35. save(m.MLst, file="m.MLst.rda")
  36. #age of sexual maturity----
  37. ## with maximum age of sexual maturity and lifespan----
  38. m.smmax <- brm(bf(CNS.1 ~ mi(ML.1) + mi(lifespan.max) + mi(matage.max) + WoS + benthic + depth.mean + pos.latmean + (1|gr(phy.species,cov=cormat))) +
  39. bf(matage.max | mi() ~ 1 + mi(ML.1) + mi(lifespan.max) + WoS + benthic + depth.mean + pos.latmean + (1|gr(phy.species,cov=cormat))) +
  40. bf(lifespan.max | mi() ~ 1 + mi(ML.1) + WoS + benthic + depth.mean + (1|gr(phy.species,cov=cormat))) +
  41. bf(ML.1 | mi() ~ 1 + benthic + depth.mean + pos.latmean + (1|gr(phy.species, cov=cormat))),
  42. data=st.cephdat,
  43. data2=list(cormat=cormat),
  44. prior = c(prior(normal(0,0.5), class = Intercept),
  45. prior(normal(0,0.5), class = b)),
  46. iter = 8000, chains = 4,
  47. control = list(adapt_delta = 0.89),
  48. backend="cmdstanr", cores=4)
  49. summary(m.smmax)
  50. save(m.smmax, file="/Users/kiranbasava/nonhumans/di_cephproject/analyses/cephalopod_analyses/nov2024_fits/m.smmax.rda")
  51. 0.33/0.75 #0.33 instead of 0.3 mean
  52. ## minimum age----
  53. m.smmin <- brm(bf(CNS.1 ~ mi(ML.1) + mi(lifespan.min) + mi(matage.min) + WoS + benthic + depth.mean + pos.latmean + (1|gr(phy.species,cov=cormat))) +
  54. bf(matage.min | mi() ~ 1 + mi(ML.1) + mi(lifespan.min) + WoS + benthic + depth.mean + pos.latmean + (1|gr(phy.species,cov=cormat))) +
  55. bf(lifespan.min | mi() ~ 1 + mi(ML.1) + WoS + benthic + depth.mean + (1|gr(phy.species,cov=cormat))) +
  56. bf(ML.1 | mi() ~ 1 + benthic + depth.mean + pos.latmean + (1|gr(phy.species, cov=cormat))),
  57. data=st.cephdat,
  58. data2=list(cormat=cormat),
  59. prior = c(prior(normal(0,1), class = Intercept),
  60. prior(normal(0,0.5), class = b)),
  61. iter = 8000, chains = 4,
  62. control = list(adapt_delta = 0.89),
  63. backend="cmdstanr", cores=4)
  64. summary(m.smmin)
  65. save(m.smmin, file="/Users/kiranbasava/nonhumans/di_cephproject/analyses/cephalopod_analyses/nov2024_fits/m.smmin.rda")
  66. -0.11/0.75
  67. m.smmean <- brm(bf(CNS.1 ~ mi(ML.1) + mi(lifespan.mean) + mi(matage.mean) + WoS + benthic + depth.mean + pos.latmean + (1|gr(phy.species,cov=cormat))) +
  68. bf(matage.mean | mi() ~ 1 + mi(ML.1) + mi(lifespan.mean) + WoS + benthic + depth.mean + pos.latmean + (1|gr(phy.species,cov=cormat))) +
  69. bf(lifespan.mean | mi() ~ 1 + mi(ML.1) + WoS + benthic + depth.mean + (1|gr(phy.species,cov=cormat))) +
  70. bf(ML.1 | mi() ~ 1 + benthic + depth.mean + pos.latmean + (1|gr(phy.species, cov=cormat))),
  71. data=st.cephdat,
  72. data2=list(cormat=cormat),
  73. prior = c(prior(normal(0,1), class = Intercept),
  74. prior(normal(0,0.5), class = b)),
  75. iter = 8000, chains = 4,
  76. control = list(adapt_delta = 0.89),
  77. backend="cmdstanr", cores=4)
  78. summary(m.smmean)
  79. save(m.smmean, file="/Users/kiranbasava/nonhumans/di_cephproject/analyses/cephalopod_analyses/nov2024_fits/m.smmean.rda")
  80. 0.26 /0.75 #instead of 0.18
  81. #sociality----
  82. ## binary----
  83. m.soc <- brm(bf(CNS.1 ~ mi(ML.1) + sociality.bin + WoS + benthic + depth.mean + (1|gr(phy.species,cov=cormat))) +
  84. bf(ML.1 | mi() ~ 1 + benthic + depth.mean + (1|gr(phy.species, cov=cormat))),
  85. data=st.cephdat,
  86. data2=list(cormat=cormat),
  87. prior = c(prior(normal(0,1), class = Intercept),
  88. prior(normal(0,0.5), class = b)),
  89. iter = 8000, chains = 4,
  90. control = list(adapt_delta = 0.89),
  91. backend="cmdstanr", cores=4)
  92. summary(m.soc)
  93. save(m.soc, file="/Users/kiranbasava/nonhumans/di_cephproject/analyses/cephalopod_analyses/nov2024_fits/m.soc.rda")
  94. -0.26/0.75 #-0.26 instead of -0.21
  95. ## 3 category----
  96. m.soc3 <- brm(bf(CNS.1 ~ mi(ML.1) + sociality.3 + WoS + benthic + depth.mean + (1|gr(phy.species,cov=cormat)))+
  97. bf(ML.1 | mi() ~ 1 + benthic + depth.mean + (1|gr(phy.species, cov=cormat))),
  98. data=st.cephdat,
  99. data2=list(cormat=cormat),
  100. family=gaussian("identity"),
  101. prior = c(prior(normal(0, 1), class = Intercept),
  102. prior(normal(0, 1), class = b)),
  103. iter = 8000, chains = 4,
  104. control = list(adapt_delta = 0.89),
  105. backend="cmdstanr", cores=4)
  106. summary(m.soc3)
  107. save(m.soc3, file="/Users/kiranbasava/nonhumans/di_cephproject/analyses/cephalopod_analyses/nov2024_fits/m.soc3.rda")
  108. ## sociality decapodiformes only----
  109. decadat <- read.csv("decadat.csv")
  110. m.socdec <- brm(bf(CNS.1 ~ mi(ML.1) + sociality.bin + WoS + benthic + depth.mean + (1|gr(phy.species,cov=cormat))) +
  111. bf(ML.1 | mi() ~ 1 + benthic + depth.mean + (1|gr(phy.species, cov=cormat))),
  112. prior = c(prior(normal(0,1), class = Intercept),
  113. prior(normal(0,0.5), class = b)),
  114. data=decadat,
  115. data2=list(cormat=cormat),
  116. backend="cmdstanr", cores=4)
  117. summary(m.socdec)
  118. save(m.socdec, file="/Users/kiranbasava/nonhumans/di_cephproject/analyses/cephalopod_analyses/ceph-brain-evolution/nov2024_fits/m.socdec.rda")
  119. # behavioral complexity----
  120. #TB's constrained imputation function
  121. constrained_imputation <- function(model, vars) {
  122. # Extract and edit Stan code
  123. scode <- capture.output(stancode(model))
  124. # Initialize imp_code as empty
  125. imp_code <- scode
  126. for (var in vars) {
  127. # Match brms var name
  128. brms_var <- gsub("[\\._]", "", var)
  129. stan_var <- paste0("Ymi_", brms_var)
  130. # Find lower and upper bounds from the data
  131. lower_bound <- min(model$data[[var]], na.rm = TRUE)
  132. upper_bound <- max(model$data[[var]], na.rm = TRUE)
  133. # Amend Stan code and set lower and upper bounds on the imputed variable
  134. imp_code <- gsub(paste0("vector[Nmi_", brms_var, "] ", stan_var, ";"),
  135. paste0("vector<lower=", lower_bound, ", upper=", upper_bound, ">[Nmi_", brms_var, "] ", stan_var, ";"),
  136. imp_code, fixed = TRUE)
  137. }
  138. # Replace and compile the model object with the amended Stan code
  139. attributes(model$fit)$CmdStanModel <- cmdstan_model(write_stan_file(imp_code))
  140. # Fit to data with modified model
  141. model_constrain <- update(model,
  142. cores = 4, chains = 4, iter = 8000,
  143. recompile = FALSE,
  144. control = list(adapt_delta = 0.95))
  145. return(model_constrain)
  146. }
  147. ## combined cognition----
  148. m.cog.empty <- brm(bf(CNS.1 ~ mi(ML.1) + mi(cog2) + benthic + articles.read + depth.mean + pos.latmean + (1|gr(phy.species,cov=cormat))) +
  149. bf(ML.1 | mi() ~ 1 + benthic + depth.mean + pos.latmean + (1|gr(phy.species,cov=cormat)))+
  150. bf(cog2 | mi() ~ 1 + benthic + articles.read + (1|gr(phy.species,cov=cormat))),
  151. family=gaussian,
  152. data=st.cephdat,
  153. data2=list(cormat=cormat),
  154. prior = c(prior(normal(0,1), class = Intercept),
  155. prior(normal(0,0.5), class = b)),
  156. backend="cmdstanr",
  157. chains = 0)
  158. m.cog.constrained <- constrained_imputation(model = m.cog.empty,
  159. vars = c("ML.1", "cog2"))
  160. summary(m.cog.constrained)
  161. save(m.cog.constrained, file="/Users/kiranbasava/nonhumans/di_cephproject/analyses/cephalopod_analyses/nov2024_fits/m.cog.rda")
  162. ## defense repertoire----
  163. m.def.empty <- brm(bf(CNS.1 ~ mi(ML.1) + mi(defense.repertoire) + articles.read + benthic + depth.mean + pos.latmean + (1|gr(phy.species,cov=cormat))) +
  164. bf(ML.1 | mi() ~ 1 + benthic + depth.mean + pos.latmean + (1|gr(phy.species,cov=cormat)))+
  165. bf(defense.repertoire | mi() ~ 1 + benthic + articles.read + (1|gr(phy.species,cov=cormat))),
  166. family=gaussian,
  167. data=st.cephdat,
  168. data2=list(cormat=cormat),
  169. prior = c(prior(normal(0,1), class = Intercept),
  170. prior(normal(0,0.5), class = b)),
  171. chains = 0,
  172. backend="cmdstanr")
  173. m.def.constrained <- constrained_imputation(model = m.def.empty, vars = "defense.repertoire")
  174. summary(m.def.constrained)
  175. save(m.def.constrained, file="/Users/kiranbasava/nonhumans/di_cephproject/analyses/cephalopod_analyses/nov2024_fits/m.def.rda")
  176. ## foraging repertoire----
  177. m.hunt.empty <- brm(bf(CNS.1 ~ mi(ML.1) + mi(foraging.repertoire) + articles.read + benthic + depth.mean + pos.latmean + (1|gr(phy.species,cov=cormat))) +
  178. bf(ML.1 | mi() ~ 1 + benthic + depth.mean + pos.latmean + (1|gr(phy.species,cov=cormat)))+
  179. bf(foraging.repertoire | mi() ~ 1 + benthic + articles.read + (1|gr(phy.species,cov=cormat))),
  180. family=gaussian,
  181. data=st.cephdat,
  182. data2=list(cormat=cormat),
  183. prior = c(prior(normal(0,1), class = Intercept),
  184. prior(normal(0,0.5), class = b)),
  185. chains=0,
  186. backend="cmdstanr")
  187. m.hunt.constrained <- constrained_imputation(model = m.hunt.empty,
  188. vars = c("ML.1", "foraging.repertoire"))
  189. summary(m.hunt.constrained)
  190. save(m.hunt.constrained, file="/Users/kiranbasava/nonhumans/di_cephproject/analyses/cephalopod_analyses/nov2024_fits/m.hunt.rda")
  191. #ecological richness----
  192. ## dietary breadth----
  193. m.diet.empty <- brm(bf(CNS.1 ~ mi(ML.1) + mi(diet.breadth) + articles.read + benthic + depth.mean + pos.latmean + (1|gr(phy.species,cov=cormat))) +
  194. bf(diet.breadth | mi() ~ 1 + mi(ML.1) + articles.read + benthic + depth.mean + pos.latmean + (1|gr(phy.species,cov=cormat))) +
  195. bf(ML.1 | mi() ~ 1 + benthic + depth.mean + pos.latmean + (1|gr(phy.species,cov=cormat))),
  196. family=gaussian,
  197. data=st.cephdat,
  198. data2=list(cormat=cormat),
  199. prior = c(prior(normal(0,1), class = Intercept),
  200. prior(normal(0,0.5), class = b)),
  201. chains = 0,
  202. backend="cmdstanr")
  203. m.diet.constrained <- constrained_imputation(model = m.diet.empty,
  204. vars = c("diet.breadth"))
  205. summary(m.diet.constrained)
  206. save(m.diet.constrained, file="/Users/kiranbasava/nonhumans/di_cephproject/analyses/cephalopod_analyses/ceph-brain-evolution/nov2024_fits/m.diet.rda")
  207. ## diet-benthic interaction----
  208. m.dhab.empty <- brm(bf(CNS.1 ~ mi(ML.1) + mi(diet.breadth)*benthic + depth.mean + pos.latmean + articles.read + (1|gr(phy.species,cov=cormat))) +
  209. bf(diet.breadth | mi() ~ 1 + mi(ML.1) + articles.read + benthic + depth.mean + pos.latmean + (1|gr(phy.species,cov=cormat))) +
  210. bf(ML.1 | mi() ~ 1 + benthic + depth.mean + pos.latmean + (1|gr(phy.species,cov=cormat))),
  211. family=gaussian,
  212. data=st.cephdat,
  213. data2=list(cormat=cormat),
  214. prior = c(prior(normal(0,1), class = Intercept),
  215. prior(normal(0,0.5), class = b)),
  216. chains=0,
  217. backend="cmdstanr", cores=4)
  218. m.dhab.constrained <- constrained_imputation(model = m.dhab.empty, vars = "diet.breadth")
  219. summary(m.dhab.constrained)
  220. save(m.dhab.constrained, file="/Users/kiranbasava/nonhumans/di_cephproject/analyses/cephalopod_analyses/nov2024_fits/m.dhab.rda")
  221. ## number of predator groups----
  222. m.preds.empty <- brm(bf(CNS.1 ~ mi(ML.1) + mi(predator.breadth) + depth.mean + benthic + articles.read + (1 | gr(phy.species, cov = cormat))) +
  223. bf(predator.breadth | mi() ~ 1 + mi(ML.1) + depth.mean + benthic + articles.read + (1 | gr(phy.species, cov = cormat))) +
  224. bf(ML.1 | mi() ~ 1 + benthic + depth.mean + (1 | gr(phy.species, cov = cormat))),
  225. family = gaussian,
  226. prior = c(prior(normal(0,1), class = Intercept),
  227. prior(normal(0,0.5), class = b)),
  228. data = st.cephdat,
  229. data2 = list(cormat = cormat),
  230. chains=0,
  231. backend = "cmdstanr", cores = 4)
  232. m.preds.constrained <- constrained_imputation(model = m.preds.empty, vars = "predator.breadth")
  233. summary(m.preds.constrained)
  234. 0.08/0.75
  235. save(m.preds.constrained, file="/Users/kiranbasava/nonhumans/di_cephproject/analyses/cephalopod_analyses/nov2024_fits/m.preds.rda")
  236. ## predators-benthic interaction----
  237. m.phab.empty <- brm(bf(CNS.1 ~ mi(ML.1) + mi(predator.breadth)*benthic + articles.read + depth.mean + pos.latmean + (1 | gr(phy.species, cov = cormat))) +
  238. bf(predator.breadth | mi() ~ 1 + mi(ML.1) + articles.read + benthic + depth.mean + pos.latmean + (1 | gr(phy.species, cov = cormat))) +
  239. bf(ML.1 | mi() ~ 1 + benthic + depth.mean + pos.latmean + (1 | gr(phy.species, cov = cormat))),
  240. family = gaussian,
  241. prior = c(prior(normal(0,1), class = Intercept),
  242. prior(normal(0,0.5), class = b)),
  243. data = st.cephdat,
  244. data2 = list(cormat=cormat),
  245. chains=0,
  246. backend = "cmdstanr", cores = 4)
  247. m.phab.constrained <- constrained_imputation(model = m.phab.empty, vars = "predator.breadth")
  248. summary(m.phab.constrained)
  249. save(m.phab.constrained, file="/Users/kiranbasava/nonhumans/di_cephproject/analyses/cephalopod_analyses/nov2024_fits/m.phab.rda")
  250. ## habitat binary----
  251. m.benth <- brm(bf(CNS.1 ~ mi(ML.1) + benthic + WoS + (1 | gr(phy.species, cov = cormat))) +
  252. bf(ML.1 | mi() ~ 1 + WoS + (1 | gr(phy.species, cov = cormat))),
  253. prior = c(prior(normal(0, 1), class = Intercept),
  254. prior(normal(0,0.5), class = b)),
  255. data = st.cephdat,
  256. data2 = list(cormat = cormat),
  257. iter = 8000, chains = 4,
  258. control = list(adapt_delta = 0.89),
  259. backend = "cmdstanr",
  260. cores = 4)
  261. summary(m.benth)
  262. save(m.benth, file="m.benth.rda")
  263. 0.58/0.75
  264. ## habitat 3 category----
  265. m.hab <- brm(bf(CNS.1 ~ mi(ML.1) + habitat3 + WoS + (1 | gr(phy.species, cov = cormat))) +
  266. bf(ML.1 | mi() ~ 1 + WoS + (1 | gr(phy.species, cov = cormat))),
  267. prior = c(prior(normal(0, 1), class = Intercept),
  268. prior(normal(0,0.5), class = b)),
  269. data = st.cephdat,
  270. data2 = list(cormat=cormat),
  271. iter = 8000, chains = 4,
  272. control = list(adapt_delta = 0.89),
  273. backend = "cmdstanr",
  274. cores = 4)
  275. summary(m.hab)
  276. save(m.hab, file="m.hab.rda")
  277. ## latitude range----
  278. m.latrange <- brm(bf(CNS.1 ~ mi(ML.1) + lat.range + benthic + WoS + (1 | gr(phy.species, cov = cormat))) +
  279. bf(ML.1 | mi() ~ 1 + lat.range + benthic + (1 | gr(phy.species, cov = cormat))),
  280. prior = c(prior(normal(0,1), class = Intercept),
  281. prior(normal(0,0.5), class = b)),
  282. data = st.cephdat,
  283. data2 = list(cormat=cormat),
  284. backend = "cmdstanr",
  285. iter=4000,
  286. cores = 4)
  287. summary(m.latrange)
  288. ## distance from equator----
  289. # rerunning August 2024 for distance from equator not mean
  290. m.eqdist <- brm(bf(CNS.1 ~ mi(ML.1) + eq.dist + benthic + WoS + (1 | gr(phy.species, cov = cormat))) +
  291. bf(ML.1 | mi() ~ 1 + pos.latmean + benthic + (1 | gr(phy.species, cov = cormat))),
  292. prior = c(prior(normal(0,1), class = Intercept),
  293. prior(normal(0,0.5), class = b)),
  294. data = st.cephdat,
  295. data2 = list(cormat=cormat),
  296. backend = "cmdstanr",
  297. iter=4000,
  298. cores = 4)
  299. summary(m.eqdist)
  300. #and that's still nothing
  301. save(m.eqdist, file="m.eqdist.rda")
  302. ## mean depth----
  303. m.meandepth <- brm(bf(CNS.1 ~ mi(ML.1) + depth.mean + benthic + WoS + (1 | gr(phy.species, cov = cormat))) +
  304. bf(ML.1 | mi() ~ 1 + (1 | gr(phy.species, cov = cormat))),
  305. prior = c(prior(normal(0,1), class = Intercept),
  306. prior(normal(0,0.5), class = b)),
  307. data = st.cephdat,
  308. data2 = list(cormat = cormat),
  309. iter = 8000, chains = 4,
  310. control = list(adapt_delta = 0.89),
  311. backend = "cmdstanr",
  312. cores = 4)
  313. summary(m.meandepth)
  314. save(m.meandepth, file="/Users/kiranbasava/nonhumans/di_cephproject/analyses/cephalopod_analyses/nov2024_fits/m.meandepth.rda")
  315. load(file="m.meandepth.rda")
  316. ## maximum depth----
  317. m.maxdepth <- brm(bf(CNS.1 ~ mi(ML.1) + depth.max + benthic + WoS + (1 | gr(phy.species, cov = cormat))) +
  318. bf(ML.1 | mi() ~ 1 + (1 | gr(phy.species, cov = cormat))),
  319. prior = c(prior(normal(0,1), class = Intercept),
  320. prior(normal(0,0.5), class = b)),
  321. data = st.cephdat,
  322. data2 = list(cormat = cormat),
  323. iter = 8000, chains = 4,
  324. control = list(adapt_delta = 0.89),
  325. backend = "cmdstanr",
  326. cores = 4)
  327. summary(m.maxdepth)
  328. save(m.maxdepth, file="/Users/kiranbasava/nonhumans/di_cephproject/analyses/cephalopod_analyses/nov2024_fits/m.maxdepth.rda")
  329. 10/75 #instead of -0.22
  330. ## minimum depth----
  331. m.mindepth <- brm(bf(CNS.1 ~ mi(ML.1) + depth.min + benthic + WoS + (1 | gr(phy.species, cov = cormat))) +
  332. bf(ML.1 | mi() ~ 1 + (1 | gr(phy.species, cov = cormat))),
  333. prior = c(prior(normal(0,1), class = Intercept),
  334. prior(normal(0,0.5), class = b)),
  335. data = st.cephdat,
  336. data2 = list(cormat = cormat),
  337. iter = 8000, chains = 4,
  338. control = list(adapt_delta = 0.89),
  339. backend = "cmdstanr",
  340. cores = 4)
  341. summary(m.mindepth)
  342. save(m.mindepth, file="/Users/kiranbasava/nonhumans/di_cephproject/analyses/cephalopod_analyses/nov2024_fits/m.mindepth.rda")
  343. -0.17/0.75 #instead of -0.14
  344. ## benthic*depth----
  345. m.maxdb <- brm(bf(CNS.1 ~ mi(ML.1) + depth.max*benthic + WoS + (1 | gr(phy.species, cov = cormat))) +
  346. bf(ML.1 | mi() ~ 1 + (1 | gr(phy.species, cov = cormat))),
  347. prior = c(prior(normal(0,1), class = Intercept),
  348. prior(normal(0,0.5), class = b)),
  349. data = st.cephdat,
  350. data2 = list(cormat = cormat),
  351. iter = 8000, chains = 4,
  352. control = list(adapt_delta = 0.89),
  353. backend = "cmdstanr",
  354. cores = 4)
  355. summary(m.maxdb)
  356. save(m.maxdb, file="/Users/kiranbasava/nonhumans/di_cephproject/analyses/cephalopod_analyses/nov2024_fits/m.maxdb.rda")
  357. m.mindb <- brm(bf(CNS.1 ~ mi(ML.1) + depth.min*benthic + WoS + (1 | gr(phy.species, cov = cormat))) +
  358. bf(ML.1 | mi() ~ 1 + (1 | gr(phy.species, cov = cormat))),
  359. prior = c(prior(normal(0,1), class = Intercept),
  360. prior(normal(0,0.5), class = b)),
  361. data = st.cephdat,
  362. data2 = list(cormat = cormat),
  363. iter = 8000, chains = 4,
  364. control = list(adapt_delta = 0.89),
  365. backend = "cmdstanr",
  366. cores = 4)
  367. summary(m.mindb)
  368. save(m.mindb, file="/Users/kiranbasava/nonhumans/di_cephproject/analyses/cephalopod_analyses/nov2024_fits/m.mindb.rda")
  369. m.meandb <- brm(bf(CNS.1 ~ mi(ML.1) + depth.mean*benthic + WoS + (1 | gr(phy.species, cov = cormat))) +
  370. bf(ML.1 | mi() ~ 1 + (1 | gr(phy.species, cov = cormat))),
  371. prior = c(prior(normal(0,1), class = Intercept),
  372. prior(normal(0,0.5), class = b)),
  373. data = st.cephdat,
  374. data2 = list(cormat = cormat),
  375. iter = 8000, chains = 4,
  376. control = list(adapt_delta = 0.89),
  377. backend = "cmdstanr",
  378. cores = 4)
  379. summary(m.meandb)
  380. save(m.meandb, file="/Users/kiranbasava/nonhumans/di_cephproject/analyses/cephalopod_analyses/nov2024_fits/m.meandb.rda")
  381. ## depth categories----
  382. m.depthcat <- brm(bf(CNS.1 ~ mi(ML.1) + depth_cat + benthic + WoS + (1 | gr(phy.species, cov = cormat))) +
  383. bf(ML.1 | mi() ~ 1 + depth_cat + benthic + (1 | gr(phy.species, cov = cormat))),
  384. prior = c(prior(normal(0,1), class = Intercept),
  385. prior(normal(0,0.5), class = b)),
  386. data = st.cephdat,
  387. data2 = list(cormat=cormat),
  388. iter = 8000, chains = 4,
  389. control = list(adapt_delta = 0.89),
  390. backend = "cmdstanr",
  391. cores = 4)
  392. summary(m.depthcat)
  393. save(m.depthcat, file="m.depthcat.rda")
  394. #ASR and signal----
  395. library(phytools)
  396. library(mice)
  397. getwd()
  398. #decomposition of phylogenetic distance matrix into orthogonal vectors (PVRs)
  399. phylo.vectors = PVR::PVRdecomp(cephtreeMCC)
  400. cephdat <- read.csv("cephdat.csv")
  401. ML.dat <- cephdat[c("phy.species", "CNS.1", "ML.1")]
  402. ML.dat$CNS.1 <- log(ML.dat$CNS.1)
  403. ML.dat$ML.1 <- log(ML.dat$ML.1)
  404. ML.dat <- complete(mice(ML.dat)) #imputation
  405. #calculate EQ
  406. ML.dat$EQ <- ML.dat$CNS.1/ML.dat$ML.1
  407. logEQ <- as.vector(ML.dat$EQ)
  408. names(logEQ) <- ML.dat$phy.species
  409. #ancestral state reconstruction and plot
  410. ASR <- contMap(cephtreeMCC, logEQ, plot=FALSE)
  411. length(ASR$cols)
  412. ASR$cols[1:1001]<-colorRampPalette(c("#feba2c","#d6556d","#2a0593"))(1001)
  413. plot(ASR)
  414. # Plot the mapped characters with the new colors
  415. plot(ASR, type="fan", outline=FALSE, legend = 0.7*max(nodeHeights(cephtreeMCC)),
  416. fsize = c(0.5, 0.7))
  417. save(ASR, file="ASR.rda")
  418. load(file="ASR.rda")
  419. plot(ASR)

consensus_analyses.R at commit a0ed371, no license · at the source

Overview

Authors: Kiran Basava1,2, Theiss Bendixen3, Alexander Leonhard3, Nicole Lauren George4, Zoé Vanhersecke4, Joshua Omotosho4, Jennifer Mather5, Michael Muthukrishna4,6
  1. University of Oxford, Oxford, UK
  2. University of Arizona, Tucson, CA, USA
  3. Aarhus University, Aarhus, Denmark
  4. London School of Economics and Political Science, London, UK
  5. University of Lethbridge, Lethbridge, AB, Canada
  6. New York University, New York, NY, USA
Institutions: University of Arizona (United States); University of Oxford (United Kingdom); Aarhus University (Denmark); London School of Economics and Political Science (United Kingdom); University of Lethbridge (Canada); New York University (United States)
Journal: iScience, volume 29, issue 7, article 116324
Dates: received 14 February 2025; accepted 26 May 2026; published online 1 July 2026
Type: Research article · Language: English
License: CC BY
Identifiers: DOI 10.1016/j.isci.2026.116324 · PMID 42422194 · PMCID PMC13343137 · OpenAlex W7166728191
Open access: gold, a free copy (OpenAlex)
Status: code verified
Categories: other (organism)
Methods: Smoothing, state filtering, decompositions, Statistics
Keywords: zoology, evolutionary biology, phylogeny
Topic: Cephalopods and Marine Biology (Ecology, Evolution, Behavior and Systematics, Agricultural and Biological Sciences), according to OpenAlex
Citations: cited by 1 paper (Europe PMC); 110 references in the paper

Abstract

Social factors have been argued to be the main selection pressure for the evolution of large brains and complex behavior, but many cephalopods live largely solitary, semelparous, short lives. This suggests that the large brains found in cephalopods are not the result of social selection pressures. Here, we derive specific, preregistered predictions from the “Asocial Brain Hypothesis” (ABH; an untested extension of the cultural brain hypothesis formal model), and evaluate those predicted associations using a new comparative dataset on brain size alongside social, ecological, and life history factors. Consistent with the ABH and other hypotheses predicting that ecological factors should be the primary selection pressure with larger brains in more calorie-rich complex ecologies, we find that shallower and benthic (seafloor) habitats are associated with larger brain sizes, and that measures of sociality are not. Our findings are not interpreted as causal, but are consistent with ecological hypotheses for brain evolution.

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

Repositories

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

kcbasava/ceph-brain-evolution

License: none: the authors keep all their rights
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Commit: a0ed3711e8999c7bf390304926617e957fd77483, 6 February 2025
Languages: R (4)
Size: 53 files, 4 scripts
Software Heritage: not archived
Found in: the text, “Results”
Holds: README
Not found: license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: brms (3 files), tidyverse (3 files), Stan (2 files), ggplot2 (1 file), patchwork (1 file)
Availability: 1 check, the latest on 27 September 2026: the link answers
  • 27 September 2026: the link answers
5 files

drepanosaur/ceph-brain-evolution

License: none: the authors keep all their rights
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Commit: a0ed3711e8999c7bf390304926617e957fd77483, 6 February 2025
Languages: R (4)
Size: 53 files, 4 scripts
Software Heritage: not archived
Found in: “Data and code availability”
Holds: README
Not found: license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: brms (3 files), tidyverse (3 files), Stan (2 files), ggplot2 (1 file), patchwork (1 file)
Availability: 1 check, the latest on 27 September 2026: the link answers
  • 27 September 2026: the link answers
5 files

kcbasava/ceph-brain-evolution.•All

License: none: the authors keep all their rights
State: the link is dead, verified on 27 September 2026
Evidence: found in the paper
Software Heritage: not archived
Found in: “Data and code availability”
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Availability: 1 check, the latest on 27 September 2026: the link is dead
  • 27 September 2026: the link is dead

kcbasava/ceph-brain-evolution.•Any

License: none: the authors keep all their rights
State: the link is dead, verified on 27 September 2026
Evidence: found in the paper
Software Heritage: not archived
Found in: “Data and code availability”
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Availability: 1 check, the latest on 27 September 2026: the link is dead
  • 27 September 2026: the link is dead

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

Tracing map

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

What the map holds:

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

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

Data

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

Data and code availability

• All data have been deposited on GitHub and are publicly available as of the date of publication at www.github.com/kcbasava/ceph-brain-evolution (http://www.github.com/drepanosaur/ceph-brain-evolution). • All original code has been deposited on GitHub and is publicly available as of the date of publication at www.github.com/kcbasava/ceph-brain-evolution (http://www.github.com/drepanosaur/ceph-brain-evolution). • Any additional information required to reanalyze the data reported in this paper is available from the lead contact upon request.

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

Recorded: type, language, journal, volume, issue, pages, dates, 8 authors, 3 keywords, 1 funder, 72 references.

Cite

This paper

Basava, K., Bendixen, T., Leonhard, A., George, N. L., Vanhersecke, Z., Omotosho, J., Mather, J., & Muthukrishna, M. (2026). Ecological not social factors explain brain size in cephalopods. iScience, 29(7), 116324. https://doi.org/10.1016/j.isci.2026.116324

BibTeX

@article{basava2026ecological,
author = {Basava, Kiran and Bendixen, Theiss and Leonhard, Alexander and George, Nicole Lauren and Vanhersecke, Zoé and Omotosho, Joshua and Mather, Jennifer and Muthukrishna, Michael},
title = {{Ecological not social factors explain brain size in cephalopods}},
journal = {iScience},
year = {2026},
month = jul,
volume = {29},
number = {7},
pages = {116324},
publisher = {Elsevier},
issn = {2589-0042},
doi = {10.1016/j.isci.2026.116324},
url = {https://doi.org/10.1016/j.isci.2026.116324},
pmid = {42422194},
pmcid = {PMC13343137}
}

RIS

TY - JOUR
AU - Basava, Kiran
AU - Bendixen, Theiss
AU - Leonhard, Alexander
AU - George, Nicole Lauren
AU - Vanhersecke, Zoé
AU - Omotosho, Joshua
AU - Mather, Jennifer
AU - Muthukrishna, Michael
TI - Ecological not social factors explain brain size in cephalopods
T2 - iScience
J2 - iScience
PY - 2026
DA - 2026/07/01
VL - 29
IS - 7
SP - 116324
SN - 2589-0042
PB - Elsevier
DO - 10.1016/j.isci.2026.116324
UR - https://doi.org/10.1016/j.isci.2026.116324
LA - en
ER -

CSL-JSON

{
"id": "10.1016/j.isci.2026.116324",
"type": "article-journal",
"title": "Ecological not social factors explain brain size in cephalopods",
"container-title": "iScience",
"author": [
{
"family": "Basava",
"given": "Kiran"
},
{
"family": "Bendixen",
"given": "Theiss"
},
{
"family": "Leonhard",
"given": "Alexander"
},
{
"family": "George",
"given": "Nicole Lauren"
},
{
"family": "Vanhersecke",
"given": "Zoé"
},
{
"family": "Omotosho",
"given": "Joshua"
},
{
"family": "Mather",
"given": "Jennifer"
},
{
"family": "Muthukrishna",
"given": "Michael"
}
],
"container-title-short": "iScience",
"volume": "29",
"issue": "7",
"page": "116324",
"DOI": "10.1016/j.isci.2026.116324",
"PMID": "42422194",
"PMCID": "PMC13343137",
"ISSN": "2589-0042",
"publisher": "Elsevier",
"URL": "https://doi.org/10.1016/j.isci.2026.116324",
"language": "en",
"issued": {
"date-parts": [
[
2026,
7,
1
]
]
}
}

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.7554/elife.107393 [code]
Chromosome-scale genome assembly of the European common cuttlefish &lt;i&gt;Sepia officinalis&lt;/i&gt;.
Journal: eLife
In common: ggplot2, tidyverse, other, 3 references
[2] doi:10.1038/s42003-026-10957-8 [code]
Brain defence by the extracellular matrix protein Cochlin.
Journal: Communications biology
In common: Stan, brms, patchwork, 2 other tools
[3] doi:10.1371/journal.pone.0355165 [code]
Pupillary dynamics during hands-off L2 driving and transitions of control under high cognitive load.
Journal: PloS one
In common: Stan, brms, patchwork, 2 other tools
[4] doi:10.1162/opmi.a.372 [code]
Broadening the Agent Preference Hypothesis Through Experiencers: Eye-Tracking and EEG Evidence of Proto-Agents and Proto-Patients.
Journal: Open mind : discoveries in cognitive science
In common: Stan, brms, patchwork, 2 other tools
[5] doi:10.1016/j.isci.2026.116747 [code]
Age and loneliness relate to reduced trust learning and alterations in amygdala function.
Journal: iScience
In common: Stan, brms, patchwork, 2 other tools
[6] doi:10.1162/nol.a.266 [code]
The Role of the Anterior Temporal Lobe in Reading: An HD-tDCS Study.
Journal: Neurobiology of language (Cambridge, Mass.)
In common: Stan, brms, patchwork, 2 other tools
[7] 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: Stan, brms, patchwork, 2 other tools
[8] doi:10.1162/imag.a.1258 [code]
Non-specific increase in alpha power during a neurofeedback session targeting its downregulation.
Journal: Imaging neuroscience (Cambridge, Mass.)
In common: Stan, brms, patchwork, 2 other tools
[9] doi:10.1038/s44271-026-00431-w [code]
Alpha power increases spontaneously during a neurofeedback session.
Journal: Communications psychology
In common: Stan, brms, patchwork, 2 other tools
[10] doi:10.1111/jne.70257 [code]
A symmetric systemic challenge elicits a right-biased response mediated by vasopressin signaling.
Journal: Journal of neuroendocrinology
In common: Stan, brms, patchwork, 1 other tool

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.