Created
August 4, 2020 06:20
-
-
Save rossibarra/f4c336895896ecfbff1984e5e560d8f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
x<-read.table("~/Desktop/ogut.map") | |
# OK we're missing bits on ends | |
group_by(x,V1) %>% | |
summarize(end=max(V3),start=min(V3)) | |
#spline to get them | |
pos.starts<-rep(0,10) | |
pos.ends<-c(307041717,244442276,235667834,246994605,223902240,174033170,182381542,181122637,159769782,150982314) | |
for(chr in 1:10){ | |
bob<-subset(x,x$V1==chr) | |
sue=spline(x=bob$V4,y=bob$V3,xout=c(pos.starts[chr],pos.ends[chr]))$y | |
start<-data.frame(chr,pos.starts[chr],sue[1]) | |
colnames(start)=c("V1","V4","V3") | |
end<-data.frame(chr,pos.ends[chr],sue[2]) | |
colnames(end)=c("V1","V4","V3") | |
bob<-select(bob,V1,V4,V3) | |
y=rbind(start,bob,end) | |
y$V3=y$V3+abs(min(y$V3)) | |
colnames(y)=c("chr","pos","map") | |
y<-mutate(y,cmdist=c(diff(y$map),"NA"), | |
posdist=c(diff(y$pos),"NA")) %>% | |
filter(cmdist!="NA") %>% | |
mutate(cmdist=as.numeric(cmdist),posdist=as.numeric(posdist),rate=cmdist/posdist*1E6)%>% | |
select(pos,rate,map) | |
write.table(y,file=paste("~/Desktop/ogut.chr",chr,".txt",sep=""),quote=F,row.names=F,col.names=F) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment