Code to Reproduce Dunhill et al analysis of secondary extinctions in Toarcian food webs, submitted to Nature Ecology and Evolution for review.
The project assumes the user has R and RStudio installed.
To initiate the project, after cloning/downloading the file containing the Scripts and Data and project file, the user should double click the project file dunhill_toarcian.Rproj.
Details for each file are provided below.
The reader/replicator/referee can start with network generation, scenario modelling or plotting/analysis. The data from each of those steps is provided and the use of read_csv() or load() data is embedded in each stage to acquire the previous stages data.
- ToarcianWebs_Guild_May2021.RData - core input data of Toarcian Network
- wrkWebs_allSeqs.RData - output from GenerateExintctionSequences (can be recreated with set.seed()) and used (loaded) in AnalyseToarcianNetworks.
- metrics_time2.csv - details among times slices on network metrics
- metrics_time.csv - details among times slices on network metricspfwim.R - This file contains the functions necessary to construct food webs using Shaw et al (https://www.biorxiv.org/content/10.1101/2024.01.30.578036v1) method described in the MS. It also contains bespoke functions to calcuate several metrics and motifs. This is a self contained subset of the PFIM code base and does not require the package in that pre-print.GenerateExtinctionSequences.R is the primary tool to generate the secondary extinction scenarios from the networks. The code -
cheddar's function RemoveNodes(); robustness_gradient.R - function to cacluate robustness following generalised method from Jonsson et al Oikos 124: 446–457, 2015plot_3d_foodwebs_orig.R - Shaw et al (https://www.biorxiv.org/content/10.1101/2024.01.30.578036v1) functions to plot food webs in 3D.MakeCompositeFigure.R for final figure.1.AnalyseToarcianNetworks.R - estimates several structural metrics, motifs and True Skill Statistic from secondary extinction scenarios and the outcome networks.
1.guild network metric plotting.R accesses combined data generated by GuildWebsBuildPlotAnalyse.R in Reference-Scratch
1.MakeCompositeFigure.R - uses patchwork in R to combine figures
1.RobustnessTest_FineScale.R - uses robustness_gradient.R above to generate analysis and Fig 4.