How the calculated the decay line by nonlinear regression to the LD plot?
2
0
Entering edit mode
7 months ago
Kumar ▴ 120

Hi, I am trying to add the non-linear regression tendency line to the Linkage Disequilibrium (LD) plot using R. Please suggest how I can add the non-linear regression tendency line to the LD plot. Here is my code for generating LD plot without the line.

library(ggplot2)
ggplot() +
geom_point(aes(gi_LD$Distance_bp, gi_LD$R2), na.rm = T, color ="blue", alpha=0.05) +
labs(x="Chromosome - Physical distance", y=(LD~(r^{2})))


example output: Linkage SNP Disequilibrium Population • 745 views
0
Entering edit mode
6 months ago
hewm2008 ▴ 40

you can try the [ popldecay ] to plot ld decay :https://github.com/BGI-shenzhen/PopLDdecay
for ldheatmap (+GWAS) : you can ues the ldblockshow : https://github.com/BGI-shenzhen/LDBlockShow

0
Entering edit mode

Hi, Thank you for your reply. I am using plink at the following command to calculate R2. Please let me know if I can make LD plot with non-linear regression tendency line at the output of plink results.

plink --bfile input[prefix] --r2 --indep-pairwise 200 50 0.2 --out output

0
Entering edit mode
6 months ago
Fabio Marroni ★ 2.8k

If you can use base R, you can try to follow a tutorial I wrote several years ago. Adapting your input should be easy:

gi_LD$Distance_bp is what should go into the distance vector gi_LD$R2 is what should go into the LD.data vector

You wll also need to specify the number n which, for diploids is twice the number of genotyped individuals.

You can find more details here

0
Entering edit mode

Hi, Thank you for your help. I created the vectors and ran the following script. However, I am looking to put the decay line by nonlinear regression. I am looking to make plot like above where r2 only goes until 0.5 and physical distance until 500 kb. Please help me to improve the plot. Also please let me know if I can me plot in ggplot for better representation.

plot:::::: 