Skip to content
/ specter Public

Analysis of biological time series frequency spectra and their changes over time

Notifications You must be signed in to change notification settings

vsbpan/specter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

README for "The Frequency of Population and Masting Fluctuations Is Increasing Globally"

Table of Contents

  1. Installation
  2. Files & Code
  3. Data
  4. SessionInfo

Installation

Run specter/Package_installation.R to install repository dependencies. For the dependency vmisc, see vmisc GitHub page on installation instructions for the latest version. An archival version is available at specter/misc/vmisc_0.2.0.tar.gz.

The custom code written for this project are bundled as a pseudo simulated package specter. It can be imported using vmisc::load_all2("specter"). Use vmisc::load_all2("specter") or pkgload::load_all("specter") to load the simulated package instead of library(specter).

Files & Code

  • analysis/ stores code for formal analysis
    • GPDD_models.R stores code for fitting brms models of population fluctuation frequency
    • mastTree_models.R stores code for fitting brms models of masting fluctuation frequency
    • in_text_effects.R stores code for generating the effect sizes reported in the main text
    • validate_freq_recovery.R stores code for simulating how accurate the lomb method is at recovering the true frequency under different sampling scenarios. The spectral method and data inclusion criteria is chosen based on this simulation.
  • cleaned_data/ stores cleaned data
    • *_recovery_simulation.csv Simulation results from validate_freq_recovery.R using the Lomb method the non-uniform discrete Fourier transformation to get the frequency spectra.
    • *_tree.tre Pruned phylogenetic trees generated by get_tree.R
    • *_taxon_info.csv Cleaned taxonomic names lookup table. Cleaned using rotl to find the closest matching ott_id.
    • *_series_cleaned.csv Cleaned series value and temperature data in long format. Generated from *_cleaning.R
    • *_meta_cleaned.csv Cleaned meta data associated with each series. Generated from *_cleaning.R
    • *_pop_res.csv Computed series value attributes. Generated from *_calc.R
    • *_temp_res.csv Computed series temperature attributes. Generated from *_calc.R
    • GPDD_ricker_res.csv Computed Ricker model parameters. Generated from *_calc.R
  • figures/ stores code for figures
  • get_data/ stores code for obtaining and cleaning data
    • data_prep.R stores code for taking cleaned datasets and producing the final data.frames and phylos used in formal analysis.
    • get_air_temp.R stores code for writing the cleaned .nc objects called by specter::find_temperature() internally to get air temperature.
    • get_tree.R stores code for pruning the phylogenetic trees.
    • GPDD_calc.R stores code for computing all series associated variables analyzed (e.g., frequency) for the GPDD datasets.
    • mastTree_calc.R stores code for computing all series associated variables analyzed (e.g., frequency) for the MASTTREE+ datasets.
    • GPDD_cleaning.R stores code for cleaning the GPDD data, including adding taxonomic and temperature information.
    • mastTree_cleaning.R stores code for cleaning the MASTTREE+ data, including adding taxonomic and temperature information.
  • raw_data/ stores raw data
    • GPDD_*.csv Raw data downloaded from the 2010 release of the GPDD database from Prebdergast et al. 2010. See the data source for column definitions.
    • MASTREEplus_2024-06-26_V2.csv Raw data downloaded from the V2 2024 release of the MASTTREE+ database from Hacket-Pain et al. 2022. See the data source for column definitions.
  • graphs/ stores graphs. Invisible to GitHub.
  • invisible/ stores large files invisible to GitHub (e.g., raw climate rasters).
  • specter/ source code for simulated package specter.
    • .Rbuildignore what to ignore in the package folder
    • Package_installation.R script for helping you install R package dependencies
    • DESCRIPTION package description file
    • NAMESPACE package namespace file
    • data/ package data files
      • annual_air_temperature_20th_century_reanalysis.nc 20th Century Reanalysis V3 2 meter air temperature at 1 x 1 degree resolution from Slivinski et al. 2019. Data in kelvins and are the result of averaging across months 1 - 12.
      • annual_air_temperature_GHCN_CAMS.nc GHCN + CAMS 2 meter air temperature at 0.5 x 0.5 degree resolution from Fan & van den Dool 2008. Data in kelvins and are the result of averaging across months 1 - 12.
    • misc/ misc package related stuff but not part of the package itself
      • vmisc_0.2.0.tar.gz Source code for the custom utility package vmisc
    • R/ R source code
  • rds_files/ Fitted model objects. Not on GitHub because of the large file size.
  • README.md This documentation

Data

  • *_recovery_simulation.csv
    • k: scaling factor where the true simulated frequency is $1/(2 \pi k)$
    • N: the length of the simulated time series
    • p: the proportion of the time series that is randomly dropped
    • rep: 1 to 100 repeated simulation
    • chunk_id: chunk identity for parallel computing
    • score: log ratio of the predicted frequency / true frequency
  • *_taxon_info.csv
    • species or taxonname: the key from the raw MASTTREE+ or GPDD data
    • name_cleaned: the best name for plotting
    • search_string: what is used to look up the ott_id
    • unique_name: what is in the phylo tree. Note that for some, the search string is changed to higher taxanomic levels because no unique_name matched the search string or the found ott_id turns out to be invalid.
    • ott_id: identifier number from open tree of life
    • is_synonym: is the name a synonym? TRUE or FALSE.
    • approximate_match, score, flags, number_matches: Other stuff generated from rotl::tnrs_match_names()
  • *_series_cleaned.csv
    • mainid or series_id: series identifier
    • year: year of value
    • population or value: series value
    • air_temp: temperature at the census location at the time of census in Kelvins
  • GPDD_meta_cleaned.csv
    • mainid: unique series identifier
    • datasourceid: data reference identifier
    • locationid: census site identifier
    • reference: citation of the data reference
    • lon: longitude in degree decimals
    • lat: latitude in degree decimals
    • taxonname: the name key from the GPDD data
    • ott_id: identifier number from open tree of life
    • name_cleaned: best name for plotting
    • ncbi_id: identifier number from NCBI
    • genus, family, order, class, phylum, kingdom: taxonomic classifications
    • taxon_rank: minimum taxonomic rank resolution of the species
  • mastTree_meta_cleaned.csv
    • series_id: unique series identifier
    • study_id: data reference identifier
    • variable: categorical classification of the measured series value variable. Options limited to: code, flower, fruit, seed, pollen, total reproduction organs
    • unit: unit of the series value
    • site_number: unique site identifier
    • lon: longitude in degree decimals
    • lat: latitude in degree decimals
    • taxonname: the name key from the MASTTREE+ data
    • ott_id: identifier number from open tree of life
    • name_cleaned: best name for plotting
    • ncbi_id: identifier number from NCBI
    • genus, family, order, class, phylum, kingdom: taxonomic classifications
    • taxon_rank: minimum taxonomic rank resolution of the species
  • *_pop_res.csv or *_temp_res.csv
    • ID: series identifier
    • error: TRUE or FALSE an error occurred in the pipeline
    • error_reason: why did the error occur?
    • part: segment identifier
    • Whole_epislon or epsilon: half of the minimum non-zero value in the series or segment. Used in place of zero.
    • whole_n_freq or n_freq: the number of spectral peaks that is significant at the $\alpha = 0.05$ level in a the series or segment
    • whole_y_mean or y_mean: the arithmetic mean of the series or segment value.
    • whole_y_log_mean or y_log_mean: the arithmetic mean of logarithm of the series or segment value.
    • whole_y_inv_mean or y_inv_mean: the arithmetic mean of the inverse of the series or segment value.
    • whole_x_min or x_min: the minimum series or segment year.
    • whole_x_max or x_max: the maximum series or segment year.
    • whole_x_median or x_median: the median series or segment year.
    • whole_x_length or x_length: the length of the series or segment years for which there is a valid series value.
    • whole_y_n or y_n: the length of the series or segment between the first and last year of the series or segment at a one year increment, including missing values.
    • whole_y_not_missing or y_not_missing: the length of the series or segment between the first and last year of the series or segment at a one year increment, excluding missing values.
    • whole_y_missing or y_missing: the length of the series or segment between the first and last year of the series or segment at a one year increment, including only missing values.
    • whole_mean_freq or mean_freq: the mean frequency index.
    • The rest of the undocumented variables: unused irrelevant variables
  • GPDD_ricker_res.csv
    • ID: series identifier
    • error: TRUE or FALSE an error occurred in the pipeline
    • error_reason: why did the error occur?
    • whole_estimate.*: MAP Ricker parameter estimate from fitting the Ricker model to the whole series
    • whole_se.*: MAP Ricker parameter estimate standard error from fitting the Ricker model to the whole series
    • whole_converged: TRUE or FALSE the Ricker model fitted to the whole series converged
    • part: segment identifier
    • estimate.*: MAP Ricker parameter estimate from fitting the Ricker model to the segment
    • se.*: MAP Ricker parameter estimate standard error from fitting the Ricker model to the segment
    • converged: TRUE or FALSE the Ricker model fitted to the segment converged

SessionInfo

Session Info ( click to expand )
─ Session info ───────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.4.2 (2024-10-31 ucrt)
 os       Windows 10 x64 (build 19045)
 system   x86_64, mingw32
 ui       RStudio
 language (EN)
 collate  English_United States.utf8
 ctype    English_United States.utf8
 tz       America/New_York
 date     2026-01-12
 rstudio  2024.09.1+394 Cranberry Hibiscus (desktop)
 pandoc   NA

─ Packages ───────────────────────────────────────────────────────────────────────────────────────────────────────────
 ! package           * version    date (UTC) lib source
   abind               1.4-8      2024-09-12 [1] CRAN (R 4.4.1)
   ape                 5.8        2024-04-11 [1] CRAN (R 4.4.1)
   aplot               0.2.3      2024-06-17 [1] CRAN (R 4.4.1)
   arrayhelpers        1.1-0      2020-02-04 [1] CRAN (R 4.3.2)
   askpass             1.2.1      2024-10-04 [1] CRAN (R 4.4.1)
   backports           1.5.0      2024-05-23 [1] CRAN (R 4.4.0)
   bayesplot           1.11.1     2024-02-15 [1] CRAN (R 4.4.1)
   bit                 4.5.0      2024-09-20 [1] CRAN (R 4.4.1)
   bit64               4.5.2      2024-09-22 [1] CRAN (R 4.4.1)
   blob                1.2.4      2023-03-17 [1] CRAN (R 4.3.2)
   bridgesampling      1.1-2      2021-04-16 [1] CRAN (R 4.3.2)
   brio                1.1.5      2024-04-24 [1] CRAN (R 4.4.1)
   brms              * 2.22.0     2024-09-23 [1] CRAN (R 4.4.1)
   Brobdingnag         1.2-9      2022-10-19 [1] CRAN (R 4.3.2)
   cachem              1.1.0      2024-05-16 [1] CRAN (R 4.4.1)
   checkmate           2.3.2      2024-07-29 [1] CRAN (R 4.4.1)
   cli                 3.6.3      2024-06-21 [1] CRAN (R 4.4.1)
   clusterGeneration   1.3.8      2023-08-16 [1] CRAN (R 4.3.2)
   coda                0.19-4.1   2024-01-31 [1] CRAN (R 4.4.1)
   codetools           0.2-20     2024-03-31 [2] CRAN (R 4.4.2)
   colorspace          2.1-1      2024-07-26 [1] CRAN (R 4.4.1)
   combinat            0.0-8      2012-10-29 [1] CRAN (R 4.3.1)
   contentid           0.0.19     2025-01-21 [1] CRAN (R 4.4.3)
   crayon              1.5.3      2024-06-20 [1] CRAN (R 4.4.1)
   cubature          * 2.1.1      2024-07-14 [1] CRAN (R 4.4.1)
   curl                6.0.0      2024-11-05 [1] CRAN (R 4.4.2)
   data.table          1.16.2     2024-10-10 [1] CRAN (R 4.4.1)
   DBI                 1.2.3      2024-06-02 [1] CRAN (R 4.4.1)
   dbplyr              2.5.0      2024-03-19 [1] CRAN (R 4.4.1)
   DEoptim             2.2-8      2022-11-11 [1] CRAN (R 4.4.1)
   desc                1.4.3      2023-12-10 [1] CRAN (R 4.4.1)
   digest              0.6.37     2024-08-19 [1] CRAN (R 4.4.1)
   distributional      0.5.0      2024-09-17 [1] CRAN (R 4.4.1)
   doParallel          1.0.17     2022-02-07 [1] CRAN (R 4.3.2)
   dplyr             * 1.1.4      2023-11-17 [1] CRAN (R 4.4.1)
   emmeans             1.10.5     2024-10-14 [1] CRAN (R 4.4.1)
   estimability        1.5.1      2024-05-12 [1] CRAN (R 4.4.1)
   expm                1.0-0      2024-08-19 [1] CRAN (R 4.4.1)
   fansi               1.0.6      2023-12-08 [1] CRAN (R 4.4.1)
   farver              2.1.2      2024-05-13 [1] CRAN (R 4.4.1)
   fastmap             1.2.0      2024-05-15 [1] CRAN (R 4.4.1)
   fastmatch           1.1-4      2023-08-18 [1] CRAN (R 4.3.1)
   forcats           * 1.0.0      2023-01-29 [1] CRAN (R 4.4.1)
   foreach             1.5.2      2022-02-02 [1] CRAN (R 4.3.2)
   fs                  1.6.5      2024-10-30 [1] CRAN (R 4.4.1)
   generics            0.1.3      2022-07-05 [1] CRAN (R 4.3.2)
   ggdist              3.3.2      2024-03-05 [1] CRAN (R 4.4.1)
   ggfun               0.1.7      2024-10-24 [1] CRAN (R 4.4.1)
   ggplot2           * 3.5.1      2024-04-23 [1] CRAN (R 4.4.1)
   ggplotify           0.1.2      2023-08-09 [1] CRAN (R 4.3.2)
   ggtree            * 3.10.0     2023-10-24 [1] Bioconductor
   glue                1.8.0      2024-09-30 [1] CRAN (R 4.4.1)
   gridExtra           2.3        2017-09-09 [1] CRAN (R 4.3.2)
   gridGraphics        0.5-1      2020-12-13 [1] CRAN (R 4.3.2)
   gtable              0.3.6      2024-10-25 [1] CRAN (R 4.4.1)
   hms                 1.1.3      2023-03-21 [1] CRAN (R 4.3.2)
   hoardr              0.5.5      2025-01-18 [1] CRAN (R 4.4.3)
   httr                1.4.7      2023-08-15 [1] CRAN (R 4.3.2)
   igraph              2.1.1      2024-10-19 [1] CRAN (R 4.4.1)
   inline              0.3.19     2021-05-31 [1] CRAN (R 4.3.2)
   insight             0.20.5     2024-10-02 [1] CRAN (R 4.4.1)
   iterators           1.0.14     2022-02-05 [1] CRAN (R 4.3.2)
   jsonlite            1.8.9      2024-09-20 [1] CRAN (R 4.4.1)
   labeling            0.4.3      2023-08-29 [1] CRAN (R 4.3.1)
   latex2exp           0.9.6      2022-11-28 [1] CRAN (R 4.3.2)
   lattice             0.22-6     2024-03-20 [2] CRAN (R 4.4.2)
   lazyeval            0.2.2      2019-03-15 [1] CRAN (R 4.3.2)
   lifecycle           1.0.4      2023-11-07 [1] CRAN (R 4.3.2)
   loo                 2.8.0      2024-07-03 [1] CRAN (R 4.4.1)
   lubridate         * 1.9.3      2023-09-27 [1] CRAN (R 4.4.1)
   magrittr            2.0.3      2022-03-30 [1] CRAN (R 4.3.2)
   maps                3.4.2      2023-12-15 [1] CRAN (R 4.4.1)
   MASS                7.3-61     2024-06-13 [2] CRAN (R 4.4.2)
   Matrix              1.7-1      2024-10-18 [1] CRAN (R 4.4.1)
   matrixStats       * 1.4.1      2024-09-08 [1] CRAN (R 4.4.1)
   memoise             2.0.1      2021-11-26 [1] CRAN (R 4.3.2)
   mnormt              2.1.1      2022-09-26 [1] CRAN (R 4.3.1)
   multcomp            1.4-26     2024-07-18 [1] CRAN (R 4.4.1)
   munsell             0.5.1      2024-04-01 [1] CRAN (R 4.4.1)
   mvtnorm             1.3-2      2024-11-04 [1] CRAN (R 4.4.2)
   nlme                3.1-166    2024-08-14 [2] CRAN (R 4.4.2)
   numDeriv            2016.8-1.1 2019-06-06 [1] CRAN (R 4.3.1)
   openssl             2.2.2      2024-09-20 [1] CRAN (R 4.4.1)
   optimParallel       1.0-2      2021-02-11 [1] CRAN (R 4.3.2)
   patchwork         * 1.3.0      2024-09-16 [1] CRAN (R 4.4.1)
   phangorn            2.12.1     2024-09-17 [1] CRAN (R 4.4.1)
   phytools            2.3-0      2024-06-13 [1] CRAN (R 4.4.1)
   pillar              1.9.0      2023-03-22 [1] CRAN (R 4.3.2)
   pkgbuild            1.4.5      2024-10-28 [1] CRAN (R 4.4.1)
   pkgconfig           2.0.3      2019-09-22 [1] CRAN (R 4.3.2)
   pkgload             1.4.0      2024-06-28 [1] CRAN (R 4.4.1)
   plyr                1.8.9      2023-10-02 [1] CRAN (R 4.3.2)
   posterior           1.6.0      2024-07-03 [1] CRAN (R 4.4.1)
   prettyunits         1.2.0      2023-09-24 [1] CRAN (R 4.3.2)
   progress            1.2.3      2023-12-06 [1] CRAN (R 4.4.1)
   purrr             * 1.0.2      2023-08-10 [1] CRAN (R 4.4.1)
   quadprog            1.5-8      2019-11-20 [1] CRAN (R 4.3.1)
   QuickJSR            1.4.0      2024-10-01 [1] CRAN (R 4.4.1)
   R6                  2.5.1      2021-08-19 [1] CRAN (R 4.3.2)
   ragg                1.3.3      2024-09-11 [1] CRAN (R 4.4.1)
   rappdirs            0.3.3      2021-01-31 [1] CRAN (R 4.3.2)
   Rcpp              * 1.0.14     2025-01-12 [1] CRAN (R 4.4.2)
 D RcppParallel        5.1.9      2024-08-19 [1] CRAN (R 4.4.1)
   readr             * 2.1.5      2024-01-10 [1] CRAN (R 4.4.1)
   rentrez             1.2.3      2020-11-10 [1] CRAN (R 4.3.2)
   reshape2            1.4.4      2020-04-09 [1] CRAN (R 4.3.2)
   rlang               1.1.4      2024-06-04 [1] CRAN (R 4.4.1)
   rncl                0.8.7      2023-01-08 [1] CRAN (R 4.3.2)
   rotl              * 3.1.0      2023-06-15 [1] CRAN (R 4.4.3)
   rprojroot           2.0.4      2023-11-05 [1] CRAN (R 4.3.2)
   RSQLite             2.3.7      2024-05-27 [1] CRAN (R 4.4.1)
   rstan               2.32.6     2024-03-05 [1] CRAN (R 4.4.1)
   rstantools          2.4.0      2024-01-31 [1] CRAN (R 4.4.1)
   rstudioapi          0.17.1     2024-10-22 [1] CRAN (R 4.4.1)
   rtrees            * 1.0.3      2025-03-16 [1] https://daijiang.r-universe.dev (R 4.4.3)
   sandwich            3.1-1      2024-09-15 [1] CRAN (R 4.4.1)
   scales              1.3.0      2023-11-28 [1] CRAN (R 4.4.1)
   scatterplot3d       0.3-44     2023-05-05 [1] CRAN (R 4.3.1)
   sessioninfo         1.2.2      2021-12-06 [1] CRAN (R 4.3.2)
 R specter           * 0.0.1      <NA>       [?] <NA>
   StanHeaders         2.32.10    2024-07-15 [1] CRAN (R 4.4.1)
   stringi             1.8.4      2024-05-06 [1] CRAN (R 4.4.0)
   stringr           * 1.5.1      2023-11-14 [1] CRAN (R 4.4.1)
   survival            3.7-0      2024-06-05 [1] CRAN (R 4.4.1)
   svUnit              1.0.6      2021-04-19 [1] CRAN (R 4.3.2)
   systemfonts         1.1.0      2024-05-15 [1] CRAN (R 4.4.1)
   taxadb            * 0.2.1.99   2025-05-12 [1] Github (ropensci/taxadb@6c2023d)
   taxizedb          * 0.3.2      2025-06-18 [1] CRAN (R 4.4.3)
   tensorA             0.36.2.1   2023-12-13 [1] CRAN (R 4.4.0)
   terra             * 1.7-83     2024-10-14 [1] CRAN (R 4.4.1)
   testthat            3.2.1.1    2024-04-14 [1] CRAN (R 4.4.1)
   textshaping         0.4.0      2024-05-24 [1] CRAN (R 4.4.1)
   TH.data             1.1-2      2023-04-17 [1] CRAN (R 4.3.2)
   tibble            * 3.2.1      2023-03-20 [1] CRAN (R 4.3.2)
   tidybayes           3.0.7      2024-09-15 [1] CRAN (R 4.4.1)
   tidyr             * 1.3.1      2024-01-24 [1] CRAN (R 4.4.1)
   tidyselect          1.2.1      2024-03-11 [1] CRAN (R 4.4.1)
   tidytree            0.4.6      2023-12-12 [1] CRAN (R 4.4.1)
   tidyverse         * 2.0.0      2023-02-22 [1] CRAN (R 4.4.1)
   timechange          0.3.0      2024-01-18 [1] CRAN (R 4.4.1)
   treeio              1.26.0     2023-10-24 [1] Bioconductor
   tzdb                0.4.0      2023-05-12 [1] CRAN (R 4.3.2)
   utf8                1.2.4      2023-10-22 [1] CRAN (R 4.3.2)
   V8                  6.0.0      2024-10-12 [1] CRAN (R 4.4.1)
   vctrs               0.6.5      2023-12-01 [1] CRAN (R 4.4.1)
   vmisc             * 0.2.0      2025-12-11 [1] Github (vsbpan/vmisc@bd11334)
   vroom               1.6.5      2023-12-05 [1] CRAN (R 4.4.1)
   withr               3.0.2      2024-10-28 [1] CRAN (R 4.4.1)
   XML                 3.99-0.17  2024-06-25 [1] CRAN (R 4.4.1)
   xtable              1.8-4      2019-04-21 [1] CRAN (R 4.3.2)
   yulab.utils         0.1.7      2024-08-26 [1] CRAN (R 4.4.1)
   zoo                 1.8-12     2023-04-13 [1] CRAN (R 4.3.2)

About

Analysis of biological time series frequency spectra and their changes over time

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages