Entering edit mode
8.8 years ago
star
▴
350
I like to find linkage Disequilibrium (LD) between my positions (rows). I have used SNPRelate
package for finding LD as below but I want compare each row with others as I show in out put.
snp1<-as.numeric(c("0","1","1","2"))
snp2<-as.numeric(c("NA","1","2","1"))
Warning message:
NAs introduced by coercion
LD<-snpgdsLDpair(snp1,snp2,"dprime")
LD
ld pA_A pA_B pB_A pB_B
9.999998e-01 3.333334e-01 3.333333e-01 3.333333e-01 2.554527e-08
Input:
pos sample1 sample2 sample3 sample4
SNP1 0 1 1 2
SNP2 NA 1 2 1
SNP3 2 2 0 1
SNP4 0 1 1 2
Each samples code as(NA = no read data , 0 = Homozygous Reference genotype , 1 = Heterozygous genotype and 2 = Homozygous Alternative genotype )
Output:
ld
SNP1 SNP2 0.25
SNP1 SNP3 0.36
SNP1 SNP4 0.54
SNP2 SNP3 0.33
SNP2 SNP4 0.36
SNP3 SNP4 0.69
Value of ld in above in output is not accurate.
I usually use the genetics package. The input is similar to yours, but you have to specify a genotype explicitly (i.e.
A/A
,A/T
,T/T
) instead of0
,1
,2
. However, the manual is rather exhaustive. In genetics, usingLD(mydata)
will perform all the pairwise comparisons.Dear Fabio,
Thanks for your help.