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

Request Download from Listo Agriculture

# Mandala is distributed directly by Listo Agriculture.
# Request a download at https://listoagriculture.com/products

# After downloading the file you receive, install it locally:
# macOS/Linux (source package)
install.packages("path/to/mandala_x.y.z.tar.gz", repos = NULL, type = "source")

# Windows (binary package)
install.packages("path\\to\\mandala_x.y.z.zip", repos = NULL, type = "win.binary")

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

model <- mandala(
  fixed  = yield ~ genotype,
  random = ~ block,
  data   = field_data,
  R_formula = ~ ar1(row):ar1(col)
)

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 quantitative genetics work
  4. lme4 Comparison — For general mixed model context

Getting Help