## Overview

The ClimMobTools package provides the toolkit employed in crowdsourcing citizen science projects under the tricot approach. Tricot, stands for “triadic comparison of technologies”, an approach developed by van Etten et al. (2016)1 for the rapid assessment of on-farm evaluation trails in small-scale agriculture. Tricot turns the research paradigm on its head; instead of a few researchers designing complicated trials to compare several technologies in search of the best solutions, it enables many farmers to carry out reasonably simple experiments that taken together can offer even more information.

## Installation

The package may be installed from CRAN via

install.packages("ClimMobTools")

The development version can be installed via

library("devtools")

devtools::install_github("agrobioinfoservices/ClimMobTools")


# Usage

The 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 the function getDataCM from ClimMobTools and an API key from the ClimMob portal.

library("ClimMobTools")
library("tidyverse")
library("magrittr")

# the API key
key <- "d39a3c66-5822-4930-a9d4-50e7da041e77"

data <- ClimMobTools::getDataCM(key = key,
tidynames = TRUE)

# reshape the data into the wide format
data %<>%
filter(!str_detect(variable, "survey")) %>%
group_by(id) %>%
distinct(id, variable, value) %>%
ungroup()


## Environmental variables

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 covariates 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 trials4 and can 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 varietal recommendations for climate adaptation6.

The environmental data can be calculated 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 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 (lonlat), ClimMobTools makes an internal call to nasapower9 to fetch the required time series data and calculate 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.

### Temperature

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 or the first day of a growing season.

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 the entire data set or a vector indicating the time span for each observation.

Here we calculate the temperature indices for a time span of 120 days after the planting date using the function temperature from ClimMobTools.

# first we convert the lonlat into numeric
# and the planting dates into Date
data %<>%
mutate(lon = as.numeric(lon),
lat = as.numeric(lat),
plantingdate = as.Date(plantingdate,
format = "%Y-%m-%d"))

# then we get the temperature indices
temp <- temperature(data[c("lon","lat")],
day.one = data["plantingdate"],
span = 120)


### Rainfall

Precipitation indices can be calculated in the same way as the temperature indices. The input can be either the geographic coordinates or a matrix with CHIRPS data.

Here we use the NASA POWER data with a time span of 120 days after planting date using the function rainfall from ClimMobTools.

rain <- rainfall(data[c("lon","lat")],
day.one = data["plantingdate"],
span = 120)


Function rainfall has also a feature that enables the indices to be calculated from some days before the planting date. This is important for some studies where a residual precipitation must be taken into account. To do so, we use the argument days.before:

rain <- rainfall(data[c("lon","lat")],
day.one = data["plantingdate"],
span = 120,
days.before = 15)


# Model with environmental variables

The Plackett-Luce model is one approach to analyse the ClimMob data2. To do so, we build the farmers’ rankings as an object of class ‘grouped_rankings’. This allows the rankings to be linked to explanatory variables and fit the model using pltree from PlackettLuce.

We build the rankings using the function build_rankings from ClimMobTools.

G <- build_rankings(data,
items = c("item_A","item_B","item_C"),
input = c("overallperf_pos","overallperf_neg"),
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 Plackett-Luce model shows that the bread wheat varieties had a different performance under a threshold of 15.5 degrees Celsius for the diurnal temperature range (DTR).

# References

1. van Etten, J., Beza, E., Calderer, L. & van Duijvendijk, K. et al. First experiences with a novel farmer citizen science approach: Crowdsourcing participatory variety selection through on-farm triadic comparisons of technologies (tricot). Experimental Agriculture 1–22 (2016).

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).