diff --git a/NEWS.md b/NEWS.md index 3204e0d..1a36224 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,7 @@ * Tests coverage > 90% * Validations in `temperature`, `rainfall`, `getDataCM`, and `ETo` +* A single vignette for the package Overview ## CRAN issues diff --git a/docs/CODE_OF_CONDUCT.html b/docs/CODE_OF_CONDUCT.html index c99c3c4..57f69db 100644 --- a/docs/CODE_OF_CONDUCT.html +++ b/docs/CODE_OF_CONDUCT.html @@ -82,9 +82,6 @@
- Department of Agricultural Sciences, Høgskolen i Innlandet, Norway; and Bioversity InternationalThe breadwheat
is a dataframe from crowdsourcing citizen-science trials of bread wheat (Triticum aestivum) varieties in India. This is a sample data available at the ClimMob that can be fetched using using the function getDataCM
from ClimMobTools and an API key from the ClimMob portal.
library("ClimMobTools")
-# library("devtools")
-# devtools::install_github("agrobioinfoservices/gosset", upgrade = "never")
-library("gosset")
-library("PlackettLuce")
library("tidyverse")
library("magrittr")
@@ -126,31 +119,29 @@
key <- "d39a3c66-5822-4930-a9d4-50e7da041e77"
data <- ClimMobTools::getDataCM(key = key,
- project = "breadwheat")
The function getDataCM
returns a dataframe in the long format to allows the organisation of projects with different structure. We can put this into wide format where each row is a farmer observation using tidyverse.
# reshape the data into the wide format
-# we also remove some variables that refer to the ODK survey employed for the data collection
+ project = "breadwheat",
+ tidynames = TRUE)
+
+# reshape the data into the wide format
data %<>%
filter(!str_detect(variable, "survey")) %>%
group_by(id) %>%
distinct(id, variable, value) %>%
- spread(variable, value)
The PlackettLuce model is one approach to analyse the tricot data2. To do so, we need to convert the farmers’ ranking into a object of class ‘rankings’ or ‘grouped_rankings’. A object of class ‘rankings’ is a matrix of dense rankings that can be used to fit a PlackettLuce model using PlackettLuce
from PlackettLuce. A object of class ‘grouped_rankings’ associates a group index with an object of class ‘rankings’, then it allows the rankings to be linked to explanatory variables and fit a PlackettLuce model using pltree
from PlackettLuce.
We can convert the farmers’ rankings in into a rankings object using the function to_rankings
from package gosset. The argument grouped.rankings
return a object of class ‘grouped_rankings’.
Environmental variables can easily be included into the data set using the longitude and latitude information from the tricot and the planting dates for each plot. In this exercise we include the heat stress indices using the function temperature
from ClimMobTools.
Understanding how different crop varieties respond to environmental variation is a valuable approach to provide recommendations based on genotype x environment (GxE) interactions for climate adaptation. ClimMobTools provides the toolkit to compute environmental variables that serves as input for the ranking analysis with explanatory variables using Plackett-Luce2 or Bradley-Terry3 model.
+The climatic variables available in ClimMobTools were previously used for the environmental analysis of wheat trial data4 and explain the changes in climatic patterns due to climate change5. In a more advanced analysis, these variables can be applied with seasonal forecasts and risk analysis to provide farm recommendations for climate adaptation6.
+The environmental data can be computed using input from time series databases such as the Climate Hazards Group InfraRed Precipitation with Station data (CHIRPS)7 for rainfall, and MODIS (MYD11A2)8 for land surface temperature. These databases has the advantage to be free and publicly available sources of global coverage and a high resolution (0.05°), and have been used in previous studies with ClimMob data6. However, it requires much computer capacity to extract this information and produce the matrix for the environmental indices. MODIS data also requires some work to reduce noise and fill gaps.
+The other alternative relies on using NASA POWER. By providing the planting dates and the geographic information (lon and lat), ClimMobTools makes an internal call to nasapower9 to fetch the required time series data and compute the environmental indices. It do not requires much computer capacity but requires a persistent internet connection. NASAPOWER, however has a low grid resolution (0.5°) compared to MODIS and CHIRPS and could not provide the expected results for GxE interactions in a narrow geographical range.
+ClimMobTools functions to compute environmental indices has the basics input data; a numeric vector of geographic information (lonlat) or an array with day and night temperature (from sources like MODIS) and the a vector of class Date
for the first day that will be taken into account for the environmental indices. Generally the Date
vector is the planting date from when the experiment were established, but can also refer to other phenological event during the plant development, such as day of 50% flowering.
The duration from where the environmental indices will be computed is defined by the argument span
which can be a single integer that takes into account a single time span for all tricot experiments or a vector indicating the time span for each of the observations.
Here we compute the temperature indices for a time span of 120 days after the planting date using the function temperature
from ClimMobTools.
# first we convert the lon lat into numeric
# and the planting dates into Date
@@ -165,17 +156,44 @@
# from the planting date to the next 120 days
temp <- temperature(data[c("lon","lat")],
day.one = data["plantingdate"],
- span = 120)
-
-
-modeldata <- cbind(G, temp)
Precipitation indices can also be computed in the same way as the temperature indices. The external input data can be fetched by NASA POWER or by providing a matrix with CHIRPS data.
+Here we use the NASA POWER data with a time span defined by the growing degree days using the function rainfall
from ClimMobTools.
Function rainfall
has also a feature that enables the indices to be calculated from some days before the planting date. This is important for case studies where a residual precipitation must be taken into account. To do so, we use the argument days.before
:
Now we fit the model using the function pltree
from PlackettLuce with temperature indices as explanatory variables.
tree <- pltree(G ~ ., data = modeldata, npseudo = 5)
The Plackett-Luce model is one approach to analyse the tricot data2. To do so, we need to convert the farmers’ ranking into an object of class ‘grouped_rankings’. An object of class ‘grouped_rankings’ allows the rankings to be linked to explanatory variables and fit the model using pltree
from PlackettLuce.
We can convert the farmers’ rankings in into a grouped_rankings object using the function to_rankings
from package gosset.
# library("devtools")
+# devtools::install_github("agrobioinfoservices/gosset", upgrade = "never")
+library("gosset")
+
+G <- to_rankings(data,
+ items = c("item_A","item_B","item_C"),
+ input = c("overallperf_pos","overallperf_neg"),
+ type = "tricot",
+ grouped.rankings = TRUE)
Finally, we fit the model using the function pltree
from PlackettLuce with temperature and rainfall indices as explanatory variables.
library("PlackettLuce")
+
+modeldata <- cbind(G, temp, rain)
+
+tree <- pltree(G ~ ., data = modeldata, npseudo = 5)
The PlackettLuce model shows that the bread wheat variaties had a different performance under a threshold of 15.5 degrees Celsius for the diurnal temperature range (DTR).
2. Turner, H., van Etten, J., Firth, D. & Kosmidis, I. Modelling rankings in R: The PlackettLuce package. arXiv:1810.12068 (2018).
3. Wickelmaier, F. & Zeileis, A. Using recursive partitioning to account for parameter heterogeneity in multinomial processing tree models. Behavior Research Methods 50, 1217–1233 (2018).
+4. Kehel, Z., Crossa, J. & Reynolds, M. Identifying Climate Patterns during the Crop-Growing Cycle from 30 Years of CIMMYT Elite Spring Wheat International Yield Trials. in Applied mathematics and omics to assess crop genetic resources for climate change adaptive traits (eds. Bari, A., Damania, A. B., Mackay, M. & Dayanandan, S.) 151–174 (CRC Press, 2016).
+5. Aguilar, E., Peterson, T. C., Obando, P. R. & Frutos, R. et al. Changes in precipitation and temperature extremes in Central America and northern South America, 1961–2003. Journal of Geophysical Research 110, D23107 (2005).
+6. van Etten, J., de Sousa, K., Aguilar, A. & Barrios, M. et al. Crop variety management for climate adaptation supported by citizen science. Proceedings of the National Academy of Sciences 116, 4194–4199 (2019).
+7. Funk, C., Peterson, P., Landsfeld, M. & Pedreros, D. et al. The climate hazards infrared precipitation with stations—a new environmental record for monitoring extremes. Scientific Data 2, 150066 (2015).
+8. Wan, Z., Hook, S. & Hulley, G. MYD11A1 MODIS/Aqua Land Surface Temperature/Emissivity Daily L3 Global 1km SIN Grid V006 [Data set]. NASA EOSDIS LP DAAC (2015). doi:10.5067/MODIS/MYD11A1.006
+9. Sparks, A. H. nasapower: A NASA POWER Global Meteorology, Surface Solar Energy and Climatology Data Client for R. Journal of Open Source Software 3, 1035 (2018).
+