Hello Vinod,
I got a little bit similar script for doing the same LD decay, but It had some addition in order to used a calculated regression value to do the line but it is using the same formula. It seems to work better than the first script. Could you try to see if you think it gives a good result?
Elmer
On Wednesday, July 18, 2012 11:20:52 AM UTC-4, Vicky wrote:
Hi,
Can anyone suggest me how to plot decay of LD of SNP data. I've r2 and D' values from TASSEL 3.0 but want to plot them for decay analysis which require some non linear regression model. the model need C= recombination rate (rho) something from Weir and Hills statistics. Using LD hat but not know about interpretation of the data. Really confused, am not perfect in statistics, please assist me in getting out of this. Instead of 101 in the formula you can modify this parameter because it is related to the population size.
Thanks,
The script can be modified to get a zoom for a specific distance ( ex. 5 Mb, less or more, you just need to modify this parameter in the option instead of 60Mb)
LD_R<-read.table('LDchrom1_A.txt',header=T)
colnames(LD_R)<-c('Dist','R')
read.delim("LDchrom1_A.txt")->a
a$Dist->x
a$R*a$R->y
data.frame(x,y) ->dataframe
remington <- function(x)
{
A <- 10+x
B <- (2+ x) * (11+ x)
C <- (3+ x)*(12+12* x+ x*x)
D<- 101*(2+ x)*(11+ x)
y<- (A/B)*(1+(C/D))
return(y)
}
modele <- nls(y~remington(x*r),
data=dataframe,
trace=TRUE ,
start=list(r=0.00000001),
)
rchapeau<-coef(modele)
#par(mfrow=c(2,2))
plot(a$Dist,a$R*a$R, xlim=c(1,60000000), cex=.5, pch=20, col='gray', main= " Gm01 all SNPs", xlab="distance in base pairs", ylab="r2")
curve(remington(x*rchapeau ), 0,60000000, add = TRUE, lwd=2, col = "black")