Skip to contents

Produces one of two ggplot2 visualisations from a fixedRegress() result object, analogous to plot_randomRegress() for fixed-effects (BLUE) output. Both plot types return a ggplot object that can be further customised with the standard + operator.

Usage

plot_fixedRegress(
  res,
  type = c("regress", "quadrant"),
  treatments = NULL,
  highlight = "default",
  centre = TRUE,
  theme = ggplot2::theme_bw(),
  return_data = FALSE,
  ...
)

Arguments

res

A list returned by fixedRegress().

type

Character string selecting the plot type. One of "regress" (default) or "quadrant".

treatments

Character vector restricting which conditioned treatments are included. NULL (default) includes all conditioned treatments.

highlight

Controls genotype annotation. One of:

"default"

Automatically selects 6 genotypes using the polar-angle algorithm (3 top-right, 3 bottom-left).

character vector

Highlight exactly the named genotypes.

NULL

No highlighting.

Default is "default".

centre

Logical. If TRUE (default), within-group means are subtracted from the x-axis (unconditional treatment BLUE) and, for type = "regress", also from the y-axis. This removes the treatment fixed-effect mean so that the zero reference lines fall within the data and the quadrant concept is meaningful. Set to FALSE to display raw BLUEs including the treatment mean.

theme

A complete ggplot2 theme object. Default ggplot2::theme_bw().

return_data

Logical. If TRUE returns the tidy data frame rather than the plot. Default FALSE.

...

Additional arguments passed to the background geom_point() call (e.g. size, alpha).

Value

A ggplot object (when return_data = FALSE) or a data.frame (when return_data = TRUE).

Details

The two type options are:

"regress"

Grid of scatter plots faceted by BLUP pair (rows) and group (columns). Each panel plots the raw conditioned-treatment BLUEs (y) against the conditioning-treatment BLUEs (x) for one group × one treatment pair. A dotted OLS regression line is drawn and the slope \(\hat{\beta}\) is annotated in the top-left corner of each panel. Unlike the random-effects analogue the line need not pass through the origin because OLS includes an intercept.

"quadrant"

Grid of scatter plots faceted by BLUP pair (rows) and group (columns). Each panel plots the response index (OLS residual, y) against the unconditional treatment BLUE (efficiency, x). Dotted zero reference lines divide each panel into four quadrants.

Variety highlighting — see plot_randomRegress() for the full description of the polar-angle algorithm used to select the default six genotypes. The same three archetypes (efficiency, balanced, responsiveness) are chosen from the top-right and bottom-left quadrants of the efficiency × response-index space, averaged across all groups.

The output data frames returned when return_data = TRUE use standardised column names "Group" (the grouping variable) and "Genotype" (the regression unit) regardless of the original column names in res$blues.

Examples

if (FALSE) { # \dontrun{
res <- fixedRegress(model, term = "Treatment:Site:Genotype",
                    by = "Site", levs = c("T0", "T1", "T2"))

# Regression plot with default 6 highlighted genotypes
plot_fixedRegress(res)

# Quadrant plot
plot_fixedRegress(res, type = "quadrant")

# User-specified highlights
plot_fixedRegress(res, type = "quadrant",
                  highlight = c("Gen01", "Gen15"))

# Suppress highlighting
plot_fixedRegress(res, type = "regress", highlight = NULL)

# Retrieve tidy data frame
df <- plot_fixedRegress(res, type = "quadrant", return_data = TRUE)
} # }