Title: Trait-space disparity in fish communities spanning 380 million years from the Late Devonian to present
In this study, we compare trait space of modern and Devonian fish communities to test whether species have dealt with their environment using similar strategies through time. Fish trait data was collected from databases, scientific literature, photographs, and expert opinion. Missing data was inferred using multiple imputation. The complete trait data set was then used to calculate Gower distances, quantifying differences between fish species in trait space. Principal coordinate analysis was applied to these Gower distances to ordinate species in lower dimensional space, and the species’ coordinates from the PCoA analysis were used to calculate functional diversity metrics, including: functional richness, functional nearest neighbour, functional specialisation, distance between community trait space centroids, and overlap between community trait spaces (Jaccard Index). The data and R code for replicating our analyses are provided in this repository. In the code, search for ‘###’ to find lines where file paths need to be specified/updated. The code files are numbered in the order they should be run.
Repository Structure
Data Folder This folder contains five subfolders:
- taxonomy/
- Contains an Excel file (.xlsx) with taxonomic information for the Devonian fish species.
- Devonian_fish_traits/
- Contains an Excel file (.xlsx) of Devonian fish traits, excluding traits inferred through multiple imputation.
- modern_fish_traits_RDSs/
- Contains RDS files of species traits for each modern community.
- Devonian_fish_traits_RDS/
- Contains an RDS file with the Devonian species' traits, including imputed data.
- data_for_plots/
- Contains RDS files produced by the code (below) and used to generate the study’s figures.
Code Folder This folder contains five subfolders, organized by the specific steps of the analysis:
- 1_multiple_imputation/
Contains one file:
- 1_missForest_taxonomyHiGitHub.R: Imputes missing trait data for Devonian fish.
- 2_3_tidy_data/
Contains two files:
- 2_Devonian_combine_and_tidy_modern_RDS_files.R: Tidies the modern fish data.
- 3_Devonian_tidy_Gogo_Miguasha.R: Tidies the Devonian fish data.
- 4_5_6_mFD/
Contains four files:
- 4_gawdis_and_mFD_allSP.R: Calculates Gower distances, applies PCoA, and computes community functional diversity metrics (functional richness, nearest neighbour, specialization, evenness, divergence).
- 5_gawdis_and_mFD_NullModel.R: Performs the same calculations as 4_gawdis_and_mFD_allSP.R, but build null models to calculate standardized effect sizes.
- 5b_gawdis_and_mFD_NullModel_SUPPLEMENTARY_BALANCED.R: Performs the same calculations as 5_gawdis_and_mFD_NullModel.R but only uses trait combinations that resulted in a balanced distribution when calculating Gower distances.
- 6_barchart_OnePanel.R: Plots the functional diversity metrics calculated in 4_gawdis_and_mFD_allSP.R and 5_gawdis_and_mFD_NullModel.R.
- 7_8_hypervolume/
Contains two files:
- 7_Hypervolumes_fixedBandwidthsMean_JaccardSplit.R: Uses PCoA coordinates to fit hypervolumes describing each community’s trait space and calculates distances between trait space centroids and overlap (Jaccard Index).
- 7b_Hypervolumes_fixedBandwidths_dataForPlots_and plot versus global_SUPPLEMENTRY.R: Build hypervolumes and make plots of each community's trait space versus the global trait space.
- 8_combine_heatmaps_and_within_vs_between.R: Plots the hypervolume results as heatmaps and within versus between violin plot.
- 8b_combine_heatmaps_and_within_vs_between_TurnoverNestedness_SUPPLEMENTARY.R: decomposes differences in Jaccard index due to turnover versus nested, and builds heatmaps and violin plots for both.
- 9_traits_by_site/
Contains one file:
- 9_plot_traits_by_sites_updated2.R: Plots the distribution of traits across the two Devonian and six modern communities.