Data and code from: Local heterogeneity an important driver for predation pressure of an herbivorous insect
Data files
May 28, 2026 version files 64.87 KB
-
Data_homed.csv
23.05 KB
-
README.md
9.27 KB
-
Rstudio_code_2025.txt
32.56 KB
Abstract
Environmental heterogeneity plays a crucial role in influencing biodiversity; however, its effect on the regulation of trophic interactions, such as predation, is still unclear. Although plant diversity is often correlated with predator diversity, its relationship with predation pressure remains inconsistent. Plant diversity and predator activity are influenced by biotic and abiotic habitats. Thus, habitat heterogeneity may serve as a stronger predictor of predation pressure. In this study, we investigated the influence of local habitat heterogeneity and tree diversity on predation by the insect herbivore Neodiprion sertifer. We measured understory diversity and structure, dead wood, and presence of boulders. Notably, the predation rates were similar between mixed and monoculture stands. However, local heterogeneity increased predation by directly increasing ant presence, which in turn increased larval predation. Shrub density and boulders also had direct positive effects on predation. Therefore, local heterogeneity may have a greater impact on predation pressure than tree diversity.
Dataset DOI: 10.5061/dryad.h1893200r
Description of the data and file structure
This dataset contains field observations collected during 2019 across 12 forest stands located within two regions in east-central Sweden (Knutby and Österbybruk) to test the effects of local heterogeneity on predation pressure of the herbivore insect Neodiprion sertifer. We recorded tree and shrub diversity and density, herb layer diversity, height and type, and the presence or absence of dead wood and boulders around 60 experimental Scots pine trees, following a standardized method in which larvae of Neodiprion sertifer were added to each experimental tree to assess predation pressure, and the presence or absence of ants on each tree was recorded. These data support the analyses presented in Local heterogeneity an important driver for predation pressure of an herbivorous insect.
Files and variables
File: Rstudio_code_2025.txt
Description: RStudio code to build models, run analyses, and plot figures used in the manuscript.
Variables
- The file Rstudio_code_2025.txt contains all R code used for data preparation, modelling, and figure generation.
File: Data_homed.csv
Description: Data on larval loss due to predation and all local heterogeneity variables (tree/shrub diversity and density, herb layer structures, dead wood presence, boulder presence, and ant presence). Each row = one experimental tree per sampling occasion.
Variables
- site: the regions Knutby or Österbybruk
- stand_letter: ID for individual forest stand
- type: mixed or monoculture forest stand
- tree: ID for experimental tree within forest stand
- total_exp: The total number of exposed larvae
- total_loss: The total loss of exposed larvae
- ants.no: Presence (1) or absence (0) of ants on the experimental tree
- p_pine: Percent pine around experimental tree
- pine_cat: Pines categorized into "None", "Low", "Medium" or "High"
- p_spruce: Percent spruce around experimental tree
- spruce_cat: Spruce categorized into "None", "Low", "Medium" or "High"
- p_birch: Percent birch around experimental tree
- Birch_cat: Birch categorized into "None", "Low", "Medium" or "High"
- p_deci: Percent deciduous trees around experimental tree
- p_all_trees.pine: Percent of all tree species besides pine around experimental tree
- p_deci.birch: Percent of all deciduous tree species besides birch around experimental tree
- p_trees.birch.pine: Percent of all tree species besides pine and birch around experimental tree
- nr_pine: The number of pines around experimental tree
- nr_spruce: The number of spruce around experimental tree
- nr_birch: The number of birch around experimental tree
- tot_nr_trees: The total number of trees around experimental tree
- tot_nr.pine: The total number of trees besides pines around experimental tree
- tot_nr_deci: The total number of deciduous trees around experimental tree
- tot_nr_deci.birch: The total number of deciduous trees besides birch around experimental tree
- tot_nr_trees.birch.pine: The total number of trees besides pines and birches around experimental tree
- simp_div: Simpson's diversity index for all tree species
- tree_density: Density of all tree species
- p_pine_shrub: Percent of pine shrubs around experimental tree
- p_spruce_shrub: Percent of spruce shrubs around experimental tree
- p_birch_shrub: Percent of birch shrubs around experimental tree
- p_deci_shrub: Percent of desideouse shrub trees around experimental tree
- p_deci.birch_shrub: Percent of desideouse shrub trees beside birch shrubs around experimental tree
- p_trees.birch.pine_shrub: Percent of shrub trees beside pine- and birch shrubs around experimental tree
- nr_pine_shrub: Number of pine shrub trees around experimental tree
- nr_spruce_shrub: Number of spruce shrub trees around experimental tree
- nr_birch_shrub: Number of birch shrub trees around experimental tree
- tot_nr_shrub: Total number of shrub trees around experimental tree
- understory_height: The average height of the understory herb layer
- shurb_height: The average height of the shrub trees
- height_shurb_deci_m: The average height of deciduous shrub trees
- height_host_tree_m: The height of the experimental tree
- height_tree_coni_m: The average height of conifer trees
- height_tree_deci_m: The average height of deciduous trees
- veg_type: Herb layer site classification system
- veg_type2: Herb layer site classification system categorized into 3 levels
- code_veg: Herb layer site classification system categorized into 1, 2, or 3
- large_boulder: Presence of boulders (> 1 m diameter), "yes" or "no"
- code_large_boulder: Presence of large boulders (> 1 m diameter), numbering 0 or 1
- large_dispercal: Dispersal of large boulders, "no", "scattered", "semi-grouped", "grouped"
- code_large_dispercal: Dispersal of large boulders, numbering 0-3
- large_amount: Amount of large boulders, "no", "few", "medium", "high"
- code_large_amount: Amount of large boulders, numbering 0-3
- small_boulder: Presence of smaller boulders (> 0.25 m & < 1 m diameter), "yes" or "no"
- code_small_boulder: Presence of smaller boulders (> 0.25 m & < 1 m diameter), numbering 0 or 1
- small_dispercal: Dispersal of smaller boulders, "no", "scattered", "semi-grouped", "grouped"
- code_small_dispercal: Dispersal of smaller boulders, numbering 0-3
- small_amount: Amount of smaller boulders, "no", "few", "medium", "high"
- code_small_amount: Amount of smaller boulders, numbering 0-3
- trunk: Presence of dead tree trunk, "yes" or "no"
- code_trunk: Presence of dead tree trunk, numbering 0 or 1
- trunk_dispercal: Dispersal of dead tree trunk, "no", "scattered", "semi-grouped", "grouped"
- code_trunk_dispercal: Dispersal of dead tree trunk, numbering 0-3
- trunk_amount: Amount of dead tree trunk, "no", "few", "medium", "high"
- code_trunk_amount: Amount of dead tree trunk, numbering 0-3
- stump: Presence of tree stump, "yes" or "no"
- code_stump: Presence of tree stump, numbering 0 or 1
- stump_dispercal: Dispersal of tree stump, "no", "scattered", "semi-grouped", "grouped"
- code_stump_dispercal: Dispersal of tree stump, numbering 0-3
- stump_amount: Amount of tree stump, "no", "few", "medium", "high"
- code_stump_amount: Amount of tree stump, numbering 0-3
- dead_wood: Presence of dead wood (fine woody debris >10 cm diameter) , "yes" or "no"
- code_dead_wood: Presence of dead wood (fine woody debris > 10 cm diameter), numbering 0 or 1
- wood_dispercal: Dispersal of dead wood, "no", "scattered", "semi-grouped", "grouped"
- code_wood_dispercal: Dispersal of dead wood, numbering 0-3
- wood_amount: Amount of dead wood, "no", "few", "medium", "high"
- code_wood_amount: Amount of dead wood, numbering 0-3
- cover_fern: Percentage of fern covering circle plot
- cover_grass: Percentage of grass (narrow-, brad-, and half grass) covering circle plot
- cover_berries: Percentage of (bluebetty, lingonberry, heather) covering circle plot
- cover_moss_lichen: Percentage of moss and lichen covering circle plot
- cover_herbs: Percentage of herbs covering circle plot
- cover_none_dominating_species: Percentage of none dominating species (no clear dominating species) covering circle plot
- cover_narrow_grass: Percentage of narrow-leaved grasses covering circle plot
- cover_broad_grass: Percentage of broad-leaved grasses covering circle plot
- cover_half_grass: Percentage of half-grasses covering circle plot
- cover_blueberry: Percentage of blueberry covering circle plot
- cover_lingon: Percentage of lingon covering circle plot
- cover_ljung: Percentage of heather covering circle plot
- ants: Presence or absence of ants on the experimental tree, "Yes", or "No"
- total_div: Count of herb-layer species (cover data) per experimental tree (presence/absence-based)
Code/software
Code/software
All analyses and figure generation can be reproduced using freely available software: R version 4.4.1 (R Core Team, 2024), version: RStudio 2025.09.0 Build 387 “Cucumberleaf Sunflower”.
Required packages: glmmTMB 1.1.8, lme4 1.1.35, piecewiseSEM 2.3.0, ggeffects 1.4.0, DHARMa 0.4.6, car 3.1.2, tidyverse 2.0.0, ggplot 2 3.5.1, dplyr 1.1.4, forcats 1.0.0, readxl 1.4.3, readr 2.1.5.
Workflow
- Copy and paste all code from Rstudio_code_2025.txt into Rstudio.
- Load Data_homed.csv in RStudio.
- Install the packages listed in Rstudio_code_2025.txt.
- Run the script to reproduce the models and figures in the manuscript.
Script description
Rstudio_code_2025.txt performs data preparations, fits the models described in the manuscript, and generates the figures.
– “SECTION 1 - data preparations" install packages, imports data and prepare data.
– “SECTION 2 - model diagnostics” go through model diagnostics for individual models.
– “SECTION 3 - SEM models” fits GLMMs and SEMs.
– “SECTION 4 - Figure plots” generates the figures plots 2-3 for the manuscript.
All code is written in Rstudio, no proprietary software is required.
