The metan (multi-environment trials analysis) package provides useful functions for analyzing multi-environment trial data using parametric and nonparametric methods. The package will help you to:

  • Inspect data for possible common errors;
  • Manipulate rows and columns;
  • Manipulate numbers and strings;
  • Compute descriptive statistics;
  • Compute within-environment analysis of variance;
  • Compute AMMI analysis with prediction considering different numbers of interaction principal component axes;
  • Compute AMMI-based stability indexes;
  • Compute GGE biplot analysis;
  • Compute BLUP-based stability indexes;
  • Compute variance components and genetic parameters in mixed-effect models;
  • Perform cross-validation procedures for AMMI-family and BLUP models;
  • Compute parametric and nonparametric stability statistics
  • Implement biometrical models

For more details see the complete vignette.

Installation

Install the released version of metan from CRAN with:

Or install the development version from GitHub with:

devtools::install_github("TiagoOlivoto/metan")

# To build the HTML vignette use
devtools::install_github("TiagoOlivoto/metan", build_vignettes = TRUE)

Note: If you are a Windows user, you should also first download and install the latest version of Rtools.

For the latest release notes on this development version, see the NEWS file.

Getting started

Here, we will use the example dataset data_ge that contains data on two variables assessed in 10 genotypes growing in 14 environments. For more details see ?data_ge.

library(metan)

The first step is to inspect the data with the function inspect().

No issues while inspecting the data. Let’s continue with the analyzes!

AMMI model

Fitting the model

The AMMI model is fitted with the function performs_ammi(). To analyze multiple variables at once we can use a comma-separated vector of unquoted variable names, or use any select helper in the argument resp. Here, using everything() we apply the function to all numeric variables in the data. For more details, see the complete vignette.

Biplots

The well-known AMMI1 and AMMI2 biplots can be created with plot_scores(). Note that since performs_ammi allows analyzing multiple variables at once, e.g., resp = c(v1, v2, ...), the output model is a list, in this case with two elements (GY and HM). By default, the biplots are created for the first variable of the model. To choose another variable use the argument var (e.g., var = "HM").

GGE model

The GGE model is fitted with the function gge(). For more details, see the complete vignette.

model <- gge(data_ge, ENV, GEN, GY)
model2 <- gge(data_ge, ENV, GEN, GY, svp = "genotype")
model3 <- gge(data_ge, ENV, GEN, GY, svp = "symmetrical")
d <- plot(model)
e <- plot(model2, type = 8)
f <- plot(model2,
          type = 2,
          col.gen = "black",
          col.env = "gray70",
          axis.expand = 1.5)
arrange_ggplot(d, e, f, labels = letters[4:6], nrow = 1)

BLUP model

Linear-mixed effect models to predict the response variable in METs are fitted using the function waasb(). Here we will obtain the predicted means for genotypes in the variables GY and HM. For more details, see the complete vignette.

Plotting the BLUPs for genotypes

To produce a plot with the predicted means, use the function plot_blup().

g <- plot_blup(model2)
h <- plot_blup(model2,
               prob = 0.1,
               col.shape  =  c("gray20", "gray80")) + ggplot2::coord_flip()
arrange_ggplot(g, h, labels = letters[7:8])

Computing parametric and non-parametric stability indexes

stats <- ge_stats(data_ge, ENV, GEN, REP, GY)
get_model_data(stats, "stats")
# Class of the model: ge_stats
# Variable extracted: stats
# # A tibble: 10 x 33
#    var   gen       Y    CV   Var Shukla  Wi_g  Wi_f  Wi_u Ecoval   bij      Sij
#    <chr> <chr> <dbl> <dbl> <dbl>  <dbl> <dbl> <dbl> <dbl>  <dbl> <dbl>    <dbl>
#  1 GY    G1     2.60  35.2 10.9  0.0280  84.4  89.2  81.1  1.22  1.06  -0.00142
#  2 GY    G10    2.47  42.3 14.2  0.244   59.2  64.6  54.4  7.96  1.12   0.177  
#  3 GY    G2     2.74  34.0 11.3  0.0861  82.8  95.3  75.6  3.03  1.05   0.0497 
#  4 GY    G3     2.96  29.9 10.1  0.0121 104.   99.7 107.   0.725 1.03  -0.0128 
#  5 GY    G4     2.64  31.4  8.93 0.0640  85.9  79.5  91.9  2.34  0.937  0.0298 
#  6 GY    G5     2.54  30.6  7.82 0.0480  82.7  82.2  82.4  1.84  0.887  0.00902
#  7 GY    G6     2.53  29.7  7.34 0.0468  83.0  83.7  81.8  1.81  0.861  0.00304
#  8 GY    G7     2.74  27.4  7.33 0.122   83.9  77.6  93.4  4.16  0.819  0.0579 
#  9 GY    G8     3.00  30.4 10.8  0.0712  98.8  90.5 107.   2.57  1.03   0.0382 
# 10 GY    G9     2.51  42.4 14.7  0.167   68.8  68.9  70.3  5.56  1.19   0.0938 
# # ... with 21 more variables: R2 <dbl>, ASV <dbl>, SIPC <dbl>, EV <dbl>,
# #   ZA <dbl>, WAAS <dbl>, HMGV <dbl>, RPGV <dbl>, HMRPGV <dbl>, Pi_a <dbl>,
# #   Pi_f <dbl>, Pi_u <dbl>, Gai <dbl>, S1 <dbl>, S2 <dbl>, S3 <dbl>, S6 <dbl>,
# #   N1 <dbl>, N2 <dbl>, N3 <dbl>, N4 <dbl>
get_model_data(stats, "ranks")
# Class of the model: ge_stats
# Variable extracted: ranks
# # A tibble: 10 x 32
#    var   gen     Y_R  CV_R Var_R Shukla_R Wi_g_R Wi_f_R Wi_u_R Ecoval_R Sij_R
#    <chr> <chr> <dbl> <dbl> <dbl>    <dbl>  <dbl>  <dbl>  <dbl>    <dbl> <dbl>
#  1 GY    G1        6     8     7        2      4      4      7        2     1
#  2 GY    G10      10     9     9       10     10     10     10       10    10
#  3 GY    G2        3     7     8        7      7      2      8        7     7
#  4 GY    G3        2     3     5        1      1      1      2        1     4
#  5 GY    G4        5     6     4        5      3      7      4        5     5
#  6 GY    G5        7     5     3        4      8      6      5        4     3
#  7 GY    G6        8     2     2        3      6      5      6        3     2
#  8 GY    G7        4     1     1        8      5      8      3        8     8
#  9 GY    G8        1     4     6        6      2      3      1        6     6
# 10 GY    G9        9    10    10        9      9      9      9        9     9
# # ... with 21 more variables: R2_R <dbl>, ASV_R <dbl>, SIPC_R <dbl>,
# #   EV_R <dbl>, ZA_R <dbl>, WAAS_R <dbl>, HMGV_R <dbl>, RPGV_R <dbl>,
# #   HMRPGV_R <dbl>, Pi_a_R <dbl>, Pi_f_R <dbl>, Pi_u_R <dbl>, Gai_R <dbl>,
# #   S1_R <dbl>, S2_R <dbl>, S3_R <dbl>, S6_R <dbl>, N1_R <dbl>, N2_R <dbl>,
# #   N3_R <dbl>, N4_R <dbl>

Getting help

  • If you encounter a clear bug, please file a minimal reproducible example on github

  • Suggestions and criticisms to improve the quality and usability of the package are welcome!