DOI: 10.5061/dryad.b5mkkwhq8
title: Urbanization facilitates intrapopulation dietary niche diversity in a generalist carnivore

description: The niche variation hypothesis predicts that members of generalist species
 are specialists, and that the degree of individual specialization
 correlates positively with resource diversity. Urban landscapes are highly
 heterogeneous in resource diversity; therefore, we predicted urbanization
 would be associated with narrower individual dietary niches and greater
 differentiation among individuals of generalist species. We used stable
 isotope analysis to compare diets of urban and nonurban coyote (Canis
 latrans) populations in San Francisco and Marin County, California, USA.
 Urban coyotes had dietary niches nearly three times narrower than nonurban
 coyotes and greater among-individual variation in isotope values.
 Within-individual differences explained 18% of total δ13C variation in
 urban coyotes compared to 58% in nonurban coyotes, and 34% versus 44% of
 δ15N variation, indicating stronger individual specialization in the urban
 population. Our findings suggest urbanization facilitates intrapopulation
 dietary niche diversity by spatially structuring foraging, highlighting
 the role of human activity in promoting ecological diversification.
description: # Urbanization facilitates intrapopulation dietary niche diversity in a
 generalist carnivore https://doi.org/10.5061/dryad.b5mkkwhq8 This
 repository contains all raw data, plots, and scripts for the data analysis
 implemented in Caspi *et al.* 2025 titled *Urbanization facilitates
 intrapopulation dietary niche diversity in a generalist carnivore* and
 published in *Ecology Letters*. The GitHub repository associated with this
 manuscript is available
 at [https://github.com/tcaspi/SF-Coyote-Stable-Isotopes/tree/main](https://github.com/tcaspi/SF-Coyote-Stable-Isotopes/tree/main). Please find below a description of all raw and clean data sets and the scripts used to clean the raw data, run the models, and create the figures presented in the manuscript. These files can be accessed by downloading the `SF-Coyote-Stable-Isotopes-main.zip`. Model output is available for download on Dryad. ## Data Files In the `Data` folder, you will find a number of files: `20240102_data.csv`; `20240910_data.csv`; and `pilot_and_20231003.csv`: csv files containing the raw isotopic data. | Column | Description | | :--------- | :--------------------------------------------------------- | | SampleID | Label for whisker segment | | C\_raw | Raw d13C value; NA values represent missing data | | N\_raw | Raw d15N values; NA values represent missing data | | C\_total | Total C; NA values represent missing data | | N\_total | Total N; NA values represent missing data | | individual | Identifier for individual coyote | | whisker | Identifier for whisker | | tray | Tray number sample was processed on | | duplicate | Indicates whether or not the whisker is a duplicate sample | `prey_data_si.csv`: csv file containing the raw isotopic data for dietary sources. | Column | Description | | :------- | :------------------------------------------------------------------------------------------------------------------------------------ | | SampleID | Label for sample | | d13C | Raw d13C value; NA values represent missing data | | TotalC | Total C; NA values represent missing data | | d15N | Raw d15N value; NA values represent missing data | | TotalN | Total N; NA values represent missing data | | tray | Tray number sample was processed on | | well | Well sample was processed in | | material | Tissue type (hair, feather, etc.) | | species | Species sample came from | | lat | Latitude of sample location; NA for vertebrate prey represent missing location data; NA for freeze-dried meat means "non-applicable" | | long | Longitude of sample location; NA for vertebrate prey represent missing location data; NA for freeze-dried meat means "non-applicable" | `fastfood_si.csv`: csv file containing raw data for chicken and beef samples from San Francisco taken from A.H. Jahren & R.A. Kraft, Carbon and nitrogen stable isotopes in fast food: Signatures of corn and confinement, Proc. Natl. Acad. Sci. U.S.A. 105 (46) 17855-17860, [https://doi.org/10.1073/pnas.0809870105](https://doi.org/10.1073/pnas.0809870105) (2008). | Column | Description | | :------- | :------------------------- | | SampleID | Label for sample | | species | Food type: chicken or beef | | d13C | Raw d13C value | | d15N | Raw d15N value | `whisker_metadata.csv`: csv file containing metadata for whisker samples*. | Column | Description | | :------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | whisker | Label for sample | | date\_clean | Date sample was rinsed | | date\_chopped | Date sample was chopped | | initials | Initials of person preparing sample | | tray | Tray number sample was processed on | | storage | Storage form for whisker | | urban | Region (San Francisco = urban; Marin County = nonurban) | | FieldID | Label of sample as identified in the field | | site | Location sample was collected | | lat | Latitude of sample location | | long | Longitude of sample location | | year | Year sample was collected | | date.collected | Day sample was collected | | age | Estimated age of coyote during sample collection | | sex | Sex of coyote | | dead | Sample collection type: roadkill = coyote killed by vehicle strike; sick.euth = coyote euthanized for medical reasons; live cap = live capture; euthanized = coyote lethally removed by wildlife officials for aggression; sick.release = sick coyote treated and released; unknown = no information on cause of death | \**NA values in any column represent missing data* `individual_ids.csv` | Column | Description | | :--------- | :--------------------------------------------------------------------------------------------------- | | individual | Individual coyote labels that match up with whisker data | | sfcoy | Unique name for each individual identified by genotyping in San Francisco | | sex | Sex as identified by genotyping | | group | Family group assignment; NA values represent individuals that could not be assigned to family groups | `scat_metadata.csv`: metadata associated with coyote fecal samples analyzed in Caspi, T., Serrano, M.G., Vanderzwan, S.L., Kessler, J., Schell, C.J. & Sacks, B.N. (2025). Impervious surface cover and the number of restaurants shape diet variation in an urban carnivore. *Ecosphere*, 16, e70152. | Column | Description | | :--------- | :--------------------------------------------------------------------------------------------------------- | | SampleID | Coyote family group/territory | | Replicate | Whether or not a PCR replicate was conducted | | Name | Unique field identifier for the sample | | Site | Location sample was collected | | Initials | Initials of the person who collected the sample | | Year | Year sample was collected | | Month | Month sample was collected | | Day | Day sample was collected | | Lat | Latitude of sample location | | Long | Longitude of sample location | | Sus.sp | Suspected species ID at the time of collection | | Genotype | Whether or not the sample was successfully genotyped | | Geno.Sp | Species identification from genotyping; NA means "non-applicable", sample was not genotyped successfully | | Individual | Individual coyote sample was assigned to; NA means "non-applicable", sample was not genotyped successfully | | Cytb\_Sp | Species identification from cytochrome b sequencing; NA means "non-applicable", Cytb not run on sample | `territory_covs.csv`: territory-level covariate data. | Column | Description | | :--------------- | :---------------------------------------------------------- | | group | Coyote family group/territory | | lat | Location of territory center point - latitude | | long | Location of territory center point - longitude | | ISA | Percent of territory classified as impervious surface cover | | Urban | Percent of territory classified as urban land cover | | Food.Services | Number of food services in territory | | Pop.Den.2020 | Mean human population density in territory | | Housing.Den.2020 | Mean housing density in territory | ## Scripts The scripts for the full workflow are available as R and Rmd files in the `Code` folder. All files are R scripts that were run in R version 4.2.1. The output of the models is not stored on GitHub due to the large file sizes, but can be generated on your own device, or is available on this Dryad Digital Repository (doi: doi:10.5061/dryad.b5mkkwhq8). * `Sample_Collection_Maps.Rmd`: this script generates a study site map indicating where samples were collected. * `Clean_Data.Rmd`: this script takes the raw isotope data and creates cleaned data frames that can be used in data visualization and analysis. The script also calculates some basic summary statistics presented in the manuscript. * `Isotope_Biplots.Rmd`: this script generates the isotope biplots presented in the manuscript. * `SIBER.Rmd`: this script uses the *SIBER* package to calculate Bayesian-based standard ellipse areas. * `RInSp.Rmd`: this script uses the *RInSp* package to calculate niche components and the WIC/TNW index of individual dietary specialization. * `DHGLMs.Rmd`: this script uses the *brms* package to construct double-hierarchical generalized linear models that assess the effect of sex and region on among-individual differences in isotopic means and variances. * `Stratified-Data.Rmd`: this script redoes the SIBER, RInSp, and DHGLM analyses after excluding roadkilled individuals. * `GLMMs.Rmd`: this script uses the *brms* package to construct generalized linear mixed-effect models that assessthe effect of impervious surface cover on d13C and d15N values. * `Mixing_Models.Rmd`: this script uses the *MixSIAR* package to construct Bayesian-based stable isotope mixing models to estimate mean proportions of different dietary sources. These models are computationally intensive and take a long time to run. Thus, it is recommended to run them on an HPC cluster rather than on a personal laptop. * `Prey_Map_Supp_Info.Rmd`: this script makes a map of prey sampling locations and generates Supplementary Figure 1, an isotope biplot of all food sources. ## Clean Data In the `Cleaned_Data` folder, you will find a number of cleaned-up files that are generated within the R scripts described above. Cleaned raw data: * `cleaned_whiskerdata.csv`: output of `Clean_Data.Rmd` script * `averaged_whiskerdata.csv`: output of `Clean_Data.Rmd` script For MixSIAR models: * `coyote_consumer_avgs.csv`: generated as an intermediate file in the `Mixing_Models.Rmd` script for the six-source mixing model. * `coyote_source.csv`: generated as an intermediate file in the `Mixing_Models.Rmd` script for the six-source mixing model. * `coyote_discrimination.csv`: generated as an intermediate file in the `Mixing_Models.Rmd` script for the six-source mixing model. * `coyote_consumer_isa.csv`: generated as an intermediate file in the `Mixing_Models.Rmd` script for the three-source mixing model. * `coyote_source_three.csv`: generated as an intermediate file in the `Mixing_Models.Rmd` script for the three-source mixing model. * `coyote_discrimination_three.csv`: generated as an intermediate file in the `Mixing_Models.Rmd` script for the three-source mixing model. ## Model Output The output of the models is not stored on GitHub in the `Model_Output` folder due to the large file sizes, but can be generated on your own device, or is available on this Dryad Digital Repository (doi: doi:10.5061/dryad.b5mkkwhq8). The `.rds` files that can be downloaded from Dryad are described below. * Stable isotope mixing models: `jags.full.rds`: model output for the six-source, categorical effect Bayesian-based stable isotope mixing model. This file is generated in the `Mixing_Models.Rmd` script. `jags.ISA.rds` and `jags.ISA.null.rds`: model output for the three-source, continuous effect Bayesian-based stable isotope mixing model and a comparative null model. These files are generated in the `Mixing_Models.Rmd` script. * Generalized linear mixed-effect models: `glmm_C_skew.rds`: model output for the effect of impervious surface cover on d13C. This file is generated in the `GLMMs.Rmd` script. `glmm_N_skew.rds`: model output for the effect of impervious surface cover on d15CN. This file is generated in the `GLMMs.Rmd` script. * Double-hierarchical generalized linear models: `dhglm_C_skew.rds`: model output for the d13C DHGLM. This file is generated in the `DHGLMs.Rmd` script. `dhglm_N_skew.rds`: model output for the d13C DHGLM. This file is generated in the `DHGLMs.Rmd` script.