DOI: 10.5061/dryad.95x69p8sf
title: Extinction and ecosystem function debt across dispersal rate and behavior in a heterogeneous metacommunity model

description: Habitat destruction causes “extinction debt” and is also thought to
 produce ecosystem function debt, but the theory of their magnitude and
 nature is limited. Heterogeneous landscapes are fundamental to the
 maintenance of species richness and ecosystem function, whilst directed or
 undirected dispersal behavior, such as dispersal of seeds by animals or by
 the wind, is also important, especially after habitat destruction. We
 therefore consider extinction and ecosystem function debt under different
 dispersal rates and behaviors in heterogeneous landscapes. In this study,
 we use a classic heterogeneous metacommunity model to capture the dynamics
 of competing species in local patches linked by dispersal and varying
 environmental conditions. We remove one patch at a time, and measure
 extinction debt and ecosystem function debt by the number / proportion of
 delayed extinctions and the amount of biomass change, respectively. Then,
 we show: 1) extinction regimes under different dispersal and consumption
 rates; 2) the magnitude of extinction debt and ecosystem function debt or
 credit under various dispersal rates; 3) the magnitudes of extinction debt
 and ecosystem function debt or credit with environmental conditions of the
 removed patch; and also 4) verifying extinction debt and ecosystem
 function credit mechanisms in metapopulations. Therefore, it is a
 theoretical study and has no data. This dataset includes the codes of the
 model and data analysis about the above content, the former in Java, and
 the latter in R. Some of the codes were modified from our prior study (Ai
 & Ellwood 2022), which we have cited.
description: # Extinction and ecosystem function debt across dispersal rate and
 behavior in a heterogeneous metacommunity model
 [https://doi.org/10.5061/dryad.95x69p8sf](https://doi.org/10.5061/dryad.95x69p8sf) This dataset includes the codes of model and data analysis for the study “Extinction and ecosystem function debt across dispersal rate and behavior in a heterogeneous metacommunity model”.  The codes of model was written in Java, while the codes of data analysis was written in R. The former is included in the directory of "Java codes for modelling", whereas the latter is included in the directory of "R codes for data analysis". Some of codes were modified from our prior study (Ai & Ellwood 2022, Ecological Modelling).  ### Java codes for modelling For the model codes to be executed, all code files must be oriented in the same directory. The following code list is provided in the "Java codes for modelling" directory, and it is run in numerical order: 1\. `Full_connected_graph.java`: gets topology (full-connected structure) of the metacommunities. In this study, we created two metacommunities with 50 and 49 patches, respectively. The topology of these two metacommunities are also included in the dataset. They are in the files “`Graph_full-connected_50.txt`” and “`Graph_full-connected_49.txt`”, respectively. To save the topology as character data files and binary data files, respectively, functions in “`Save_m.java`” and “`Final.java`” will be called. 2\. `Parameters_functions.java`: initializes the parameters and defines some functions. To read the topology of the metacommunities mentioned above, a function in “`Read_topology.java`” will be called. 3\. `Resource_competition_elimination_Gextinct_before.java`: gets the whole metacommunity state before patch removal, including individual species biomass and the available resource on each patch. To save the biomass of each species on each patch and the resource of each patch at the first equlibrium as character and binary data, functions in “`SAVE.java`” will be called. 4\. `Runnable_elimination.java`: provides the access to the codes of patch removal. To read the biomass of each species on each patch and the resource of each patch obtained at the first equilibrium as input, functions in “`Read.java`” will be called. To read the topology of metacommunity, a function in “`Read_topology.java`” will be called. Then, the file "`Resource_competition_elimination_Gextinct.java`" will be executed to remove a patch and continue to run to the second equilibrium. To save the biomass of each species on each patch as well as the extinction time of each speciesa at the second equilibrium, functions in “`SAVE.java`” will be called. 5\. `Resource_competition_elimination_Gextinct_WITHOUT.java`: gets the metacommunity state without removal, but it runs for the same length of time as the case with patch removal. To save the biomass and extinction time of each species without patch removal, functions in “`SAVE.java`” will be called. `Resource_competition_elimination_metapopulation_directed.java`: provides metapopulation model for the directed case. It can run separately. In each related code file, we provided comments regarding the exact codes for the case of directed and undirected dispersal behaviors. If you run the case of directed dispersal behavior, just comment out the code about the undirected dispersal behavior, and vice versa.   For the data analysis codes to be executed, it is necessary to give the directions of model results. In our study, for example, a direction is “E:\Model-Extinction Debt in Metacommunity\a=1\ 10-undirected-longer\”. ### R code The R codes for data analysis and visualization begin with "Data-" and "Plot-", respectively. The list of codes in the direction of " R codes for data analysis" is as follows: 1\. `Data-Convert into excel file.R`: converts each data files (.txt) which was obtained from the model into an excel file. 2\. `Data-Environment value and species optimal niche value.R`: provides the environmental value for each patch and optimal niche value for each species. 3\. `Data-Calculate mean biomass for each patch.R`: calculates mean biomass change of each patch 4\. `Data-Calculate mean biomass for each dispersal rate.R`: calculates the mean biomass changes across all patches under each dispersal rate 5\. `Data-calculate extinction risk.R`: calculates extinction risk of each species. 6\. `Data-Calculate # extiction species.R`: calculates the number of extinct species 7\. `Plot equilibrium_biomass.R`: plots the biomass of each species as well as total biomass of all species in the whole metacommunity over time. 8\. `Plot species biomass distribution before removal.R`: plots the distribution of species biomass on patches with different environmental values before patch removal for metacommunities with 50 patches. 9\. `Plot species biomass distribution before removal – 49.R`: plots the distribution of species biomass on patches with different environmental values before patch removal for metacommunities with 49 patches. 10\. `Plot extinction regimes.R`: plots extinction regimes. The model should be run under various combinations of dispersal and resource consumption rates to obtain the extinction regimes before plotting it.  11\. `Plot risk intensity.R`: plots extinction risk intensity of each species. 12\. `Plot extinction and function debt with dispersal.R`: plots the extinction and ecosystem function debt with dispersal rates. 13\. `plot #extinction species vs patch.R`: plots the number of extinct species with the environmental condition of the removed patch. 14\. `Plot biomass change-directed-undirected vs patch.R`: plots the ecosystem function debt with the environmental condition of the removed patch. ## References Ai, D. & Ellwood, M.D.F. (2022). A spatially implicit model fails to predict the structure of spatially explicit metacommunities under high dispersal. *Ecological Modelling*, 474, 110151.