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
Four additional R packages are required (these will be installed by running the setup script, scripts/setup.R):
- terra
- geodata
- predicts
- data
- Adelpha_californica_data.csv: data harvested from iNaturalist for Adelpha californica (Lepidoptera: Nymphalidae)
- Aglais_io_data.csv: data harvested from iNaturalist for Aglais io (Lepidoptera: Nymphalidae)
- climate
- wc2.1_2.5m: folder with climate data at 2.5 minute resolution from WorldClim. This and the containing "climate" folder are not under version control, but will be created when running the setup script (scripts/setup.R). The folder contains both contemporary climate data, as well as forecast climate data. The forecast data are for the year 2070, and based on the GFDL-ESM4 model under the SSP 3-7.0. For more information on the various climate models, see the CMIP6 site.
- 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)
- gadm: folder to hold country border data; not under version control, but will be created upon first species distribution model analysis
- 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
- Usage:
- 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:
- observations of species one (e.g. an insect)
- observations of species two (e.g. a plant)
- contemporary species distribution model for species one
- contemporary species distribution model for species two
- contemporary species distribution models of species one and two, showing areas of difference and overlap
- 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 three additional R packages that are necessary for this lesson (terra, geodata, predicts)
- Check to make sure the
data
folder was copied correctly during the cloning of the GitHub repository - Download contemporary and forecast climate data from the WorldClim website
- If it does not successfully complete all these tasks, please reference the Troubleshooting page.
Side note: This project was originally forked from https://github.com/jcoliver/ebutterfly-sdm.git.
- The guide for SDMs in R
- Vignettes for the three R packages that this lesson heavily relies on:
- A single-species focused lesson
- Fast and flexible Bayesian species distribution modelling using Gaussian processes
- Species distribution models in R
- Run a range of species distribution models
- SDM polygons on a Google map
- R package 'maxnet' for functionality of Java maxent package