Get Started

Install Mandala and run your first analysis in minutes

Installation

Prerequisites

  • R version: 4.1.0 or higher
  • Operating System: Windows, macOS, or Linux

If you don’t have R installed, download it from CRAN:

We strongly recommend installing RStudio Desktop — it provides the best experience for working with R and Mandala, including syntax highlighting, integrated help, and data viewers.

Request Free Access from Listo Agriculture

# Mandala is distributed directly by Listo Agriculture.
# 1. Request free access at https://listoagriculture.com/products
# 2. You will receive an email with installation instructions
# 3. Follow the emailed instructions to install from the Listo repository

Your First Analysis

Let’s analyze a simple Randomized Complete Block Design (RCBD):

Step 1: Load packages and create example data

library(mandala)
library(dplyr)
library(ggplot2)

# Create example field trial data
set.seed(123)
n_genotypes <- 10
n_blocks <- 4

field_data <- expand.grid(
  genotype = factor(paste0("G", 1:n_genotypes)),
  block = factor(paste0("B", 1:n_blocks))
)

# Simulate yield with genotype and block effects
field_data$yield <- 5000 + 
  rnorm(n_genotypes, 0, 300)[as.numeric(field_data$genotype)] +
  rnorm(n_blocks, 0, 150)[as.numeric(field_data$block)] +
  rnorm(nrow(field_data), 0, 200)

head(field_data)

Step 2: Visualize the data

ggplot(field_data, aes(x = reorder(genotype, yield), y = yield, color = block)) +
  geom_point(size = 3, alpha = 0.7) +
  coord_flip() +
  theme_minimal() +
  labs(title = "Yield by Genotype and Block",
       x = "Genotype", y = "Yield (kg/ha)")

Step 3: Fit the model

# Fit RCBD model: genotype as fixed, block as random
model <- mandala(
  fixed  = yield ~ genotype,
  random = ~ block,
  data   = field_data
)

# View summary
summary(model)

Step 4: Extract results

# Variance components
var_comps <- summary(model)$varcomp
print(var_comps)

# BLUEs (adjusted genotype means)
blues <- model$BLUEs
print(blues)

Step 5: Calculate heritability

# For heritability, fit with genotype as random
model_random <- mandala(
  fixed  = yield ~ 1,
  random = ~ genotype + block,
  data   = field_data
)

# Get heritability estimates
h2 <- h2_estimates(
  random_mod = model_random,
  fixed_mod  = model,
  genotype   = "genotype"
)
print(h2)

Common Model Specifications

Alpha-Lattice Design

model <- mandala(
  fixed  = yield ~ genotype,
  random = ~ rep + rep:incomplete_block,
  data   = alpha_data
)

Multi-Environment Trial

model <- mandala(
  fixed  = yield ~ genotype + env + genotype:env,
  random = ~ env:block,
  data   = met_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)),
  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
)

# Visualization and diagnostics
fa_biplot(model)
fa_heatmap(model)
fa_reliability(model)

Genomic Prediction (GBLUP)

# Prepare relationship matrix
grm_prep <- mandala_grm_prep(
  GRM     = "path/to/grm.csv",
  data    = pheno_data,
  gen_col = "genotype"
)

# Fit GBLUP model
model <- mandala(
  fixed       = yield ~ env,
  random      = ~ GM(genotype, GRM) + env:block,
  matrix_list = grm_prep,
  data        = pheno_data
)

# Or use the high-level wrapper with cross-validation
gp_fit <- mandala_gp(

  GRM     = "path/to/grm.csv",
  data    = pheno_data,
  gen_col = "genotype",
  fixed   = yield ~ 1,
  random  = ~ GM(genotype, GRM)
)

Next Steps

Ready to dive deeper? Continue with our tutorials:

TipRecommended Learning Path
  1. Introduction — Understand the core concepts
  2. Example Datasets — Work through realistic scenarios
  3. Sommer Comparison — For genomic prediction and quantitative genetics
  4. lme4 Comparison — For general mixed model context
  5. SpATS Comparison — For P-spline spatial analysis

License

Mandala is free to use for any lawful purpose, including commercial use, with no restrictions on outputs. Redistribution, modification, and reverse engineering of the software are not permitted. See the full Mandala License for details.

Getting Help