Make a BESD file from QTLtools output

Make a BESD file from QTLtools output

# 根据基因名与变异rsid编号去重   
library(tidyverse)
library(readxl)
qtltoolsnomi <- read_table("qtltoolsnomi.txt",col_names = F)
qtltoolsnomi %>% distinct(X1,X8, .keep_all = TRUE) -> qtltool
qtltool %>% group_by(X2) %>% 
  summarise(n=n()) %>% 
  as.data.frame()
# 去除X,Y染色体
qtltool %>% filter(!(X2 %in% c("chrX","chrY"))) -> qtltool
qtltool %>% filter(!(X8==".")) -> qtltool
write.table(qtltool, "qtltool.txt",quote = FALSE,row.names = FALSE, col.names = F)

生成 BESD file

# 工作目录
$ pwd
/HP_NL/PUBLIC/WORK/guanjiawei/analysis/TWAS_papper/eQTL_result
$/HP_NL/PUBLIC/WORK/guanjiawei/bio_software/soft/smr/smr --eqtl-summary qtltool.txt --qtltools-nominal-format --make-besd --out eqtl_ali_225

Update MAF file to a BESD file

  1. 生成MAF文件

    
    awk '{print $2,$3,$4, $5}' ./snp_info.frq > ./eqtl.freq
    # 删除第一行列名
    $ sed -i '1d' eqtl.freq
    
    # 去除包含NA的行
    grep -v 'NA' eqtl > a.txt
    mv a.txt  eqtl.freq
    
    $ head eqtl.freq 
    rs3107975 C T 0.1477
    rs76735897 G A 0.175
    rs77573425 C G 0.1727
    
  2. update the frequencies of the effect alleles,实质更新到.esi文档

  library(tidyverse)
   library(dplyr)
   eqtl_esi <- read_table("eqt.esi",col_names = F)
   names(eqtl_esi)[2] <- "rsid"
   eqtl_freq <- read_table("eqtl.freq",col_names = F)
   names(eqtl_freq) <- c("rsid","A1","A2","freq")
   eqtl_esi %>% 
     left_join(eqtl_freq, by = "rsid") %>% 
     dplyr::select(X1,rsid,X3,X4,A1,A2,freq) -> eqtl_esi
   write.table(eqtl_esi,"eqtl_1.esi",quote = F,col.names = F,row.names = F)

更新esi

smr --beqtl-summary eqtl --update-esi eqtl_1.esi
  • 8
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

紫霄zixiao

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值