Code and data for analyzing the evolution of reproductive accessory glands across fishes. Specifically, we test whether the evolution of accessory glands is driven by other reproductive traits, namely parental care and spawning mode.
A recent version of R (i.e. 4.2.0 or higher) and updating your packages is strongly recommended (update.packages()
). You will probably need to have compilation tools installed on your system, for installing R packages from source.
All the code should run, but compiling everything (including PDF version of the supplementary material) needs a few additional tools: a working LaTeX installation, the optipng program, ...
if (!require("remotes")) install.packages("remotes")
detach("package:remotes")
source("R/pkg_install.R")
install_pkgs()
These instructions will run all the code and build the supplementary material.
To run single-threaded:
library(targets)
tar_make()
Or multi-threaded:
library(targets)
library(future)
plan("multicore")
tar_make_future()
make all
if you havemake
installed.
To load existing products (e.g. for debugging):
targets::tar_load(everything())
To visualize the workflow:
targets::tar_visnetwork()
- figure 1 (flow diagram):
mk_flowfig.R
(needs LaTeX, imagemagick for PDF to PNG conversion) - figure 2 (phylogeny): used
diversitree
package,phytools
for stochastic mapping; overlaid in PowerPoint - figure 3: run
figures.R
- implemented in the targets package
- for different cases (data, settings, etc.), we need to be able to:
- fit a basic
corHMM
model - possibly: compute Wald and/or likelihood profile confidence intervals
- specify priors and do MCMC computation
- plot/interpret results
- fit a basic
ag_bayesdiag.rmd
: Bayes diagnostics for MCMC fits (link)ag_supp.rmd
: supplementary material (link)ag_tech.rmd
: tech overview document (????)ag_model.rmd
: mostly obsoletecorHMM.bib
: bibliography for paper/supp
contr*.csv
: definitions of contrast matrices for different cases. Usesource("R/utils.R"); tar_load(<R_object>); iplot(<R_object>)
to view them.contr_full.csv
: contrast matrix for full (24-parameter) model (R objectcontrast_mat_full
)contr.csv
: 12-parameter model, including contrasts for net gain of AGs (gain - loss) (R objectcontrast_mat_0
)contr_invertible.csv
: 12-parameter model with gain, loss, and including simple (1-to-1) contrasts for transitions in spawning mode and male care
accessTree.R
: extract phylogenies viafishtree
package, given datacleanTraitData.csv
: trait data in full formatbinaryTraitData.csv
: trait data collapsed to binary (0/1) for traitstreeBlock.rds
: tree block (100 imputed trees)treeSingle.rds
: phylogeny only for complete genetic datadataReferencecs.csv
: list of references for each speciesreferenceList.rtf
: full reference list corresponding to the above csv
bayestraits
: explorations ofBayesTraits
test_btw.R
: preliminary tests ofbtw
package (BayesTraits R interface)BTrefs.xls
: papers using BayesTraits with some added information about what priors were used in the papers, how inference was done, etc..
old
: Miscellaneous old explorations etc.twotraits
: code for two-trait analyses (comparisons with LE's thesis)
google drive link
BTrefs.xls
has all articles from 2020-2022 referencing Pagel & Meade (99 articles)
Linux (from source, V3)
git clone ://github.com/bbolker/BayesTraitsV3
cd BayesTraitsV3/src
## sudo apt install libnlopt-dev
make threaded
mv BayesTraitsv3_threaded ../../BayesTraitsV3
from binary:
download.file("http://www.evolution.reading.ac.uk/BayesTraitsV4.0.0/Files/BayesTraitsV4.0.0-Linux.tar.gz", destfile = "btv4.tgz")
untar("btv4.tgz")
unlink("btv4.tgz")
test:
library("btw")
bayestraits(data = primate.discrete1,
tree = primate.tree100,
command = c("1", "1", "run"))
git clone git@github.com:bbolker/btw.git