久久精品精选,精品九九视频,www久久只有这里有精品,亚洲熟女乱色综合一区
    分享

    孟德爾隨機化R包TwoSampleMR安裝教程并設置token

     育種數據分析 2024-10-13 發布于河南

    大家好,我是鄧飛,今天介紹一下TwoSampleMR包如何設置token,從而可以使用數據庫的數據進行孟德爾隨機化的分析。

    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./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./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.v", "https://cran."))

    B:設置token

    Then you need to obtain an OPENGWAS_JWT token - see the ieugwasr documentation https://mrcieu./ieugwasr/articles/guide.html - and store it in your .Renviron file - then restart R.

    • Login to https://api./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./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./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./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文件中

    OPENGWAS_JWT="這里粘貼你的token"

    3.5 重啟R語言(必須)

    重啟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)

    運行結果:

    作圖結果:

    這就搞定了。

      轉藏 分享 獻花(0

      0條評論

      發表

      請遵守用戶 評論公約

      類似文章 更多

      主站蜘蛛池模板: 日夜啪啪一区二区三区| 无码专区 人妻系列 在线| 国产成人一区二区不卡| 国产AV福利第一精品| 欧美亚洲另类 丝袜综合网| 日韩av片无码一区二区不卡| 九九在线精品国产| 国产精品自在欧美一区| 国产午精品午夜福利757视频播放| 色妞色综合久久夜夜| 2019亚洲午夜无码天堂 | 99中文字幕精品国产| 特级欧美AAAAAAA免费观看| 人妻少妇不满足中文字幕| 久久先锋男人AV资源网站| 熟妇人妻无码中文字幕| 日韩在线视频线观看一区| 国产偷国产偷亚洲高清人| 日韩中文字幕V亚洲中文字幕| 公喝错春药让我高潮| 一本之道高清乱码少妇 | 国产精品中文字幕免费| 亚洲一区二区三区影院| 国产中文字幕精品免费| 日韩AV无码免费播放| 国产成人精彩在线视频| 日日噜噜夜夜爽爽 | 免费VA国产高清大片在线| 免费看国产美女裸体视频| 国产黑色丝袜在线观看下| 精品超清无码视频在线观看| 亚洲乳大丰满中文字幕| 国产美女被遭强高潮免费一视频| 国产精品无码不卡一区二区三区| 久久亚洲精品情侣| 四川丰满少妇无套内谢| 五月天婷婷激情无码专区| 无码人妻一区二区三区四区AV| 国产成人高清亚洲综合| 国产仑乱无码内谢| 久久丫精品国产亚洲AV不卡|