Skip to contents

Generates a line plot showing QTL traces (LOD scores) across chromosomes for one or more traits. Supports customization of visual appearance and annotations such as significance thresholds and vertical lines.

Usage

plot_qtl_trace(
  qtl_df,
  thresholds_df,
  vline_df = NULL,
  use_physical_pos = FALSE,
  x_angle = 0,
  trait_colors = NULL,
  trait_labels = NULL,
  x_label = "Position (cM)",
  y_label = "LOD",
  plot_title = NULL,
  show_legend = TRUE,
  facet_nrow = 1
)

Arguments

qtl_df

A data frame containing QTL mapping results. Must include columns: pos (genetic position in cM), lod (LOD score), response_var (trait name), and chr (chromosome). Optional phys.pos (physical position in Mb).

thresholds_df

A data frame with LOD score thresholds per trait. Must include columns: chr, hline, and response_var.

vline_df

Optional. A data frame specifying positions for vertical lines. Must include chr and vline columns. Can also include a label column for text annotation at each vertical line.

use_physical_pos

Logical. If TRUE, use physical position (phys.pos) for the x-axis. If FALSE (default), use genetic position (pos).

x_angle

Integer. Angle of the x-axis text labels (default is 0).

trait_colors

Optional. A named vector of colors for each trait. If NULL (default), colors are automatically assigned.

trait_labels

Optional. A named vector of human-readable trait labels (can include expressions) to use in the legend.

x_label

Character. Label for the x-axis (default is "Position (cM)").

y_label

Character. Label for the y-axis (default is "LOD").

plot_title

Optional. Title for the plot (default is NULL).

show_legend

Logical. Whether to display the legend (defaults to TRUE).

facet_nrow

Integer. Number of rows in the facet layout (defaults to 1).

Value

A ggplot object displaying QTL traces per trait and chromosome, with optional custom styling.