Learn R Programming

xbreed (version 1.0.1.1)

calc_LD: Calculate linkage disequilibrium

Description

Different measures of linkage disequilibrium (LD) such as \(D\),\(r\) and \(r^2\) are calculated for phased genotypes. LD measurements can be calculated both for adjacent and pairwise loci. Decay of LD between marker pairs can be assessed as well.

Usage

calc_LD(mat, MAF, method, LD_summary, saveAt, linkage_map, interval)

Arguments

mat

(matrix) Matrix with phased genotypes of individuals coded as 11,12,21,22 for genotypes AA, Aa, aA and AA respectively. Dimension is \(n*p\) where n is number of individuals and p is twice the number of loci.

MAF

Optional Minor allele frequency threshold for LD calculation. Loci with minor allele frequency less than MAF will be excluded. Default: 0.05.

method

Optional (character) Method to be used for calculation of LD. Possible options are:

  • "adjacent" LD will be calculated for adjacent loci only.

  • "pairwise" LD will be calculated for all pairwise loci.

Default: "adjacent"

LD_summary

Optional (Logical) Display LD calculation summary if is not FALSE. Default: True.

saveAt

Optional (character). Name to be used to save output files.

linkage_map

Optional (data.frame) or (vector) Linkage map of the loci for the measurement of LD decay. Note: both argument linkage_map and interval should be present in the function and also argument method should be set to "pairwise" for the calculation of LD decay.

interval

Optional Interval to be used for grouping loci by their pairwise distance. See details.

Value

list with data of LD calculations.

$Mean_r2

Mean \(r^2\) for provided genotypes based on the method specified

.
$ld_data

Data frame with 12 columns including pair id, frequencies of alleles and haplotypes for each pair as well as measurements of LD

.
$ld_decay

Data for LD decay including the average \(r^2\) for loci pairs in each interval

.

Details

The extent of LD is an important factor both in association studies and genomic selection. Commonly used measure to calculate LD between loci A and B is Pearson coefficient (\(r\)) of correlation as: $$r = D/ \sqrt{(p_1p_2q_1q_2)}$$ where \(D\) is $$D_{ij}=p(A_iB_j)-p(A_i)p(B_j)$$ However, squared coefficient of correlation \(r^2\) is often used to remove the arbitrary sign introduced: $$r^2_{ij} = D^2_{ij}/ (p(A_i)(1-p(A_i))p(B_j)(1-p(B_j)))$$

To determine the decay of LD with increasing distance between loci (SNPs), the average \(r^2\) can be expressed as a function of distance between SNPs. SNP pairs are grouped by their pairwise distance into intervals defined by the user in argument interval. The average \(r^2\) for SNP pairs in each interval are estimated as the mean of all \(r^2\) within that interval.

Examples

Run this code
# NOT RUN {
# Calculate mean r2 and LD decay.

genome<-data.frame(matrix(NA, nrow=1, ncol=6))
names(genome)<-c("chr","len","nmrk","mpos","nqtl","qpos")
genome$chr<-c(1)
genome$len<-c(100)	
genome$nmrk<-c(100)
genome$mpos<-c("rnd")	
genome$nqtl<-c(50)
genome$qpos<-c("even")	
genome

hp<-make_hp(hpsize=100,
ng=10,h2=0.3,phen_var=1 ,genome=genome,
mutr=2.5e-4)

# Mean r2

mat<-hp$hp_mrk[,-1]
rLD<-calc_LD(mat=mat,MAF=0.1,method='adjacent',LD_summary=TRUE)

# LD decay

 linkage_map<-hp$linkage_map_mrk[,3]
 rLD<-calc_LD(mat=mat,MAF=0.1,method='pairwise'
,LD_summary=TRUE,linkage_map=linkage_map,interval=5)

rLD$ld_decay
# }

Run the code above in your browser using DataLab