# \donttest{
library(metan)
# simulate a data set
# 10 genotypes
# 5 replications
# 4 traits
df <-
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 genotypes
gmd(mod, "blupg")
# Compute the MGIDI index
# Default options (all traits with positive desired gains)
# Equal weights for all traits
mgidi_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 pressure
mgidi_ind2 <-
mgidi(mod,
weights = c(1, .2, .2, 1),
SI = 30)
gmd(mgidi_ind2, "MGIDI")
# plot the contribution of each factor on the MGIDI index
p1 <- 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 V4
mgidi_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 trait
ideotype <- 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")
# }
Run the code above in your browser using DataLab