参考:
https://zhuanlan.zhihu.com/p/392589375
https://blog.csdn.net/u013012420/article/details/127697722
https://zhuanlan.zhihu.com/p/477035163?utm_id=0

不明意义的图片,忘记当时为什么截图了
https://zhuanlan.zhihu.com/p/106103885 这个里面的图
正文开始
简单来说,MR是观察性研究,意义类似于meta,共定位是遗传层次的研究,意义是性状在遗传层次有没有关系
直接上代码咯,随缘
#这代码是我从循环里抓出来的核心内容,主要流程就是
#1. 确定lead snp的locus
#2. 获取两个性状在这个locus相同的snp
#3. 去重后组装,然后就是coloc
#4. 提示coloc的函数注释很管用哦
snp_range_gene<-range[j,]
#diff locuses
index<-
str_remove(pqtl$Chrom,'chr')==snp_range_gene$chr &
pqtl$Pos<snp_range_gene$max &
pqtl$Pos>snp_range_gene$min
pqtl_temp<-pqtl[index,c(4,8,7,10,11,12)]
index<-
ss_gwas$`#chrom` == snp_range_gene$chr &
ss_gwas$pos < snp_range_gene$max &
ss_gwas$pos > snp_range_gene$min
ss_gwas_temp<-ss_gwas[index,]
pqtl_temp<-arrange(pqtl_temp,Pval)
keep<-duplicated(pqtl_temp[,1])
pqtl_temp<-pqtl_temp[!keep,]
snps<-intersect(ss_gwas_temp$rsids,pqtl_temp$rsids)
ss_gwas_temp<-subset(ss_gwas_temp,rsids %in% snps)
pqtl_temp<-subset(pqtl_temp,rsids %in% snps)
ss_gwas_temp<-list('snp'=ss_gwas_temp[[1]],
'pvalues'=ss_gwas_temp[[2]],
type='cc',
s=2735/(2735+399355),
N=2735+399355)
MAF<-pqtl_temp[[6]]
pqtl_temp<-list('snp'=pqtl_temp[[1]],
'pvalues'=pqtl_temp[[2]],
'beta'=pqtl_temp[[3]],
'varbeta'=pqtl_temp[[4]]^2,
'N'=pqtl_temp[[1,5]],
'type'='quant')
result <- coloc.abf(dataset1=ss_gwas_temp, dataset2=pqtl_temp, MAF=MAF)
