calc_LD: Calculate linkage disequilibrium

Description Usage Arguments Details Value Examples

View source: R/Calc_LD_v2_Commented.R

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

1
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.

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/ √{(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.

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

.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 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

Example output

("|-----------------------------------------------------|")
("|                      xbreed                         |")
("|    Genomic simulation of purebreds and crossbreds   |")
("|               March 2017 Version 1.0.1              |")
("|                                                     |")
("|             H.Esfandyari,A.C.Sorensen               |")
("| Center for Quantitative Qenetics and Genomics (QGG) |")
("|             Aarhus University,Denmark               |")
("|                                                     |")
("|-----------------------------------------------------|")
("|Questions and bugs: [email protected]        |")
("|Development of xbreed was supported by GenSAP.       |")
("|-----------------------------------------------------|")
  chr len nmrk mpos nqtl qpos
1   1 100  100  rnd   50 even
---sel_seq_qtl is missing, it has been set to default value of 0
---sel_seq_mrk is missing, it has been set to default value of 0
---laf is missing, loci allele frequency in the first historical generation will be sampled from uniform distribution
Historical pop is initialized...
Simulating trait ...
Output data preparation ...
Establishment of historical population completed

 ****  Linkage disequilibrium output ****  

Method: adjacent
No. marker: 100
No. marker pairs: 99

 "D" summary:
     Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
-0.231500 -0.065025 -0.004350 -0.005211  0.050450  0.221800 

 "r" summary:
    Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
-0.93992 -0.27027 -0.02067 -0.02150  0.20281  0.93600 

 "r2" summary:
     Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
0.0000272 0.0152325 0.0637690 0.1293656 0.1665302 0.8834531 

 ****  Linkage disequilibrium output ****  

Method: pairwise
No. marker: 100
No. marker pairs: 4950

 "D" summary:
      Min.    1st Qu.     Median       Mean    3rd Qu.       Max. 
-0.2315000 -0.0184000 -0.0002000 -0.0002952  0.0186375  0.2218000 

 "r" summary:
      Min.    1st Qu.     Median       Mean    3rd Qu.       Max. 
-0.9399219 -0.0758355 -0.0008733 -0.0012180  0.0775101  0.9360000 

 "r2" summary:
    Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
0.000000 0.001311 0.005878 0.026631 0.020345 0.883453 
             [,1] [,2]
 [1,] 0.101891929  2.5
 [2,] 0.053734700  7.5
 [3,] 0.038286658 12.5
 [4,] 0.022509538 17.5
 [5,] 0.015350270 22.5
 [6,] 0.009603001 27.5
 [7,] 0.007976439 32.5
 [8,] 0.007164346 37.5
 [9,] 0.006772920 42.5
[10,] 0.005617391 47.5
[11,] 0.006254410 52.5
[12,] 0.006347469 57.5
[13,] 0.007075840 62.5
[14,] 0.005040097 67.5
[15,] 0.005988281 72.5
[16,] 0.006171468 77.5
[17,] 0.007397394 82.5
[18,] 0.006375128 87.5
[19,] 0.010175550 92.5

xbreed documentation built on May 30, 2017, 4:07 a.m.