Creates a Manhattan plot showing \(-\log_{10}(p)\) for each variant, arranged by genomic position across chromosomes.
plot_manhattan(
x,
pvalue_col = "pvalue",
chr_col = "chr",
pos_col = "pos",
suggestive_line = 1e-05,
genome_wide_line = 5e-08,
highlight = NULL,
chr_colors = c("grey30", "grey60"),
highlight_color = "red",
title = "Manhattan Plot",
cex = 0.5,
...
)A glow_marginal_scan data.frame, or any data.frame with columns for chromosome, position, and p-value.
Character name of the p-value column. Default: "pvalue".
Character name of the chromosome column. Default: "chr".
Character name of the position column. Default: "pos".
Numeric p-value threshold for suggestive significance line (blue dashed). Default: 1e-5. Set to NULL to suppress.
Numeric p-value threshold for genome-wide significance line (red solid). Default: 5e-8. Set to NULL to suppress.
Integer or character vector of variant_id values to highlight in a distinct color. Requires a "variant_id" column in x. Default: NULL.
Character vector of length 2 for alternating chromosome colors. Default: c("grey30", "grey60").
Color for highlighted variants. Default: "red".
Character plot title. Default: "Manhattan Plot".
Numeric point size. Default: 0.5.
Additional arguments passed to plot().
invisible(NULL).
Chromosome labels are standardized to numeric by stripping the "chr" prefix (e.g., "chr22" becomes 22). Non-numeric chromosomes (X, Y, MT) are assigned the next integer after the maximum numeric chromosome found. Within each chromosome, variants are positioned by their base-pair coordinate. A 2% inter-chromosome gap is added relative to the total genomic span.
Variants with NA or zero p-values are silently excluded. The y-axis is \(-\log_{10}(p)\). The x-axis tick marks are placed at chromosome midpoints.
Complexity: O(m log m) where m is the number of variants (dominated by the sort to compute cumulative positions).
if (FALSE) { # \dontrun{
# Simulate results
sim <- data.frame(
chr = rep(1:22, each = 100),
pos = rep(seq(1e6, 1e8, length.out = 100), 22),
pvalue = runif(2200)
)
class(sim) <- c("glow_marginal_scan", "data.frame")
plot_manhattan(sim)
# With highlights
sim$variant_id <- seq_len(nrow(sim))
plot_manhattan(sim, highlight = c(1, 500, 1000))
} # }