
LD decay plots
geom_ld_decay.RdPlot LD decay summaries as point, connected line, or fitted line plots. The x-axis is pairwise distance in kilobases and the y-axis defaults to mean LD \(r^2\), with optional D-prime or combined \(r^2\)/D-prime views. All styles support population colouring through the package-wide pop column. pop_group relabels imported file/sample labels; "point" and "line" keep the imported summaries, while "fit" draws population-level fitted curves.
Usage
geom_ld_decay(
mapping = ggplot2::aes(x = .data$dist_kb, y = .data$r2),
data = NULL,
...,
pop = NULL,
pop_group = NULL,
style = c("point", "line", "fit"),
measure = c("r2", "D", "both"),
colour_by = c("pop", "file"),
size = NULL,
alpha = NULL,
base_size = 11,
base_family = "",
palette = "population",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
plot_ld_decay(
data,
pop = NULL,
pop_group = NULL,
style = c("point", "line", "fit"),
measure = c("r2", "D", "both"),
title = NULL,
subtitle = NULL,
caption = NULL,
base_size = 11,
base_family = "",
palette = "population",
...
)Arguments
- mapping
Aesthetic mapping. Defaults to pairwise distance in Kb and mean LD \(r^2\).
- data
A
ggpop_ld_decayobject fromimport_ld_decay().- ...
Additional geom parameters.
- pop
Optional population labels to keep.
- pop_group
Optional population group table or path to the standard two-column
sample popfile. File labels are matched throughsample, then regrouped by the mapped population labels.- style
Draw raw summary
"point"layers, raw connected"line"layers, or population-level fitted"fit"curves.- measure
Plot
r^2, D-prime, or both measures together.- colour_by
Colour by population or source file.
- size, alpha
Layer appearance. Point plots default to size 1, matching common LD decay summaries.
- base_size, base_family
Base theme font controls.
- palette
ggpop discrete palette.
- na.rm, show.legend, inherit.aes
Standard ggplot2 layer arguments.
- title, subtitle, caption
Optional plot labels. No default title is added.
Examples
ld_dir <- system.file("extdata", "ld_decay", "PopLDdecay_grouped", package = "ggPopi")
groups <- system.file("extdata", "pop_group.txt", package = "ggPopi")
ld <- import_ld_decay(ld_dir, type = "poplddecay", pop_group = groups)
#> Error: `dir` must point to an existing directory.
ld |> plot_ld_decay(style = "point")
#> Error: object 'ld' not found
ld |> plot_ld_decay(style = "line")
#> Error: object 'ld' not found
ld |> plot_ld_decay(style = "fit")
#> Error: object 'ld' not found
ld |> ggpop() + geom_ld_decay(style = "point")
#> Error: object 'ld' not found