Skip to contents

Plot a Manhattan plot from a gwas object

Usage

manhattan(
  gwas,
  output,
  lower_logp_threshold = 3,
  y_axis_break = NULL,
  y_axis_break_scale = 0.2,
  label_top_n = NULL,
  label_strategy = "lead_per_locus",
  label_locus_window_kb = 500,
  label_pvalue_threshold = NULL,
  label_nudge_y = NULL,
  force_highlight_labels = TRUE,
  label_repel_direction = "y",
  italic_gene_labels = TRUE,
  highlight_genes = NULL,
  highlight_color = "red3",
  label_color = "black",
  label_size = 3,
  highlight_label_size = NULL,
  label_segment_alpha = 0.65,
  label_max_y_nudge = NULL,
  ...
)

Arguments

gwas

A gwas object containing the data to plot.

output

The output file name.

lower_logp_threshold

The lower threshold for the -log10(p-value) to plot. Default is 3.0.

y_axis_break

Optional `-log10(p)` value where the upper y-axis should be compressed. Values below the break are unchanged; values above are compressed by `y_axis_break_scale`, with a slash marker drawn at the break. Default NULL (no compression).

y_axis_break_scale

Compression factor for values above `y_axis_break`. Smaller values create more visual room below the break. Must be in (0, 1]. Default 0.2.

label_top_n

Integer. If set and a `gene_name` column is present, annotate the top N variants (by p-value) with labels using ggrepel. If `gene_name` is missing, labels fall back to cytoband-like text (e.g., `chr4p16.3`). Default is NULL (no labels).

label_strategy

Label selection mode: `"top_n"` (global top N by p-value) or `"lead_per_locus"` (one lead per locus, then top N). Default `"lead_per_locus"`.

label_locus_window_kb

Locus window size in kilobases used when `label_strategy = "lead_per_locus"`. Default 500.

label_pvalue_threshold

P-value cutoff for labeling: only variants with `PVALUE < label_pvalue_threshold` are eligible for labels. Genes in `highlight_genes` are labeled regardless when `force_highlight_labels = TRUE`. Default NULL, which uses the genome-wide significance line (5e-8).

label_nudge_y

Vertical distance (in `-log10(p)` units) to lift gene labels above their points. Default NULL uses adaptive per-label nudges. Set to a number to force the same upward nudge for every label, or 0 to disable the upward nudge.

force_highlight_labels

Logical. If TRUE, genes in `highlight_genes` are labeled even when they do not pass `label_pvalue_threshold` or `label_top_n`. Default TRUE.

label_repel_direction

Direction passed to `ggrepel`: `"y"` keeps labels aligned above variants, `"both"` lets labels move horizontally and vertically, and `"x"` repels horizontally. Default `"y"`.

italic_gene_labels

Logical. If TRUE, gene labels are italicized; cytoband fallback labels remain plain text. Default TRUE.

highlight_genes

Optional character vector of gene symbols to highlight (e.g., novel genes). Matching labels are colored with `highlight_color`.

highlight_color

Color for highlighted labels. Default `"red3"`.

label_color

Color for non-highlighted labels. Default `"black"`.

label_size

Text size for non-highlighted labels. Default 3.

highlight_label_size

Text size for highlighted labels. Default NULL, which uses `label_size`.

label_segment_alpha

Alpha transparency for label leader lines. Default 0.65.

label_max_y_nudge

Maximum adaptive starting nudge for labels in `-log10(p)` units. `NULL` chooses a conservative value from the plotted y-range. Lower values keep labels closer to variants. Default NULL.

...

Additional arguments passed to `ggsave`.