| Type: | Package |
| Title: | Multi Environment Trials Analysis |
| Version: | 1.19.0 |
| Maintainer: | Tiago Olivoto <tiagoolivoto@gmail.com> |
| Description: | Performs stability analysis of multi-environment trial data using parametric and non-parametric methods. Parametric methods includes Additive Main Effects and Multiplicative Interaction (AMMI) analysis by Gauch (2013) <doi:10.2135/cropsci2013.04.0241>, Ecovalence by Wricke (1965), Genotype plus Genotype-Environment (GGE) biplot analysis by Yan & Kang (2003) <doi:10.1201/9781420040371>, geometric adaptability index by Mohammadi & Amri (2008) <doi:10.1007/s10681-007-9600-6>, joint regression analysis by Eberhart & Russel (1966) <doi:10.2135/cropsci1966.0011183X000600010011x>, genotypic confidence index by Annicchiarico (1992), Murakami & Cruz's (2004) method, power law residuals (POLAR) statistics by Doring et al. (2015) <doi:10.1016/j.fcr.2015.08.005>, scale-adjusted coefficient of variation by Doring & Reckling (2018) <doi:10.1016/j.eja.2018.06.007>, stability variance by Shukla (1972) <doi:10.1038/hdy.1972.87>, weighted average of absolute scores by Olivoto et al. (2019a) <doi:10.2134/agronj2019.03.0220>, and multi-trait stability index by Olivoto et al. (2019b) <doi:10.2134/agronj2019.03.0221>. Non-parametric methods includes superiority index by Lin & Binns (1988) <doi:10.4141/cjps88-018>, nonparametric measures of phenotypic stability by Huehn (1990) <doi:10.1007/BF00024241>, TOP third statistic by Fox et al. (1990) <doi:10.1007/BF00040364>. Functions for computing biometrical analysis such as path analysis, canonical correlation, partial correlation, clustering analysis, and tools for inspecting, manipulating, summarizing and plotting typical multi-environment trial data are also provided. |
| License: | GPL-3 |
| URL: | https://github.com/nepem-ufsc/metan,https://nepem-ufsc.github.io/metan/ |
| BugReports: | https://github.com/nepem-ufsc/metan/issues |
| Depends: | R (≥ 4.1.0) |
| Imports: | dplyr (≥ 1.0.0), GGally, ggforce, ggplot2 (≥ 3.3.0),ggrepel, lme4, lmerTest, magrittr, mathjaxr, methods,patchwork, purrr, rlang (≥ 0.4.11), tibble, tidyr, tidyselect(≥ 1.0.0) |
| Suggests: | DT, knitr, rmarkdown, roxygen2, rstudioapi |
| VignetteBuilder: | knitr |
| RdMacros: | mathjaxr |
| Encoding: | UTF-8 |
| Language: | en-US |
| LazyData: | true |
| LazyLoad: | true |
| RoxygenNote: | 7.3.2 |
| NeedsCompilation: | no |
| Packaged: | 2024-12-13 23:52:54 UTC; tiago |
| Author: | Tiago Olivoto |
| Repository: | CRAN |
| Date/Publication: | 2024-12-15 01:00:02 UTC |
Pipe operator
Description
Seemagrittr::[\%>\%][magrittr::pipe] for details.
Usage
lhs %>% rhsAnnicchiarico's genotypic confidence index
Description
Stability analysis using the known genotypic confidence index (Annicchiarico,1992).
Usage
Annicchiarico(.data, env, gen, rep, resp, prob = 0.25, verbose = TRUE)Arguments
.data | The dataset containing the columns related to Environments,Genotypes, replication/block and response variable(s) |
env | The name of the column that contains the levels of theenvironments. |
gen | The name of the column that contains the levels of the genotypes. |
rep | The name of the column that contains the levels of thereplications/blocks |
resp | The response variable(s). To analyze multiple variables in asingle procedure use, for example, |
prob | The probability of error assumed. |
verbose | Logical argument. If |
Value
A list where each element is the result for one variable and contains thefollowing data frames:
environments Contains the mean, environmental index andclassification as favorable and unfavorable environments.
general Contains the genotypic confidence index considering allenvironments.
favorable Contains the genotypic confidence index consideringfavorable environments.
unfavorable Contains the genotypic confidence index consideringunfavorable environments.
Author(s)
Tiago Olivoto,tiagoolivoto@gmail.com
References
Annicchiarico, P. 1992. Cultivar adaptation and recommendationfrom alfalfa trials in Northern Italy. J. Genet. Breed. 46:269-278.
See Also
superiority(),ecovalence(),ge_stats()
Examples
library(metan)Ann <- Annicchiarico(data_ge2, env = ENV, gen = GEN, rep = REP, resp = PH)print(Ann)Fox's stability function
Description
Performs a stability analysis based on the criteria of Fox et al. (1990),using the statistical "TOP third" only. A stratified ranking of the genotypesat each environment is done. The proportion of locations at which thegenotype occurred in the top third are expressed in the output.
Usage
Fox(.data, env, gen, resp, verbose = TRUE)Arguments
.data | The dataset containing the columns related to Environments,Genotypes, replication/block and response variable(s). |
env | The name of the column that contains the levels of theenvironments. |
gen | The name of the column that contains the levels of the genotypes. |
resp | The response variable(s). To analyze multiple variables in asingle procedure use, for example, |
verbose | Logical argument. If |
Value
An object of classFox, which is a list containing the resultsfor each variable used in the argumentresp. For each variable, atibble with the following columns is returned.
GEN the genotype's code.
mean the mean for the response variable.
TOP The proportion of locations at which the
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Fox, P.N., B. Skovmand, B.K. Thompson, H.J. Braun, and R.Cormier. 1990. Yield and adaptation of hexaploid spring triticale.Euphytica 47:57-64.doi:10.1007/BF00040364.
Examples
library(metan)out <- Fox(data_ge2, ENV, GEN, PH)print(out)Huehn's stability statistics
Description
Performs a stability analysis based on Huehn (1979) statistics. The fournonparametric measures of phenotypic stability are: S1 (mean of the absoluterank differences of a genotype over the n environments), S2 (variance amongthe ranks over the k environments), S3 (sum of the absolute deviations), andS6 (relative sum of squares of rank for each genotype).
Usage
Huehn(.data, env, gen, resp, verbose = TRUE)Arguments
.data | The dataset containing the columns related to Environments,Genotypes, replication/block and response variable(s). |
env | The name of the column that contains the levels of theenvironments. |
gen | The name of the column that contains the levels of the genotypes. |
resp | The response variable(s). To analyze multiple variables in asingle procedure use, for example, |
verbose | Logical argument. If |
Value
An object of classHuehn, which is a list containing the resultsfor each variable used in the argumentresp. For each variable, atibble with the following columns is returned.
GEN The genotype's code.
Y The mean for the response variable.
S1 Mean of the absolute rank differences of a genotype over the n environments.
S2 variance among the ranks over the k environments.
S3 Sum of the absolute deviations.
S6 Relative sum of squares of rank for each genotype.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Huehn, V.M. 1979. Beitrage zur erfassung der phanotypischenstabilitat. EDV Med. Biol. 10:112.
Examples
library(metan)out <- Huehn(data_ge2, ENV, GEN, PH)print(out)Schmildt's genotypic confidence index
Description
Stability analysis using the known genotypic confidence index (Annicchiarico,1992) modified by Schmildt et al. 2011.
Usage
Schmildt(.data, env, gen, rep, resp, prob = 0.05, verbose = TRUE)Arguments
.data | The dataset containing the columns related to Environments,Genotypes, replication/block and response variable(s) |
env | The name of the column that contains the levels of theenvironments. |
gen | The name of the column that contains the levels of the genotypes. |
rep | The name of the column that contains the levels of thereplications/blocks |
resp | The response variable(s). To analyze multiple variables in asingle procedure use, for example, |
prob | The probability of error assumed. |
verbose | Logical argument. If |
Value
A list where each element is the result for one variable and contains thefollowing data frames:
environments Contains the mean, environmental index andclassification as favorables and unfavorables environments.
general Contains the genotypic confidence index considering allenvironments.
favorable Contains the genotypic confidence index consideringfavorable environments.
unfavorable Contains the genotypic confidence index consideringunfavorable environments.
Author(s)
Tiago Olivoto,tiagoolivoto@gmail.com
References
Annicchiarico, P. 1992. Cultivar adaptation and recommendation from alfalfatrials in Northern Italy. J. Genet. Breed. 46:269-278.
Schmildt, E.R., A.L. Nascimento, C.D. Cruz, and J.A.R. Oliveira. 2011.Avaliacao de metodologias de adaptabilidade e estabilidade de cultivaresmilho. Acta Sci. - Agron. 33:51-58.doi:10.4025/actasciagron.v33i1.5817
See Also
superiority(),ecovalence(),ge_stats(),Annicchiarico()
Examples
library(metan)Sch <- Schmildt(data_ge2, env = ENV, gen = GEN, rep = REP, resp = PH)print(Sch)Select helper
Description
These functions allow you to select variables based operationswith prefixes and suffixes and length of names.
difference_var(): Select variables that start with a prefixANDNOT end wiht a suffix.intersect_var(): Select variables that start with a prefixAND end wiht a suffix.union_var(): Select variables that start with a prefixORend wiht a suffix.width_of(): Select variables with width ofn.width_greater_than(): Select variables with width greater thann.width_less_than(): Select variables with width less thann.lower_case_only(): Select variables that contains lower case only(e.g., "env").upper_case_only(): Select variables that contains upper case only(e.g., "ENV").title_case_only(): Select variables that contains upper case in the firstcharacter only (e.g., "Env").
Usage
difference_var(prefix, suffix)intersect_var(prefix, suffix)union_var(prefix, suffix)width_of(n, vars = peek_vars(fn = "width_of"))width_greater_than(n, vars = peek_vars(fn = "width_greater_than"))width_less_than(n, vars = peek_vars(fn = "width_less_than"))lower_case_only(vars = peek_vars(fn = "lower_case_only"))upper_case_only(vars = peek_vars(fn = "upper_case_only"))title_case_only(vars = peek_vars(fn = "title_case_only"))Arguments
prefix | A prefix that start the variable name. |
suffix | A suffix that end the variable name. |
n | The length of variable names to select. For |
vars | A character vector of variable names. When called from insideselecting functions like |
Examples
library(metan)# Select variables that start with "C" and not end with "D".data_ge2 %>%select_cols(difference_var("C", "D"))# Select variables that start with "C" and end with "D".data_ge2 %>%select_cols(intersect_var("C", "D"))# Select variables that start with "C" or end with "D".data_ge2 %>%select_cols(union_var("C", "D"))# Select variables with width name of 4data_ge2 %>%select_cols(width_of(4))# Select variables with width name greater than 2data_ge2 %>%select_cols(width_greater_than(2))# Select variables with width name less than 3data_ge2 %>%select_cols(width_less_than(3))# Creating data with messy column namesdf <- head(data_ge, 3)colnames(df) <- c("Env", "gen", "Rep", "GY", "hm")select_cols(df, lower_case_only())select_cols(df, upper_case_only())select_cols(df, title_case_only())Shukla's stability variance parameter
Description
The function computes the Shukla's stability variance parameter (1972) anduses the Kang's nonparametric stability (rank sum) to imcorporate the meanperformance and stability into a single selection criteria.
Usage
Shukla(.data, env, gen, rep, resp, verbose = TRUE)Arguments
.data | The dataset containing the columns related to Environments,Genotypes, replication/block and response variable(s). |
env | The name of the column that contains the levels of theenvironments. |
gen | The name of the column that contains the levels of the genotypes. |
rep | The name of the column that contains the levels of thereplications/blocks. |
resp | The response variable(s). To analyze multiple variables in asingle procedure use, for example, |
verbose | Logical argument. If |
Value
An object of classShukla, which is a list containing the results for eachvariable used in the argumentresp. For each variable, a tibble with the followingcolumns is returned.
GEN the genotype's code.
Y the mean for the response variable.
ShuklaVar The Shukla's stability variance parameter.
rMean The rank forY (decreasing).
rShukaVar The rank forShukaVar.
ssiShukaVar The simultaneous selection index (
ssiShukaVar = rMean + rShukaVar).
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Shukla, G.K. 1972. Some statistical aspects of partitioninggenotype-environmental components of variability. Heredity. 29:238-245.doi:10.1038/hdy.1972.87
Kang, M.S., and H.N. Pham. 1991. Simultaneous Selection for High Yielding andStable Crop Genotypes. Agron. J. 83:161.doi:10.2134/agronj1991.00021962008300010037x
Examples
library(metan)out <- Shukla(data_ge2, env = ENV, gen = GEN, rep = REP, resp = PH)Smith-Hazel index
Description
Computes the Smith (1936) and Hazel (1943) index given economic weights andphenotypic and genotypic variance-covariance matrices. The Smith-Hazel indexis computed as follows:\[\bf{b = P^{-1}Aw}\]
where \(\bf{P}\) and \(\bf{G}\) are phenotypic and geneticcovariance matrices, respectively, and \(\bf{b}\) and \(\bf{w}\)are vectors of index coefficients and economic weightings, respectively.
The genetic worth \(I\) of an individualgenotype based on traitsx,y, ...,n, is calculated as:
\[I = b_xG_x + b_yG_y + ... + b_nG_n\]whereb the index coefficient for the traitsx,y, ...,n, respectively, andG is the individual genotype BLUPs for thetraitsx,y, ...,n, respectively.
Usage
Smith_Hazel( .data, use_data = "blup", pcov = NULL, gcov = NULL, SI = 15, weights = NULL)Arguments
.data | The input data. It can be either a two-way table with genotypesin rows and traits in columns, or an object fitted with the function |
use_data | Define which data to use If |
pcov,gcov | The phenotypic and genotypic variance-covariance matrix,respectively. Defaults to |
SI | The selection intensity (percentage). Defaults to |
weights | The vector of economic weights. Defaults to a vector of 1swith the same length of the number of traits. |
Details
When using the phenotypic means in.data, be sure the genotype's codeare in rownames. If.data is an object of classgamem them theBLUPs for each genotype are used to compute the index. In this case, thegenetic covariance components are estimated by mean cross products.
Value
An object of classhz containing:
b: the vector of index coefficient.
index: The genetic worth.
sel_dif_trait: The selection differencial.
sel_gen: The selected genotypes.
gcov: The genotypic variance-covariance matrix
pcov: The phenotypic variance-covariance matrix
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Smith, H.F. 1936. A discriminant function for plant selection. Ann. Eugen.7:240-250.doi:10.1111/j.1469-1809.1936.tb02143.x
Hazel, L.N. 1943. The genetic basis for constructing selection indexes.Genetics 28:476-90. https://www.genetics.org/content/28/6/476.short
See Also
Examples
vcov <- covcor_design(data_g, GEN, REP, everything())means <- as.matrix(vcov$means)pcov <- vcov$phen_covgcov <- vcov$geno_covindex <- Smith_Hazel(means, pcov = pcov, gcov = gcov, weights = rep(1, 15))Thennarasu's stability statistics
Description
Performs a stability analysis based on Thennarasu (1995) statistics.
Usage
Thennarasu(.data, env, gen, resp, verbose = TRUE)Arguments
.data | The dataset containing the columns related to Environments,Genotypes, replication/block and response variable(s). |
env | The name of the column that contains the levels of theenvironments. |
gen | The name of the column that contains the levels of the genotypes. |
resp | The response variable(s). To analyze multiple variables in asingle procedure use, for example, |
verbose | Logical argument. If |
Value
An object of classThennarasu, which is a list containing the resultsfor each variable used in the argumentresp. For each variable, atibble with the columns GEN, N1, N2, N3 and N4 is returned.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Thennarasu, K. 1995. On certain nonparametric procedures forstudying genotype x environment interactions and yield stability. Ph.D.thesis. P.J. School, IARI, New Delhi, India.
Examples
library(metan)out <- Thennarasu(data_ge, ENV, GEN, GY)print(out)Adjusted Coefficient of Variation
Description
Computes the scale-adjusted coefficient of variation,acv, (Doring and Reckling, 2018) to account for the systematicdependence of \(\sigma^2\) from \(\mu\). Theacv iscomputed as follows:\[acv = \frac{\sqrt{10^{\tilde v_i}}}{\mu_i}\times 100\]where \(\tilde v_i\) is the adjusted logarithm of the variancecomputed as:\[\tilde v_i = a + (b - 2)\frac{1}{n}\sum m_i + 2m_i + e_i\]being \(a\) and \(b\) the coefficients of the linear regression for\(log_{10}\) of the variance over the \(log_{10}\) of the mean;\( m_i\) is the \(log_{10}\) of the mean, and \( e_i\) is thePower Law Residuals (POLAR), i.e., the residuals for the previously describedregression.
Usage
acv(mean, var, na.rm = FALSE)Arguments
mean | A numeric vector with mean values. |
var | A numeric vector with variance values. |
na.rm | If |
Value
A tibble with the following columns
mean The mean values.
var The variance values;
log10_mean The base 10 logarithm of mean;
log10_var The base 10 logarithm of variance;
POLAR The Power Law Residuals;
cv The standard coefficient of variation;
acv Adjusted coefficient of variation.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Doring, T.F., and M. Reckling. 2018. Detecting global trends ofcereal yield stability by adjusting the coefficient of variation. Eur. J.Agron. 99: 30-36.doi:10.1016/j.eja.2018.06.007
Examples
################# Table 1 from Doring and Reckling (2018) ############ Mean valuesu <- c(0.5891, 0.6169, 0.7944, 1.0310, 1.5032, 3.8610, 4.6969, 6.1148, 7.1526, 7.5348, 1.2229, 1.6321, 2.4293, 2.5011, 3.0161)# Variancesv <- c(0.0064, 0.0141, 0.0218, 0.0318, 0.0314, 0.0766, 0.0620, 0.0822, 0.1605, 0.1986, 0.0157, 0.0593, 0.0565, 0.1997, 0.2715)library(metan)acv(u, v)AMMI-based stability indexes
Description
ammi_indexes()computes several AMMI-based stability statistics. SeeDetails for a detailed overview.
Usage
ammi_indexes(.data, order.y = NULL, level = 0.95)Arguments
.data | An object of class |
order.y | A vector of the same length of |
level | The confidence level. Defaults to 0.95. |
Details
First, let's define some symbols: \(N'\) is the number of significantinteration principal component axis (IPCs) that were retained in the AMMImodel via F tests); \(\lambda_{n}\) is the singular value for th IPC andcorrespondingly \(\lambda_{n}^{2}\) its eigen value; \(\gamma_{in}\)is the eigenvector value for ith genotype; \(\delta_{jn}\) is theeigenvector value for the th environment. \(PC_{1}\), \(PC_{2}\),and \(PC_{n}\) are the scores of 1st, 2nd, and nth IPC; respectively;\(\theta_{1}\), \(\theta_{2}\), and \(\theta_{n}\) arepercentage sum of squares explained by the 1st, 2nd, and nth IPC,respectively.
AMMI Based Stability Parameter (ASTAB) (Rao and Prabhakaran 2005).\[ASTAB = \sum_{n=1}^{N'}\lambda_{n}\gamma_{in}^{2}\]
AMMI Stability Index (ASI) (Jambhulkar et al. 2017)\[ASI = \sqrt{\left [ PC_{1}^{2} \times \theta_{1}^{2} \right ]+\left[ PC_{2}^{2} \times \theta_{2}^{2} \right ]}\]
AMMI-stability value (ASV) (Purchase et al., 2000).\[ASV_{i}=\sqrt{\frac{SS_{IPCA1}}{SS_{IPCA2}}(\mathrm{IPC} \mathrm{A} 1)^{2}+(\mathrm{IPCA} 2)^{2}}\]
Sum Across Environments of Absolute Value of GEI Modelled by AMMI (AVAMGE) (Zali et al. 2012)\[AV_{(AMGE)} = \sum_{j=1}^{E} \sum_{n=1}^{N'} \left |\lambda_{n}\gamma_{in} \delta_{jn} \right |\]
Annicchiarico's D Parameter values (Da) (Annicchiarico 1997)\[D_{a} = \sqrt{\sum_{n=1}^{N'}(\lambda_{n}\gamma_{in})^2}\]
Zhang's D Parameter (Dz) (Zhang et al. 1998)\[D_{z} = \sqrt{\sum_{n=1}^{N'}\gamma_{in}^{2}}\]
Sums of the Averages of the Squared Eigenvector Values (EV) (Zobel 1994)\[EV = \sum_{n=1}^{N'}\frac{\gamma_{in}^2}{N'}\]
Stability Measure Based on Fitted AMMI Model (FA) (Raju 2002)\[FA = \sum_{n=1}^{N'}\lambda_{n}^{2}\gamma_{in}^{2}\]
Modified AMMI Stability Index (MASI) (Ajay et al. 2018)\[MASI = \sqrt{ \sum_{n=1}^{N'} PC_{n}^{2} \times \theta_{n}^{2}}\]
Modified AMMI Stability Value (MASV) (Ajay et al. 2019)\[MASV = \sqrt{\sum_{n=1}^{N'-1}\left (\frac{SSIPC_{n}}{SSIPC_{n+1}} \right ) \times (PC_{n})^2 + \left (PC_{N'}\right )^2}\]
Sums of the Absolute Value of the IPC Scores (SIPC) (Sneller et al. 1997)\[SIPC = \sum_{n=1}^{N'} | \lambda_{n}^{0.5}\gamma_{in}|\]
Absolute Value of the Relative Contribution of IPCs to the Interaction (Za) (Zali et al. 2012)\[Za = \sum_{i=1}^{N'} | \theta_{n}\gamma_{in} |\]
Weighted average of absolute scores (WAAS) (Olivoto et al. 2019)\[WAAS_i = \sum_{k = 1}^{p} |IPCA_{ik} \times \theta_{k}/ \sum_{k = 1}^{p}\theta_{k}\]
For all the statistics, simultaneous selection indexes (SSI) are alsocomputed by summation of the ranks of the stability and mean performance,Y_R, (Farshadfar, 2008).
Value
A list where each element contains the result AMMI-based stability indexesfor one variable.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Ajay BC, Aravind J, Abdul Fiyaz R, Bera SK, Kumar N, Gangadhar K, Kona P(2018). “Modified AMMI Stability Index (MASI) for stability analysis.”ICAR-DGR Newsletter, 18, 4–5.
Ajay BC, Aravind J, Fiyaz RA, Kumar N, Lal C, Gangadhar K, Kona P, Dagla MC,Bera SK (2019). “Rectification of modified AMMI stability value (MASV).”Indian Journal of Genetics and Plant Breeding (The), 79, 726–731.https://www.isgpb.org/article/rectification-of-modified-ammi-stability-value-masv.
Annicchiarico P (1997). “Joint regression vs AMMI analysis ofgenotype-environment interactions for cereals in Italy.” Euphytica, 94(1),53–62.doi:10.1023/A:1002954824178
Farshadfar E (2008) Incorporation of AMMI stability value and grain yield ina single non-parametric index (GSI) in bread wheat. Pakistan J Biol Sci11:1791–1796.doi:10.3923/pjbs.2008.1791.1796
Jambhulkar NN, Rath NC, Bose LK, Subudhi HN, Biswajit M, Lipi D, Meher J(2017). “Stability analysis for grain yield in rice in demonstrationsconducted during rabi season in India.” Oryza, 54(2), 236–240.doi:10.5958/2249-5266.2017.00030.3
Olivoto T, LUcio ADC, Silva JAG, et al (2019) Mean Performance and Stabilityin Multi-Environment Trials I: Combining Features of AMMI and BLUPTechniques. Agron J 111:2949–2960.doi:10.2134/agronj2019.03.0220
Raju BMK (2002). “A study on AMMI model and its biplots.” Journal of theIndian Society of Agricultural Statistics, 55(3), 297–322.
Rao AR, Prabhakaran VT (2005). “Use of AMMI in simultaneous selection ofgenotypes for yield and stability.” Journal of the Indian Society ofAgricultural Statistics, 59, 76–82.
Sneller CH, Kilgore-Norquest L, Dombek D (1997). “Repeatability of yieldstability statistics in soybean.” Crop Science, 37(2), 383–390.doi:10.2135/cropsci1997.0011183X003700020013x
Zali H, Farshadfar E, Sabaghpour SH, Karimizadeh R (2012). “Evaluation ofgenotype × environment interaction in chickpea using measures of stabilityfrom AMMI model.” Annals of Biological Research, 3(7), 3126–3136.
Zhang Z, Lu C, Xiang Z (1998). “Analysis of variety stability based on AMMImodel.” Acta Agronomica Sinica, 24(3), 304–309.http://zwxb.chinacrops.org/EN/Y1998/V24/I03/304.
Zobel RW (1994). “Stress resistance and root systems.” In Proceedings of theWorkshop on Adaptation of Plants to Soil Stress. 1-4 August, 1993. INTSORMILPublication 94-2, 80–99. Institute of Agriculture and Natural Resources,University of Nebraska-Lincoln.
Examples
library(metan)model <- performs_ammi(data_ge, env = ENV, gen = GEN, rep = REP, resp = c(GY, HM))model_indexes <- ammi_indexes(model)# Alternatively (and more intuitively) using %>%# If resp is not declared, all traits are analyzedres_ind <- data_ge %>% performs_ammi(ENV, GEN, REP, verbose = FALSE) %>% ammi_indexes()rbind_fill_id(res_ind, .id = "TRAIT")Within-environment analysis of variance
Description
Performs a within-environment analysis of variance in randomized completeblock or alpha-lattice designs and returns values such as Mean Squares,p-values, coefficient of variation, heritability, and accuracy of selection.
Usage
anova_ind(.data, env, gen, rep, resp, block = NULL, verbose = TRUE)Arguments
.data | The dataset containing the columns related to Environments,Genotypes, replication/block and response variable(s). |
env | The name of the column that contains the levels of theenvironments. The analysis of variance is computed for each level of thisfactor. |
gen | The name of the column that contains the levels of the genotypes. |
rep | The name of the column that contains the levels of thereplications/blocks. |
resp | The response variable(s). To analyze multiple variables in asingle procedure a vector of variables may be used. For example |
block | Defaults to |
verbose | Logical argument. If |
Value
A list where each element is the result for one variable containing(1)individual: A tidy tbl_df with the results of the individualanalysis of variance with the following column names, and (2)MSRatio:The ratio between the higher and lower residual mean square. The followingcolumns are returned, depending on the experimental design
For analysis in alpha-lattice designs:
MEAN: The grand mean.DFG, DFCR, and DFIB_R, and DFE: The degree of freedom for genotype,complete replicates, incomplete blocks within replicates, and error,respectively.MSG, MSCR, MSIB_R: The mean squares for genotype, replicates, incompleteblocks within replicates, and error, respectively.FCG, FCR, FCIB_R: The F-calculated for genotype, replicates andincomplete blocks within replicates, respectively.PFG, PFCR, PFIB_R: The P-values for genotype, replicates and incompleteblocks within replicates, respectively.CV: coefficient of variation.h2: broad-sense heritability.AS: accuracy of selection (square root ofh2)
For analysis in randomized complete block design:
MEAN: The grand mean.DFG, DFB, and DFE: The degree of freedom for genotype blocks, and error, respectively.MSG, MSB, and MSE: The mean squares for genotype blocks, and error, respectively.FCG and FCB: The F-calculated for genotype and blocks, respectively.PFG and PFB: The P-values for genotype and blocks, respectively.CV: coefficient of variation.h2: broad-sense heritability.h2MG: broad-sense heritability at a plot level.AS: accuracy of selection (square root ofh2)
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Patterson, H.D., and E.R. Williams. 1976. A new class ofresolvable incomplete block designs. Biometrika 63:83-92.
Examples
library(metan)# ANOVA for all variables in dataind_an <- anova_ind(data_ge, env = ENV, gen = GEN, rep = REP, resp = everything())# mean for each environmentget_model_data(ind_an)# P-value for genotype effectget_model_data(ind_an, "PFG")Joint analysis of variance
Description
Performs a joint analysis of variance to check for the presence ofgenotype-vs-environment interactions using both randomized complete block andalpha-lattice designs.
Usage
anova_joint(.data, env, gen, rep, resp, block = NULL, verbose = TRUE)Arguments
.data | The dataset containing the columns related to Environments,Genotypes, replication/block and response variable(s). |
env | The name of the column that contains the levels of theenvironments. The analysis of variance is computed for each level of thisfactor. |
gen | The name of the column that contains the levels of the genotypes. |
rep | The name of the column that contains the levels of thereplications/blocks. |
resp | The response variable(s). To analyze multiple variables in asingle procedure a vector of variables may be used. For example |
block | Defaults to |
verbose | Logical argument. If |
Value
A list where each element is the result for one variable containingthe following objects:
anova: The two-way ANOVA table
model: The model of class
lm.augment: Information about each observation in the dataset. Thisincludes predicted values in the
fittedcolumn, residuals in theresidcolumn, standardized residuals in thestdrescolumn,the diagonal of the 'hat' matrix in thehat, and standard errors forthe fitted values in these.fitcolumn.details: A tibble with the following data:
Ngen, thenumber of genotypes;OVmean, the grand mean;Min, the minimumobserved (returning the genotype and replication/block);Maxthemaximum observed,MinGENthe loser winner genotype,MaxGEN,the winner genotype.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Patterson, H.D., and E.R. Williams. 1976. A new class ofresolvable incomplete block designs. Biometrika 63:83-92.
See Also
Examples
library(metan)# traditional usage approachj_an <- anova_joint(data_ge, env = ENV, gen = GEN, rep = REP, resp = everything())# Predicted valuesget_model_data(j_an)# Detailsget_model_data(j_an, "details")Arrange separate ggplots into the same graphic
Description
This is a wraper function aroundpatchwork::wrap_plots() andpatchwork::plot_annotation() to arrange ggplot2 objects.
Usage
arrange_ggplot( ..., nrow = NULL, ncol = NULL, widths = NULL, heights = NULL, guides = NULL, design = NULL, legend.position = "bottom", title = NULL, subtitle = NULL, caption = NULL, tag_levels = NULL, tag_prefix = NULL, tag_suffix = NULL, tag_sep = NULL, theme = NULL)Arguments
... | multiple |
nrow,ncol | The number of rows and columns, respectively. |
widths,heights | The relative widths and heights of each column and rowin the grid. Will get repeated to match the dimensions of the grid. |
guides | A string specifying how guides should be treated in the layout.Defaults to |
design | Specification of the location of areas in the layout. |
legend.position | The position of the legends in the plot if |
title,subtitle,caption | Text strings to use for the various plotannotations. |
tag_levels | A character vector defining the enumeration format to useat each level. Possible values are |
tag_prefix,tag_suffix | Strings that should appear before or after thetag. |
tag_sep | A separator between different tag levels. |
theme | A ggplot theme specification to use for the plot. Only elementsrelated to the titles as well as plot margin and background is used. |
Value
Apatchwork object
Examples
library(ggplot2)library(metan)p1 <- ggplot(mtcars, aes(wt, mpg)) + geom_point()p2 <- ggplot(mpg, aes(class, hwy)) + geom_boxplot()# Default plotarrange_ggplot(p1, p2)# Insert plot annotation, titles and subtitlesarrange_ggplot(p1, p2, ncol = 1, tag_levels = "1", tag_prefix = "P.", title = "My grouped ggplot", subtitle = "Made with arrange_ggplot()", caption = "P1 = scatter plot - P2 = boxplot")Coerce to an object of class lpcor
Description
Functions to check if an object is of classlpcor, or coerce it ifpossible.
Usage
as.lpcor(...)Arguments
... | A comma-separated list of matrices to be coerced to a list. |
Value
An object of classlpcor.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)library(dplyr)mt_num = mtcars %>% select_if(., is.numeric)lpdata = as.lpcor(cor(mt_num[1:5]), cor(mt_num[1:5]), cor(mt_num[2:6]), cor(mt_num[4:8]))is.lpcor(lpdata)Fast way to create bar plots
Description
plot_bars()Creates a bar plot based on one categorical variable andone numeric variable. It can be used to show the results of a one-way trialwithqualitative treatments.plot_factbars()Creates a bar plot based on two categoricalvariables and one numeric variable. It can be used to show the results of atwo-way trial withqualitative-qualitative treatment structure.
Usage
plot_bars( .data, x, y, order = NULL, y.lim = NULL, y.breaks = waiver(), y.expand = 0.05, y.contract = 0, xlab = NULL, ylab = NULL, n.dodge = 1, check.overlap = FALSE, color.bar = "black", fill.bar = "gray", lab.bar = NULL, lab.bar.hjust = 0.5, lab.bar.vjust = -0.5, lab.bar.angle = 0, size.text.bar = 5, values = FALSE, values.hjust = 0.5, values.vjust = 1.5, values.angle = 0, values.digits = 2, values.size = 4, lab.x.hjust = 0.5, lab.x.vjust = 1, lab.x.angle = 0, errorbar = TRUE, stat.erbar = "se", width.erbar = NULL, level = 0.95, invert = FALSE, width.bar = 0.9, size.line = 0.5, size.text = 12, fontfam = "sans", na.rm = TRUE, verbose = FALSE, plot_theme = theme_metan())plot_factbars( .data, ..., resp, y.lim = NULL, y.breaks = waiver(), y.expand = 0.05, y.contract = 0, xlab = NULL, ylab = NULL, n.dodge = 1, check.overlap = FALSE, lab.bar = NULL, lab.bar.hjust = 0.5, lab.bar.vjust = -0.5, lab.bar.angle = 0, size.text.bar = 5, values = FALSE, values.hjust = 0.5, values.vjust = 1.5, values.angle = 0, values.digits = 2, values.size = 4, lab.x.hjust = 0.5, lab.x.vjust = 1, lab.x.angle = 0, errorbar = TRUE, stat.erbar = "se", width.erbar = NULL, level = 0.95, invert = FALSE, col = TRUE, palette = "Spectral", width.bar = 0.9, legend.position = "bottom", size.line = 0.5, size.text = 12, fontfam = "sans", na.rm = TRUE, verbose = FALSE, plot_theme = theme_metan())Arguments
.data | The data set. |
x,y | Argument valid for |
order | Argument valid for |
y.lim | The range of y axis. Defaults to |
y.breaks | The breaks to be plotted in the y-axis. Defaults to waiver(). |
y.expand,y.contract | A multiplication range expansion/contractionfactor. |
xlab,ylab | The labels of the axes x and y, respectively. Defaults to |
n.dodge | The number of rows that should be used to render the x labels.This is useful for displaying labels that would otherwise overlap. |
check.overlap | Silently remove overlapping labels, (recursively)prioritizing the first, last, and middle labels. |
color.bar,fill.bar | Argument valid for |
lab.bar | A vector of characters to show in each bar. Defaults to NULL. |
lab.bar.hjust,lab.bar.vjust | The horizontal and vertical adjust for thelabels in the bar. Defaults to 0.5 and -0.5, respectively. |
lab.bar.angle | The angle for the labels in the plot. Defaults to 0. Usein combination with |
size.text.bar | The size of the text in the bar labels. |
values | Logical argument. Shows the values in the plot bar?Defaults to |
values.hjust,values.vjust | The horizontal and vertical adjustfor the values in the bar. Defaults to 0.5 and 1.5, respectively. If |
values.angle | The angle for the labels in the plot. Defaults to 0.Use in combination with |
values.digits | The significant digits to show if |
values.size | The size of the text for values shown in the bars.Defaults to |
lab.x.hjust,lab.x.vjust | The horizontal and vertical adjust for thelabels in the bar. Defaults to 0.5 and 1, respectively. |
lab.x.angle | The angle for the labels in x axis. Defaults to 0. Usein combination with |
errorbar | Logical argument, set to TRUE. In this case, an error bar isshown. |
stat.erbar | The statistic to be shown in the errorbar. Must be one ofthe |
width.erbar | The width of the error bar. Defaults to 25% of |
level | The confidence level |
invert | Logical argument. If |
width.bar | The width of the bars in the graph. Defaults to 0.9.Possible values are in the range 0-1. |
size.line | The size of the line in the bars. Default to |
size.text | The size of the text. Default to |
fontfam | The family of the font text. Defaults to |
na.rm | Should 'NA' values be removed to compute the statistics?Defaults to true |
verbose | Logical argument. If TRUE a tibble containing the mean, N,standard deviation, standard error of mean and confidence interval isreturned. |
plot_theme | The graphical theme of the plot. Default is |
... | Argument valid for |
resp | Argument valid for |
col | Logical argument valid for |
palette | Argument valid for |
legend.position | The position of the legend in the plot. |
Value
An object of classgg, ggplot.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
See Also
Examples
library(metan)# two categorical variablesplot_factbars(data_ge2, GEN, ENV, resp = PH)# one categorical variablep1 <- plot_bars(data_g, GEN, PH)p2 <- plot_bars(data_g, GEN, PH, n.dodge = 2, # two rows for x labels y.expand = 0.1, # expand y scale y.contract = -0.75, # contract the lower limit errorbar = FALSE, # remove errorbar color.bar = "red", # color of bars fill.bar = alpha_color("cyan", 75), # create a transparent color lab.bar = letters[1:13]) # add labelsarrange_ggplot(p1, p2)Bind cross-validation objects
Description
Helper function that combines objects of classcv_ammi,cv_ammif orcv_blup. It is useful when looking for a boxplotcontaining the RMSPD values of those cross-validation procedures.
Usage
bind_cv(..., bind = "boot", sort = TRUE)Arguments
... | Input objects of class |
bind | What data should be used? To plot the RMSPD, use 'boot'(default). Use |
sort | Used to sort the RMSPD mean in ascending order. |
Value
An object of classcv_ammif. The results will depend on theargumentbind. Ifbind = 'boot' then the RMSPD of all modelsin... will be bind to a unique data frame. Ifbind = 'means'then the RMSPD mean of all models in... will be bind to an uniquedata frame.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)# Two examples with only 5 resampling proceduresAMMI <- cv_ammi(data_ge, resp = GY, gen = GEN, env = ENV, rep = REP, nboot = 5)BLUP <- cv_blup(data_ge, resp = GY, gen = GEN, env = ENV, rep = REP, nboot = 5)bind_data <- bind_cv(AMMI, BLUP)plot(bind_data)print(bind_cv(AMMI, BLUP, bind = 'means'))Stability indexes based on a mixed-effect model
Description
hmgv()Computes the harmonic mean of genotypic values (HMGV).rpgv()Computes the relative performance of the genotypic values (RPGV).hmrpgv()Computes the harmonic mean of the relative performance ofgenotypic values (HMRPGV).blup_indexes()Is a wrapper around the above functions that also computesthe WAASB index (Olivoto et al. 2019) if an object computed withwaasb()isused as input data.
Usage
hmgv(model)rpgv(model)hmrpgv(model)blup_indexes(model)Arguments
model | An object of class |
Details
The indexes computed with this function have been used to select genotypeswith stability performance in a mixed-effect model framework. Some examplesare in Alves et al (2018), Azevedo Peixoto et al. (2018), Dias et al. (2018)and Colombari Filho et al. (2013).
The HMGV index is computed as\[HMG{V_i} = \frac{E}{{\sum\limits_{j = 1}^E {\frac{1}{{G{v_{ij}}}}}}}\]
where \(E\) is the number of environments included in the analysis,\(Gv_{ij}\) is the genotypic value (BLUP) for the ith genotype in thejth environment.
The RPGV index is computed as\[RPGV_i = \frac{1}{E}{\sum\limits_{j = 1}^E {Gv_{ij}} /\mathop \mu\nolimits_j }\]
The HMRPGV index is computed as\[HMRPG{V_i} = \frac{E}{{\sum\limits_{j = 1}^E{\frac{1}{{G{v_{ij}}/{\mu _j}}}} }}\]
Value
A tibble containing the indexes.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Alves, R.S., L. de Azevedo Peixoto, P.E. Teodoro, L.A. Silva, E.V.Rodrigues, M.D.V. de Resende, B.G. Laviola, and L.L. Bhering. 2018.Selection of Jatropha curcas families based on temporal stability andadaptability of genetic values. Ind. Crops Prod. 119:290-293.doi:10.1016/J.INDCROP.2018.04.029
Azevedo Peixoto, L. de, P.E. Teodoro, L.A. Silva, E.V. Rodrigues, B.G.Laviola, and L.L. Bhering. 2018. Jatropha half-sib family selection withhigh adaptability and genotypic stability. PLoS One 13:e0199880.doi:10.1371/journal.pone.0199880
Colombari Filho, J.M., M.D.V. de Resende, O.P. de Morais, A.P. de Castro,E.P. Guimaraes, J.A. Pereira, M.M. Utumi, and F. Breseghello. 2013. Uplandrice breeding in Brazil: a simultaneous genotypic evaluation of stability,adaptability and grain yield. Euphytica 192:117-129.doi:10.1007/s10681-013-0922-2
Dias, P.C., A. Xavier, M.D.V. de Resende, M.H.P. Barbosa, F.A. Biernaski,R.A. Estopa. 2018. Genetic evaluation of Pinus taeda clones from somaticembryogenesis and their genotype x environment interaction. Crop Breed.Appl. Biotechnol. 18:55-64.doi:10.1590/1984-70332018v18n1a8
Olivoto, T., A.D.C. Lúcio, J.A.G. da silva, V.S. Marchioro, V.Q. deSouza, and E. Jost. 2019. Mean performance and stability inmulti-environment trials I: Combining features of AMMI and BLUP techniques.Agron. J. 111:2949-2960.doi:10.2134/agronj2019.03.0220
Resende MDV (2007) Matematica e estatistica na analise de experimentos e nomelhoramento genetico. Embrapa Florestas, Colombo
Examples
library(metan)res_ind <- waasb(data_ge, env = ENV, gen = GEN, rep = REP, resp = c(GY, HM), verbose = FALSE)model_indexes <- blup_indexes(res_ind)gmd(model_indexes)Canonical correlation analysis
Description
Performs canonical correlation analysis with collinearity diagnostic,estimation of canonical loads, canonical scores, and hypothesis testing forcorrelation pairs.
Usage
can_corr( .data, FG, SG, by = NULL, use = "cor", test = "Bartlett", prob = 0.05, center = TRUE, stdscores = FALSE, verbose = TRUE, collinearity = TRUE)Arguments
.data | The data to be analyzed. It can be a data frame (possible withgrouped data passed from |
FG,SG | A comma-separated list of unquoted variable names that willcompose the first (smallest) and second (highest) group of the correlationanalysis, respectively. Select helpers are also allowed. |
by | One variable (factor) to compute the function by. It is a shortcutto |
use | The matrix to be used. Must be one of 'cor' for analysis using thecorrelation matrix (default) or 'cov' for analysis using the covariancematrix. |
test | The test of significance of the relationship between the FG andSG. Must be one of the 'Bartlett' (default) or 'Rao'. |
prob | The probability of error assumed. Set to 0.05. |
center | Should the data be centered to compute the scores? |
stdscores | Rescale scores to produce scores of unit variance? |
verbose | Logical argument. If |
collinearity | Logical argument. If |
Value
If.data is a grouped data passed fromdplyr::group_by() then the results will be returned into alist-column of data frames.
Matrix The correlation (or covariance) matrix of the variables
MFG, MSG The correlation (or covariance) matrix for the variables ofthe first group or second group, respectively.
MFG_SG The correlation (or covariance) matrix for the variables of thefirst group with the second group.
Coef_FG, Coef_SG Matrix of the canonical coefficients of the firstgroup or second group, respectively.
Loads_FG, Loads_SG Matrix of the canonical loadings of the first groupor second group, respectively.
Score_FG, Score_SG Canonical scores for the variables in FG and SG,respectively.
Crossload_FG, Crossload_FG Canonical cross-loadings for FG variableson the SG scores, and cross-loadings for SG variables on the FG scores,respectively.
SigTest A dataframe with the correlation of the canonical pairs andhypothesis testing results.
collinearity A list with the collinearity diagnostic for each group ofvariables.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Olivoto, T., V.Q. Souza, M. Nardino, I.R. Carvalho, M. Ferrari, A.J.Pelegrin, V.J. Szareski, and D. Schmidt. 2017. Multicollinearity in pathanalysis: a simple method to reduce its effects. Agron. J. 109:131-142.doi:10.2134/agronj2016.04.0196
Examples
library(metan)cc1 <- can_corr(data_ge2, FG = c(PH, EH, EP), SG = c(EL, ED, CL, CD, CW, KW, NR))# Canonical correlations for each environmentcc3 <- data_ge2 %>% can_corr(FG = c(PH, EH, EP), SG = c(EL, ED, CL, CD, CW, KW, NR), by = ENV, verbose = FALSE)Clustering analysis
Description
Performs clustering analysis with selection of variables.
Usage
clustering( .data, ..., by = NULL, scale = FALSE, selvar = FALSE, verbose = TRUE, distmethod = "euclidean", clustmethod = "average", nclust = NA)Arguments
.data | The data to be analyzed. It can be a data frame, possible withgrouped data passed from |
... | The variables in |
by | One variable (factor) to compute the function by. It is a shortcutto |
scale | Should the data be scaled before computing the distances? Set toFALSE. If TRUE, then, each observation will be divided by the standarddeviation of the variable \(Z_{ij} = X_{ij} / sd_j\) |
selvar | Logical argument, set to |
verbose | Logical argument. If |
distmethod | The distance measure to be used. This must be one of |
clustmethod | The agglomeration method to be used. This should be one of |
nclust | The number of clusters to be formed. Set to |
Details
Whenselvar = TRUE a variable selection algorithm is executed. Theobjective is to select a group of variables that most contribute to explainthe variability of the original data. The selection of the variables is basedon eigenvalue/eigenvectors solution based on the following steps.
compute the distance matrix and the cophenetic correlation with the originalvariables (all numeric variables in dataset);
compute the eigenvalues and eigenvectors of the correlation matrix betweenthe variables;
Delete the variable with the largest weight (highest eigenvector inthe lowest eigenvalue);
Compute the distance matrix and cophenetic correlation with the remainingvariables;
Compute the Mantel's correlation between the obtained distances matrix andthe original distance matrix;
Iterate steps 2 to 5p - 2 times, wherep is the number of originalvariables.
At the end of thep - 2 iterations, a summary of the models is returned.The distance is calculated with the variables that generated the model withthe largest cophenetic correlation. I suggest a careful evaluation aiming atchoosing a parsimonious model, i.e., the one with the fewer number ofvariables, that presents acceptable cophenetic correlation and highsimilarity with the original distances.
Value
data The data that was used to compute the distances.
cutpoint The cutpoint of the dendrogram according to Mojena (1977).
distance The matrix with the distances.
de The distances in an object of class
dist.hc The hierarchical clustering.
Sqt The total sum of squares.
tab A table with the clusters and similarity.
clusters The sum of square and the mean of the clusters for eachvariable.
cofgrap If
selectvar = TRUE, then,cofpgrapis aggplot2-based graphic showing the cophenetic correlation for each model(with different number of variables). Else, will be aNULLobject.statistics If
selectvar = TRUE, then,statisticsshowsthe summary of the models fitted with different number of variables,including cophenetic correlation, Mantel's correlation with the originaldistances (all variables) and the p-value associated with the Mantel'stest. Else, will be aNULLobject.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Mojena, R. 2015. Hierarchical grouping methods and stoppingrules: an evaluation. Comput. J. 20:359-363.doi:10.1093/comjnl/20.4.359
Examples
library(metan)# All rows and all numeric variables from datad1 <- clustering(data_ge2)# Based on the mean for each genotypemean_gen <- data_ge2 %>% mean_by(GEN) %>% column_to_rownames("GEN")d2 <- clustering(mean_gen)# Select variables for compute the distancesd3 <- clustering(mean_gen, selvar = TRUE)# Compute the distances with standardized data# Define 4 clustersd4 <- clustering(data_ge, by = ENV, scale = TRUE, nclust = 4)Computes the coincidence index of genotype selection
Description
Computes the coincidence index (Hamblin and Zimmermann, 1986) as follows:
\[CI = \frac{A-C}{M-C}\times 100\]whereA is the number of selected genotypes common to differentmethods;C is the number of expected genotypes selected by chance; andM is the number of genotypes selected according to the selectionintensity.
Usage
coincidence_index(..., total, sel1 = NULL, sel2 = NULL)Arguments
... | A comma-separated list of objects of class |
total | The total number of genotypes in the study. |
sel1,sel2 | The selected genotypes by the method 1 and 2, respectively. Defaults to |
Value
A list with the following elements:
coincidence: A data frame with the coincidence index, number ofcommon genotypes and the list of common genotypes for each model combination.
coincidence_mat: A matrix-like containing the coincidence index.
genotypes: The number of common genotypes for all models, i.e.,the insersection of the selected genotypes of all models
References
Hamblin, J., and M.J. de O. Zimmermann. 1986. Breeding Common Bean for Yieldin Mixtures. p. 245-272. In Plant Breeding Reviews. John Wiley & Sons, Inc.,Hoboken, NJ, USA.doi:10.1002/9781118061015.ch8
Examples
sel1 <- paste("G", 1:30, sep = "")sel2 <- paste("G", 16:45, sep = "")coincidence_index(sel1 = sel1, sel2 = sel2, total = 150)Collinearity Diagnostics
Description
Perform a (multi)collinearity diagnostic of a correlation matrix of predictorvariables using several indicators, as shown by Olivoto et al. (2017).
Usage
colindiag(.data, ..., by = NULL, n = NULL)Arguments
.data | The data to be analyzed. It must be a symmetric correlationmatrix, or a data frame, possible with grouped data passed from |
... | Variables to use in the correlation. If |
by | One variable (factor) to compute the function by. It is a shortcutto |
n | If a correlation matrix is provided, then |
Value
If.data is a grouped data passed fromdplyr::group_by()then the results will be returned into a list-column of data frames.
cormat A symmetric Pearson's coefficient correlation matrixbetween the variables
corlist A hypothesis testing for each of the correlationcoefficients
evalevet The eigenvalues with associated eigenvectors of thecorrelation matrix
indicators A
data.framewith the following indicators
VIFThe Variance Inflation Factors, being the diagonal elements ofthe inverse of the correlation matrix.cnThe Condition Number of the correlation matrix, given by theratio between the largest and smallest eigenvalue.detThe determinant of the correlation matrix.ncorhighNumber of correlation greather than |0.8|.largest_corrThe largest correlation (in absolute value) observed.smallest_corrThe smallest correlation (in absolute value)observed.weight_varThe variables with largest eigenvector (largest weight)in the eigenvalue of smallest value, sorted in decreasing order.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Olivoto, T., V.Q. Souza, M. Nardino, I.R. Carvalho, M. Ferrari, A.J.Pelegrin, V.J. Szareski, and D. Schmidt. 2017. Multicollinearity in pathanalysis: a simple method to reduce its effects. Agron. J. 109:131-142.doi:10.2134/agronj2016.04.0196
Examples
# Using the correlation matrixlibrary(metan)cor_iris <- cor(iris[,1:4])n <- nrow(iris)col_diag <- colindiag(cor_iris, n = n)# Using a data framecol_diag_gen <- data_ge2 %>% group_by(GEN) %>% colindiag()# Diagnostic by levels of a factor# For variables with "N" in variable namecol_diag_gen <- data_ge2 %>% group_by(GEN) %>% colindiag(contains("N"))Pairwise combinations of variables
Description
Pairwise combinations of variables that will be the result of a functionapplied to each combination.
Usage
comb_vars(.data, order = "first", FUN = "+", verbose = TRUE)Arguments
.data | A matrix of data with, say, p columns. |
order | The order on how the results will appear in the output. Defaultis |
FUN | The function that will be applied to each combination. The defaultis |
verbose | Logical argument. If |
Value
A data frame containing all possible combination of variables. Eachcombination is the result of the function inFUN applied to the twovariables.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)data <- data.frame(A = rnorm(n = 5, mean = 10, sd = 3), B = rnorm(n = 5, mean = 120, sd = 30), C = rnorm(n = 5, mean = 40, sd = 10), D = rnorm(n = 5, mean = 1100, sd = 200), E = rnorm(n = 5, mean = 2, sd = 1))comb1 <- comb_vars(data)comb2 <- comb_vars(data, FUN = '*', order = 'second')Confidence interval for correlation coefficient
Description
Computes the half-width confidence interval for correlation coefficient usingthe nonparametric method proposed by Olivoto et al. (2018).
The half-width confidence interval is computed according to the followingequation:
\[CI_w = 0.45304^r \times 2.25152 \times n^{-0.50089}\]where \(n\) is the sample size and \(r\) is the correlation coefficient.
Usage
corr_ci( .data = NA, ..., r = NULL, n = NULL, by = NULL, sel.var = NULL, verbose = TRUE)Arguments
.data | The data to be analyzed. It can be a data frame (possible withgrouped data passed from |
... | Variables to compute the confidence interval. If not informed, allthe numeric variables from |
r | If |
n | The sample size if |
by | One variable (factor) to compute the function by. It is a shortcutto |
sel.var | A variable to shows the correlation with. This will omit allthe pairwise correlations that doesn't contain |
verbose | If |
Value
A tibble containing the values of the correlation, confidenceinterval, upper and lower limits for all combination of variables.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Olivoto, T., A.D.C. Lucio, V.Q. Souza, M. Nardino, M.I. Diel,B.G. Sari, D.. K. Krysczun, D. Meira, and C. Meier. 2018. Confidenceinterval width for Pearson's correlation coefficient: aGaussian-independent estimator based on sample size and strength ofassociation. Agron. J. 110:1-8.doi:10.2134/agronj2016.04.0196
Examples
library(metan)CI1 <- corr_ci(data_ge2)# By each level of the factor 'ENV'CI2 <- corr_ci(data_ge2, CD, TKW, NKE, by = ENV, verbose = FALSE)CI2Linear and partial correlation coefficients
Description
Computes Pearson's linear correlation or partial correlation with p-values
Usage
corr_coef( data, ..., type = c("linear", "partial"), method = c("pearson", "kendall", "spearman"), use = c("pairwise.complete.obs", "everything", "complete.obs"), by = NULL, verbose = TRUE)Arguments
data | The data set. It understand grouped data passed from |
... | Variables to use in the correlation. If no variable is informedall the numeric variables from |
type | The type of correlation to be computed. Defaults to |
method | a character string indicating which partial correlationcoefficient is to be computed. One of "pearson" (default), "kendall", or"spearman" |
use | an optional character string giving a method for computingcovariances in the presence of missing values. Seestats::cor for moredetails |
by | One variable (factor) to compute the function by. It is a shortcutto |
verbose | Logical argument. If |
Details
The partial correlation coefficient is a technique based on matrix operationsthat allow us to identify the association between two variables by removingthe effects of the other set of variables present (Anderson 2003) Ageneralized way to estimate the partial correlation coefficient between twovariables (i and j ) is through the simple correlation matrix that involvesthese two variables and m other variables from which we want to remove theeffects. The estimate of the partial correlation coefficient between i and jexcluding the effect of m other variables is given by:\[r_{ij.m} = \frac{{- {a_{ij}}}}{{\sqrt {{a_{ii}}{a_{jj}}}}}\]
Where \(r_{ij.m}\) is the partial correlation coefficient betweenvariables i and j, without the effect of the other m variables;\(a_{ij}\) is the ij-order element of the inverse of the linearcorrelation matrix; \(a_{ii}\), and \(a_{jj}\) are the elements oforders ii and jj, respectively, of the inverse of the simple correlationmatrix.
Value
A list with the correlation coefficients and p-values
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Anderson, T. W. 2003. An introduction to multivariate statistical analysis.3rd ed. Wiley-Interscience.
Examples
library(metan)# All numeric variablesall <- corr_coef(data_ge2)# Select variablesel <- corr_coef(data_ge2, EP, EL, CD, CL)sel$cor# Select variables, partial correlationsel <- corr_coef(data_ge2, EP, EL, CD, CL, type = "partial")sel$corFocus on section of a correlation matrix
Description
Select a set of variables from a correlation matrix to keep as the columns,and exclude these or all other variables from the rows.
Usage
corr_focus(model, ...)Arguments
model | A model computed with |
... | One or more unquoted variable name separated by commas. Variablenames can be used as if they were positions in the data frame, soexpressions like |
Value
A tibble
Examples
corr_coef(data_ge2) |> corr_focus(PH)Visualization of a correlation matrix
Description
Graphical and numerical visualization of a correlation matrix
Usage
corr_plot( .data, ..., col.by = NULL, upper = "corr", lower = "scatter", decimal.mark = ".", axis.labels = FALSE, show.labels.in = "show", size.axis.label = 12, size.varnames = 12, col.varnames = "black", diag = TRUE, diag.type = "histogram", bins = 20, col.diag = "gray", alpha.diag = 1, col.up.panel = "gray", col.lw.panel = "gray", col.dia.panel = "gray", prob = 0.05, col.sign = "green", alpha.sign = 0.15, lab.position = "tr", progress = NULL, smooth = FALSE, col.smooth = "red", confint = TRUE, size.point = 1, shape.point = 19, alpha.point = 0.7, fill.point = NULL, col.point = "black", size.line = 0.5, minsize = 2, maxsize = 3, pan.spacing = 0.15, digits = 2, export = FALSE, file.type = "pdf", file.name = NULL, width = 8, height = 7, resolution = 300)Arguments
.data | The data. Should, preferentially, contain numeric variablesonly. If |
... | Variables to use in the correlation. If no variable is informedall the numeric variables from |
col.by | A categorical variable to map the color of the points by.Defaults to |
upper | The visualization method for the upper triangular correlationmatrix. Must be one of |
lower | The visualization method for the lower triangular correlationmatrix. Must be one of |
decimal.mark | The decimal mark. Defaults to |
axis.labels | Should the axis labels be shown in the plot? Set to |
show.labels.in | Where to show the axis labels. Defaults to "show"bottom and left. Use "diag" to show the labels on the diagonal. In thiscase, the diagonal layer (boxplot, density or histogram) will beoverwritten. |
size.axis.label | The size of the text for axis labels if |
size.varnames | The size of the text for variable names. Defaults to 12. |
col.varnames | The color of the text for variable names. Defaults to"black". |
diag | Should the diagonal be shown? |
diag.type | The type of plot to show in the diagonal if |
bins | The number of bins, Defaults to 20. |
col.diag | If |
alpha.diag | Alpha-transparency scale (0-1) to make the diagonal plottransparent. 0 = fully transparent; 1 = full color. Set to 0.15 |
col.up.panel,col.lw.panel,col.dia.panel | The color for the upper,lower, and diagonal panels, respectively. Set to 'gray'. |
prob | The probability of error. Significant correlations will behighlighted with '', '', and '' (0.05, 0.01, and 0.001,respectively). Scatterplots with significant correlations may becolor-highlighted. |
col.sign | The color that will highlight the significant correlations.Set to 'green'. |
alpha.sign | Alpha-transparency scale (0-1) to make the plot areatransparent. 0 = fully transparent; 1 = full color. Set to 0.15 |
lab.position | The position that the labels will appear. Set to |
progress |
|
smooth | Should a linear smooth line be shown in the scatterplots? Setto |
col.smooth | The color for the smooth line. |
confint | Should a confidence band be shown with the smooth line? Set to |
size.point | The size of the points in the plot. Set to |
shape.point | The shape of the point, set to |
alpha.point | Alpha-transparency scale (0-1) to make the pointstransparent. 0 = fully transparent; 1 = full color. Set to 0.7 |
fill.point | The color to fill the points. Valid argument if points arebetween 21 and 25. |
col.point | The color for the edge of the point, set to |
size.line | The size of the line (smooth and diagonal). |
minsize | The size of the letter that will represent the smallestcorrelation coefficient. |
maxsize | The size of the letter that will represent the largestcorrelation coefficient. |
pan.spacing | The space between the panels. Set to 0.15. |
digits | The number of digits to show in the plot. |
export | Logical argument. If |
file.type | The format of the file if |
file.name | The name of the plot when exported. Set to |
width | The width of the plot, set to |
height | The height of the plot, set to |
resolution | The resolution of the plot if |
Value
An object of classgg, ggmatrix.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)dataset <- data_ge2 %>% select_cols(1:7)# Default plot settingcorr_plot(dataset)# Chosing variables to be correlatedcorr_plot(dataset, PH, EH, EL)# Axis labels, similar to the function pairs()# Gray scalecorr_plot(dataset, PH, EH, EL, shape.point = 19, size.point = 2, alpha.point = 0.5, alpha.diag = 0, pan.spacing = 0, col.sign = 'gray', alpha.sign = 0.3, axis.labels = TRUE)corr_plot(dataset, PH, EH, EL, prob = 0.01, shape.point = 21, col.point = 'black', fill.point = 'orange', size.point = 2, alpha.point = 0.6, maxsize = 4, minsize = 2, smooth = TRUE, size.line = 1, col.smooth = 'black', col.sign = 'cyan', col.up.panel = 'black', col.lw.panel = 'black', col.dia.panel = 'black', pan.spacing = 0, lab.position = 'tl')Sample size planning for a desired Pearson's correlation confidence interval
Description
Find the required (sufficient) sample size for computing a Pearsoncorrelation coefficient with a desired confidence interval (Olivoto et al.,2018) as follows\[n = {\left[ {\frac{{C{I_w}}}{{{{0.45304}^r} \times 2.25152}}} \right]^{{\rm{ - 0}}{\rm{.50089}}}}\]
where \(CI_w\) is desired confidence interval and \(r\) is thecorrelation coefficient.
Usage
corr_ss(r, CI, verbose = TRUE)Arguments
r | The magnitude of the correlation coefficient. |
CI | The half-width for confidence interval at p < 0.05. |
verbose | Logical argument. If |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Olivoto, T., A.D.C. Lucio, V.Q. Souza, M. Nardino, M.I. Diel,B.G. Sari, D.. K. Krysczun, D. Meira, and C. Meier. 2018. Confidenceinterval width for Pearson's correlation coefficient: aGaussian-independent estimator based on sample size and strength ofassociation. Agron. J. 110:1-8.doi:10.2134/agronj2016.04.0196
Examples
corr_ss(r = 0.60, CI = 0.1)Correlation between stability indexes
Description
Computes the Spearman's rank correlation between the parametric andnonparametric stability indexes computed with the functionge_stats().
Usage
corr_stab_ind(x, stats = "all", plot = TRUE, ...)Arguments
x | An object of class |
stats | The statistics to compute the correlation. See the sectionDetails for more information. |
plot | Plot the heat map with the correlations? Defaults to |
... | Other arguments to be passed to the function |
Details
The argumentstats is used to chose the statistics to show theranks. Allowed values are"all" (All statistics, default),"par"(Parametric statistics),"nonpar" (Non-parametric statistics),"ammi"(AMMI-based stability statistics), or the following values that can becombined into comma-separated character vector."Y" (Response variable),"Var" (Genotype's variance),"Shukla" (Shukla's variance),"Wi_g", "Wi_f", "Wi_u" (Annichiarrico's genotypic confidence index for all,favorable and unfavorable environments, respectively),"Ecoval" (Wricke'secovalence),"Sij" (Deviations from the joint-regression analysis),"R2" (R-squared from the joint-regression analysis),"ASTAB" (AMMIBased Stability Parameter),"ASI" (AMMI Stability Index),"ASV"(AMMI-stability value),"AVAMGE" (Sum Across Environments of AbsoluteValue of GEI Modelled by AMMI ),"Da" (Annicchiarico's D Parametervalues),"Dz" (Zhang's D Parameter),"EV" (Sums of the Averages of theSquared Eigenvector Values),"FA" (Stability Measure Based on Fitted AMMIModel),"MASV" (Modified AMMI Stability Value),"SIPC" (Sums of theAbsolute Value of the IPC Scores),"Za" (Absolute Value of the RelativeContribution of IPCs to the Interaction),"WAAS" (Weighted average ofabsolute scores),"HMGV" (Harmonic mean of the genotypic value),"RPGV"(Relative performance of the genotypic values),"HMRPGV" (Harmonic meanof the relative performance of the genotypic values),"Pi_a", "Pi_f", "Pi_u" (Superiority indexes for all, favorable and unfavorableenvironments, respectively),"Gai" (Geometric adaptability index),"S1"(mean of the absolute rank differences of a genotype over the nenvironments),"S2" (variance among the ranks over the k environments),"S3" (sum of the absolute deviations),"S6" (relative sum of squares ofrank for each genotype),"N1", "N2", "N3", "N4" (Thennarasu"sstatistics)).
Value
A list with the data (ranks) correlation, p-values and a heat map showing thecorrelation coefficients.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)model <- ge_stats(data_ge, ENV, GEN, REP, GY)a <- corr_stab_ind(model)Generate correlated variables
Description
Generate correlated variables using a vector of know values and desiredmaximum and minimum correlations
Usage
correlated_vars( y, min_cor = -1, max_cor = 1, nvars, constant = NULL, operation = "*", x = NULL)Arguments
y | A vector to generate variables correlated with. |
min_cor | The minimum desired correlation. |
max_cor | The maximum desired correlation. |
nvars | The number of variables. |
constant | A constant. Use |
operation | The operation to be applied to the |
x | An optional vector of the same length of |
Value
A data frame with they variable and the correlated variables.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)y <- rnorm(n = 10)cor_vars <- correlated_vars(y, nvar = 6)plot(cor_vars)Variance-covariance matrices for designed experiments
Description
Compute variance-covariance and correlation matrices using data from adesigned (RCBD or CRD) experiment.
Usage
covcor_design(.data, gen, rep, resp, design = "RCBD", by = NULL, type = NULL)Arguments
.data | The data to be analyzed. It can be a data frame, possible withgrouped data passed from |
gen | The name of the column that contains the levels of the genotypes. |
rep | The name of the column that contains the levels of thereplications/blocks. |
resp | The response variables. For example |
design | The experimental design. Must be RCBD or CRD. |
by | One variable (factor) to compute the function by. It is a shortcutto |
type | What the matrices should return? Set to |
Value
An object of classcovcor_design containing the followingitems:
geno_cov The genotypic covariance.
phen_cov The phenotypic covariance.
resi_cov The residual covariance.
geno_cor The phenotypic correlation.
phen_cor The phenotypic correlation.
resi_cor The residual correlation.
If.data is a grouped data passed fromdplyr::group_by()then the results will be returned into a list-column of data frames.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)# List of matricesdata <- subset(data_ge2, ENV == 'A1')matrices <- covcor_design(data, gen = GEN, rep = REP, resp = c(PH, EH, NKE, TKW))# Genetic correlationsgcor <- covcor_design(data, gen = GEN, rep = REP, resp = c(PH, EH, NKE, TKW), type = 'gcor')# Residual (co)variance matrix for each environmentrcov <- covcor_design(data_ge2, gen = GEN, rep = REP, resp = c(PH, EH, CD, CL), by = ENV, type = "rcov")Cross-validation procedure
Description
Cross-validation for estimation of AMMI models
THe original dataset is split into two datasets: training set and validationset. The 'training' set has all combinations (genotype x environment) withN-1 replications. The 'validation' set has the remaining replication. Thesplitting of the dataset into modeling and validation sets depends on thedesign informed. For Completely Randomized Block Design (default), andalpha-lattice design (declaringblock arguments), complete replicatesare selected within environments. The remained replicate serves as validationdata. Ifdesign = 'RCD' is informed, completely randomly samples aremade for each genotype-by-environment combination (Olivoto et al. 2019). Theestimated values consideringnaxis-Interaction Principal ComponentAxis are compared with the 'validation' data. The Root Mean Square PredictionDifference (RMSPD) is computed. At the end of boots, a list is returned.
IMPORTANT: If the data set is unbalanced (i.e., any genotype missingin any environment) the function will return an error. An error is alsoobserved if any combination of genotype-environment has a different number ofreplications than observed in the trial.
Usage
cv_ammi( .data, env, gen, rep, resp, block = NULL, naxis = 2, nboot = 200, design = "RCBD", verbose = TRUE)Arguments
.data | The dataset containing the columns related to Environments,Genotypes, replication/block and response variable(s). |
env | The name of the column that contains the levels of theenvironments. |
gen | The name of the column that contains the levels of the genotypes. |
rep | The name of the column that contains the levels of thereplications/blocks.AT LEAST THREE REPLICATES ARE REQUIRED TOPERFORM THE CROSS-VALIDATION. |
resp | The response variable. |
block | Defaults to |
naxis | The number of axis to be considered for estimation of GEeffects. |
nboot | The number of resamples to be used in the cross-validation.Defaults to 200. |
design | The experimental design. Defaults to |
verbose | A logical argument to define if a progress bar is shown.Default is |
Value
An object of classcv_ammi with the following items: *RMSPD: A vector with nboot-estimates of the Root Mean SquaredPrediction Difference between predicted and validating data.
RMSPDmean: The mean of RMSPDmean estimates.
Estimated: A data frame that contain the values (predicted,observed, validation) of the last loop.
Modeling: The dataset used as modeling data in the last loop
Testing: The dataset used as testing data in the last loop.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Olivoto, T., A.D.C. Lúcio, J.A.G. da silva, V.S. Marchioro,V.Q. de Souza, and E. Jost. 2019. Mean performance and stability inmulti-environment trials I: Combining features of AMMI and BLUP techniques.Agron. J. 111:2949-2960.doi:10.2134/agronj2019.03.0220
Patterson, H.D., and E.R. Williams. 1976. A new class ofresolvable incomplete block designs. Biometrika 63:83-92.
See Also
Examples
library(metan)model <- cv_ammi(data_ge, env = ENV, gen = GEN, rep = REP, resp = GY, nboot = 5, naxis = 2)Cross-validation procedure
Description
Cross-validation for estimation of all AMMI-family models
cv_ammif provides a complete cross-validation of replicate-based datausing AMMI-family models. By default, the first validation is carried outconsidering the AMMIF (all possible axis used). Considering this model, theoriginal dataset is split up into two datasets: training set and validationset. The 'training' set has all combinations (genotype x environment) withN-1 replications. The 'validation' set has the remaining replication. Thesplitting of the dataset into modeling and validation sets depends on thedesign informed. For Completely Randomized Block Design (default), andalpha-lattice design (declaringblock arguments), complete replicatesare selected within environments. The remained replicate serves as validationdata. Ifdesign = 'RCD' is informed, completely randomly samples aremade for each genotype-by-environment combination (Olivoto et al. 2019). Theestimated values for each member of the AMMI-family model are compared withthe 'validation' data. The Root Mean Square Prediction Difference (RMSPD) iscomputed. At the end of boots, a list is returned.
IMPORTANT: If the data set is unbalanced (i.e., any genotype missingin any environment) the function will return an error. An error is alsoobserved if any combination of genotype-environment has a different number ofreplications than observed in the trial.
Usage
cv_ammif( .data, env, gen, rep, resp, nboot = 200, block, design = "RCBD", verbose = TRUE)Arguments
.data | The dataset containing the columns related to Environments,Genotypes, replication/block and response variable(s). |
env | The name of the column that contains the levels of theenvironments. |
gen | The name of the column that contains the levels of the genotypes. |
rep | The name of the column that contains the levels of thereplications/blocks.AT LEAST THREE REPLICATES ARE REQUIRED TOPERFORM THE CROSS-VALIDATION. |
resp | The response variable. |
nboot | The number of resamples to be used in the cross-validation.Defaults to 200. |
block | Defaults to |
design | The experimental design used in each environment. Defaults to |
verbose | A logical argument to define if a progress bar is shown.Default is |
Value
An object of classcv_ammif with the following items:
RMSPD: A vector with nboot-estimates of the Root Mean SquaredPrediction Difference between predicted and validating data.
RMSPDmean: The mean of RMSPDmean estimates.
Estimated: A data frame that contain the values (predicted, observed,validation) of the last loop.
Modeling: The dataset used as modeling data in the last loop
Testing: The dataset used as testing data in the last loop.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Patterson, H.D., and E.R. Williams. 1976. A new class ofresolvable incomplete block designs. Biometrika 63:83-92.
See Also
Examples
library(metan)model <- cv_ammif(data_ge2, env = ENV, gen = GEN, rep = REP, resp = EH, nboot = 5)plot(model)Cross-validation procedure
Description
Cross-validation for blup prediction.
This function provides a cross-validation procedure for mixed models usingreplicate-based data. By default, complete blocks are randomly selectedwithin each environment. In each iteration, the original dataset is split upinto two datasets: training and validation data. The 'training' set has allcombinations (genotype x environment) with R - 1 replications. The'validation' set has the remaining replication. The estimated values arecompared with the 'validation' data and the Root Means Square PredictionDifference (Olivoto et al. 2019) is computed. At the end of boots, a list isreturned.
Usage
cv_blup( .data, env, gen, rep, resp, block = NULL, nboot = 200, random = "gen", verbose = TRUE)Arguments
.data | The dataset containing the columns related to Environments,Genotypes, replication/block and response variable(s). |
env | The name of the column that contains the levels of theenvironments. |
gen | The name of the column that contains the levels of the genotypes. |
rep | The name of the column that contains the levels of thereplications/blocks.AT LEAST THREE REPLICATES ARE REQUIRED TOPERFORM THE CROSS-VALIDATION. |
resp | The response variable. |
block | Defaults to |
nboot | The number of resamples to be used in the cross-validation.Defaults to 200 |
random | The effects of the model assumed to be random. SeeDetails for more information. |
verbose | A logical argument to define if a progress bar is shown.Default is |
Details
Six models may be fitted depending upon the values inblockandrandom arguments.
Model 1:
block = NULLandrandom = "gen"(Thedefault option). This model considers a Randomized Complete Block Design ineach environment assuming genotype and genotype-environment interaction asrandom effects. Environments and blocks nested within environments areassumed to fixed factors.Model 2:
block = NULLandrandom = "env". Thismodel considers a Randomized Complete Block Design in each environmenttreating environment, genotype-environment interaction, and blocks nestedwithin environments as random factors. Genotypes are assumed to be fixedfactors.Model 3:
block = NULLandrandom = "all". Thismodel considers a Randomized Complete Block Design in each environmentassuming a random-effect model, i.e., all effects (genotypes, environments,genotype-vs-environment interaction and blocks nested within environments)are assumed to be random factors.Model 4:
blockis notNULLandrandom = "gen". This model considers an alpha-lattice design in each environmentassuming genotype, genotype-environment interaction, and incomplete blocksnested within complete replicates as random to make use of inter-blockinformation (Mohring et al., 2015). Complete replicates nested withinenvironments and environments are assumed to be fixed factors.Model 5:
blockis notNULLandrandom = "env". This model considers an alpha-lattice design in each environmentassuming genotype as fixed. All other sources of variation (environment,genotype-environment interaction, complete replicates nested withinenvironments, and incomplete blocks nested within replicates) are assumedto be random factors.Model 6:
blockis notNULLandrandom = "all". This model considers an alpha-lattice design in each environmentassuming all effects, except the intercept, as random factors.
IMPORTANT: An error is returned if any combination ofgenotype-environment has a different number of replications than observed inthe trial.
Value
An object of classcv_blup with the following items: *RMSPD: A vector with nboot-estimates of the root mean squaredprediction difference between predicted and validating data. *RMSPDmean The mean of RMSPDmean estimates.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Olivoto, T., A.D.C. Lúcio, J.A.G. da silva, V.S. Marchioro,V.Q. de Souza, and E. Jost. 2019. Mean performance and stability inmulti-environment trials I: Combining features of AMMI and BLUP techniques.Agron. J. 111:2949-2960.doi:10.2134/agronj2019.03.0220
Patterson, H.D., and E.R. Williams. 1976. A new class ofresolvable incomplete block designs. Biometrika 63:83-92.
Mohring, J., E. Williams, and H.-P. Piepho. 2015. Inter-blockinformation: to recover or not to recover it? TAG. Theor. Appl. Genet.128:1541-54.doi:10.1007/s00122-015-2530-0
See Also
Examples
library(metan)model <- cv_blup(data_ge, env = ENV, gen = GEN, rep = REP, resp = GY, nboot = 5)Data from an alpha lattice design
Description
Alpha lattice design of spring oats
Format
A tibble with 72 observations on the following 5 variables.
PLOT Plot number
REP Replicate code
BLOCK Incomplete block code
GEN Genotype code
YIELD Observed dry matter yield (tonnes/ha)
Details
A spring oats trial grown in Craibstone. There were 24 varietiesin 3 replicates, each consisting of 6 incomplete blocks of 4 plots.Planted in a resolvable alpha design. The plots were laid out in a single line.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Source
J. A. John & E. R. Williams (1995). Cyclic and computer generated designs,Chapman and Hall, London. Page 146.
Single maize trial
Description
This dataset contain data on 15 traits assessed in 13 maize hybrids.The experimental design was a RCBD with 3 blocks and 1replications per block. It is used as an example in the functiongamem()of themetan package.
Format
A tibble with 39 observations on the following 17 variables.
GEN A factor with 13 levels; each level represents one maize hybrid.
REP A factor with 3 levels; each level represents one replication/block.
PH Plant height, in cm.
EH Ear height, in cm.
EP Ear position, i.e., the ratio EH/PH.
EL Ear length, in cm.
ED Ear diameter, in mm.
CL Cob length, in cm.
CD Cob diameter, in mm.
CW Cob weight, in g.
KW Kernel weight, in cm.
NR Number of rows.
NKR Number of kernels per row.
CDED Cob diameter / Ear diameter ratio.
PERK Percentage of kernels.
TKW Thousand-kernel weight
NKE Number of kernels per row.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Source
Personal data
Multi-environment trial of oat
Description
This dataset contain data on two variables assessed in 10 genotypes growingin 14 environments. The experimental design was a RCBD with 3replicates (blocks). This data provide examples for several functions ofmetan package.
Format
A tibble with 420 observations on the following 5 variables.
ENV A factor with 14 levels; each level represents one cultivationenvironment.
GEN A factor with 10 levels; each level represents one genotype.
REP A factor with 3 levels; each level represents onereplication/block.
GY A continuous variable (grain yield) observed in each plot.
HM A continuous variable (hectoliter mass) observed in each plot.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Source
Personal data
Multi-environment trial of maize
Description
This dataset contain data on 15 traits assessed in 13 maize hybrids growingin 4 environments. The experimental design was a RCBD with 3 blocks and 1replications per block. It may be used as example in several functions ofmetan package.
Format
A tibble with 156 observations on the following 18 variables.
ENV A factor with 4 levels; each level represents one cultivationenvironment.
GEN A factor with 13 levels; each level represents one maize hybrid.
REP A factor with 3 levels; each level represents onereplication/block.
PH Plant height, in cm.
EH Ear height, in cm.
EP Ear position, i.e., the ratio EH/PH.
EL Ear length, in cm.
ED Ear diameter, in mm.
CL Cob length, in cm.
CD Cob diameter, in mm.
CW Cob weight, in g.
KW Kernel weight, in cm.
NR Number of rows.
NKR Number of kernels per row.
CDED Cob diameter / Ear diameter ratio.
PERK Percentage of kernels.
TKW Thousand-kernel weight
NKE Number of kernels per row.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Source
Personal data
Simulate genotype and genotype-environment data
Description
g_simula()simulate replicated genotype data.ge_simula()simulate replicated genotype-environment data.
Usage
ge_simula( ngen, nenv, nrep, nvars = 1, gen_eff = 20, env_eff = 15, rep_eff = 5, ge_eff = 10, res_eff = 5, intercept = 100, seed = NULL)g_simula( ngen, nrep, nvars = 1, gen_eff = 20, rep_eff = 5, res_eff = 5, intercept = 100, seed = NULL)Arguments
ngen | The number of genotypes. |
nenv | The number of environments. |
nrep | The number of replications. |
nvars | The number of traits. |
gen_eff | The genotype effect. |
env_eff | The environment effect |
rep_eff | The replication effect |
ge_eff | The genotype-environment interaction effect. |
res_eff | The residual effect. The effect is sampled from a normaldistribution with zero mean and standard deviation equal to |
intercept | The intercept. |
seed | The seed. |
Details
The functions simulate genotype or genotype-environment data given adesired number of genotypes, environments and effects. All effects aresampled from an uniform distribution. For example, given 10 genotypes, andgen_eff = 30, the genotype effects will be sampled asrunif(10, min = -30, max = 30). Use the argumentseed to ensure reproducibility. If morethan one trait is used (nvars > 1), the effects and seed can be passed asa numeric vector. Single numeric values will be recycled with a warningwhen more than one trait is used.
Value
A data frame with the simulated traits
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)# Genotype data (5 genotypes and 3 replicates)gen_data <- g_simula(ngen = 5, nrep = 3, seed = 1)gen_datainspect(gen_data, plot = TRUE)aov(V1 ~ GEN + REP, data = gen_data) %>% anova()# Genotype-environment data# 5 genotypes, 3 environments, 4 replicates and 2 traitsdf <-ge_simula(ngen = 5, nenv = 3, nrep = 4, nvars = 2, seed = 1)ge_plot(df, ENV, GEN, V1)aov(V1 ~ ENV*GEN + ENV/REP, data = df) %>% anova()# Change genotype effect (trait 1 with fewer differences among genotypes)# Define different intercepts for the two traitsdf2 <-ge_simula(ngen = 10, nenv = 3, nrep = 4, nvars = 2, gen_eff = c(1, 50), intercept = c(80, 1500), seed = 1)ge_plot(df2, ENV, GEN, V2)Descriptive statistics
Description
desc_stat()Computes the most used measures of central tendency,position, and dispersion.desc_wider()is useful to put the variables in columns and groupingvariables in rows. The table is filled with a statistic chosen with theargumentstat.
Usage
desc_stat( .data = NULL, ..., by = NULL, stats = "main", hist = FALSE, level = 0.95, digits = 4, na.rm = FALSE, verbose = TRUE, plot_theme = theme_metan())desc_wider(.data, which)Arguments
.data | The data to be analyzed. It can be a data frame (possible withgrouped data passed from |
... | A single variable name or a comma-separated list of unquotedvariables names. If no variable is informed, all the numeric variables from |
by | One variable (factor) to compute the function by. It is a shortcutto |
stats | The descriptive statistics to show. This is used to filter theoutput after computation. Defaults to
Use a names to select the statistics. For example, |
hist | Logical argument defaults to |
level | The confidence level to compute the confidence interval of mean.Defaults to 0.95. |
digits | The number of significant digits. |
na.rm | Logical. Should missing values be removed? Defaults to |
verbose | Logical argument. If |
plot_theme | The graphical theme of the plot. Default is |
which | A statistic to fill the table. |
Value
desc_stats()returns a tibble with the statistics in the columns andvariables (with possible grouping factors) in rows.desc_wider()returns a tibble with variables in columns and groupingfactors in rows.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)#===============================================================## Example 1: main statistics (coefficient of variation, maximum,## mean, median, minimum, sample standard deviation, standard ## error and confidence interval of the mean) for all numeric ## variables in data ##===============================================================#desc_stat(data_ge2)#===============================================================##Example 2: robust statistics using a numeric vector as input ## data#===============================================================#vect <- data_ge2$TKWdesc_stat(vect, stats = "robust")#===============================================================## Example 3: Select specific statistics. In this example, NAs ## are removed before analysis with a warning message ##===============================================================#desc_stat(c(12, 13, 19, 21, 8, NA, 23, NA), stats = c('mean, se, cv, n, n.valid'), na.rm = TRUE)#===============================================================## Example 4: Select specific variables and compute statistics by## levels of a factor variable (GEN) ##===============================================================#stats <- desc_stat(data_ge2, EP, EL, EH, ED, PH, CD, by = GEN)stats# To get a 'wide' format with the maximum values for all variablesdesc_wider(stats, max)#===============================================================## Example 5: Compute all statistics for all numeric variables ## by two or more factors. Note that group_by() was used to pass ## grouped data to the function desc_stat() ##===============================================================#data_ge2 %>% group_by(ENV, GEN) %>% desc_stat()Alternative to dplyr::do for doing anything
Description
Provides an alternative to thedplyr:do() usingnest(),mutate() andmap() to apply a function to a grouped data frame.
Usage
doo(.data, .fun, ..., unnest = TRUE)Arguments
.data | a (grouped) data frame |
.fun | A function, formula, or atomic vector. |
... | Additional arguments passed on to |
unnest | Logical argument defaults to |
Details
If the applied function returns a data frame, then the output will beautomatically unnested. Otherwise, the output includes the groupingvariables and a column named "data" , which is a "list-columns" containingthe results for group combinations.
Value
a data frame
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)# Head the first two lines of each environmentdata_ge2 %>% group_by(ENV) %>% doo(~head(., 2))# Genotype analysis for each environment using 'gafem()'# variable PHdata_ge2 %>% group_by(ENV) %>% doo(~gafem(., GEN, REP, PH, verbose = FALSE))Stability analysis based on Wricke's model
Description
The function computes the ecovalence (Wricke, 1965) for stability analysis.
Usage
ecovalence(.data, env, gen, rep, resp, verbose = TRUE)Arguments
.data | The dataset containing the columns related to Environments,Genotypes, replication/block and response variable(s). |
env | The name of the column that contains the levels of theenvironments. |
gen | The name of the column that contains the levels of the genotypes. |
rep | The name of the column that contains the levels of thereplications/blocks. |
resp | The response variable(s). To analyze multiple variables in asingle procedure use, for example, |
verbose | Logical argument. If |
Value
An object of classecovalence containing the results for eachvariable used in the argumentresp.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Wricke, G. 1965. Zur berechnung der okovalenz bei sommerweizenund hafer. Z. Pflanzenzuchtg 52:127-138.
Examples
library(metan)out <- ecovalence(data_ge2, env = ENV, gen = GEN, rep = REP, resp = PH)Dissimilarity between environments
Description
Computes the dissimilarity between environments based on several approaches.See the sectiondetails for more details.
Usage
env_dissimilarity(.data, env, gen, rep, resp)Arguments
.data | The dataset containing the columns related to Environments,Genotypes, replication/block and response variable(s). |
env | The name of the column that contains the levels of theenvironments. |
gen | The name of the column that contains the levels of the genotypes. |
rep | The name of the column that contains the levels of thereplications/blocks. |
resp | The response variable(s). To analyze multiple variables in asingle procedure a vector of variables may be used. For example |
Details
Roberteson (1959) proposed the partition of the mean square of thegenotype-environment interaction (MS_GE) into single (S) and complex (C)parts, whereS = \frac{1}{2}(\sqrt{Q1}-\sqrt{Q2})^2) andC = (1-r)\sqrt{Q1-Q2}, beingr the correlation between the genotype'saverage in the two environments; andQ1 andQ2 the genotypemean square in the environments 1 and 2, respectively. Cruz and Castoldi(1991) proposed a new decomposition of the MS_GE, in which the complex partis given byC = \sqrt{(1-r)^3\times Q1\times Q2}.
Value
A list with the following matrices:
SPART_CC: The percentage of the single (non cross-over) part of theinteraction between genotypes and pairs of environments according to themethod proposed by Cruz and Castoldi (1991).CPART_CC: The percentage of the complex (cross-over) part of theinteraction between genotypes and pairs of environments according to themethod proposed by Cruz and Castoldi (1991).SPART_RO: The percentage of the single (non cross-over) part of theinteraction between genotypes and pairs of environments according to themethod proposed by Robertson (1959).CPART_RO: The percentage of the complex (cross-over) part of theinteraction between genotypes and pairs of environments according to themethod proposed by Robertson (1959).MSGE: Interaction mean square between genotypes and pairs ofenvironments.SSGE: Interaction sum of square between genotypes and pairs ofenvironments.correlation: Correlation coefficients between genotypes's average ineach pair of environment.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Cruz, C.D., Castoldi, F. (1991). Decomposicao da interacao genotipos xambientes em partes simples e complexa. Ceres, 38:422-430.
Robertson, A. (1959). Experimental design on the measurement ofheritabilities and genetic correlations. biometrical genetics. New York:Pergamon Press.
Examples
library(metan)mod <- env_dissimilarity(data_ge, ENV, GEN, REP, GY)print(mod)Environment stratification
Description
Computes environment stratification based on factor analysis.
Usage
env_stratification( .data, env, gen, resp, use = "complete.obs", mineval = 1, verbose = TRUE)Arguments
.data | The dataset containing the columns related to Environments,Genotypes, replication/block and response variable(s) |
env | The name of the column that contains the levels of theenvironments. |
gen | The name of the column that contains the levels of the genotypes. |
resp | The response variable(s). To analyze multiple variables in asingle procedure use, for example, |
use | The method for computing covariances in the presence of missingvalues. Defaults to |
mineval | The minimum value so that an eigenvector is retained in thefactor analysis. |
verbose | Logical argument. If |
Value
An object of classenv_stratification which is a list with oneelement per analyzed trait. For each trait, the following values are given.
dataThe genotype-environment means.cormat: The correlation matrix among the environments.PCA: The eigenvalues and explained variance.FA: The factor analysis.env_strat: The environmental stratification.mega_env_code: The environments within each mega-environment.mega_env_stat: The statistics for each mega-environment.KMO: The result for the Kaiser-Meyer-Olkin test.MSA: The measure of sampling adequacy for individual variable.communalities_mean: The communalities' mean.initial_loadings: The initial loadings.
Author(s)
Tiago Olivoto,tiagoolivoto@gmail.com
References
Murakami, D.M.D., and C.D.C. Cruz. 2004. Proposal ofmethodologies for environment stratification and analysis of genotypeadaptability. Crop Breed. Appl. Biotechnol. 4:7-11.
See Also
Examples
library(metan)model <-env_stratification(data_ge, env = ENV, gen = GEN, resp = everything())gmd(model)Multi-trait selection index
Description
Multitrait index based on factor analysis and ideotype-design proposed byRocha et al. (2018).
Usage
fai_blup( .data, use_data = "blup", DI = NULL, UI = NULL, SI = 15, mineval = 1, verbose = TRUE)Arguments
.data | An object of class |
use_data | Define which data to use If |
DI,UI | A vector of the same length of |
SI | An integer (0-100). The selection intensity in percentage of thetotal number of genotypes. Defaults to 15. |
mineval | The minimum value so that an eigenvector is retained in thefactor analysis. |
verbose | Logical value. If |
Value
An object of classfai_blup with the following items:
data The data (BLUPS) used to compute the index.
eigen The eigenvalues and explained variance for each axis.
FA The results of the factor analysis.
canonical_loadings The canonical loadings for each factor retained.
FAI A list with the FAI-BLUP index for each ideotype design.
sel_dif_trait A list with the selection differential for each ideotype design.
sel_gen The selected genotypes.
ideotype_construction A list with the construction of the ideotypes.
total_gain A list with the total gain for variables to be increased or decreased.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Rocha, J.R.A.S.C.R, J.C. Machado, and P.C.S. Carneiro. 2018. Multitrait indexbased on factor analysis and ideotype-design: proposal and application onelephant grass breeding for bioenergy. GCB Bioenergy 10:52-60.doi:10.1111/gcbb.12443
Examples
library(metan)mod <- waasb(data_ge, env = ENV, gen = GEN, rep = REP, resp = c(GY, HM))FAI <- fai_blup(mod, SI = 15, DI = c('max, max'), UI = c('min, min'))Find possible outliers in a dataset
Description
Find possible outliers in the dataset.
Usage
find_outliers( .data = NULL, var = NULL, by = NULL, plots = FALSE, coef = 1.5, verbose = TRUE, plot_theme = theme_metan())Arguments
.data | The data to be analyzed. Must be a dataframe or an object ofclass |
var | The variable to be analyzed. |
by | One variable (factor) to compute the function by. It is a shortcutto |
plots | If |
coef | The multiplication coefficient, defaults to 1.5. For more detailssee |
verbose | If |
plot_theme | The graphical theme of the plot. Default is |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)find_outliers(data_ge2, var = PH, plots = TRUE)# Find outliers within each environmentfind_outliers(data_ge2, var = PH, by = ENV)Genotype analysis by fixed-effect models
Description
One-way analysis of variance of genotypes conducted in both randomizedcomplete block and alpha-lattice designs.
Usage
gafem( .data, gen, rep, resp, block = NULL, by = NULL, prob = 0.05, verbose = TRUE)Arguments
.data | The dataset containing the columns related to, Genotypes,replication/block and response variable(s). |
gen | The name of the column that contains the levels of the genotypes, that willbe treated as random effect. |
rep | The name of the column that contains the levels of the replications(assumed to be fixed). |
resp | The response variable(s). To analyze multiple variables in asingle procedure a vector of variables may be used. For example |
block | Defaults to |
by | One variable (factor) to compute the function by. It is a shortcutto |
prob | The error probability. Defaults to 0.05. |
verbose | Logical argument. If |
Details
gafem analyses data from a one-way genotype testingexperiment. By default, a randomized complete block design is usedaccording to the following model:\[Y_{ij} = m + g_i + r_j + e_{ij}\]where \(Y_{ij}\) is the response variable of the ith genotype in thejth block;m is the grand mean (fixed); \(g_i\) is the effectof theith genotype; \(r_j\) is the effect of thejthreplicate; and \(e_{ij}\) is the random error.
Whenblock is informed, then a resolvable alpha design is implemented,according to the following model:
where where \(y_{ijk}\)is the response variable of theith genotype in thekth blockof thejth replicate;m is the intercept, \(t_i\) is theeffect for theith genotype \(r_j\) is the effect of thejthreplicate, \(b_{jk}\) is the effect of thekth incomplete block ofthejth replicate, and \(e_{ijk}\) is the plot error effectcorresponding to \(y_{ijk}\). All effects, except the random error areassumed to be fixed.
Value
A list where each element is the result for one variable containingthe following objects:
anova: The one-way ANOVA table.
model: The model with of
lm.augment: Information about each observation in the dataset. Thisincludes predicted values in the
fittedcolumn, residuals in theresidcolumn, standardized residuals in thestdrescolumn,the diagonal of the 'hat' matrix in thehat, and standard errors forthe fitted values in these.fitcolumn.hsd: The Tukey's 'Honest Significant Difference' for genotypeeffect.
details: A tibble with the following data:
Ngen, thenumber of genotypes;OVmean, the grand mean;Min, the minimumobserved (returning the genotype and replication/block);Maxthemaximum observed,MinGENthe loser winner genotype,MaxGEN,the winner genotype.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Patterson, H.D., and E.R. Williams. 1976. A new class ofresolvable incomplete block designs. Biometrika 63:83-92.
See Also
Examples
library(metan)# RCBDrcbd <- gafem(data_g, gen = GEN, rep = REP, resp = c(PH, ED, EL, CL, CW))# Fitted valuesget_model_data(rcbd)# ALPHA-LATTICE DESIGNalpha <- gafem(data_alpha, gen = GEN, rep = REP, block = BLOCK, resp = YIELD)# Fitted valuesget_model_data(alpha)Geometric adaptability index
Description
Performs a stability analysis based on the geometric mean (GAI), according tothe following model (Mohammadi and Amri, 2008):\[GAI = \sqrt[E]{{\mathop {\bar Y}\nolimits_1 + \mathop {\bar Y}\nolimits_2 + ... + \mathop {\bar Y}\nolimits_i }}\]where \(\bar Y_1\), \(\bar Y_2\), and \(\bar Y_i\) arethe mean yields of the first, second andi-th genotypes acrossenvironments, and E is the number of environments
Usage
gai(.data, env, gen, resp, verbose = TRUE)Arguments
.data | The dataset containing the columns related to Environments,Genotypes, replication/block and response variable(s). |
env | The name of the column that contains the levels of theenvironments. |
gen | The name of the column that contains the levels of the genotypes. |
resp | The response variable(s). To analyze multiple variables in asingle procedure use, for example, |
verbose | Logical argument. If |
Value
An object of classgai, which is a list containing the resultsfor each variable used in the argumentresp. For each variable, atibble with the following columns is returned.
GEN the genotype's code.
GAI Geometric adaptability index
GAI_R The rank for the GAI value.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Mohammadi, R., & Amri, A. (2008). Comparison of parametric and non-parametricmethods for selecting stable and adapted durum wheat genotypes in variableenvironments. Euphytica, 159(3), 419-432.doi:10.1007/s10681-007-9600-6.
Examples
library(metan)out <- gai(data_ge2, env = ENV, gen = GEN, resp = c(EH, PH, EL, CD, ED, NKE))Genotype analysis by mixed-effect models
Description
Analysis of genotypes in single experiments using mixed-effect models withestimation of genetic parameters.
Usage
gamem( .data, gen, rep, resp, block = NULL, by = NULL, prob = 0.05, verbose = TRUE)Arguments
.data | The dataset containing the columns related to, Genotypes,replication/block and response variable(s). |
gen | The name of the column that contains the levels of the genotypes,that will be treated as random effect. |
rep | The name of the column that contains the levels of thereplications (assumed to be fixed). |
resp | The response variable(s). To analyze multiple variables in asingle procedure a vector of variables may be used. For example |
block | Defaults to |
by | One variable (factor) to compute the function by. It is a shortcutto |
prob | The probability for estimating confidence interval for BLUP'sprediction. |
verbose | Logical argument. If |
Details
gamem analyses data from a one-way genotype testing experiment.By default, a randomized complete block design is used according to the following model:\[Y_{ij} = m + g_i + r_j + e_{ij}\]where \(Y_{ij}\) is the response variable of the ith genotype in thejth block;m is the grand mean (fixed); \(g_i\) is the effect of theith genotype(assumed to be random); \(r_j\) is the effect of thejth replicate (assumed to be fixed);and \(e_{ij}\) is the random error.
Whenblock is informed, then a resolvable alpha design is implemented, according to the following model:
where where \(y_{ijk}\) is the response variable of theith genotype in thekth block of thejth replicate;m is the intercept, \(t_i\) isthe effect for theith genotype \(r_j\) is the effect of thejthreplicate, \(b_{jk}\) is the effect of thekth incomplete block ofthejth replicate, and \(e_{ijk}\) is the plot error effectcorresponding to \(y_{ijk}\).
Value
An object of classgamem orgamem_grouped, which is alist with the following items for each element (variable):
fixed: Test for fixed effects.
random: Variance components for random effects.
LRT: The Likelihood Ratio Test for the random effects.
BLUPgen: The estimated BLUPS for genotypes
ranef: The random effects of the model
modellme The mixed-effect model of class
lmerMod.residuals The residuals of the mixed-effect model.
model_lm The fixed-effect model of class
lm.residuals_lm The residuals of the fixed-effect model.
Details: A tibble with the following data:
Ngen, thenumber of genotypes;OVmean, the grand mean;Min, the minimumobserved (returning the genotype and replication/block);Maxthemaximum observed,MinGENthe winner genotype,MaxGEN, theloser genotype.ESTIMATES: A tibble with the values:
Gen_var, the genotypic variance and ;rep:block_varblock-within-replicate variance (ifan alpha-lattice design is used by informing the block inblock);Res_var, the residual variance;Gen (%), rep:block (%), and Res (%)the respective contributionof variance components to the phenotypic variance;H2, broad-sense heritability;h2mg, heritability on the entry-mean basis;Accuracy, the accuracy of selection (square root ofh2mg);CVg, genotypic coefficient of variation;CVr, residual coefficient of variation;CV ratio, the ratio between genotypic and residual coefficient ofvariation.
formula The formula used to fit the mixed-model.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Mohring, J., E. Williams, and H.-P. Piepho. 2015. Inter-block information:to recover or not to recover it? TAG. Theor. Appl. Genet. 128:1541-54.doi:10.1007/s00122-015-2530-0
See Also
Examples
library(metan)# fitting the model considering an RCBD# Genotype as random effectsrcbd <- gamem(data_g, gen = GEN, rep = REP, resp = c(PH, ED, EL, CL, CW, KW, NR, TKW, NKE))# Likelihood ratio test for random effectsget_model_data(rcbd, "lrt")# Variance componentsget_model_data(rcbd, "vcomp")# Genetic parametersget_model_data(rcbd, "genpar")# random effectsget_model_data(rcbd, "ranef")# Predicted valuespredict(rcbd)# fitting the model considering an alpha-lattice design# Genotype and block-within-replicate as random effects# Note that block effect was now informed.alpha <- gamem(data_alpha, gen = GEN, rep = REP, block = BLOCK, resp = YIELD)# Genetic parametersget_model_data(alpha, "genpar")# Random effectsget_model_data(alpha, "ranef")Genotype-environment analysis by mixed-effect models
Description
Genotype analysis in multi-environment trials using mixed-effect orrandom-effect models.
The nature of the effects in the model is chosen with the argumentrandom. By default, the experimental design considered in eachenvironment is a randomized complete block design. Ifblock isinformed, a resolvable alpha-lattice design (Patterson and Williams, 1976) isimplemented. The following six models can be fitted depending on the valuesofrandom andblock arguments.
Model 1:
block = NULLandrandom = "gen"(Thedefault option). This model considers a Randomized Complete Block Design ineach environment assuming genotype and genotype-environment interaction asrandom effects. Environments and blocks nested within environments areassumed to fixed factors.Model 2:
block = NULLandrandom = "env". Thismodel considers a Randomized Complete Block Design in each environmenttreating environment, genotype-environment interaction, and blocks nestedwithin environments as random factors. Genotypes are assumed to be fixedfactors.Model 3:
block = NULLandrandom = "all". Thismodel considers a Randomized Complete Block Design in each environmentassuming a random-effect model, i.e., all effects (genotypes, environments,genotype-vs-environment interaction and blocks nested within environments)are assumed to be random factors.Model 4:
blockis notNULLandrandom = "gen". This model considers an alpha-lattice design in each environmentassuming genotype, genotype-environment interaction, and incomplete blocksnested within complete replicates as random to make use of inter-blockinformation (Mohring et al., 2015). Complete replicates nested withinenvironments and environments are assumed to be fixed factors.Model 5:
blockis notNULLandrandom = "env". This model considers an alpha-lattice design in each environmentassuming genotype as fixed. All other sources of variation (environment,genotype-environment interaction, complete replicates nested withinenvironments, and incomplete blocks nested within replicates) are assumedto be random factors.Model 6:
blockis notNULLandrandom = "all". This model considers an alpha-lattice design in each environmentassuming all effects, except the intercept, as random factors.
Usage
gamem_met( .data, env, gen, rep, resp, block = NULL, by = NULL, random = "gen", prob = 0.05, verbose = TRUE)Arguments
.data | The dataset containing the columns related to Environments,Genotypes, replication/block and response variable(s). |
env | The name of the column that contains the levels of theenvironments. |
gen | The name of the column that contains the levels of the genotypes. |
rep | The name of the column that contains the levels of thereplications/blocks. |
resp | The response variable(s). To analyze multiple variables in asingle procedure a vector of variables may be used. For example |
block | Defaults to |
by | One variable (factor) to compute the function by. It is a shortcutto |
random | The effects of the model assumed to be random. Defaults to |
prob | The probability for estimating confidence interval for BLUP'sprediction. |
verbose | Logical argument. If |
Value
An object of classwaasb with the following items for eachvariable:
fixed Test for fixed effects.
random Variance components for random effects.
LRT The Likelihood Ratio Test for the random effects.
BLUPgen The random effects and estimated BLUPS for genotypes (If
random = "gen"orrandom = "all")BLUPenv The random effects and estimated BLUPS for environments,(If
random = "env"orrandom = "all").BLUPint The random effects and estimated BLUPS of all genotypes inall environments.
MeansGxE The phenotypic means of genotypes in the environments.
modellme The mixed-effect model of class
lmerMod.residuals The residuals of the mixed-effect model.
model_lm The fixed-effect model of class
lm.residuals_lm The residuals of the fixed-effect model.
Details A list summarizing the results. The following informationare shown:
Nenv, the number of environments in the analysis;Ngenthe number of genotypes in the analysis;Meanthe grandmean;SEthe standard error of the mean;SDthe standarddeviation.CVthe coefficient of variation of the phenotypic means,estimating WAASB,Minthe minimum value observed (returning thegenotype and environment),Maxthe maximum value observed (returningthe genotype and environment);MinENVthe environment with the lowermean,MaxENVthe environment with the larger mean observed,MinGENthe genotype with the lower mean,MaxGENthe genotypewith the larger.ESTIMATES A tibble with the genetic parameters (if
random = "gen"orrandom = "all") with the following columns:Phenotypic variancethe phenotypic variance;Heritabilitythe broad-senseheritability;GEr2the coefficient of determination of the interactioneffects;h2mgthe heritability on the mean basis;Accuracythe selective accuracy;rgethe genotype-environmentcorrelation;CVgthe genotypic coefficient of variation;CVrthe residual coefficient of variation;CV ratiothe ratio betweengenotypic and residual coefficient of variation.formula The formula used to fit the mixed-model.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Olivoto, T., A.D.C. Lúcio, J.A.G. da silva, V.S. Marchioro, V.Q. deSouza, and E. Jost. 2019. Mean performance and stability in multi-environmenttrials I: Combining features of AMMI and BLUP techniques. Agron. J.111:2949-2960.doi:10.2134/agronj2019.03.0220
Mohring, J., E. Williams, and H.-P. Piepho. 2015. Inter-block information: torecover or not to recover it? TAG. Theor. Appl. Genet. 128:1541-54.doi:10.1007/s00122-015-2530-0
Patterson, H.D., and E.R. Williams. 1976. A new class of resolvableincomplete block designs. Biometrika 63:83-92.
See Also
mtsi()waas()get_model_data()plot_scores()
Examples
library(metan)#===============================================================## Example 1: Analyzing all numeric variables assuming genotypes ## as random effects ##===============================================================#model <- gamem_met(data_ge, env = ENV, gen = GEN, rep = REP, resp = everything())# Distribution of random effects (first variable)plot(model, type = "re")# Genetic parametersget_model_data(model, "genpar")#===============================================================## Example 2: Unbalanced trials ## assuming all factors as random effects ##===============================================================#un_data <- data_ge %>% remove_rows(1:3) %>% droplevels()model2 <- gamem_met(un_data, env = ENV, gen = GEN, rep = REP, random = "all", resp = GY)get_model_data(model2)Adjusted Coefficient of Variation as yield stability index
Description
Performs a stability analysis based on the scale-adjusted coefficient ofvariation (Doring and Reckling, 2018). For more details seeacv()
Usage
ge_acv(.data, env, gen, resp, verbose = TRUE)Arguments
.data | The dataset containing the columns related to Environments,Genotypes and response variable(s). |
env | The name of the column that contains the levels of theenvironments. |
gen | The name of the column that contains the levels of the genotypes. |
resp | The response variable(s). To analyze multiple variables in asingle procedure use, for example, |
verbose | Logical argument. If |
Value
An object of classge_acv, which is a list containing theresults for each variable used in the argumentresp. For eachvariable, a tibble with the following columns is returned.
GEN the genotype's code.
ACV The adjusted coefficient of variation
ACV_R The rank for the ACV value.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Doring, T.F., and M. Reckling. 2018. Detecting global trends ofcereal yield stability by adjusting the coefficient of variation. Eur. J.Agron. 99: 30-36.doi:10.1016/j.eja.2018.06.007
Examples
library(metan)out <- ge_acv(data_ge2, ENV, GEN, c(EH, PH, EL, CD, ED, NKE))gmd(out)Cluster genotypes or environments
Description
Performs clustering for genotypes or tester environments based on a dissimilarity matrix.
Usage
ge_cluster( .data, env = NULL, gen = NULL, resp = NULL, table = FALSE, distmethod = "euclidean", clustmethod = "ward.D", scale = TRUE, cluster = "env", nclust = NULL)Arguments
.data | The dataset containing the columns related to Environments, Genotypesand the response variable. It is also possible to use a two-way table with genotypesin lines and environments in columns as input. In this case you must use |
env | The name of the column that contains the levels of the environments. Defaults to |
gen | The name of the column that contains the levels of the genotypes. Defaults to |
resp | The response variable(s). Defaults to |
table | Logical values indicating if the input data is a two-way table with genotypesin the rows and environments in the columns. Defaults to |
distmethod | The distance measure to be used. This must be one of |
clustmethod | The agglomeration method to be used. This should be oneof |
scale | Should the data be scaled befor computing the distances? Set toTRUE. Let |
cluster | What should be clustered? Defaults to |
nclust | The number of clust to be formed. Set to |
Value
data The data that was used to compute the distances.
cutpoint The cutpoint of the dendrogram according to Mojena (1977).
distance The matrix with the distances.
de The distances in an object of class
dist.hc The hierarchical clustering.
cophenetic The cophenetic correlation coefficient between distance matrixand cophenetic matrix
Sqt The total sum of squares.
tab A table with the clusters and similarity.
clusters The sum of square and the mean of the clusters for eachgenotype (if
cluster = "env"or environment (ifcluster = "gen").labclust The labels of genotypes/environments within each cluster.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Mojena, R. 2015. Hierarchical grouping methods and stoppingrules: an evaluation. Comput. J. 20:359-363.doi:10.1093/comjnl/20.4.359
Ouyang, Z., R.P. Mowers, A. Jensen, S. Wang, and S. Zheng. 1995.Cluster analysis for genotype x environment interaction with unbalanced data. Crop Sci. 35:1300-1305.doi:10.2135/cropsci1995.0011183X003500050008x
Examples
library(metan)d1 <- ge_cluster(data_ge, ENV, GEN, GY, nclust = 3)plot(d1, nclust = 3)Details for genotype-environment trials
Description
Provide details for genotype-environment trials
Usage
ge_details(.data, env, gen, resp)Arguments
.data | The dataset containing the columns related to Environments,Genotypes, replication/block and response variable(s). |
env | The name of the column that contains the levels of theenvironments. |
gen | The name of the column that contains the levels of the genotypes. |
resp | The response variable(s). To analyze multiple variables in asingle procedure a vector of variables may be used. For example |
Value
A tibble with the following results for each variable:
Mean: The grand mean.SE: The standard error of the mean.SD: The standard deviation.CV: The coefficient of variation.Min,Max: The minimum and maximum value, indicating the genotype and environment of occurence.MinENV, MinGEN: The environment and genotype with the lower mean.MaxENV, MaxGEN: The environment and genotype with the higher mean.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)details <- ge_details(data_ge2, ENV, GEN, everything())print(details)Genotype-environment effects
Description
This is a helper function that computes the genotype-environment effects,i.e., the residual effect of the additive model
Usage
ge_effects(.data, env, gen, resp, type = "ge", verbose = TRUE)Arguments
.data | The dataset containing the columns related to Environments,Genotypes, replication/block and response variable(s). |
env | The name of the column that contains the levels of theenvironments. The analysis of variance is computed for each level of thisfactor. |
gen | The name of the column that contains the levels of the genotypes. |
resp | The response variable(s). To analyze multiple variables in asingle procedure a vector of variables may be used. For example |
type | The type of effect to compute. Defaults to |
verbose | Logical argument. If |
Value
A list where each element is the result for one variable thatcontains a two-way table with genotypes in rows and environments incolumns.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)ge_eff <- ge_effects(data_ge, ENV, GEN, GY)gge_eff <- ge_effects(data_ge, ENV, GEN, GY, type = "gge")plot(ge_eff)Stability analysis and environment stratification
Description
This function computes the stability analysis and environmental stratificationusing factor analysis as proposed by Murakami and Cruz (2004).
Usage
ge_factanal(.data, env, gen, rep, resp, mineval = 1, verbose = TRUE)Arguments
.data | The dataset containing the columns related to Environments, Genotypes,replication/block and response variable(s) |
env | The name of the column that contains the levels of theenvironments. |
gen | The name of the column that contains the levels of the genotypes. |
rep | The name of the column that contains the levels of thereplications/blocks |
resp | The response variable(s). To analyze multiple variables in asingle procedure use, for example, |
mineval | The minimum value so that an eigenvector is retained in thefactor analysis. |
verbose | Logical argument. If |
Value
An object of classge_factanal with the following items:
data: The data used to compute the factor analysis.cormat: The correlation matrix among the environments.PCA: The eigenvalues and explained variance.FA: The factor analysis.env_strat: The environmental stratification.KMO: The result for the Kaiser-Meyer-Olkin test.MSA: The measure of sampling adequacy for individual variable.communalities: The communalities.communalities.mean: The communalities' mean.initial.loadings: The initial loadings.finish.loadings: The final loadings after varimax rotation.canonical.loadings: The canonical loadings.scores.gen: The scores for genotypes for the first and second factors.
Author(s)
Tiago Olivoto,tiagoolivoto@gmail.com
References
Murakami, D.M.D., and C.D.C. Cruz. 2004. Proposal ofmethodologies for environment stratification and analysis of genotypeadaptability. Crop Breed. Appl. Biotechnol. 4:7-11.
See Also
superiority(),ecovalence(),ge_stats(),ge_reg()
Examples
library(metan)model <- ge_factanal(data_ge2, env = ENV, gen = GEN, rep = REP, resp = PH)Genotype-environment means
Description
Computes genotype-environment interaction means
Usage
ge_means(.data, env, gen, resp)Arguments
.data | The dataset containing the columns related to Environments,Genotypes, and the response variable(s). |
env | The name of the column that contains the levels of theenvironments. |
gen | The name of the column that contains the levels of the genotypes. |
resp | The response variable(s). To analyze multiple variables at once,a vector of variables may be used. For example |
Value
A list where each element is the result for one variable containing:
ge_means: A two-way table with the means for genotypes (rows) andenvironments (columns).
gen_means: A tibble with the means for genotypes.
env_means: A tibble with the means for environments.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)means_ge <- ge_means(data_ge, ENV, GEN, resp = everything())# Genotype-environment interaction meansget_model_data(means_ge)# Environment meansget_model_data(means_ge, what = "env_means")# Genotype meansget_model_data(means_ge, what = "gen_means")Graphical analysis of genotype-vs-environment interaction
Description
This function produces a line plot for a graphical interpretation of thegenotype-vs-environment interaction. By default, environments are in the xaxis whereas the genotypes are depicted by different lines. The y axiscontains the value of the selected variable. A heatmap can also be created.
Usage
ge_plot( .data, env, gen, resp, type = 1, values = TRUE, text_col_pos = c("top", "bottom"), text_row_pos = c("left", "right"), average = TRUE, row_col = TRUE, row_col_type = c("average", "sum"), order_g = NULL, order_e = NULL, xlab = NULL, ylab = NULL, width_bar = 1.5, heigth_bar = 15, plot_theme = theme_metan(), colour = TRUE)Arguments
.data | The dataset containing the columns related to Environments,Genotypes, replication/block and response variable(s). |
env | The name of the column that contains the levels of theenvironments |
gen | The name of the column that contains the levels of the genotypes. |
resp | The response variable. |
type | The type of plot |
values | Show the values in the plot? Defaults to |
text_row_pos,text_col_pos | The position of the text in therows and columns. The defaults show the text at left and top. |
average | Show the average values for environments and genotypes?Defaults to |
row_col,row_col_type | Shows row/column and defines what to show.Defaults to 'average'. |
order_g,order_e | A charactere vector indicating the order of the levelsfor genotypes and environments, respectively. This can be used to changethe default ordering of rows and columns. |
xlab,ylab | The labels for x and y axis, respectively. |
width_bar,heigth_bar | The width and heigth of the legend bar,respectively. |
plot_theme | The graphical theme of the plot. Default is |
colour | Logical argument. If |
Value
An object of classgg, ggplot.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)ge_plot(data_ge2, ENV, GEN, PH)ge_plot(data_ge, ENV, GEN, GY, type = 2)Power Law Residuals as yield stability index
Description
Performs a stability analysis based on the Power Law Residuals (POLAR)statistics (Doring et al., 2015). POLAR is the residuals from the linearregression of \(log(\sigma^2\)) against \(log(\mu\)) and can beused as a measure of crop stability with lower stability (relative to allsamples with that mean yield) indicated by more positive POLAR values, andhigher stability (relative to all samples with that mean yield) indicated bymore negative POLAR values.
Usage
ge_polar(.data, env, gen, resp, base = 10, verbose = TRUE)Arguments
.data | The dataset containing the columns related to Environments,Genotypes and response variable(s). |
env | The name of the column that contains the levels of theenvironments. |
gen | The name of the column that contains the levels of the genotypes. |
resp | The response variable(s). To analyze multiple variables in asingle procedure use, for example, |
base | The base with respect to which logarithms are computed. Defaultsto |
verbose | Logical argument. If |
Value
An object of classge_acv, which is a list containing theresults for each variable used in the argumentresp. For eachvariable, a tibble with the following columns is returned.
GEN the genotype's code.
POLAR The Power Law Residuals
POLAR_R The rank for the ACV value.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Doring, T.F., S. Knapp, and J.E. Cohen. 2015. Taylor's power lawand the stability of crop yields. F. Crop. Res. 183: 294-302.doi:10.1016/j.fcr.2015.08.005
Examples
library(metan)out <- ge_polar(data_ge2, ENV, GEN, c(EH, PH, EL, CD, ED, NKE))gmd(out)Eberhart and Russell's regression model
Description
Regression-based stability analysis using the Eberhart and Russell (1966) model.
Usage
ge_reg(.data, env, gen, rep, resp, verbose = TRUE)Arguments
.data | The dataset containing the columns related to Environments, Genotypes,replication/block and response variable(s) |
env | The name of the column that contains the levels of theenvironments. |
gen | The name of the column that contains the levels of the genotypes. |
rep | The name of the column that contains the levels of thereplications/blocks |
resp | The response variable(s). To analyze multiple variables in asingle procedure use, for example, |
verbose | Logical argument. If |
Value
An object of classge_reg with the folloing items for eachvariable:
data: The data with means for genotype and environment combinations and theenvironment index
anova: The analysis of variance for the regression model.
regression: A data frame with the following columns:
GEN, the genotypes;b0andb1the intercept and slope of the regression, respectively;t(b1=1)the calculated t-value;pval_tthe p-value for the t test;s2dithe deviations from the regression (stability parameter);F(s2di=0)theF-test for the deviations;pval_fthe p-value for the F test;RMSEtheroot-mean-square error;R2the determination coefficient of the regression.b0_variance: The variance of b0.
b1_variance: The variance of b1.
Author(s)
Tiago Olivoto,tiagoolivoto@gmail.com
References
Eberhart, S.A., and W.A. Russell. 1966. Stability parameters for comparing Varieties.Crop Sci. 6:36-40.doi:10.2135/cropsci1966.0011183X000600010011x
See Also
superiority(),ecovalence(),ge_stats()
Examples
library(metan)reg <- ge_reg(data_ge2, env = ENV, gen = GEN, rep = REP, resp = PH)plot(reg)Parametric and non-parametric stability statistics
Description
ge_stats() computes parametric and non-parametric stability statisticsgiven a data set with environment, genotype, and block factors.
Usage
ge_stats(.data, env, gen, rep, resp, verbose = TRUE, prob = 0.05)Arguments
.data | The dataset containing the columns related to Environments,Genotypes, replication/block and response variable(s). |
env | The name of the column that contains the levels of theenvironments. |
gen | The name of the column that contains the levels of the genotypes. |
rep | The name of the column that contains the levels of thereplications/blocks. |
resp | The response variable(s). To analyze multiple variables in asingle procedure use, for example, |
verbose | Logical argument. If |
prob | The probability error assumed. |
Details
The function computes the statistics and ranks for the followingstability indexes.
"Y"(Response variable),"CV"(coefficient of variation)"ACV"(adjusted coefficient of variation callingge_acv()internally)POLAR(Power Law Residuals, callingge_polar()internally)"Var"(Genotype's variance)"Shukla"(Shukla's variance, callingShukla()internally)"Wi_g", "Wi_f", "Wi_u"(Annichiarrico's genotypicconfidence index for all, favorable and unfavorable environments,respectively, callingAnnicchiarico()internally )"Ecoval"(Wricke's ecovalence,ecovalence()internally)"Sij"(Deviations from the joint-regression analysis) and"R2"(R-squared from the joint-regression analysis, callingge_reg()internally)"ASTAB"(AMMI Based Stability Parameter),"ASI"(AMMI StabilityIndex),"ASV"(AMMI-stability value),"AVAMGE"(Sum Across Environmentsof Absolute Value of GEI Modelled by AMMI ),"Da"(Annicchiarico's DParameter values),"Dz"(Zhang's D Parameter),"EV"(Sums of theAverages of the Squared Eigenvector Values),"FA"(Stability MeasureBased on Fitted AMMI Model),"MASV"(Modified AMMI Stability Value),"SIPC"(Sums of the Absolute Value of the IPC Scores),"Za"(AbsoluteValue of the Relative Contribution of IPCs to the Interaction),"WAAS"(Weighted average of absolute scores), callingammi_indexes()internally"HMGV"(Harmonic mean of the genotypic value),"RPGV"(Relativeperformance of the genotypic values),"HMRPGV"(Harmonic mean of therelative performance of the genotypic values), by callingblup_indexes()internally"Pi_a", "Pi_f", "Pi_u"(Superiority indexes for all, favorable andunfavorable environments, respectively, callingsuperiority()internally)"Gai"(Geometric adaptability index, callinggai()internally)"S1"(mean of the absolute rank differences of a genotype over the nenvironments),"S2"(variance among the ranks over the k environments),"S3"(sum of the absolute deviations),"S6"(relative sum of squares ofrank for each genotype), by callingHuehn()internally"N1","N2","N3","N4"(Thennarasu"s statistics, callingThennarasu()internally ).
Value
An object of classge_stats which is a list with one dataframe for each variable containing the computed indexes.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Annicchiarico, P. 1992. Cultivar adaptation and recommendation from alfalfatrials in Northern Italy. Journal of Genetic & Breeding, 46:269-278
Ajay BC, Aravind J, Abdul Fiyaz R, Bera SK, Kumar N, Gangadhar K, Kona P(2018). “Modified AMMI Stability Index (MASI) for stability analysis.”ICAR-DGR Newsletter, 18, 4–5.
Ajay BC, Aravind J, Fiyaz RA, Kumar N, Lal C, Gangadhar K, Kona P, Dagla MC,Bera SK (2019). “Rectification of modified AMMI stability value (MASV).”Indian Journal of Genetics and Plant Breeding (The), 79, 726–731.https://www.isgpb.org/article/rectification-of-modified-ammi-stability-value-masv.
Annicchiarico P (1997). “Joint regression vs AMMI analysis ofgenotype-environment interactions for cereals in Italy.” Euphytica, 94(1),53–62.doi:10.1023/A:1002954824178
Doring, T.F., and M. Reckling. 2018. Detecting global trends ofcereal yield stability by adjusting the coefficient of variation. Eur. J.Agron. 99: 30-36.doi:10.1016/j.eja.2018.06.007
Doring, T.F., S. Knapp, and J.E. Cohen. 2015. Taylor's power law and thestability of crop yields. F. Crop. Res. 183: 294-302.doi:10.1016/j.fcr.2015.08.005
Eberhart, S.A., and W.A. Russell. 1966. Stability parameters forcomparing Varieties. Crop Sci. 6:36-40.doi:10.2135/cropsci1966.0011183X000600010011x
Farshadfar E (2008) Incorporation of AMMI stability value and grain yield ina single non-parametric index (GSI) in bread wheat. Pakistan J Biol Sci11:1791–1796.doi:10.3923/pjbs.2008.1791.1796
Fox, P.N., B. Skovmand, B.K. Thompson, H.J. Braun, and R.Cormier. 1990. Yield and adaptation of hexaploid spring triticale.Euphytica 47:57-64.doi:10.1007/BF00040364.
Huehn, V.M. 1979. Beitrage zur erfassung der phanotypischenstabilitat. EDV Med. Biol. 10:112.
Jambhulkar NN, Rath NC, Bose LK, Subudhi HN, Biswajit M, Lipi D, Meher J(2017). “Stability analysis for grain yield in rice in demonstrationsconducted during rabi season in India.” Oryza, 54(2), 236–240.doi:10.5958/2249-5266.2017.00030.3
Kang, M.S., and H.N. Pham. 1991. Simultaneous Selection for HighYielding and Stable Crop Genotypes. Agron. J. 83:161.doi:10.2134/agronj1991.00021962008300010037x
Lin, C.S., and M.R. Binns. 1988. A superiority measure of cultivarperformance for cultivar x location data. Can. J. Plant Sci. 68:193-198.doi:10.4141/cjps88-018
Olivoto, T., A.D.C. Lúcio, J.A.G. da silva, V.S. Marchioro, V.Q. deSouza, and E. Jost. 2019a. Mean performance and stability inmulti-environment trials I: Combining features of AMMI and BLUP techniques.Agron. J. 111:2949-2960.doi:10.2134/agronj2019.03.0220
Mohammadi, R., & Amri, A. (2008). Comparison of parametric and non-parametricmethods for selecting stable and adapted durum wheat genotypes in variableenvironments. Euphytica, 159(3), 419-432.doi:10.1007/s10681-007-9600-6
Shukla, G.K. 1972. Some statistical aspects of partitioninggenotype-environmental components of variability. Heredity. 29:238-245.doi:10.1038/hdy.1972.87
Raju BMK (2002). “A study on AMMI model and its biplots.” Journal of theIndian Society of Agricultural Statistics, 55(3), 297–322.
Rao AR, Prabhakaran VT (2005). “Use of AMMI in simultaneous selection ofgenotypes for yield and stability.” Journal of the Indian Society ofAgricultural Statistics, 59, 76–82.
Sneller CH, Kilgore-Norquest L, Dombek D (1997). “Repeatability of yieldstability statistics in soybean.” Crop Science, 37(2), 383–390.doi:10.2135/cropsci1997.0011183X003700020013x
Thennarasu, K. 1995. On certain nonparametric procedures forstudying genotype x environment interactions and yield stability. Ph.D.thesis. P.J. School, IARI, New Delhi, India.
Wricke, G. 1965. Zur berechnung der okovalenz bei sommerweizen und hafer.Z. Pflanzenzuchtg 52:127-138.
See Also
acv(),ammi_indexes(),ecovalence(),Fox(),gai(),ge_reg(),hmgv(),hmrpgv(),rpgv(),Huehn(),ge_polar(),Shukla(),superiority(),Thennarasu(),waas(),waasb()
Examples
library(metan)model <- ge_stats(data_ge, ENV, GEN, REP, GY)get_model_data(model, "stats")Genotype-environment winners
Description
Computes the ranking for genotypes within environments and return the winners.
Usage
ge_winners(.data, env, gen, resp, type = "winners", better = NULL)Arguments
.data | The dataset containing the columns related to Environments,Genotypes, and the response variable(s). |
env | The name of the column that contains the levels of theenvironments. |
gen | The name of the column that contains the levels of the genotypes. |
resp | The response variable(s). To analyze multiple variables in asingle procedure a vector of variables may be used. For example |
type | The type of results. Defaults to |
better | A vector of the same length of the number of variables to rankthe genotypes according to the response variable. Each element of thevector must be one of the |
Value
A tibble with two-way table with the winner genotype in eachenvironment (default) or the genotype ranking for each environment (iftype = "ranks").
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)ge_winners(data_ge, ENV, GEN, resp = everything())# Assuming that for 'GY' lower values are better.ge_winners(data_ge, ENV, GEN, resp = everything(), better = c("l, h"))# Show the genotype ranking for each environmentge_winners(data_ge, ENV, GEN, resp = everything(), type = "ranks")Generate normal, correlated variables
Description
Given the mean and desired correlations, generate normal, correlatedvariables.
Usage
get_corvars(n = 10, mu, sigma, tol = 1e-06, seed = NULL)Arguments
n | The number of samples required. |
mu | A vector with the means for the variables. |
sigma | A symmetric, positive-definite matrix with the (co)variance orcorrelation matrix of the variables. |
tol | Tolerance (relative to largest variance) for numerical lack ofpositive-definiteness in sigma. |
seed | An integer value interpreted as seed. |
Value
A tibble containing the simulated data.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
sigma <- matrix(c(1, .3, 0, .3, 1, .9, 0, .9, 1),3,3)mu <- c(6,50,5)df <- get_corvars(n = 10000, mu = mu, sigma = sigma, seed = 101010)mean_by(df)cor(df)Generate a covariance matrix
Description
Given the variances and desired correlations, generate a covariance matrix
Usage
get_covmat(cormat, var)Arguments
cormat | A symmetric matrix with desired correlations. |
var | A numeric vector with variances. It must have length equal to thenumber of elements in the diagonal of |
Value
A (co)variance matrix
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
cormat <-matrix(c(1, 0.9, -0.4, 0.9, 1, 0.6, -0.4, 0.6, 1), nrow = 3, ncol = 3)get_covmat(cormat, var = c(16, 25, 9))Get a distance matrix
Description
Get the distance matrices from objects fitted with the functionclustering(). This is especially useful to get distance matricesfrom several objects to be further analyzed usingpairs_mantel().
Usage
get_dist(..., digits = 2)Arguments
... | Object(s) of class |
digits | The number of significant figures. Defaults to |
Value
A list of classclustering.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)d <- data_ge2 %>% mean_by(GEN) %>% column_to_rownames("GEN") %>% clustering()get_dist(d)Get data from a model easily
Description
Usage
get_model_data(x, what = NULL, type = "GEN", verbose = TRUE)gmd(x, what = NULL, type = "GEN", verbose = TRUE)sel_gen(x)Arguments
x | An object created with the functions |
what | What should be captured from the model. See more in sectionDetails. |
type | Chose if the statistics must be show by genotype ( |
verbose | Logical argument. If |
Details
get_model_data()Easily get data from some objects generated in themetan package such as the WAASB and WAASBY indexes (Olivoto et al.,2019a, 2019b) BLUPs, variance components, details of AMMI models andAMMI-based stability statistics.gmd()Is a shortcut toget_model_data.sel_gen()Extracts the selected genotypes by a given index.
Bellow are listed the options allowed in the argumentwhat dependingon the class of the object
Objects of classammi_indexes:
"ASV"AMMI stability value."EV"Averages of the squared eigenvector values."SIPC"Sums of the absolute value of the IPCA scores."WAAS"Weighted average of absolute scores (default)."ZA"Absolute value of the relative contribution of IPCAs to theinteraction.
Objects of classanova_ind:
"MEAN"The mean value of the variable"DFG", "DFB", "DFCR", "DFIB_R", "DFE". The degree of freedom forgenotypes, blocks (randomized complete block design), complete replicates,incomplete blocks within replicates (alpha-lattice design), and error,respectively."MSG", "FCG", "PFG"The mean square, F-calculated and P-values forgenotype effect, respectively."MSB", "FCB", "PFB"The mean square, F-calculated and P-values forblock effect in randomized complete block design."MSCR", "FCR", "PFCR"The mean square, F-calculated and P-values forcomplete replicates in alpha lattice design."MSIB_R", "FCIB_R", "PFIB_R"The mean square, F-calculated andP-values for incomplete blocks within complete replicates, respectively (foralpha lattice design only)."MSE"The mean square of error."CV"The coefficient of variation."h2"The broad-sence heritability"AS"The accucary of selection (square root of h2)."FMAX"The Hartley's test (the ratio of the largest MSE to the smallestMSE).
Objects of classanova_joint orgafem:
"Y"The observed values."h2"The broad-sense heritability."Sum Sq"Sum of squares."Mean Sq"Mean Squares."F value"F-values."Pr(>F)"P-values.".fitted"Fitted values (default).".resid"Residuals.".stdresid"Standardized residuals.".se.fit"Standard errors of the fitted values."details"Details.
Objects of classAnnicchiarico andSchmildt:
"Sem_rp"The standard error of the relative mean performance (Schmildt)."Mean_rp"The relative performance of the mean."rank"The rank for genotypic confidence index."Wi"The genotypic confidence index.
Objects of classcan_corr:
"coefs"The canonical coefficients (default)."loads"The canonical loadings."crossloads"The canonical cross-loadings."canonical"The canonical correlations and hypothesis testing.
Objects of classcolindiag:
"cormat"The correlation matrix betwen predictors."corlist"The correlations in a 'long' format"evalevet"The eigenvalue with associated eigenvectors"VIF"The Variance Inflation Factor"indicators"The colinearity indicators
Objects of classecovalence:
"Ecoval"Ecovalence value (default)."Ecov_perc"Ecovalence in percentage value."rank"Rank for ecovalence.
Objects of classfai_blup: See theValue section offai_blup() to see valid options forwhat argument.
Objects of classge_acv:
"ACV"The adjusted coefficient of variation (default)."ACV_R"The rank for adjusted coefficient of variation.
Objects of classge_polar:
"POLAR"The Power Law Residuals (default)."POLAR_R"The rank for Power Law Residuals.
Objects of classge_reg:
GEN: the genotypes.b0andb1(default): the intercept and slope of the regression,respectively.t(b1=1): the calculated t-valuepval_t: the p-value for the t test.s2dithe deviations from the regression (stability parameter).F(s2di=0): the F-test for the deviations.pval_f: the p-value for the F test;RMSEthe root-mean-square error.R2the determination coefficient of the regression.
Objects of classge_effects:
For objects of class
ge_effectsno argumentwhatis required.
Objects of classge_means:
"ge_means"Genotype-environment interaction means (default)."env_means"Environment means."gen_means"Genotype means.
Objects of classgge:
"scores"The scores for genotypes and environments for all theanalyzed traits (default)."exp_var"The eigenvalues and explained variance."projection"The projection of each genotype in the AEC coordinates inthe stability GGE plot
Objects of classgytb:
"gyt"Genotype by yield*trait table (Default)."stand_gyt"The standardized (zero mean and unit variance) Genotype by yield*trait table."si"The superiority index (sum standardized value across all yield*trait combinations).
Objects of classmgidi: See theValue section ofmgidi() to see valid options forwhat argument.
Objects of classmtsi: See theValue section ofmtsi() to see valid options forwhat argument.
**Objects of classpath_coeff
"coef"Path coefficients"eigenval"Eigenvalues and eigenvectors."vif "Variance Inflation Factor
**Objects of classpath_coeff_seq
"resp_fc"Coefficients of primary predictors and response"resp_sc"Coefficients of secondary predictors and response"resp_sc2"contribution to the total effects through primary traits"fc_sc_coef"Coefficients of secondary predictors and primary predictors.
Objects of classShukla:
"rMean"Rank for the mean."ShuklaVar"Shukla's stablity variance (default)."rShukaVar"Rank for Shukla's stablity variance."ssiShukaVar"Simultaneous selection index.
Objects of classsh: See theValue section ofSmith_Hazel() to see valid options forwhat argument.
Objects of classFox:
"TOP"The proportion of locations at which the genotype occurred inthe top third (default).
Objects of classgai:
"GAI"The geometric adaptability index (default)."GAI_R"The rank for the GAI values.
Objects of classsuperiority:
"Pi_a"The superiority measure for all environments (default)."R_a"The rank for Pi_a."Pi_f"The superiority measure for favorable environments."R_f"The rank for Pi_f."Pi_u"The superiority measure for unfavorable environments."R_u"The rank for Pi_u.
Objects of classHuehn:
"S1"Mean of the absolute rank differences of a genotype over the nenvironments (default)."S2"variance among the ranks over the k environments."S3"Sum of the absolute deviations."S6"Relative sum of squares of rank for each genotype."S1_R","S2_R","S3_R", and"S6_R", the ranksfor S1, S2, S3, and S6, respectively.
Objects of classThennarasu:
"N1"First statistic (default)."N2"Second statistic."N3"Third statistic."N4"Fourth statistic."N1_R","N2_R","N3_R", and"N4_R", The ranksfor the statistics.
Objects of classperforms_ammi:
"PC1", "PC2", ..., "PCn"The values for the nth interactionprincipal component axis."ipca_ss"Sum of square for each IPCA."ipca_ms"Mean square for each IPCA."ipca_fval"F value for each IPCA."ipca_pval"P-value for for each IPCA."ipca_expl"Explained sum of square for each IPCA (default)."ipca_accum"Accumulated explained sum of square.
Objects of classwaas,waas_means, andwaasb:
"PC1", "PC2", ..., "PCn"The values for the nth interactionprincipal component axis."WAASB"The weighted average of the absolute scores (default forobjects of classwaas)."PctResp"The rescaled values of the response variable."PctWAASB"The rescaled values of the WAASB."wResp"The weight for the response variable."wWAASB"The weight for the stability."OrResp"The ranking regarding the response variable."OrWAASB"The ranking regarding the WAASB."OrPC1"The ranking regarding the first principal component axix."WAASBY"The superiority index WAASBY."OrWAASBY"The ranking regarding the superiority index.
Objects of classgamem andwaasb:
"blupge"Best Linear Unbiased Prediction for genotype-environmentinteraction (mixed-effect model, classwaasb)."blupg"Best Linear Unbiased Prediction for genotype effect."bluege"Best Linear Unbiased Estimation for genotype-environmentinteraction (fixed-effect model, classwaasb)."blueg"Best Linear Unbiased Estimation for genotype effect (fixedmodel)."data"The data used."details"The details of the trial."genpar"Genetic parameters (default)."gcov"The genotypic variance-covariance matrix."pcov"The phenotypic variance-covariance matrix."gcor"The genotypic correlation matrix."pcor"The phenotypic correlation matrix."h2"The broad-sense heritability."lrt"The likelihood-ratio test for random effects."vcomp"The variance components for random effects."ranef"Random effects.
Objects of classblup_ind
"HMGV","HMGV_R"For harmonic mean of genotypic values or its ranks."RPGV", RPGV_Y"For relative performance of genotypic values or itsranks."HMRPGV", "HMRPGV_R"For harmonic mean of relative performance ofgenotypic values or its ranks."WAASB", "WAASB_R"For the weighted average of absolute scores from thesingular or its ranks. value decomposition of the BLUPs for GxE interactionor its ranks.
Value
A tibble showing the values of the variable chosen in argumentwhat.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Annicchiarico, P. 1992. Cultivar adaptation and recommendation from alfalfatrials in Northern Italy. J. Genet. Breed. 46:269-278.
Dias, P.C., A. Xavier, M.D.V. de Resende, M.H.P. Barbosa, F.A. Biernaski,R.A. Estopa. 2018. Genetic evaluation of Pinus taeda clones from somaticembryogenesis and their genotype x environment interaction. Crop Breed. Appl.Biotechnol. 18:55-64.doi:10.1590/1984-70332018v18n1a8
Azevedo Peixoto, L. de, P.E. Teodoro, L.A. Silva, E.V. Rodrigues, B.G.Laviola, and L.L. Bhering. 2018. Jatropha half-sib family selection with highadaptability and genotypic stability. PLoS One 13:e0199880.doi:10.1371/journal.pone.0199880
Eberhart, S.A., and W.A. Russell. 1966. Stability parameters for comparingVarieties. Crop Sci. 6:36-40.doi:10.2135/cropsci1966.0011183X000600010011x
Fox, P.N., B. Skovmand, B.K. Thompson, H.J. Braun, and R. Cormier. 1990.Yield and adaptation of hexaploid spring triticale. Euphytica 47:57-64.doi:10.1007/BF00040364
Huehn, V.M. 1979. Beitrage zur erfassung der phanotypischen stabilitat. EDVMed. Biol. 10:112.
Olivoto, T., A.D.C. Lúcio, J.A.G. da silva, V.S. Marchioro, V.Q. deSouza, and E. Jost. 2019a. Mean performance and stability inmulti-environment trials I: Combining features of AMMI and BLUP techniques.Agron. J. 111:2949-2960.doi:10.2134/agronj2019.03.0220
Olivoto, T., A.D.C. Lúcio, J.A.G. da silva, B.G. Sari, and M.I. Diel.2019b. Mean performance and stability in multi-environment trials II:Selection based on multiple traits. Agron. J. 111:2961-2969.doi:10.2134/agronj2019.03.0221
Purchase, J.L., H. Hatting, and C.S. van Deventer. 2000.Genotype vs environment interaction of winter wheat (Triticum aestivum L.)in South Africa: II. Stability analysis of yield performance. South AfricanJ. Plant Soil 17:101-107.doi:10.1080/02571862.2000.10634878
Resende MDV (2007) Matematica e estatistica na analise de experimentos e nomelhoramento genetico. Embrapa Florestas, Colombo
Sneller, C.H., L. Kilgore-Norquest, and D. Dombek. 1997. Repeatability ofYield Stability Statistics in Soybean. Crop Sci. 37:383-390.doi:10.2135/cropsci1997.0011183X003700020013x
Mohammadi, R., & Amri, A. (2008). Comparison of parametric and non-parametricmethods for selecting stable and adapted durum wheat genotypes in variableenvironments. Euphytica, 159(3), 419-432.doi:10.1007/s10681-007-9600-6
Wricke, G. 1965. Zur berechnung der okovalenz bei sommerweizen und hafer. Z.Pflanzenzuchtg 52:127-138.
Zali, H., E. Farshadfar, S.H. Sabaghpour, and R. Karimizadeh. 2012.Evaluation of genotype vs environment interaction in chickpea using measuresof stability from AMMI model. Ann. Biol. Res. 3:3126-3136.
See Also
ammi_indexes(),anova_ind(),anova_joint(),ecovalence(),Fox(),gai(),gamem(),gafem(),ge_acv(),ge_polar()ge_means(),ge_reg(),mgidi(),mtsi(),mps(),mtmps(),performs_ammi(),blup_indexes(),Shukla(),superiority(),waas(),waasb()
Examples
library(metan)#################### WAASB index ###################### Fitting the WAAS indexAMMI <- waasb(data_ge2, env = ENV, gen = GEN, rep = REP, resp = c(PH, ED, TKW, NKR))# Getting the weighted average of absolute scoresgmd(AMMI, what = "WAASB")#################### BLUP model ###################### Fitting a mixed-effect model# Genotype and interaction as randomblup <- gamem_met(data_ge2, env = ENV, gen = GEN, rep = REP, resp = c(PH, ED))# Getting p-values for likelihood-ratio testgmd(blup, what = "lrt")# Getting the variance componentsgmd(blup, what = "vcomp")Genotype plus genotype-by-environment model
Description
Produces genotype plus genotype-by-environment model based on a multi-environmenttrial dataset containing at least the columns for genotypes, environments and oneresponse variable or a two-way table.
Usage
gge( .data, env, gen, resp, centering = "environment", scaling = "none", svp = "environment", by = NULL, ...)Arguments
.data | The dataset containing the columns related to Environments, Genotypesand the response variable(s). |
env | The name of the column that contains the levels of the environments. |
gen | The name of the column that contains the levels of the genotypes. |
resp | The response variable(s). To analyze multiple variables in asingle procedure a vector of variables may be used. For example |
centering | The centering method. Must be one of the |
scaling | The scaling method. Must be one of the |
svp | The method for singular value partitioning. Must be one of the |
by | One variable (factor) to compute the function by. It is a shortcutto |
... | Arguments passed to the function |
Value
The function returns a list of classgge containing the following objects
coordgen The coordinates for genotypes for all components.
coordenv The coordinates for environments for all components.
eigenvalues The vector of eigenvalues.
totalvar The overall variance.
labelgen The name of the genotypes.
labelenv The names of the environments.
labelaxes The axes labels.
ge_mat The data used to produce the model (scaled and centered).
centering The centering method.
scaling The scaling method.
svp The singular value partitioning method.
d The factor used to generate in which the ranges of genotypes and environmentsare comparable when singular value partitioning is set to 'genotype' or 'environment'.
grand_mean The grand mean of the trial.
mean_gen A vector with the means of the genotypes.
mean_env A vector with the means of the environments.
scale_var The scaling vector when the scaling method is
'sd'.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Yan, W., and M.S. Kang. 2003. GGE biplot analysis: a graphical tool for breeders,geneticists, and agronomists. CRC Press.
Examples
library(metan)mod <- gge(data_ge, ENV, GEN, GY)plot(mod)# GGE model for all numeric variablesmod2 <- gge(data_ge2, ENV, GEN, resp = everything())plot(mod2, var = "ED")# If we have a two-way table with the mean values for# genotypes and environmentstable <- make_mat(data_ge, GEN, ENV, GY) %>% round(2)tablemake_long(table) %>%gge(ENV, GEN, Y) %>%plot()Genotype by trait biplot
Description
Produces a genotype-by-trait biplot model. From a genotype by environment bytrait three-way table, genotype-by-trait tables in any single environment,across all environments, or across a subset of the environments can begenerated and visually studied using biplots. The model for biplot analysisof genotype by trait data is the singular value decomposition oftrait-standardized two-way table.
Usage
gtb(.data, gen, resp, centering = "trait", scaling = "sd", svp = "trait")Arguments
.data | The dataset containing the columns related to Genotypes and theresponse variable(s). |
gen | The name of the column that contains the levels of the genotypes. |
resp | The response variables, i.e., |
centering | The centering method. Must be one of the |
scaling | The scaling method. Must be one of the |
svp | The method for singular value partitioning. Must be one of the |
Value
The function returns a list of classgge that is compatible with the functionplot() used ingge().
coordgen The coordinates for genotypes for all components.
coordenv The coordinates for traits for all components.
eigenvalues The vector of eigenvalues.
totalvar The overall variance.
labelgen The name of the genotypes.
labelenv The names of the traits.
labelaxes The axes labels.
gt_mat The data used to produce the model (scaled and centered).
centering The centering method.
scaling The scaling method.
svp The singular value partitioning method.
d The factor used to generate in which the ranges of genotypesand traits are comparable when singular value partitioning is set to'genotype' or 'trait'.
grand_mean The grand mean of the trial.
mean_gen A vector with the means of the genotypes.
mean_env A vector with the means of the traits.
scale_var The scaling vector when the scaling method is
'sd'.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Yan, W., and M.S. Kang. 2003. GGE biplot analysis: a graphical tool for breeders,geneticists, and agronomists. CRC Press.
Examples
library(metan)# GT biplot for all numeric variablesmod <- gtb(data_ge2, GEN, resp = contains("E"))plot(mod)Genotype by yield*trait biplot
Description
Produces a Genotype by Yield*Trait biplot (GTY) proposed by Yan andFregeau-Reid (2018).
Usage
gytb( .data, gen, yield, traits = everything(), ideotype = NULL, weight = NULL, prefix = "Y", centering = "trait", scaling = "sd", svp = "trait")Arguments
.data | The dataset containing the columns related to Genotypes, Yield,and Traits. |
gen | The name of the column that contains the levels of the genotypes. |
yield | The column containing the yield values. |
traits | The column(s) with thetraits values. Defaults toNULL. In this case, all numeric traits in |
ideotype | A vector of |
weight | The weight assumed for each trait. Similar to |
prefix | The prefix used in the biplot for the yield*trait combinations.Defaults to |
centering | The centering method. Must be one of the |
scaling | The scaling method. Must be one of the |
svp | The method for singular value partitioning. Must be one of the |
Value
The function returns a list of classgge that is compatible with the functionplot() used ingge().
data The Genotype by yield\*trait (GYT) data.
ge_mat The Genotype by yield\*trait (GYT) data (scaled and centered).
coordgen The coordinates for genotypes for all components.
coordenv The coordinates for traits for all components.
eigenvalues The vector of eigenvalues.
totalvar The overall variance.
labelgen The name of the genotypes.
labelenv The names of the traits.
labelaxes The axes labels.
centering The centering method.
scaling The scaling method.
svp The singular value partitioning method.
d The factor used to generate in which the ranges of genotypesand traits are comparable when singular value partitioning is set to'genotype' or 'trait'.
grand_mean The grand mean of the trial.
mean_gen A vector with the means of the genotypes.
mean_env A vector with the means of the traits.
scale_var The scaling vector when the scaling method is
'sd'.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Yan, W., & Fregeau-Reid, J. (2018). Genotype by Yield\*Trait (GYT) Biplot: aNovel Approach for Genotype Selection based on Multiple Traits. ScientificReports, 8(1), 1-10.doi:10.1038/s41598-018-26688-8
Examples
library(metan)# GYT biplot for all numeric traits of 'data_g'# KW (kernel weight) considered as 'yield',mod <- gytb(data_g, GEN, KW)plot(mod)Missing value imputation
Description
Impute the missing entries of a matrix with missing values using differentalgorithms. SeeDetails section for more details
Usage
impute_missing_val( .data, naxis = 1, algorithm = "EM-SVD", tol = 1e-10, max_iter = 1000, simplified = FALSE, verbose = TRUE)Arguments
.data | A matrix to impute the missing entries. Frequently a two-waytable of genotype means in each environment. |
naxis | The rank of the Singular Value Approximation. Defaults to |
algorithm | The algorithm to impute missing values. Defaults to |
tol | The convergence tolerance for the algorithm. |
max_iter | The maximum number of steps to take. If |
simplified | Valid argument when |
verbose | Logical argument. If |
Details
EM-AMMI algorithm
TheEM-AMMI algorithm completes a data set with missing values according to bothmain and interaction effects. The algorithm works as follows (Gauch andZobel, 1990):
The initial values are calculated as the grand mean increased by maineffects of rows and main effects of columns. That way, the matrix ofobservations is pre-filled in.
The parameters of the AMMI model are estimated.
The adjusted means are calculated based on the AMMI model with
naxisprincipal components.The missing cells are filled with the adjusted means.
The root mean square error of the predicted values (
RMSE_p) iscalculated with the two lasts iteration steps. IfRMSE_p > tol, thesteps 2 through 5 are repeated. Declare convergence ifRMSE_p < tol.Ifmax_iteris achieved without convergence, the algorithm will stopwith a warning.
EM-SVD algorithm
TheEM-SVD algorithm impute the missing entries using a low-rank SingularValue Decomposition approximation estimated by the Expectation-Maximizationalgorithm. The algorithm works as follows (Troyanskaya et al., 2001).
Initialize all
NAvalues to the column means.Compute the first
naxisterms of the SVD of the completed matrixReplace the previously missing values with their approximations from the SVD
The root mean square error of the predicted values (
RMSE_p) iscalculated with the two lasts iteration steps. IfRMSE_p > tol, thesteps 2 through 3 are repeated. Declare convergence ifRMSE_p < tol.Ifmax_iteris achieved without convergence, the algorithm will stopwith a warning.
colmeans algorithm
Thecolmeans algorithm simply impute the missing entires using thecolumn mean of the respective entire. Thus, there is no iteractive process.
Value
An object of classimv with the following values:
.data The imputed matrix
pc_ss The sum of squares representing variation explained by theprincipal components
iter The final number of iterations.
Final_RMSE The maximum change of the estimated values for missing cells in the last step of iteration.
final_axis The final number of principal component axis.
convergence Logical value indicating whether the modern converged.
References
Gauch, H. G., & Zobel, R. W. (1990). Imputing missing yield trial data.Theoretical and Applied Genetics, 79(6), 753-761.doi:10.1007/BF00224240
Troyanskaya, O., Cantor, M., Sherlock, G., Brown, P., Hastie, T., Tibshirani,R., . Altman, R. B. (2001). Missing value estimation methods for DNAmicroarrays. Bioinformatics, 17(6), 520-525.
Examples
library(metan)mat <- (1:20) %*% t(1:10)mat# 10% of missing values at randommiss_mat <- random_na(mat, prop = 10)miss_matmod <- impute_missing_val(miss_mat)mod$.dataCheck for common errors in multi-environment trial data
Description
inspect() scans adata.frame object for errors that may affect the useof functions inmetan. By default, all variables are checked regardingthe class (numeric or factor), missing values, and presence of possibleoutliers. The function will return a warning if the data looks likeunbalanced, has missing values or possible outliers.
Usage
inspect(.data, ..., plot = FALSE, threshold = 15, verbose = TRUE)Arguments
.data | The data to be analyzed |
... | The variables in |
plot | Create a plot to show the check? Defaults to |
threshold | Maximum number of levels allowed in a character / factorcolumn to produce a plot. Defaults to 15. |
verbose | Logical argument. If |
Value
A tibble with the following variables:
Variable The name of variable
Class The class of the variable
Missing Contains missing values?
Levels The number of levels of a factor variable
Valid_n Number of valid n (omit NAs)
Outlier Contains possible outliers?
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)inspect(data_ge)# Create a toy example with messy datadf <- data_ge2[-c(2, 30, 45, 134), c(1:5)] %>% as.data.frame()df[c(1, 20, 50), 5] <- NAdf[40, 4] <- "2..814"inspect(df)Data for examples
Description
Data for examples
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Coerce to an object of class lpcor
Description
Functions to check if an object is of classlpcor
Usage
is.lpcor(x)Arguments
x | An object to check. |
Value
A logical valueTRUE orFALSE.
Examples
library(metan)library(dplyr)mt_num <- mtcars %>% select_if(., is.numeric)lpdata <- as.lpcor(cor(mt_num[1:5]), cor(mt_num[1:5]), cor(mt_num[2:6]), cor(mt_num[4:8]))is.lpcor(lpdata)Check if a data set is balanced
Description
Check if a data set coming from multi-environment trials is balanced, i.e.,all genotypes are in all environments.
Usage
is_balanced_trial(.data, env, gen, resp)Arguments
.data | The dataset containing the columns related to Environments,Genotypes, replication/block and response variable(s). |
env | The name of the column that contains the levels of theenvironments. |
gen | The name of the column that contains the levels of the genotypes. |
resp | The response variable. |
Value
A logical value
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
unb <- data_ge %>% remove_rows(1:3) %>% droplevels()is_balanced_trial(data_ge, ENV, GEN, GY)is_balanced_trial(unb, ENV, GEN, GY)Fast way to create line plots
Description
plot_lines()Creates a line plot based on one quantitative factorand one numeric variable. It can be used to show the results of a one-waytrial withquantitative treatments.plot_factlines()Creates a line plot based on: one categorical and one quantitative factor andone numeric variable. It can be used to show the results of atwo-way trial withqualitative-quantitative treatment structure.
Usage
plot_lines( .data, x, y, fit, level = 0.95, confidence = TRUE, xlab = NULL, ylab = NULL, n.dodge = 1, check.overlap = FALSE, col = "red", alpha = 0.2, size.shape = 1.5, size.line = 1, size.text = 12, fontfam = "sans", plot_theme = theme_metan())plot_factlines( .data, x, y, group, fit, level = 0.95, confidence = TRUE, xlab = NULL, ylab = NULL, n.dodge = 1, check.overlap = FALSE, legend.position = "bottom", grid = FALSE, scales = "free", col = TRUE, alpha = 0.2, size.shape = 1.5, size.line = 1, size.text = 12, fontfam = "sans", plot_theme = theme_metan())Arguments
.data | The data set |
x,y | The variables to be mapped to the |
fit | The polynomial degree to use. It must be between 1 (linear fit) to4 (fourth-order polynomial regression.). In |
level | The fonfidence level. Defaults to |
confidence | Display confidence interval around smooth? (TRUE bydefault) |
xlab,ylab | The labels of the axes x and y, respectively. Defaults to |
n.dodge | The number of rows that should be used to render the x labels.This is useful for displaying labels that would otherwise overlap. |
check.overlap | Silently remove overlapping labels, (recursively)prioritizing the first, last, and middle labels. |
col | The colour to be used in the line plot and points. |
alpha | The alpha for the color in confidence band |
size.shape | The size for the shape in plot |
size.line | The size for the line in the plot |
size.text | The size of the text |
fontfam | The family of the font text. |
plot_theme | The graphical theme of the plot. Default is |
group | The grouping variable. Valid for |
legend.position | Valid argument for |
grid | Valid argument for |
scales | Valid argument for |
Value
An object of classgg, ggplot.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
See Also
plot_bars() andplot_factbars()
Examples
library(metan)# One-way line plotdf1 <- data.frame(group = "A", x = c(0, 100, 200, 300, 400), y = c(3.2, 3.3, 4.0, 3.8, 3.4))plot_lines(df1, x, y, fit = 2)# Two-way line plotdf2 <- data.frame(group = "B", x = c(0, 100, 200, 300, 400), y = c(3.2, 3.3, 3.7, 3.9, 4.1))facts <- rbind(df1, df2)p1 <- plot_factlines(facts, x, y, group = group, fit = 1)p2 <- plot_factlines(facts, x = x, y = y, group = group, fit = c(2, 1), confidence = FALSE)arrange_ggplot(p1, p2)Linear and Partial Correlation Coefficients
Description
Estimates the linear and partial correlation coefficients using as input adata frame or a correlation matrix.
Usage
lpcor(.data, ..., by = NULL, n = NULL, method = "pearson")Arguments
.data | The data to be analyzed. It must be a symmetric correlationmatrix or a data frame, possible with grouped data passed from |
... | Variables to use in the correlation. If |
by | One variable (factor) to compute the function by. It is a shortcutto |
n | If a correlation matrix is provided, then |
method | a character string indicating which correlation coefficient isto be computed. One of 'pearson' (default), 'kendall', or 'spearman'. |
Value
If.data is a grouped data passed fromdplyr::group_by() then the results will be returned into alist-column of data frames, containing:
linear.mat The matrix of linear correlation.
partial.mat The matrix of partial correlations.
results Hypothesis testing for each pairwise comparison.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)partial1 <- lpcor(iris)# Alternatively using the pipe operator %>%partial2 <- iris %>% lpcor()# Using a correlation matrixpartial3 <- cor(iris[1:4]) %>% lpcor(n = nrow(iris))# Select all numeric variables and compute the partial correlation# For each level of Speciespartial4 <- lpcor(iris, by = Species)Mahalanobis Distance
Description
Compute the Mahalanobis distance of all pairwise rows in.means. Theresult is a symmetric matrix containing the distances that may be used forhierarchical clustering.
Usage
mahala(.means, covar, inverted = FALSE)Arguments
.means | A matrix of data with, say, p columns. |
covar | The covariance matrix. |
inverted | Logical argument. If |
Value
A symmetric matrix with the Mahalanobis' distance.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)library(dplyr)# Compute the mean for genotypesmeans <- mean_by(data_ge, GEN) %>% column_to_rownames("GEN")# Compute the covariance matrixcovmat <- cov(means)# Compute the distancedist <- mahala(means, covmat)# Dendrogramdend <- dist %>% as.dist() %>% hclust() %>% as.dendrogram()plot(dend)Mahalanobis distance from designed experiments
Description
Compute the Mahalanobis distance using data from an experiment conducted in arandomized complete block design or completely randomized design.
Usage
mahala_design( .data, gen, rep, resp, design = "RCBD", by = NULL, return = "distance")Arguments
.data | The dataset containing the columns related to Genotypes,replication/block and response variables, possible with grouped data passedfrom |
gen | The name of the column that contains the levels of the genotypes. |
rep | The name of the column that contains the levels of thereplications/blocks. |
resp | The response variables. For example |
design | The experimental design. Must be RCBD or CRD. |
by | One variable (factor) to compute the function by. It is a shortcutto |
return | What the function return? Default is 'distance', i.e., theMahalanobis distance. Alternatively, it is possible to return the matrix ofmeans |
Value
A symmetric matrix with the Mahalanobis' distance. If.data isa grouped data passed fromdplyr::group_by() then the resultswill be returned into a list-column of data frames.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)maha <- mahala_design(data_g, gen = GEN, rep = REP, resp = everything(), return = "covmat")# Compute one distance for each environment (all numeric variables)maha_group <- mahala_design(data_ge, gen = GEN, rep = REP, resp = everything(), by = ENV)# Return the variance-covariance matrix of residualscov_mat <- mahala_design(data_ge, gen = GEN, rep = REP, resp = c(GY, HM), return = 'covmat')Two-way table to a 'long' format
Description
Helps users to easily convert a two-way table (genotype vs environment) to a'long' format data. The data inmat will be gathered into threecolumns. The row names will compose the first column. The column names willcompose the second column and the third column will contain the data thatfills the two-way table.
Usage
make_long(mat, gen_in = "rows")Arguments
mat | A two-way table. It must be a matrix or a data.frame withrownames. |
gen_in | Where are the genotypes? Defaults to |
Value
A tibble with three columns: GEN (genotype), ENV (environment), and Y(response) variable.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)set.seed(1)mat <- matrix(rnorm(9, 2530, 350), ncol = 3)colnames(mat) <- paste("E", 1:3, sep = "")rownames(mat) <- paste("G", 1:3, sep = "")make_long(mat)gen_cols <- t(mat)make_long(gen_cols, gen_in = "cols")Make a two-way table
Description
This function help users to easily make a two-way table from a "long format"data.
Usage
make_mat(.data, row, col, value, fun = mean)Arguments
.data | The dataset. Must contains at least two categorical columns. |
row | The column of data in which the mean of each level willcorrespond toone line in the output. |
col | The column of data in which the mean of each level willcorrespond toone column in the output. |
value | The column of data that contains the values to fill the two-waytable. |
fun | The function to apply. Defaults to |
Value
A two-way table with the argumentrow in the rows,colin the columns, filled by the argumentvalue.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)matrix <- data_ge %>% make_mat(row = GEN, col = ENV, val = GY)matrix# standart error of meandata_ge %>% make_mat(GEN, ENV, GY, sem)Mantel test
Description
Performs a Mantel test between two correlation/distance matrices. Thefunction calculates the correlation between two matrices, the Z-score that isis the sum of the products of the corresponding elements of the matrices anda two-tailed p-value (null hypothesis: \[r = 0\]).
Usage
mantel_test(mat1, mat2, nboot = 1000, plot = FALSE)Arguments
mat1,mat2 | A correlation matrix or an object of class |
nboot | The number of permutations to be used. Defaults to |
plot | if |
Value
mantel_rThe correlation between the two matrices.z_scoreThe Z-score.p-valueThe quantile of the observed Z-score. in the permutationdistribution.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
See Also
Examples
library(metan)# Test if the correlation of traits (data_ge2 dataset)# changes between A1 and A2 levels of factor ENVA1 <- corr_coef(data_ge2 %>% subset(ENV == "A1"))[["cor"]]A2 <- corr_coef(data_ge2 %>% subset(ENV == "A2"))[["cor"]]mantel_test(A1, A2, plot = TRUE)Data for examples
Description
This dataset contains the means for grain yield of 10 genotypes cultivatedin 5 environments. The interaction effects for this data is found inint.effects()
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Multi-Environment Trial Analysis
Description
metan provides functions for performing the most used analyses in theevaluation of multi-environment trials, including, but not limited to:
ANOVA-based stability statistics;
AMMI-based stability indexes;
BLUP-based stability indexes;
Cross-validation procedures for AMMI-family and BLUP models;
GGE biplot analysis;
Estimation using AMMI considering different numbers of interactionprincipal component axes;
Graphics tools for generating biplots;
Nonparametric stability statistics;
Variance components and genetic parameters in mixed-effect models;
Within-environment analysis of variance;
metan also provides functions for biometrical analysis such as pathanalysis, canonical correlation, partial correlation, clustering analysis, aswell as tools for summarizing and plotting data.
A complete guide may be found athttps://tiagoolivoto.github.io/metan/
Multitrait Genotype-Ideotype Distance Index
Description
Computes the multi-trait genotype-ideotype distance index, MGIDI, (Olivotoand Nardino, 2020), used to select genotypes in plant breeding programs basedon multiple traits.The MGIDI index is computed as follows:\[MGIDI_i = \sqrt{\sum\limits_{j = 1}^f(F_{ij} - {F_j})^2}\]
where \(MGIDI_i\) is the multi-trait genotype-ideotype distance indexfor theith genotype; \(F_{ij}\) is the score of theith genotype inthejth factor (i = 1, 2, ..., g; j = 1, 2, ..., f), beingg andfthe number of genotypes and factors, respectively, and \(F_j\) is thejth score of the ideotype. The genotype with the lowest MGIDI is thencloser to the ideotype and therefore should presents desired values for allthe analyzed traits.
Usage
mgidi( .data, use_data = "blup", SI = 15, mineval = 1, ideotype = NULL, weights = NULL, use = "complete.obs", verbose = TRUE)Arguments
.data | An object fitted with the function |
use_data | Define which data to use if |
SI | An integer (0-100). The selection intensity in percentage of thetotal number of genotypes. |
mineval | The minimum value so that an eigenvector is retained in thefactor analysis. |
ideotype | A vector of length |
weights | Optional weights to assign for each trait in the selectionprocess. It must be a numeric vector of length equal to the number oftraits in |
use | The method for computing covariances in the presence of missingvalues. Defaults to |
verbose | If |
Value
An object of classmgidi with the following items:
data The data used to compute the factor analysis.
cormat The correlation matrix among the environments.
PCA The eigenvalues and explained variance.
FA The factor analysis.
KMO The result for the Kaiser-Meyer-Olkin test.
MSA The measure of sampling adequacy for individual variable.
communalities The communalities.
communalities_mean The communalities' mean.
initial_loadings The initial loadings.
finish_loadings The final loadings after varimax rotation.
canonical_loadings The canonical loadings.
scores_gen The scores for genotypes in all retained factors.
scores_ide The scores for the ideotype in all retained factors.
gen_ide The distance between the scores of each genotype with theideotype.
MGIDI The multi-trait genotype-ideotype distance index.
contri_fac The relative contribution of each factor on the MGIDIvalue. The lower the contribution of a factor, the close of the ideotype thevariables in such factor are.
contri_fac_rank, contri_fac_rank_sel The rank for the contributionof each factor for all genotypes and selected genotypes, respectively.
complementarity The complementarity matrix, which is the Euclideandistance between selected genotypes based on the contribution of each factoron the MGIDI index (waiting reference).
sel_dif The selection differential for the variables.
stat_gain A descriptive statistic for the selection gains. Theminimum, mean, confidence interval, standard deviation, maximum, and sum ofselection gain values are computed. If traits have negative and positivedesired gains, the statistics are computed for by strata.
sel_gen The selected genotypes.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Olivoto, T., and Nardino, M. (2020). MGIDI: toward an effectivemultivariate selection in biological experiments. Bioinformatics.doi:10.1093/bioinformatics/btaa981
Examples
library(metan)# simulate a data set# 10 genotypes# 5 replications# 4 traitsdf <- g_simula(ngen = 10, nrep = 5, nvars = 4, gen_eff = 35, seed = c(1, 2, 3, 4))# run a mixed-effect model (genotype as random effect)mod <- gamem(df, gen = GEN, rep = REP, resp = everything())# BLUPs for genotypesgmd(mod, "blupg")# Compute the MGIDI index# Default options (all traits with positive desired gains)# Equal weights for all traitsmgidi_ind <- mgidi(mod)gmd(mgidi_ind, "MGIDI")# Higher weight for traits V1 and V4# This will increase the probability of selecting H7 and H9# 30% selection pressuremgidi_ind2 <- mgidi(mod, weights = c(1, .2, .2, 1), SI = 30)gmd(mgidi_ind2, "MGIDI")# plot the contribution of each factor on the MGIDI indexp1 <- plot(mgidi_ind, type = "contribution")p2 <- plot(mgidi_ind2, type = "contribution")p1 + p2# Negative desired gains for V1# Positive desired gains for V2, V3 and V4mgidi_ind3 <- mgidi(mod, ideotype = c("h, h, h, l"))# Extract the BLUPs for each genotype(blupsg <- gmd(mod, "blupg"))# Consider the following ideotype that will be close to H4# Define a numeric ideotype for the first three traits, and the lower values# for the last traitideotype <- c("129.46, 76.8, 89.7, l")mgidi_ind4 <- mgidi(mod, ideotype = ideotype)# Note how the strenghts of H4 are related to FA1 (V1 and V2)plot(mgidi_ind4, type = "contribution", genotypes = "all")Mean performance and stability in multi-environment trials
Description
This function implements the weighting method between mean performance andstability (Olivoto et al., 2019) considering different parametric andnon-parametric stability indexes.
Usage
mps( .data, env, gen, rep, resp, block = NULL, by = NULL, random = "gen", performance = c("blupg", "blueg"), stability = "waasb", ideotype_mper = NULL, ideotype_stab = NULL, wmper = NULL, verbose = TRUE)Arguments
.data | The dataset containing the columns related to Environments,Genotypes, replication/block and response variable(s). |
env | The name of the column that contains the levels of theenvironments. |
gen | The name of the column that contains the levels of the genotypes. |
rep | The name of the column that contains the levels of thereplications/blocks. |
resp | The response variable(s). To analyze multiple variables in asingle procedure a vector of variables may be used. For example |
block | Defaults to |
by | One variable (factor) to compute the function by. It is a shortcutto |
random | The effects of the model assumed to be random. Defaults to |
performance | Wich considers as mean performance. Either |
stability | The stability method. One of the following:
|
ideotype_mper,ideotype_stab | The new maximum value after rescaling theresponse variable/stability index. By default, all variables in |
wmper | The weight for the mean performance. By default, all variablesin |
verbose | Logical argument. If |
Value
An object of classmps with the following items.
observed: The observed value on a genotype-mean basis.performance: The performance for genotypes (BLUPs or BLUEs)performance_res: The rescaled values of genotype's performance,consideringideotype_mper.stability: The stability for genotypes, chosen with argumentstability.stability_res: The rescaled values of genotype's stability, consideringideotype_stab.mps_ind: The mean performance and stability for the traits.h2: The broad-sense heritability for the traits.perf_method: The method for measuring genotype's performance.wmper: The weight for the mean performance.sense_mper: The goal for genotype's performance (l= lower,h= higher).stab_method: The method for measuring genotype's stability.wstab: The weight for the mean stability.sense_stab: The goal for genotype's stability (l= lower,h= higher).
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Annicchiarico, P. 1992. Cultivar adaptation and recommendation from alfalfatrials in Northern Italy. J. Genet. Breed. 46:269-278.
Doring, T.F., S. Knapp, and J.E. Cohen. 2015. Taylor's power law and thestability of crop yields. F. Crop. Res. 183: 294-302.doi:10.1016/j.fcr.2015.08.005
Doring, T.F., and M. Reckling. 2018. Detecting global trends of cereal yieldstability by adjusting the coefficient of variation. Eur. J. Agron. 99:30-36.doi:10.1016/j.eja.2018.06.007
Eberhart, S.A., and W.A. Russell. 1966. Stability parameters for comparing Varieties.Crop Sci. 6:36-40.doi:10.2135/cropsci1966.0011183X000600010011x
Huehn, V.M. 1979. Beitrage zur erfassung der phanotypischen stabilitat. EDVMed. Biol. 10:112.
Lin, C.S., and M.R. Binns. 1988. A superiority measure of cultivarperformance for cultivar x location data. Can. J. Plant Sci. 68:193-198.doi:10.4141/cjps88-018
Mohammadi, R., & Amri, A. (2008). Comparison of parametric and non-parametricmethods for selecting stable and adapted durum wheat genotypes in variableenvironments. Euphytica, 159(3), 419-432.doi:10.1007/s10681-007-9600-6
Olivoto, T., A.D.C. Lúcio, J.A.G. da silva, V.S. Marchioro, V.Q. deSouza, and E. Jost. 2019. Mean performance and stability in multi-environmenttrials I: Combining features of AMMI and BLUP techniques. Agron. J.doi:10.2134/agronj2019.03.0220
Resende MDV (2007) Matematica e estatistica na analise de experimentos e nomelhoramento genetico. Embrapa Florestas, Colombo
Shukla, G.K. 1972. Some statistical aspects of partitioninggenotype-environmental components of variability. Heredity. 29:238-245.doi:10.1038/hdy.1972.87
Thennarasu, K. 1995. On certain nonparametric procedures for studyinggenotype x environment interactions and yield stability. Ph.D. thesis. P.J.School, IARI, New Delhi, India.
Wricke, G. 1965. Zur berechnung der okovalenz bei sommerweizen und hafer. Z.Pflanzenzuchtg 52:127-138.
See Also
Examples
library(metan)# The same approach as mtsi()# mean performance and stability for GY and HM# mean performance: The genotype's BLUP# stability: the WAASB index (lower is better)# weights: equal for mean performance and stabilitymodel <-mps(data_ge, env = ENV, gen = GEN, rep = REP, resp = everything())# The mean performance and stability after rescalingmodel$mps_indMulti-trait mean performance and stability index
Description
Computes the multi-trait stability index proposed by Olivoto et al. (2019)considering different parametric and non-parametric stability indexes.
Usage
mtmps(model, SI = 15, mineval = 1, verbose = TRUE)Arguments
model | An object of class |
SI | An integer (0-100). The selection intensity in percentage of thetotal number of genotypes. |
mineval | The minimum value so that an eigenvector is retained in thefactor analysis. |
verbose | If |
Value
An object of classmtmps with the following items:
data The data used to compute the factor analysis.
cormat The correlation matrix among the environments.
PCA The eigenvalues and explained variance.
FA The factor analysis.
KMO The result for the Kaiser-Meyer-Olkin test.
MSA The measure of sampling adequacy for individual variable.
communalities The communalities.
communalities_mean The communalities' mean.
initial_loadings The initial loadings.
finish_loadings The final loadings after varimax rotation.
canonical_loadings The canonical loadings.
scores_gen The scores for genotypes in all retained factors.
scores_ide The scores for the ideotype in all retained factors.
MTSI The multi-trait mean performance and stability index.
contri_fac The relative contribution of each factor on the MTSIvalue. The lower the contribution of a factor, the close of the ideotype thevariables in such factor are.
contri_fac_rank, contri_fac_rank_sel The rank for the contributionof each factor for all genotypes and selected genotypes, respectively.
sel_dif_trait, sel_dif_stab, sel_dif_mps A data frame containing theselection differential (gains) for the mean performance, stability index, andmean performance and stability index, respectively. The following variablesare shown.
VAR: the trait's name.Factor: The factor that traits where grouped into.Xo: The original population mean.Xs: The mean of selected genotypes.SDandSDperc: The selection differential and selection differential inpercentage, respectively.h2: The broad-sense heritability.SGandSGperc: The selection gains and selection gains in percentage,respectively.sense: The desired selection sense.goal: selection gains match desired sense? 100 for yes and 0 for no.
stat_dif_trait, stat_dif_stab, stat_dif_mps A data frame with thedescriptive statistic for the selection gains for the mean performance,stability index, and mean performance and stability index, respectively. Thefollowing columns are shown by sense.
sense: The desired selection sense.variable: the trait's name.min: the minimum value for the selection gain.mean: the mean value for the selection gain.ci: the confidence interval for the selection gain.sd.amo: the standard deviation for the selection gain.max: the maximum value for the selection gain.sum: the sum of the selection gain.
sel_gen The selected genotypes.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Olivoto, T., A.D.C. Lúcio, J.A.G. da silva, B.G. Sari, andM.I. Diel. 2019. Mean performance and stability in multi-environment trialsII: Selection based on multiple traits. Agron. J. 111:2961-2969.doi:10.2134/agronj2019.03.0220
See Also
mgidi(),mps(),get_model_data()
Examples
library(metan)# The same approach as mtsi()# mean performance and stability for GY and HM# mean performance: The genotype's BLUP# stability: the WAASB index (lower is better)# weights: equal for mean performance and stabilitymodel <-mps(data_ge, env = ENV, gen = GEN, rep = REP, resp = everything())selection <- mtmps(model)# gains for stabilityselection$sel_dif_stab# gains for mean performanceselection$sel_dif_traitMulti-trait stability index
Description
Computes the multi-trait stability index proposed by Olivoto et al. (2019)
Usage
mtsi( .data, index = "waasby", ideotype = NULL, SI = 15, mineval = 1, verbose = TRUE)Arguments
.data | An object of class |
index | If |
ideotype | A vector of length |
SI | An integer (0-100). The selection intensity in percentage of thetotal number of genotypes. |
mineval | The minimum value so that an eigenvector is retained in thefactor analysis. |
verbose | If |
Value
An object of classmtsi with the following items:
data The data used to compute the factor analysis.
cormat The correlation matrix among the environments.
PCA The eigenvalues and explained variance.
FA The factor analysis.
KMO The result for the Kaiser-Meyer-Olkin test.
MSA The measure of sampling adequacy for individual variable.
communalities The communalities.
communalities_mean The communalities' mean.
initial_loadings The initial loadings.
finish_loadings The final loadings after varimax rotation.
canonical_loadings The canonical loadings.
scores_gen The scores for genotypes in all retained factors.
scores_ide The scores for the ideotype in all retained factors.
MTSI The multi-trait stability index.
contri_fac The relative contribution of each factor on the MTSIvalue. The lower the contribution of a factor, the close of the ideotype thevariables in such factor are.
contri_fac_rank, contri_fac_rank_sel The rank for the contributionof each factor for all genotypes and selected genotypes, respectively.
sel_dif_trait, sel_dif_stab, sel_dif_mps A data frame containing theselection differential (gains) for the traits, for the stability (WAASBindex) WAASB, and for the mean performance and stability (WAASBY indexes).The following variables are shown.
VAR: the trait's name.Factor: The factor that traits where grouped into.Xo: The original population mean.Xs: The mean of selected genotypes.SDandSDperc: The selection differential and selection differential inpercentage, respectively.h2: The broad-sense heritability.SGandSGperc: The selection gains and selection gains in percentage,respectively.sense: The desired selection sense.goal: selection gains match desired sense? 100 for yes and 0 for no.
stat_dif_var, stat_dif_stab, stat_dif_mps A data frame with thedescriptive statistic for the selection gains for the traits, for thestability (WAASB index) WAASB, and for the mean performance and stability(WAASBY index).The following variables are shown.
sense: The desired selection sense.variable: the trait's name.min: the minimum value for the selection gain.mean: the mean value for the selection gain.ci: the confidence interval for the selection gain.sd.amo: the standard deviation for the selection gain.max: the maximum value for the selection gain.sum: the sum of the selection gain.
sel_gen The selected genotypes.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Olivoto, T., A.D.C. Lúcio, J.A.G. da silva, B.G. Sari, andM.I. Diel. 2019. Mean performance and stability in multi-environment trialsII: Selection based on multiple traits. Agron. J. 111:2961-2969.doi:10.2134/agronj2019.03.0220
See Also
mgidi(),waasb(),get_model_data()
Examples
library(metan)# Based on stability only, for both GY and HM, higher is bettermtsi_model <- waasb(data_ge, env = ENV, gen = GEN, rep = REP, resp = c(GY, HM))mtsi_index <- mtsi(mtsi_model, index = 'waasb')# Based on mean performance and stability (using pipe operator %>%)# GY: higher is better# HM: lower is bettermtsi_index2 <- data_ge %>% waasb(ENV, GEN, REP, resp = c(GY, HM), mresp = c("h, l")) %>% mtsi()Network plot of a correlation matrix
Description
Produces a network plot of a correlation matrix or an object computed withcorr_coef(). Variables that are more highly correlated appear closertogether and are joined by stronger (more opaque) and wider paths. The proximity of thepoints is determined using multidimensional clustering, also known asprincipal coordinates analysis (Gower, 1966). The color of the paths alsoindicates the sign of the correlation (blue for positive and red fornegative).
Usage
network_plot( model, min_cor = NULL, show = c("signif", "all"), p_val = 0.05, legend = c("full", "range"), colours = c("red", "white", "blue"), legend_width = 1, legend_height = 15, legend_position = c("right", "left", "top", "bottom"), curved = TRUE, angle = 90, curvature = 0.5, expand_x = 0.25, expand_y = 0.25)Arguments
model | A model computed with |
min_cor | Number to indicate the minimum value of correlations to plot(0-1 in absolute terms). By default, all the correlations are plotted when |
show | The correlations to be shown when |
p_val | The p-value to indicate significant correlations. Defaults to |
legend | The type of legend. Either |
colours | A vector of colors to use for n-color gradient. |
legend_width | The width of the legend (considering |
legend_height | The height of the legend (considering |
legend_position | The legend position. Defaults to |
curved | Shows curved paths? Defaults to |
angle | A numeric value between 0 and 180, giving an amount to skew thecontrol points of the curve. Values less than 90 skew the curve towards thestart point and values greater than 90 skew the curve towards the endpoint. |
curvature | A numeric value giving the amount of curvature. Negativevalues produce left-hand curves, positive values produce right-hand curves,and zero produces a straight line. |
expand_x,expand_y | Vector of multiplicative range expansion factors. Iflength 1, both the lower and upper limits of the scale are expandedoutwards by mult. If length 2, the lower limit is expanded by |
Value
Aggplot object
References
Gower, J.C. 1966. Some Distance Properties of Latent Root and Vector MethodsUsed in Multivariate Analysis. Biometrika 53(3/4): 325–338.doi:10.2307/2333639
Examples
cor <- corr_coef(iris)network_plot(cor)network_plot(cor, show = "all", curved = FALSE, legend_position = "bottom", legend = "range")Select a set of predictors with minimal multicollinearity
Description
Select a set of predictors with minimal multicollinearity using the varianceinflation factor (VIF) as criteria to remove collinear variables. Thealgorithm will:(i) compute the VIF value of the correlation matrixcontaining the variables selected in...;(ii) arrange theVIF values and delete the variable with the highest VIF; and(iii)iterate stepii until VIF value is less than or equal tomax_vif.
Usage
non_collinear_vars( .data, ..., max_vif = 10, missingval = "pairwise.complete.obs")Arguments
.data | The data set containing the variables. |
... | Variables to be submitted to selection. If |
max_vif | The maximum value for the Variance Inflation Factor(threshold) that will be accepted in the set of selected predictors. |
missingval | How to deal with missing values. For more information,please see |
Value
A data frame showing the number of selected predictors, maximum VIFvalue, condition number, determinant value, selected predictors and removedpredictors from the original set of variables.
Examples
library(metan)# All numeric variablesnon_collinear_vars(data_ge2)# Select variables and choose a VIF threshold to 5non_collinear_vars(data_ge2, EH, CL, CW, KW, NKE, max_vif = 5)Mantel test for a set of correlation matrices
Description
This function generate a pairwise matrix of plots to compare the similarityof two or more correlation matrices. In the upper diagonal are presented theplots and in the lower diagonal the result of Mantel test based onpermutations.
Usage
pairs_mantel( ..., type = 1, nrepet = 1000, names = NULL, prob = 0.05, diag = FALSE, export = FALSE, main = "auto", file.type = "pdf", file.name = NULL, width = 8, height = 7, resolution = 300, size.point = 0.5, shape.point = 19, alpha.point = 1, fill.point = NULL, col.point = "black", minsize = 2, maxsize = 3, signcol = "green", alpha = 0.15, diagcol = "gray", col.up.panel = "gray", col.lw.panel = "gray", col.dia.panel = "gray", pan.spacing = 0.15, digits = 2)Arguments
... | The input matrices. May be an output generated by the function |
type | The type of correlation if an obect generated by the function |
nrepet | The number of permutations. Default is 1000 |
names | An optional vector of names of the same length of |
prob | The error probability for Mantel test. |
diag | Logical argument. If |
export | Logical argument. If |
main | The title of the plot, set to 'auto'. |
file.type | The format of the file if |
file.name | The name of the plot when exported. Set to |
width | The width of the plot, set to |
height | The height of the plot, set to |
resolution | The resolution of the plot if |
size.point | The size of the points in the plot. Set to |
shape.point | The shape of the point, set to |
alpha.point | The value for transparency of the points: 1 = full color. |
fill.point | The color to fill the points. Valid argument if points arebetween 21 and 25. |
col.point | The color for the edge of the point, set to |
minsize | The size of the letter that will represent the smallestcorrelation coefficient. |
maxsize | The size of the letter that will represent the largestcorrelation coefficient. |
signcol | The colour that indicate significant correlations (based onthe |
alpha | The value for transparency of the color informed in |
diagcol | The color in the kernel distribution. Set to 'gray'. |
col.up.panel,col.lw.panel,col.dia.panel | The color for the opper, lowerand diagonal pannels. Set to 'gray', 'gray', and 'gray', respectively. |
pan.spacing | The space between the pannels. Set to 0.15. |
digits | The number of digits to show in the plot. |
Value
An object of classgg, ggmatrix.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
See Also
Examples
library(metan)# iris datasetlpc <- iris %>% group_by(Species) %>% lpcor() %>% pairs_mantel(names = c('setosa', 'versicolor', 'virginica'))# mtcars datasetmt_num <- select_numeric_cols(mtcars)lpdata <- as.lpcor(cor(mt_num[1:5]), cor(mt_num[1:5]), cor(mt_num[2:6]), cor(mt_num[4:8])) %>% pairs_mantel()Path coefficients with minimal multicollinearity
Description
path_coeff()computes a path analysis using a data frame as input data.path_coeff_seq()computes a sequential path analysis using primary and secondary traits.path_coeff_mat()computes a path analysis using correlation matrices asinput data.
Usage
path_coeff( .data, resp, pred = everything(), by = NULL, exclude = FALSE, correction = NULL, knumber = 50, brutstep = FALSE, maxvif = 10, missingval = "pairwise.complete.obs", plot_res = FALSE, verbose = TRUE, ...)path_coeff_mat(cor_mat, resp, correction = NULL, knumber = 50, verbose = TRUE)path_coeff_seq(.data, resp, chain_1, chain_2, by = NULL, verbose = TRUE, ...)Arguments
.data | The data. Must be a data frame or a grouped data passed from |
resp | The dependent trait. |
pred | The predictor traits. set to |
by | One variable (factor) to compute the function by. It is a shortcutto |
exclude | Logical argument, set to false. If |
correction | Set to |
knumber | When |
brutstep | Logical argument, set to |
maxvif | The maximum value for the Variance Inflation Factor (cut point)that will be accepted. See theDetails section for more information. |
missingval | How to deal with missing values. For more information,please see |
plot_res | If |
verbose | If |
... | Depends on the function used:
|
cor_mat | Matrix of correlations containing both dependent andindependent traits. |
chain_1,chain_2 | The traits usedin the first (primary) and second (secondary) chain. |
Details
Inpath_coeff(), whenbrutstep = TRUE, an algorithm toselect a set of predictors with minimal multicollinearity and highexplanatory power is implemented. first, the algorithm will select a set ofpredictors with minimal multicollinearity. The selection is based on thevariance inflation factor (VIF). An iterative process is performed untilthe maximum VIF observed is less thanmaxvif. The variables selectedin this iterative process are then used in a series of stepwise-basedregressions. The first model is fitted and p-1 predictor variables areretained (p is the number of variables selected in the iterative process.The second model adjusts a regression considering p-2 selected variables,and so on until the last model, which considers only two variables. Threeobjects are created.Summary, with the process summary,Models, containing the aforementioned values for all the adjustedmodels; andSelectedpred, a vector with the name of the selectedvariables in the iterative process.
Value
Depends on the function used:
path_coeff(), returns a list with the following items:Corr.x A correlation matrix between the predictor variables.
Corr.y A vector of correlations between each predictor variablewith the dependent variable.
Coefficients The path coefficients. Direct effects are thediagonal elements, and the indirect effects those in the off-diagonalelements (lines).
Eigen Eigenvectors and eigenvalues of the
Corr.x.VIF The Variance Inflation Factors.
plot A ggplot2-based graphic showing the direct effects in 21different k values.
Predictors The predictor variables used in the model.
CN The Condition Number, i.e., the ratio between the highest andlowest eigenvalue.
Det The matrix determinant of the
Corr.x..R2 The coefficient of determination of the model.
Residual The residual effect of the model.
Response The response variable.
weightvar The order of the predictor variables with the highestweight (highest eigenvector) in the lowest eigenvalue.
path_coeff_seq()returns a list with the following objectsresp_fc an object of class
path_coeffwith the results for theanalysis with dependent trait and first chain predictors.resp_sc an object of class
path_coeffwith the results for theanalysis with dependent trait and second chain predictors.resp_sc2 The path coefficients of second chain predictors and thedependent trait through the first chain predictors
fc_sc_list A list of objects with the path analysis using each traitin the first chain as dependent and second chain as predictors.
fc_sc_coef The coefficients between first- and second-chain traits.
cor_mat A correlation matrix between the analyzed traits.If
.datais a grouped data passed fromdplyr::group_by()then the results will be returned into a list-column of data frames.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Olivoto, T., V.Q. Souza, M. Nardino, I.R. Carvalho, M. Ferrari, A.J.Pelegrin, V.J. Szareski, and D. Schmidt. 2017. Multicollinearity in pathanalysis: a simple method to reduce its effects. Agron. J. 109:131-142.doi:10.2134/agronj2016.04.0196
Olivoto, T., M. Nardino, I.R. Carvalho, D.N. Follmann, M. Ferrari, et al.2017. REML/BLUP and sequential path analysis in estimating genotypic valuesand interrelationships among simple maize grain yield-related traits. Genet.Mol. Res. 16(1): gmr16019525.doi:10.4238/gmr16019525
Examples
library(metan)# Using KW as the response variable and all other ones as predictorspcoeff <- path_coeff(data_ge2, resp = KW)# The same as above, but using the correlation matrixcor_mat <- cor(data_ge2 %>% select_numeric_cols())pcoeff2 <- path_coeff_mat(cor_mat, resp = KW)# Declaring the predictors# Create a residual plot with 'plot_res = TRUE'pcoeff3<- path_coeff(data_ge2, resp = KW, pred = c(PH, EH, NKE, TKW), plot_res = TRUE)# sequential path analysis# KW as dependent trait# NKE and TKW as primary predictors# PH, EH, EP, and EL as secondary traitspcoeff4 <- path_coeff_seq(data_ge2, resp = KW, chain_1 = c(NKE, TKW), chain_2 = c(PH, EH, EP, EL))pcoeff4$resp_sc$Coefficientspcoeff4$resp_sc2Additive Main effects and Multiplicative Interaction
Description
Compute the Additive Main effects and Multiplicative interaction (AMMI)model. The estimate of the response variable for theith genotype in thejth environment (\(y_{ij}\)) using the AMMI model, is given as follows:\[{y_{ij}} = \mu + {\alpha_i} + {\tau_j} + \sum\limits_{k = 1}^p{{\lambda_k}{a_{ik}}} {t_{jk}} + {\rho_{ij}} + {\varepsilon _{ij}}\]
where \(\lambda_k\) is the singular value for thek-th interactionprincipal component axis (IPCA); \(a_{ik}\) is thei-th element of thek-th eigenvector; \(t_{jk}\) is thejth element of thektheigenvector. A residual \(\rho _{ij}\) remains, if not allp IPCA areused, where \(p \le min(g - 1; e - 1)\).
This function also serves as a helper function for other procedures performedin themetan package such aswaas() andwsmp()
Usage
performs_ammi(.data, env, gen, rep, resp, block = NULL, verbose = TRUE, ...)Arguments
.data | The dataset containing the columns related to Environments,Genotypes, replication/block and response variable(s). |
env | The name of the column that contains the levels of theenvironments |
gen | The name of the column that contains the levels of the genotypes |
rep | The name of the column that contains the levels of thereplications/blocks |
resp | The response variable(s). To analyze multiple variables in asingle procedure, use comma-separated list of unquoted variable names,i.e., |
block | Defaults to |
verbose | Logical argument. If |
... | Arguments passed to the function |
Value
ANOVA: The analysis of variance for the AMMI model.
PCA: The principal component analysis
MeansGxE: The means of genotypes in the environments
model: scores for genotypes and environments in all the possibleaxes.
augment: Information about each observation in the dataset. Thisincludes predicted values in the
fittedcolumn, residuals in theresidcolumn, standardized residuals in thestdrescolumn,the diagonal of the 'hat' matrix in thehat, and standard errors forthe fitted values in these.fitcolumn.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Patterson, H.D., and E.R. Williams. 1976. A new class ofresolvable incomplete block designs. Biometrika 63:83-92.
See Also
impute_missing_val(),waas(),waas_means(),waasb(),get_model_data()
Examples
library(metan)model <- performs_ammi(data_ge, ENV, GEN, REP, resp = c(GY, HM))# PC1 x PC2 (variable GY)p1 <- plot_scores(model)p1# PC1 x PC2 (variable HM)plot_scores(model, var = 2, # or "HM" type = 2)# Nominal yield plot (variable GY)# Draw a convex hull polygonplot_scores(model, type = 4)# Unbalanced data (GEN 2 in E1 missing)mod <- data_ge %>% remove_rows(4:6) %>% droplevels() %>% performs_ammi(ENV, GEN, REP, GY)p2 <- plot_scores(mod)arrange_ggplot(p1, p2, tag_levels = list(c("Balanced data", "Unbalanced data")))Stability analysis based on Plaisted and Peterson (1959)
Description
The function computes the stability as the arithmetic mean of the variancecomponent of the genotype-environment interaction between environment pairsthat includes a given genotype
Usage
plaisted_peterson(.data, env, gen, rep, resp, verbose = TRUE)Arguments
.data | The dataset containing the columns related to Environments,Genotypes, replication/block and response variable(s). |
env | The name of the column that contains the levels of theenvironments. |
gen | The name of the column that contains the levels of the genotypes. |
rep | The name of the column that contains the levels of thereplications/blocks. |
resp | The response variable(s). To analyze multiple variables in asingle procedure use, for example, |
verbose | Logical argument. If |
Value
An object of classplaisted_peterson containing the results for eachvariable used in the argumentresp.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Plaisted, R.L., and L.C. Peterson. 1959. A technique forevaluating the ability of selections to yield consistently in differentlocations or seasons. American Potato Journal 36(11): 381–385.doi:10.1007/BF02852735
Examples
library(metan) plaisted_peterson(data_ge, ENV, GEN, REP, GY)Several types of residual plots
Description
Residual plots for a output model of classanova_joint. Seven typesof plots are produced: (1) Residuals vs fitted, (2) normal Q-Q plot for theresiduals, (3) scale-location plot (standardized residuals vs Fitted Values),(4) standardized residuals vs Factor-levels, (5) Histogram of raw residualsand (6) standardized residuals vs observation order, and (7) 1:1 line plot.
Usage
## S3 method for class 'anova_joint'plot(x, ...)Arguments
x | An object of class |
... | Additional arguments passed on to the function |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)model <- anova_joint(data_ge, ENV, GEN, REP, GY)plot(model)plot(model, which = c(3, 5), nrow = 2, labels = TRUE, size.lab.out = 4)Plots an object of class can_cor
Description
Graphs of the Canonical Correlation Analysis
Usage
## S3 method for class 'can_cor'plot( x, type = 1, plot_theme = theme_metan(), size.tex.lab = 12, size.tex.pa = 3.5, x.lab = NULL, x.lim = NULL, x.breaks = waiver(), y.lab = NULL, y.lim = NULL, y.breaks = waiver(), axis.expand = 1.1, shape = 21, col.shape = "orange", col.alpha = 0.9, size.shape = 3.5, size.bor.tick = 0.3, labels = FALSE, main = NULL, ...)Arguments
x | The |
type | The type of the plot. Defaults to |
plot_theme | The graphical theme of the plot. Default is |
size.tex.lab | The size of the text in axis text and labels. |
size.tex.pa | The size of the text of the plot area. Default is |
x.lab | The label of x-axis. Each plot has a default value. Newarguments can be inserted as |
x.lim | The range of x-axis. Default is |
x.breaks | The breaks to be plotted in the x-axis. Default is |
y.lab | The label of y-axis. Each plot has a default value. Newarguments can be inserted as |
y.lim | The range of y-axis. Default is |
y.breaks | The breaks to be plotted in the x-axis. Default is |
axis.expand | Multiplication factor to expand the axis limits by toenable fitting of labels. Default is |
shape | The shape of points in the plot. Default is |
col.shape | A vector of length 2 that contains the color of shapes forgenotypes above and below of the mean, respectively. Defaults to |
col.alpha | The alpha value for the color. Default is |
size.shape | The size of the shape in the plot. Default is |
size.bor.tick | The size of tick of shape. Default is |
labels | Logical arguments. If |
main | The title of the plot. Defaults to |
... | Currently not used. |
Value
An object of classgg, ggplot.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)cc1 = can_corr(data_ge2, FG = c(PH, EH, EP), SG = c(EL, ED, CL, CD, CW, KW, NR))plot(cc1, 2)cc2 <-data_ge2 %>%mean_by(GEN) %>%column_to_rownames("GEN") %>%can_corr(FG = c(PH, EH, EP), SG = c(EL, ED, CL, CD, CW, KW, NR))plot(cc2, 2, labels = TRUE)Plot an object of class clustering
Description
Plot an object of class clustering
Usage
## S3 method for class 'clustering'plot(x, horiz = TRUE, type = "dendrogram", ...)Arguments
x | An object of class |
horiz | Logical indicating if the dendrogram should be drawnhorizontally or not. |
type | The type of plot. Must be one of the 'dendrogram' or'cophenetic'. |
... | Other arguments passed from the function |
Value
An object of classgg, ggplot iftype == "cophenetic".
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
mean_gen <- data_ge2 %>% mean_by(GEN) %>% column_to_rownames("GEN")d <- clustering(mean_gen)plot(d, xlab = "Euclidean Distance")Create a correlation heat map
Description
Create a correlation heat map for object of classcorr_coef
Usage
## S3 method for class 'corr_coef'plot( x, type = "lower", diag = FALSE, reorder = TRUE, signif = c("stars", "pval"), show = c("all", "signif"), p_val = 0.05, caption = TRUE, digits.cor = 2, digits.pval = 3, col.low = "red", col.mid = "white", col.high = "blue", lab.x.position = NULL, lab.y.position = NULL, legend.position = NULL, legend.title = "Pearson's\nCorrelation", size.text.cor = 3, size.text.signif = 3, size.text.lab = 10, ...)Arguments
x | The data set. |
type | The type of heat map to produce. Either |
diag | Plot diagonal elements? Defaults to |
reorder | Reorder the correlation matrix to identify the hidden pattern?Defaults to |
signif | How to show significant correlations. If |
show | The correlations to show. Either |
p_val | The p-value to the correlation significance. |
caption | Logical. If |
digits.cor,digits.pval | The significant digits to show for correlationsand p-values, respectively. |
col.low,col.mid,col.high | The color for the low (-1), mid(0) and high(1) points in the color key. Defaults to |
lab.x.position,lab.y.position | The position of the x and y axis label.Defaults to |
legend.position | The legend position in the plot. |
legend.title | The title of the color key. Defaults to |
size.text.cor | The size of the text for correlation values. Defaults to 3. |
size.text.signif | The size of the text for significance values (stars or p-values). Defaults to 3. |
size.text.lab | The size of the text for labels. Defaults to 10. |
... | Currently not used. |
Value
An object of classgg, ggplot
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)# All numeric variablesx <- corr_coef(data_ge2)plot(x)plot(x, reorder = FALSE)# Select variablessel <- corr_coef(data_ge2, EP, EL, CD, CL)plot(sel, type = "upper", reorder = FALSE, size.text.lab = 14, size.text.plot = 5)Plot an object of class correlated_vars
Description
Plot an object of class correlated_vars
Usage
## S3 method for class 'correlated_vars'plot(x, ...)Arguments
x | An object of class correlated_vars. |
... | Currently not used. |
Value
An object of class gg.
Examples
library(metan)y <- rnorm(n = 10)cor_vars <- correlated_vars(y, nvar = 6)plot(cor_vars)Plot the RMSPD of a cross-validation procedure
Description
Boxplot showing the Root Means Square Prediction Difference of of a crossvalidation procedure.
Usage
## S3 method for class 'cvalidation'plot( x, violin = FALSE, export = FALSE, order_box = FALSE, x.lab = NULL, y.lab = NULL, size.tex.lab = 12, file.type = "pdf", file.name = NULL, plot_theme = theme_metan(), width = 6, height = 6, resolution = 300, col.violin = "gray90", col.boxplot = "gray70", col.boxplot.win = "cyan", width.boxplot = 0.6, x.lim = NULL, x.breaks = waiver(), ...)Arguments
x | An object of class |
violin | Define if a violin plot is used with boxplot. Default is 'TRUE' |
export | Export (or not) the plot. Default is |
order_box | Logical argument. If |
x.lab | The label of x-axis. New arguments can be inserted as |
y.lab | The label of y-axis. New arguments can be inserted as |
size.tex.lab | The size of the text in axis text and labels. |
file.type | The type of file to be exported. Default is |
file.name | The name of the file for exportation, default is |
plot_theme | The graphical theme of the plot. Default is |
width | The width 'inch' of the plot. Default is |
height | The height 'inch' of the plot. Default is |
resolution | The resolution of the plot. Parameter valid if |
col.violin | Parameter valid if |
col.boxplot | Define the color for boxplot. Default is 'gray70'. |
col.boxplot.win | Define the color for boxplot of the best model.Default is 'cyan'. |
width.boxplot | The width of boxplots. Default is |
x.lim | The range of x-axis. Default is |
x.breaks | The breaks to be plotted in the x-axis. Default is |
... | Currently not used. |
Details
Five statistics are shown in this type of plot. The lower and upper hingescorrespond to the first and third quartiles (the 25th and 75th percentiles).The upper whisker extends from the hinge to the largest value no further than1.5 * IQR from the hinge (where IQR is the inter-quartile range). The lowerwhisker extends from the hinge to the smallest value at most 1.5 * IQR of thehinge. Data beyond the end of the whiskers are considered outlying points.
Value
An object of classgg, ggplot.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
validation <- cv_ammif(data_ge2, resp = EH, gen = GEN, env = ENV, rep = REP, nboot = 5)plot(validation)Plot an object of class env_dissimilarity
Description
Create dendrograms to show the dissimilarity between environments.
Usage
## S3 method for class 'env_dissimilarity'plot(x, var = 1, nclust = NULL, ...)Arguments
x | An object of class |
var | The variable to plot. Defaults to |
nclust | The number of clusters to show. |
... | Other arguments bo be passed to the function |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)mod <- env_dissimilarity(data_ge, ENV, GEN, REP, GY)plot(mod)Plot the env_stratification model
Description
This function plots the correlation between environments generated withenv_stratification()
Usage
## S3 method for class 'env_stratification'plot(x, var = 1, ...)Arguments
x | An object of class |
var | The variable to plot. Defaults to |
... | Further arguments passed to |
Value
An object of classgg, ggplot.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
See Also
Examples
library(metan)model <-env_stratification(data_ge, env = ENV, gen = GEN, resp = GY)plot(model)Multi-trait selection index
Description
Plot the multitrait index based on factor analysis and ideotype-designproposed by Rocha et al. (2018).
Usage
## S3 method for class 'fai_blup'plot( x, ideotype = 1, SI = 15, radar = TRUE, arrange.label = FALSE, size.point = 2.5, size.line = 0.7, size.text = 10, col.sel = "red", col.nonsel = "black", ...)Arguments
x | An object of class |
ideotype | The ideotype to be plotted. Default is 1. |
SI | An integer (0-100). The selection intensity in percentage of thetotal number of genotypes. |
radar | Logical argument. If true (default) a radar plot is generatedafter using |
arrange.label | Logical argument. If |
size.point | The size of the point in graphic. Defaults to 2.5. |
size.line | The size of the line in graphic. Defaults to 0.7. |
size.text | The size for the text in the plot. Defaults to 10. |
col.sel | The colour for selected genotypes. Defaults to |
col.nonsel | The colour for nonselected genotypes. Defaults to |
... | Other arguments to be passed from ggplot2::theme(). |
Value
An object of classgg, ggplot.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Rocha, J.R.A.S.C.R, J.C. Machado, and P.C.S. Carneiro. 2018. Multitrait indexbased on factor analysis and ideotype-design: proposal and application onelephant grass breeding for bioenergy. GCB Bioenergy 10:52-60.doi:10.1111/gcbb.12443
Examples
library(metan)mod <- waasb(data_ge, env = ENV, gen = GEN, rep = REP, resp = c(GY, HM))FAI <- fai_blup(mod, DI = c('max, max'), UI = c('min, min'))plot(FAI)Several types of residual plots
Description
Residual plots for a output model of classgafem. Seven typesof plots are produced: (1) Residuals vs fitted, (2) normal Q-Q plot for theresiduals, (3) scale-location plot (standardized residuals vs Fitted Values),(4) standardized residuals vs Factor-levels, (5) Histogram of raw residualsand (6) standardized residuals vs observation order, and (7) 1:1 line plot.
Usage
## S3 method for class 'gafem'plot(x, ...)Arguments
x | An object of class |
... | Additional arguments passed on to the function |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)model <- gafem(data_g, GEN, REP, PH)plot(model)plot(model, which = c(3, 5), nrow = 2, labels = TRUE, size.lab.out = 4)Several types of residual plots
Description
Residual plots for a output model of classgamem. Six types of plotsare produced: (1) Residuals vs fitted, (2) normal Q-Q plot for the residuals,(3) scale-location plot (standardized residuals vs Fitted Values), (4)standardized residuals vs Factor-levels, (5) Histogram of raw residuals and(6) standardized residuals vs observation order. For awaasb object,normal Q-Q plot for random effects may also be obtained declaringtype = 're'
Usage
## S3 method for class 'gamem'plot( x, var = 1, type = "res", position = "fill", rotate = FALSE, conf = 0.95, out = "print", n.dodge = 1, check.overlap = FALSE, labels = FALSE, plot_theme = theme_metan(), alpha = 0.2, fill.hist = "gray", col.hist = "black", col.point = "black", col.line = "red", col.lab.out = "red", size.line = 0.7, size.text = 10, width.bar = 0.75, size.lab.out = 2.5, size.tex.lab = 10, size.shape = 1.5, bins = 30, which = c(1:4), ncol = NULL, nrow = NULL, ...)Arguments
x | An object of class |
var | The variable to plot. Defaults to |
type | One of the |
position | The position adjustment when |
rotate | Logical argument. If |
conf | Level of confidence interval to use in the Q-Q plot (0.95 bydefault). |
out | How the output is returned. Must be one of the 'print' (default)or 'return'. |
n.dodge | The number of rows that should be used to render the x labels.This is useful for displaying labels that would otherwise overlap. |
check.overlap | Silently remove overlapping labels, (recursively)prioritizing the first, last, and middle labels. |
labels | Logical argument. If |
plot_theme | The graphical theme of the plot. Default is |
alpha | The transparency of confidence band in the Q-Q plot. Must be anumber between 0 (opaque) and 1 (full transparency). |
fill.hist | The color to fill the histogram. Default is 'gray'. |
col.hist | The color of the border of the the histogram. Default is'black'. |
col.point | The color of the points in the graphic. Default is 'black'. |
col.line | The color of the lines in the graphic. Default is 'red'. |
col.lab.out | The color of the labels for the 'outlying' points. |
size.line | The size of the line in graphic. Defaults to 0.7. |
size.text | The size for the text in the plot. Defaults to 10. |
width.bar | The width of the bars if |
size.lab.out | The size of the labels for the 'outlying' points. |
size.tex.lab | The size of the text in axis text and labels. |
size.shape | The size of the shape in the plots. |
bins | The number of bins to use in the histogram. Default is 30. |
which | Which graphics should be plotted. Default is |
ncol,nrow | The number of columns and rows of the plot pannel. Defaultsto |
... | Additional arguments passed on to the function |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)model <- gamem(data_g, gen = GEN, rep = REP, resp = PH)plot(model)Plot an object of class ge_cluster
Description
Plot an object of class ge_cluster
Usage
## S3 method for class 'ge_cluster'plot(x, nclust = NULL, xlab = "", ...)Arguments
x | An object of class |
nclust | The number of clusters to show. |
xlab | The label of the x axis. |
... | Other arguments passed from the function |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Plot an object of class ge_effects
Description
Plot the regression model generated by the functionge_effects.
Usage
## S3 method for class 'ge_effects'plot( x, var = 1, plot_theme = theme_metan(), x.lab = NULL, y.lab = NULL, leg.position = "right", size.text = 12, ...)Arguments
x | An object of class |
var | The variable to plot. Defaults to |
plot_theme | The graphical theme of the plot. Default is |
x.lab | The label of x-axis. Each plot has a default value. Newarguments can be inserted as |
y.lab | The label of y-axis. Each plot has a default value. Newarguments can be inserted as |
leg.position | The position of the legend. |
size.text | The size of the text in the axes text and labels. Defaultis |
... | Current not used. |
Value
An object of classgg, ggplot.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
See Also
Examples
library(metan)ge_eff <- ge_effects(data_ge2, ENV, GEN, PH)plot(ge_eff)Plot the ge_factanal model
Description
This function plot the scores for genotypes obtained in the factor analysisto interpret the stability
Usage
## S3 method for class 'ge_factanal'plot( x, var = 1, plot_theme = theme_metan(), x.lim = NULL, x.breaks = waiver(), x.lab = NULL, y.lim = NULL, y.breaks = waiver(), y.lab = NULL, shape = 21, col.shape = "gray30", col.alpha = 1, size.shape = 2.2, size.bor.tick = 0.3, size.tex.lab = 12, size.tex.pa = 3.5, force.repel = 1, line.type = "dashed", line.alpha = 1, col.line = "black", size.line = 0.5, ...)Arguments
x | An object of class |
var | The variable to plot. Defaults to |
plot_theme | The graphical theme of the plot. Default is |
x.lim | The range of x-axis. Default is |
x.breaks | The breaks to be plotted in the x-axis. Default is |
x.lab | The label of x-axis. Each plot has a default value. Newarguments can be inserted as |
y.lim | The range of x-axis. Default is |
y.breaks | The breaks to be plotted in the x-axis. Default is |
y.lab | The label of y-axis. Each plot has a default value. Newarguments can be inserted as |
shape | The shape for genotype indication in the plot. Default is |
col.shape | The shape color for genotypes. Must be one value or a vectorof colors with the same length of the number of genotypes. Default is |
col.alpha | The alpha value for the color. Default is |
size.shape | The size of the shape (both for genotypes andenvironments). Default is |
size.bor.tick | The size of tick of shape. Default is |
size.tex.lab | The size of the text in the axes text and labels. Defaultis |
size.tex.pa | The size of the text of the plot area. Default is |
force.repel | Force of repulsion between overlapping text labels.Defaults to 1. |
line.type | The type of the line that indicate the means in the biplot.Default is |
line.alpha | The alpha value that combine the line with the backgroundto create the appearance of partial or full transparency. Default is |
col.line | The color of the line that indicate the means in the biplot.Default is |
size.line | The size of the line that indicate the means in the biplot.Default is |
... | Currently not used.. |
Value
An object of classgg, ggplot.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
See Also
Examples
library(metan)library(ggplot2)model = ge_factanal(data_ge2, env = ENV, gen = GEN, rep = REP, resp = PH)plot(model)plot(model, size.shape = 3, force.repel = 10, col.shape = "orange", col.line = "red")Plot an object of class ge_reg
Description
Plot the regression model generated by the functionge_reg.
Usage
## S3 method for class 'ge_reg'plot( x, var = 1, type = 1, plot_theme = theme_metan(), x.lim = NULL, x.breaks = waiver(), x.lab = NULL, y.lim = NULL, y.breaks = waiver(), y.lab = NULL, leg.position = "right", size.tex.lab = 12, ...)Arguments
x | An object of class |
var | The variable to plot. Defaults to |
type | The type of plot to show. |
plot_theme | The graphical theme of the plot. Default is |
x.lim | The range of x-axis. Default is |
x.breaks | The breaks to be plotted in the x-axis. Default is |
x.lab | The label of x-axis. Each plot has a default value. Newarguments can be inserted as |
y.lim | The range of x-axis. Default is |
y.breaks | The breaks to be plotted in the x-axis. Default is |
y.lab | The label of y-axis. Each plot has a default value. Newarguments can be inserted as |
leg.position | The position of the legend. |
size.tex.lab | The size of the text in the axes text and labels. Defaultis |
... | Currently not used.. |
Value
An object of classgg, ggplot.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
See Also
Examples
library(metan)model <- ge_reg(data_ge2, ENV, GEN, REP, PH)plot(model)Create GGE, GT or GYT biplots
Description
Produces a ggplot2-based GGE-GT-GYT biplot based on a model fitted with thefunctionsgge(),gtb(), andgytb().
Usage
## S3 method for class 'gge'plot( x, var = 1, type = 1, repel = TRUE, repulsion = 1, max_overlaps = 20, sel_env = NA, sel_gen = NA, sel_gen1 = NA, sel_gen2 = NA, shape.gen = 21, shape.env = 23, line.type.gen = "dotted", size.shape = 2.2, size.shape.win = 3.2, size.stroke = 0.3, col.stroke = "black", col.gen = "blue", col.env = "forestgreen", col.line = "forestgreen", col.alpha = 1, col.circle = "gray", col.alpha.circle = 0.5, leg.lab = NULL, size.text.gen = 3.5, size.text.env = 3.5, size.text.lab = 12, size.text.win = 4.5, size.line = 0.5, axis_expand = 1.2, title = TRUE, plot_theme = theme_metan(), ...)Arguments
x | An object with classes |
var | The variable to plot (useful for |
type | The type of biplot to produce.
|
repel | If |
repulsion | Force of repulsion between overlapping text labels. Defaultsto |
max_overlaps | Exclude text labels that overlap too many things.Defaults to 20. |
sel_env,sel_gen | The name of the environment (or trait/yield*traitcombination) and genotype to examine when |
sel_gen1,sel_gen2 | The name of genotypes to compare between when |
shape.gen,shape.env | The shape for genotype and environment indicationin the biplot. Defaults to |
line.type.gen | The line type to highlith the genotype's vectors.Defaults to |
size.shape | The size of the shape (both for genotypes andenvironments). Defaults to |
size.shape.win | The size of the shape for winners genotypes when |
size.stroke,col.stroke | The width and color of the border,respectively. Default to |
col.gen,col.env,col.line | Color for genotype/environment labels and forthe line that passes through the biplot origin. Defaults to |
col.alpha | The alpha value for the color. Defaults to |
col.circle,col.alpha.circle | The color and alpha values for the circlelines. Defaults to |
leg.lab | The labs of legend. Defaults to |
size.text.gen,size.text.env,size.text.lab | The size of the text forgenotypes, environments and labels, respectively. |
size.text.win | The text size to use for winner genotypes where |
size.line | The size of the line in biplots (Both for segments and circles). |
axis_expand | multiplication factor to expand the axis limits by toenable fitting of labels. Defaults to 1.2 |
title | Logical values (Defaults to |
plot_theme | The graphical theme of the plot. Default is |
... | Currently not used. |
Value
A ggplot2-based biplot.
An object of classgg, ggplot.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Yan, W., and M.S. Kang. 2003. GGE biplot analysis: a graphicaltool for breeders, geneticists, and agronomists. CRC Press.
Examples
library(metan)mod <- gge(data_ge, ENV, GEN, GY)plot(mod)plot(mod, type = 2, col.gen = 'blue', col.env = 'red', size.text.gen = 2)Plot the multi-trait genotype-ideotype distance index
Description
Makes a radar plot showing the multi-trait genotype-ideotype distance index
Usage
## S3 method for class 'mgidi'plot( x, SI = 15, radar = TRUE, type = "index", position = "fill", rotate = FALSE, genotypes = "selected", n.dodge = 1, check.overlap = FALSE, x.lab = NULL, y.lab = NULL, title = NULL, size.point = 2.5, size.line = 0.7, size.text = 3.5, width.bar = 0.75, col.sel = "red", col.nonsel = "gray", legend.position = "bottom", ...)Arguments
x | An object of class |
SI | An integer (0-100). The selection intensity in percentage of thetotal number of genotypes. |
radar | Logical argument. If true (default) a radar plot is generatedafter using |
type | The type of the plot. Defaults to |
position | The position adjustment when |
rotate | Logical argument. If |
genotypes | When |
n.dodge | The number of rows that should be used to render the x labels.This is useful for displaying labels that would otherwise overlap. |
check.overlap | Silently remove overlapping labels, (recursively)prioritizing the first, last, and middle labels. |
x.lab,y.lab | The labels for the axes x and y, respectively. x label isset to null when a radar plot is produced. |
title | The plot title when |
size.point | The size of the point in graphic. Defaults to 2.5. |
size.line | The size of the line in graphic. Defaults to 0.7. |
size.text | The size for the text in the plot. Defaults to 10. |
width.bar | The width of the bars if |
col.sel | The colour for selected genotypes. Defaults to |
col.nonsel | The colour for nonselected genotypes. Defaults to |
legend.position | The position of the legend. |
... | Other arguments to be passed from |
Value
An object of classgg, ggplot.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)model <- gamem(data_g, gen = GEN, rep = REP, resp = c(KW, NR, NKE, NKR))mgidi_index <- mgidi(model)plot(mgidi_index)Plot the multi-trait stability index
Description
Makes a radar plot showing the multitrait stability index proposed by Olivotoet al. (2019)
Usage
## S3 method for class 'mtmps'plot( x, SI = 15, type = "index", position = "fill", genotypes = "selected", title = TRUE, radar = TRUE, arrange.label = FALSE, x.lab = NULL, y.lab = NULL, size.point = 2.5, size.line = 0.7, size.text = 10, width.bar = 0.75, n.dodge = 1, check.overlap = FALSE, invert = FALSE, col.sel = "red", col.nonsel = "black", legend.position = "bottom", ...)Arguments
x | An object computed with |
SI | An integer (0-100). The selection intensity in percentage of thetotal number of genotypes. |
type | The type of the plot. Defaults to |
position | The position adjustment when |
genotypes | When |
title | Logical values (Defaults to |
radar | Logical argument. If true (default) a radar plot is generatedafter using |
arrange.label | Logical argument. If |
x.lab,y.lab | The labels for the axes x and y, respectively. x label isset to null when a radar plot is produced. |
size.point | The size of the point in graphic. Defaults to 2.5. |
size.line | The size of the line in graphic. Defaults to 0.7. |
size.text | The size for the text in the plot. Defaults to 10. |
width.bar | The width of the bars if |
n.dodge | The number of rows that should be used to render the x labels.This is useful for displaying labels that would otherwise overlap. |
check.overlap | Silently remove overlapping labels, (recursively)prioritizing the first, last, and middle labels. |
invert | Logical argument. If |
col.sel | The colour for selected genotypes. Defaults to |
col.nonsel | The colour for nonselected genotypes. Defaults to |
legend.position | The position of the legend. |
... | Other arguments to be passed from |
Value
An object of classgg, ggplot.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Olivoto, T., A.D.C. Lúcio, J.A.G. da silva, B.G. Sari, and M.I. Diel. 2019. Mean performance and stability in multi-environment trials II: Selection based on multiple traits. Agron. J. (in press).
Examples
library(metan)model <-mps(data_ge, env = ENV, gen = GEN, rep = REP, resp = everything())selection <- mtmps(model)plot(selection)Plot the multi-trait stability index
Description
Makes a radar plot showing the multitrait stability index proposed by Olivotoet al. (2019)
Usage
## S3 method for class 'mtsi'plot( x, SI = 15, type = "index", position = "fill", genotypes = "selected", title = TRUE, radar = TRUE, x.lab = NULL, y.lab = NULL, size.point = 2.5, size.line = 0.7, size.text = 3.5, width.bar = 0.75, n.dodge = 1, check.overlap = FALSE, invert = FALSE, col.sel = "red", col.nonsel = "black", legend.position = "bottom", ...)Arguments
x | An object of class |
SI | An integer (0-100). The selection intensity in percentage of thetotal number of genotypes. |
type | The type of the plot. Defaults to |
position | The position adjustment when |
genotypes | When |
title | Logical values (Defaults to |
radar | Logical argument. If true (default) a radar plot is generatedafter using |
x.lab,y.lab | The labels for the axes x and y, respectively. x label isset to null when a radar plot is produced. |
size.point | The size of the point in graphic. Defaults to 2.5. |
size.line | The size of the line in graphic. Defaults to 0.7. |
size.text | The size for the text in the plot. Defaults to 10. |
width.bar | The width of the bars if |
n.dodge | The number of rows that should be used to render the x labels.This is useful for displaying labels that would otherwise overlap. |
check.overlap | Silently remove overlapping labels, (recursively)prioritizing the first, last, and middle labels. |
invert | Logical argument. If |
col.sel | The colour for selected genotypes. Defaults to |
col.nonsel | The colour for nonselected genotypes. Defaults to |
legend.position | The position of the legend. |
... | Other arguments to be passed from |
Value
An object of classgg, ggplot.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Olivoto, T., A.D.C. Lúcio, J.A.G. da silva, B.G. Sari, and M.I. Diel. 2019. Mean performance and stability in multi-environment trials II: Selection based on multiple traits. Agron. J. (in press).
Examples
library(metan)mtsi_model <- waasb(data_ge, ENV, GEN, REP, resp = c(GY, HM))mtsi_index <- mtsi(mtsi_model)plot(mtsi_index)Plots an object of classpath_coeff
Description
Plots an object generated bypath_coeff(). Options includes the pathcoefficients, variance inflaction factor and the beta values with differentvalues of 'k' values added to the diagonal of the correlation matrix ofexplanatory traits. See more onDetails section.
Usage
## S3 method for class 'path_coeff'plot( x, which = "coef", size.text.plot = 4, size.text.labels = 10, digits = 3, ...)Arguments
x | An object of class |
which | Which to plot: one of |
size.text.plot,size.text.labels | The size of the text for plot area andlabels, respectively. |
digits | The significant digits to be shown. |
... | Further arguments passed on to |
Details
The plotwhich = "coef" (default) is interpreted as follows:
The direct effects are shown in the diagonal (highlighted with a thickerline). In the example, the direct effect of NKE on KW is 0.718.
The indirect effects are shown in the line. In the example, the indirect effect of EH on KW through TKW is 0.396.
The linear correlation (direct + indirect) is shown in the last column.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)# KW as dependent trait and all others as predictors# PH, EH, NKE, and TKW as predictorspcoeff <- path_coeff(data_ge2, resp = KW, pred = c(PH, EH, NKE, TKW))plot(pcoeff)plot(pcoeff, which = "vif")plot(pcoeff, which = "betas")Several types of residual plots
Description
Residual plots for a output model of classperforms_ammi. Seven typesof plots are produced: (1) Residuals vs fitted, (2) normal Q-Q plot for theresiduals, (3) scale-location plot (standardized residuals vs Fitted Values),(4) standardized residuals vs Factor-levels, (5) Histogram of raw residualsand (6) standardized residuals vs observation order, and (7) 1:1 line plot.
Usage
## S3 method for class 'performs_ammi'plot(x, ...)Arguments
x | An object of class |
... | Additional arguments passed on to the function |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)model <- performs_ammi(data_ge, ENV, GEN, REP, GY)plot(model)plot(model, which = c(3, 5), nrow = 2, labels = TRUE, size.lab.out = 4)Plot the response surface model
Description
Plot the response surface model using a contour plot
Usage
## S3 method for class 'resp_surf'plot( x, xlab = NULL, ylab = NULL, resolution = 100, bins = 10, plot_theme = theme_metan(), ...)Arguments
x | An object of class |
xlab,ylab | The label for the x and y axis, respectively. Defaults tooriginal variable names. |
resolution | The resolution of the contour plot. Defaults to 100. highervalues produce high-resolution plots but may increase the computation time. |
bins | The number of bins shown in the plot. Defaults to |
plot_theme | The graphical theme of the plot. Default is |
... | Currently not used |
Value
An object of classgg, ggplot.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)# A small toy exampledf <- data.frame( expand.grid(x = seq(0, 4, by = 1), y = seq(0, 4, by = 1)), z = c(10, 11, 12, 11, 10, 14, 15, 16, 15, 14, 16, 17, 18, 17, 16, 14, 15, 16, 15, 14, 10, 11, 12, 11, 10))mod <- resp_surf(df, x, y, resp = z)plot(mod)Plot the Smith-Hazel index
Description
Makes a radar plot showing the individual genetic worth for the Smith-Hazel index
Usage
## S3 method for class 'sh'plot( x, SI = 15, radar = TRUE, arrange.label = FALSE, size.point = 2.5, size.line = 0.7, size.text = 10, col.sel = "red", col.nonsel = "black", ...)Arguments
x | An object of class |
SI | An integer (0-100). The selection intensity in percentage of thetotal number of genotypes. |
radar | Logical argument. If true (default) a radar plot is generatedafter using |
arrange.label | Logical argument. If |
size.point | The size of the point in graphic. Defaults to 2.5. |
size.line | The size of the line in graphic. Defaults to 0.7. |
size.text | The size for the text in the plot. Defaults to 10. |
col.sel | The colour for selected genotypes. Defaults to |
col.nonsel | The colour for nonselected genotypes. Defaults to |
... | Other arguments to be passed from ggplot2::theme(). |
Value
An object of classgg, ggplot.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)vcov <- covcor_design(data_g, GEN, REP, everything())means <- as.matrix(vcov$means)pcov <- vcov$phen_covgcov <- vcov$geno_covindex <- Smith_Hazel(means, pcov = pcov, gcov = gcov, weights = rep(1, 15))plot(index)Several types of residual plots
Description
Residual plots for a output model of classwaas. Seven typesof plots are produced: (1) Residuals vs fitted, (2) normal Q-Q plot for theresiduals, (3) scale-location plot (standardized residuals vs Fitted Values),(4) standardized residuals vs Factor-levels, (5) Histogram of raw residualsand (6) standardized residuals vs observation order, and (7) 1:1 line plot.
Usage
## S3 method for class 'waas'plot(x, ...)Arguments
x | An object of class |
... | Additional arguments passed on to the function |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)model <- waas(data_ge, ENV, GEN, REP, GY)plot(model)plot(model, which = c(3, 5), nrow = 2, labels = TRUE, size.lab.out = 4)Several types of residual plots
Description
Residual plots for a output model of classwaas andwaasb. Six typesof plots are produced: (1) Residuals vs fitted, (2) normal Q-Q plot for theresiduals, (3) scale-location plot (standardized residuals vs FittedValues), (4) standardized residuals vs Factor-levels, (5) Histogram of rawresiduals and (6) standardized residuals vs observation order. For awaasbobject, normal Q-Q plot for random effects may also be obtained declaringtype = 're'
Usage
## S3 method for class 'waasb'plot( x, var = 1, type = "res", position = "fill", trait.levels = NULL, percent = TRUE, percent.digits = 2, size.text.percent = 3.5, rotate = FALSE, conf = 0.95, out = "print", n.dodge = 1, check.overlap = FALSE, labels = FALSE, plot_theme = theme_metan(), alpha = 0.2, fill.hist = "gray", col.hist = "black", col.point = "black", col.line = "red", col.lab.out = "red", size.line = 0.7, size.text = 10, width.bar = 0.75, size.lab.out = 2.5, size.tex.lab = 10, size.shape = 1.5, bins = 30, which = c(1:4), ncol = NULL, nrow = NULL, ...)Arguments
x | An object of class |
var | The variable to plot. Defaults to |
type | One of the |
position | The position adjustment when |
trait.levels | By default, variables are ordered in the x-axis byalphabetic order. If a plot with two variables (eg., "GY" and "PH") "PH"should appers before "GY", one can use a comma-separated vector of variablenames to relevel the variable's position in the plot (eg., |
percent | If |
percent.digits | The significant figures for the percentage values.Defaults to |
size.text.percent | The size of the text for the percentage values.Defaults to |
rotate | Logical argument. If |
conf | Level of confidence interval to use in the Q-Q plot (0.95 bydefault). |
out | How the output is returned. Must be one of the 'print' (default)or 'return'. |
n.dodge | The number of rows that should be used to render the x labels.This is useful for displaying labels that would otherwise overlap. |
check.overlap | Silently remove overlapping labels, (recursively)prioritizing the first, last, and middle labels. |
labels | Logical argument. If |
plot_theme | The graphical theme of the plot. Default is |
alpha | The transparency of confidence band in the Q-Q plot. Must be anumber between 0 (opaque) and 1 (full transparency). |
fill.hist | The color to fill the histogram. Default is 'gray'. |
col.hist | The color of the border of the the histogram. Default is'black'. |
col.point | The color of the points in the graphic. Default is 'black'. |
col.line | The color of the lines in the graphic. Default is 'red'. |
col.lab.out | The color of the labels for the 'outlying' points. |
size.line | The size of the line in graphic. Defaults to 0.7. |
size.text | The size for the text in the plot. Defaults to 10. |
width.bar | The width of the bars if |
size.lab.out | The size of the labels for the 'outlying' points. |
size.tex.lab | The size of the text in axis text and labels. |
size.shape | The size of the shape in the plots. |
bins | The number of bins to use in the histogram. Default is 30. |
which | Which graphics should be plotted. Default is |
ncol,nrow | The number of columns and rows of the plot pannel. Defaultsto |
... | Additional arguments passed on to the function |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)x <- gamem_met(data_ge, gen = GEN, env = ENV, rep = REP, resp = everything())plot(x)Plot heat maps with genotype ranking
Description
Plot heat maps with genotype ranking in two ways.
Usage
## S3 method for class 'wsmp'plot(x, var = 1, type = 1, y.lab = NULL, x.lab = NULL, size.lab = 12, ...)Arguments
x | An object returned by the function |
var | The variable to plot. Defaults to |
type |
|
y.lab | The label of y axis. Default is 'Genotypes'. |
x.lab | The label of x axis. Default is 'Number of axes'. |
size.lab | The size of the labels. |
... | Currently not used. |
Details
The first type of heatmap shows the genotype ranking depending on the numberof principal component axis used for estimating the WAASB index. The second type of heatmap shows thegenotype ranking depending on the WAASB/GY ratio. The ranks obtained with aratio of 100/0 considers exclusively the stability for the genotype ranking.On the other hand, a ratio of 0/100 considers exclusively the productivityfor the genotype ranking. Four clusters of genotypes are shown by label colors (red) unproductive andunstable genotypes; (blue) productive, but unstable genotypes; (black) stable, butunproductive genotypes; and (green), productive and stable genotypes.
Value
An object of classgg.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)model <- waasb(data_ge2, env = ENV, gen = GEN, rep = REP, resp = PH) %>% wsmp()p1 <- plot(model)p2 <- plot(model, type = 2)arrange_ggplot(p1, p2, ncol = 1)Plot the BLUPs for genotypes
Description
Plot the predicted BLUP of the genotypes.
Usage
plot_blup( x, var = 1, which = "gen", ncol = NULL, nrow = NULL, prob = 0.05, export = FALSE, file.type = "pdf", file.name = NULL, plot_theme = theme_metan(), width = 6, height = 6, err.bar = TRUE, size.err.bar = 0.5, size.shape = 3.5, size.tex.lab = 12, height.err.bar = 0.3, x.lim = NULL, x.breaks = waiver(), col.shape = c("blue", "red"), y.lab = "Genotypes", x.lab = NULL, n.dodge = 1, check.overlap = FALSE, panel.spacing = 0.15, resolution = 300, ...)Arguments
x | The |
var | The variable to plot. Defaults to |
which | Which plot to shown. If |
ncol,nrow | The number of columns and rows, respectively, to be shown inthe plot when |
prob | The probability error for constructing confidence interval. |
export | Export (or not) the plot. Default is |
file.type | If |
file.name | The name of the file for exportation, default is |
plot_theme | The graphical theme of the plot. Default is |
width | The width "inch" of the plot. Default is |
height | The height "inch" of the plot. Default is |
err.bar | Logical value to indicate if an error bar is shown. Defaultsto |
size.err.bar | The size of the error bar for the plot. Default is |
size.shape | The size of the shape (both for genotypes andenvironments). Default is |
size.tex.lab | The size of the text in axis text and labels. |
height.err.bar | The height for error bar. Default is |
x.lim | The range of x-axis. Default is |
x.breaks | The breaks to be plotted in the x-axis. Default is |
col.shape | A vector of length 2 that contains the color of shapes forgenotypes above and below of the mean, respectively. Default is |
y.lab | The label of the y-axis in the plot. Default is |
x.lab | The label of the x-axis in the plot. Default is |
n.dodge | The number of rows that should be used to render the Y labels.This is useful for displaying labels that would otherwise overlap. |
check.overlap | Silently remove overlapping labels, (recursively)prioritizing the first, last, and middle labels. |
panel.spacing | Defines the spacing between panels when |
resolution | The resolution of the plot. Parameter valid if |
... | Currently not used. |
Value
An object of classgg, ggplot.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
See Also
Examples
library(metan)BLUP <- waasb(data_ge2, resp = PH, gen = GEN, env = ENV, rep = REP)plot_blup(BLUP)plot_blup(BLUP, which = "ge")Plot the confidence interval for correlation
Description
This function plots the 95% confidence interval for Pearson's correlationcoefficient generated by the functioncorr_ci.
Usage
plot_ci( object, fill = NULL, position.fill = 0.3, x.lab = NULL, y.lab = NULL, y.lim = NULL, y.breaks = waiver(), shape = 21, col.shape = "black", fill.shape = "orange", size.shape = 2.5, width.errbar = 0.2, main = TRUE, invert.axis = TRUE, reorder = TRUE, legend.position = "bottom", plot_theme = theme_metan())Arguments
object | An object generate by the function |
fill | If |
position.fill | The position of shapes and errorbar when |
x.lab | The label of x-axis, set to 'Pairwise combinations'. Newarguments can be inserted as |
y.lab | The label of y-axis, set to 'Pearson's correlation coefficient'New arguments can be inserted as |
y.lim | The range of x-axis. Default is |
y.breaks | The breaks to be plotted in the x-axis. Default is |
shape | The shape point to represent the correlation coefficient.Default is |
col.shape | The color for the shape edge. Set to |
fill.shape | The color to fill the shape. Set to |
size.shape | The size for the shape point. Set to |
width.errbar | The width for the errorbar showing the CI. |
main | The title of the plot. Set to |
invert.axis | Should the names of the pairwise correlation appear in they-axis? |
reorder | Logical argument. If |
legend.position | The position of the legend when using |
plot_theme | The graphical theme of the plot. Default is |
Value
An object of classgg, ggplot.
Examples
library(metan)library(dplyr)# Traits that contains "E"data_ge2 %>% select(contains('E')) %>% corr_ci() %>% plot_ci()# Group by environment# Traits PH, EH, EP, EL, and ED# Select only correlations with PHdata_ge2 %>% corr_ci(PH, EP, EL, ED, CW, sel.var = "PH", by = ENV) %>% plot_ci(fill = ENV)Plot the eigenvalues
Description
Plot the eigenvalues for from singular value decomposition of BLUPinteraction effects matrix.
Usage
plot_eigen( x, var = 1, export = FALSE, plot_theme = theme_metan(), file.type = "pdf", file.name = NULL, width = 6, height = 6, size.shape = 3.5, size.line = 1, size.tex.lab = 12, y.lab = "Eigenvalue", y2.lab = "Accumulated variance", x.lab = "Number of multiplicative terms", resolution = 300, ...)Arguments
x | The |
var | The variable to plot. Defaults to |
export | Export (or not) the plot. Default is |
plot_theme | The graphical theme of the plot. Default is |
file.type | If |
file.name | The name of the file for exportation, default is |
width | The width "inch" of the plot. Default is |
height | The height "inch" of the plot. Default is |
size.shape | The size of the shape. Default is |
size.line | The size of the line. Default is |
size.tex.lab | The size of the text in axis text and labels. |
y.lab | The label of the y-axis in the plot. Default is |
y2.lab | The label of the second y-axis in the plot. Default is |
x.lab | The label of the x-axis in the plot. Default is |
resolution | The resolution of the plot. Parameter valid if |
... | Currently not used. |
Value
An object of classgg, ggplot.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
See Also
Examples
library(metan)BLUP <- waasb(data_ge, resp = c(GY, HM), gen = GEN, env = ENV, rep = REP)plot_eigen(BLUP)Plot scores in different graphical interpretations
Description
Plot scores of genotypes and environments in different graphicalinterpretations.
Biplots type 1 and 2 are well known in AMMI analysis. In the plot type 3, thescores of both genotypes and environments are plotted considering theresponse variable and the WAASB, an stability index that considers allsignificant principal component axis of traditional AMMI models or allprincipal component axis estimated with BLUP-interaction effects (Olivoto etal. 2019). Plot type 4 may be used to better understand the well known'which-won-where' pattern, facilitating the recommendation of appropriategenotypes targeted for specific environments, thus allowing the exploitationof narrow adaptations.
Usage
plot_scores( x, var = 1, type = 1, first = "PC1", second = "PC2", repel = TRUE, repulsion = 1, max_overlaps = 20, polygon = FALSE, title = TRUE, plot_theme = theme_metan(), axis.expand = 1.1, x.lim = NULL, y.lim = NULL, x.breaks = waiver(), y.breaks = waiver(), x.lab = NULL, y.lab = NULL, shape.gen = 21, shape.env = 23, size.shape.gen = 2.2, size.shape.env = 2.2, size.bor.tick = 0.1, size.tex.lab = 12, size.tex.gen = 3.5, size.tex.env = 3.5, size.line = 0.5, size.segm.line = 0.5, col.bor.gen = "black", col.bor.env = "black", col.line = "black", col.gen = "blue", col.env = "forestgreen", col.alpha.gen = 1, col.alpha.env = 1, col.segm.gen = transparent_color(), col.segm.env = "forestgreen", highlight = NULL, col.highlight = "red", col.alpha.highlight = 1, size.tex.highlight = 5.5, size.shape.highlight = 3.2, leg.lab = c("Env", "Gen"), line.type = "solid", line.alpha = 0.9, resolution = deprecated(), file.type = "png", export = FALSE, file.name = NULL, width = 8, height = 7, color = TRUE, ...)Arguments
x | An object fitted with the functions |
var | The variable to plot. Defaults to |
type | type of biplot to produce
|
first,second | The IPCA to be shown in the first (x) and second (y)axis. By default, IPCA1 is shown in the |
repel | If |
repulsion | Force of repulsion between overlapping text labels. Defaultsto |
max_overlaps | Exclude text labels that overlap too many things. Defaults to 20. |
polygon | Logical argument. If |
title | Logical values (Defaults to |
plot_theme | The graphical theme of the plot. Default is |
axis.expand | Multiplication factor to expand the axis limits by toenable fitting of labels. Default is |
x.lim,y.lim | The range of x and y axes, respectively. Default is |
x.breaks,y.breaks | The breaks to be plotted in the x and y axes,respectively. Defaults to |
x.lab,y.lab | The label of x and y axes, respectively. Defaults to |
shape.gen,shape.env | The shape for genotypes and environmentsindication in the biplot. Default is |
size.shape.gen,size.shape.env | The size of the shapes for genotypes andenvironments respectively. Defaults to |
size.bor.tick | The size of tick of shape. Default is |
size.tex.lab,size.tex.gen,size.tex.env | The size of the text for axislabels (Defaults to 12), genotypes labels, and environments labels(Defaults to 3.5). |
size.line | The size of the line that indicate the means in the biplot.Default is |
size.segm.line | The size of the segment that start in the origin of thebiplot and end in the scores values. Default is |
col.bor.gen,col.bor.env | The color of the shape's border for genotypesand environments, respectively. |
col.line | The color of the line that indicate the means in the biplot.Default is |
col.gen,col.env | The shape color for genotypes (Defaults to |
col.alpha.gen,col.alpha.env | The alpha value for the color forgenotypes and environments, respectively. Defaults to |
col.segm.gen,col.segm.env | The color of segment for genotypes (Defaultsto |
highlight | Genotypes/environments to be highlight in the plot. Defaultsto |
col.highlight | The color for shape/labels when a value is provided in |
col.alpha.highlight | The alpha value for the color of the highlightedgenotypes. Defaults to |
size.tex.highlight | The size of the text for the highlighted genotypes.Defaults to |
size.shape.highlight | The size of the shape for the highlightedgenotypes. Defaults to |
leg.lab | The labs of legend. Default is |
line.type | The type of the line that indicate the means in the biplot.Default is |
line.alpha | The alpha value that combine the line with the backgroundto create the appearance of partial or full transparency. Default is |
resolution | deprecated |
file.type | The type of file to be exported. Currently recognises the extensionseps/ps, tex, pdf, jpeg, tiff, png (default), bmp, svg and wmf (windows only). |
export | Export (or not) the plot. Default is |
file.name | The name of the file for exportation, default is |
width | The width 'inch' of the plot. Default is |
height | The height 'inch' of the plot. Default is |
color | Should type 4 plot have colors? Default to |
... | Currently not used. |
Value
An object of classgg, ggplot.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Olivoto, T., A.D.C. Lúcio, J.A.G. da silva, V.S. Marchioro, V.Q. deSouza, and E. Jost. 2019. Mean performance and stability in multi-environmenttrials I: Combining features of AMMI and BLUP techniques. Agron. J.111:2949-2960.doi:10.2134/agronj2019.03.0220
See Also
Examples
library(metan)# AMMI modelmodel <- waas(data_ge, env = ENV, gen = GEN, rep = REP, resp = everything())# GY x PC1 for variable GY (default plot)plot_scores(model)# PC1 x PC2 (variable HM)#plot_scores(model, polygon = TRUE, # Draw a convex hull polygon var = "HM", # or var = 2 to select variable highlight = c("G1", "G2"), # Highlight genotypes 2 and 3 type = 2) # type of biplot# PC3 x PC4 (variable HM)# Change size of plot fonts and colors# Minimal themeplot_scores(model, var = "HM", type = 2, first = "PC3", second = "PC4", col.gen = "black", col.env = "gray", col.segm.env = "gray", size.tex.gen = 5, size.tex.env = 2, size.tex.lab = 16, plot_theme = theme_metan_minimal())# WAASB indexwaasb_model <- waasb(data_ge, ENV, GEN, REP, GY)# GY x WAASB# Highlight genotypes 2 and 8plot_scores(waasb_model, type = 3, highlight = c("G2", "G8"))Plot WAASBY values for genotype ranking
Description
Plot heat maps with genotype ranking in two ways.
Usage
plot_waasby( x, var = 1, export = F, file.type = "pdf", file.name = NULL, plot_theme = theme_metan(), width = 6, height = 6, size.shape = 3.5, size.tex.lab = 12, col.shape = c("blue", "red"), x.lab = "WAASBY", y.lab = "Genotypes", x.breaks = waiver(), resolution = 300, ...)Arguments
x | The |
var | The variable to plot. Defaults to |
export | Export (or not) the plot. Default is |
file.type | The type of file to be exported. Default is |
file.name | The name of the file for exportation, default is |
plot_theme | The graphical theme of the plot. Default is |
width | The width "inch" of the plot. Default is |
height | The height "inch" of the plot. Default is |
size.shape | The size of the shape in the plot. Default is |
size.tex.lab | The size of the text in axis text and labels. |
col.shape | A vector of length 2 that contains the color of shapes forgenotypes above and below of the mean, respectively. Default is |
x.lab | The label of the x axis in the plot. Default is |
y.lab | The label of the y axis in the plot. Default is |
x.breaks | The breaks to be plotted in the x-axis. Default is |
resolution | The resolution of the plot. Parameter valid if |
... | Currently not used. |
Value
An object of classgg, ggplot.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
See Also
Examples
library(metan)library(ggplot2)waasby <- waasb(data_ge, resp = GY, gen = GEN, env = ENV, rep = REP)waasby2 <- waas(data_ge, resp = GY, gen = GEN, env = ENV, rep = REP)plot_waasby(waasby)plot_waasby(waasby2) + theme_gray() + theme(legend.position = "bottom", legend.background = element_blank(), legend.title = element_blank(), legend.direction = "horizontal")Predict method for gamem fits
Description
Obtains predictions from an object fitted withgamem().
Usage
## S3 method for class 'gamem'predict(object, ...)Arguments
object | An object of class |
... | Currently not used |
Value
A tibble with the predicted values for each variable in the model
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)model <- gamem(data_g, gen = GEN, rep = REP, resp = everything())predict(model)Predict a two-way table based on GGE model
Description
Predict the means for a genotype-vs-environment trial based on a Genotypeplus Genotype-vs-Environment interaction (GGE) model.
Usage
## S3 method for class 'gge'predict(object, naxis = 2, output = "wide", ...)Arguments
object | An object of class |
naxis | The the number of principal components to be used in theprediction. Generally, two axis may be used. In this case, the estimatedvalues will be those shown in the biplot. |
output | The type of output. It must be one of the |
... | Currently not used. |
Details
This function is used to predict the response variable of a two-way table(for examples the yielding of g genotypes in e environments) based on GGEmodel. This prediction is based on the number of principal components used.For more details see Yan and Kang (2007).
Value
A two-way table with genotypes in rows and environments in columns ifoutput = "wide" or a long format (columns ENV, GEN and Y) ifoutput = "long" with the predicted values by the GGE model.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Yan, W., and M.S. Kang. 2003. GGE biplot analysis: a graphicaltool for breeders, geneticists, and agronomists. CRC Press.
Examples
library(metan)mod <- gge(data_ge, GEN, ENV, c(GY, HM))predict(mod)Predict the means of a performs_ammi object
Description
Predict the means of a performs_ammi object considering a specific number of axis.
Usage
## S3 method for class 'performs_ammi'predict(object, naxis = 2, ...)Arguments
object | An object of class performs_ammi |
naxis | The the number of axis to be use in the prediction. If |
... | Additional parameter for the function |
Details
This function is used to predict the response variable of a two-way table(for examples the yielding of the i-th genotype in the j-th environment)based on AMMI model. This prediction is based on the number of multiplicativeterms used. Ifnaxis = 0, only the main effects (AMMI0) are used. Inthis case, the predicted mean will be the predicted value from OLSestimation. Ifnaxis = 1 the AMMI1 (with one multiplicative term) isused for predicting the response variable. Ifnaxis = min(gen-1;env-1), the AMMIF is fitted and the predicted value will be thecell mean, i.e. the mean of R-replicates of the i-th genotype in the j-thenvironment. The number of axis to be used must be carefully chosen.Procedures based on Postdictive success (such as Gollobs's d.f.) orPredictive success (such as cross-validation) should be used to do this. Thispackage provide both.performs_ammi() function computetraditional AMMI analysis showing the number of significant axis. On theother hand,cv_ammif() function provide a cross-validation,estimating the RMSPD of all AMMI-family models, based on resamplingprocedures.
Value
A list where each element is the predicted values by the AMMI modelfor each variable.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)model <- performs_ammi(data_ge, ENV, GEN, REP, resp = c(GY, HM))# Predict GY with 3 IPCA and HM with 1 IPCApredict <- predict(model, naxis = c(3, 1))Predict the means of a waas object
Description
Predict the means of a waas object considering a specific number of axis.
Usage
## S3 method for class 'waas'predict(object, naxis = 2, ...)Arguments
object | An object of class waas |
naxis | The the number of axis to be use in the prediction. If |
... | Additional parameter for the function |
Details
This function is used to predict the response variable of a two-way table(for examples the yielding of the i-th genotype in the j-th environment)based on AMMI model. This prediction is based on the number of multiplicativeterms used. Ifnaxis = 0, only the main effects (AMMI0) are used. Inthis case, the predicted mean will be the predicted value from OLSestimation. Ifnaxis = 1 the AMMI1 (with one multiplicative term) isused for predicting the response variable. Ifnaxis = min(gen-1;env-1), the AMMIF is fitted and the predicted value will be thecell mean, i.e. the mean of R-replicates of the i-th genotype in the j-thenvironment. The number of axis to be used must be carefully chosen.Procedures based on Postdictive success (such as Gollobs's d.f.) orPredictive sucess (such as cross-validation) should be used to do this. Thispackage provide both.waas() function compute traditional AMMIanalysis showing the number of significant axis. On the other hand,cv_ammif() function provide a cross-validation, estimating theRMSPD of all AMMI-family models, based on resampling procedures.
Value
A list where each element is the predicted values by the AMMI modelfor each variable.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)model <- waas(data_ge, env = ENV, gen = GEN, rep = REP, resp = c(GY, HM))# Predict GY with 3 IPCA and HM with 1 IPCApredict <- predict(model, naxis = c(3, 1))predictPredict method for waasb fits
Description
Obtains predictions from an object fitted withwaasb().
Usage
## S3 method for class 'waasb'predict(object, ...)Arguments
object | An object of class |
... | Currently not used |
Value
A tibble with the predicted values for each variable in the model
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)model <- waasb(data_ge, env = ENV, gen = GEN, rep = REP, resp = c(GY, HM))predict(model)Print an object of class Annicchiarico
Description
Print theAnnicchiarico object in two ways. By default, the resultsare shown in the R console. The results can also be exported to the directoryinto a *.txt file.
Usage
## S3 method for class 'Annicchiarico'print(x, export = FALSE, file.name = NULL, digits = 3, ...)Arguments
x | The |
export | A logical argument. If |
file.name | The name of the file if |
digits | The significant digits to be shown. |
... | Options used by the tibble package to format the output. See |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)Ann <- Annicchiarico(data_ge2, env = ENV, gen = GEN, rep = REP, resp = PH)print(Ann)Print an object of class Fox
Description
Print theFox object in two ways. By default, the resultsare shown in the R console. The results can also be exported to the directoryinto a *.txt file.
Usage
## S3 method for class 'Fox'print(x, export = FALSE, file.name = NULL, digits = 3, ...)Arguments
x | The |
export | A logical argument. If |
file.name | The name of the file if |
digits | The significant digits to be shown. |
... | Options used by the tibble package to format the output. See |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)library(metan)out <- Fox(data_ge2, ENV, GEN, PH)print(out)Print an object ofclassHuehn
Description
Print theHuehn object in two ways. By default, the results areshown in the R console. The results can also be exported to the directoryinto a *.txt file.
Usage
## S3 method for class 'Huehn'print(x, export = FALSE, file.name = NULL, digits = 3, ...)Arguments
x | An object of class |
export | A logical argument. If |
file.name | The name of the file if |
digits | The significant digits to be shown. |
... | Options used by the tibble package to format the output. See |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)model <- Huehn(data_ge2, ENV, GEN, PH)print(model)Print an object of class Schmildt
Description
Print theSchmildt object in two ways. By default, the resultsare shown in the R console. The results can also be exported to the directoryinto a *.txt file.
Usage
## S3 method for class 'Schmildt'print(x, export = FALSE, file.name = NULL, digits = 3, ...)Arguments
x | The |
export | A logical argument. If |
file.name | The name of the file if |
digits | The significant digits to be shown. |
... | Options used by the tibble package to format the output. See |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)Sch <- Schmildt(data_ge2, env = ENV, gen = GEN, rep = REP, resp = PH)print(Sch)Print an object of class Shukla
Description
Print theShukla object in two ways. By default, the resultsare shown in the R console. The results can also be exported to the directoryinto a *.txt file.
Usage
## S3 method for class 'Shukla'print(x, export = FALSE, file.name = NULL, digits = 3, ...)Arguments
x | The |
export | A logical argument. If |
file.name | The name of the file if |
digits | The significant digits to be shown. |
... | Options used by the tibble package to format the output. See |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)eco <- Shukla(data_ge2, env = ENV, gen = GEN, rep = REP, resp = PH)print(eco)Print an object ofclassThennarasu
Description
Print theThennarasu object in two ways. By default, the results areshown in the R console. The results can also be exported to the directoryinto a *.txt file.
Usage
## S3 method for class 'Thennarasu'print(x, export = FALSE, file.name = NULL, digits = 3, ...)Arguments
x | An object of class |
export | A logical argument. If |
file.name | The name of the file if |
digits | The significant digits to be shown. |
... | Options used by the tibble package to format the output. See |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)model <- Thennarasu(data_ge2, ENV, GEN, PH)print(model)Print an object of class ammi_indexes
Description
Print theammi_indexes object in two ways. By default, the results are shownin the R console. The results can also be exported to the directory into a*.txt file.
Usage
## S3 method for class 'ammi_indexes'print(x, which = "stats", export = FALSE, file.name = NULL, digits = 3, ...)Arguments
x | An object of class |
which | Which should be printed. Defaults to |
export | A logical argument. If |
file.name | The name of the file if |
digits | The significant digits to be shown. |
... | Options used by the tibble package to format the output. See |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)model <- performs_ammi(data_ge, ENV, GEN, REP, GY) %>% ammi_indexes()print(model)Print an object of class anova_ind
Description
Print theanova_ind object in two ways. By default, the results are shownin the R console. The results can also be exported to the directory into a*.txt file.
Usage
## S3 method for class 'anova_ind'print(x, export = FALSE, file.name = NULL, digits = 3, ...)Arguments
x | An object of class |
export | A logical argument. If |
file.name | The name of the file if |
digits | The significant digits to be shown. |
... | Options used by the tibble package to format the output. See |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)model <- data_ge %>% anova_ind(ENV, GEN, REP, c(GY, HM))print(model)Print an object of class anova_joint
Description
Print theanova_joint object in two ways. By default, the results are shownin the R console. The results can also be exported to the directory into a*.txt file.
Usage
## S3 method for class 'anova_joint'print(x, export = FALSE, file.name = NULL, digits = 3, ...)Arguments
x | An object of class |
export | A logical argument. If |
file.name | The name of the file if |
digits | The significant digits to be shown. |
... | Options used by the tibble package to format the output. See |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)model <- data_ge %>% anova_joint(ENV, GEN, REP, c(GY, HM))print(model)Print an object of class can_cor
Description
Print an object of classcan_cor object in two ways. By default, theresults are shown in the R console. The results can also be exported to thedirectory.
Usage
## S3 method for class 'can_cor'print(x, export = FALSE, file.name = NULL, digits = 3, ...)Arguments
x | An object of class |
export | A logical argument. If |
file.name | The name of the file if |
digits | The significant digits to be shown. |
... | Options used by the tibble package to format the output. See |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)cc <- can_corr(data_ge2, FG = c(PH, EH, EP), SG = c(EL, CL, CD, CW, KW, NR, TKW), verbose = FALSE)print(cc)Print an object of class coincidence
Description
Print acoincidence object in two ways. By default, the results are shown inthe R console. The results can also be exported to the directory.
Usage
## S3 method for class 'coincidence'print(x, export = FALSE, file.name = NULL, digits = 4, ...)Arguments
x | An object of class |
export | A logical argument. If |
file.name | The name of the file if |
digits | The significant digits to be shown. |
... | Options used by the tibble package to format the output. See |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)sel1 <- paste("G", 1:30, sep = "")sel2 <- paste("G", 16:45, sep = "")coinc <- coincidence_index(sel1 = sel1, sel2 = sel2, total = 150)print(coinc)Print an object of class colindiag
Description
Print thecolindiag object in two ways. By default, the resultsare shown in the R console. The results can also be exported to the directoryinto a *.txt file.
Usage
## S3 method for class 'colindiag'print(x, export = FALSE, file.name = NULL, digits = 3, ...)Arguments
x | The object of class |
export | A logical argument. If |
file.name | The name of the file if |
digits | The significant digits to be shown. |
... | Options used by the tibble package to format the output. See |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)col <- colindiag(data_ge2)print(col)Print an object of class corr_coef
Description
Print thecorr_coef object in two ways. By default, the resultsare shown in the R console. The results can also be exported to the directoryinto a *.txt file.
Usage
## S3 method for class 'corr_coef'print(x, export = FALSE, file.name = NULL, digits = 3, ...)Arguments
x | An object of class |
export | A logical argument. If |
file.name | The name of the file if |
digits | The significant digits to be shown. |
... | Options used by the tibble package to format the output. See |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)sel <- corr_coef(data_ge2, EP, EL, CD, CL)print(sel)Print an object of class ecovalence
Description
Print theecovalence object in two ways. By default, the resultsare shown in the R console. The results can also be exported to the directoryinto a *.txt file.
Usage
## S3 method for class 'ecovalence'print(x, export = FALSE, file.name = NULL, digits = 3, ...)Arguments
x | The |
export | A logical argument. If |
file.name | The name of the file if |
digits | The significant digits to be shown. |
... | Options used by the tibble package to format the output. See |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)eco <- ecovalence(data_ge2, env = ENV, gen = GEN, rep = REP, resp = PH)print(eco)Print an object of class env_dissimilarity
Description
Print theenv_dissimilarity object in two ways. By default, the resultsare shown in the R console. The results can also be exported to the directoryinto a *.txt file.
Usage
## S3 method for class 'env_dissimilarity'print(x, export = FALSE, file.name = NULL, digits = 3, ...)Arguments
x | An object of class |
export | A logical argument. If |
file.name | The name of the file if |
digits | The significant digits to be shown. |
... | Currently not used. |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)mod <- env_dissimilarity(data_ge, ENV, GEN, REP, GY)print(mod)Print the env_stratification model
Description
Print an object of classge_factanal in two ways. By default, the results areshown in the R console. The results can also be exported to the directory.
Usage
## S3 method for class 'env_stratification'print(x, export = FALSE, file.name = NULL, digits = 3, ...)Arguments
x | An object of class |
export | A logical argument. If |
file.name | The name of the file if |
digits | The significant digits to be shown. |
... | Currently not used. |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)model <-env_stratification(data_ge, env = ENV, gen = GEN, resp = GY)print(model)Print an object of class gamem
Description
Print thegamem object in two ways. By default, the results are shownin the R console. The results can also be exported to the directory.
Usage
## S3 method for class 'gamem'print(x, export = FALSE, file.name = NULL, digits = 4, ...)Arguments
x | An object fitted with the function |
export | A logical argument. If |
file.name | The name of the file if |
digits | The significant digits to be shown. |
... | Options used by the tibble package to format the output. See |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)alpha <- gamem(data_alpha, gen = GEN, rep = REP, block = BLOCK, resp = YIELD)print(alpha)Print an object of class ge_factanal
Description
Print thege_factanal object in two ways. By default, the results areshown in the R console. The results can also be exported to the directory.
Usage
## S3 method for class 'ge_factanal'print(x, export = FALSE, file.name = NULL, digits = 4, ...)Arguments
x | An object of class |
export | A logical argument. If |
file.name | The name of the file if |
digits | The significant digits to be shown. |
... | Options used by the tibble package to format the output. See |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
model <- ge_factanal(data_ge2, env = ENV, gen = GEN, rep = REP, resp = PH)print(model)Print an object of class ge_reg
Description
Print thege_reg object in two ways. By default, the results are shownin the R console. The results can also be exported to the directory into a*.txt file.
Usage
## S3 method for class 'ge_reg'print(x, export = FALSE, file.name = NULL, digits = 3, ...)Arguments
x | An object of class |
export | A logical argument. If |
file.name | The name of the file if |
digits | The significant digits to be shown. |
... | Options used by the tibble package to format the output. See |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)model <- ge_reg(data_ge2, ENV, GEN, REP, PH)print(model)Print an object of class ge_stats
Description
Print thege_stats object in two ways. By default, the results areshown in the R console. The results can also be exported to the directoryinto a *.txt file.
Usage
## S3 method for class 'ge_stats'print(x, what = "all", export = FALSE, file.name = NULL, digits = 3, ...)Arguments
x | An object of class |
what | What should be printed. |
export | A logical argument. If |
file.name | The name of the file if |
digits | The significant digits to be shown. |
... | Options used by the tibble package to format the output. See |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)model <- ge_stats(data_ge, ENV, GEN, REP, GY)print(model)Print the partial correlation coefficients
Description
Print an object of classlpcor or orlpcor_group in two ways.By default, the results are shown in the R console. The results can also beexported to the directory.
Usage
## S3 method for class 'lpcor'print(x, export = FALSE, file.name = NULL, digits = 3, ...)Arguments
x | An object of class |
export | A logical argument. If |
file.name | The name of the file if |
digits | The significant digits to be shown. |
... | Options used by the tibble package to format the output. See |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)pcor <- lpcor(data_ge2, NR, NKR, NKE)print(pcor)# Compute the correlations for each level of the factor ENVlpc2 <- lpcor(data_ge2, NR, NKR, NKE, by = ENV)print(lpc2)Print an object of class mgidiPrint amgidi object in two ways. By default, the results are shown inthe R console. The results can also be exported to the directory.
Description
Print an object of class mgidiPrint amgidi object in two ways. By default, the results are shown inthe R console. The results can also be exported to the directory.
Usage
## S3 method for class 'mgidi'print(x, export = FALSE, file.name = NULL, digits = 4, ...)Arguments
x | An object of class |
export | A logical argument. If |
file.name | The name of the file if |
digits | The significant digits to be shown. |
... | Options used by the tibble package to format the output. See |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)model <- gamem(data_g, gen = GEN, rep = REP, resp = c(KW, NR, NKE, NKR))mgidi_index <- mgidi(model)print(mgidi_index)Print an object of class mtmps
Description
Print amtmps object in two ways. By default, the results are shown inthe R console. The results can also be exported to the directory.
Usage
## S3 method for class 'mtmps'print(x, export = FALSE, file.name = NULL, digits = 4, ...)Arguments
x | An object of class |
export | A logical argument. If |
file.name | The name of the file if |
digits | The significant digits to be shown. |
... | Options used by the tibble package to format the output. See |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)model <-mps(data_ge, env = ENV, gen = GEN, rep = REP, resp = everything())selection <- mtmps(model)print(selection)Print an object of class mtsi
Description
Print amtsi object in two ways. By default, the results are shown inthe R console. The results can also be exported to the directory.
Usage
## S3 method for class 'mtsi'print(x, export = FALSE, file.name = NULL, digits = 4, ...)Arguments
x | An object of class |
export | A logical argument. If |
file.name | The name of the file if |
digits | The significant digits to be shown. |
... | Options used by the tibble package to format the output. See |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)# Based on stability onlyMTSI_MODEL <- waasb(data_ge, resp = c(GY, HM), gen = GEN, env = ENV, rep = REP)MTSI_index <- mtsi(MTSI_MODEL)print(MTSI_index)Print an object of class path_coeff
Description
Print an object generated by the function 'path_coeff()'. By default, theresults are shown in the R console. The results can also be exported to thedirectory.
Usage
## S3 method for class 'path_coeff'print(x, export = FALSE, file.name = NULL, digits = 4, ...)Arguments
x | An object of class |
export | A logical argument. If |
file.name | The name of the file if |
digits | The significant digits to be shown. |
... | Options used by the tibble package to format the output. See |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)# KW as dependent trait and all others as predictorspcoeff <- path_coeff(data_ge2, resp = KW)print(pcoeff)# Call the algorithm for selecting a set of predictors# With minimal multicollinearity (no VIF larger than 5)pcoeff2 <- path_coeff(data_ge2, resp = KW, brutstep = TRUE, maxvif = 5)print(pcoeff2)Print an object of class performs_ammi
Description
Print theperforms_ammi object in two ways. By default, the results are shownin the R console. The results can also be exported to the directory.
Usage
## S3 method for class 'performs_ammi'print(x, export = FALSE, file.name = NULL, digits = 4, ...)Arguments
x | An object of class |
export | A logical argument. If |
file.name | The name of the file if |
digits | The significant digits to be shown. |
... | Options used by the tibble package to format the output. See |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)model <- performs_ammi(data_ge, ENV, GEN, REP, resp = c(GY, HM))print(model)Print an object of class plaisted_peterson
Description
Print theplaisted_peterson object in two ways. By default, the resultsare shown in the R console. The results can also be exported to the directoryinto a *.txt file.
Usage
## S3 method for class 'plaisted_peterson'print(x, export = FALSE, file.name = NULL, digits = 3, ...)Arguments
x | The |
export | A logical argument. If |
file.name | The name of the file if |
digits | The significant digits to be shown. |
... | Options used by the tibble package to format the output. See |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)eco <- ecovalence(data_ge2, env = ENV, gen = GEN, rep = REP, resp = PH)print(eco)Print an object of class sh
Description
Print ash object in two ways. By default, the results are shown inthe R console. The results can also be exported to the directory.
Usage
## S3 method for class 'sh'print(x, export = FALSE, file.name = NULL, digits = 4, ...)Arguments
x | An object of class |
export | A logical argument. If |
file.name | The name of the file if |
digits | The significant digits to be shown. |
... | Options used by the tibble package to format the output. See |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
vcov <- covcor_design(data_g, GEN, REP, everything())means <- as.matrix(vcov$means)pcov <- vcov$phen_covgcov <- vcov$geno_covindex <- Smith_Hazel(means, pcov = pcov, gcov = gcov, weights = rep(1, 15))print(index)Print an object ofclasssuperiority
Description
Print thesuperiority object in two ways. By default, the results areshown in the R console. The results can also be exported to the directoryinto a *.txt file.
Usage
## S3 method for class 'superiority'print(x, export = FALSE, file.name = NULL, digits = 3, ...)Arguments
x | An object of class |
export | A logical argument. If |
file.name | The name of the file if |
digits | The significant digits to be shown. |
... | Options used by the tibble package to format the output. See |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)model <- superiority(data_ge2, ENV, GEN, PH)print(model)Print an object of class waas
Description
Print thewaas object in two ways. By default, the results are shownin the R console. The results can also be exported to the directory.
Usage
## S3 method for class 'waas'print(x, export = FALSE, file.name = NULL, digits = 4, ...)Arguments
x | An object of class |
export | A logical argument. If |
file.name | The name of the file if |
digits | The significant digits to be shown. |
... | Options used by the tibble package to format the output. See |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)model <- waas(data_ge, resp = c(GY, HM), gen = GEN, env = ENV, rep = REP)print(model)Print an object of class waas_means
Description
Print thewaas_means object in two ways. By default, the results are shownin the R console. The results can also be exported to the directory.
Usage
## S3 method for class 'waas_means'print(x, export = FALSE, file.name = NULL, digits = 4, ...)Arguments
x | An object of class |
export | A logical argument. If |
file.name | The name of the file if |
digits | The significant digits to be shown. See |
... | Currently not used. |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)data_means <- mean_by(data_ge, ENV, GEN)model <- waas_means(data_ge, env = ENV, gen = GEN, resp = everything())print(model)Print an object of class waasb
Description
Print awaasb object in two ways. By default, the results are shown inthe R console. The results can also be exported to the directory.
Usage
## S3 method for class 'waasb'print(x, export = FALSE, blup = FALSE, file.name = NULL, digits = 4, ...)Arguments
x | An object of class |
export | A logical argument. If |
blup | A logical argument. If |
file.name | The name of the file if |
digits | The significant digits to be shown. |
... | Options used by the tibble package to format the output. See |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)model <- waasb(data_ge, resp = c(GY, HM), gen = GEN, env = ENV, rep = REP)print(model)Objects exported from other packages
Description
These objects are imported from other packages. Follow the linksbelow to see their documentation.
- dplyr
- tidyselect
contains,ends_with,everything,last_col,matches,num_range,one_of,starts_with
Reorder a correlation matrix
Description
Reorder the correlation matrix according to the correlation coefficient byusing hclust for hierarchical clustering order. This is useful to identifythe hidden pattern in the matrix.
Usage
reorder_cormat(x)Arguments
x | The correlation matrix |
Value
The ordered correlation matrix
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)cor_mat <- corr_coef(data_ge2, PH, EH, CD, CL, ED, NKR)cor_mat$correorder_cormat(cor_mat$cor)Rescale a variable to have specified minimum and maximum values
Description
Helper function that rescales a continuous variable to have specified minimumand maximum values.
The function rescale a continuous variable as follows:
Rv_i = (Nmax -Nmin)/(Omax - Omin) * (O_i - Omax) + Nmax
WhereRv_i is the rescaledvalue of the ith position of the variable/ vector;Nmax andNminare the new maximum and minimum values;Omax and Omin are the maximumand minimum values of the original data, andO_i is the ith value ofthe original data.
There are basically two options to useresca to rescale a variable.The first is passing a data frame to.data argument and selecting oneor more variables to be scaled using.... The function will return theoriginal variables in.data plus the rescaled variable(s) with theprefix_res. By using the functiongroup_by fromdplyrpackage it is possible to rescale the variable(s) within each level of thegrouping factor. The second option is pass a numeric vector in the argumentvalues. The output, of course, will be a numeric vector of rescaledvalues.
Usage
resca( .data = NULL, ..., values = NULL, new_min = 0, new_max = 100, na.rm = TRUE, keep = TRUE)Arguments
.data | The dataset. Grouped data is allowed. |
... | Comma-separated list of unquoted variable names that will berescaled. |
values | Optional vector of values to rescale |
new_min | The minimum value of the new scale. Default is 0. |
new_max | The maximum value of the new scale. Default is 100 |
na.rm | Remove |
keep | Should all variables be kept after rescaling? If false, onlyrescaled variables will be kept. |
Value
A numeric vector ifvalues is used as input data or a tibbleif a data frame is used as input in.data.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)library(dplyr)# Rescale a numeric vectorresca(values = c(1:5)) # Using a data framehead( resca(data_ge, GY, HM, new_min = 0, new_max = 1))# Rescale within factors;# Select variables that stats with 'N' and ends with 'L';# Compute the mean of these variables by ENV and GEN;# Rescale the variables that ends with 'L' whithin ENV;data_ge2 %>% select(ENV, GEN, starts_with("N"), ends_with("L")) %>% mean_by(ENV, GEN) %>% group_by(ENV) %>% resca(ends_with("L")) %>% head(n = 13)Several types of residual plots
Description
Residual plots for a output model of classperforms_ammi,waas,anova_ind, andanova_joint. Seven types of plotsare produced: (1) Residuals vs fitted, (2) normal Q-Q plot for the residuals,(3) scale-location plot (standardized residuals vs Fitted Values), (4)standardized residuals vs Factor-levels, (5) Histogram of raw residuals and(6) standardized residuals vs observation order, and (7) 1:1 line plot
Usage
residual_plots( x, var = 1, conf = 0.95, labels = FALSE, plot_theme = theme_metan(), band.alpha = 0.2, point.alpha = 0.8, fill.hist = "gray", col.hist = "black", col.point = "black", col.line = "red", col.lab.out = "red", size.lab.out = 2.5, size.tex.lab = 10, size.shape = 1.5, bins = 30, which = c(1:4), ncol = NULL, nrow = NULL, ...)Arguments
x | An object of class |
var | The variable to plot. Defaults to |
conf | Level of confidence interval to use in the Q-Q plot (0.95 bydefault). |
labels | Logical argument. If |
plot_theme | The graphical theme of the plot. Default is |
band.alpha,point.alpha | The transparency of confidence band in the Q-Qplot and the points, respectively. Must be a number between 0 (opaque) and1 (full transparency). |
fill.hist | The color to fill the histogram. Default is 'gray'. |
col.hist | The color of the border of the the histogram. Default is'black'. |
col.point | The color of the points in the graphic. Default is 'black'. |
col.line | The color of the lines in the graphic. Default is 'red'. |
col.lab.out | The color of the labels for the 'outlying' points. |
size.lab.out | The size of the labels for the 'outlying' points. |
size.tex.lab | The size of the text in axis text and labels. |
size.shape | The size of the shape in the plots. |
bins | The number of bins to use in the histogram. Default is 30. |
which | Which graphics should be plotted. Default is |
ncol,nrow | The number of columns and rows of the plot pannel. Defaultsto |
... | Additional arguments passed on to the function |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)model <- performs_ammi(data_ge, ENV, GEN, REP, GY)# Default plotplot(model)# Normal Q-Q plot# Label possible outliersplot(model, which = 2, labels = TRUE)# Residual vs fitted,# Normal Q-Q plot# Histogram of raw residuals# All in one rowplot(model, which = c(1, 2, 5), nrow = 1)Response surface model
Description
Compute a surface model and find the best combination of factor1 and factor2to obtain the stationary point.
Usage
resp_surf( .data, factor1, factor2, rep = NULL, resp, prob = 0.05, verbose = TRUE)Arguments
.data | The dataset containing the columns related to Environments,factor1, factor2, replication/block and response variable(s). |
factor1 | The first factor, for example, dose of Nitrogen. |
factor2 | The second factor, for example, dose of potassium. |
rep | The name of the column that contains the levels of thereplications/blocks, if a designed experiment was conducted. Defaults to |
resp | The response variable(s). |
prob | The probability error. |
verbose | If |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)# A small toy exampledf <- data.frame( expand.grid(x = seq(0, 4, by = 1), y = seq(0, 4, by = 1)), z = c(10, 11, 12, 11, 10, 14, 15, 16, 15, 14, 16, 17, 18, 17, 16, 14, 15, 16, 15, 14, 10, 11, 12, 11, 10))mod <- resp_surf(df, x, y, resp = z)plot(mod)Selects a best subset of predictor variables.
Description
Selects among a set ofcovariates the best set ofnpredpredictors for a given response traitresp based on AIC values.
Usage
select_pred(.data, resp, covariates = NULL, npred)Arguments
.data | A data frame with the response variable and covariates. |
resp | The response variable. |
covariates | The covariates. Defaults toNULL. In this case, allnumeric traits in |
npred | An integer specifying the size of the subset of predictors to beselected |
Value
A list with the following elements:
sel_mod An object of class
lmthat is the selected model.predictors The name of the selected predictors.
AIC The Akaike's Information Criterion for the selected model.
pred_models The Akaike's Information Criterion and the predictorsselected in each step.
predicted The predicted values considering the model in
sel_mod.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)mod <- select_pred(data_ge2, resp = PH, npred = 10)mod$predictorsmod$AICPseudoinverse of a square matrix
Description
This function computes the Moore-Penrose pseudoinverse of a square matrixusing singular value decomposition.
Usage
solve_svd(x, tolerance = 2.220446e-16)Arguments
x | A square matrix |
tolerance | The tolerance to consider an eigenvalue equals to zero. |
Value
A matrix with the same dimension ofx.
Author(s)
Tiago Olivoto,tiagoolivoto@gmail.com
Examples
library(metan)mat <- matrix(c(1, 4, 2, 8), ncol = 2)det(mat)solve_svd(mat)Split a data frame by factors
Description
Split a data frame into subsets grouping by one or more factors.
This function is used to split a data frame into a named list where eachelement is a level of the grouping variable (or combination of groupingvariables).
Usage
split_factors(.data, ..., keep_factors = FALSE)as.split_factors(.data, keep_factors = FALSE)is.split_factors(x)Arguments
.data | The data that will be split. Must contain at least one groupingvariable. |
... | Comma-separated list of unquoted variable names that will be usedto split the data. |
keep_factors | Should the grouping columns be kept? |
x | An object to check for class |
Details
split_factors()Split a data frame by factors.as.splict_factors()coerce to an object of classsplit_factorsis.splict_factors()check if an object is of classsplit_factors
Value
A list where each element is a named level of the grouping factors.If more than one grouping variable is used, then each element is thecombination of the grouping variables.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)g1 <- split_factors(iris, Species)g2 <- split_factors(data_ge, ENV, keep_factors = TRUE)spdata <- as.split_factors(iris)is.split_factors(spdata)Generate significance stars from p-values
Description
Generate significance stars from p-values using R's standard definitions.
Usage
stars_pval(p_value)Arguments
p_value | A numeric vector of p-values |
Details
Mapping from p_value ranges to symbols:
0 - 0.0001: '****'
0.0001 - 0.001: '***'
0.001 - 0.01: '**'
0.01 - 0.05: '*'
0.05 - 1.0: 'ns'
Value
A character vector containing the same number of elements as p-value,with an attribute "legend" providing the conversion pattern.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
p_vals <- c(0.01, 0.043, 0.1, 0.0023, 0.000012)stars_pval(p_vals)Lin e Binns' superiority index
Description
Nonparametric stability analysis using the superiority index proposed by Lin& Binns (1988).
Usage
superiority(.data, env, gen, resp, verbose = TRUE)Arguments
.data | The dataset containing the columns related to Environments,Genotypes, replication/block and response variable(s) |
env | The name of the column that contains the levels of theenvironments. |
gen | The name of the column that contains the levels of the genotypes. |
resp | The response variable(s). To analyze multiple variables in asingle procedure use, for example, |
verbose | Logical argument. If |
Value
An object of classsuperiority where each element is theresult of one variable and contains the following items:
environments The mean for each environment, the environment indexand classification as favorable and unfavorable environments.
index The superiority index computed for all (
Pi_a),favorable (Pi_f) and unfavorable (Pi_u) environments.
Author(s)
Tiago Olivoto,tiagoolivoto@gmail.com
References
Lin, C.S., and M.R. Binns. 1988. A superiority measure of cultivarperformance for cultivar x location data. Can. J. Plant Sci. 68:193-198.doi:10.4141/cjps88-018
See Also
Annicchiarico(),ecovalence(),ge_stats()
Examples
library(metan)out <- superiority(data_ge2, ENV, GEN, PH)print(out)Personalized theme for ggplot2-based graphics
Description
theme_metan(): Theme with a gray background and major grids.theme_metan_minimal(): A minimalistic theme with half-open frame, whitebackground, and no grid. For more details seeggplot2::theme().transparent_color(): A helper function to return a transparent colorwith Hex value of "#000000FF"ggplot_color(): A helper function to emulate ggplot2 default colorpalette.alpha_color(): Return a semi-transparent color based on a color nameand an alpha value. For more details seegrDevices::colors().
Usage
theme_metan(grid = "none", col.grid = "white", color.background = "gray95")theme_metan_minimal()transparent_color()ggplot_color(n)alpha_color(color, alpha = 50)Arguments
grid | Control the grid lines in plot. Defaults to |
col.grid | The color for the grid lines |
color.background | The color for the panel background. |
n | The number of colors. This works well for up to about eight colours,but after that it becomes hard to tell the different colours apart. |
color | A color name. |
alpha | An alpha value for transparency (0 < alpha < 1). |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Tidy eval helpers
Description
This page lists the tidy eval tools reexported in this package fromrlang. To learn about using tidy eval in scripts and packages at ahigh level, see thedplyr programming vignetteand theggplot2 in packages vignette.TheMetaprogramming section ofAdvanced R may also be useful for a deeper dive.
The tidy eval operators
{{,!!, and!!!are syntacticconstructs which are specially interpreted by tidy eval functions.You will mostly need{{, as!!and!!!are more advancedoperators which you should not have to use in simple cases.The curly-curly operator
{{allows you to tunnel data-variablespassed from function arguments inside other tidy eval functions.{{is designed for individual arguments. To pass multiplearguments contained in dots, use...in the normal way.my_function <- function(data, var, ...) { data %>% group_by(...) %>% summarise(mean = mean({{ var }}))}enquo()andenquos()delay the execution of one or severalfunction arguments. The former returns a single expression, thelatter returns a list of expressions. Once defused, expressionswill no longer evaluate on their own. They must be injected backinto an evaluation context with!!(for a single expression) and!!!(for a list of expressions).my_function <- function(data, var, ...) { # Defuse var <- enquo(var) dots <- enquos(...) # Inject data %>% group_by(!!!dots) %>% summarise(mean = mean(!!var))}In this simple case, the code is equivalent to the usage of
{{and...above. Defusing withenquo()orenquos()is onlyneeded in more complex cases, for instance if you need to inspector modify the expressions in some way.The
.datapronoun is an object that represents the currentslice of data. If you have a variable name in a string, use the.datapronoun to subset that variable with[[.my_var <- "disp"mtcars %>% summarise(mean = mean(.data[[my_var]]))
Another tidy eval operator is
:=. It makes it possible to useglue and curly-curly syntax on the LHS of=. For technicalreasons, the R language doesn't support complex expressions onthe left of=, so we use:=as a workaround.my_function <- function(data, var, suffix = "foo") { # Use `{{` to tunnel function arguments and the usual glue # operator `{` to interpolate plain strings. data %>% summarise("{{ var }}_mean_{suffix}" := mean({{ var }}))}Many tidy eval functions like
dplyr::mutate()ordplyr::summarise()give an automatic name to unnamed inputs. Ifyou need to create the same sort of automatic names by yourself,useas_label(). For instance, the glue-tunnelling syntax abovecan be reproduced manually with:my_function <- function(data, var, suffix = "foo") { var <- enquo(var) prefix <- as_label(var) data %>% summarise("{prefix}_mean_{suffix}" := mean(!!var))}Expressions defused with
enquo()(or tunnelled with{{) neednot be simple column names, they can be arbitrarily complex.as_label()handles those cases gracefully. If your code assumesa simple column name, useas_name()instead. This is saferbecause it throws an error if the input is not a name as expected.
Transpose a data frame
Description
Is an alternative tot() to transpose a data frame. The firstcolumn ofdf will become column names in the transposed data.
Usage
transpose_df(df)Arguments
df | A data frame to be transposed. |
Value
A tibble containing the transposed data.
Examples
library(metan)df <-data.frame( GEN = c("G1", "G2", "G3","G4"), E1 = rnorm(4, 100, 20), E2 = rnorm(4, 10, 2), E3 = rnorm(4, 50, 5), E4 = rnorm(4, 1000, 150))dft(df)transpose_df(df)Tukey Honest Significant Differences
Description
Helper function to perform Tukey post-hoc tests. It is used ingafem.
Usage
tukey_hsd(model, ..., out = "long")Arguments
model | an object of class |
... | other arguments passed to the function
|
out | The format of outputs. If |
Value
A tibble data frame containing the results of the pairwisecomparisons (ifout = "long") or a "list-columns" with p-values foreach term (ifout = "wide").
Examples
library(metan)mod <- lm(PH ~ GEN + REP, data = data_g)tukey_hsd(mod)tukey_hsd(mod, out = "wide")Encode variables to a specific format
Description
Function to quick encode vector or columns to a specific format.
as_numeric(): Encode columns to numeric usingas.numeric().as_integer(): Encode columns to integer usingas.integer().as_logical(): Encode columns to logical usingas.logical().as_character(): Encode columns to character usingas.character().as_factor(): Encode columns to factor usingas.factor().
Usage
as_numeric(.data, ..., .keep = "all", .pull = FALSE)as_integer(.data, ..., .keep = "all", .pull = FALSE)as_logical(.data, ..., .keep = "all", .pull = FALSE)as_character(.data, ..., .keep = "all", .pull = FALSE)as_factor(.data, ..., .keep = "all", .pull = FALSE)Arguments
.data | A data frame or a vector. |
... | If |
.keep | Allows you to control which columns from
|
.pull | Allows you to pull out the last column of the output. It isuseful in combination with |
Value
An object of the same class of.data with the variables in... encoded to the specified format.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)library(tibble)df <- tibble(y = rnorm(5), x1 = c(1:5), x2 = c(TRUE, TRUE, FALSE, FALSE, FALSE), x3 = letters[1:5], x4 = as.factor(x3))df# Convert y to integeras_integer(df, y)as_integer(df$y)# convert x3 to factoras_factor(df, x3)# Convert all columns to characteras_character(df, everything())# Convert x2 to numeric and coerce to a vectoras_numeric(df, x2, .keep = "used", .pull = TRUE)Helper function for binding rows
Description
rbind_fill_id()Implements the common pattern of
do.call(rbind, dfs)with data frame identifier and filling of missing values.
Usage
rbind_fill_id(..., .id = NULL, .fill = NA)Arguments
... | The dataframes. Either a list of data frames, or a comma-separatedlist of dataframes. |
.id | Data frame identifier. If a comma-separated list of data frames issupplied, the labels are taken from the names of the objects. When a listof data frames is supplied, the labels are taken from the names of thelist. If no names are found, a numeric sequence is used instead. |
.fill | When row-binding, columns are matched by name, and any missingcolumns will be filled with |
Value
A data frame.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
(df1 <- data.frame(v1 = c(1, 2), v2 = c(2, 3)))(df2 <- data.frame(v3 = c(4, 5)))rbind_fill_id(df1, df2)rbind_fill_id(df1, df2, .fill = ".", .id = "dfs")# Named listlist <- list(a = df1, b = df2)rbind_fill_id(list, .id = "dfs")# Unnamed listlist <- list(df1, df2)rbind_fill_id(list, .id = "dfs")Utilities for handling with classes
Description
Utilities for handling with classes
Usage
add_class(x, class)has_class(x, class)remove_class(x, class)set_class(x, class)Arguments
x | An object |
class | The class to add or remove |
Details
add_class(): add a class to the objectxkeeping all the other class(es).has_class(): Check if a class exists in objectxand returns a logical value.set_class(): set a class to the objectx.remove_class(): remove a class from the objectx.
Value
The objectx with the class added or removed.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)df <-data_ge2 %>%add_class("my_class")class(df)has_class(df, "my_class")remove_class(df, "my_class") %>% class()set_class(df, "data_frame") %>% class()Utilities for data Copy-Pasta
Description
These functions allows interacting with the system clipboard. It is possibleread from the clipboard or write a data frame or matrix to the clipboard.
clip_read()read data from the clipboard.clip_write()write data to the clipboard.
Usage
clip_read(header = TRUE, sep = "\t", ...)clip_write(.data, sep = "\t", row_names = FALSE, col_names = TRUE, ...)Arguments
header | If the copied data has a header row for dataFrame, defaults to |
sep | The separator which should be used in the copied output. |
... | Further arguments to be passed to |
.data | The data that should be copied to the clipboard. Only data frames and matrices are allowed |
row_names | Decides if the output should keep row names or not, defaultsto |
col_names | Decides if the output should keep column names or not,defaults to |
Value
Nothing
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Utilities for data organization
Description
Useful function for data organization before statistical analysis
add_seq_block(): Add a column with sequential block numeration inmulti-environment data sets.recode_factor(): Recode a factor column. A sequential numbering (withpossible prefix) is used to identify each level.df_to_selegen_54(): Given a multi-environment data with environment,genotype, and replication, format the data to be used in the Selegen software(model 54).
Usage
add_seq_block(data, env, rep, new_factor = BLOCK, prefix = "", verbose = TRUE)recode_factor(data, factor, new_factor = CODE, prefix = "", verbose = TRUE)df_to_selegen_54(data, env, gen, rep, verbose = TRUE)Arguments
data | A data frame. |
env | The name of the column that contains the levels of theenvironments. |
rep | The name of the column that contains the levels of thereplications/blocks. |
new_factor | The name of the new column created. |
prefix | An optional prefix to bind with the new factor. |
verbose | Logical argument. If |
factor | A column to recode. |
gen | The name of the column that contains the levels of the genotypes,that will be treated as random effect. |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Resende, M.D. V. 2016. Software Selegen-REML/BLUP: a useful tool for plantbreeding. Crop Breed. Appl. Biotechnol. 16(4): 330–339.doi:10.1590/1984-70332016v16n4a49.
Examples
library(metan)df_ge <- ge_simula(ngen = 2, nenv = 3, nrep = 2) %>% add_cols(ENV = c(rep("CACIQUE", 4), rep("FREDERICO", 4), rep("SANTA_MARIA", 4)))df_ge# Add sequential block numbering over environmentsadd_seq_block(df_ge, ENV, REP, prefix = "B")# Recode the 'ENV' column to "ENV1", "ENV2", and so on.recode_factor(df_ge, factor = ENV, prefix = "ENV", new_factor = ENV_CODE)# Format the data to be used in the Selegen software (model 54)df <- df_to_selegen_54(df_ge, ENV, GEN, REP) %>%recode_factor(ENV, prefix = "E", new_factor = ENV)Utilities for handling with matrices
Description
These functions help users to make upper, lower, or symmetric matriceseasily.
Usage
make_upper_tri(x, diag = NA)make_lower_tri(x, diag = NA)make_lower_upper(lower, upper, diag = NA)make_sym(x, make = "upper", diag = NA)tidy_sym(x, keep_diag = TRUE)Arguments
x | A matrix to apply the function. It must be a symmetric (square)matrix in |
diag | What show in the diagonal of the matrix. Default to |
lower | A square matrix to fill the lower diagonal of the new matrix. |
upper | A square matrix to fill the upper diagonal of the new matrix. |
make | The triangular to built. Default is |
keep_diag | Keep diagonal values in the tidy data frame? Defaults to |
Details
make_upper_tri()makes an upper triangular matrix using a symmetricmatrix.make_lower_tri()makes a lower triangular matrix using a symmetricmatrix.make_sym()makes a lower triangular matrix using a symmetric matrix.tidy_sym()transform a symmetric matrix into tidy data frame.
Value
An upper, lower, or symmetric matrix, or a tidy data frame.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)m <- cor(select_cols(data_ge2, 5:10))make_upper_tri(m)make_lower_tri(m)make_lower_tri(m) %>%make_sym(diag = 0)tidy_sym(m)tidy_sym(make_lower_tri(m))Utilities for handling with NA and zero values
Description
NAs and zeros can increase the noise in multi-environment trial analysis.This collection of functions will make it easier to deal with them.
fill_na(): FillsNAin selected columns using the next orprevious entry.has_na(), has_zero(): Check forNAsand0sin thedata and return a logical value.prop_na()returns the proportion ofNAsin each column of a data frame.random_na(): Generate randomNAvalues in a two-way tablebased on a desired proportion.remove_cols_na(),remove_rows_na(): Remove columns and rows thatcontains at least oneNAvalue.remove_cols_all_na(),remove_rows_all_na(): Remove columns and rowswhere all values areNAs.remove_cols_zero(),remove_rows_zero(): Remove columns and rows thatcontains at least one0value, respectively.select_cols_na(), select_cols_zero(): Select columns withNAsand0s, respectively.select_rows_na(), select_rows_zero(): Select rows withNAsand0s, respectively.replace_na(), replace_zero(): ReplaceNAsand0s,respectively, with areplacementvalue.
Usage
fill_na(.data, ..., direction = "down")has_na(.data)prop_na(.data, ...)remove_rows_na(.data, verbose = TRUE)remove_rows_all_na(.data, verbose = TRUE)remove_cols_na(.data, verbose = TRUE)remove_cols_all_na(.data, verbose = TRUE)select_cols_na(.data, verbose = TRUE)select_rows_na(.data, verbose = TRUE)replace_na(.data, ..., replacement = 0)random_na(.data, prop)has_zero(.data)remove_rows_zero(.data, verbose = TRUE)remove_cols_zero(.data, verbose = TRUE)select_cols_zero(.data, verbose = TRUE)select_rows_zero(.data, verbose = TRUE)replace_zero(.data, ..., replacement = NA)Arguments
.data | A data frame. |
... | Variables to fill |
direction | Direction in which to fill missing values. Currently either"down" (the default), "up", "downup" (i.e. first down and then up) or"updown" (first up and then down). |
verbose | Logical argument. If |
replacement | The value used for replacement. Defaults to |
prop | The proportion (percentage) of |
Value
A data frame with rows or columns withNA values deleted.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)data_naz <- iris %>% group_by(Species) %>% doo(~head(., n = 3)) %>% as_character(Species)data_nazdata_naz[c(2:3, 6, 8), c(1:2, 4, 5)] <- NAdata_naz[c(2, 7, 9), c(2, 3, 4)] <- 0has_na(data_naz)has_zero(data_naz)# Fill NA values of column GENfill_na(data_naz, Species)# Remove columnsremove_cols_na(data_naz)remove_cols_zero(data_naz)remove_rows_na(data_naz)remove_rows_zero(data_naz)# Select columnsselect_cols_na(data_naz)select_cols_zero(data_naz)select_rows_na(data_naz)select_rows_zero(data_naz)# Replace valuesreplace_na(data_naz)replace_zero(data_naz)Utilities for handling with numbers and strings
Description
all_lower_case(): Translate all non-numeric strings of a data frameto lower case.all_upper_case(): Translate all non-numeric strings of a data frameto upper case.all_title_case(): Translate all non-numeric strings of a data frameto title case.first_upper_case: Translate the first word of a string to uppercase.extract_number(): Extract the number(s) of a string.extract_string(): Extract all strings, ignoring case.find_text_in_num(): Find text characters in a numeric sequence andreturn the row index.has_text_in_num(): Inspect columns looking for text in numericsequence and return a warning if text is found.remove_space(): Remove all blank spaces of a string.remove_strings(): Remove all strings of a variable.replace_number(): Replace numbers with a replacement.replace_string(): Replace all strings with a replacement, ignoringcase.round_cols(): Round a selected column or a whole data frame tosignificant figures.tidy_strings(): Tidy up characters strings, non-numeric columns, orany selected columns in a data frame by putting all word in upper case,replacing any space, tabulation, punctuation characters by'_', andputting'_'between lower and upper case. Suppose thatstr = c("Env1", "env 1", "env.1")(which by definition should represent a uniquelevel in plant breeding trials, e.g., environment 1) is subjected totidy_strings(str): the result will be thenc("ENV_1", "ENV_1", "ENV_1"). See Examples section for more examples.
Usage
all_upper_case(.data, ...)all_lower_case(.data, ...)all_title_case(.data, ...)first_upper_case(.data, ...)extract_number(.data, ..., pattern = NULL)extract_string(.data, ..., pattern = NULL)find_text_in_num(.data, ...)has_text_in_num(.data)remove_space(.data, ...)remove_strings(.data, ...)replace_number( .data, ..., pattern = NULL, replacement = "", ignore_case = FALSE)replace_string( .data, ..., pattern = NULL, replacement = "", ignore_case = FALSE)round_cols(.data, ..., digits = 2)tidy_strings(.data, ..., sep = "_")Arguments
.data | A data frame |
... | The argument depends on the function used.
|
pattern | A string to be matched. Regular Expression Syntax is alsoallowed. |
replacement | A string for replacement. |
ignore_case | If |
digits | The number of significant figures. |
sep | A character string to separate the terms. Defaults to "_". |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)################ Rounding numbers ################ All numeric columnsround_cols(data_ge2, digits = 1)# Round specific columnsround_cols(data_ge2, EP, digits = 1)########### Extract or replace numbers ########### Extract numbersextract_number(data_ge, GEN)# Replace numbersreplace_number(data_ge, GEN)replace_number(data_ge, GEN, pattern = 1, replacement = "_one")########## Extract, replace or remove strings ########### Extract stringsextract_string(data_ge, GEN)# Replace stringsreplace_string(data_ge, GEN)replace_string(data_ge, GEN, pattern = "G", replacement = "GENOTYPE_")# Remove stringsremove_strings(data_ge)remove_strings(data_ge, ENV)############ Find text in numeric sequences ###########mixed_text <- data.frame(data_ge)mixed_text[2, 4] <- "2..503"mixed_text[3, 4] <- "3.2o75"find_text_in_num(mixed_text, GY)############# upper, lower and title cases ############gen_text <- c("This is the first string.", "this is the second one")all_lower_case(gen_text)all_upper_case(gen_text)all_title_case(gen_text)first_upper_case(gen_text)# A whole data frameall_lower_case(data_ge)############### Tidy up messy text string ##############messy_env <- c("ENV 1", "Env 1", "Env1", "env1", "Env.1", "Env_1")tidy_strings(messy_env)messy_gen <- c("GEN1", "gen 2", "Gen.3", "gen-4", "Gen_5", "GEN_6")tidy_strings(messy_gen)messy_int <- c("EnvGen", "Env_Gen", "env gen", "Env Gen", "ENV.GEN", "ENV_GEN")tidy_strings(messy_int)library(tibble)# Or a whole data framedf <- tibble(Env = messy_env, gen = messy_gen, Env_GEN = interaction(Env, gen), y = rnorm(6, 300, 10))dftidy_strings(df)Utilities for text progress bar in the terminal
Description
Progress bars are configurable, may include percentage, elapsed time, andcustom text.
progress(): Initiate a custom progress bar of classpb_metan.run_progress(): Run the progress bar and should be called within a 'forloop' statement, alapply()family orpurrr::map()family of functionalprogramming tools.
Usage
progress( min = 0, max = 100, leftd = "|", rightd = "|", char = "=", style = 2, width = getOption("width"), time = Sys.time())run_progress(pb, actual, text = "", digits = 0, sleep = 0)Arguments
min,max | Numeric values for the extremes of the progress bar. Must have |
leftd,rightd | The left and right delimiters for the progress bar.Defaults to |
char | The character (or character string) to form the progress bar. |
style | The 'style' of the progress bar. Elapsed time is counted fromcalling
|
width | The the width of the progress bar. Defaults to the number ofcharacters is that which fits into |
time | The system time used to compute the elapsed time from calling |
pb | An object created with |
actual | The actual value, for example, a loop variable that define theloop index value. |
text | An optional character string to be shown at the begining of theprogress bar. |
digits | The number of significant figures in percentage value. Defaultsto |
sleep | Suspend execution for a time interval with |
Value
progress() returns a list of classpb_metan that contains the setparameters that will called byrun_progress().
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
################### A for looping approach ################pb <- progress()for (i in 1:100) { run_progress(pb, actual = i, sleep = 0.01)}################### An apply family approach ##############pb <- progress(max = 10)foo <- function(...){ run_progress(pb, ...) rnorm(100) %>% mean() }(a <- sapply(1:10, FUN = foo, sleep = 0.05))######## A purrr functional programming approach ##########foo2 <- function(...){ run_progress(pb2, ...) rnorm(100) %>% mean()}pb2 <- progress(max = 10000, style = 4, leftd = "", char = ".", rightd = "!")b <- purrr::map_dbl(1:10000, foo2, text = "Progress bar for sampling")hist(b)Utilities for handling with rows and columns
Description
add_cols(): Add one or more columns to an existing data frame. Ifspecified.beforeor.aftercolumns does not exist, columns areappended at the end of the data. Return a data frame with all the originalcolumns in.dataplus the columns declared in.... Inadd_cols()columns in.dataare available for the expressions.So, it is possible to add a column based on existing data.add_rows(): Add one or more rows to an existing data frame. Ifspecified.beforeor.afterrows does not exist, rows areappended at the end of the data. Return a data frame with all the originalrows in.dataplus the rows declared in...argument.add_row_id(): Add a column with the row id as the first column in.data.add_prefix()andadd_suffix()add prefixes and suffixes,respectively, in variable names selected in...argument.all_pairs(): Get all the possible pairs between the levels of afactor.colnames_to_lower(): Translate all column names to lower case.colnames_to_upper(): Translate all column names to upper case.colnames_to_title(): Translate all column names to title case.column_exists(): Checks if a column exists in a data frame. Return alogical value.columns_to_first(): Move columns to first positions in.data.columns_to_last(): Move columns to last positions in.data.columns_to_rownames(): Move a column of.datato its rownames.rownames_to_column(): Move the row names of.datato a newcolumn.remove_rownames(): Remove the row names of.data.concatenate(): Concatenate columns of a data frame. Ifdrop = TRUEthen the existing variables are dropped. Ifpull = TRUEthen theconcatenated variable is pull out to a vector. This is specially useful whenusingconcatenateto add columns to a data frame withadd_cols().get_levels(): Get the levels of a factor variable.get_levels_comb(): Get the combination of the levels of a factor.get_level_size(): Get the size of each level of a factor variable.remove_cols(): Remove one or more columns from a data frame.remove_rows(): Remove one or more rows from a data frame.reorder_cols(): Reorder columns in a data frame.select_cols(): Select one or more columns from a data frame.select_first_col(): Select first variable, possibly with an offset.select_last_col(): Select last variable, possibly with an offset.select_numeric_cols(): Select all the numeric columns of a dataframe.select_non_numeric_cols(): Select all the non-numeric columns of adata frame.select_rows(): Select one or more rows from a data frame.tidy_colnames(): Tidy up column names withtidy_strings().
Usage
add_cols(.data, ..., .before = NULL, .after = NULL)add_rows(.data, ..., .before = NULL, .after = NULL)add_row_id(.data, var = "row_id")all_pairs(.data, levels)add_prefix(.data, ..., prefix, sep = "_")add_suffix(.data, ..., suffix, sep = "_")colnames_to_lower(.data)colnames_to_upper(.data)colnames_to_title(.data)column_to_first(.data, ...)column_to_last(.data, ...)column_to_rownames(.data, var = "rowname")rownames_to_column(.data, var = "rowname")remove_rownames(.data, ...)column_exists(.data, cols)concatenate( .data, ..., prefix = NULL, suffix = NULL, new_var = new_var, sep = "_", drop = FALSE, pull = FALSE, .before = NULL, .after = NULL)get_levels(.data, ...)get_levels_comb(.data, ...)get_level_size(.data, ...)reorder_cols(.data, ..., .before = NULL, .after = NULL)remove_cols(.data, ...)remove_rows(.data, ...)select_first_col(.data, offset = NULL)select_last_col(.data, offset = NULL)select_numeric_cols(.data)select_non_numeric_cols(.data)select_cols(.data, ...)select_rows(.data, ...)tidy_colnames(.data, sep = "_")Arguments
.data | A data frame |
... | The argument depends on the function used.
|
.before,.after | For |
var | Name of column to use for rownames. |
levels | The levels of a factor or a numeric vector. |
prefix,suffix | The prefix and suffix used in |
sep | The separator to appear when using |
cols | A quoted variable name to check if it exists in |
new_var | The name of the new variable containing the concatenatedvalues. Defaults to |
drop | Logical argument. If |
pull | Logical argument. If |
offset | Set it ton to select thenth variable from theend (for |
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)################# Adding columns ################## Variables x and y .after last columndata_ge %>% add_cols(x = 10, y = 30)# Variables x and y .before the variable GENdata_ge %>% add_cols(x = 10, y = 30, .before = GEN)# Creating a new variable based on the existing ones.data_ge %>% add_cols(GY2 = GY^2, GY2_HM = GY2 + HM, .after = GY)############### Reordering columns ###############reorder_cols(data_ge2, NKR, .before = ENV)reorder_cols(data_ge2, where(is.factor), .after = last_col())######## Selecting and removing columns ##########select_cols(data_ge2, GEN, REP)remove_cols(data_ge2, GEN, REP)########## Selecting and removing rows ###########select_rows(data_ge2, 2:3)remove_rows(data_ge2, 2:3)########### Concatenating columns ################concatenate(data_ge, ENV, GEN, REP)concatenate(data_ge, ENV, GEN, REP, drop = TRUE)# Combine with add_cols() and replace_string()data_ge2 %>% add_cols(ENV_GEN = concatenate(., ENV, GEN, pull = TRUE), .after = GEN) %>% replace_string(ENV_GEN, pattern = "H", replacement = "HYB_")# Use prefixes and suffixesconcatenate(data_ge2, REP, prefix = "REP", new_var = REP)# Use prefixes and suffixes (the ear traits EH, EP, EL, and ED)add_prefix(data_ge2, PH, EH, EP, EL, prefix = "EAR")add_suffix(data_ge2, PH, EH, EP, EL, suffix = "EAR", sep = ".")# Use prefixes and suffixes (colnames)concatenate(data_ge2, REP, prefix = "REP", new_var = REP)########### formating column names ################ Creating data with messy column namesdf <- head(data_ge, 3)colnames(df) <- c("Env", "gen", "Rep", "GY", "hm")dfcolnames_to_lower(df)colnames_to_upper(df)colnames_to_title(df)################### Adding rows ##################data_ge %>% add_rows(GY = 10.3, HM = 100.11, .after = 1)########## checking if a column exists ###########column_exists(data_g, "GEN")####### get the levels, level combinations and size of levels ########get_levels(data_g, GEN)get_levels_comb(data_ge, ENV, GEN)get_level_size(data_g, GEN)############## all possible pairs ################all_pairs(data_g, GEN)########## select numeric variables only #########select_numeric_cols(data_g)select_non_numeric_cols(data_g)Random Sampling
Description
sample_random()performs Simple Random Sampling or Stratified RandomSamplingsample_systematic()performs systematic sampling. In this case, a regularinterval of size k (k = floor(N/n)) is generated considering the populationsize (N) and desired sample size (n). Then, the starting member (r) israndomly chosen between1-k. The second element isr+k, and so on.
Usage
sample_random(data, n, prop, by = NULL, weight = NULL)sample_systematic(data, n, r = NULL, by = NULL)Arguments
data | A data frame. If |
n,prop | Provide either |
by | A categorical variable to compute the sample by. It is ashortcut to |
weight | Sampling weights. This must evaluate to a vector ofnon-negative numbers the same length as the input. Weights areautomatically standardised to sum to 1. |
r | The starting element. By default, |
Value
An object of the same type asdata.
Examples
library(metan)sample_random(data_ge, n = 5)sample_random(data_ge, n = 3, by = ENV)sample_systematic(data_g, n = 6)Utilities for set operations for many sets
Description
Provides alternative function tobase::union(),base::intersect(), andbase::setdiff().
set_union(): Returns the union of the sets in....set_intersect(): Returns the intersect of the sets in....set_difference(): Returns the difference of the sets in....
Usage
set_intersect(..., pairs = FALSE)set_union(..., pairs = FALSE)set_difference(..., pairs = FALSE)Arguments
... | A list or a comma-separated list of vectors in the same class. Ifvector contains duplicates they will be discarded. If the list doesn't havenames the sets will be named as |
pairs | Returns the pairwise unions of the sets? Defaults to |
Value
A vector showing the desired operation of the sets. Ifpairs = TRUE, returns a list showing the pairwise operation of the sets.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)(A <- letters[1:4])(B <- letters[2:5])(C <- letters[3:7])set_union(A, B)set_intersect(A, B, C)set_difference(B, C)# Operations with data frames# Add a row id for better understandingsets <- data_ge %>% add_row_id()set_1 <- sets[1:5,]set_2 <- sets[2:6,]set_3 <- sets[3:7,]set_intersect(set_1, set_2, set_3)set_difference(set_2, set_3)set_union(set_1, set_2, set_3)Useful functions for computing descriptive statistics
Description
The following functions compute descriptive statistics by levels ofa factor or combination of factors quickly.
cv_by()For computing coefficient of variation.max_by()For computing maximum values.mean_by()For computing arithmetic means.min_by()For compuing minimum values.n_by()For getting the length.sd_by()For computing sample standard deviation.var_by()For computing sample variance.sem_by()For computing standard error of the mean.
Useful functions for descriptive statistics. All of them worknaturally with
\%>\%, handle grouped data and multiple variables (allnumeric variables from.databy default).av_dev()computes the average absolute deviation.ci_mean_t()computes the t-interval for the mean.ci_mean_z()computes the z-interval for the mean.cv()computes the coefficient of variation.freq_table()Computes a frequency table for either numeric andcategorical/discrete data. For numeric data, it is possible to define thenumber of classes to be generated.hmean(), gmean()computes the harmonic and geometric means,respectively. The harmonic mean is the reciprocal of the arithmetic mean ofthe reciprocals. The geometric mean is thenth root ofnproducts.kurt()computes the kurtosis like used in SAS and SPSS.range_data()Computes the range of the values.n_valid()The valid (notNA) length of a data.n_unique()Number of unique values.n_missing()Number of missing values.row_col_mean(), row_col_sum()Adds a row with the mean/sum ofeach variable and a column with the the mean/sum for each row of the data.sd_amo(), sd_pop()Computes sample and populational standarddeviation, respectively.sem()computes the standard error of the mean.skew()computes the skewness like used in SAS and SPSS.ave_dev()computes the average of the absolute deviations.sum_dev()computes the sum of the absolute deviations.sum_sq()computes the sum of the squared values.sum_sq_dev()computes the sum of the squared deviations.var_amo(), var_pop()computes sample and populational variance.
desc_stat() is wrapper function around the above ones and can beused to compute quickly all these statistics at once.
Usage
av_dev(.data, ..., na.rm = FALSE)ci_mean_t(.data, ..., na.rm = FALSE, level = 0.95)ci_mean_z(.data, ..., na.rm = FALSE, level = 0.95)cv(.data, ..., na.rm = FALSE)freq_table(.data, var, k = NULL, digits = 3)freq_hist( table, xlab = NULL, ylab = NULL, fill = "gray", color = "black", ygrid = TRUE)hmean(.data, ..., na.rm = FALSE)gmean(.data, ..., na.rm = FALSE)kurt(.data, ..., na.rm = FALSE)n_missing(.data, ..., na.rm = FALSE)n_unique(.data, ..., na.rm = FALSE)n_valid(.data, ..., na.rm = FALSE)pseudo_sigma(.data, ..., na.rm = FALSE)range_data(.data, ..., na.rm = FALSE)row_col_mean(.data, na.rm = FALSE)row_col_sum(.data, na.rm = FALSE)sd_amo(.data, ..., na.rm = FALSE)sd_pop(.data, ..., na.rm = FALSE)sem(.data, ..., na.rm = FALSE)skew(.data, ..., na.rm = FALSE)sum_dev(.data, ..., na.rm = FALSE)ave_dev(.data, ..., na.rm = FALSE)sum_sq_dev(.data, ..., na.rm = FALSE)sum_sq(.data, ..., na.rm = FALSE)var_pop(.data, ..., na.rm = FALSE)var_amo(.data, ..., na.rm = FALSE)cv_by(.data, ..., .vars = NULL, na.rm = FALSE)max_by(.data, ..., .vars = NULL, na.rm = FALSE)min_by(.data, ..., .vars = NULL, na.rm = FALSE)means_by(.data, ..., .vars = NULL, na.rm = FALSE)mean_by(.data, ..., .vars = NULL, na.rm = FALSE)n_by(.data, ..., .vars = NULL, na.rm = FALSE)sd_by(.data, ..., .vars = NULL, na.rm = FALSE)var_by(.data, ..., .vars = NULL, na.rm = FALSE)sem_by(.data, ..., .vars = NULL, na.rm = FALSE)sum_by(.data, ..., .vars = NULL, na.rm = FALSE)Arguments
.data | A data frame or a numeric vector. |
... | The argument depends on the function used.
|
na.rm | If |
level | The confidence level for the confidence interval of the mean.Defaults to 0.95. |
var | The variable to compute the frequency table. See |
k | The number of classes to be created. See |
digits | The number of significant figures to show. Defaults to 2. |
table | A frequency table computed with |
xlab,ylab | The |
fill,color | The color to fill the bars and color the border of the bar,respectively. |
ygrid | Shows a grid line on the |
.vars | Used to select variables in the |
Details
The functionfreq_table() computes a frequency table for eithernumerical or categorical variables. If a variable is categorical ordiscrete (integer values), the number of classes will be the number oflevels that the variable contains.
If a variable (say, data) is continuous, the number of classes (k) is given bythe square root of the number of samples (n) ifn =< 100 or5 * log10(n)ifn > 100.
The amplitude (\(A\)) of the data is used to define the size of the class (\(c\)),given by
\[c = \frac{A}{n - 1}\]The lower limit of the first class (LL1) is given by min(data) - c / 2. Theupper limit is given by LL1 + c. The limits of the other classes are given inthe same way. After the creation of the classes, the absolute and relativefrequencies within each class are computed.
Value
Functions
*_by()returns atbl_dfwith the computed statistics byeach level of the factor(s) declared in....All other functions return a named integer if the input is a data frameor a numeric value if the input is a numeric vector.
freq_table()Returns a list with the frequency table and the breaks usedfor class definition. These breaks can be used to construct an histogram ofthe variable.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Ferreira, Daniel Furtado. 2009. Estatistica Basica. 2 ed. Vicosa,MG: UFLA.
Examples
library(metan)# means of all numeric variables by ENVmean_by(data_ge2, GEN, ENV)# Coefficient of variation for all numeric variables# by GEN and ENVcv_by(data_ge2, GEN, ENV)# Skewness of a numeric vectorset.seed(1)nvec <- rnorm(200, 10, 1)skew(nvec)# Confidence interval 0.95 for the mean# All numeric variables# Grouped by levels of ENVdata_ge2 %>% group_by(ENV) %>% ci_mean_t()# standard error of the mean# Variable PH and EHsem(data_ge2, PH, EH)# Frequency table for variable NRdata_ge2 %>% freq_table(NR)Set and get the Working Directory quicky
Description
get_wd_here()gets the working directory to the path of the current script.set_wd_here()sets the working directory to the path of the current script.open_wd_here()Open the File Explorer at the directory path of the current script.open_wd()Open the File Explorer at the current working directory.
Usage
set_wd_here(path = NULL)get_wd_here(path = NULL)open_wd_here(path = get_wd_here())open_wd(path = getwd())Arguments
path | Path components below the project root. Defaults to |
Value
get_wd_here()returns a full-path directory name.get_wd_here()returns a message showing the current working directory.open_wd_here()Opens the File Explorer of the path returned byget_wd_here().
Examples
## Not run: get_wd_here()set_wd_here()open_wd_here()## End(Not run)Draw Venn diagrams
Description
Produces ggplot2-based Venn plots for 2, 3 or 4 sets. A Venn diagram showsall possible logical relationships between several sets of data.
Usage
venn_plot( ..., names = NULL, show_elements = FALSE, split_labels = FALSE, split_each = 4, show_sets = FALSE, fill = ggplot_color(4), alpha = 0.5, stroke_color = "white", stroke_alpha = 1, stroke_size = 1, stroke_linetype = "solid", name_color = "black", name_size = 6, text_color = "black", text_size = 4, label_sep = ",")Arguments
... | A list or a comma-separated list of vectors in the same class. Ifvector contains duplicates they will be discarded. If the list doesn't havenames the sets will be named as |
names | By default, the names of the sets are set as the names of theobjects in |
show_elements | Show set elements instead of count. Defaults to |
split_labels | Splits the element labels into new lines each |
split_each | The number of elements that will apper in each line when |
show_sets | Show set names instead of count. Defaults to |
fill | Filling colors in circles. Defaults to the default ggplot2 colorpalette. A vector of length 1 will be recycled. |
alpha | Transparency for filling circles. Defaults to |
stroke_color | Stroke color for drawing circles. |
stroke_alpha | Transparency for drawing circles. |
stroke_size | Stroke size for drawing circles. |
stroke_linetype | Line type for drawing circles. Defaults to |
name_color | Text color for set names. Defaults to |
name_size | Text size for set names. |
text_color | Text color for intersect contents. |
text_size | Text size for intersect contents. |
label_sep | The separator for labs when |
Value
A ggplot object.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
Examples
library(metan)(A <- letters[1:4])(B <- letters[2:5])(C <- letters[3:7])(D <- letters[4:12])# create a Venn plotvenn_plot(A, B)# Three setsvenn_plot(A, B, C)# Four setsvenn_plot(A, B, C, D)# Use a listdfs <- list(A = A, B = B, C = C, D = D)venn_plot(dfs, show_elements = TRUE, fill = c("red", "blue", "green", "gray"), stroke_color = "black", alpha = 0.8, text_size = 8, label_sep = ".")Weighted Average of Absolute Scores
Description
Compute the Weighted Average of Absolute Scores for AMMI analysis (Olivoto etal., 2019).
This function compute the weighted average of absolute scores, estimated asfollows:\[WAAS_i = \sum_{k = 1}^{p} |IPCA_{ik} \times EP_k|/ \sum_{k =1}^{p}EP_k\]
where \(WAAS_i\) is the weighted average of absolute scores of theith genotype; \(IPCA_{ik}\) is the score of theith genotypein thekth IPCA; and \(EP_k\) is the explained variance of thekthIPCA fork = 1,2,..,p, consideringp the number of significantPCAs, or a declared number of PCAs. For example ifprob = 0.05, allaxis that are significant considering this probability level are used. Thenumber of axis can be also informed by declaringnaxis = x. This willoverride the number of significant axes according to the argumentprob.
Usage
waas( .data, env, gen, rep, resp, block = NULL, mresp = NULL, wresp = NULL, prob = 0.05, naxis = NULL, ind_anova = FALSE, verbose = TRUE)Arguments
.data | The dataset containing the columns related to Environments,Genotypes, replication/block and response variable(s). |
env | The name of the column that contains the levels of theenvironments. |
gen | The name of the column that contains the levels of the genotypes. |
rep | The name of the column that contains the levels of thereplications/blocks. |
resp | The response variable(s). To analyze multiple variables in asingle procedure a vector of variables may be used. For example |
block | Defaults to |
mresp | The new maximum value after rescaling the response variable. Bydefault, all variables in |
wresp | The weight for the response variable(s) for computing the WAASBYindex. By default, all variables in |
prob | The p-value for considering an interaction principal componentaxis significant. |
naxis | The number of IPCAs to be used for computing the WAAS index.Default is |
ind_anova | Logical argument set to |
verbose | Logical argument. If |
Value
An object of classwaas with the following items for eachvariable:
individual A within-environments ANOVA considering a fixed-effectmodel.
model A data frame with the response variable, the scores of allPrincipal Components, the estimates of Weighted Average of Absolute Scores,and WAASY (the index that consider the weights for stability and productivityin the genotype ranking.
MeansGxE The means of genotypes in the environments
PCA Principal Component Analysis.
ANOVA Joint analysis of variance for the main effects andPrincipal Component analysis of the interaction effect.
Details A list summarizing the results. The following informationare showed.
WgtResponse, the weight for the response variable inestimating WAASB,WgtWAASthe weight for stability,Ngenthenumber of genotypes,Nenvthe number of environments,OVmeanthe overall mean,Minthe minimum observed (returning the genotype andenvironment),Maxthe maximum observed,Maxthe maximumobserved,MinENVthe environment with the lower mean,MaxENVthe environment with the larger mean observed,MinGENthe genotypewith the lower mean,MaxGENthe genotype with the larger.augment: Information about each observation in the dataset. Thisincludes predicted values in the
fittedcolumn, residuals in theresidcolumn, standardized residuals in thestdrescolumn,the diagonal of the 'hat' matrix in thehat, and standard errors forthe fitted values in these.fitcolumn.probint The p-value for the genotype-vs-environment interaction.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Olivoto, T., A.D.C. Lúcio, J.A.G. da silva, V.S. Marchioro,V.Q. de Souza, and E. Jost. 2019a. Mean performance and stability inmulti-environment trials I: Combining features of AMMI and BLUP techniques.Agron. J. 111:2949-2960.doi:10.2134/agronj2019.03.0220
See Also
waas_means()waasb()get_model_data()
Examples
library(metan)#===============================================================## Example 1: Analyzing all numeric variables considering p-value## <= 0.05 to compute the WAAS. ##===============================================================#model <- waas(data_ge, env = ENV, gen = GEN, rep = REP, resp = everything())# Residual plot (first variable)plot(model)# Get the WAAS indexget_model_data(model, "WAAS")# Plot WAAS and response variableplot_scores(model, type = 3)#===============================================================## Example 2: Declaring the number of axis to be used for ## computing WAAS and assigning a larger weight for the response ## variable when computing the WAASBY index. ##===============================================================#model2 <- waas(data_ge, env = ENV, gen = GEN, rep = REP, resp = everything(), naxis = 1, # Only to compare with PC1 wresp = 60)# Get the WAAS index (it will be |PC1|)get_model_data(model2)# Get values for IPCA1get_model_data(model2, "PC1")#===============================================================## Example 3: Analyzing GY and HM assuming a random-effect model.## Smaller values for HM and higher values for GY are better. ## To estimate WAASBY, higher weight for the GY (60%) and lower ## weight for HM (40%) are considered for mean performance. ##===============================================================#model3 <- waas(data_ge, env = ENV, gen = GEN, rep = REP, resp = c(GY, HM), mresp = c("h, l"), wresp = c(60, 40))# Get the ranks for the WAASY indexget_model_data(model3, what = "OrWAASY")Weighted Average of Absolute Scores
Description
Compute the Weighted Average of Absolute Scores (Olivoto et al., 2019) basedon means for genotype-environment data as follows:\[WAAS_i = \sum_{k = 1}^{p} |IPCA_{ik} \times EP_k|/ \sum_{k =1}^{p}EP_k\]
where \(WAAS_i\) is the weighted average of absolute scores of theith genotype; \(PCA_{ik}\) is the score of theith genotypein thekth IPCA; and \(EP_k\) is the explained variance of thekthIPCA fork = 1,2,..,p, wherep is the number of IPCAs thatexplain at least an amount of the genotype-interaction variance declared inthe argumentmin_expl_var.
Usage
waas_means( .data, env, gen, resp, mresp = NULL, wresp = NULL, min_expl_var = 85, verbose = TRUE, ...)Arguments
.data | The dataset containing the columns related to Environments,Genotypes, replication/block and response variable(s). |
env | The name of the column that contains the levels of theenvironments. |
gen | The name of the column that contains the levels of the genotypes. |
resp | The response variable(s). To analyze multiple variables in asingle procedure a vector of variables may be used. For example |
mresp | The new maximum value after rescaling the response variable. Bydefault, all variables in |
wresp | The weight for the response variable(s) for computing the WAASBYindex. Must be a numeric vector of the same length of |
min_expl_var | The minimum explained variance. Defaults to 85.Interaction Principal Compoment Axis are iteractively retained up to theexplained variance (eigenvalues in the singular value decomposition of thematrix with the interaction effects) be greather than or equal to |
verbose | Logical argument. If |
... | Arguments passed to the function |
Value
An object of classwaas_means with the following items for eachvariable:
model A data frame with the response variable, the scores of allPrincipal Components, the estimates of Weighted Average of Absolute Scores,and WAASY (the index that consider the weights for stability and productivityin the genotype ranking.
ge_means A tbl_df containing the genotype-environment means.
ge_eff Agxe matrix containing the genotype-environment effects.
eigenvalues The eigenvalues from the singular value decompositionof the matrix withe the genotype-environment interaction effects.
proportion The proportion of the variance explained by each IPCA.
cum_proportion The cumulative proportion of the variance explained.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Olivoto, T., A.D.C. Lúcio, J.A.G. da silva, V.S. Marchioro, V.Q. deSouza, and E. Jost. 2019a. Mean performance and stability inmulti-environment trials I: Combining features of AMMI and BLUP techniques.Agron. J. 111:2949-2960.doi:10.2134/agronj2019.03.0220
See Also
Examples
library(metan)# Data with replicatesmodel <- waas(data_ge, env = ENV, gen = GEN, rep = REP, resp = everything())# Based on means of genotype-environment datadata_means <- mean_by(data_ge, ENV, GEN)model2 <- waas_means(data_ge, env = ENV, gen = GEN, resp = everything())# The index WAASget_model_data(model, what = "OrWAAS")get_model_data(model2, what = "OrWAAS")Weighted Average of Absolute Scores
Description
Compute the Weighted Average of Absolute Scores (Olivoto et al., 2019) forquantifying the stability ofg genotypes conducted ineenvironments using linear mixed-effect models.
The weighted average of absolute scores is computed considering allInteraction Principal Component Axis (IPCA) from the Singular ValueDecomposition (SVD) of the matrix of genotype-environment interaction (GEI)effects generated by a linear mixed-effect model, as follows:\[WAASB_i = \sum_{k = 1}^{p} |IPCA_{ik} \times EP_k|/ \sum_{k =1}^{p}EP_k\]
where \(WAASB_i\) is the weighted average of absolute scores of theith genotype; \(IPCA_{ik}\) is the score of theith genotype in thekth Interaction Principal Component Axis (IPCA); and \(EP_k\) is theexplained variance of thekth IPCA fork = 1,2,..,p, considering\(p = min(g - 1; e - 1)\).
The nature of the effects in the model ischosen with the argumentrandom. By default, the experimental designconsidered in each environment is a randomized complete block design. Ifblock is informed, a resolvable alpha-lattice design (Patterson andWilliams, 1976) is implemented. The following six models can be fitteddepending on the values ofrandom andblock arguments.
Model 1:
block = NULLandrandom = "gen"(Thedefault option). This model considers a Randomized Complete Block Design ineach environment assuming genotype and genotype-environment interaction asrandom effects. Environments and blocks nested within environments areassumed to fixed factors.Model 2:
block = NULLandrandom = "env". Thismodel considers a Randomized Complete Block Design in each environmenttreating environment, genotype-environment interaction, and blocks nestedwithin environments as random factors. Genotypes are assumed to be fixedfactors.Model 3:
block = NULLandrandom = "all". Thismodel considers a Randomized Complete Block Design in each environmentassuming a random-effect model, i.e., all effects (genotypes, environments,genotype-vs-environment interaction and blocks nested within environments)are assumed to be random factors.Model 4:
blockis notNULLandrandom = "gen". This model considers an alpha-lattice design in each environmentassuming genotype, genotype-environment interaction, and incomplete blocksnested within complete replicates as random to make use of inter-blockinformation (Mohring et al., 2015). Complete replicates nested withinenvironments and environments are assumed to be fixed factors.Model 5:
blockis notNULLandrandom = "env". This model considers an alpha-lattice design in each environmentassuming genotype as fixed. All other sources of variation (environment,genotype-environment interaction, complete replicates nested withinenvironments, and incomplete blocks nested within replicates) are assumedto be random factors.Model 6:
blockis notNULLandrandom = "all". This model considers an alpha-lattice design in each environmentassuming all effects, except the intercept, as random factors.
Usage
waasb( .data, env, gen, rep, resp, block = NULL, by = NULL, mresp = NULL, wresp = NULL, random = "gen", prob = 0.05, ind_anova = FALSE, verbose = TRUE, ...)Arguments
.data | The dataset containing the columns related to Environments,Genotypes, replication/block and response variable(s). |
env | The name of the column that contains the levels of theenvironments. |
gen | The name of the column that contains the levels of the genotypes. |
rep | The name of the column that contains the levels of thereplications/blocks. |
resp | The response variable(s). To analyze multiple variables in asingle procedure a vector of variables may be used. For example |
block | Defaults to |
by | One variable (factor) to compute the function by. It is a shortcutto |
mresp | The new maximum value after rescaling the response variable. Bydefault, all variables in |
wresp | The weight for the response variable(s) for computing the WAASBYindex. By default, all variables in |
random | The effects of the model assumed to be random. Defaults to |
prob | The probability for estimating confidence interval for BLUP'sprediction. |
ind_anova | Logical argument set to |
verbose | Logical argument. If |
... | Arguments passed to the function |
Value
An object of classwaasb with the following items for eachvariable:
individual A within-environments ANOVA considering afixed-effect model.
fixed Test for fixed effects.
random Variance components for random effects.
LRT The Likelihood Ratio Test for the random effects.
model A tibble with the response variable, the scores of allIPCAs, the estimates of Weighted Average of Absolute Scores, and WAASBY (theindex that considers the weights for stability and mean performance in thegenotype ranking), and their respective ranks.
BLUPgen The random effects and estimated BLUPS for genotypes (If
random = "gen"orrandom = "all")BLUPenv The random effects and estimated BLUPS for environments,(If
random = "env"orrandom = "all").BLUPint The random effects and estimated BLUPS of all genotypes inall environments.
PCA The results of Principal Component Analysis with theeigenvalues and explained variance of the matrix of genotype-environmenteffects estimated by the linear fixed-effect model.
MeansGxE The phenotypic means of genotypes in the environments.
Details A list summarizing the results. The following informationare shown:
Nenv, the number of environments in the analysis;Ngenthe number of genotypes in the analysis;mrespThe valueattributed to the highest value of the response variable after rescaling it;wrespThe weight of the response variable for estimating the WAASBYindex.Meanthe grand mean;SEthe standard error of the mean;SDthe standard deviation.CVthe coefficient of variation ofthe phenotypic means, estimating WAASB,Minthe minimum value observed(returning the genotype and environment),Maxthe maximum valueobserved (returning the genotype and environment);MinENVtheenvironment with the lower mean,MaxENVthe environment with thelarger mean observed,MinGENthe genotype with the lower mean,MaxGENthe genotype with the larger.ESTIMATES A tibble with the genetic parameters (if
random = "gen"orrandom = "all") with the following columns:Phenotypic variancethe phenotypic variance;Heritabilitythe broad-senseheritability;GEr2the coefficient of determination of the interactioneffects;h2mgthe heritability on the mean basis;Accuracythe selective accuracy;rgethe genotype-environmentcorrelation;CVgthe genotypic coefficient of variation;CVrthe residual coefficient of variation;CV ratiothe ratio betweengenotypic and residual coefficient of variation.residuals The residuals of the model.
formula The formula used to fit the model.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Olivoto, T., A.D.C. Lúcio, J.A.G. da silva, V.S. Marchioro, V.Q. deSouza, and E. Jost. 2019. Mean performance and stability in multi-environmenttrials I: Combining features of AMMI and BLUP techniques. Agron. J.111:2949-2960.doi:10.2134/agronj2019.03.0220
Mohring, J., E. Williams, and H.-P. Piepho. 2015. Inter-block information: torecover or not to recover it? TAG. Theor. Appl. Genet. 128:1541-54.doi:10.1007/s00122-015-2530-0
Patterson, H.D., and E.R. Williams. 1976. A new class of resolvableincomplete block designs. Biometrika 63:83-92.
See Also
mtsi()waas()get_model_data()plot_scores()
Examples
library(metan)#===============================================================## Example 1: Analyzing all numeric variables assuming genotypes ## as random effects with equal weights for mean performance and ## stability ##===============================================================#model <- waasb(data_ge, env = ENV, gen = GEN, rep = REP, resp = everything())# Genetic parametersget_model_data(model, "genpar")#===============================================================## Example 2: Analyzing variables that starts with "N" ## assuming environment as random effects with higher weight for ## response variable (65) for the three traits. ##===============================================================#model2 <- waasb(data_ge2, env = ENV, gen = GEN, rep = REP, random = "env", resp = starts_with("N"), wresp = 65)# Get the index WAASBYget_model_data(model2, what = "WAASBY")#===============================================================## Example 3: Analyzing GY and HM assuming a random-effect model.## Smaller values for HM and higher values for GY are better. ## To estimate WAASBY, higher weight for the GY (60%) and lower ## weight for HM (40%) are considered for mean performance. ##===============================================================#model3 <- waasb(data_ge, env = ENV, gen = GEN, rep = REP, resp = c(GY, HM), random = "all", mresp = c("h, l"), wresp = c(60, 40))# Plot the scores (response x WAASB)plot_scores(model3, type = 3)Weighting between stability and mean performance
Description
This function computes the WAASY or WAASBY indexes (Olivoto et al., 2019)considering different scenarios of weights for stability and meanperformance.
After fitting a model with the functionswaas() orwaasb() it is possible to compute the superiority indexes WAASYor WAASBY in different scenarios of weights for stability and meanperformance. The number of scenarios is defined by the argumentsincrement. By default, twenty-one different scenarios are computed. Inthis case, the the superiority index is computed considering the followingweights: stability (waasb or waas) = 100; mean performance = 0. In otherwords, only stability is considered for genotype ranking. In the nextiteration, the weights becomes 95/5 (since increment = 5). In the thirdscenario, the weights become 90/10, and so on up to these weights become0/100. In the last iteration, the genotype ranking for WAASY or WAASBYmatches perfectly with the ranks of the response variable.
Usage
wsmp( model, mresp = 100, increment = 5, saveWAASY = 50, prob = 0.05, progbar = TRUE)Arguments
model | |
mresp | A numeric value that will be the new maximum value afterrescaling. By default, the variable in |
increment | The increment in the weight ratio for stability and meanperformance. Se theDetails section for more information. |
saveWAASY | Automatically save the WAASY values when the weight forstability is |
prob | The p-value for considering an interaction principal componentaxis significant. must be multiple of |
progbar | A logical argument to define if a progress bar is shown.Default is |
Value
An object of classwsmp with the following items for eachvariable
When computed with
waas()orwaasb().scenarios A list with the model for all computed scenarios.
WAASY The values of the WAASY estimated when the weight for thestability in the loop match with argument
saveWAASY.hetdata, hetcomb The data used to produce the heatmaps.
Ranks All the values of WAASY estimated in the differentscenarios of WAAS/GY weighting ratio.
When computed with
mps()hetcomb showing the rank for mean performance and stability in the different weights.
Author(s)
Tiago Olivototiagoolivoto@gmail.com
References
Olivoto, T., A.D.C. Lúcio, J.A.G. da silva, V.S. Marchioro, V.Q. deSouza, and E. Jost. 2019. Mean performance and stability in multi-environmenttrials I: Combining features of AMMI and BLUP techniques. Agron. J.doi:10.2134/agronj2019.03.0220
See Also
Examples
library(metan)# using the WAASB as statistic and BLUP as mean performance# the same as using waasb()model <- mps(data_ge2, env = ENV, gen = GEN, rep = REP, resp = PH)scenarios <- wsmp(model)