DOI: 10.5061/dryad.wstqjq301
title: Drivers of metacommunity dynamics in river-floodplain fish: A path modeling approach

description: Metacommunity theory offers a compelling framework for understanding the
 processes that govern biodiversity patterns across space and time. Yet, a
 persistent challenge remains: integrating the wide array of ecological
 drivers into a unified model using observational data from complex,
 dynamic ecosystems. In this study, we present a novel, process-explicit
 path modelling approach that bridges recent theoretical advances in
 metacommunity ecology with empirical data. Focusing on fish communities in
 the floodplains of the Danube River, we leverage environmental DNA (eDNA)
 metabarcoding to characterize community composition across a
 spatio-temporal network of sites. We partition beta diversity into its
 species replacement and richness difference components and apply
 structural equation modelling to evaluate the relative influence of
 multiple ecological drivers—including spatial and temporal dispersal,
 demographic stochasticity, abiotic filtering and interspecific
 interactions. Our results reveal that river-floodplain fish
 metacommunities are shaped by a complex web of interacting processes.
 Notably, we find that species replacement is primarily driven by spatial
 distance and environmental filtering, while richness differences are more
 influenced by biotic interactions and community size. Lateral hydrological
 connectivity emerged as a pivotal landscape feature, governing beta
 diversity both directly and indirectly through its modulation of local
 environmental conditions. This connectivity acted as a structural conduit,
 mediating dispersal, environmental heterogeneity, and biotic interactions.
 By disentangling the contributions of multiple processes, our model
 underscores the dominant role of spatial structuring and abiotic filtering
 over temporal dynamics and biotic interactions in shaping metacommunity
 assembly. The model also demonstrates improved explanatory power and
 stronger model fit, outperforming previous studies. These findings
 underscore the need for integrative frameworks that consider the
 simultaneous influence of multiple ecological processes, particularly in
 highly dynamic systems like river-floodplains. Our conceptual and
 modelling approach advances metacommunity theory by offering a robust,
 data-driven means to assess complex assembly mechanisms and by emphasizing
 the critical role of connectivity and habitat complementarity in
 sustaining biodiversity within dynamic landscapes.
description: # Drivers of metacommunity dynamics in river-floodplain fish: A path
 modeling approach Dataset DOI:
 [10.5061/dryad.wstqjq301](10.5061/dryad.wstqjq301) ## Description of the
 data and file structure ### Project Overview This project processes and
 transforms pairwise site data from lake ecosystems for ecological
 analysis, focusing on environmental filtering, demographic stochasticity,
 patch dynamics, interspecific interactions, and beta-diversity components.
 The workflow covers data preparation, transformation, standardization, and
 conversion to symmetric matrices, producing an RData file ready for
 Structural Equation Modeling (SEM) and other downstream analyses. ###
 Workflow Summary 1. **Data preparation** — Pairwise site-time dataset and
 reference metadata. 2. **Data transformation** — Long-to-wide conversion,
 skewness check, variable transformation, and standardization. 3. **Matrix
 generation** — Conversion of variables into symmetric distance matrices.
 4. **Statistical analysis** — SEM and permutation-based path analysis to
 quantify ecological process contributions. 5. **Output generation** —
 Final SEM results stored in RData format. ### Data Notes * All variables
 in the pairwise dataset are expressed as **differences** or **similarity
 indices** between two site-time combinations. * Reference metadata (e.g.,
 site IDs, sampling dates) is provided for interpretation but not directly
 used in analyses. * Outputs are organized to keep **data processing** and
 **analysis** steps modular, enabling reproducibility and easier review. ##
 File Descriptions ### 1. Pairwise_Site_Data_Raw.csv This dataset contains
 pairwise observations between sampling sites and occasions, used as input
 for SEM analysis. | **Column name** | **Description** | |
 :------------------ |
 :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `Site1`, `Site2` | Site-time codes for the two sites in the pair. Codes follow the format `AT_##_##` or `HU_##_##`, where the prefix denotes the country (AT = Austria, HU = Hungary), the first number is the site number, and the second number is the sampling occasion. | | `tax_total_df` | Pairwise beta diversity index (total dissimilarity in community composition based on relative abundance). | | `tax_repl_df` | Beta diversity component representing species replacement. | | `tax_rich_df` | Beta diversity component representing richness differences. | | `abundance_df` | Mean community size (average number of fish DNA copies per unit water volume between the two sites). | | `abundance_dist_df` | Absolute difference in community size between the two sites. | | `CHP1_df` | Difference in chemical properties (first principal component score from PCA). | | `LUP1_df` | Difference in land use composition within 500 m buffer (first principal component score from PCA). | | `PHP1_df` | Difference in physical habitat characteristics (first principal component score from PCA). | | `MAP1_df` | Difference in hydrophyte coverage (first principal component score from PCA). | | `RPP1_df` | Difference in riparian coverage (first principal component score from PCA). | | `SES_corQ_df` | Difference in abundance‐weighted species association strength, derived from residual correlation patterns in joint species distribution models (HMSC). | | `dry_df` | Difference in proportion of drying period (% of days per year dry). | | `LHC_df` | Difference in lateral hydrological connectivity (% of days per year connected to main channel). | | `regime_df` | Difference in water level. | | `volume_df` | Difference in estimated waterbody volume (km² × m). | | `distance_df` | Streamline distance between sites (km). | | `time_df` | Absolute time distance (days since study start). | | `month_df` | Cyclic time distance (day of year difference). | **Note:** All variables are expressed as pairwise differences or similarity indices between two site-time combinations, enabling the analysis of spatial, temporal, and environmental factors shaping community composition. ### 2. Site_Time.csv A reference table describing the mapping between site/time codes used in `Pairwise_Site_Data_Raw.csv` and their actual locations and sampling dates. * **Column 1 – Site:** Site IDs, ranging from `AUT1` to `AUT15` (Austria) and `HUN1` to `HUN15` (Hungary). * **Column 2 – Country:** Country names corresponding to site codes (`Austria` = AUT, `Hungary` = HUN). * **Columns 3–13 – Time1 to Time11:** Sampling dates (`YYYY-MM-DD`) for up to eleven sampling occasions per site. Missing values are indicated by `NA`. **Relationship to Pairwise_Site_Data_Raw.csv** In `Pairwise_Site_Data_Raw.csv`, site-time codes follow the pattern `AT_01_01` or `HU_07_08`: * Prefix (`AT` or `HU`) is derived from the country code (`AUT` or `HUN`). * The first number is the site number (matching the numeric part of the `Site` column in `Site_Time.csv`). * The second number is the occasion number (matching the relevant `Time#` column in `Site_Time.csv`). This file is **not used directly** in the analysis but serves as metadata to interpret the site and time identifiers in the pairwise dataset. ### 3. Function_Vector_to_Matrix.R Contains a wrapper function `convert_to_symmetric_matrix` that converts a long-format pairwise dataframe into a symmetric matrix. **Functionality includes:** * Transforming long-format data into wide-format * Optionally adding a new column at the beginning and a new row at the end * Symmetrizing the matrix and setting the diagonal to 0 This function is called within `Convert_Pairwise_to_Matrix.R` to achieve one-step matrix conversion. ### 4. Convert_Pairwise_to_Matrix.R An R script that processes `Pairwise_Site_Data_Raw.csv` and performs the following tasks: 1. Computes skewness for each variable column and chooses the appropriate transformation/standardization 2. Standardizes each variable 3. Calls `convert_to_symmetric_matrix` to convert each variable into a symmetric matrix 4. Generates distance matrices for all ecological and environmental variables Running this script produces `All_Variables_Standardized_Matrix_Distance.RData` for downstream analyses. ### 5. All_Variables_Standardized_Matrix_Distance.RData Output from the `Convert_Pairwise_to_Matrix.R` script, containing standardized symmetric matrices, including: * Environmental filtering variables (e.g., `CHP1`, `PHP1`, `MAP1`, etc.) * Demographic stochasticity variables (e.g., `abundance`) * Patch dynamics and beta-diversity metrics * Interspecific interaction indices (e.g., SES correlation matrices) The RData file is provided separately to keep **data processing** and **data analysis** stages modular. ### 6. Beta_Components_SEM.R An R script that performs SEM to quantify the contributions of different ecological processes to beta-diversity and its components (total, replacement, richness difference). **Main steps:** 1. Prepare the SEM dataframe from `All_Variables_Standardized_Matrix_Distance.RData` 2. Build matrices for permutation-based SEM 3. Define SEM models incorporating environmental filtering, demographic stochasticity, patch dynamics, spatial/temporal dispersal, and interspecific interactions 4. Run SEM and permutation-based path analysis 5. Conduct variance partitioning by sequentially removing predictor groups (patch, environment, spatial, interaction, community size, temporal) and calculating changes in R² 6. Save final results to `SEM_Results.RData` ### 7. Permutation_Based_PathAnalysis.R Contains a function implementing permutation-based path analysis for matrix SEM, adapted from: * Fourtune et al. (2018) *The American Naturalist*, 191(4), 491–508 * Jabot et al. (2020) *Ecology Letters*, 23(9), 1330–1339 This function is called within `Beta_Components_SEM.R` to test the significance of SEM path coefficients in a distance-matrix framework. ### 8. SEM_Results.RData Final output from `Beta_Components_SEM.R`, containing SEM results and permutation test outputs. Provided for direct inspection without re-running computationally intensive permutation analyses. ## Reproducibility The following sequence reproduces all analyses from raw pairwise data to final SEM results: 1. **Prepare data files** * Ensure `Pairwise_Site_Data_Raw.csv` and `Site_Time.csv` are available in the working directory. 2. **Convert pairwise data to symmetric matrices** ``` source("Function_Vector_to_Matrix.R") source("Convert_Pairwise_to_Matrix.R") ``` This produces `All_Variables_Standardized_Matrix_Distance.RData`. 3\. **Run Structural Equation Modeling** ``` source("Beta_Components_SEM.R") ``` This uses permutation-based path analysis (via `Permutation_Based_PathAnalysis.R`) and generates `SEM_Results.RData`. 4\. **Inspect results** Load `SEM_Results.RData` directly to explore SEM outputs without re-running the computational steps. **Note:** This workflow is fully contained within the provided scripts and datasets, requiring no external raw field data access.