How the calculated the decay line by nonlinear regression to the LD plot?
2
0
Entering edit mode
3.6 years ago
Kumar ▴ 170

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)
gi_LD <- read.table("gi_LD.ld", sep="\t", header = T, na.strings = "NaN")
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: enter image description here

Linkage SNP Disequilibrium Population • 2.6k views
ADD COMMENT
0
Entering edit mode
3.6 years ago
hewm2008 ▴ 50

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

ADD COMMENT
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

ADD REPLY
0
Entering edit mode
3.6 years ago
Fabio Marroni ★ 3.0k

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

ADD COMMENT
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:::::: enter image description here

ADD REPLY

Login before adding your answer.

Traffic: 777 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6