jcoliver / biodiversity-sdm-lesson

Introductory lesson to generate range maps for butterfly-host plant interactions and predict distributional shifts using publicly available biodiversity data and data science tools

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lesson on biodiversity data and species distribution models

v0.9.4

NOTE: This lesson relies on several R packages that were retired in late 2023 (e.g. maptools, raster, sp). The lesson will need to be updated with the successor packages (e.g. terra, geodata, predicts). In the meantime, you can find a lesson using current R packages for making predictions on a single species at https://jcoliver.github.io/learn-r/011-species-distribution-models.html.

Overview

Introductory lesson to generate range maps for butterfly-host plant interactions and predict distributional shifts using publicly available biodiversity data and data science tools. See Clement et al. (2018) TIEE 14 for additional information.

Detailed instructions can be found in docs/instructions.md

Originally forked from https://github.com/jcoliver/ebutterfly-sdm.git

Dependencies

Four additional R packages are required (these will be installed by running the the setup script, scripts/setup.R):

  • raster
  • sp
  • dismo
  • maptools

Structure

  • data
    • wc2-5: climate data at 2.5 minute resolution from WorldClim (note: this folder is not under version control, but will be created by running the setup script (scripts/setup.R))
    • cmip5: forcast climate data at 2.5 minute resolution from WorldClim. These data were originally downloaded from the WorldClim website, but stored in the .RData format for ease of use. The data are for the year 2070, based on the GFDL-ESM2G model with an RCP of 4.5 CO2. For an examination of different forecast models, see McSweeney et al. 2015.
    • Adelpha_californica_data.csv: data harvested from iNaturalist for Adelpha californica (Lepidoptera: Nymphalidae)
    • Danaus_gilippus_data.csv: data harvested from iNaturalist for Danaus gilippus (Lepidoptera: Nymphalidae)
    • Fraxinus_velutina_data.csv: data harvested from iNaturalist for Fraxinus velutina (Lamiales: Oleaceae)
    • Limenitis_archippus_data.csv: data harvested from iNaturalist for Limenitis archippus (Lepidoptera: Nymphalidae)
    • Lycaena_xanthoides_data.csv: data harvested from iNaturalist for Lycaena xanthoides (Lepidoptera: Lycaenidae)
    • Papilio_cresphontes_data.csv: data harvested from iNaturalist for Papilio cresphontes (Lepidoptera: Papilionidae)
    • Papilio_multicaudata_data.csv: data harvested from iNaturalist for Papilio multicaudata (Lepidoptera: Papilionidae)
    • Platanus_wrightii_data.csv: data harvested from iNaturalist for Platanus wrightii (Proteales: Platanaceae)
    • Quercus_chrysolepis_data.csv: data harvested from iNaturalist for Quercus chrysolepus (Fagales: Fagaceae)
    • Rumex_salicifolius_data.csv: data harvested from iNaturalist for Rumex salicifolius (Caryophyllales: Polygonaceae)
    • Speyeria_mormo_data.csv: data harvested from iNaturalist for Speyeria mormo (Lepidoptera: Nymphalidae)
    • Suggested_pairs.csv: suggested species pairs (butterfly + plant) for lessons
    • Urtica_dioica_data.csv: data harvested from iNaturalist for Urtica dioica (Rosales: Urticaceae)
    • Zanthoxylum_americanum_data.csv: data harvested from iNaturalist for Zanthoxylum americanum (Sapindales: Rutaceae)
  • dev: developmental scripts for example images and code testing
  • docs: documentation for this code and lesson
    • instructions.md: instructions for installing software, downloading data, and running analyses
    • script-explanation.md: explanations of the four species distribution modeling scripts (all prefixed with "run-*") in the scripts folder
    • troubleshooting.md: common challenges and possible solutions related to installing software and running analyses
  • functions
    • sdm-functions.R: functions used in species distribution models
  • img: images for Instructions
  • output (contents are not under version control)
  • scripts (The Script Explanation page provides more in-depth explanations of the species distribution modeling scripts)
    • examples: example scripts implementing the four run-* scripts and two plot-* scripts
    • get-observation-data.R: Harvest data from iNaturalist using their API based on a taxon ID; called from command line terminal
      • Usage: Rscript --vanilla get-observation-data.R <taxon_id>
      • Example: Rscript --vanilla get-observation-data.R 60606
    • plot-observations.R: Template to plot observations on a map
    • plot-six-panel.R: Template to generate species distribution models for a pair of species (generally, an insect and host plant) and create a six panel plot with the following panels: (1) Observations of species one (e.g. an insect), (2) observations of species two (e.g. a plant), (3) contemporary species distribution model for species one, (4) contemporary species distribution model for species two, (5) contemporary species distribution models of species one and two, showing areas of difference and overlap, (6) forecast species distribution models of species one and two, showing areas of difference and overlap
    • run-future-sdm-pairwise.R: Template to run species distribution model for an insect and its host plant species based on forecast climate model
    • run-future-sdm-single.R: Template to run species distribution model for a single species based on forecast climate model
    • run-sdm-pairwise.R: Template to run species distribution model for an insect and its host plant species based on current climate data
    • run-sdm-single.R: Template to run species distribution model for a single species based on current climate data
    • setup.R: Setup script to run at start of project, it will:
      • Install four additional R packages that are necessary for this lesson (raster, sp, dismo, maptools)
      • Check to make sure the data folder was copied correctly during the cloning of the GitHub repository
      • Download climate data from the WorldClim website If it does not successfully complete all these tasks, please reference the Troubleshooting page.

Resources

Species distribution models in R

Climate forecast models

iNaturalist

About

Introductory lesson to generate range maps for butterfly-host plant interactions and predict distributional shifts using publicly available biodiversity data and data science tools

License:MIT License


Languages

Language:R 100.0%