繪制LD衰減圖

之前使用popLDdeacy這個(gè)軟件自動(dòng)生成的圖片不是特別好看,重新繪制了一下,記錄一下。

popLDdeacy 生成的圖片

在使用LDdecay計(jì)算LD 衰減的時(shí)候,會(huì)返回OUT.bin.gz,前兩列為繪圖所需的數(shù)據(jù)。

OUT.bin.gz 部分?jǐn)?shù)據(jù)
  1. 使用系統(tǒng)函數(shù)繪制
# 我選用的LD衰減距離是r2 一半的時(shí)候的距離
rm(list = ls())  # 清除工作環(huán)境中的變量
setwd("M:\\LD衰減圖") 
LD <- read.table(gzfile("./OUT.bin.gz"),header = T,sep = "\t") # 讀入數(shù)據(jù)
plot(LD$Dist/1000,LD$Mean_r.2,type = "l",col="blue",main="LD decay",xlab = "Distance(Kb)",ylab = expression(r^{2}),cex=3,panel.first = grid(),panel.last = grid())
# Dist_avage <- round((max(LD$Dist)-min(LD$Dist))/2)
segments(0,0.3368,67,0.3368,lty=4,col="red") # 加上虛線
segments(67,0,67,0.3368,lty=4,col="red") 
# abline(h=0.3368,v=67,lty=3,col="lightgray") 
text(67,0.3368,"(67,0.3368881)",pos = 4,font = 4,cex = 0.8) # 加上坐標(biāo)點(diǎn) 
LD衰減圖
  1. 使用 ggplot2 繪制
rm (list = ls() )
library(ggplot2) # 調(diào)用 ggplot2
setwd("M:\\LD衰減圖")
LD <- read.table(gzfile("./OUT.bin.gz"),header = T,sep = "\t")
p <- ggplot(data=LD,mapping = aes(x=Dist/1000,y=Mean_r.2))+
  geom_line(color="blue")+
  geom_segment(aes(x = 67,y=0.3368881,xend=0,yend=0.3366881),data = NULL,colour="red",lty=2,lwd=0.8,lineend = "butt")+
  geom_segment(aes(x = 67,y=0,xend=67,yend=0.33668881),data = NULL,colour="red",lty=2,lwd=0.8)+
  geom_text(aes(x=67,y=0.3368881),label=c("(67,0.3368881)"),hjust=0,nudge_x = 0.002,size=3)+
  labs(y=expression(r^{2}),title = "LD decay")+
  xlab("Distance")+
  scale_x_continuous(c(0:300),breaks = c(seq(0,300,50)))+
  theme_bw()
p <- p+theme(plot.title = element_text(hjust = 0.5)) # 使主標(biāo)題居中
p
LD衰減圖
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容