AMMI plots in R languages
The genotypebyenvironment interaction is often analyzed by AMMI analysis (Gauch 1992). The interpretation of this analysis is often based on the AMMI2 biplot. But sometimes it is need to use easier to read diagrams. Usually in that cases it is used the yield plot (lines represented the AMMI adjusted genotypes reaction on the different environmental conditions) or nominal yield plot (main effects of genotypes plus AMMI adjusted GenotypebyEnvironment interaction effects). So there are presented some codes to AMMI analysis for R languages that allow generate those diagrams. They were written for nonprofessional R users. Those codes were tested in a few computers and a few examples so it is no guarantee that they will run on all operating systems, version of R of R setups, but it is written enough simple that I wonder that they will.
First, you need to load your data set into R. he easy way is to write data set with genotypes names in first column and environments names in first row in .txt file (with one tabulation chart as separator). Next you import those data by read.table function. For example:
dataSet<read.table("C:/folder/subfolder/dataSet.txt")
Description of AMMI.table function. This function returns analysis of variance for interaction principal components.
Usage:
AMMI.table(X, err.MS=NA, err.df=NA, test="FR", rounding=c(2,2,2,3))
Arguments:
X – twoway table. This is the data set with genotypes names as row names and and environments names as column names.
err.MS – Errom mean square that will be used for testing principal components of GE interaction.
err.df – Error degree of freedom.
test – (optional) the type of test. If “FR” then it will be used FR test (Cornellius 1993), if “F” then Gollob test (Gollob 1968).
rounding – the digits will be used to rounded the results. First value will rounds the sum of squares, second – means squares, third – wariance ratio and fourth – Pvalues. The default is 2, 2, 2, 3.
Value: The outcome of function is analysis of variance for interaction principal components.
Examples: Bellow were shown three examples of use. First – tha analysis of dataSet if there was Errom mean square equal 1.8 with 50 degree of freedom; second – if you will use the Gollob test; third – if you will have more digits.
AMMI.table(dataSet, 1.3, 50)
AMMI.table(dataSet, 1.8, 50, "F")
AMMI.table(dataSet, 1.8, 50, rounding=c(3,3,3,3))
The output of firs example for the dataSet was written bellow: The first two were significant, so The AMMI2 model is appropriate.
SS df MS F P.v
IPC 1 580.30 98 5.92 3.29 0.000
IPC 2 329.09 78 4.22 2.34 0.001
IPC 3 153.11 60 2.55 1.42 0.103
IPC 4 44.27 44 1.01 0.56 0.974
IPC 5 2.39 30 0.08 0.04 1.000
IPC 6 1.05 18 0.06 0.03 1.000
IPC 7 0.45 8 0.06 0.03 1.000
Description of mplot.AMMI function. This function draws the diagram of genotypes reaction on different environmental condition according the AMMI model (AMMI adjusted genotypes reaction). The environments are put into horizontal axis.
Usage:
mplot.AMMI<function(X, nbPC=1, ordering="mean", cex.axis=1, File=FALSE, plot.height=7, plot.width=10, plot.res=300, plot.units="in", ...)
Arguments:
X – twoway table. This is the data set with genotypes names as row names and environments names as column names.
nbPC – number of principal components used in AMMI model in the aim to compute AMMI adjusted means (it could be set according to AMMI.table function). Moreover it can be equal ‘Full’ if you need plot according to full AMMI model (original genotypes means).
ordering – The order of environments drawing on the axis. The default is ‘mean’ so the environments with smaller yield means were on the left and with greather means of yiels on the right side of plot. It can be used order according scores of IPC1 of AMMI model (‘PC1’), according angle of AMMI2 biplot (‘angle’) or according the order in the column of X data set (‘FALSE’).
cex.axis – the size of characters that were described axis. Default is 1
File – the file path and name if the diagram have be save into disk. Default is ‘FALSE’ so the plot will not be saved. This function requires ‘grDevices’ packages to write plot into file. You need install it first.
plot.height, plot.width, plot.res, plot.units – if the plot will be saved you can describe its height, width, resolution and units. default units is ‘in’ – inches – and then the height is 7 inches, width 10 inches and resoluton 300 pixels per inch.
... – additive parameters for matplot function, for example main (title of plot), lwd (line widths), cex (size of characters), xlab (label of horizontal axis), ylab (label of vertical axis). See ‘par’ in R help.
Value: The output of function is structured as a listobject.
AMMI.adjusted.means – AMMI adjusted means according to number of interaction principal components (argument ‘nbPC’).
Env.symbols – the used symbols (characters) on the axis represented environmental names and the value that allows ordering the environments.
Gen.symbols – the used symbols (characters) on the plot representing genotype names.
Examples:
The default plot based on dataSet, the plot based on AMMI2 adjusted means and the plot based on full AMMI model. the environments are ordered according they means, angle of AMMI2 biplot, environmental scores of first principal component respectively.
mplot.AMMI(dataSet)
mplot.AMMI(dataSet, nbPC=2, ordering=”angle”)
mplot.AMMI(dataSet, nbPC=”Full”, ordering=”PC1”)
Moreover it can be given additive parameters, for example the title, the size of fonts, labels of both axes with bigger size of characters.
mplot.AMMI(dataSet, main="Genotypes reaction for different environmental condition")
mplot.AMMI(dataSet, lwd=2, cex=1.5, cex.axis=1.5)
mplot.AMMI(dataSet, lwd=2,cex=1.5,cex.axis=1.5,xlab="Environments",ylab="Yield in t/ha",cex.lab=1.5)
The plots can be saved into the disk, for example into partition F, folder Temp with default size or with 72dpi 800x600 pixel size.
mplot.AMMI(dataSet, lwd=2, cex=1.1, cex.axis=1.5, xlab="Environments", ylab="Yield in t/ha", cex.lab=1.5, File="F:/Temp/yield.png")
mplot.AMMI(dataSet, xlab="Environments", ylab="Yield in t/ha", File="F:/Temp/yield_mini.png", plot.height=600, plot.width=800, plot.units="px", plot.res=72)
Description of nominal.yield.plot function. This plot gives order of yield of genotypes according to AMMI1 model (the model with 1 principal component). The nominal yield is described by sum of grand mean (if a parameter mean.y is not equal ‘FALSE’), main effects of genotypes and GE interactions according to AMMI1 (AMMI1 adjusted interaction effects).
Usage:
nominal.yield.plot(X, mean.y=TRUE, mean.col="gray", mean.lty=3, mean.lwd=3, File=FALSE, plot.height=7, plot.width=10, plot.res=300, plot.units="in",...)
Arguments:
X – twoway table. This is the data set with genotypes names as row names and environments names as column names
mean.y – If the grand mean have be add (and draw into plot as line) then this argument must be ‘TRUE’ (default). If not – pleas write ‘FALSE’. If you get a value then it will be drawn the horizontal line at a given value.
mean.col, mean.lty, mean.lwd – parameters of mean line, color, line type ("blank", "solid", "dashed", "dotted", "dotdash", "longdash", or "twodash") and line width. See ‘par’ in R help.
File, plot.height, plot.width, plot.res, plot.units – the same as in mplot.AMMI function.
... – additive parameters for matplot and axis function, for example main (title of plot), lwd (line widths), xlab (label of horizontal axis), ylab (label of vertical axis), cex (size of characters), cex.axis (size of characters described axes), cex.lab (size of axis labels). See ‘par’ in R help
Value: The output of function is structured as a listobject.
Env.symbols – symbol (letters) used to mark environments on horizontal axis
Gen.symbols – symbol (letters) used to mark genotypes names on the plot
Env.scores – AMMI scores of environments used to draw the plot
Gen.scores – AMMI scores of genotypes used to draw the plot
contained.part.of.SS – the part of sum of squares of G+GE (main effects of genotypes and genotypebyenvironment intetraction) saved in the plot (in AMMI model with one principal component)
Examples:
The nominal yield plot without the mean lines, with grand mean lines and described axes, with grand mean line in blue color and thin, respectively.
nominal.yield.plot(dataSet, mean.y=FALSE)
nominal.yield.plot(dataSet, cex=2,cex.axis=2,xlab="Environment scores of PC1 according to AMMI model",ylab="Nominal Yield in t/ha",cex.lab=1.5)
nominal.yield.plot(Y,mean.col="blue",mean.lty=1,mean.lwd=1)
The nominal yield plot will be saved into a disk with default parameters or with small size
nominal.yield.plot(Y,File="F:/Temp/naminal_yield.png")
nominal.yield.plot(Y,File="F:/Temp/naminal_yield2.png",plot.height = 4, plot.width = 6, plot.res = 72)
