人妖 telegram 孟德尔随即化R包TwoSampleMR装配教程并修复token
人人好,我是邓飞,今天先容一下TwoSampleMR包若何修复token人妖 telegram,从而不错使用数据库的数据进行孟德尔随即化的分析。
1,装配TwoSampleMR包这个包在github上头,之前流行用devtools包装配github上的R包,然而devtools本人就相配难装配,好在当今有了 remotes包,这个包比拟好装配,进而github上头的包也比拟好装配了。
# install.packages("remotes")library(remotes)install_github("MRCIEU/TwoSampleMR")
将上头的代码贴到Rstudio中扩充,就不错了。淌若深切莫得 remote包,就把附近去掉,再开动就行了。
图片
2, 开动MR示例数据library(TwoSampleMR)# List available GWASsao <- available_outcomes()# Get instrumentsexposure_dat <- extract_instruments("ieu-a-2")# Get effects of instruments on outcomeoutcome_dat <- extract_outcome_data(snps=exposure_dat$SNP, outcomes = "ieu-a-7")# Harmonise the exposure and outcome datadat <- harmonise_data(exposure_dat, outcome_dat)# Perform MR
然后发现报错了:
> library(TwoSampleMR)TwoSampleMR version 0.6.8 载入程辑包:'TwoSampleMR’The following object is masked from 'package:remotes’: add_metadata> # List available GWASs> ao <- available_outcomes()Error in `dplyr::bind_rows()`:! Argument 1 must be a data frame or a named atomic vector.
报错的信息是:Error in dplyr::bind_rows():! Argument 1 must be a data frame or a named atomic vector.Run rlang::last_trace() to see where the error occurred.
看起来是dplyr的错,其实不是,连接开动望望能不行读取ieu的数据:
> bmi_exp_dat <- extract_instruments(outcomes = 'ieu-a-2')
当今的报错信息是:> bmi_exp_dat <- extract_instruments(outcomes = 'ieu-a-2')Error in if (nrow(d) == 0) return(NULL) : 参数长度为零
忧伤,淌若你认为我方是R讲话大神,思从R讲话包装配的角度,包突破的角度去解决问题,终末很大可能是 砸电脑!!!
正确的解决轮换,是检察官网,淌若你把报错信息贴到网上头,好像率亦然找不到谜底,因为之前TwoSampleMR还莫得这个问题,网上的东西是相互抄,垃圾信息满天飞,第一手费力始终是官网。
https://mrcieu.github.io/ieugwasr/articles/guide.html
内部有一句话:
From 1st May 2024, most queries to the OpenGWAS API will require user authentication. For more information on why this is necessary, see this [blog post](https://blog.opengwas.io/posts/user-auth-spring-2024/).
从2024年5月1号,TwoSampleMR包需要修复token之后,才不错阅览数据库,是以,底下即是若何修复token的问题了。
3,TwoSampleMR修复token官方保举决议:
A:更新你的R包
Please update your TwoSampleMR and ieugwasr packages - you can use the following command to do this.
install.packages("TwoSampleMR", repos = c("https://mrcieu.r-universe.dev", "https://cran.r-project.org"))
B:修复token
Then you need to obtain an OPENGWAS_JWT token - see the ieugwasr documentation https://mrcieu.github.io/ieugwasr/articles/guide.html - and store it in your .Renviron file - then restart R.
Login to https://api.opengwas.io/profile/
Generate a new token
Add OPENGWAS_JWT=<token> to your .Renviron file. This file could be either in your home directory or in the working directory of your R session. You can check the location of your .Renviron file by running Sys.getenv("R_ENVIRON_USER") in R.
Restart your R session
To check that your token is being recognised, run [ieugwasr::get_opengwas_jwt()](https://mrcieu.github.io/ieugwasr/reference/get_opengwas_jwt.html). If it returns a long random string then you are authenticated.
To check that your token is working, run [user()](https://mrcieu.github.io/ieugwasr/reference/user.html). It will make a request to the API for your user information using your token. It should return a list with your user information. If it returns an error, then your token is not working.
底下,我将上头的花式,相连我我方的告捷操作经由,先容一下,随着我的花式,你也确定能处治啦!
3.1 登录opengwas,注册一下登录注册,用github账号,https://api.opengwas.io/profile/
3.2 创建token按照底下的截图就能处治。
图片
把token复制一下。
淫荡妈妈3.3 在R讲话中检测是否有token淌若之前莫得修复过,确定是莫得的。
Sys.getenv("R_ENVIRON_USER")
我的复返效果:
> Sys.getenv("R_ENVIRON_USER")[1] ""
不错看到,莫得修复。
那就需要在文档文献夹中,新建一个.Renviron文献
图片
3.4 把token放到新建的.Renviron文献中3.5 重启R讲话(必须)OPENGWAS_JWT="这里粘贴你的token"图片
重启R讲话,然后键入底下代码,测试token是否修复告捷:
## 测试token是否灵验library(ieugwasr)user()
图片
不错看到个东谈主的信息,就修复告捷了。
4. 测试MR示例数据library(TwoSampleMR)# List available GWASsao <- available_outcomes()# Get instrumentsexposure_dat <- extract_instruments("ieu-a-2")# Get effects of instruments on outcomeoutcome_dat <- extract_outcome_data(snps=exposure_dat$SNP, outcomes = "ieu-a-7")# Harmonise the exposure and outcome datadat <- harmonise_data(exposure_dat, outcome_dat)# Perform MRres <- mr(dat)
开动效果:
图片
作图效果:
图片
这就处治了人妖 telegram。
本站仅提供存储就业,总计实质均由用户发布,如发现存害或侵权实质,请点击举报。