一个做孟德尔随机化的过程遇到的报错:
bmi_exp_dat <- clump_data(bmi_exp_dat,clump_r2=0.01,pop = "EUR")
Please look at vignettes for options on running this locally if you need to run many instances of this command. Clumping C5nTuK, 5340156 variants, using EUR population reference Error in api_query("ld/clump", query = list(rsid = dat[["rsid"]], pval = dat[["pval"]], ?:? ? The query to MR-Base exceeded 300 seconds and timed out. Please simplify the query
以下是作者给出的解决办法:
- Extracting without clumping
- Performing clumping on each chromosome separately
Alternatively, you could try downloading the VCF from?IEU OpenGWAS project?and using the?gwasvcf?to extract based on p-value, and use the?ieugwasr?package to do clumping locally. We're trying to get to a point where it's easy to do heavier computation on these data locally.
LD reference files listed in the gwasvcf page
看到作者建议可以用ieugwasr这个包做本地clump。
下面尝试做本地clump
首先安装ieugwasr包
devtools::install_github("mrcieu/ieugwasr")
?然后我们可以看到
ld_clump_local() | Wrapper for clump function using local plink binary and ld reference dataset |
?ld_clump_local()这个函数是用来做本地clump的,用法和参数如下:
ld_clump_local(dat, clump_kb, clump_r2, clump_p, bfile, plink_bin)
Arguments
dat | Dataframe. Must have a variant name column ("variant") and pval column called "pval". If id is present then clumping will be done per unique id. |
---|
clump_kb | Clumping kb window. Default is very strict, 10000 |
---|
clump_r2 | Clumping r2 threshold. Default is very strict, 0.001 |
---|
clump_p | Clumping sig level for index variants. Default = 1 (i.e. no threshold) |
---|
bfile | If this is provided then will use the API. Default = NULL |
---|
plink_bin | Specify path to plink binary. Default = NULL. See https://github.com/explodecomputer/plinkbinr for convenient access to plink binaries |
---|
?需要plink包,安装一下plink包,获得可执行二进制plink地址
devtools::install_github("explodecomputer/plinkbinr")
library(plinkbinr)
get_plink_exe()
#[1] "D:/R-4.1.1/library/plinkbinr/bin/plink_Windows.exe"
然后我们下载bfile,我的GWAS是欧洲人种所以用EUR*
wget http://fileserve.mrcieu.ac.uk/ld/1kg.v3.tgz
?#ld_clump_local()报错
改用
"perform clumping, just do the following:
ld_clump( dplyr::tibble(rsid=dat$rsid, pval=dat$pval, id=dat$trait_id), plink_bin = genetics.binaRies::get_plink_binary(), bfile = "/path/to/reference/EUR" ) "
b <- ld_clump(
dplyr::tibble(rsid=a$rsid, pval=a$p, id=a$id),
#get_plink_exe()
plink_bin = "D:/R-4.1.1/library/plinkbinr/bin/plink_Windows.exe",
#欧洲人群参考基因组位置
bfile = "D:/EUR_ref/EUR"
)
注意a的列名,必须要有:
“ with the following columns:
“?
然后我们就完成了,可以看到跟在线方法去除的LD SNP个数是一样的
PLINK v1.90b6.10 64-bit (17 Jun 2019) www.cog-genomics.org/plink/1.9/
(C) 2005-2019 Shaun Purcell, Christopher Chang GNU General Public License v3
Logging to C:\Users\Lenovo\AppData\Local\Temp\RtmpS8aq1j\file2e646a65362c.log.
Options in effect:
--bfile D:/EUR_ref/EUR
--clump C:\Users\Lenovo\AppData\Local\Temp\RtmpS8aq1j\file2e646a65362c
--clump-kb 10000
--clump-p1 0.99
--clump-r2 0.001
--out C:\Users\Lenovo\AppData\Local\Temp\RtmpS8aq1j\file2e646a65362c
32549 MB RAM detected; reserving 16274 MB for main workspace.
8550156 variants loaded from .bim file.
503 people (0 males, 0 females, 503 ambiguous) loaded from .fam.
Ambiguous sex IDs written to
C:\Users\Lenovo\AppData\Local\Temp\RtmpS8aq1j\file2e646a65362c.nosex .
Using 1 thread (no multithreaded calculations invoked).
Before main variant filters, 503 founders and 0 nonfounders present.
Calculating allele frequencies... done.
8550156 variants and 503 people pass filters and QC.
Note: No phenotypes present.
--clump: 78 clumps formed from 2011 top variants.
Results written to
C:\Users\Lenovo\AppData\Local\Temp\RtmpS8aq1j\file2e646a65362c.clumped .
Warning: 'rs9930333' is missing from the main dataset, and is a top variant.
Warning: 'rs8083289' is missing from the main dataset, and is a top variant.
Warning: 'rs2683992' is missing from the main dataset, and is a top variant.
27 more top variant IDs missing; see log file.
Removing 1963 of 2041 variants due to LD with other variants or absence from LD reference panel
|