# Palimpsest

happy pigs = happy bacon

# asreml-r, univariate analyses

## Some basic models

Lets start with the simplest design normally used in tree breeding programs: randomized complete blocks.

# Reading data and pedigree files

# Fitting model with a family model
dbh.1 <- asreml(dbh ~ 1, random = ~ Block+ Block:Plot + Mom,
data = dat)

# Having a look at the variance components
summary(dbh.1)\$varcomp

# If single tree plots then use:
dbh.2 <- asreml(dbh ~ 1, random = ~ Block+ Mom,
data = dat)

Then we can move to fit an animal model (or tree model, or individual tree model, pick a name), for which we need the inverse of the numerator relationship matrix (obtained from the pedigree).

# Get the inverse of the NRM
pedinv <- asreml.Ainverse(ped)\$ginv

# Fitting model with an animal model
dbh.3 <- asreml(dbh ~ 1, random = ~ Block+ Block:Plot + ped(Tree),
data = dat, ginverse = list(Tree = pedinv))

# Same thing for basic density
den.1  <- asreml(den ~ 1, random = ~ Block+ Block:Plot + ped(Tree),
data = dat, ginverse = list(Tree = pedinv))

Now an incomplete block design, where we have complete replicates and incomplete blocks within each Rep.

# Fitting incomplete block, single tree plot and animal model
dbh.4 <- asreml(dbh ~ 1, random = ~ Rep + Rep/Block+ ped(Tree),
data = dat, ginverse = list(Tree = pedinv))

In some situations, e.g. when you are only interested in predicting breeding values for the parents for backwards selection, you may prefer to use models that are equivalent and computationally less demanding (e.g. a family model over using a tree model). In the case of controlled pollinated material (full sibs):

# Fitting model with a family model
dbh.5 <- asreml(dbh ~ 1, random = ~ Block+ Block:Plot + Mom + and(Dad),
data = dat)

In the previous equation Mom + and(Dad) overlays the design matrices for males and females so you get only one prediction for each parent, in spite of some parents acting as both male and female (which is typical in crossing programs in trees). The variance of motherID will represent var(GCA).

## Diallels

The specification of diallels is very straightforward in asreml, and do not require the creation of many additional variables to hold extra factors. Note: The specification of family code is in such a way that direction of cross does not matter (for example, crosses 55x96 and 96x55 both use the code 5596). When fitting reciprocals code direction is important (for example, the crosses would be coded 5596, for 55x96, and 9655 for 96x55).

# Uses an individual tree model
fm1 <- asreml(dbh ~ 1, random = ~ Rep + Rep.Iblock + Plot +
ped(Tree) + Family + Mom + Recipro,
data = dat, ginverse = list(Tree = pedinv))

# Uses a family model
fm2 <- asreml(dbh ~ 1, random = ~ Rep + Rep.Iblock + Plot +
Dad + and(Mom) + Family + Mom + Recipro,
data = dat)

## Clonal data

Clonal data can be seen as repeated observations of a genotype, thus their analysis is related to repeated measurements, although there is no ordering in time. The analysis of clonal data is straightforward in asreml-r. In the data file all ramets of the same clone will have the same genotype ID, and each genotype will be only once in the pedigree file.

Brian Kennedy (in Animal Model BLUP. Erasmus Intensive Graduate Course. August 20-26 1989. University of Guelph. page 130) showed the mathematics behind using clonal data as repeated measurements, referring to the analysis of embryo splitting. I first ran code like this while working in longitudinal analysis in 1999-2000. However, João Costa e Silva provided me with a very good interpretation of the analyses at the end of 2003. For more details, check: Costa e Silva, J., Borralho, N.M.G. & Potts, B.M. 2004. Additive and non-additive genetic parameters from clonally replicated and seedling progenies of Eucalyptus globulus. Theoretical and Applied Genetics 108: 1113-1119.

# Expanding the previous dbh.4 example to include clones
# Fitting incomplete block, single tree plot and animal model
dbh.6 <- asreml(dbh ~ 1, random = ~ Rep + Rep/Block+ ped(Tree) + ide(Tree),
data = dat, ginverse = list(Tree = pedinv))

The ide(Tree) part of the job, creates an additional matrix for Tree that ignores the pedigree relationships.

## Multiple site, single trait

The traditional approach used in tree breeding to analyze progeny trials in multiple sites was to either assume a unique error variance (and then use the approach explained before) or to correct the data by the site specific error variance and then use the typical approach using the corrected data. Using asreml-R it is possible to use alternative methods, either explicitly fitting a site specific error variance (but keeping a unique additive genetic variance) or fitting site specific additive and residual variances, in fact using a Multivariate Analysis approach, where the expression of a trait in each site is considered a different variable. In any case, any of the alternative methods needs a specification of Covariance Structures.

# Fitting site effects, incomplete block, single tree plot,
# animal model and site specific residual variances (rcov)
dbh.7 <- asreml(dbh ~ Site, random = ~ Site:Rep + Site:Rep:Block+ ped(Tree),
rcov = ~ at(Site):units,
data = dat, ginverse = list(Tree = pedinv))