Skip to contents

Plot LD vs distance using an asymptotic regression model.

Usage

LD_decay_plot(
  data,
  map,
  max.pair = 10000,
  max.loci = NULL,
  position = "bp",
  r2_threshold = 0.2,
  xlim_range = c(0, 20),
  show_vline = TRUE,
  show_hline = TRUE,
  seed = 123
)

Arguments

data

Genotype matrix (markers as columns, individuals as rows). Rownames have the marker names that matcho those of the marker column in the map.

map

Data frame with columns 'chrom', 'marker', and 'position'

max.pair

Maximum number of r² pairs for the model (default: 1e4)

max.loci

Maximum number of markers to use per chromosome (default: NULL)

position

"bp" or "Mb" (default: "bp")

r2_threshold

r² value for decay distance calculation (default: 0.2),

xlim_range

Zoom in range on the x axis, default is c(0, 20). Set to NULL to see entire plot.

show_vline

show a vertical line intersecting the x-axis at the the half-decay distance (default, TRUE)

show_hline

show a horizontal line intersecting the y-axis at the selected r² threshold (default, TRUE)

seed

Optional integer seed to make the random sampling reproducible. Default 123.

Value

A list containing:

plot

ggplot2 object with points and fitted curve (or NULL if fit fails)

half_decay_dist

Distance where r² reaches the specified threshold (or NA if not estimable)

model

Fitted nls object (or NULL if fitting failed)

Details

An asymptotic regression model is fit using SSasymp. The distance where r² reaches a specified threshold (e.g., 0.1 or 0.2) is calculated and returned. This function calculates r² by chromosome and follows the general logic of MapRtools::LD.plot but uses the function SSasymp to model the non-linear LD decay. This function will give you a quick and simple estimate of LD. For more sophisticated LD functions see David Gerard ldfast()

It processes each chromosome separately to compute all pairwise r² values within chromosomes, then it combines the results across all chromosomes into a single dataset, and fits one global LD decay model to the pooled data. No cross-chromosome marker pairs are considered.

If the user is interested in LD per chromosome, provide a map and data file with only data pertaining to the chromosome of interest.

Note

If the number of rows (number of marker pairs) is larger than max.pair (default is 1e4), we proceed to random sampling.