Generates a clean and simple effect plot. Shows the relationship between genotype classes at a marker on a trait. Optionally includes annotation of medians and sample sizes, and allows flipping of axes. Works on polyploids.
Usage
simple_effect_plot(
effects_df,
marker_name,
trait_name,
genotype_levels = c("A", "H", "B"),
annotate = TRUE,
flip = FALSE,
trait_label = NULL
)
Arguments
- effects_df
A data frame containing at least the columns for marker genotypes and trait values. Usually the output of
format_qtl_input
with a few modifications (first two rows removed).- marker_name
A character string specifying the name of the marker column in
effects_df
.- trait_name
A character string specifying the name of the trait column in
effects_df
.- genotype_levels
A character vector indicating the expected genotype categories (factor levels). Default is
c("A", "H", "B")
.- annotate
Logical; if
TRUE
, the plot includes annotations of median values and sample sizes per genotype. Default isTRUE
.- flip
Logical; if
TRUE
, the coordinates of the plot are flipped (horizontal layout). Default isFALSE
.- trait_label
Optional character string to use as the y-axis label. If
NULL
, the trait name is used.
Value
A ggplot2
object displaying the distribution of trait values across genotype classes (alleles) at the specified marker.
Details
The function performs the following:
Verifies the presence of marker and trait columns in the input data frame.
Removes rows with missing genotype data.
Converts the marker column to a factor with specified genotype levels.
Creates a boxplot with optional annotations of median values and counts.
Optionally flips the plot horizontally.
Note
Inspired by Fig. 2 Caraza-Harter & Endelman