DOI: 10.5061/dryad.c59zw3rgn
title: Code from: Spatial resource heterogeneity stabilizes local and regional predator-prey dynamics in ecologically-realistic networks

description: Spatial resource heterogeneity (SRH; the variable spatial distribution of
 resources) is a surprisingly understudied component of oscillatory
 consumer-resource dynamics. SRH may be particularly important in large,
 ecologically-realistic networks where different patterns of resource
 distribution can manifest, which has important implications for spatial
 synchrony. Here we explore how SRH in large spatial networks influences
 both local and regional consumer-resource stability. To do so, we employ a
 spatially-explicit Rosenzweig-MacArthur model and vary resource
 distribution accordingly: homogeneously-distributed resources of low,
 medium and high productivity, and heterogeneously-distributed resources.
 The latter includes networks with SRH of random variability in
 productivity (“random networks”) or a spatial productivity gradient
 (“gradient networks”). We analyze the effects of local patch factors
 (i.e., productivity and connectivity) and regional factors (i.e.,
 productivity distribution and structure). First, we find that SRH,
 regardless of productivity distribution type, stabilizes regional dynamics
 via statistical stabilization of asynchronous oscillations and local
 dynamics by reducing the amplitude of oscillations and bounding them
 further from zero. Second, the local-level stabilizing effect increases
 with both productivity and connectivity. Lower productivity patches are
 subsequently destabilized in return, albeit minimally. Lastly, random
 variability in productivity provides the greatest local-level
 stabilization effect, because high productivity patches are often (highly)
 connected to lower ones in a way not possible in gradient networks. We
 conclude that SRH is a particularly strong driver of consumer-resource
 stability in that it provides local-level stability in a way that other
 forms of heterogeneity do not. To promote consumer-resource stability,
 management decisions should prioritize 1) variable resource distribution
 patterns in large spatial networks, and 2) high connectivity between
 patches of different productivity levels.
description: # Code from: Spatial resource heterogeneity stabilizes local and regional
 predator-prey dynamics in ecologically-realistic networks Dataset DOI:
 [10.5061/dryad.c59zw3rgn](10.5061/dryad.c59zw3rgn) ## Description of the
 data and file structure We simulated predator-prey dynamics in
 metacommunities using a spatially explicit version of the well-known
 Rosenzweig-MacArthur model (Rosenzweig and MacArthur, 1963). We have
 submitted Mathematica code (“SRM_Manuscript_2024.nb”) for model creation
 and numerical simulation, and two output datasets, one containing the
 results for the main manuscript (final.df.csv”) and one containing the
 results for the supplementary information (“all.data.for.supplement.csv”).
 ### Files and variables #### **Description of code and file structure**
 The Mathematica code (“SRM_Manuscript_2024.nb”) simulates the spatial
 predator-prey dynamics and produces output for predator-prey stability
 metrics (amplitude and minimum of oscillations) as a function of network
 structure (dendritic vs. ring lattice), network size (7, 15, 31, and 63
 patches), and spatial resource heterogeneity (homogeneous low
 productivity, homogeneous medium productivity, homogeneous high
 productivity, random heterogeneous distribution, gradient heterogeneous
 distribution). The first section (“Initialize Program”) defines
 parameters, creates empty tables, and defines the type of network
 structure to simulate. The second section (“Start Loop”) includes analysis
 for the single patches and the networks. The post-processing stores the
 data, along with visualizing it. Specifics are described in-code through
 comments. #### **Description of data and file structure** There are two
 datasets we created from running the model under various scenarios.
 “final.df.csv” is the resulting table from running the Mathematica code
 for the main manuscript findings, which focuses on 63-patch dendritic
 (tree) network structures across productivity level (low, medium, high)
 and productivity distribution (homogeneous, heterogeneous [random,
 gradient]). “all.data.for.supplement.csv” involves the additional results
 presented in the supplement, which includes networks of all sizes (7, 15,
 31, 63 patches), structures (dendritic, ring lattice), as well as
 productivity level and productivity distribution patterns. Each data file
 has the same variable column headings, with variable descriptions and
 differences in the variable levels between the datasets described below. *
 Run.Number: Number of simulations (50). Consistent between each data file.
 * structure: Network structure, including tree (dendritic) or ring (ring
 lattice) in all.data.for.supplement.csv. Includes only tree in
 final.df.csv. * patch: Number of patches in a network. In final.df.csv,
 includes only 63. In all.data.for.supplement.csv, includes 7, 15, 31, and
 63. * K: Refers to the distribution of productivity or carrying capacity.
 Both datasets include constant, random, and slope. Constant pertains to a
 homogeneous productivity distribution. Random pertains to a random
 productivity distribution. Slope pertains to a slope-like or gradient
 distribution. * productivity: Refers to the average productivity level.
 Both datasets include low, mid (medium) and high. * treatment2: For figure
 purposes. Combines K, productivity, and network vs. single patch. *
 variable: Describes variable type, whether single patch or network, patch
 or regional scale results, and minimum or amplitude metric. * value: the
 resulting minimum or amplitude value. * prod.dist: For figure purposes.
 Refers to productivity distribution, whether constant, random, or slope
 and with an average productivity level of mid (medium), low, or high. *
 log_value: the log of “value”. ## Code/software Mathematica version
 14.1.0.0 was used to run the script and generate the datasets. Annotations
 are provided throughout the script for 1) parameter definitions, 2) model
 creation, 3) processing and analysis, and 4) figure creation.