Movatterモバイル変換


[0]ホーム

URL:


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 OlivotoORCID iD [aut, cre, cph]
Repository:CRAN
Date/Publication:2024-12-15 01:00:02 UTC

Pipe operator

Description

See⁠magrittr::[\%>\%][magrittr::pipe]⁠ for details.

Usage

lhs %>% rhs

Annicchiarico's genotypic confidence index

Description

[Stable]

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,resp = c(var1, var2, var3).

prob

The probability of error assumed.

verbose

Logical argument. Ifverbose = FALSE the code will runsilently.

Value

A list where each element is the result for one variable and contains thefollowing data frames:

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

[Stable]

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,resp = c(var1, var2, var3).

verbose

Logical argument. Ifverbose = FALSE the code will runsilently.

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.

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

[Stable]

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,resp = c(var1, var2, var3).

verbose

Logical argument. Ifverbose = FALSE the code will runsilently.

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.

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

[Stable]

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,resp = c(var1, var2, var3).

prob

The probability of error assumed.

verbose

Logical argument. Ifverbose = FALSE the code will runsilently.

Value

A list where each element is the result for one variable and contains thefollowing data frames:

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.

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. Forwidth_of() theselected variables containsn characters. Forwidth_greater_than() andwidth_less_than() the selectedvariables contains greater and less characteres thann,respectively.

vars

A character vector of variable names. When called from insideselecting functions likeselect_cols() these are automaticallyset to the names of the table.

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

[Stable]

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,resp = c(var1, var2, var3).

verbose

Logical argument. Ifverbose = FALSE the code will runsilently.

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.

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

[Stable]

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 functiongamem(). Please, seeDetails for more details.

use_data

Define which data to use If.data is an object ofclassgamem. Defaults to"blup" (the BLUPs for genotypes).Use"pheno" to use phenotypic means instead BLUPs for computing theindex.

pcov,gcov

The phenotypic and genotypic variance-covariance matrix,respectively. Defaults toNULL. If a two-way table is informed in.data these matrices are mandatory.

SI

The selection intensity (percentage). Defaults to20

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:

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

mtsi(),mgidi(),fai_blup()

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

[Stable]

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,resp = c(var1, var2, var3).

verbose

Logical argument. Ifverbose = FALSE the code will runsilently.

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

[Stable]

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

IfFALSE, the default, missing values are removed with awarning. IfTRUE, missing values are silently removed.

Value

A tibble with the following columns

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

Usage

ammi_indexes(.data, order.y = NULL, level = 0.95)

Arguments

.data

An object of classwaas orperforms_ammi

order.y

A vector of the same length ofx used to order theresponse variable. Each element of the vector must be one of the'h'or'l'. If'h' is used, the response variable will be orderedfrom maximum to minimum. If'l' is used then the response variablewill be ordered from minimum to maximum. Use a comma-separated vector ofnames. For example,order.y = c("h, h, l, h, l").

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.

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

[Stable]

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 exampleresp = c(var1, var2, var3).

block

Defaults toNULL. In this case, a randomized completeblock design is considered. If block is informed, then a resolvablealpha-lattice design (Patterson and Williams, 1976) is employed.All effects, except the error, are assumed to be fixed.

verbose

Logical argument. Ifverbose = FALSE the code will runsilently.

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

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

[Stable]

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 exampleresp = c(var1, var2, var3).

block

Defaults toNULL. In this case, a randomized completeblock design is considered. If block is informed, then a resolvablealpha-lattice design (Patterson and Williams, 1976) is employed.All effects, except the error, are assumed to be fixed.

verbose

Logical argument. Ifverbose = FALSE the code will runsilently.

Value

A list where each element is the result for one variable containingthe following objects:

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

get_model_data()anova_ind()

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

[Experimental]

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

...

multipleggplots or a list containingggplotobjects.

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'auto'. Other possible values are'keep' and'collect'.In this case, will collect guides below to the given nesting level,removing duplicates.

design

Specification of the location of areas in the layout.

legend.position

The position of the legends in the plot ifguides = "collect" Default to'bottom'.

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'a' for lowercase letters,'A' foruppercase letters,'1' for numbers,'i' for lowercase Roman numerals, and'I' for uppercase Roman numerals. It can also be a list containingcharacter vectors defining arbitrary tag sequences. If any element in thelist is a scalar and one of'a','A','1','i', or'I', this levelwill be expanded to the expected sequence.

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

[Stable]

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

[Stable]

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 forplot_bars() The variables to be mappedto thex andy axes, respectively.

order

Argument valid forplot_bars(). Controls the order of thefactor in thex axis. Defaults to the order of the factors in.data. Useorder = "asce" ororder = "desc" to reorderthe labels to ascending or descending order, respectively, based on thevalues of the variabley.

y.lim

The range of y axis. Defaults toNULL (maximum andminimum values of the data set). New values can be inserted asy.lim = c(y.min, y.max).

y.breaks

The breaks to be plotted in the y-axis. Defaults to waiver().⁠authomatic breaks⁠. The same arguments thanx.breaks can beused.

y.expand,y.contract

A multiplication range expansion/contractionfactor.y.expand expands the upper limit of the y escale, whiley.contract contracts the lower limit of the y scale. By defaulty.expand = 0.05 andy.contract = 0 produces a plot withoutspacing in the lower y limit and an expansion in the upper y limit.

xlab,ylab

The labels of the axes x and y, respectively. Defaults toNULL.

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 forplot_bars(). The color andfill values of the bars.

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 withlab.bar.hjust andlab.bar.vjust to bestfit the labels in the plot.

size.text.bar

The size of the text in the bar labels.

values

Logical argument. Shows the values in the plot bar?Defaults toFALSE

values.hjust,values.vjust

The horizontal and vertical adjustfor the values in the bar. Defaults to 0.5 and 1.5, respectively. Ifvalues = TRUE the values are shown bellow the error bar.

values.angle

The angle for the labels in the plot. Defaults to 0.Use in combination withvalues.hjust andvalues.vjustto best fit the values in the plot bar.

values.digits

The significant digits to show ifvalues = TRUE. Defaults to2.

values.size

The size of the text for values shown in the bars.Defaults to3.

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 withlab.x.hjust andlab.x.vjust to bestfit the labels in the axis.

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 ofthestat.erbar = "se" (standard error, default),stat.erbar = "sd" (standard deviation), orstat.erbar = "ci" (confidenceinterval), based on the confidence level in the argumentlevel.

width.erbar

The width of the error bar. Defaults to 25% ofwidth.bar.

level

The confidence level

invert

Logical argument. IfTRUE, rotate the plot inplot_bars() and invert the order of the factors inplot_factbars().

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 to0.5.

size.text

The size of the text. Default to12.

fontfam

The family of the font text. Defaults to"sans".

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 isplot_theme = theme_metan(). For more details, seeggplot2::theme().

...

Argument valid forplot_factbars(). A comma-separated listof unquoted variable names. Sets the two variables to be mapped to thex axis.

resp

Argument valid forplot_factbars(). The response variableto be mapped to the y axis.

col

Logical argument valid forplot_factbars(). IfFALSE, a gray scale is used.

palette

Argument valid forplot_factbars() The color palette tobe used. For more details, see?scale_colour_brewer

legend.position

The position of the legend in the plot.

Value

An object of class⁠gg, ggplot⁠.

Author(s)

Tiago Olivototiagoolivoto@gmail.com

See Also

plot_lines(),plot_factlines()

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

[Stable]

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 classcv_ammi,cv_ammif orcv_blup.

bind

What data should be used? To plot the RMSPD, use 'boot'(default). Usebind = 'means' to return the RMSPD mean for eachmodel.

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

[Stable]

Usage

hmgv(model)rpgv(model)hmrpgv(model)blup_indexes(model)

Arguments

model

An object of classwaasb computed withwaasb() orgamem_met().

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

[Stable]

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 fromdplyr::group_by().

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 shortcuttodplyr::group_by(). To compute the statistics by more thanone grouping variable use that function.

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. IfTRUE (default) then the resultsare shown in the console.

collinearity

Logical argument. IfTRUE (default) then acollinearity diagnostic is performed for each group of variables accordingto Olivoto et al.(2017).

Value

If.data is a grouped data passed fromdplyr::group_by() then the results will be returned into alist-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

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

[Stable]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 fromdplyr::group_by().

...

The variables in.data to compute the distances. Set toNULL, i.e., all the numeric variables in.data are used.

by

One variable (factor) to compute the function by. It is a shortcuttodplyr::group_by(). To compute the statistics by more thanone grouping variable use that function.

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 toFALSE. IfTRUE, then analgorithm for selecting variables is implemented. See the sectionDetails for additional information.

verbose

Logical argument. IfTRUE (default) then the resultsfor variable selection are shown in the console.

distmethod

The distance measure to be used. This must be one of'euclidean','maximum','manhattan','canberra','binary','minkowski','pearson','spearman', or'kendall'. The last three arecorrelation-based distance.

clustmethod

The agglomeration method to be used. This should be one of'ward.D','ward.D2','single','complete','average' (= UPGMA),'mcquitty' (= WPGMA),'median' (=WPGMC) or'centroid' (= UPGMC).

nclust

The number of clusters to be formed. Set toNA

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.

  1. compute the distance matrix and the cophenetic correlation with the originalvariables (all numeric variables in dataset);

  2. compute the eigenvalues and eigenvectors of the correlation matrix betweenthe variables;

  3. Delete the variable with the largest weight (highest eigenvector inthe lowest eigenvalue);

  4. Compute the distance matrix and cophenetic correlation with the remainingvariables;

  5. Compute the Mantel's correlation between the obtained distances matrix andthe original distance matrix;

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

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

[Stable]

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 classmgidi,mtsifai_blup, orsh. When a model is informed, thenthe selected genotypes are extracted automatically.

total

The total number of genotypes in the study.

sel1,sel2

The selected genotypes by the method 1 and 2, respectively. Defaults toNULL.

Value

A list with the following elements:

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

[Stable]

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 fromdplyr::group_by().

...

Variables to use in the correlation. If... is null thenall the numeric variables from.data are used. It must be a singlevariable name or a comma-separated list of unquoted variables names.

by

One variable (factor) to compute the function by. It is a shortcuttodplyr::group_by(). To compute the statistics by more thanone grouping variable use that function.

n

If a correlation matrix is provided, thenn is the number ofobjects used to compute the correlation coefficients.

Value

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

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

[Stable]

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. Defaultisorder = 'first'. In this case, assuming that .data has fourcolumns, namely,⁠V1, V2, V3, V4⁠, the order of columns in the outputwill be⁠V1.V2, V1.V3, V1.V4, V2.V3, V2.V4, V3.V4⁠. Iforder = 'second', the result will be then⁠V1.V2, V1.V3, V2.V3, V1.V4, V2.V4, V3.V4⁠.

FUN

The function that will be applied to each combination. The defaultis+, i.e., V1 + V2.

verbose

Logical argument. Ifverbose = FALSE the code will runsilently.

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

[Stable]

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 fromdplyr::group_by()) or a symmetric correlationmatrix.

...

Variables to compute the confidence interval. If not informed, allthe numeric variables from.data are used.

r

Ifdata is not available, provide the value for correlationcoefficient.

n

The sample size ifdata is a correlation matrix or if r isinformed.

by

One variable (factor) to compute the function by. It is a shortcuttodplyr::group_by(). To compute the statistics by more thanone grouping variable use that function.

sel.var

A variable to shows the correlation with. This will omit allthe pairwise correlations that doesn't containsel.var.

verbose

Ifverbose = TRUE then some results are shown in theconsole.

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

Linear 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 fromdplyr::group_by().

...

Variables to use in the correlation. If no variable is informedall the numeric variables fromdata are used.

type

The type of correlation to be computed. Defaults to"linear".Usetype = "partial" to compute partial correlation.

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 shortcuttodplyr::group_by().This is especially useful, for example,to compute correlation matrices by levels of a factor.

verbose

Logical argument. Ifverbose = FALSE the code is runsilently.

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$cor

Focus 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 withcorr_coef() or a symmetric matrix, oftenproduced withstats::cor().

...

One or more unquoted variable name separated by commas. Variablenames can be used as if they were positions in the data frame, soexpressions likex:y can be used to select a range of variables.

Value

A tibble

Examples

corr_coef(data_ge2) |> corr_focus(PH)

Visualization of a correlation matrix

Description

[Stable]

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.data has factor-columns, these columns will be deletedwith a warning message.

...

Variables to use in the correlation. If no variable is informedall the numeric variables from.data are used.

col.by

A categorical variable to map the color of the points by.Defaults toNULL.

upper

The visualization method for the upper triangular correlationmatrix. Must be one of'corr' (numeric values),'scatter'(the scatterplot for each pairwise combination), orNULL to set ablank diagonal.

lower

The visualization method for the lower triangular correlationmatrix. Must be one of'corr' (numeric values),'scatter'(the scatterplot for each pairwise combination), orNULL to set ablank diagonal.

decimal.mark

The decimal mark. Defaults to".".

axis.labels

Should the axis labels be shown in the plot? Set toFALSE.

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 ifaxis.labels = TRUE. Defaults to 12.

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⁠diag TRUE⁠. It must be one of the 'histogram' (to show an histogram), 'density'to show the Kernel density, or 'boxplot' (to show a boxplot).

bins

The number of bins, Defaults to 20.

col.diag

Ifdiag = TRUE thendiagcol is the color forthe distribution. Set to gray.

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'tr', i.e., the legends will appear in the top and right of theplot. Other allowed options are'tl' (top and left),'br'(bottom and right),'bl' (bottom and left).

progress

NULL (default) for a progress bar in interactivesessions with more than 15 plots,TRUE for a progress bar,FALSE for no progress bar.

smooth

Should a linear smooth line be shown in the scatterplots? SettoFALSE.

col.smooth

The color for the smooth line.

confint

Should a confidence band be shown with the smooth line? Set toTRUE.

size.point

The size of the points in the plot. Set to0.5.

shape.point

The shape of the point, set to1.

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

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. IfTRUE, then the plot is exported tothe current directory.

file.type

The format of the file ifexport = TRUE. Set to'pdf'. Other possible values are⁠*.tiff⁠ usingfile.type = 'tiff'.

file.name

The name of the plot when exported. Set toNULL,i.e., automatically.

width

The width of the plot, set to8.

height

The height of the plot, set to7.

resolution

The resolution of the plot iffile.type = 'tiff' isused. Set to300 (300 dpi).

Value

An object of class⁠gg, 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

[Stable]

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. Ifverbose = FALSE the code is runsilently.

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

[Stable]

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

stats

The statistics to compute the correlation. See the sectionDetails for more information.

plot

Plot the heat map with the correlations? Defaults toTRUE.

...

Other arguments to be passed to the functionplot.corr_coef().

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

[Experimental]

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. Useoperation to define which operation isused.

operation

The operation to be applied to theconstant value.

x

An optional vector of the same length ofy. If not informed(default) then a normally distributed variable (mean = 0, sd = 1) will beused.

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

[Stable]

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 fromdplyr::group_by().

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 exampleresp = c(var1, var2, var3).

design

The experimental design. Must be RCBD or CRD.

by

One variable (factor) to compute the function by. It is a shortcuttodplyr::group_by(). To compute the statistics by more thanone grouping variable use that function.

type

What the matrices should return? Set toNULL, i.e., a listof matrices is returned. The argument type allow the following values⁠'pcor', 'gcor', 'rcor'⁠, (which will return the phenotypic, genotypicand residual correlation matrices, respectively) or⁠'pcov', 'gcov', 'rcov'⁠ (which will return the phenotypic, genotypic and residualvariance-covariance matrices, respectively). Alternatively, it is possibleto get a matrix with the means of each genotype in each trait, by usingtype = 'means'.

Value

An object of classcovcor_design containing the followingitems:

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

[Stable]

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 toNULL. In this case, a randomized completeblock design is considered. If block is informed, then a resolvablealpha-lattice design (Patterson and Williams, 1976) is employed.All effects, except the error, are assumed to be fixed.

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 toRCBD (Randomizedcomplete Block Design). For Completely Randomized Designs informdesign = 'CRD'.

verbose

A logical argument to define if a progress bar is shown.Default isTRUE.

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.

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

cv_ammif(),cv_blup()

Examples

library(metan)model <- cv_ammi(data_ge,                env = ENV,                gen = GEN,                rep = REP,                resp = GY,                nboot = 5,                naxis = 2)

Cross-validation procedure

Description

[Stable]

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 toNULL. In this case, a randomized completeblock design is considered. If block is informed, then a resolvablealpha-lattice design (Patterson and Williams, 1976) is employed.All effects, except the error, are assumed to be fixed.

design

The experimental design used in each environment. Defaults toRCBD (Randomized complete Block Design). For Completely RandomizedDesigns informdesign = 'CRD'.

verbose

A logical argument to define if a progress bar is shown.Default isTRUE.

Value

An object of classcv_ammif with the following items:

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

cv_ammi(),cv_blup()

Examples

library(metan)model <- cv_ammif(data_ge2,                  env = ENV,                  gen = GEN,                  rep = REP,                  resp = EH,                  nboot = 5)plot(model)

Cross-validation procedure

Description

[Stable]

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 toNULL. In this case, a randomized completeblock design is considered. If block is informed, then a resolvablealpha-lattice design (Patterson and Williams, 1976) is employed. See howfixed and random effects are considered, see the sectionDetails.

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

Details

Six models may be fitted depending upon the values inblockandrandom arguments.

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

cv_ammi(),cv_ammif()

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.

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.

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.

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.

Author(s)

Tiago Olivototiagoolivoto@gmail.com

Source

Personal data


Simulate genotype and genotype-environment data

Description

[Experimental]

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 tores_eff.Be sure to changeres_eff when changin theintercept scale.

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

[Stable]

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 fromdplyr::group_by() or a numericvector. Fordesc_wider().data is an object of classdesc_stat.

...

A single variable name or a comma-separated list of unquotedvariables names. If no variable is informed, all the numeric variables from.data will be used. Select helpers are allowed.

by

One variable (factor) to compute the function by. It is a shortcuttodplyr::group_by(). To compute the statistics by more thanone grouping variable use that function.

stats

The descriptive statistics to show. This is used to filter theoutput after computation. Defaults to"main" (cv, max, mean median,min, sd.amo, se, ci ). Other allowed values are"all" toshow all the statistics,"robust" to show robust statistics,"quantile" to show quantile statistics, or chose one (or more) of thefollowing:

  • "av.dev": average deviation.

  • "ci.t": t-interval (95% confidence interval) of the mean.

  • "ci.z": z-interval (95% confidence interval) of the mean.

  • "cv": coefficient of variation.

  • "iqr": interquartile range.

  • "gmean": geometric mean.

  • "hmean": harmonic mean.

  • "Kurt": kurtosis.

  • "mad": median absolute deviation.

  • "max": maximum value.

  • "mean": arithmetic mean.

  • "median": median.

  • "min": minimum value.

  • "n": the length of the data.

  • "n.valid": The valid (NotNA) number of elements

  • "n.missing": The number of missing values

  • "n.unique": The length of unique elements.

  • "ps": the pseudo-sigma (iqr / 1.35).

  • ⁠"q2.5", "q25", "q75", "q97.5"⁠: the percentile 2.5\quartile, third quartile, and percentile 97.5\

  • range: The range of data).

  • ⁠"sd.amo", "sd.pop"⁠: the sample and population standard deviation.

  • "se": the standard error of the mean.

  • "skew": skewness.

  • "sum". the sum of the values.

  • "sum.dev": the sum of the absolute deviations.

  • "ave.sq.dev": the average of the squared deviations.

  • "sum.sq.dev": the sum of the squared deviations.

  • "n.valid": The size of sample with valid number (not NA).

  • ⁠"var.amo", "var.pop"⁠: the sample and population variance.

Use a names to select the statistics. For example,stats = c("median, mean, cv, n"). Note that the statistic namesare notcase-sensitive. Both comma or space can be used as separator.

hist

Logical argument defaults toFALSE. Ifhist = TRUEthen a histogram is created for each selected variable.

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

verbose

Logical argument. Ifverbose = FALSE the code is runsilently.

plot_theme

The graphical theme of the plot. Default isplot_theme = theme_metan(). For more details, seeggplot2::theme().

which

A statistic to fill the table.

Value

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

unnest

Logical argument defaults toTRUE to control if resultsof.fun should be unnested. Valid only if the result is of classdata.frame ortbl_df.

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

[Stable]

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,resp = c(var1, var2, var3).

verbose

Logical argument. Ifverbose = FALSE the code will runsilently.

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

[Stable]

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 exampleresp = c(var1, var2, var3). Select helpers are also allowed.

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:

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

[Stable]

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,resp = c(var1, var2, var3).

use

The method for computing covariances in the presence of missingvalues. Defaults tocomplete.obs, i.e., missing values are handledby casewise deletion.

mineval

The minimum value so that an eigenvector is retained in thefactor analysis.

verbose

Logical argument. Ifverbose = FALSE the code will runsilently.

Value

An object of classenv_stratification which is a list with oneelement per analyzed trait. For each trait, the following values are given.

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

env_dissimilarity()

Examples

library(metan)model <-env_stratification(data_ge,                   env = ENV,                   gen = GEN,                   resp = everything())gmd(model)

Multi-trait selection index

Description

[Stable]

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 classwaasb or a two-way table withgenotypes in the rows and traits in columns. In the last case the row namesmust contain the genotypes names.

use_data

Define which data to use If.data is an object ofclassgamem. Defaults to"blup" (the BLUPs for genotypes).Use"pheno" to use phenotypic means instead BLUPs for computing theindex.

DI,UI

A vector of the same length of.data to construct thedesirable (DI) and undesirable (UI) ideotypes. For each element of thevector, allowed values are'max','min','mean', or anumeric value. Use a comma-separated vector of text. For example,DI = c("max, max, min, min"). By default, DI is set to"max" for alltraits and UI is set to"min" for all traits.

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. IfTRUE some results are shown inconsole.

Value

An object of classfai_blup with the following items:

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

[Stable]

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

var

The variable to be analyzed.

by

One variable (factor) to compute the function by. It is a shortcuttodplyr::group_by(). To compute the statistics by more thanone grouping variable use that function.

plots

IfTRUE, then histograms and boxplots are shown.

coef

The multiplication coefficient, defaults to 1.5. For more detailssee?boxplot.stat.

verbose

Ifverbose = TRUE then some results are shown in theconsole.

plot_theme

The graphical theme of the plot. Default isplot_theme = theme_metan(). For more details, seeggplot2::theme().

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

[Stable]

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 exampleresp = c(var1, var2, var3). Select helpers are also allowed.

block

Defaults toNULL. In this case, a randomized completeblock design is considered. If block is informed, then a resolvablealpha-lattice design (Patterson and Williams, 1976) is employed.All effects, except the error, are assumed to be fixed. Use thefunctiongamem() to analyze a one-way trial with mixed-effectmodels.

by

One variable (factor) to compute the function by. It is a shortcuttodplyr::group_by().This is especially useful, for example,when the researcher want to fit a fixed-effect model for each environment.In this case, an object of class gafem_grouped is returned.mgidi() can then be used to compute the mgidi index within eachenvironment.

prob

The error probability. Defaults to 0.05.

verbose

Logical argument. Ifverbose = FALSE the code are runsilently.

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:

\[Y_{ijk} = m + g_i + r_j + b_{jk} + e_{ijk}\]

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:

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

get_model_data()gamem()

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

[Stable]

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,resp = c(var1, var2, var3).

verbose

Logical argument. Ifverbose = FALSE the code will runsilently.

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.

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

[Stable]

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 exampleresp = c(var1, var2, var3). Select helpers are also allowed.

block

Defaults toNULL. In this case, a randomized completeblock design is considered. If block is informed, then an alpha-latticedesign is employed considering block as random to make use of inter-blockinformation, whereas the complete replicate effect is always taken asfixed, as no inter-replicate information was to be recovered (Mohring etal., 2015).

by

One variable (factor) to compute the function by. It is a shortcuttodplyr::group_by().This is especially useful, for example,when the researcher want to fit a mixed-effect model for each environment.In this case, an object of class gamem_grouped is returned.mgidi() can then be used to compute the mgidi index within eachenvironment.

prob

The probability for estimating confidence interval for BLUP'sprediction.

verbose

Logical argument. Ifverbose = FALSE the code are runsilently.

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:

\[Y_{ijk} = m + g_i + r_j + b_{jk} + e_{ijk}\]

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

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

get_model_data()waasb()

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

[Stable]

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.

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 exampleresp = c(var1, var2, var3).

block

Defaults toNULL. In this case, a randomized completeblock design is considered. If block is informed, then an alpha-latticedesign is employed considering block as random to make use of inter-blockinformation, whereas the complete replicate effect is always taken asfixed, as no inter-replicate information was to be recovered (Mohring etal., 2015).

by

One variable (factor) to compute the function by. It is a shortcuttodplyr::group_by().This is especially useful, for example,when the researcher want to analyze environments within mega-environments.In this case, an object of class waasb_grouped is returned.

random

The effects of the model assumed to be random. Defaults torandom = "gen". SeeDetails to see the random effectsassumed depending on the experimental design of the trials.

prob

The probability for estimating confidence interval for BLUP'sprediction.

verbose

Logical argument. Ifverbose = FALSE the code will runsilently.

Value

An object of classwaasb with the following items for eachvariable:

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

[Stable]

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,resp = c(var1, var2, var3).

verbose

Logical argument. Ifverbose = FALSE the code will runsilently.

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.

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

[Stable]

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 usetable = TRUE.

env

The name of the column that contains the levels of the environments. Defaults toNULL,in case of the input data is a two-way table.

gen

The name of the column that contains the levels of the genotypes. Defaults toNULL,in case of the input data is a two-way table.

resp

The response variable(s). Defaults toNULL, in case of the input data is a two-way table.

table

Logical values indicating if the input data is a two-way table with genotypesin the rows and environments in the columns. Defaults toFALSE.

distmethod

The distance measure to be used. This must be one of'euclidean','maximum','manhattan','canberra','binary', or'minkowski'.

clustmethod

The agglomeration method to be used. This should be oneof'ward.D' (Default),'ward.D2','single','complete','average' (= UPGMA),'mcquitty' (= WPGMA),'median' (=WPGMC) or'centroid' (= UPGMC).

scale

Should the data be scaled befor computing the distances? Set toTRUE. LetY_{ij} be the yield of Hybridi in Locationj,\bar Y_{.j} be the mean yield, andS_j be the standard deviation ofLocationj. The standardized yield (Zij) is computed as (Ouyang et al. 1995):Z_{ij} = (Y_{ij} - Y_{.j}) / S_j.

cluster

What should be clustered? Defaults tocluster = "env" (cluster environments).To cluster the genotypes usecluster = "gen".

nclust

The number of clust to be formed. Set toNULL.

Value

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

[Stable]

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 exampleresp = c(var1, var2, var3). Select helpers are also allowed.

Value

A tibble with the following results for each variable:

Author(s)

Tiago Olivototiagoolivoto@gmail.com

Examples

library(metan)details <- ge_details(data_ge2, ENV, GEN, everything())print(details)

Genotype-environment effects

Description

[Stable]

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 exampleresp = c(var1, var2, var3).

type

The type of effect to compute. Defaults to"ge", i.e.,genotype-environment. To compute genotype plus genotype-environment effectsusetype = "gge".

verbose

Logical argument. Ifverbose = FALSE the code will runsilently.

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

[Stable]

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,resp = c(var1, var2, var3).

mineval

The minimum value so that an eigenvector is retained in thefactor analysis.

verbose

Logical argument. Ifverbose = FALSE the code will run silently.

Value

An object of classge_factanal with the following items:

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

[Stable]

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 exampleresp = c(var1, var2, var3). Select helpers are also allowed.

Value

A list where each element is the result for one variable containing:

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

[Stable]

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 plottype = 1 for a heatmap ortype = 2for a line plot.

values

Show the values in the plot? Defaults toTRUE.

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

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 isplot_theme = theme_metan(). For more details,seeggplot2::theme().

colour

Logical argument. IfFALSE then the plot will not becolored.

Value

An object of class⁠gg, 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

[Stable]

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,resp = c(var1, var2, var3).

base

The base with respect to which logarithms are computed. Defaultsto10.

verbose

Logical argument. Ifverbose = FALSE the code will runsilently.

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.

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

[Stable]

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,resp = c(var1, var2, var3).

verbose

Logical argument. Ifverbose = FALSE the code will runsilently.

Value

An object of classge_reg with the folloing items for eachvariable:

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

[Stable]

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,resp = c(var1, var2, var3).

verbose

Logical argument. Ifverbose = FALSE the code will runsilently.

prob

The probability error assumed.

Details

The function computes the statistics and ranks for the followingstability indexes.

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

[Stable]

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 exampleresp = c(var1, var2, var3). Select helpers are also allowed.

type

The type of results. Defaults to"winners" (default),i.e., a two-way table with the winner genotype in each environment. Iftype = "ranks" return the genotype ranking within each environment.

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'h' or'l'. If'h' is used(default), the genotypes are ranked from maximum to minimum. If'l'is used then the are ranked from minimum to maximum. Use a comma-separatedvector of names. For example,better = c("h, h, h, h, l"), forranking the fifth variable from minimum to maximum.

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

[Stable]

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

[Stable]

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

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

[Stable]

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 classclustering.]

digits

The number of significant figures. Defaults to2.

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

[Experimental]

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 functionsammi_indexes(),anova_ind(),anova_joint(),can_corr()ecovalence(),Fox(),gai(),gamem(),gafem(),ge_acv(),ge_means(),ge_reg(),gytb(),mgidi(),performs_ammi(),blup_indexes(),Shukla(),superiority(),waas() orwaasb().

what

What should be captured from the model. See more in sectionDetails.

type

Chose if the statistics must be show by genotype (type = "GEN", default) or environment (TYPE = "ENV"), when possible.

verbose

Logical argument. Ifverbose = FALSE the code will runsilently.

Details

Bellow are listed the options allowed in the argumentwhat dependingon the class of the object

Objects of classammi_indexes:

Objects of classanova_ind:

Objects of classanova_joint orgafem:

Objects of classAnnicchiarico andSchmildt:

Objects of classcan_corr:

Objects of classcolindiag:

Objects of classecovalence:

Objects of classfai_blup: See theValue section offai_blup() to see valid options forwhat argument.

Objects of classge_acv:

Objects of classge_polar:

Objects of classge_reg:

Objects of classge_effects:

Objects of classge_means:

Objects of classgge:

Objects of classgytb:

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

**Objects of classpath_coeff_seq

Objects of classShukla:

Objects of classsh: See theValue section ofSmith_Hazel() to see valid options forwhat argument.

Objects of classFox:

Objects of classgai:

Objects of classsuperiority:

Objects of classHuehn:

Objects of classThennarasu:

Objects of classperforms_ammi:

Objects of classwaas,waas_means, andwaasb:

Objects of classgamem andwaasb:

Objects of classblup_ind

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

[Stable]

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 exampleresp = c(var1, var2, var3). Select helpers are also supported.

centering

The centering method. Must be one of the'none | 0', for nocentering;'global | 1', for global centered (E+G+GE);'environment | 2' (default),for environment-centered (G+GE); or'double | 3', for double centered (GE).A biplot cannot be produced with models produced without centering.

scaling

The scaling method. Must be one of the'none | 0' (default), for no scaling;or'sd | 1', where each value is divided by the standard deviation of its correspondingenvironment (column). This will put all environments roughly he same rang of values.

svp

The method for singular value partitioning. Must be one of the'genotype | 1',(The singular value is entirely partitioned into the genotype eigenvectors, also called rowmetric preserving);'environment | 2', default, (The singular value is entirely partitioned into theenvironment eigenvectors, also called column metric preserving); or'symmetrical | 3'(The singular value is symmetrically partitioned into the genotype and the environment eigenvectorsThis SVP is most often used in AMMI analysis and other biplot analysis, but it is not ideal forvisualizing either the relationship among genotypes or that among the environments).

by

One variable (factor) to compute the function by. It is a shortcuttodplyr::group_by().This is especially useful, for example,when the researcher want to produce GGE biplots for each level of acategorical variable. In this case, an object of class gge_grouped isreturned.

...

Arguments passed to the functionimpute_missing_val() for imputation of missing values in caseof unbalanced data.

Value

The function returns a list of classgge containing the following objects

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

[Stable]

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.,resp = c(var1, var2, var3).Select helpers can also be used.

centering

The centering method. Must be one of the'none | 0',for no centering;'global | 1', for global centered (T+G+GT);'trait | 2' (default), for trait-centered (G+GT); or'double | 3', for double centred (GT). A biplot cannot be produced with modelsproduced without centering.

scaling

The scaling method. Must be one of the'none | 0', forno scaling; or'sd | 1' (default), where each value is divided bythe standard deviation of its corresponding trait (column). This will putall traits roughly he same rang of values.

svp

The method for singular value partitioning. Must be one of the'genotype | 1', (The singular value is entirely partitioned into thegenotype eigenvectors, also called row metric preserving);'trait | 2', default, (The singular value is entirely partitioned into the traiteigenvectors, also called column metric preserving); or'symmetrical | 3' (The singular value is symmetrically partitioned into the genotypeand the trait eigenvectors This SVP is most often used in AMMI analysis andother biplot analysis, but it is not ideal for visualizing either therelationship among genotypes or that among the traits).

Value

The function returns a list of classgge that is compatible with the functionplot() used ingge().

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

[Stable]

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.data, except thatinyield are selected. To select specific traits from.data,use a list of unquoted comma-separated variable names (e.g.traits =c(var1, var2, var3)), an specific range of variables, (e.g.traits =c(var1:var3)), or even a select helper likestarts_with("N").

ideotype

A vector of"h" or"l" with the same length oftraits to define which trait is desired to increase or decrease. Bydefault (ideotype = NULL) for all numeric traits intraitsare assumed that high values is desirable. Following the order of thetraits selected intraits, use"h" to indicate the traits inwhich higher values are desired or"l" to indicate the variables inwhich lower values are desired. Then,yield will be multiplied bytraits with"h" and divided by traits with"l" to generatethe Genotype by yield*trait table. For example,ideotype = c("h, h, l") will assume that the ideotype has higher values for the first twotraits and lower values for the last trait.

weight

The weight assumed for each trait. Similar toideotypeargument, provide a numeric vector of the same length oftraits.Suggested values are between 0 and 2.

prefix

The prefix used in the biplot for the yield*trait combinations.Defaults to"Y".

centering

The centering method. Must be one of the'none | 0',for no centering;'global | 1', for global centered (T+G+GYT);'trait | 2' (default), for trait-centered (G+GYT); or'double | 3', for double centered (GYT). A biplot cannot be produced with modelsproduced without centering.

scaling

The scaling method. Must be one of the'none | 0', forno scaling; or'sd | 1' (default), so that the mean for each traitor yield-trait combination becomes 0 and the variance becomes unit.

svp

The method for singular value partitioning. Must be one of the'genotype | 1', (The singular value is entirely partitioned into thegenotype eigenvectors, also called row metric preserving);'trait | 2', default, (The singular value is entirely partitioned into the traiteigenvectors, also called column metric preserving); or'symmetrical | 3' (The singular value is symmetrically partitioned into the genotypeand the trait eigenvectors This SVP is most often used in AMMI analysis andother biplot analysis, but it is not ideal for visualizing either therelationship among genotypes or that among the traits).

Value

The function returns a list of classgge that is compatible with the functionplot() used ingge().

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

[Stable]

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

algorithm

The algorithm to impute missing values. Defaults to"EM-SVD". Other possible values are"EM-AMMI" and"colmeans". SeeDetails section.

tol

The convergence tolerance for the algorithm.

max_iter

The maximum number of steps to take. Ifmax_iter isachieved without convergence, the algorithm will stop with a warning.

simplified

Valid argument whenalgorithm = "EM-AMMI". IFFALSE (default), the current effects of rows and columns change fromiteration to iteration. IfTRUE, the general mean and effects ofrows and columns are computed in the first iteration only, and in nextiterations uses these values.

verbose

Logical argument. Ifverbose = FALSE the code will runsilently.

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

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

  2. The parameters of the AMMI model are estimated.

  3. The adjusted means are calculated based on the AMMI model withnaxis principal components.

  4. The missing cells are filled with the adjusted means.

  5. 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_iter is 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).

  1. Initialize allNA values to the column means.

  2. Compute the firstnaxis terms of the SVD of the completed matrix

  3. Replace the previously missing values with their approximations from the SVD

  4. 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_iter is 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:

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$.data

Check for common errors in multi-environment trial data

Description

[Stable]

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.data to check. If no variable isinformed, all the variables in.data are used.

plot

Create a plot to show the check? Defaults toFALSE.

threshold

Maximum number of levels allowed in a character / factorcolumn to produce a plot. Defaults to 15.

verbose

Logical argument. IfTRUE (default) then the resultsfor checks are shown in the console.

Value

A tibble with the following variables:

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

[Stable]

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

[Stable]

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 thex andy axes,respectively.

fit

The polynomial degree to use. It must be between 1 (linear fit) to4 (fourth-order polynomial regression.). Inplot_factlines(), iffit is a lenth 1 vector, i.e., 1, the fitted curves of all levels ingroup will be fitted with polynomial degreefit. To use adifferent polynomial degree for each level ingroup, use a numericvector with the same length of the variable ingroup.

level

The fonfidence level. Defaults to0.05.

confidence

Display confidence interval around smooth? (TRUE bydefault)

xlab,ylab

The labels of the axes x and y, respectively. Defaults toNULL.

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 isplot_theme = theme_metan(). For more details, seeggplot2::theme().

group

The grouping variable. Valid forplot_factlines() only.

legend.position

Valid argument forplot_factlines. The positionof the legend. Defaults to 'bottom'.

grid

Valid argument forplot_factlines. Logical argument. IfTRUE then a grid will be created.

scales

Valid argument forplot_factlines. Ifgrid = TRUEscales controls how the scales are in the plot. Possible values are'free' (default),'fixed','free_x' or'free_y'.

Value

An object of class⁠gg, 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

[Stable]

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 fromdplyr::group_by().

...

Variables to use in the correlation. If... is null(Default) then all the numeric variables from.data are used. Itmust be a single variable name or a comma-separated list of unquotedvariables names.

by

One variable (factor) to compute the function by. It is a shortcuttodplyr::group_by(). To compute the statistics by more thanone grouping variable use that function.

n

If a correlation matrix is provided, thenn is the number ofobjects used to compute the correlation coefficients.

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:

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

[Stable]

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. IfTRUE,covar is supposed tocontain the inverse of the covariance matrix.

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

[Stable]

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 passedfromdplyr::group_by().

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 exampleresp = c(var1, var2, var3).

design

The experimental design. Must be RCBD or CRD.

by

One variable (factor) to compute the function by. It is a shortcuttodplyr::group_by(). To compute the statistics by more thanone grouping variable use that function.

return

What the function return? Default is 'distance', i.e., theMahalanobis distance. Alternatively, it is possible to return the matrix ofmeansreturn = 'means', or the variance-covariance matrix ofresidualsreturn = 'covmat'.

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

[Stable]

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'rows'. Ifgenotypes are in columns and environments in rows, set togen_in = 'cols'.

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

[Stable]

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 tomean, i.e., the two-way tablewill show the mean values for each genotype-environment combination. Other R base functionssuch asmax,min,sd,var, or an own function that returna single numeric value can be used.

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

[Stable]

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

nboot

The number of permutations to be used. Defaults to1000.

plot

ifplot = TRUE, plots the density estimate of thepermutation distribution along with the observed Z-score as a verticalline.

Value

Author(s)

Tiago Olivototiagoolivoto@gmail.com

See Also

pairs_mantel()

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:

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

[Stable]

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 functiongafem(),gamem() or atwo-way table with BLUPs for genotypes in each trait (genotypes in rows andtraits in columns). In the last case, the first column is assumed to havethe genotype's name.

use_data

Define which data to use if.data is an object ofclassgamem. Defaults to"blup" (the BLUPs for genotypes).Use"pheno" to use phenotypic means instead BLUPs for computing theindex.

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 lengthnvar wherenvar is the number oftraits used to plan the ideotype. Use'h' to indicate the traits in whichhigher values are desired or'l' to indicate the traits in which lowervalues are desired. For example,ideotype = c("h, h, h, h, l") willconsider that the ideotype has higher values for the first four traits andlower values for the last trait. ALternatively, one can use a mixed vector,indicating both h/l values and a numeric value for the target trait(s),eg.,ideotype = c("120, h, 30, h, l"). In this scenario, a numeric valueto define the ideotype is declared for the first and third traits. For thistraits, the absolute difference between the observed value and the numericideotype will be computed, and after the rescaling procedure, the genotypewith the smallest difference will have 100. If.datais a model fittedwith the functionsgafem() orgamem(), the order of the traits will bethe declared in the argumentresp in those functions.

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.data. By default (NULL) a numeric vector of weights equal to1 is used, i.e., all traits have the same weight in the selection process.It is suggested weights ranging from 0 to 1. The weights will then shrinkthe ideotype vector toward 0. This is useful, for example, to prioritizegrain yield rather than a plant-related trait in the selection process.

use

The method for computing covariances in the presence of missingvalues. Defaults tocomplete.obs, i.e., missing values are handledby casewise deletion.

verbose

Ifverbose = TRUE (Default) then some results areshown in the console.

Value

An object of classmgidi with the following items:

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

[Experimental]

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 exampleresp = c(var1, var2, var3).

block

Defaults toNULL. In this case, a randomized completeblock design is considered. If block is informed, then an alpha-latticedesign is employed considering block as random to make use of inter-blockinformation, whereas the complete replicate effect is always taken asfixed, as no inter-replicate information was to be recovered (Mohring etal., 2015).

by

One variable (factor) to compute the function by. It is a shortcuttodplyr::group_by().This is especially useful, for example, when theresearcher want to analyze environments within mega-environments. In thiscase, an object of class mps_grouped is returned.

random

The effects of the model assumed to be random. Defaults torandom = "gen". Seegamem_met() to see the random effects assumeddepending on the experimental design of the trials.

performance

Wich considers as mean performance. Eitherblupg (forBest Linear Unbiased Prediction) orblueg (for Best Linear UnbiasedEstimation)

stability

The stability method. One of the following:

  • "waasb" The weighted average of absolute scores (Olivoto et al. 2019).

  • "ecovalence" The Wricke's ecovalence (Wricke, 1965).

  • "Shukla" The Shukla's stability variance parameter (Shukla, 1972).

  • "hmgv" The harmonic mean of genotypic values (Resende, 2007).

  • "s2di" The deviations from the Eberhart and Russell regression (Eberhartand Russell, 1966).

  • "r2" The determination coefficient of the Eberhart and Russell regression(Eberhart and Russell, 1966)..

  • "rmse" The root mean squared error of the Eberhart and Russell regression(Eberhart and Russell, 1966).

  • "wi" Annicchiarico's genotypic confidence index (Annicchiarico, 1992).

  • "polar" Power Law Residuals as yield stability index (Doring et al.,2015).

  • "acv" Adjusted Coefficient of Variation (Doring and Reckling, 2018)

  • "pi" Lin e Binns' superiority index (Lin and Binns, 1988).

  • "gai" Geometric adaptability index (Mohammadi and Amri, 2008).

  • ⁠"s1", "s2", "s3", and "s6"⁠ Huehn's stability statistics (Huehn, 1979).

  • ⁠"n1", "n2", "n3", and "n4"⁠ Thennarasu's stability statistics (Thennarasu,1995).

  • ⁠"asv", "ev", "za", and "waas"⁠ AMMI-based stability indexes (seeammi_indexes()).

ideotype_mper,ideotype_stab

The new maximum value after rescaling theresponse variable/stability index. By default, all variables inresp arerescaled so that de maximum value is 100 and the minimum value is 0 (i.e.,ideotype_mper = NULL andideotype_stab = NULL). It must be a charactervector of the same length ofresp if rescaling is assumed to be differentacross variables, e.g., if for the first variable smaller values are betterand for the second one, higher values are better, thenideotype_mper = c("l, h") must be used. For stability index in which lower values arebetter, useideotype_stab = "l". Character value of length 1 will berecycled with a warning message.

wmper

The weight for the mean performance. By default, all variablesinresp have equal weights for mean performance and stability (i.e.,wmper = 50). It must be a numeric vector of the same length ofresp toassign different weights across variables, e.g., if for the first variableequal weights for mean performance and stability are assumed and for thesecond one, a higher weight for mean performance (e.g. 65) is assumed, thenwmper = c(50, 65) must be used. Numeric value of length 1 will berecycled with a warning message.

verbose

Logical argument. Ifverbose = FALSE the code will runsilently.

Value

An object of classmps with the following items.

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

mtsi(),mtmps(),mgidi()

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_ind

Multi-trait mean performance and stability index

Description

[Experimental]

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 classmtmps

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

Ifverbose = TRUE (Default), some results are shown in theconsole.

Value

An object of classmtmps with the following items:

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_trait

Multi-trait stability index

Description

[Stable]

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 classwaasb orwaas.

index

Ifindex = 'waasby' (default) both stability and meanperformance are considered. Ifindex = 'waasb' the multi-trait indexwill be computed considering the stability of genotypes only. More detailscan be seen inwaasb() andwaas() functions.

ideotype

A vector of lengthnvar wherenvar is thenumber of variables used to plan the ideotype. Use'h' to indicatethe traits in which higher values are desired or'l' to indicate thevariables in which lower values are desired. For example,ideotype = c("h, h, h, h, l") will consider that the ideotype has higher values forthe first four traits and lower values for the last trait.

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

Ifverbose = TRUE (Default) then some results areshown in the console.

Value

An object of classmtsi with the following items:

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 withcorr_coef() or a symmetric matrix, oftenproduced withstats::cor().

min_cor

Number to indicate the minimum value of correlations to plot(0-1 in absolute terms). By default, all the correlations are plotted whenmodel is a matrix, and significant correlations (p-value < 0.05) whenmodel is an object computed withcorr_coef().

show

The correlations to be shown whenmodel is an object computedwithcorr_coef(). Either"signif" (default) to show only significantcorrelations or"all" to show all the correlations.

p_val

The p-value to indicate significant correlations. Defaults to0.05.

legend

The type of legend. Either"full" (ranges from -1 to +1) or"range" (ranges according to the data range). Defaults to"full".

colours

A vector of colors to use for n-color gradient.

legend_width

The width of the legend (consideringposition = "right")

legend_height

The height of the legend (consideringposition = "right")

legend_position

The legend position. Defaults to"right".

curved

Shows curved paths? Defaults toTRUE.

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 bymult[1] andthe upper limit bymult[2].

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

[Stable]

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... is null thenall the numeric variables from.data are used. It must be a singlevariable name or a comma-separated list of unquoted variables names.

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 seestats::cor().

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

[Stable]

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 functionlpcor or a coerced list generated by the functionas.lpcor

type

The type of correlation if an obect generated by the functionlpcor is used. 1 = Linear correlation matrices, or 2 = partialcorrelation matrices.

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. IfTRUE, the Kernel density is shown inthe diagonal of plot.

export

Logical argument. IfTRUE, then the plot is exported tothe current directory.

main

The title of the plot, set to 'auto'.

file.type

The format of the file ifexport = TRUE. Set to'pdf'. Other possible values are⁠*.tiff⁠ usingfile.type = 'tiff'.

file.name

The name of the plot when exported. Set toNULL,i.e., automatically.

width

The width of the plot, set to8.

height

The height of the plot, set to7.

resolution

The resolution of the plot iffile.type = 'tiff' isused. Set to300 (300 dpi).

size.point

The size of the points in the plot. Set to0.5.

shape.point

The shape of the point, set to 19.

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

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 ontheprob value.), set to 'green'.

alpha

The value for transparency of the color informed insigncol, when 1 = full color. Set to 0.15.

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 class⁠gg, ggmatrix⁠.

Author(s)

Tiago Olivototiagoolivoto@gmail.com

See Also

mantel_test()

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

[Stable]

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 fromdplyr::group_by()

resp

The dependent trait.

pred

The predictor traits. set toeverything(), i.e., the predictor traits are all the numeric traits inthe data except that inresp. To select multiple traits, use acomma-separated vector of names, (e.g.,pred = c(V1, V2, V2)), aninterval of trait names, (e.g.,pred = c(V1:V3)), or even a select helper(e.g.,pred = starts_with("V")).

by

One variable (factor) to compute the function by. It is a shortcuttodplyr::group_by(). To compute the statistics by more thanone grouping variable use that function.

exclude

Logical argument, set to false. Ifexclude = TRUE, thenthe traits inpred are deleted from the data, and the analysiswill use as predictor those that remained, except that inresp.

correction

Set toNULL. A correction value (k) that will beadded into the diagonal elements of theX'X matrix aiming atreducing the harmful problems of the multicollinearity in path analysis(Olivoto et al., 2017)

knumber

Whencorrection = NULL, a plot showing the values ofdirect effects in a set of different k values (0-1) is produced.knumber is the number of k values used in the range of 0 to 1.

brutstep

Logical argument, set toFALSE. If true, then analgorithm will select a subset of variables with minimal multicollinearityand fit a set of possible models. See theDetails section for moreinformation.

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 seestats::cor().

plot_res

IfTRUE, create a scatter plot of residual againstpredicted value and a normal Q-Q plot.

verbose

Ifverbose = TRUE then some results are shown in theconsole.

...

Depends on the function used:

  • Forpath_coeff() additional arguments passed on tostats::plot.lm().

  • Forpath_coeff_seq() additional arguments passed on topath_coeff.

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:

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_sc2

Additive Main effects and Multiplicative Interaction

Description

[Stable]

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.,resp = c(var1, var2, var3), or any select helper likeresp = contains("_PLA").

block

Defaults toNULL. In this case, a randomized completeblock design is considered. If block is informed, then a resolvablealpha-lattice design (Patterson and Williams, 1976) is employed.All effects, except the error, are assumed to be fixed.

verbose

Logical argument. Ifverbose = FALSE the code will runsilently.

...

Arguments passed to the functionimpute_missing_val() for imputation of missing values in caseof unbalanced data.

Value

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

[Stable]

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,resp = c(var1, var2, var3).

verbose

Logical argument. Ifverbose = FALSE the code will runsilently.

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

...

Additional arguments passed on to the functionresidual_plots()

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⁠waasb object⁠

type

The type of the plot. Defaults totype = 1 (Scree-plot ofthe correlations of the canonical loadings). Usetype = 2, toproduce a plot with the scores of the variables in the first group,type = 3 to produce a plot with the scores of the variables in thesecond group, ortype = 4 to produce a circle of correlations.

plot_theme

The graphical theme of the plot. Default isplot_theme = theme_metan(). For more details,seeggplot2::theme().

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 is3.5.

x.lab

The label of x-axis. Each plot has a default value. Newarguments can be inserted asx.lab = 'my label'.

x.lim

The range of x-axis. Default isNULL (maximum and minimumvalues of the data set). New arguments can be inserted asx.lim = c(x.min, x.max).

x.breaks

The breaks to be plotted in the x-axis. Default is⁠authomatic breaks⁠. New arguments can be inserted asx.breaks = c(breaks)

y.lab

The label of y-axis. Each plot has a default value. Newarguments can be inserted asy.lab = 'my label'.

y.lim

The range of y-axis. Default isNULL. The same argumentsthanx.lim can be used.

y.breaks

The breaks to be plotted in the x-axis. Default is⁠authomatic breaks⁠. The same arguments thanx.breaks can beused.

axis.expand

Multiplication factor to expand the axis limits by toenable fitting of labels. Default is1.1.

shape

The shape of points in the plot. Default is21 (circle).Values must be between21-25:21 (circle),22(square),23 (diamond),24 (up triangle), and25 (lowtriangle).

col.shape

A vector of length 2 that contains the color of shapes forgenotypes above and below of the mean, respectively. Defaults to"orange".c("blue", "red").

col.alpha

The alpha value for the color. Default is0.9. Valuesmust be between0 (full transparency) to1 (full color).

size.shape

The size of the shape in the plot. Default is3.5.

size.bor.tick

The size of tick of shape. Default is0.3. Thesize of the shape will besize.shape + size.bor.tick

labels

Logical arguments. IfTRUE then the points in the plotwill have labels.

main

The title of the plot. Defaults toNULL, in which eachplot will have a default title. Use a string text to create an own title orset tomain = FALSE to omit the plot title.

...

Currently not used.

Value

An object of class⁠gg, 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 classclustering

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 functionplot.dendrogram orabline.

Value

An object of class⁠gg, 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. Eitherlower (default) toproduce a lower triangle heat map orupper to produce an uppertriangular heat map.

diag

Plot diagonal elements? Defaults toFALSE.

reorder

Reorder the correlation matrix to identify the hidden pattern?Defaults toTRUE.

signif

How to show significant correlations. If"stars" is used(default), stars are used showing the significance at 0.05 (""), 0.01("") and 0.001 ("") probability error. Ifsignif = "pval", thenthe p-values are shown.

show

The correlations to show. Eitherall (default) orsignif(only significant correlations).

p_val

The p-value to the correlation significance.

caption

Logical. IfTRUE (Default) includes a caption with thesignificance meaning for stars.

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 toblue,white, andred, respectively.

lab.x.position,lab.y.position

The position of the x and y axis label.Defaults to"bottom" and"right" iftype = "lower" or"top" and"left" iftype = "upper".

legend.position

The legend position in the plot.

legend.title

The title of the color key. Defaults to"Pearson's Correlation".

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 class⁠gg, 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 classcvalidation fitted with the functionscv_ammi(),cv_ammif(),cv_blup(), or abound object fitted withbind_cv().

violin

Define if a violin plot is used with boxplot. Default is 'TRUE'

export

Export (or not) the plot. Default isT.

order_box

Logical argument. IfTRUE then the boxplots will beordered according to the values of the RMSPD.

x.lab

The label of x-axis. New arguments can be inserted asx.lab = 'my x label'.

y.lab

The label of y-axis. New arguments can be inserted asy.lab = 'my y label'.

size.tex.lab

The size of the text in axis text and labels.

file.type

The type of file to be exported. Default ispdf,Graphic can also be exported in⁠*.tiff⁠ format by declaringfile.type = 'tiff'.

file.name

The name of the file for exportation, default isNULL, i.e. the files are automatically named.

plot_theme

The graphical theme of the plot. Default isplot_theme = theme_metan(). For more details,seeggplot2::theme().

width

The width 'inch' of the plot. Default is6.

height

The height 'inch' of the plot. Default is6.

resolution

The resolution of the plot. Parameter valid iffile.type = 'tiff' is used. Default is300 (300 dpi)

col.violin

Parameter valid ifviolin = T. Define the color ofthe violin plot. Default is 'gray90.

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 is0.2.

x.lim

The range of x-axis. Default isNULL (maximum and minimumvalues of the data set). New arguments can be inserted asx.lim = c(x.min, x.max).

x.breaks

The breaks to be plotted in the x-axis. Default is⁠authomatic breaks⁠. New arguments can be inserted asx.breaks = c(breaks)

...

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 class⁠gg, 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 classenv_dissimilarity

var

The variable to plot. Defaults tovar = 1 the firstvariable ofx.

nclust

The number of clusters to show.

...

Other arguments bo be passed to the functionstats::hclust().

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 classenv_stratification

var

The variable to plot. Defaults tovar = 1 the firstvariable ofx.

...

Further arguments passed toplot.corr_coef()

Value

An object of class⁠gg, ggplot⁠.

Author(s)

Tiago Olivototiagoolivoto@gmail.com

See Also

env_dissimilarity()

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 classwaasb

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

arrange.label

Logical argument. IfTRUE, the labels arearranged to avoid text overlapping. This becomes useful when the number ofgenotypes is large, say, more than 30.

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"red".

col.nonsel

The colour for nonselected genotypes. Defaults to"black".

...

Other arguments to be passed from ggplot2::theme().

Value

An object of class⁠gg, 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 classgafem.

...

Additional arguments passed on to the functionresidual_plots()

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

var

The variable to plot. Defaults tovar = 1 the firstvariable ofx.

type

One of the"res" to plot the model residuals (default),type = 're' to plot normal Q-Q plots for the random effects, or"vcomp" to create a bar plot with the variance components.

position

The position adjustment whentype = "vcomp". Defaultsto"fill", which shows relative proportions at each trait bystacking the bars and then standardizing each bar to have the same height.Useposition = "stack" to plot the phenotypic variance for eachtrait.

rotate

Logical argument. Ifrotate = TRUE the plot is rotated,i.e., traits in y axis and value in the x axis.

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. IfTRUE labels the points outsideconfidence interval limits.

plot_theme

The graphical theme of the plot. Default isplot_theme = theme_metan(). For more details, seeggplot2::theme().

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 iftype = "contribution".

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 iswhich = c(1:4) that means that the first four graphics will be plotted.

ncol,nrow

The number of columns and rows of the plot pannel. DefaultstoNULL

...

Additional arguments passed on to the functionpatchwork::wrap_plots().

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 classge_cluster

nclust

The number of clusters to show.

xlab

The label of the x axis.

...

Other arguments passed from the functionplot.hclust.

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 classge_effects

var

The variable to plot. Defaults tovar = 1 the firstvariable ofx.

plot_theme

The graphical theme of the plot. Default isplot_theme = theme_metan(). For more details, seeggplot2::theme().

x.lab

The label of x-axis. Each plot has a default value. Newarguments can be inserted asx.lab = "my label".

y.lab

The label of y-axis. Each plot has a default value. Newarguments can be inserted asy.lab = "my label".

leg.position

The position of the legend.

size.text

The size of the text in the axes text and labels. Defaultis12.

...

Current not used.

Value

An object of class⁠gg, ggplot⁠.

Author(s)

Tiago Olivototiagoolivoto@gmail.com

See Also

ge_plot()

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 classge_factanal

var

The variable to plot. Defaults tovar = 1 the firstvariable ofx.

plot_theme

The graphical theme of the plot. Default isplot_theme = theme_metan(). For more details, seeggplot2::theme().

x.lim

The range of x-axis. Default isNULL (maximum and minimumvalues of the data set). New arguments can be inserted asx.lim = c(x.min, x.max).

x.breaks

The breaks to be plotted in the x-axis. Default is⁠authomatic breaks⁠. New arguments can be inserted asx.breaks = c(breaks)

x.lab

The label of x-axis. Each plot has a default value. Newarguments can be inserted asx.lab = "my label".

y.lim

The range of x-axis. Default isNULL. The same argumentsthanx.lim can be used.

y.breaks

The breaks to be plotted in the x-axis. Default is⁠authomatic breaks⁠. The same arguments thanx.breaks can beused.

y.lab

The label of y-axis. Each plot has a default value. Newarguments can be inserted asy.lab = "my label".

shape

The shape for genotype indication in the plot. Default is1 (circle). Values between21-25:21 (circle),22 (square),23 (diamond),24 (up triangle), and25 (low triangle) allows a color for fill the shape.

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"gray30". Other values can be attributed. For example,transparent_color(), will make a plot with only an outline around theshape area.

col.alpha

The alpha value for the color. Default is1. Valuesmust be between0 (full transparency) to1 (full color).

size.shape

The size of the shape (both for genotypes andenvironments). Default is2.2.

size.bor.tick

The size of tick of shape. Default is0.3. Thesize of the shape will besize.shape + size.bor.tick

size.tex.lab

The size of the text in the axes text and labels. Defaultis12.

size.tex.pa

The size of the text of the plot area. Default is3.5.

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"solid". Other values that can be attributed are:"blank", no lines in the biplot,⁠"dashed", "dotted", "dotdash", "longdash", and "twodash"⁠.

line.alpha

The alpha value that combine the line with the backgroundto create the appearance of partial or full transparency. Default is0.4. Values must be between "0" (full transparency) to "1" (fullcolor).

col.line

The color of the line that indicate the means in the biplot.Default is"gray"

size.line

The size of the line that indicate the means in the biplot.Default is0.5.

...

Currently not used..

Value

An object of class⁠gg, ggplot⁠.

Author(s)

Tiago Olivototiagoolivoto@gmail.com

See Also

ge_factanal()

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 classge_factanal

var

The variable to plot. Defaults tovar = 1 the firstvariable ofx.

type

The type of plot to show.type = 1 produces a plot withthe environmental index in the x axis and the genotype mean yield in the yaxis.type = 2 produces a plot with the response variable in the xaxis and the slope/deviations of the regression in the y axis.

plot_theme

The graphical theme of the plot. Default isplot_theme = theme_metan(). For more details, seeggplot2::theme().

x.lim

The range of x-axis. Default isNULL (maximum and minimumvalues of the data set). New arguments can be inserted asx.lim = c(x.min, x.max).

x.breaks

The breaks to be plotted in the x-axis. Default is⁠authomatic breaks⁠. New arguments can be inserted asx.breaks = c(breaks)

x.lab

The label of x-axis. Each plot has a default value. Newarguments can be inserted asx.lab = "my label".

y.lim

The range of x-axis. Default isNULL. The same argumentsthanx.lim can be used.

y.breaks

The breaks to be plotted in the x-axis. Default is⁠authomatic breaks⁠. The same arguments thanx.breaks can beused.

y.lab

The label of y-axis. Each plot has a default value. Newarguments can be inserted asy.lab = "my label".

leg.position

The position of the legend.

size.tex.lab

The size of the text in the axes text and labels. Defaultis12.

...

Currently not used..

Value

An object of class⁠gg, ggplot⁠.

Author(s)

Tiago Olivototiagoolivoto@gmail.com

See Also

ge_factanal()

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 classesggegtb, orgytb.

var

The variable to plot (useful forgge objects. Defaults tovar = 1 the first variable ofx.

type

The type of biplot to produce.

  1. Basic biplot.

  2. Mean performance vs. stability (gge biplots) or the The Average TesterCoordination view for genotype-trait and genotype-yield*trait biplots.

  3. Which-won-where.

  4. Discriminativeness vs. representativeness.

  5. Examine an environment (or trait/yield*trait combination).

  6. Ranking environments (or trait/yield*trait combination).

  7. Examine a genotype.

  8. Ranking genotypes.

  9. Compare two genotypes.

  10. Relationship among environments (or trait/yield*trait combination).

repel

IfTRUE (default), the text labels repel away from eachother and away from the data points.

repulsion

Force of repulsion between overlapping text labels. Defaultsto1.

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 whentype = 5 andtype = 7,respectively. Must be a string which matches a environment or genotypelabel.

sel_gen1,sel_gen2

The name of genotypes to compare between whentype = 9. Must be a string present in the genotype's name.

shape.gen,shape.env

The shape for genotype and environment indicationin the biplot. Defaults toshape.gen = 21 (circle) for genotypes andshape.env = 23 (rhombus) for environments. Values must be between21-25:21 (circle),22 (square),23 (rhombus),24 (up triangle), and25 (low triangle).

line.type.gen

The line type to highlith the genotype's vectors.Defaults to⁠line.type.gen == "dotted⁠.

size.shape

The size of the shape (both for genotypes andenvironments). Defaults to2.2.

size.shape.win

The size of the shape for winners genotypes whentype = 3. Defaults to3.2.

size.stroke,col.stroke

The width and color of the border,respectively. Default tosize.stroke = 0.3 andcol.stroke = "black". The size of the shape will besize.shape + size.stroke

col.gen,col.env,col.line

Color for genotype/environment labels and forthe line that passes through the biplot origin. Defaults tocol.gen = 'blue',col.env = 'forestgreen', andcol.line = 'forestgreen'.

col.alpha

The alpha value for the color. Defaults to1. Valuesmust be between0 (full transparency) to1 (full color).

col.circle,col.alpha.circle

The color and alpha values for the circlelines. Defaults to'gray' and0.4, respectively.

leg.lab

The labs of legend. Defaults toNULL isc('Env', 'Gen').

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 wheretype = 3 and for the two selected genotypes wheretype = 9.Defaults to 4.5.

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 toTRUE) to includeautomatically generated information in the plot such as singular valuepartitioning, scaling and centering.

plot_theme

The graphical theme of the plot. Default isplot_theme = theme_metan(). For more details, seeggplot2::theme().

...

Currently not used.

Value

A ggplot2-based biplot.

An object of class⁠gg, 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 classmgidi

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

type

The type of the plot. Defaults to"index". Usetype = "contribution" to show the contribution of each factor to the MGIDIindex of the selected genotypes/treatments.

position

The position adjustment whentype = "contribution".Defaults to"fill", which shows relative proportions at each traitby stacking the bars and then standardizing each bar to have the sameheight. Useposition = "stack" to plot the MGIDI index for eachgenotype/treatment.

rotate

Logical argument. Ifrotate = TRUE the plot is rotated,i.e., traits in y axis and value in the x axis.

genotypes

Whentype = "contribution" defines the genotypes tobe shown in the plot. By default (genotypes = "selected" onlyselected genotypes are shown. Usegenotypes = "all" to plot thecontribution for all genotypes.)

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 whentype = "contribution".

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 iftype = "contribution".Defaults to 0.75.

col.sel

The colour for selected genotypes. Defaults to"red".

col.nonsel

The colour for nonselected genotypes. Defaults to"gray".

legend.position

The position of the legend.

...

Other arguments to be passed fromggplot2::theme().

Value

An object of class⁠gg, 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 withmps().

SI

An integer (0-100). The selection intensity in percentage of thetotal number of genotypes.

type

The type of the plot. Defaults to"index". Usetype = "contribution" to show the contribution of each factor to the MTMPSindex of the selected genotypes.

position

The position adjustment whentype = "contribution".Defaults to"fill", which shows relative proportions at each traitby stacking the bars and then standardizing each bar to have the sameheight. Useposition = "stack" to plot the MGIDI index for eachgenotype.

genotypes

Whentype = "contribution" defines the genotypes tobe shown in the plot. By default (genotypes = "selected" onlyselected genotypes are shown. Usegenotypes = "all" to plot thecontribution for all genotypes.)

title

Logical values (Defaults toTRUE) to includeautomatically generated titles.

radar

Logical argument. If true (default) a radar plot is generatedafter usingcoord_polar().

arrange.label

Logical argument. IfTRUE, the labels arearranged to avoid text overlapping. This becomes useful when the number ofgenotypes is large, say, more than 30.

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 iftype = "contribution".Defaults to 0.75.

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. IfTRUE, rotate the plot.

col.sel

The colour for selected genotypes. Defaults to"red".

col.nonsel

The colour for nonselected genotypes. Defaults to"black".

legend.position

The position of the legend.

...

Other arguments to be passed fromggplot2::theme().

Value

An object of class⁠gg, 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 classmtsi

SI

An integer (0-100). The selection intensity in percentage of thetotal number of genotypes.

type

The type of the plot. Defaults to"index". Usetype = "contribution" to show the contribution of each factor to the MGIDIindex of the selected genotypes.

position

The position adjustment whentype = "contribution".Defaults to"fill", which shows relative proportions at each traitby stacking the bars and then standardizing each bar to have the sameheight. Useposition = "stack" to plot the MGIDI index for eachgenotype.

genotypes

Whentype = "contribution" defines the genotypes tobe shown in the plot. By default (genotypes = "selected" onlyselected genotypes are shown. Usegenotypes = "all" to plot thecontribution for all genotypes.)

title

Logical values (Defaults toTRUE) to includeautomatically generated titles.

radar

Logical argument. If true (default) a radar plot is generatedafter usingcoord_polar().

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 iftype = "contribution".Defaults to 0.75.

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. IfTRUE, rotate the plot.

col.sel

The colour for selected genotypes. Defaults to"red".

col.nonsel

The colour for nonselected genotypes. Defaults to"black".

legend.position

The position of the legend.

...

Other arguments to be passed fromggplot2::theme().

Value

An object of class⁠gg, 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 classpath_coeff orgroup_path.

which

Which to plot: one of'coef','vif', or'betas'.

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 toggplot2::theme().

Details

The plotwhich = "coef" (default) is interpreted as follows:

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

...

Additional arguments passed on to the functionresidual_plots()

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 classresp_surf

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

plot_theme

The graphical theme of the plot. Default isplot_theme = theme_metan(). For more details, seeggplot2::theme().

...

Currently not used

Value

An object of class⁠gg, 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 classsh

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

arrange.label

Logical argument. IfTRUE, the labels arearranged to avoid text overlapping. This becomes useful when the number ofgenotypes is large, say, more than 30.

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"red".

col.nonsel

The colour for nonselected genotypes. Defaults to"black".

...

Other arguments to be passed from ggplot2::theme().

Value

An object of class⁠gg, 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 classwaas.

...

Additional arguments passed on to the functionresidual_plots()

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

var

The variable to plot. Defaults tovar = 1 the firstvariable ofx.

type

One of the"res" to plot the model residuals (default),type = 're' to plot normal Q-Q plots for the random effects, or"vcomp" to create a bar plot with the variance components.

position

The position adjustment whentype = "vcomp". Defaultsto"fill", which shows relative proportions at each trait bystacking the bars and then standardizing each bar to have the same height.Useposition = "stack" to plot the phenotypic variance for eachtrait.

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.,trait.levels = "PH, GY").

percent

IfTRUE (default) shows the y-axis as percent and thepercentage values within each bar.

percent.digits

The significant figures for the percentage values.Defaults to2.

size.text.percent

The size of the text for the percentage values.Defaults to3.5.

rotate

Logical argument. Ifrotate = TRUE the plot is rotated,i.e., traits in y axis and value in the x axis.

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. IfTRUE labels the points outsideconfidence interval limits.

plot_theme

The graphical theme of the plot. Default isplot_theme = theme_metan(). For more details, seeggplot2::theme().

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 iftype = "contribution".

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 iswhich = c(1:4) that means that the first four graphics will be plotted.

ncol,nrow

The number of columns and rows of the plot pannel. DefaultstoNULL

...

Additional arguments passed on to the functionpatchwork::wrap_plots().

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

var

The variable to plot. Defaults tovar = 1 the firstvariable ofx.

type

⁠1 = Heat map Ranks⁠: this graphic shows the genotyperanking considering the WAASB index estimated with different numbers ofPrincipal Components;⁠2 = Heat map WAASY-GY ratio⁠: this graphicshows the genotype ranking considering the different combinations in theWAASB/GY ratio.

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

[Stable]

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⁠waasb object⁠

var

The variable to plot. Defaults tovar = 1 the firstvariable ofx.

which

Which plot to shown. Ifwhich = "gen" (default) plots theBLUPs for genotypes. To create a plot showing the BLUPs forgenotype-environment combinations, usewhich = "ge".

ncol,nrow

The number of columns and rows, respectively, to be shown inthe plot whenwhich = "ge".

prob

The probability error for constructing confidence interval.

export

Export (or not) the plot. Default isTRUE.

file.type

Ifexport = TRUE, define the type of file to beexported. Default ispdf, Graphic can also be exported in⁠*.tiff⁠ format by declaringfile.type = "tiff".

file.name

The name of the file for exportation, default isNULL, i.e. the files are automatically named.

plot_theme

The graphical theme of the plot. Default isplot_theme = theme_metan(). For more details, seeggplot2::theme().

width

The width "inch" of the plot. Default is6.

height

The height "inch" of the plot. Default is6.

err.bar

Logical value to indicate if an error bar is shown. DefaultstoTRUE.

size.err.bar

The size of the error bar for the plot. Default is0.5.

size.shape

The size of the shape (both for genotypes andenvironments). Default is3.5.

size.tex.lab

The size of the text in axis text and labels.

height.err.bar

The height for error bar. Default is0.3.

x.lim

The range of x-axis. Default isNULL (maximum and minimumvalues of the data set). New arguments can be inserted asx.lim = c(x.min, x.max).

x.breaks

The breaks to be plotted in the x-axis. Default is⁠authomatic breaks⁠. New arguments can be inserted asx.breaks = c(breaks)

col.shape

A vector of length 2 that contains the color of shapes forgenotypes above and below of the mean, respectively. Default isc("blue", "red").

y.lab

The label of the y-axis in the plot. Default is"Genotypes".

x.lab

The label of the x-axis in the plot. Default isNULL,i.e., the name of the selected variable.

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 whenwhich = "ge".

resolution

The resolution of the plot. Parameter valid iffile.type = "tiff" is used. Default is300 (300 dpi)

...

Currently not used.

Value

An object of class⁠gg, ggplot⁠.

Author(s)

Tiago Olivototiagoolivoto@gmail.com

See Also

plot_scores(),plot_waasby()

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

[Stable]

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 functioncorr_ci()

fill

Ifcorr_ci() is computed with the argumentby usefill to fill the shape by each level of the grouping variableby.

position.fill

The position of shapes and errorbar whenfill is used.Defaults to0.3.

x.lab

The label of x-axis, set to 'Pairwise combinations'. Newarguments can be inserted asx.lab = 'my label'.

y.lab

The label of y-axis, set to 'Pearson's correlation coefficient'New arguments can be inserted asy.lab = 'my label'.

y.lim

The range of x-axis. Default isNULL. The same argumentsthanx.lim can be used.

y.breaks

The breaks to be plotted in the x-axis. Default is⁠authomatic breaks⁠. The same arguments thanx.breaks can beused.

shape

The shape point to represent the correlation coefficient.Default is21 (circle). Values must be between21-25:21 (circle),22 (square),23 (diamond),24 (uptriangle), and25 (low triangle).

col.shape

The color for the shape edge. Set toblack.

fill.shape

The color to fill the shape. Set toorange.

size.shape

The size for the shape point. Set to2.5.

width.errbar

The width for the errorbar showing the CI.

main

The title of the plot. Set tomain = FALSE to ommite theplot title.

invert.axis

Should the names of the pairwise correlation appear in they-axis?

reorder

Logical argument. IfTRUE (default) the pairwisecombinations are reordered according to the correlation coefficient.

legend.position

The position of the legend when usingfill argument.Defaults to"bottom".

plot_theme

The graphical theme of the plot. Default isplot_theme = theme_metan(). For more details, seeggplot2::theme().

Value

An object of class⁠gg, 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

[Stable]

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⁠waasb object⁠

var

The variable to plot. Defaults tovar = 1 the firstvariable ofx.

export

Export (or not) the plot. Default isTRUE.

plot_theme

The graphical theme of the plot. Default isplot_theme = theme_metan(). For more details, seeggplot2::theme().

file.type

Ifexport = TRUE, define the type of file to beexported. Default ispdf, Graphic can also be exported in⁠*.tiff⁠ format by declaringfile.type = "tiff".

file.name

The name of the file for exportation, default isNULL, i.e. the files are automatically named.

width

The width "inch" of the plot. Default is6.

height

The height "inch" of the plot. Default is6.

size.shape

The size of the shape. Default is3.5.

size.line

The size of the line. Default is1.

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"Eigenvalue".

y2.lab

The label of the second y-axis in the plot. Default is"Accumulated variance".

x.lab

The label of the x-axis in the plot. Default is"Number of multiplicative terms".

resolution

The resolution of the plot. Parameter valid iffile.type = "tiff" is used. Default is300 (300 dpi)

...

Currently not used.

Value

An object of class⁠gg, ggplot⁠.

Author(s)

Tiago Olivototiagoolivoto@gmail.com

See Also

plot_scores(),plot_waasby()

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

[Stable]

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 functionsperforms_ammi(),waas(),waas_means(), orwaasb().

var

The variable to plot. Defaults tovar = 1 the firstvariable ofx.

type

type of biplot to produce

  • type = 1 The default. Produces an AMMI1 biplot (Y x PC1) to makeinferences related to stability and productivity.

  • type = 2 Produces an AMMI2 biplot (PC1 x PC2) to make inferencesrelated to the interaction effects. Use the argumentsfirst orsecond to change the default IPCA shown in the plot.

  • type = 3 Valid for objects of classwaas orwaasb,produces a biplot showing the GY x WAASB.

  • type = 4 Produces a plot with the Nominal yield x Environment PC.

first,second

The IPCA to be shown in the first (x) and second (y)axis. By default, IPCA1 is shown in thex axis and IPCA2 in they axis. For example, usesecond = "PC3" to shown the IPCA3 inthey axis.

repel

IfTRUE (default), the text labels repel away from eachother and away from the data points.

repulsion

Force of repulsion between overlapping text labels. Defaultsto1.

max_overlaps

Exclude text labels that overlap too many things. Defaults to 20.

polygon

Logical argument. IfTRUE, a polygon is drawn whentype = 2.

title

Logical values (Defaults toTRUE) to includeautomatically generated titles

plot_theme

The graphical theme of the plot. Default isplot_theme = theme_metan(). For more details, seeggplot2::theme().

axis.expand

Multiplication factor to expand the axis limits by toenable fitting of labels. Default is1.1.

x.lim,y.lim

The range of x and y axes, respectively. Default isNULL (maximum and minimum values of the data set). New values can beinserted asx.lim = c(x.min, x.max) ory.lim = c(y.min, y.max).

x.breaks,y.breaks

The breaks to be plotted in the x and y axes,respectively. Defaults towaiver() (automatic breaks). New valuescan be inserted, for example, asx.breaks = c(0.1, 0.2, 0.3) orx.breaks = seq(0, 1, by = 0.2)

x.lab,y.lab

The label of x and y axes, respectively. Defaults toNULL, i.e., each plot has a default axis label. New values can beinserted asx.lab = 'my label'.

shape.gen,shape.env

The shape for genotypes and environmentsindication in the biplot. Default is21 (circle) for genotypes and23 (diamond) for environments. Values must be between21-25:21 (circle),22 (square),23 (diamond),24 (uptriangle), and25 (low triangle).

size.shape.gen,size.shape.env

The size of the shapes for genotypes andenvironments respectively. Defaults to2.2.

size.bor.tick

The size of tick of shape. Default is0.1. Thesize of the shape will bemax(size.shape.gen, size.shape.env) + size.bor.tick

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 is0.5.

size.segm.line

The size of the segment that start in the origin of thebiplot and end in the scores values. Default is0.5.

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'gray'

col.gen,col.env

The shape color for genotypes (Defaults to'blue') and environments ('forestgreen'). Must be lengthone or a vector of colors with the same length of the number ofgenotypes/environments.

col.alpha.gen,col.alpha.env

The alpha value for the color forgenotypes and environments, respectively. Defaults toNA. Values must bebetween0 (full transparency) to1 (full color).

col.segm.gen,col.segm.env

The color of segment for genotypes (Defaultstotransparent_color()) and environments (Defaults to 'forestgreen'),respectively. Valid arguments for plots withtype = 1 ortype = 2 graphics.

highlight

Genotypes/environments to be highlight in the plot. DefaultstoNULL.

col.highlight

The color for shape/labels when a value is provided inhighlight. Defaults to"red".

col.alpha.highlight

The alpha value for the color of the highlightedgenotypes. Defaults to1.

size.tex.highlight

The size of the text for the highlighted genotypes.Defaults to5.5.

size.shape.highlight

The size of the shape for the highlightedgenotypes. Defaults to3.2.

leg.lab

The labs of legend. Default isGen andEnv.

line.type

The type of the line that indicate the means in the biplot.Default is'solid'. Other values that can be attributed are:'blank', no lines in the biplot,⁠'dashed', 'dotted', 'dotdash', 'longdash', and 'twodash'⁠.

line.alpha

The alpha value that combine the line with the backgroundto create the appearance of partial or full transparency. Default is0.4. Values must be between '0' (full transparency) to '1' (fullcolor).

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 isFALSE. IfTRUE, calls theggplot2::ggsave() function.

file.name

The name of the file for exportation, default isNULL, i.e. the files are automatically named.

width

The width 'inch' of the plot. Default is8.

height

The height 'inch' of the plot. Default is7.

color

Should type 4 plot have colors? Default toTRUE.

...

Currently not used.

Value

An object of class⁠gg, 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

plot_eigen()

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

[Stable]

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⁠WAASBY object⁠

var

The variable to plot. Defaults tovar = 1 the firstvariable ofx.

export

Export (or not) the plot. Default isT.

file.type

The type of file to be exported. Default ispdf,Graphic can also be exported in⁠*.tiff⁠ format by declaringfile.type = "tiff".

file.name

The name of the file for exportation, default isNULL, i.e. the files are automatically named.

plot_theme

The graphical theme of the plot. Default isplot_theme = theme_metan(). For more details, seeggplot2::theme().

width

The width "inch" of the plot. Default is8.

height

The height "inch" of the plot. Default is7.

size.shape

The size of the shape in the plot. Default is3.5.

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 isc("blue", "red").

x.lab

The label of the x axis in the plot. Default is"WAASBY".

y.lab

The label of the y axis in the plot. Default is"Genotypes".

x.breaks

The breaks to be plotted in the x-axis. Default is⁠authomatic breaks⁠. New arguments can be inserted asx.breaks = c(breaks)

resolution

The resolution of the plot. Parameter valid iffile.type = "tiff" is used. Default is300 (300 dpi)

...

Currently not used.

Value

An object of class⁠gg, ggplot⁠.

Author(s)

Tiago Olivototiagoolivoto@gmail.com

See Also

plot_scores()

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 classgamem

...

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

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'long'(default) returning a long-format table with the columns for environment(ENV), genotypes (GEN) and response variable (Y); or'wide' toreturn a two-way table with genotypes in the row, environments in thecolumns, filled by the estimated values.

...

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. Ifobject has more than one variable, thennaxis must be avector.

...

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. If⁠naxis = 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. Ifobject has more than one variable, thennaxis must be avector.

...

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. If⁠naxis = 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))predict

Predict 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 classwaasb

...

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

TheAnnicchiarico x

export

A logical argument. IfTRUE, a *.txt file is exported tothe working directory.

file.name

The name of the file ifexport = TRUE

digits

The significant digits to be shown.

...

Options used by the tibble package to format the output. Seetibble::print() for more details.

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

TheFox x

export

A logical argument. IfTRUE, a *.txt file is exported tothe working directory.

file.name

The name of the file ifexport = TRUE

digits

The significant digits to be shown.

...

Options used by the tibble package to format the output. Seetibble::print() for more details.

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

export

A logical argument. IfTRUE, a *.txt file is exported tothe working directory.

file.name

The name of the file ifexport = TRUE

digits

The significant digits to be shown.

...

Options used by the tibble package to format the output. Seetibble::print() for more details.

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

TheSchmildt x

export

A logical argument. IfTRUE, a *.txt file is exported tothe working directory.

file.name

The name of the file ifexport = TRUE

digits

The significant digits to be shown.

...

Options used by the tibble package to format the output. Seetibble::formatting() for more details.

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

TheShukla x

export

A logical argument. IfTRUE, a *.txt file is exported tothe working directory.

file.name

The name of the file ifexport = TRUE

digits

The significant digits to be shown.

...

Options used by the tibble package to format the output. Seetibble::print() for more details.

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

export

A logical argument. IfTRUE, a *.txt file is exported tothe working directory.

file.name

The name of the file ifexport = TRUE

digits

The significant digits to be shown.

...

Options used by the tibble package to format the output. Seetibble::print() for more details.

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

which

Which should be printed. Defaults to"stats". Otherpossible values are"ranks" for genotype ranking and"ssi"for the simultaneous selection index.

export

A logical argument. IfTRUE, a *.txt file is exported tothe working directory.

file.name

The name of the file ifexport = TRUE

digits

The significant digits to be shown.

...

Options used by the tibble package to format the output. Seetibble::print() for more details.

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

export

A logical argument. IfTRUE, a *.txt file is exported tothe working directory.

file.name

The name of the file ifexport = TRUE

digits

The significant digits to be shown.

...

Options used by the tibble package to format the output. Seetibble::print() for more details.

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

export

A logical argument. IfTRUE, a *.txt file is exported tothe working directory.

file.name

The name of the file ifexport = TRUE

digits

The significant digits to be shown.

...

Options used by the tibble package to format the output. Seetibble::print() for more details.

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

export

A logical argument. IfTRUE|T, a *.txt file is exportedto the working directory

file.name

The name of the file ifexport = TRUE

digits

The significant digits to be shown.

...

Options used by the tibble package to format the output. Seetibble::print() for more details.

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

export

A logical argument. IfTRUE, a *.txt file is exportedto the working directory

file.name

The name of the file ifexport = TRUE

digits

The significant digits to be shown.

...

Options used by the tibble package to format the output. Seetibble::print() for more details.

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 classcolindiag

export

A logical argument. IfTRUE, a *.txt file is exported tothe working directory.

file.name

The name of the file ifexport = TRUE

digits

The significant digits to be shown.

...

Options used by the tibble package to format the output. Seetibble::print() for more details.

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 classcorr_coef

export

A logical argument. IfTRUE, a *.txt file is exported tothe working directory.

file.name

The name of the file ifexport = TRUE

digits

The significant digits to be shown.

...

Options used by the tibble package to format the output. Seetibble::formatting() for more details.

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

Theecovalence x

export

A logical argument. IfTRUE, a *.txt file is exported tothe working directory.

file.name

The name of the file ifexport = TRUE

digits

The significant digits to be shown.

...

Options used by the tibble package to format the output. Seetibble::print() for more details.

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

export

A logical argument. IfTRUE, a *.txt file is exported tothe working directory.

file.name

The name of the file ifexport = TRUE

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

export

A logical argument. IfTRUE, a *.txt file is exported tothe working directory

file.name

The name of the file ifexport = TRUE

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

export

A logical argument. IfTRUE, a *.txt file is exported tothe working directory

file.name

The name of the file ifexport = TRUE

digits

The significant digits to be shown.

...

Options used by the tibble package to format the output. Seetibble::print() for more details.

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

export

A logical argument. IfTRUE, a *.txt file is exported tothe working directory

file.name

The name of the file ifexport = TRUE

digits

The significant digits to be shown.

...

Options used by the tibble package to format the output. Seetibble::print() for more details.

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

export

A logical argument. IfTRUE, a *.txt file is exported tothe working directory.

file.name

The name of the file ifexport = TRUE

digits

The significant digits to be shown.

...

Options used by the tibble package to format the output. Seetibble::print() for more details.

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

what

What should be printed.what = "all" for both statisticsand ranks,what = "stats" for statistics, andwhat = "ranks"for ranks.

export

A logical argument. IfTRUE, a *.txt file is exported tothe working directory.

file.name

The name of the file ifexport = TRUE

digits

The significant digits to be shown.

...

Options used by the tibble package to format the output. Seetibble::print() for more details.

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 classlpcor orlpcor_group.

export

A logical argument. IfTRUE, a *.txt file is exportedto the working directory

file.name

The name of the file ifexport = TRUE

digits

The significant digits to be shown.

...

Options used by the tibble package to format the output. Seetibble::print() for more details.

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

export

A logical argument. IfTRUE|T, a *.txt file is exportedto the working directory

file.name

The name of the file ifexport = TRUE

digits

The significant digits to be shown.

...

Options used by the tibble package to format the output. Seetibble::print() for more details.

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

export

A logical argument. IfTRUE|T, a *.txt file is exportedto the working directory

file.name

The name of the file ifexport = TRUE

digits

The significant digits to be shown.

...

Options used by the tibble package to format the output. Seetibble::print() for more details.

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

export

A logical argument. IfTRUE|T, a *.txt file is exportedto the working directory

file.name

The name of the file ifexport = TRUE

digits

The significant digits to be shown.

...

Options used by the tibble package to format the output. Seetibble::print() for more details.

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 classpath_coeff orgroup_path.

export

A logical argument. IfTRUE, a *.txt file is exported tothe working directory

file.name

The name of the file ifexport = TRUE

digits

The significant digits to be shown.

...

Options used by the tibble package to format the output. Seetibble::print() for more details.

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

export

A logical argument. IfTRUE, a *.txt file is exported tothe working directory

file.name

The name of the file ifexport = TRUE

digits

The significant digits to be shown.

...

Options used by the tibble package to format the output. Seetibble::print() for more details.

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

Theplaisted_peterson x

export

A logical argument. IfTRUE, a *.txt file is exported tothe working directory.

file.name

The name of the file ifexport = TRUE

digits

The significant digits to be shown.

...

Options used by the tibble package to format the output. Seetibble::print() for more details.

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

export

A logical argument. IfTRUE, a *.txt file is exportedto the working directory

file.name

The name of the file ifexport = TRUE

digits

The significant digits to be shown.

...

Options used by the tibble package to format the output. Seetibble::print() for more details.

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

export

A logical argument. IfTRUE, a *.txt file is exported tothe working directory.

file.name

The name of the file ifexport = TRUE

digits

The significant digits to be shown.

...

Options used by the tibble package to format the output. Seetibble::print() for more details.

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

export

A logical argument. IfTRUE, a *.txt file is exported tothe working directory

file.name

The name of the file ifexport = TRUE

digits

The significant digits to be shown.

...

Options used by the tibble package to format the output. Seetibble::print() for more details.

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

export

A logical argument. IfTRUE, a *.txt file is exported tothe working directory

file.name

The name of the file ifexport = TRUE

digits

The significant digits to be shown. Seetibble::print() for more details.

...

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

export

A logical argument. IfTRUE|T, a *.txt file is exportedto the working directory

blup

A logical argument. IfTRUE|T, the blups are shown.

file.name

The name of the file ifexport = TRUE

digits

The significant digits to be shown.

...

Options used by the tibble package to format the output. Seetibble::print() for more details.

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

group_by,mutate,rename,select

tidyselect

contains,ends_with,everything,last_col,matches,num_range,one_of,starts_with


Reorder a correlation matrix

Description

[Stable]

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

[Stable]

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

RemoveNA values? Default toTRUE.

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

[Stable]

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 classperforms_ammi,waas,anova_joint, orgafem

var

The variable to plot. Defaults tovar = 1 the firstvariable ofx.

conf

Level of confidence interval to use in the Q-Q plot (0.95 bydefault).

labels

Logical argument. IfTRUE labels the points outsideconfidence interval limits.

plot_theme

The graphical theme of the plot. Default isplot_theme = theme_metan(). For more details, seeggplot2::theme().

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 iswhich = c(1:4) that means that the first four graphics will be plotted.

ncol,nrow

The number of columns and rows of the plot pannel. DefaultstoNULL

...

Additional arguments passed on to the functionpatchwork::wrap_plots().

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

[Stable]

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

resp

The response variable(s).

prob

The probability error.

verbose

Ifverbose = TRUE then some results are shown in theconsole.

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.data, except that inresp are selected. Toselect specific covariates from.data, use a list of unquotedcomma-separated variable names (e.g.traits = c(var1, var2, var3)),an specific range of variables, (e.g.traits = c(var1:var3)), oreven a select helper likestarts_with("N").

npred

An integer specifying the size of the subset of predictors to beselected

Value

A list with the following elements:

Author(s)

Tiago Olivototiagoolivoto@gmail.com

Examples

library(metan)mod <- select_pred(data_ge2, resp = PH, npred = 10)mod$predictorsmod$AIC

Pseudoinverse of a square matrix

Description

[Stable]

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

[Stable]

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

Details

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:

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

[Stable]

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,resp = c(var1, var2, var3).

verbose

Logical argument. Ifverbose = FALSE the code will runsilently.

Value

An object of classsuperiority where each element is theresult of one variable and contains the following items:

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

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"both" (x andy major grids). Allows alsogrid = "x" for grids in x axis only,grid = "y" for grid in y axis only, orgrid = "none" for nogrids.

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.


Transpose a data frame

Description

[Experimental]

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

[Experimental]

Helper function to perform Tukey post-hoc tests. It is used ingafem.

Usage

tukey_hsd(model, ..., out = "long")

Arguments

model

an object of classaov orlm.

...

other arguments passed to the functionstats::TukeyHSD(). These include:

  • which: A character vector listing terms in the fitted model for which theintervals should be calculated. Defaults to all the terms.

  • ordered: A logical value indicating if the levels of the factor should beordered according to increasing average in the sample before takingdifferences. If ordered is true then the calculated differences in the meanswill all be positive. The significant differences will be those for which thelwr end point is positive.

out

The format of outputs. Ifout = "long" a 'long' format(tibble) is returned. Ifout = "wide", a matrix with the adjustedp-values for each term is returned.

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

[Stable]

Function to quick encode vector or columns to a specific format.

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.data is a dataframe, then... are the variable(s) to encode to a format.

.keep

Allows you to control which columns from.data areretained in the output.

  • "all" (default) retains all variables.

  • "used" keeps any variables used to make new variables.

.pull

Allows you to pull out the last column of the output. It isuseful in combination with.keep = "used". In this case, a vectorwill be created with the used column.

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

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 withNA Defaults toNA.

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

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

[Stable]

These functions allows interacting with the system clipboard. It is possibleread from the clipboard or write a data frame or matrix 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 toTRUE.

sep

The separator which should be used in the copied output.

...

Further arguments to be passed toutils::read.table().

.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, defaultstoFALSE.

col_names

Decides if the output should keep column names or not,defaults toTRUE.

Value

Nothing

Author(s)

Tiago Olivototiagoolivoto@gmail.com


Utilities for data organization

Description

[Experimental]

Useful function for data organization before statistical analysis

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. Ifverbose = FALSE the code will runsilently.

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

[Stable]

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 inmake_upper_tri() andmake_lower_tri() or atriangular matrix inmake_sym().tidy_sym() accepts bothsymmetrical or triangular matrices.

diag

What show in the diagonal of the matrix. Default toNA.

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"upper". In this case,a symmetric matrix will be built based on the values of a lower triangularmatrix.

keep_diag

Keep diagonal values in the tidy data frame? Defaults toTRUE.

Details

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

[Stable]

NAs and zeros can increase the noise in multi-environment trial analysis.This collection of functions will make it easier to deal with them.

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 fillNAs infill_na(), replaceNAs inreplace_na() or zeros inreplace_zero(). If... is null then all variables in.data will be evaluated. Itmust be a single variable name or a comma-separated list of unquotedvariables names. Select helpers are also allowed.

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. IfTRUE (default) shows in consolethe rows or columns deleted.

replacement

The value used for replacement. Defaults to0. Otherpossible values are Use"colmean","colmin", and"colmax" to replacemissing values with column mean, minimum and maximum values, respectively.

prop

The proportion (percentage) ofNA values to generate in.data.

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

[Stable]

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.

  • Forround_cols()... are the variables to round. If novariable is informed, all the numeric variables fromdata are used.

  • Forall_lower_case(),all_upper_case(),all_title_case(),stract_number(),stract_string(),remove_strings(), andtidy_strings()... are thevariables to apply the function. If no variable is informed, the functionwill be applied to all non-numeric variables in.data.

pattern

A string to be matched. Regular Expression Syntax is alsoallowed.

replacement

A string for replacement.

ignore_case

IfFALSE (default), the pattern matching is casesensitive and ifTRUE, case is ignored during matching.

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

[Experimental]

Progress bars are configurable, may include percentage, elapsed time, andcustom text.

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 havemin < max.

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 fromcallingprogress() up to each call ofrun_progress().

  • type = 1: Shows a progress bar without percentage or elapsed time.

  • type = 2: The default, shows the progress bar and its percentage.

  • type = 3: Shows the progress bar and elapsed time.

  • type = 4: Shows the progress bar, percentage, and elapsed time.

width

The the width of the progress bar. Defaults to the number ofcharacters is that which fits intogetOption("width").

time

The system time used to compute the elapsed time from callingprogress() to each call ofrun_progress(). Defaults toSys.time().

pb

An object created withprogress()

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

sleep

Suspend execution for a time interval withSys.sleep() withinrun_progress(). Defaults to0.

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

[Stable]

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.

  • Foradd_cols() andadd_rows() is name-value pairs. All valuesmust have one element for each row in.data when usingadd_cols() or one element for each column in.data when usingadd_rows(). Values of length 1 will be recycled when usingadd_cols().

  • Forremove_cols() andselect_cols(),... is thecolumn name or column index of the variable(s) to be dropped.

  • Foradd_prefix() andadd_suffix(),... is the columnname to add the prefix or suffix, respectively. Select helpers are allowed.

  • Forcolumns_to_first() andcolumns_to_last(),... isthe column name or column index of the variable(s) to be moved to first orlast in.data.

  • Forremove_rows() andselect_rows(),... is an integerrow value.

  • Forconcatenate(),... is the unquoted variable names to beconcatenated.

  • Forget_levels(),get_level_comb(), andget_level_size()... is the unquoted variable names to get thelevels, levels combinations and levels size, respectively.

.before,.after

Foradd_cols(),concatenate(), andreorder_cols(), one-based column index or column name where to addthe new columns, default: .after last column. Foradd_rows(),one-based row index where to add the new rows, default: .after last row.

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 inadd_prefix() andadd_suffix(), respectively.

sep

The separator to appear when usingconcatenate(),add_prefix(), oradd_suffix(). Defaults to to"_".

cols

A quoted variable name to check if it exists in.data.

new_var

The name of the new variable containing the concatenatedvalues. Defaults tonew_var.

drop

Logical argument. IfTRUE keeps the new variablenew_var and drops the existing ones. Defaults toFALSE.

pull

Logical argument. IfTRUE, returns the last column (on theassumption that's the column you've created most recently), as a vector.

offset

Set it ton to select thenth variable from theend (forselect_last_col()) of from the begin (forselect_first_col())

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

Usage

sample_random(data, n, prop, by = NULL, weight = NULL)sample_systematic(data, n, r = NULL, by = NULL)

Arguments

data

A data frame. Ifdata is agrouped_df, the operation will beperformed on each group (stratified).

n,prop

Provide eithern, the number of rows, orprop, theproportion of rows to select. If neither are supplied,n = 1 will beused.

by

A categorical variable to compute the sample by. It is ashortcut todplyr::group_by() that allows to group the data by onecategorical variable. If more than one grouping variable needs to be used,usedplyr::group_by() to pass the data grouped.

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,r is randomly selected between1:k

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

[Stable]

Provides alternative function tobase::union(),base::intersect(), andbase::setdiff().

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"set_1", "⁠Set_2"⁠,"Set_3" and so on.If vectors are given in..., the set names will be named with the namesof the objects provided. Data frames are also allowed, provided that commoncolumn names exist.

pairs

Returns the pairwise unions of the sets? Defaults toFALSE.

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

[Stable]

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.

  • For⁠*_by⁠ functions,... is one or more categorical variablesfor grouping the data. Then the statistic required will be computed for allnumeric variables in the data. If no variables are informed in...,the statistic will be computed ignoring all non-numeric variables in.data.

  • For the other statistics,... is a comma-separated of unquotedvariable names to compute the statistics. If no variables are informed in n..., the statistic will be computed for all numeric variables in.data.

na.rm

IfFALSE, the default, missing values are removed with awarning. IfTRUE, missing values are silently removed.

level

The confidence level for the confidence interval of the mean.Defaults to 0.95.

var

The variable to compute the frequency table. SeeDetails formore details.

k

The number of classes to be created. SeeDetails formore details.

digits

The number of significant figures to show. Defaults to 2.

table

A frequency table computed withfreq_table().

xlab,ylab

Thex andy labels.

fill,color

The color to fill the bars and color the border of the bar,respectively.

ygrid

Shows a grid line on they axis? Defaults toTRUE.freq_hist <- function(table,

.vars

Used to select variables in the⁠*_by()⁠ functions. One or moreunquoted expressions separated by commas. Variable names can be used as ifthey were positions in the data frame, so expressions likex:y can beused to select a range of variables. Defaults toNULL (all numericvariables are analyzed)..

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) if⁠n =< 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

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

[Experimental]

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 toNULL. This means thatthe directory will be set to the path of the file. If the path doesn't exist, theuser will be asked if he wants to create such a folder.

Value

Examples

## Not run: get_wd_here()set_wd_here()open_wd_here()## End(Not run)

Draw Venn diagrams

Description

[Stable]

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"set_1", "⁠Set_2"⁠,"Set_3" and so on.If vectors are given in..., the set names will be named with the namesof the objects provided.

names

By default, the names of the sets are set as the names of theobjects in... (names = NULL). Usenames to override this default.

show_elements

Show set elements instead of count. Defaults toFALSE.

split_labels

Splits the element labels into new lines eachsplit_each elements? Defaults toTRUE. This is useful to split labelsinto several lines whenshow_elements = TRUE is used.

split_each

The number of elements that will apper in each line whensplit_labels = TRUE is used.

show_sets

Show set names instead of count. Defaults toFALSE.

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 to0.5.

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"solid".

name_color

Text color for set names. Defaults to"black".

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 whenshow_elements = TRUE. Defaultsto",".

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

[Stable]

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 exampleresp = c(var1, var2, var3).

block

Defaults toNULL. In this case, a randomized completeblock design is considered. If block is informed, then a resolvablealpha-lattice design (Patterson and Williams, 1976) is employed.All effects, except the error, are assumed to be fixed.

mresp

The new maximum value after rescaling the response variable. Bydefault, all variables inresp are rescaled so that de maximum valueis 100 and the minimum value is 0 (i.e.,mresp = NULL). It must be acharacter vector of the same length ofresp if rescaling is assumedto be different across variables, e.g., if for the first variable smallervalues are better and for the second one, higher values are better, thenmresp = c("l, h") must be used. Character value of length 1 will berecycled with a warning message.

wresp

The weight for the response variable(s) for computing the WAASBYindex. By default, all variables inresp have equal weights for meanperformance and stability (i.e.,wresp = 50). It must be a numericvector of the same length ofresp to assign different weights acrossvariables, e.g., if for the first variable equal weights for meanperformance and stability are assumed and for the second one, a higherweight for mean performance (e.g. 65) is assumed, thenwresp = c(50, 65) must be used. Numeric value of length 1 will be recycled with awarning message.

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 isNULL (Significant IPCAs are used). If values areinformed, the number of IPCAS will be used independently on itssignificance. Note that if two or more variables are included inresp, thennaxis must be a vector.

ind_anova

Logical argument set toFALSE. IfTRUE anwithin-environment ANOVA is performed.

verbose

Logical argument. Ifverbose = FALSE the code is runsilently.

Value

An object of classwaas with the following items for eachvariable:

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

[Stable]

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 exampleresp = c(var1, var2, var3). Select helpers are also allowed.

mresp

The new maximum value after rescaling the response variable. Bydefault, all variables inresp are rescaled so that de maximum valueis 100 and the minimum value is 0 (i.e.,mresp = NULL). It must be acharacter vector of the same length ofresp if rescaling is assumedto be different across variables, e.g., if for the first variable smallervalues are better and for the second one, higher values are better, thenmresp = c("l, h") must be used. Character value of length 1 will berecycled with a warning message.

wresp

The weight for the response variable(s) for computing the WAASBYindex. Must be a numeric vector of the same length ofresp. Defaultsto 50, i.e., equal weights for stability and mean performance.

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 tomin_expl_var. For example, if the explained variance (in percentage)in seven possible IPCAs are⁠56, 21, 9, 6, 4, 3, 1⁠, resulting in acumulative proportion of⁠56, 77, 86, 92, 96, 99, 100⁠, thenp = 3, i.e., three IPCAs will be used to compute the index WAAS.

verbose

Logical argument. Ifverbose = FALSE the code is runsilently.

...

Arguments passed to the functionimpute_missing_val() for imputation of missing values in caseof unbalanced data.

Value

An object of classwaas_means with the following items for eachvariable:

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

waas()waasb()

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

[Stable]

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.

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 exampleresp = c(var1, var2, var3).

block

Defaults toNULL. In this case, a randomized completeblock design is considered. If block is informed, then an alpha-latticedesign is employed considering block as random to make use of inter-blockinformation, whereas the complete replicate effect is always taken asfixed, as no inter-replicate information was to be recovered (Mohring etal., 2015).

by

One variable (factor) to compute the function by. It is a shortcuttodplyr::group_by().This is especially useful, for example,when the researcher want to compute the indexes by mega-environments. Inthis case, an object of class waasb_grouped is returned.mtsi() can then be used to compute the mtsi index within eachmega-environment.

mresp

The new maximum value after rescaling the response variable. Bydefault, all variables inresp are rescaled so that de maximum valueis 100 and the minimum value is 0 (i.e.,mresp = NULL). It must be acharacter vector of the same length ofresp if rescaling is assumedto be different across variables, e.g., if for the first variable smallervalues are better and for the second one, higher values are better, thenmresp = c("l, h") must be used. Character value of length 1 will berecycled with a warning message.

wresp

The weight for the response variable(s) for computing the WAASBYindex. By default, all variables inresp have equal weights for meanperformance and stability (i.e.,wresp = 50). It must be a numericvector of the same length ofresp to assign different weights acrossvariables, e.g., if for the first variable equal weights for meanperformance and stability are assumed and for the second one, a higherweight for mean performance (e.g. 65) is assumed, thenwresp = c(50, 65) must be used. Numeric value of length 1 will be recycled with awarning message.

random

The effects of the model assumed to be random. Defaults torandom = "gen". SeeDetails to see the random effectsassumed depending on the experimental design of the trials.

prob

The probability for estimating confidence interval for BLUP'sprediction.

ind_anova

Logical argument set toFALSE. IfTRUE anwithin-environment ANOVA is performed.

verbose

Logical argument. Ifverbose = FALSE the code will runsilently.

...

Arguments passed to the functionimpute_missing_val() for imputation of missing values in thematrix of BLUPs for genotype-environment interaction, thus allowing thecomputation of the WAASB index.

Value

An object of classwaasb with the following items for eachvariable:

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

[Stable]

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

An object computed withwaas(),waasb(), ormps().

mresp

A numeric value that will be the new maximum value afterrescaling. By default, the variable inresp is rescaled so that theoriginal maximum and minimum values are 100 and 0, respectively. Let usconsider that for a specific trait, say, lodging incidence, lower valuesare better. In this case, you should usemresp = 0 to rescale theresponse variable so that the lowest values will become 100 and the highestvalues 0.

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

prob

The p-value for considering an interaction principal componentaxis significant. must be multiple ofincrement. If this assumptionis not valid, an error will be occur.

progbar

A logical argument to define if a progress bar is shown.Default isTRUE.

Value

An object of classwsmp with the following items for eachvariable

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

resca(),mps(),mtmps()

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)

[8]ページ先頭

©2009-2025 Movatter.jp