This function generates powerful effect plots to show the relationship between genotype classes at a a marker (QTL) on a given trait. Works on polyploids The function computes summary statistics for each genotype class and overlays them on the plot. Optionally, it can flip the coordinate axes. Shows the distributions and measures of spread of individuals and not simply a boxplot.
Usage
effect_plot(
effects_df,
marker_name,
trait_name,
genotype_levels = c("A", "H", "B"),
flip = TRUE,
trait_label = NULL
)
Arguments
- effects_df
A data frame containing at least the columns for marker and trait of interest. Could work with 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 levels (genotype categories) for the marker. Default is
c("A", "H", "B")
.- flip
Logical; if
TRUE
, the plot is displayed with flipped coordinates (horizontal layout). Default isTRUE
.- trait_label
Optional character string to use as a y-axis label. If
NULL
, the trait name will be used.
Value
A list with three elements:
[[1]]
A
ggplot2
object showing the distribution of trait values for each genotype at the given marker.[[2]]
A data frame with summary statistics (median, max, min, count, standard deviation) by genotype.
[[3]]
A data frame with population-level summary statistics (mean, median, sd, max) for the trait.
Details
The function performs the following steps:
Checks for presence of specified columns.
Calculates summary statistics by genotype.
Constructs a half-eye plot with boxplot overlays and annotations.
It uses ggplot2
for plotting and ggdist
for the half-eye visualization.
Note
The half-eye visualization is inspired in work by Cedric Scherer