Readme updated 2 Sep 2025.
This repo contains code to (1) use the iNaturalist API to download species observations based on phenology annotations, by modifying code from the rinat package, and (2) model the relationship between flowering and weather using spatially interpolated records from PRISM and Bayesian additive regression tree methods implemented in dbarts with utilities from embarcadero (for a binary-response model of flowering), or using functions from softBart (for a continuous-response model).
The full analysis, from modeling to predicting flowering activity from historic records ("hindcasting") to analyzing trends in predicted historical flowering activity, is "Temporal Analysis of Reproduction Distributed in Space", or TARDIS. This workflow was first demonstrated in the following paper, which should be cited in connection with TARDIS even though we hadn't come up with the clever acronym when it was published:
Yoder JB, AK Andrade*, LA DeFalco, TC Esque, CJ Carlson, DF Shryock, R Yeager, and CI Smith. 2024. Reconstructing 120 years of climate change impacts on Joshua tree flowering. Ecology Letters, 27, e14478. doi.org/10.1111/ele.14478
Subfolders in the repository and their contents:
protocol_manual--- a PDF document describing our protocol for adding phenology annotations to the iNaturalist database, with supporting Markdown and image filesscripts--- all project scriptsR--- all R scriptsget_inat.R--- script to loadrinatand modify theget_inatfunction to allow searches on phenology state annotation.inat_phenology_download.R--- script to useget_inat.Rto download phenology-annotated observations using the iNaturalist API, clean them up for downstream analysis, and visualize this initial data. Creates:data/inat_phenology_data_[taxon code].csv--- iNat records for the taxon with numeric id[taxon code]data/inat_phenology_data_[taxon code]_cleaned.csv--- the above, cleaned using utilities in theCoordinateCleaner
PRISM_data-management.R--- downloads monthly climate data by year, crops it to an extent defined for the taxon with numeric id [taxon code], and summarizes it to quarterlies for downstream work. Creates files indata/PRISM/annual.[taxon code], using functionality from theprismpackageinat_phenology_data-management.R--- organization of data output frominat_phenology_download.Rinto rasterized, binary flowering occurrences, and pairing of these records with PRISM data by location and year. Creates:output/flowering_obs_rasterized_[taxon code].csv(only rasterized flowering frequency records) andoutput/flowering_obs_climate_[taxon code].csv(the above with PRISM data)
- Scripts for using a "static" SDM to predict habitat suitability change from the early 20th century (1901--1930) to recent times (1991--2020)
PRISM_bioclim_calc.R--- use PRISM data to calculate the 19 Bioclim variables as averages for the early and recent periodstime_shift_SDM.R--- script to use GBIF records for the target species, and the early-recent Bioclim averages calculated inPRISM_bioclim_calc.R, to train a SDM on recent-period records and predict habitat suitability in the early period
- Scripts for binary-response modeling of flowering activity
phenology_modeling_binary.R--- modeling annualized, rasterized observations of binary flowering (or no flowering) predicted with weather data using Bayesian additive regression tree (BART) methods. Includes code to perform predictor selection and diagnostic plot(s) and trains a final model with top predictors. Saves modeling objects tooutput/modelsasrdsfiles with the[taxon code]numeric id tag; and creates predictor partial-effect plots inoutput/figuresphenology_prediction_binary.R--- uses the BART model trained inphenology_modeling_binary.Rto predict flowering from PRISM data for 1900-present, output as annual spatial layers tooutput/models/predictions.[taxon code]flowering_years.R--- analyses of the historic flowering activity predictions fromphenology_prediction_binary.R, with figures created inoutput/figures
- Scripts for continuous-response modeling of flowering activity
phenology_modeling_continous.R--- modeling annualized, rasterized observations of flowering frequency predicted with weather data using Bayesian additive regression tree (BART) methods. Includes code to perform predictor selection and diagnostic plot(s) and trains a final model with top predictors. Saves modeling objects tooutput/modelsasrdsfiles with the[taxon code]numeric id tag; and creates predictor partial-effect plots inoutput/figuresphenology_prediction_continous.R--- uses the BART model trained inphenology_modeling_continous.Rto predict flowering activity from PRISM data for 1900-present, output as annual spatial layers tooutput/models/predictions.[taxon code]flowering_continouos.R--- analyses of the historic flowering activity predictions fromphenology_prediction_continuous.R, with figures created inoutput/figures
The following subfolders are generated in the course of running the pipeline, but they are not part of the version-controlled repository:
data--- for collecting data in various stages of processing/cleaningPRISM--- folder for PRISM data, downloaded and modified withPRISM_data-management.RBClim--- folder for Bioclim variable normals, calculated from PRISM data inPRISM_bioclim_calc.Rand used as predictors intime_shift_SDM.R- iNat observations with phenology annotation, output from
inat_phenology_download.R, stored as delimited text files with numeric taxon codes in the file names.
output--- transitional data products, modeling results, analysis and figuresmodels--- saved BART models and prediction layersfigures--- what it says on the tin
