{EnvRtype} - The Envirotyper Library in Genetics EnvRtype logo

version G3 paper DOI License: GPL-3 pkgdown Visitors

EnvRtype is an R package for enviromics — the study of the envirome, the set of environmental conditions linked to the biological performance of living beings (Costa-Neto and Fritsche-Neto, 2021; Crossa et al., 2021). It collects worldwide daily weather and soil data, derives agro-meteorological parameters, builds environmental covariable matrices and relatedness kernels, mines environmental typologies, delineates soil zones with Gaussian mixture models, and runs a FAO-56 soil water balance for use in enviromics and genotype-by-environment (GxE) analyses.

This is a fully re-engineered successor to the original EnvRtype (allogamous/EnvRtype, 2021), extending it from a weather-typing toolbox into an end-to-end envirotyping, simulation and prediction framework.

📄 Original publication: Costa-Neto, G., Galli, G., Carvalho, H. F., Crossa, J., & Fritsche-Neto, R. (2021). EnvRtype: a software to interplay enviromics and quantitative genomics in agriculture. G3 Genes|Genomes|Genetics, 11(4), jkab040. Read the paper →

📖 Documentation: https://gcostaneto.github.io/EnvRtype/

Installation

if (!require("devtools")) install.packages("devtools")
devtools::install_github("gcostaneto/EnvRtype")
library(EnvRtype)

What’s new compared to the original EnvRtype (2021)

The original EnvRtype (Costa-Neto et al., 2021, G3) focused on collecting NASA POWER weather data, computing environmental typologies and building environmental kernels for reaction-norm models. This version keeps that workflow and adds several new layers:

Area Original EnvRtype (2021) EnvRtype (this version)
Weather data get_weather() (NASA POWER, daily) get_weather() + hourly (get_weather_hourly()) and resumable / restartable downloads (get_weather_resumable(), read_progress_log(), restart_from_log())
Soil data — get_soil(), get_soil_resumable(), soil_classification() (Gaussian-mixture soil zoning)
Other geodata — get_elevation(), get_bioclim(), get_spatial(), get_AEZ() (with helpers aez_legend(), aez_default_url()), get_climate_scenario()
Processing processWTH(), param_temperature/radiation/atmospheric(), summaryWTH() Same, plus a full FAO-56 water balance (water_balance(), summary_water_balance()) and phenology (env_phenology(), phenology_templates(), planting_window_table(), best_planting_date(), show_phenology(), plot_planting_window())
Characterisation W_matrix(), env_typing() Adds T_matrix(), env_indices(), env_expand(), a full PCA suite (env_pca(), env_pca_biplot(), env_pca_scree(), env_loading_curve(), env_pc_associate()), correlation tools (env_cor(), env_cor_heatmap()) and coverage/target diagnostics (coverage_summary(), env_target_importance())
Risk & TPE — env_risk_profile(), env_copula(), tpe_weights(), project_risk(), env_target_importance()
Kernels env_kernel(), get_kernel() Adds decompose_kernels(), undecompose_kernels(), truncate_gxe_kernel() and a soil kernel path in get_kernel()
Modelling kernel_model() Adds kernel_cv(), kernel_model_clustered(), kernel_model_mc(), varcomp_summary(), environment clustering (env_cluster(), cluster_environments())
Untested environments — scan_untested_envs(), grid_scan(), map_scan(), scan_spatial_table()
Simulation — Ground-truth simulator: sim_met(), sim_met_C(), sim_W(), sim_W_grid(), plus controllable-diversity data generators sim_markers() (genetic diversity) and sim_envirome() (environmental diversity), to validate every layer against a known truth
License MIT GPL-3 (CRAN-ready)

Package modules & workflow

The package is organised in four data layers — acquisition, processing, characterisation and prediction — plus a simulation engine that generates ground-truth data to validate each layer. Each subsection lists the functions involved and the primary references used to build them.

Overview — the four layers + simulation

Design follows the enviromics reaction-norm framework of Costa-Neto et al. (2021, G3) and its envirome-wide extension (Costa-Neto et al., 2023, G3).

flowchart TB
  L1["<b>1 · ACQUIRE</b><br/>get_weather · get_soil · get_elevation<br/>get_bioclim · get_spatial · get_AEZ<br/>get_climate_scenario · + resumable/hourly variants"]
  L2["<b>2 · PROCESS</b><br/>processWTH · summaryWTH · param_*<br/>water_balance · env_phenology"]
  L3["<b>3 · CHARACTERISE</b><br/>W_matrix · T_matrix · env_indices · env_pca<br/>soil_classification · env_typing · env_risk_profile"]
  L4["<b>4 · MODEL &amp; SCAN</b><br/>env_kernel · get_kernel · kernel_model<br/>kernel_cv · scan_untested_envs · map_scan"]
  SIM["<b>SIMULATE</b><br/>sim_markers · sim_envirome<br/>sim_met() → C_env → sim_W()<br/><i>ground truth for every layer</i>"]

  L1 --> L2 --> L3 --> L4
  SIM -.->|"validates"| L3
  SIM -.->|"validates"| L4

  classDef l1 fill:#1565c0,stroke:#0d47a1,color:#fff
  classDef l2 fill:#1976d2,stroke:#0d47a1,color:#fff
  classDef l3 fill:#2e7d32,stroke:#1b5e20,color:#fff
  classDef l4 fill:#c62828,stroke:#b71c1c,color:#fff
  classDef sim fill:#6a1b9a,stroke:#4a148c,color:#fff
  class L1 l1
  class L2 l2
  class L3 l3
  class L4 l4
  class SIM sim

1–2 · Data acquisition and processing

Weather and geodata come from NASA POWER via nasapower (Sparks, 2018), SoilGrids 2.0 (Poggio et al., 2021), WorldClim 2 (Fick & Hijmans, 2017), bioclimatic predictors (O’Donnell & Ignizio, 2012), CMIP6 / ScenarioMIP scenarios (Hawkins et al., 2013; O’Neill et al., 2016) and GAEZ v4 (FAO & IIASA, 2021). Agro-meteorological processing, the FAO-56 soil water balance and phenology follow Allen et al. (1998), Pereira et al. (2021), Doorenbos & Kassam (1979), Steduto et al. (2012), Borg & Grimes (1986), Forsythe et al. (1995), Zadoks et al. (1974) and Counce et al. (2000).

flowchart LR
  GW["get_weather()"]
  GWH["get_weather_hourly()"]
  GWR["get_weather_resumable()"]
  RPL["read_progress_log()"]
  RFL["restart_from_log()"]
  GS["get_soil()"]
  GSR["get_soil_resumable()"]
  GEL["get_elevation()"]
  GBC["get_bioclim()"]
  GSP["get_spatial()"]
  GAEZ["get_AEZ()"]
  GCS["get_climate_scenario()"]

  PRAD["param_radiation()"]
  PATM["param_atmospheric()"]
  PTMP["param_temperature()"]
  PWT["processWTH()"]
  SWT["summaryWTH()"]

  EPH["env_phenology()"]
  PHT["phenology_templates()"]
  PWD["planting_window_table()"]
  BPD["best_planting_date()"]
  SPH["show_phenology()"]
  PPW["plot_planting_window()"]

  WBAL["water_balance()"]
  SWB["summary_water_balance()"]

  GWR --> RPL --> RFL --> GW
  GW --> PWT
  GWH --> PWT
  PRAD --> PWT
  PTMP --> PWT
  GEL --> PATM
  PATM --> PWT
  PWT --> SWT
  PWT --> EPH
  PHT --> EPH
  EPH --> PWD
  EPH --> SPH
  PWD --> BPD
  PWD --> PPW
  PWT --> WBAL
  GSR --> GS
  GS --> WBAL
  GEL --> WBAL
  WBAL --> SWB

  classDef collect fill:#1565c0,stroke:#0d47a1,color:#fff
  classDef char fill:#2e7d32,stroke:#1b5e20,color:#fff
  classDef wb fill:#0097a7,stroke:#006064,color:#fff
  class GW,GWH,GWR,RPL,RFL,GS,GSR,GEL,GBC,GSP,GAEZ,GCS,PRAD,PATM,PTMP,PWT,SWT collect
  class EPH,PHT,PWD,BPD,SPH,PPW char
  class WBAL,SWB wb

3 · Characterisation and dissection

Environmental covariables, typologies and kernels follow Costa-Neto et al. (2021, G3); interval-resolved indices follow Della Coletta et al. (2023); breeding-zone typologies and target-population importance follow Costa-Neto et al. (2023, Agronomy Journal); copula reparameterisation follows Sklar (1959), Genest & Rivest (1993) and Salvadori et al. (2007); Gaussian-mixture soil zoning follows Fraley & Raftery (2002), Scrucca et al. (2016) and Egozcue et al. (2003).

flowchart LR
  SWT["summaryWTH()"]
  GS["get_soil()"]
  WM["W_matrix()"]
  ETYP["env_typing()"]
  TM["T_matrix()"]
  EEX["env_expand()"]
  ECOP["env_copula()"]
  ERP["env_risk_profile()"]
  TPW["tpe_weights()"]
  PRK["project_risk()"]
  ETI["env_target_importance()"]
  CVS["coverage_summary()"]
  GCS["get_climate_scenario()"]
  SCL["soil_classification()"]

  EIX["env_indices()"]
  EPC["env_pca()"]
  EPS["env_pca_scree()"]
  EPB["env_pca_biplot()"]
  ELC["env_loading_curve()"]
  ECOR["env_cor()"]
  ECH["env_cor_heatmap()"]
  EPA["env_pc_associate()"]

  SWT --> WM
  WM --> ETYP
  ETYP --> TM
  WM --> EEX
  WM --> ECOP
  WM --> ETI
  ERP --> TPW
  ERP --> PRK
  GCS --> PRK
  TPW --> CVS
  GS --> SCL
  EIX --> WM
  EIX --> EPC
  EIX --> ECOR
  ECOR --> ECH
  EPC --> EPS
  EPC --> EPB
  EPC --> ELC
  EPC --> EPA

  classDef char fill:#2e7d32,stroke:#1b5e20,color:#fff
  classDef dis fill:#6a1b9a,stroke:#4a148c,color:#fff
  classDef collect fill:#1565c0,stroke:#0d47a1,color:#fff
  class WM,ETYP,TM,EEX,ECOP,ERP,TPW,PRK,ETI,CVS,SCL char
  class EIX,EPC,EPS,EPB,ELC,ECOR,ECH,EPA dis
  class SWT,GS,GCS collect

4 · Prediction and scanning

Reaction-norm and kernel models follow Costa-Neto et al. (2021, G3), the nonlinear / Gaussian kernels of Costa-Neto, Fritsche-Neto & Crossa (2021, Heredity) and the deep kernels of Cuevas et al. (2019); the GxE modelling engine follows the BGGE approach of Granato et al. (2018); scanning of untested environments follows the envirome-wide prediction of Costa-Neto et al. (2023, G3).

flowchart TB
  EK["env_kernel()"]
  GK["get_kernel()<br/>K_G · K_E · K_S"]
  DK["decompose_kernels()"]
  UDK["undecompose_kernels()"]
  TGK["truncate_gxe_kernel()"]
  KM["kernel_model()"]
  KCV["kernel_cv()"]
  KMC["kernel_model_clustered()"]
  KMM["kernel_model_mc()"]
  ECL["env_cluster()"]
  CLE["cluster_environments()"]
  VCS["varcomp_summary()"]
  SUE["scan_untested_envs()"]
  GSC["grid_scan()"]
  MSC["map_scan()"]
  SST["scan_spatial_table()"]
  CVS["coverage_summary()"]

  EK --> GK
  GK --> DK
  DK --> UDK
  DK --> TGK
  TGK --> KM
  DK --> KM
  KM --> KCV
  KM --> VCS
  KM --> SUE
  ECL --> CLE
  CLE --> KMC
  KM --> KMM
  SUE --> GSC
  SUE --> MSC
  SUE --> SST
  SUE --> CVS

  classDef pred fill:#c62828,stroke:#b71c1c,color:#fff
  classDef rel fill:#ef6c00,stroke:#e65100,color:#fff
  classDef char fill:#2e7d32,stroke:#1b5e20,color:#fff
  class GK,DK,UDK,TGK,KM,KCV,KMC,KMM,VCS,SUE,GSC,MSC,SST,CVS pred
  class EK rel
  class ECL,CLE char

Simulation — closing the validation loop

The simulator encodes a known environmental covariance and reaction-norm structure to benchmark every layer, following the envirome-wide prediction framework of Costa-Neto et al. (2023, G3) and the kernel models of Costa-Neto et al. (2021, G3). sim_markers() and sim_envirome() additionally generate marker and envirome data with controllable genetic and environmental diversity (MAF spectrum, population structure, linkage; mega-environments, gradients and covariable redundancy), feeding sim_met() and get_kernel() directly.

flowchart LR
  SMK["sim_markers()<br/><i>genetic diversity</i>"]
  K["genomic kinship K<br/><i>n × n lines</i>"]
  SEV["sim_envirome()<br/><i>environmental diversity</i>"]
  SMC["sim_met_C()<br/><i>q × q envs</i>"]
  SM["sim_met()"]
  CE["$C_env<br/><i>q × q correlation<br/>among environments</i>"]
  PH["$data<br/>env · gid · rep · value"]
  SW["sim_W()"]
  SWG["sim_W_grid()"]
  W["simulated W<br/><i>known % explained</i>"]
  GK["get_kernel()"]
  KM["kernel_model()"]
  VCS["varcomp_summary()"]
  CHK{{"compare to<br/>known truth"}}

  SMK --> K
  K --> SM
  K --> GK
  SEV --> SM
  SEV --> GK
  SMC --> SM
  SM --> CE
  SM --> PH
  CE --> SW
  SW --> W
  SWG --> W
  W --> GK
  PH --> KM
  GK --> KM
  KM --> VCS
  VCS --> CHK
  SM -.->|"$truth"| CHK

  classDef sim fill:#6a1b9a,stroke:#4a148c,color:#fff
  classDef pred fill:#c62828,stroke:#b71c1c,color:#fff
  classDef data fill:#455a64,stroke:#263238,color:#fff
  classDef chk fill:#f9a825,stroke:#f57f17,color:#000
  class SM,SW,SWG,SMC,SMK,SEV sim
  class GK,KM,VCS pred
  class K,CE,PH,W data
  class CHK chk

Prediction

EnvRtype fits enviromics-enabled reaction-norm models in which phenotypes are regressed on genomic, environmental and GxE relatedness kernels. The current prediction workflow provides:

These tools implement the reaction-norm and kernel methods of Costa-Neto et al. (2021, G3), the nonlinear / Gaussian kernels of Costa-Neto, Fritsche-Neto & Crossa (2021, Heredity), the deep kernels of Cuevas et al. (2019, G3), the BGGE GxE engine of Granato et al. (2018, G3), and the envirome-wide prediction of untested environments of Costa-Neto et al. (2023, G3). Full citations are listed under References for the new functions below.


Acknowledgements

Original EnvRtype team (2020–2021)

EnvRtype began in 2020 and was first published as allogamous/EnvRtype in Costa-Neto, G., Galli, G., Carvalho, H. F., Crossa, J., & Fritsche-Neto, R. (2021). EnvRtype: a software to interplay enviromics and quantitative genomics in agriculture. G3: Genes|Genomes|Genetics, 11(4), jkab040. We gratefully acknowledge the original authors and the community of users whose feedback shaped this new version.

Current maintainers and developers


References for the new functions

The methods and data sources underlying the new and extended functions are documented below, grouped by module.

Enviromics framework, kernels and genomic prediction

Environmental characterisation, typologies and target-population importance

Copula-based environmental indices (env_copula)

Environmental data acquisition (weather, soil, elevation, bioclimate, scenarios, agro-ecological zones)

Water balance, evapotranspiration and phenology

Soil classification and Gaussian-mixture risk zoning


Citation

If you use EnvRtype in your research, please cite the original publication:

Costa-Neto, G., Galli, G., Carvalho, H. F., Crossa, J., & Fritsche-Neto, R. (2021). EnvRtype: a software to interplay enviromics and quantitative genomics in agriculture. G3 Genes|Genomes|Genetics, 11(4), jkab040. https://doi.org/10.1093/g3journal/jkab040

🔗 academic.oup.com/g3journal/article/11/4/jkab040/6129777

BibTeX
@article{costaneto2021envrtype,
  title   = {EnvRtype: a software to interplay enviromics and quantitative genomics in agriculture},
  author  = {Costa-Neto, Germano and Galli, Giovanni and Carvalho, Humberto Fanelli
             and Crossa, Jos{\'e} and Fritsche-Neto, Roberto},
  journal = {G3 Genes|Genomes|Genetics},
  volume  = {11},
  number  = {4},
  pages   = {jkab040},
  year    = {2021},
  doi     = {10.1093/g3journal/jkab040},
  url     = {https://academic.oup.com/g3journal/article/11/4/jkab040/6129777}
}

From within R:

citation("EnvRtype")

Please also kindly let the maintainer know when you are using EnvRtype (contact germano.cneto@gmail.com).


License

Released under the GPL-3 license — free and open source. You may use, study, modify and redistribute the code, provided derivative works remain under the same terms.