statgenSTA (version 1.0.2)

plot.TD: Plot function for class TD

Description

Plotting function for objects of class TD. Plots either the layout of the different trials within the TD object or locates the trials on a map. Also a boxplot can be made for selected traits and trials and a plot of correlations between trials. A detailed description and optional extra parameters of the different plots is given in the sections below.

Usage

# S3 method for TD
plot(
  x,
  ...,
  plotType = c("layout", "map", "box", "cor"),
  trials = names(x),
  traits = NULL,
  output = TRUE
)

Arguments

x

An object of class TD.

...

Extra plot options. Described per plotType in their respective section.

plotType

A single character string indicating which plot should be made. See the sections below for a detailed explanation of the plots.

trials

A character vector indicating the trials to be plotted when plotting field layouts. Only used if plotType = "layout" or "box".

traits

A character vector indicating the traits to be plotted in a boxplot. Only used if plotType = "box" or "cor".

output

Should the plot be output to the current device? If FALSE only a list of ggplot objects is invisibly returned.

Layout Plot

Plots the layout of the selected trials (all available trials by default). This plot can only be made for trials that contain both row (rowCoord) and column (colCoord) information. If either one of those is missing the trial is skipped with a warning. If blocks (subBlock) are available for a trial these are indicated in different colors per block, otherwise all plots are colored in grey. If replicates (repId) are available a black line is plotted between diffent replicates. Missing plots are indicated in white. This can either be single plots in a trial or complete missing columns or rows. Extra parameter options:

showGeno

Should individual genotypes be indicated in the plot? Defaults to FALSE

highlight

A character vector of genotypes to be highlighted in the plot.

colorSubBlock

Should subBlocks be colored with a different color per subBlock? Defaults to FALSE. colorSubBlock is ignored when highlight is used to highlight genotypes.

Map Plot

A map is plotted with the locations of the trials in the TD object. Mapping the trials is done based on lattitude and longitude that can be added when creating an object of class TD. Trials without latitude and/or longitude available are skipped with a warning message. The countries in which the trials are located will be plotted on a single map and the location of the trials will be indicated on this map. The actual plot is made using ggplot, but for getting the data for the borders of the countries the maps package is needed. Extra parameter options:

minLatRange

A positive numerical value indicating the minimum range (in degrees) for the latitude on the plotted map. Defaults to 10.

minLongRange

A positive numerical value indicating the minimum range (in degrees) for the longitud on the plotted map. Defaults to 5.

Box Plot

Creates a boxplot per selected trait grouped by trial. Extra parameter options:

groupBy

A character string indicating a column in TD by which the boxes in the plot should be grouped. By default the boxes are grouped per trial.

colorBy

A character string indicating a column in TD by which the boxes are colored. Coloring will be done within the groups indicated by the groupBy parameter.

orderBy

A character string indicating the way the boxes should be ordered. Either "alphabetic" for alphabetical ordering of the groups, "ascending" for ordering by ascending mean, or "descending" for ordering by descending mean. Default boxes are ordered alphabetically.

Correlation Plot

Draws a heatmap of correlations between trials per selected trait. If genotypes are replicated within trials genotypic means are taken before computing correlations. The order of the trials in the heatmap is determined by clustering them.

See Also

Other functions for TD objects: TD, getMeta(), summary.TD()

Examples

Run this code
# NOT RUN {
data("wheatChl")

## Create a TD object.
wheatTD <- createTD(data = wheatChl, genotype = "trt", repId = "rep",
                    subBlock = "bl", rowCoord = "row", colCoord = "col")

## Add meta data to be able to plot locations on a map.
wheatMeta <- getMeta(wheatTD)
wheatMeta$trLocation <- c("Cauquenes", rep("Santa Rosa", times = 4))
wheatMeta$trLat <- c(-35.58, rep(-36.32, times = 4))
wheatMeta$trLong <- c(-72.17, rep(-71.55, times = 4))
wheatTD <- setMeta(wheatTD, wheatMeta)

### Layout plot.

## Plot the layout of one of the trials.
plot(wheatTD, trials = "C_SWS_12")

## Highlight some of the genotypes in the layout.
plot(wheatTD, trials = "C_SWS_12", highlight = c("G001", "G002"))

### Map plot.

## Plot the location of the trials on the map.
plot(wheatTD, plotType = "map")

### Box plot.

## Create a box plot for GY.
plot(wheatTD, plotType = "box", traits = "GY")

## Add coloring by repId to the boxes.
plot(wheatTD, plotType = "box", traits = "GY", colorBy = "repId")

## Sort the boxes in descending order.
plot(wheatTD, plotType = "box", traits = "GY", orderBy = "descending")

### Correlation plot.

## Plot the correlations between trials for GY.
plot(wheatTD, plotType = "cor", traits = "GY")

# }

Run the code above in your browser using DataLab