A concise reference for common tasks when analyzing field trial data with the mandala package.
Basic Model Syntax
Simple RCBD
model <- mandala (
fixed = yield ~ genotype,
random = ~ block,
data = field_data
)
Alpha-Lattice Design
model <- mandala (
fixed = yield ~ genotype,
random = ~ rep + rep: incomplete_block,
data = field_data
)
Multi-Environment Trial
model <- mandala (
fixed = yield ~ genotype + env + genotype: env,
random = ~ env: block,
data = field_data
)
Spatial Model (AR1)
model <- mandala (
fixed = yield ~ genotype,
random = ~ block + ar1 (row) + ar1 (col),
data = field_data
)
Spatial Model (P-spline)
model <- mandala (
fixed = yield ~ genotype,
random = ~ pspline2D (row.num, col.num,
nseg = c (10 , 10 ),
degree = c (3 , 3 ),
pord = c (2 , 2 )),
data = field_data
)
Factor-Analytic G×E
model <- mandala (
fixed = yield ~ env + genotype,
random = ~ FA (genotype, env, k = 2 ) + by (env): ar1 (row) + by (env): ar1 (col),
data = met_data
)
Genomic Prediction (GBLUP)
# Prepare GRM
grm_prep <- mandala_grm_prep (
GRM = "path/to/grm.csv" ,
data = pheno_data,
gen_col = "genotype" ,
GRM_label = "GRM"
)
# Fit model
model <- mandala (
fixed = yield ~ env,
random = ~ GM (genotype, GRM) + GM (genotype, GRM): env,
matrix_list = grm_prep,
data = pheno_data
)
Package Comparison
Mandala vs Sommer vs lme4
Model fit
mandala()
mmer()
lmer()
Variance components
$varcomp
summary()$varcomp
VarCorr()
BLUPs
mandala_predict()
randef()
ranef()
Heritability
h2_estimates()
Manual
Manual
GBLUP
GM(), mandala_gp()
vsr(Gu=)
Not supported
FA models
FA()
dsr()
Not supported
AR1 spatial
ar1(row)
Custom cov
Not supported
P-spline spatial
pspline2D()
Not supported
Not supported
Variograms
mandala_variogram()
Not supported
Not supported
Common Experimental Designs
1. RCBD
Genotype
Fixed
Block
Random
yield ~ genotype + (1 | block)
2. Alpha-Lattice
Genotype
Fixed
Rep
Random
Incomplete Block(Rep)
Random
yield ~ genotype + (1 | rep) + (1 | rep: incomplete_block)
3. Row-Column
Genotype
Fixed
Row
Random
Column
Random
yield ~ genotype + (1 | row) + (1 | col)
4. Multi-Environment Trial
Genotype
Fixed
Environment
Fixed
G×E
Fixed
Block(Env)
Random
yield ~ genotype + env + genotype: env + (1 | env: block)
5. FA G×E Model
Environment
Fixed
Genotype
Fixed
FA G×E
Random (k factors)
# Mandala syntax
random = ~ FA (genotype, env, k = 2 )
6. GBLUP
Intercept
Fixed
Genotype (GRM)
Random
# Mandala syntax
random = ~ GM (genotype, GRM)
Data Preparation Checklist
Model Checking
Check Convergence
summary (model)
# Look for warnings
Examine Residuals
plot (fitted (model), residuals (model))
abline (h = 0 , col = "red" )
Check Normality
qqnorm (residuals (model))
qqline (residuals (model))
Common Issues
Model doesn’t converge
Check for missing data, verify design
Negative variance estimates
Simplify model, check data structure
Very low heritability
Check data quality, model specification
Visualization Templates
G×E Interaction
gxe_data %>%
ggplot (aes (x = environment, y = mean_yield,
group = genotype, color = genotype)) +
geom_line () +
geom_point (size = 2 ) +
theme_minimal ()
Field Heatmap
field_data %>%
ggplot (aes (x = col, y = row, fill = yield)) +
geom_tile () +
scale_fill_viridis_c () +
theme_minimal ()
Resources
Key References
Piepho et al. (2003) - BLUP in plant breeding
Gilmour et al. (1997) - Spatial analysis
Smith et al. (2005) - Variety trials
Rodríguez-Álvarez et al. (2018) - SpATS spatial analysis
VanRaden (2008) - Genomic relationship matrices