metan (version 1.2.1)

covcor_design: Variance-covariance matrices for designed experiments

Description

Compute variance-covariance and correlation matrices using data from a designed (RCBD or CRD) experiment.

Usage

covcor_design(.data, gen, rep, resp, design = "RCBD", by = NULL, type = NULL)

Arguments

.data

The dataset containing the columns related to Genotypes, replication/block and response variables. Alternatively, it is possible to use an object of class 'split_factors' to compute the results for each level of the grouping factor. See ?split_factors.

gen

The name of the column that contains the levels of the genotypes.

rep

The name of the column that contains the levels of the replications/blocks.

resp

The response variables. For example resp = c(var1, var2, var3).

design

The experimental design. Must be RCBD or CRD.

by

One variable (factor) to split the data into subsets. The function is then applied to each subset and returns a list where each element contains the results for one level of the variable in by. To split the data by more than one factor variable, use the function split_factors to pass subsetted data to .data.

type

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

Value

An object of class covcor_design containing the following items:

  • geno_cov The genotypic covariance.

  • phen_cov The phenotypic covariance.

  • resi_cov The residual covariance.

  • geno_cor The phenotypic correlation.

  • phen_cor The phenotypic correlation.

  • resi_cor The residual correlation.

If .data is an object of class split_factors then the output will be a list with the above values for each grouping variable in the function split_factors to pass subsetted data.to pass subsetted data to code.data.to pass subsetted data to code.data.

Examples

Run this code
# NOT RUN {
library(metan)
# List of matrices
data <- subset(data_ge2, ENV == 'A1')
matrices <- covcor_design(data, gen = GEN, rep = REP,
                           resp = c(PH, EH, NKE, TKW))

# Genetic correlations
gcor <- covcor_design(data,
                      gen = GEN,
                      rep = REP,
                      resp = c(PH, EH, NKE, TKW),
                      type = 'gcor')

# Residual (co)variance matrix for each environment
rcov <- covcor_design(data_ge2,
                      gen = GEN,
                      by = ENV,
                      rep = REP,
                      resp = c(PH, EH, CD, CL),
                      type = "rcov")

# }

Run the code above in your browser using DataLab