Mendelian-Randomization.html 86 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836
  1. <!DOCTYPE html>
  2. <html lang="en" data-default-color-scheme=auto>
  3. <head><!-- hexo injector head_begin start -->
  4. <script defer src="https://api.limour.top/vue/0d2f95c1-755d-436b-adf8-eee12a80ed32/script.js"></script>
  5. <!-- hexo injector head_begin end -->
  6. <meta charset="UTF-8">
  7. <link rel="apple-touch-icon" sizes="76x76" href="https://img.limour.top/2023/08/29/64ee07361815a.webp">
  8. <link rel="icon" href="https://img.limour.top/2023/08/29/64ee07361815a.webp">
  9. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  10. <meta http-equiv="x-ua-compatible" content="ie=edge">
  11. <meta name="theme-color" content="#2f4154">
  12. <meta name="author" content="Limour">
  13. <meta name="keywords" content="">
  14. <meta name="description" content="MR定义 孟德尔随机化是一种基于全基因组测序数据(GWAS数据),利用单核首酸多态性(SNPs)作为工具变量(IV),用于揭示因果关系的新型流行病学方法,相较于队列研究等观察性研究,暴露在出生前便已确定,较少受到反向因果及混杂因素的影响,因而能够有效减少偏倚。 MR的核心是运用遗传学数据作为桥梁,来探索某一暴露和某一结局之间的因果关联。与RCT将参与者随机分配到试验组或对照组类似,MR研究基于影">
  15. <title>【学习】孟德尔随机化 - Limour&#39;s Blog</title>
  16. <link rel="stylesheet" href="https://jscdn.limour.top/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css" />
  17. <link rel="stylesheet" href="https://jscdn.limour.top/npm/github-markdown-css@4.0.0/github-markdown.min.css" />
  18. <link rel="stylesheet" href="https://jscdn.limour.top/npm/hint.css@2.7.0/hint.min.css" />
  19. <!-- 主题依赖的图标库,不要自行修改 -->
  20. <!-- Do not modify the link that theme dependent icons -->
  21. <link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">
  22. <link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">
  23. <link rel="stylesheet" href="/css/main.css" />
  24. <link id="highlight-css" rel="stylesheet" href="/css/highlight.css" />
  25. <link id="highlight-css-dark" rel="stylesheet" href="/css/highlight-dark.css" />
  26. <link rel="stylesheet" href="/theme-inject/custom.css">
  27. <link rel="stylesheet" href="/theme-inject/iconfont.css">
  28. <script id="fluid-configs">
  29. var Fluid = window.Fluid || {};
  30. Fluid.ctx = Object.assign({}, Fluid.ctx)
  31. var CONFIG = {"hostname":"hexo.limour.top","root":"/","version":"1.9.7","typing":{"enable":false,"typeSpeed":70,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":"§"},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":false,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"right","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"https://jscdn.limour.top/gh/Limour-dev/Sakurairo_Vision/load_svg/inload.svg","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":{"measurement_id":null},"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml","include_content_in_search":true};
  32. if (CONFIG.web_analytics.follow_dnt) {
  33. var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
  34. Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
  35. }
  36. </script>
  37. <script src="/js/utils.js" ></script>
  38. <script src="/js/color-schema.js" ></script>
  39. <link rel="canonical" href="https://hexo.limour.top/Mendelian-Randomization"/>
  40. <meta name="generator" content="Hexo 7.1.1"><link rel="alternate" href="/atom.xml" title="Limour's Blog" type="application/atom+xml">
  41. <link rel="alternate" href="/rss2.xml" title="Limour's Blog" type="application/rss+xml">
  42. </head>
  43. <body>
  44. <header>
  45. <div class="header-inner" style="height: 70vh;">
  46. <nav id="navbar" class="navbar fixed-top navbar-expand-lg navbar-dark scrolling-navbar">
  47. <div class="container">
  48. <a class="navbar-brand" href="/">
  49. <strong>Limour&#39;s Blog</strong>
  50. </a>
  51. <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
  52. data-target="#navbarSupportedContent"
  53. aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
  54. <div class="animated-icon"><span></span><span></span><span></span></div>
  55. </button>
  56. <!-- Collapsible content -->
  57. <div class="collapse navbar-collapse" id="navbarSupportedContent">
  58. <ul class="navbar-nav ml-auto text-center">
  59. <li class="nav-item">
  60. <a class="nav-link" href="https://hexo.limour.top/" target="_self">
  61. <i class="iconfont icon-home-fill"></i>
  62. <span>Home</span>
  63. </a>
  64. </li>
  65. <li class="nav-item">
  66. <a class="nav-link" href="/archives/" target="_self">
  67. <i class="iconfont icon-archive-fill"></i>
  68. <span>Archive1</span>
  69. </a>
  70. </li>
  71. <li class="nav-item">
  72. <a class="nav-link" href="https://occdn.limour.top/archives/" target="_self">
  73. <i class="iconfont icon-archive-fill"></i>
  74. <span>Archive2</span>
  75. </a>
  76. </li>
  77. <li class="nav-item">
  78. <a class="nav-link" href="https://b.limour.top/archives/" target="_self">
  79. <i class="iconfont icon-archive-fill"></i>
  80. <span>Archive3</span>
  81. </a>
  82. </li>
  83. <li class="nav-item">
  84. <a class="nav-link" href="https://od.limour.top/" target="_self">
  85. <i class="iconfont icon-onedrive"></i>
  86. <span>Alist</span>
  87. </a>
  88. </li>
  89. <li class="nav-item">
  90. <a class="nav-link" href="https://orcid.org/0000-0001-8897-1685" target="_self">
  91. <i class="iconfont icon-orcid"></i>
  92. <span>Orcid</span>
  93. </a>
  94. </li>
  95. <li class="nav-item">
  96. <a class="nav-link" href="/links/" target="_self">
  97. <i class="iconfont icon-link-fill"></i>
  98. <span>Links</span>
  99. </a>
  100. </li>
  101. <li class="nav-item">
  102. <a class="nav-link" href="/atom.xml" target="_self">
  103. <i class="iconfont icon-rss"></i>
  104. <span>RSS</span>
  105. </a>
  106. </li>
  107. <li class="nav-item" id="search-btn">
  108. <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
  109. <i class="iconfont icon-search"></i>
  110. </a>
  111. </li>
  112. <li class="nav-item" id="color-toggle-btn">
  113. <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">
  114. <i class="iconfont icon-dark" id="color-toggle-icon"></i>
  115. </a>
  116. </li>
  117. </ul>
  118. </div>
  119. </div>
  120. </nav>
  121. <div id="banner" class="banner" parallax=true
  122. style="background: url('https://img.limour.top/2023/08/29/64ee08e108638.webp') no-repeat center center; background-size: cover;">
  123. <div class="full-bg-img">
  124. <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
  125. <div class="banner-text text-center fade-in-up">
  126. <div class="h2">
  127. <span id="subtitle">【学习】孟德尔随机化</span>
  128. </div>
  129. <div class="mt-3">
  130. <span class="post-meta mr-2">
  131. <i class="iconfont icon-author" aria-hidden="true"></i>
  132. Limour
  133. </span>
  134. <span class="post-meta">
  135. <i class="iconfont icon-date-fill" aria-hidden="true"></i>
  136. <time datetime="2023-10-14 17:18" pubdate>
  137. October 14, 2023 pm
  138. </time>
  139. </span>
  140. </div>
  141. <div class="mt-1">
  142. <span class="post-meta mr-2">
  143. <i class="iconfont icon-chart"></i>
  144. 2.7k words
  145. </span>
  146. <span class="post-meta mr-2">
  147. <i class="iconfont icon-clock-fill"></i>
  148. 23 mins
  149. </span>
  150. </div>
  151. </div>
  152. </div>
  153. </div>
  154. </div>
  155. </div>
  156. </header>
  157. <main>
  158. <div class="container-fluid nopadding-x">
  159. <div class="row nomargin-x">
  160. <div class="side-col d-none d-lg-block col-lg-2">
  161. </div>
  162. <div class="col-lg-8 nopadding-x-md">
  163. <div class="container nopadding-x-md" id="board-ctn">
  164. <div id="board">
  165. <article class="post-content mx-auto">
  166. <h1 id="seo-header">【学习】孟德尔随机化</h1>
  167. <p id="updated-time" class="note note-info" style="">
  168. Last updated on March 19, 2024 pm
  169. </p>
  170. <div class="markdown-body">
  171. <h2 id="MR定义">MR定义</h2>
  172. <p>孟德尔随机化是一种基于全基因组测序数据(GWAS数据),利用单核首酸多态性(SNPs)作为工具变量(IV),用于揭示因果关系的新型流行病学方法,相较于队列研究等观察性研究,暴露在出生前便已确定,较少受到反向因果及混杂因素的影响,因而能够有效减少偏倚。<br>
  173. <img src="https://img.limour.top/2023/10/14/652a61ab222a4.webp" srcset="https://jscdn.limour.top/gh/Limour-dev/Sakurairo_Vision/load_svg/inload.svg" lazyload alt="RCT与MR的比较"><br>
  174. MR的核心是运用遗传学数据作为桥梁,来探索某一暴露和某一结局之间的因果关联。与RCT将参与者随机分配到试验组或对照组类似,MR研究基于影响危险因素的一个或多个等位基因,对参与基因进行&quot;随机化&quot;(自然的随机化),以确定这些遗传变异的携带者与非携带者相比,是否具有不同的疾病发生风险,因此,孟德尔随机化可以被认为类似于<a target="_blank" rel="noopener" href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2458144">&quot;自然的随机对照试验&quot;</a>。<a target="_blank" rel="noopener" href="https://mr-dictionary.mrcieu.ac.uk/">MR的相关术语</a></p>
  175. <h2 id="理论假设">理论假设</h2>
  176. <ol>
  177. <li>the variant is associated with the exposure</li>
  178. <li>the variant is not associated with the outcome via a confounding pathway</li>
  179. <li>the variant does not affect the outcome directly, only possibly indirectly via the exposure</li>
  180. </ol>
  181. <p><img src="https://img.limour.top/2023/10/14/652a651b96f98.webp" srcset="https://jscdn.limour.top/gh/Limour-dev/Sakurairo_Vision/load_svg/inload.svg" lazyload alt="孟德尔随机化框架的有向无环图表示"></p>
  182. <ol>
  183. <li>关联性假设:变异与暴露有关</li>
  184. <li>独立性假设:变异与结果之间没有通过混杂途径相关</li>
  185. <li>排他性假设:变异不直接影响结果,只可能通过暴露途径间接影响</li>
  186. </ol>
  187. <ul>
  188. <li>关联性假设:p值,F统计量,R^2</li>
  189. <li>排他性假设:与结局的相关性计算时,p值要大于0.05</li>
  190. <li><a target="_blank" rel="noopener" href="https://doi.org/10.1093/ije/dyv080">MR-Egger</a>回归相比线性回归可以弱化对排他性假设的要求</li>
  191. </ul>
  192. <h2 id="适用范围">适用范围</h2>
  193. <ul>
  194. <li>不确定先有鸡还是先有蛋,比如,到底是抑郁导致肺癌还是肺癌导致了抑郁?</li>
  195. <li>暴露因素难以测量,或者花费昂贵。例如,水溶性维生素等生物标志物的检测金标准可能成本太高,大样本无法承受,或者空腹血糖的测量需要隔夜空腹,可能不现实。</li>
  196. <li>暴露与结局数据来自同一人群,且不存在或存在少量可接受范围内的样本重叠</li>
  197. </ul>
  198. <h2 id="配置环境">配置环境</h2>
  199. <ul>
  200. <li><a href="/-ji-lu--an-zhuang-sheng-xin-de-dai-ma-bian-xie-huan-jing">基础编程环境</a></li>
  201. <li><a href="/-fu-ke-GitHub-wen-jian-jia-su">GitHub 下载加速</a></li>
  202. <li><a href="/-ji-lu-SOCKS5-zhuan-QUIC">可能需要用到的加速服务</a></li>
  203. </ul>
  204. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line">conda create -n MR -c conda-forge r-devtools -y</span><br><span class="line">conda activate MR</span><br><span class="line">conda install -c conda-forge r-irkernel -y</span><br><span class="line">Rscript -e <span class="string">&quot;IRkernel::installspec(name=&#x27;MR&#x27;, displayname=&#x27;MR&#x27;)&quot;</span></span><br><span class="line"><span class="comment"># Rscript -e &quot;usethis::edit_r_environ()&quot; # 设置 GITHUB_PAT</span></span><br><span class="line"><span class="comment"># nano ~/.Renviron # MRCIEU 真是超喜欢GITHUB,要访问一万次 api.github.com</span></span><br><span class="line">conda install -c conda-forge r-rmarkdown -y</span><br><span class="line">conda install -c conda-forge r-meta -y</span><br><span class="line">wget https://github.com/MRCIEU/TwoSampleMR/archive/refs/heads/master.zip -O TwoSampleMR.zip</span><br><span class="line">Rscript -e <span class="string">&quot;devtools::install_local(&#x27;TwoSampleMR.zip&#x27;)&quot;</span></span><br><span class="line">wget https://github.com/MRCIEU/MRInstruments/archive/refs/heads/master.zip -O MRInstruments.zip</span><br><span class="line">Rscript -e <span class="string">&quot;devtools::install_local(&#x27;MRInstruments.zip&#x27;)&quot;</span></span><br><span class="line">conda install -c conda-forge r-susier -y</span><br><span class="line">conda install -c bioconda bioconductor-variantannotation -y</span><br><span class="line">wget https://github.com/MRCIEU/gwasglue/archive/refs/heads/master.zip -O gwasglue.zip</span><br><span class="line">Rscript -e <span class="string">&quot;devtools::install_local(&#x27;gwasglue.zip&#x27;)&quot;</span></span><br><span class="line"><span class="comment"># wget https://github.com/MRCIEU/genetics.binaRies/archive/refs/heads/master.zip -O genetics.binaRies.zip</span></span><br><span class="line"><span class="comment"># Rscript -e &quot;devtools::install_local(&#x27;genetics.binaRies.zip&#x27;)&quot;</span></span><br><span class="line">conda install -c bioconda plink -y</span><br><span class="line"><span class="comment"># whereis plink # /opt/conda/envs/MR/bin/plink</span></span><br><span class="line">Rscript -e <span class="string">&#x27;install.packages(&quot;MendelianRandomization&quot;)&#x27;</span></span><br></pre></td></tr></table></figure>
  205. <h2 id="数据来源">数据来源</h2>
  206. <ul>
  207. <li>精神病学基因组:<a target="_blank" rel="noopener" href="https://pgc.unc.edu/">PGC</a></li>
  208. <li>社会科学遗传学:<a target="_blank" rel="noopener" href="https://www.thessgac.org/">SSGAC</a></li>
  209. <li>大脑健康和疾病:<a target="_blank" rel="noopener" href="https://ctg.cncr.nl/software/summary_statistics">CTG</a></li>
  210. <li>MRCIEU汇总数据库:<a target="_blank" rel="noopener" href="https://gwas.mrcieu.ac.uk/">IEU</a></li>
  211. <li>GWAS研究目录:<a target="_blank" rel="noopener" href="https://www.ebi.ac.uk/gwas/search">NHGRI-EBI</a></li>
  212. <li><a href="/shi-yong-GATK-zhao-SNP">自己分析出数据</a></li>
  213. <li><a target="_blank" rel="noopener" href="https://od.limour.top/archives/GWAS/MR">更多相关网站</a></li>
  214. </ul>
  215. <h3 id="一些参考数据">一些参考数据</h3>
  216. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">wget http://fileserve.mrcieu.ac.uk/ld/1kg.v3.tgz</span><br><span class="line">tar -zxvf 1kg.v3.tgz</span><br><span class="line"><span class="comment"># mkdir EUR &amp;&amp; mv EUR.* EUR</span></span><br></pre></td></tr></table></figure>
  217. <h3 id="示例结局数据">示例结局数据</h3>
  218. <ul>
  219. <li>浏览器下载 <a target="_blank" rel="noopener" href="https://figshare.com/ndownloader/files/40036684">ADHD2022_iPSYCH_deCODE_PGC.meta.gz</a></li>
  220. <li><a href="/Rclone-bei-fen-VPS-shu-ju-dao-onedrive">上传到服务器</a></li>
  221. </ul>
  222. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># zcat ADHD2022_iPSYCH_deCODE_PGC.meta.gz | head</span></span><br><span class="line">CHR SNP BP A1 A2 FRQ_A_38691 FRQ_U_186843 INFO OR SE P Direction Nca Nco</span><br><span class="line">8 rs62513865 101592213 C T 0.925 0.937 0.981 0.99631 0.0175 0.8325 +---+++0-++-+ 38691 186843</span><br><span class="line">8 rs79643588 106973048 G A 0.91 0.917 1 1.00411 0.0159 0.7967 ++--++-+-+-++ 38691 186843</span><br><span class="line">8 rs17396518 108690829 T G 0.561 0.577 0.998 0.99611 0.0096 0.6876 --++-++??-+-- 37367 184388</span><br><span class="line">8 rs983166 108681675 A C 0.57 0.586 0.996 0.99491 0.0096 0.5956 --++-++++-+-- 38691 186843</span><br><span class="line">8 rs28842593 103044620 T C 0.839 0.836 0.982 0.98314 0.0135 0.2081 ----++0+??--+ 37504 184525</span><br><span class="line">8 rs7014597 104152280 G C 0.824 0.824 0.997 0.99950 0.0122 0.9679 +-++-+++++--- 38691 186843</span><br><span class="line">8 rs3134156 100479917 T C 0.841 0.833 0.997 0.98866 0.0128 0.3762 -+----+--++-- 38691 186843</span><br><span class="line">8 rs6980591 103144592 A C 0.783 0.79 1 1.01106 0.0108 0.3075 ++-++---+++++ 38691 186843</span><br><span class="line">8 rs72670434 108166508 A T 0.642 0.623 0.983 1.00672 0.0103 0.5171 +++-+++--+++- 38691 186843</span><br></pre></td></tr></table></figure>
  223. <figure class="highlight txt"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">CHR Chromosome (hg19)</span><br><span class="line">SNP Marker name</span><br><span class="line">BP Base pair location (hg19)</span><br><span class="line">A1 Reference allele for OR (may or may not be minor allele)</span><br><span class="line">A2 Alternative allele</span><br><span class="line">FRQ_A_38691 allele frequency of A1 in 38,691 ADHD cases</span><br><span class="line">FRQ_U_186843 allele frequency of A1 in 38,691 controls</span><br><span class="line">INFO Imputation information score (the reported imputation INFO score is a weighted average across the</span><br><span class="line">cohorts contributing to the meta-analysis for that variant)</span><br><span class="line">OR Odds ratio for the effect of the A1 allele</span><br><span class="line">SE Standard error of the log(OR)</span><br><span class="line">P P-value for association test in the meta-analysis</span><br><span class="line">Direction direction of effect in the included cohorts</span><br><span class="line">Nca number of cases with variant information</span><br><span class="line">Nco number of controls with variant information</span><br></pre></td></tr></table></figure>
  224. <p>其中<code>SNP</code>,<code>Effect allele</code>,<code>Beta(OR)</code>,<code>SE</code>,<code>P</code>这五列是必须的。遇到没有提供EAF的数据,可以<a target="_blank" rel="noopener" href="https://github.com/HaobinZhou/Get_MR">匹配千人基因组数据的EAF</a>,<code>get_eaf_from_1000G</code>。</p>
  225. <h3 id="示例暴露数据">示例暴露数据</h3>
  226. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">wget -c https://gwas.mrcieu.ac.uk/files/ieu-a-2/ieu-a-2.vcf.gz</span><br></pre></td></tr></table></figure>
  227. <figure class="highlight r"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line">VCF_dat <span class="operator">=</span> VariantAnnotation<span class="operator">::</span>readVcf<span class="punctuation">(</span><span class="string">&#x27;~/upload/GWAS/IEU/ieu-a-2.vcf.gz&#x27;</span><span class="punctuation">)</span></span><br><span class="line">exp_dat <span class="operator">=</span> gwasglue<span class="operator">::</span>gwasvcf_to_TwoSampleMR<span class="punctuation">(</span>vcf <span class="operator">=</span> VCF_dat<span class="punctuation">)</span></span><br><span class="line">saveRDS<span class="punctuation">(</span>file <span class="operator">=</span> <span class="string">&#x27;ieu-a-2.exp_dat&#x27;</span><span class="punctuation">,</span> exp_dat<span class="punctuation">)</span></span><br><span class="line">exp_dat <span class="operator">=</span> subset<span class="punctuation">(</span>exp_dat<span class="punctuation">,</span> pval.exposure <span class="operator">&lt;</span> <span class="number">5e-08</span><span class="punctuation">)</span> <span class="comment"># 关联性假设</span></span><br><span class="line"><span class="comment"># 去除连锁不平衡</span></span><br><span class="line"><span class="comment"># exp_dat = TwoSampleMR::clump_data(dat = exp_dat, clump_kb = 10000, clump_r2 = 0.001) # MRCIEU太喜欢用cloud api了</span></span><br><span class="line">fix_ld_clump_local <span class="operator">=</span> <span class="keyword">function</span> <span class="punctuation">(</span>dat<span class="punctuation">,</span> tempfile<span class="punctuation">,</span> clump_kb<span class="punctuation">,</span> clump_r2<span class="punctuation">,</span> clump_p<span class="punctuation">,</span> bfile<span class="punctuation">,</span> plink_bin<span class="punctuation">)</span> <span class="punctuation">&#123;</span></span><br><span class="line"> shell <span class="operator">&lt;-</span> ifelse<span class="punctuation">(</span>Sys.info<span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">[</span><span class="string">&quot;sysname&quot;</span><span class="punctuation">]</span> <span class="operator">==</span> <span class="string">&quot;Windows&quot;</span><span class="punctuation">,</span> <span class="string">&quot;cmd&quot;</span><span class="punctuation">,</span> </span><br><span class="line"> <span class="string">&quot;sh&quot;</span><span class="punctuation">)</span></span><br><span class="line"> write.table<span class="punctuation">(</span>data.frame<span class="punctuation">(</span>SNP <span class="operator">=</span> dat<span class="punctuation">[[</span><span class="string">&quot;rsid&quot;</span><span class="punctuation">]</span><span class="punctuation">]</span><span class="punctuation">,</span> P <span class="operator">=</span> dat<span class="punctuation">[[</span><span class="string">&quot;pval&quot;</span><span class="punctuation">]</span><span class="punctuation">]</span><span class="punctuation">)</span><span class="punctuation">,</span> </span><br><span class="line"> file <span class="operator">=</span> tempfile<span class="punctuation">,</span> row.names <span class="operator">=</span> <span class="built_in">F</span><span class="punctuation">,</span> col.names <span class="operator">=</span> <span class="built_in">T</span><span class="punctuation">,</span> <span class="built_in">quote</span> <span class="operator">=</span> <span class="built_in">F</span><span class="punctuation">)</span></span><br><span class="line"> fun2 <span class="operator">&lt;-</span> paste0<span class="punctuation">(</span>shQuote<span class="punctuation">(</span>plink_bin<span class="punctuation">,</span> type <span class="operator">=</span> shell<span class="punctuation">)</span><span class="punctuation">,</span> <span class="string">&quot; --bfile &quot;</span><span class="punctuation">,</span> </span><br><span class="line"> shQuote<span class="punctuation">(</span>bfile<span class="punctuation">,</span> type <span class="operator">=</span> shell<span class="punctuation">)</span><span class="punctuation">,</span> <span class="string">&quot; --clump &quot;</span><span class="punctuation">,</span> shQuote<span class="punctuation">(</span>tempfile<span class="punctuation">,</span> </span><br><span class="line"> type <span class="operator">=</span> shell<span class="punctuation">)</span><span class="punctuation">,</span> <span class="string">&quot; --clump-p1 &quot;</span><span class="punctuation">,</span> clump_p<span class="punctuation">,</span> <span class="string">&quot; --clump-r2 &quot;</span><span class="punctuation">,</span> </span><br><span class="line"> clump_r2<span class="punctuation">,</span> <span class="string">&quot; --clump-kb &quot;</span><span class="punctuation">,</span> clump_kb<span class="punctuation">,</span> <span class="string">&quot; --out &quot;</span><span class="punctuation">,</span> shQuote<span class="punctuation">(</span>tempfile<span class="punctuation">,</span> </span><br><span class="line"> type <span class="operator">=</span> shell<span class="punctuation">)</span><span class="punctuation">)</span></span><br><span class="line"> print<span class="punctuation">(</span>fun2<span class="punctuation">)</span></span><br><span class="line"> system<span class="punctuation">(</span>fun2<span class="punctuation">)</span></span><br><span class="line"> res <span class="operator">&lt;-</span> read.table<span class="punctuation">(</span>paste<span class="punctuation">(</span>tempfile<span class="punctuation">,</span> <span class="string">&quot;.clumped&quot;</span><span class="punctuation">,</span> sep <span class="operator">=</span> <span class="string">&quot;&quot;</span><span class="punctuation">)</span><span class="punctuation">,</span> header <span class="operator">=</span> <span class="built_in">T</span><span class="punctuation">)</span></span><br><span class="line"> unlink<span class="punctuation">(</span>paste<span class="punctuation">(</span>tempfile<span class="punctuation">,</span> <span class="string">&quot;*&quot;</span><span class="punctuation">,</span> sep <span class="operator">=</span> <span class="string">&quot;&quot;</span><span class="punctuation">)</span><span class="punctuation">)</span></span><br><span class="line"> y <span class="operator">&lt;-</span> subset<span class="punctuation">(</span>dat<span class="punctuation">,</span> <span class="operator">!</span>dat<span class="punctuation">[[</span><span class="string">&quot;rsid&quot;</span><span class="punctuation">]</span><span class="punctuation">]</span> <span class="operator">%in%</span> res<span class="punctuation">[[</span><span class="string">&quot;SNP&quot;</span><span class="punctuation">]</span><span class="punctuation">]</span><span class="punctuation">)</span></span><br><span class="line"> <span class="keyword">if</span> <span class="punctuation">(</span>nrow<span class="punctuation">(</span>y<span class="punctuation">)</span> <span class="operator">&gt;</span> <span class="number">0</span><span class="punctuation">)</span> <span class="punctuation">&#123;</span></span><br><span class="line"> message<span class="punctuation">(</span><span class="string">&quot;Removing &quot;</span><span class="punctuation">,</span> <span class="built_in">length</span><span class="punctuation">(</span>y<span class="punctuation">[[</span><span class="string">&quot;rsid&quot;</span><span class="punctuation">]</span><span class="punctuation">]</span><span class="punctuation">)</span><span class="punctuation">,</span> <span class="string">&quot; of &quot;</span><span class="punctuation">,</span> nrow<span class="punctuation">(</span>dat<span class="punctuation">)</span><span class="punctuation">,</span> </span><br><span class="line"> <span class="string">&quot; variants due to LD with other variants or absence from LD reference panel&quot;</span><span class="punctuation">)</span></span><br><span class="line"> <span class="punctuation">&#125;</span></span><br><span class="line"> <span class="built_in">return</span><span class="punctuation">(</span>subset<span class="punctuation">(</span>dat<span class="punctuation">,</span> dat<span class="punctuation">[[</span><span class="string">&quot;rsid&quot;</span><span class="punctuation">]</span><span class="punctuation">]</span> <span class="operator">%in%</span> res<span class="punctuation">[[</span><span class="string">&quot;SNP&quot;</span><span class="punctuation">]</span><span class="punctuation">]</span><span class="punctuation">)</span><span class="punctuation">)</span></span><br><span class="line"><span class="punctuation">&#125;</span></span><br><span class="line">fuck <span class="operator">=</span> fix_ld_clump_local<span class="punctuation">(</span></span><br><span class="line"> dat <span class="operator">=</span> dplyr<span class="operator">::</span>tibble<span class="punctuation">(</span>rsid<span class="operator">=</span>exp_dat<span class="operator">$</span>SNP<span class="punctuation">,</span> pval<span class="operator">=</span>exp_dat<span class="operator">$</span>pval.exposure<span class="punctuation">)</span><span class="punctuation">,</span></span><br><span class="line"> tempfile <span class="operator">=</span> file.path<span class="punctuation">(</span>getwd<span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">,</span><span class="string">&#x27;tmp.ld_clump.exp_dat&#x27;</span><span class="punctuation">)</span><span class="punctuation">,</span></span><br><span class="line"> clump_kb <span class="operator">=</span> <span class="number">10000</span><span class="punctuation">,</span> clump_r2 <span class="operator">=</span> <span class="number">0.001</span><span class="punctuation">,</span> clump_p <span class="operator">=</span> <span class="number">1</span><span class="punctuation">,</span></span><br><span class="line"> <span class="comment"># pop = &quot;EUR&quot;, # Super-population. Options are &quot;EUR&quot;, &quot;SAS&quot;, &quot;EAS&quot;, &quot;AFR&quot;, &quot;AMR&quot;</span></span><br><span class="line"> plink_bin <span class="operator">=</span> <span class="string">&#x27;/opt/conda/envs/MR/bin/plink&#x27;</span><span class="punctuation">,</span> <span class="comment"># 千万别用什么 genetics.binaRies::get_plink_binary(),他们自己编译的文件有问题</span></span><br><span class="line"> bfile <span class="operator">=</span> <span class="string">&quot;/home/jovyan/upload/GWAS/ld/EUR&quot;</span> <span class="comment"># 前缀,不是文件夹也不是文件</span></span><br><span class="line"><span class="punctuation">)</span></span><br><span class="line">exp_dat_clumped <span class="operator">=</span> exp_dat<span class="punctuation">[</span>exp_dat<span class="operator">$</span>SNP <span class="operator">%in%</span> fuck<span class="operator">$</span>rsid<span class="punctuation">,</span><span class="punctuation">]</span></span><br><span class="line">saveRDS<span class="punctuation">(</span>file <span class="operator">=</span> <span class="string">&#x27;ieu-a-2.exp_gwas&#x27;</span><span class="punctuation">,</span> exp_dat_clumped<span class="punctuation">)</span></span><br></pre></td></tr></table></figure>
  228. <h2 id="获取暴露数据">获取暴露数据</h2>
  229. <h3 id="自己的数据">自己的数据</h3>
  230. <figure class="highlight r"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">df_gwas <span class="operator">&lt;-</span> data.frame<span class="punctuation">(</span></span><br><span class="line"> SNP <span class="operator">=</span> <span class="built_in">c</span><span class="punctuation">(</span><span class="string">&quot;rs1&quot;</span><span class="punctuation">,</span> <span class="string">&quot;rs2&quot;</span><span class="punctuation">)</span><span class="punctuation">,</span></span><br><span class="line"> beta <span class="operator">=</span> <span class="built_in">c</span><span class="punctuation">(</span><span class="number">1</span><span class="punctuation">,</span> <span class="number">2</span><span class="punctuation">)</span><span class="punctuation">,</span></span><br><span class="line"> se <span class="operator">=</span> <span class="built_in">c</span><span class="punctuation">(</span><span class="number">1</span><span class="punctuation">,</span> <span class="number">2</span><span class="punctuation">)</span><span class="punctuation">,</span></span><br><span class="line"> effect_allele <span class="operator">=</span> <span class="built_in">c</span><span class="punctuation">(</span><span class="string">&quot;A&quot;</span><span class="punctuation">,</span> <span class="string">&quot;T&quot;</span><span class="punctuation">)</span></span><br><span class="line"><span class="punctuation">)</span></span><br><span class="line">head<span class="punctuation">(</span>df_gwas<span class="punctuation">)</span></span><br><span class="line">exp_dat <span class="operator">&lt;-</span> TwoSampleMR<span class="operator">::</span>format_data<span class="punctuation">(</span>df_gwas<span class="punctuation">,</span> type <span class="operator">=</span> <span class="string">&quot;exposure&quot;</span><span class="punctuation">)</span></span><br></pre></td></tr></table></figure>
  231. <h3 id="gwas-catalog">gwas_catalog</h3>
  232. <figure class="highlight r"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">df_gwas <span class="operator">&lt;-</span></span><br><span class="line"> subset<span class="punctuation">(</span>MRInstruments<span class="operator">::</span>gwas_catalog<span class="punctuation">,</span></span><br><span class="line"> grepl<span class="punctuation">(</span><span class="string">&quot;Speliotes&quot;</span><span class="punctuation">,</span> Author<span class="punctuation">)</span> <span class="operator">&amp;</span></span><br><span class="line"> Phenotype <span class="operator">==</span> <span class="string">&quot;Body mass index&quot;</span><span class="punctuation">)</span></span><br><span class="line">head<span class="punctuation">(</span>df_gwas<span class="punctuation">)</span></span><br><span class="line">exp_dat <span class="operator">&lt;-</span> TwoSampleMR<span class="operator">::</span>format_data<span class="punctuation">(</span>df_gwas<span class="punctuation">)</span></span><br></pre></td></tr></table></figure>
  233. <h3 id="metab-qtls">metab_qtls</h3>
  234. <figure class="highlight r"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">df_gwas <span class="operator">&lt;-</span></span><br><span class="line"> subset<span class="punctuation">(</span>MRInstruments<span class="operator">::</span>metab_qtls<span class="punctuation">,</span></span><br><span class="line"> phenotype <span class="operator">==</span> <span class="string">&quot;Ala&quot;</span></span><br><span class="line"> <span class="punctuation">)</span></span><br><span class="line">head<span class="punctuation">(</span>df_gwas<span class="punctuation">)</span></span><br><span class="line">exp_dat <span class="operator">&lt;-</span> TwoSampleMR<span class="operator">::</span>format_metab_qtls<span class="punctuation">(</span>df_gwas<span class="punctuation">)</span></span><br></pre></td></tr></table></figure>
  235. <h3 id="proteomic-qtls">proteomic_qtls</h3>
  236. <figure class="highlight r"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">df_gwas <span class="operator">&lt;-</span></span><br><span class="line"> subset<span class="punctuation">(</span>MRInstruments<span class="operator">::</span>proteomic_qtls<span class="punctuation">,</span></span><br><span class="line"> analyte <span class="operator">==</span> <span class="string">&quot;ApoH&quot;</span></span><br><span class="line"> <span class="punctuation">)</span></span><br><span class="line">head<span class="punctuation">(</span>df_gwas<span class="punctuation">)</span></span><br><span class="line">exp_dat <span class="operator">&lt;-</span> TwoSampleMR<span class="operator">::</span>format_proteomic_qtls<span class="punctuation">(</span>df_gwas<span class="punctuation">)</span></span><br></pre></td></tr></table></figure>
  237. <h3 id="某个基因">某个基因</h3>
  238. <figure class="highlight r"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">df_gwas <span class="operator">&lt;-</span></span><br><span class="line"> subset<span class="punctuation">(</span>MRInstruments<span class="operator">::</span>gtex_eqtl<span class="punctuation">,</span></span><br><span class="line"> gene_name <span class="operator">==</span> <span class="string">&quot;IRAK1BP1&quot;</span> <span class="operator">&amp;</span> tissue <span class="operator">==</span> <span class="string">&quot;Adipose Subcutaneous&quot;</span></span><br><span class="line"> <span class="punctuation">)</span></span><br><span class="line">head<span class="punctuation">(</span>df_gwas<span class="punctuation">)</span></span><br><span class="line">exp_dat <span class="operator">&lt;-</span> TwoSampleMR<span class="operator">::</span>format_gtex_eqtl<span class="punctuation">(</span>df_gwas<span class="punctuation">)</span></span><br></pre></td></tr></table></figure>
  239. <h3 id="某个性状的某个甲基化位点相关QTL">某个性状的某个甲基化位点相关QTL</h3>
  240. <figure class="highlight r"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">df_gwas <span class="operator">&lt;-</span></span><br><span class="line"> subset<span class="punctuation">(</span>MRInstruments<span class="operator">::</span>aries_mqtl<span class="punctuation">,</span></span><br><span class="line"> cpg <span class="operator">==</span> <span class="string">&quot;cg25212131&quot;</span> <span class="operator">&amp;</span> age <span class="operator">==</span> <span class="string">&quot;Birth&quot;</span></span><br><span class="line"> <span class="punctuation">)</span></span><br><span class="line">head<span class="punctuation">(</span>df_gwas<span class="punctuation">)</span></span><br><span class="line">exp_dat <span class="operator">&lt;-</span> TwoSampleMR<span class="operator">::</span>format_aries_mqtl<span class="punctuation">(</span>df_gwas<span class="punctuation">)</span></span><br></pre></td></tr></table></figure>
  241. <h3 id="IEU的ID">IEU的ID</h3>
  242. <figure class="highlight r"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">exp_gwas <span class="operator">&lt;-</span> TwoSampleMR<span class="operator">::</span>extract_instruments<span class="punctuation">(</span>outcomes <span class="operator">=</span> <span class="string">&#x27;ieu-a-2&#x27;</span><span class="punctuation">)</span></span><br><span class="line">head<span class="punctuation">(</span>exp_gwas<span class="punctuation">)</span></span><br><span class="line">saveRDS<span class="punctuation">(</span>file <span class="operator">=</span> <span class="string">&#x27;ieu-a-2.exp_gwas&#x27;</span><span class="punctuation">,</span> exp_gwas<span class="punctuation">)</span> <span class="comment"># 和自己从VCF开始经过clump得到的差不多</span></span><br></pre></td></tr></table></figure>
  243. <h3 id="UK-Biobank">UK_Biobank</h3>
  244. <figure class="highlight r"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line">hyperten_tophits <span class="operator">&lt;-</span> ieugwasr<span class="operator">::</span>tophits<span class="punctuation">(</span>id<span class="operator">=</span><span class="string">&quot;ukb-b-12493&quot;</span><span class="punctuation">,</span> clump<span class="operator">=</span><span class="number">0</span><span class="punctuation">)</span></span><br><span class="line">hyperten_gwas <span class="operator">&lt;-</span> dplyr<span class="operator">::</span>rename<span class="punctuation">(</span>hyperten_tophits<span class="punctuation">,</span> <span class="built_in">c</span><span class="punctuation">(</span></span><br><span class="line"> <span class="string">&quot;SNP&quot;</span><span class="operator">=</span><span class="string">&quot;rsid&quot;</span><span class="punctuation">,</span></span><br><span class="line"> <span class="string">&quot;effect_allele.exposure&quot;</span><span class="operator">=</span><span class="string">&quot;ea&quot;</span><span class="punctuation">,</span></span><br><span class="line"> <span class="string">&quot;other_allele.exposure&quot;</span><span class="operator">=</span><span class="string">&quot;nea&quot;</span><span class="punctuation">,</span></span><br><span class="line"> <span class="string">&quot;beta.exposure&quot;</span><span class="operator">=</span><span class="string">&quot;beta&quot;</span><span class="punctuation">,</span></span><br><span class="line"> <span class="string">&quot;se.exposure&quot;</span><span class="operator">=</span><span class="string">&quot;se&quot;</span><span class="punctuation">,</span></span><br><span class="line"> <span class="string">&quot;eaf.exposure&quot;</span><span class="operator">=</span><span class="string">&quot;eaf&quot;</span><span class="punctuation">,</span></span><br><span class="line"> <span class="string">&quot;pval.exposure&quot;</span><span class="operator">=</span><span class="string">&quot;p&quot;</span><span class="punctuation">,</span></span><br><span class="line"> <span class="string">&quot;N&quot;</span><span class="operator">=</span><span class="string">&quot;n&quot;</span><span class="punctuation">)</span><span class="punctuation">)</span></span><br><span class="line">fuck <span class="operator">=</span> fix_ld_clump_local<span class="punctuation">(</span></span><br><span class="line"> dat <span class="operator">=</span> dplyr<span class="operator">::</span>tibble<span class="punctuation">(</span>rsid<span class="operator">=</span>hyperten_gwas<span class="operator">$</span>SNP<span class="punctuation">,</span> pval<span class="operator">=</span>hyperten_gwas<span class="operator">$</span>pval.exposure<span class="punctuation">)</span><span class="punctuation">,</span></span><br><span class="line"> tempfile <span class="operator">=</span> file.path<span class="punctuation">(</span>getwd<span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">,</span><span class="string">&#x27;tmp.ld_clump.exp_dat&#x27;</span><span class="punctuation">)</span><span class="punctuation">,</span></span><br><span class="line"> clump_kb <span class="operator">=</span> <span class="number">10000</span><span class="punctuation">,</span> clump_r2 <span class="operator">=</span> <span class="number">0.001</span><span class="punctuation">,</span> clump_p <span class="operator">=</span> <span class="number">1</span><span class="punctuation">,</span></span><br><span class="line"> <span class="comment"># pop = &quot;EUR&quot;, # Super-population. Options are &quot;EUR&quot;, &quot;SAS&quot;, &quot;EAS&quot;, &quot;AFR&quot;, &quot;AMR&quot;</span></span><br><span class="line"> plink_bin <span class="operator">=</span> <span class="string">&#x27;/opt/conda/envs/MR/bin/plink&#x27;</span><span class="punctuation">,</span> <span class="comment"># 千万别用什么 genetics.binaRies::get_plink_binary(),他们自己编译的文件有问题</span></span><br><span class="line"> bfile <span class="operator">=</span> <span class="string">&quot;/home/jovyan/upload/GWAS/ld/EUR&quot;</span> <span class="comment"># 前缀,不是文件夹也不是文件</span></span><br><span class="line"><span class="punctuation">)</span></span><br><span class="line">exp_dat_clumped <span class="operator">=</span> hyperten_gwas<span class="punctuation">[</span>hyperten_gwas<span class="operator">$</span>SNP <span class="operator">%in%</span> fuck<span class="operator">$</span>rsid<span class="punctuation">,</span><span class="punctuation">]</span></span><br><span class="line">MR_calc_r2_F<span class="punctuation">(</span></span><br><span class="line"> beta <span class="operator">=</span> exp_dat_clumped<span class="operator">$</span>beta.exposure<span class="punctuation">,</span> <span class="comment"># Vector of Log odds ratio. beta = log(OR)</span></span><br><span class="line"> eaf <span class="operator">=</span> exp_dat_clumped<span class="operator">$</span>eaf.exposure<span class="punctuation">,</span> <span class="comment"># Vector of allele frequencies.</span></span><br><span class="line"> N <span class="operator">=</span> exp_dat_clumped<span class="operator">$</span>N<span class="punctuation">,</span> <span class="comment"># Array of sample sizes</span></span><br><span class="line"> se <span class="operator">=</span> exp_dat_clumped<span class="operator">$</span>se.exposure <span class="comment"># Vector of SE.</span></span><br><span class="line"><span class="punctuation">)</span> <span class="comment"># 取 F&gt;10 的</span></span><br></pre></td></tr></table></figure>
  245. <h2 id="计算统计效力">计算统计效力</h2>
  246. <figure class="highlight r"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 分类变量</span></span><br><span class="line">tmp_r2 <span class="operator">=</span>TwoSampleMR<span class="operator">::</span>get_r_from_lor<span class="punctuation">(</span></span><br><span class="line"> lor <span class="operator">=</span> exp_dat_clumped<span class="operator">$</span>beta.exposure<span class="punctuation">,</span> <span class="comment"># Vector of Log odds ratio. beta = log(OR)</span></span><br><span class="line"> af <span class="operator">=</span> exp_dat_clumped<span class="operator">$</span>eaf.exposure<span class="punctuation">,</span> <span class="comment"># Vector of allele frequencies.</span></span><br><span class="line"> ncase <span class="operator">=</span> exp_dat_clumped<span class="operator">$</span>ncase.exposure<span class="punctuation">,</span> <span class="comment"># Vector of Number of cases. </span></span><br><span class="line"> ncontrol <span class="operator">=</span> exp_dat_clumped<span class="operator">$</span>ncontrol.exposure<span class="punctuation">,</span> <span class="comment"># Vector of Number of controls. </span></span><br><span class="line"> prevalence <span class="operator">=</span> <span class="number">1</span><span class="punctuation">,</span> <span class="comment"># Vector of Disease prevalence in the population.</span></span><br><span class="line"><span class="punctuation">)</span></span><br><span class="line"><span class="comment"># 连续变量</span></span><br><span class="line">tmp_r2 <span class="operator">=</span>TwoSampleMR<span class="operator">::</span>get_r_from_pn<span class="punctuation">(</span></span><br><span class="line"> p <span class="operator">=</span> exp_dat_clumped<span class="operator">$</span>pval.exposure<span class="punctuation">,</span> <span class="comment"># Array of pvals</span></span><br><span class="line"> n <span class="operator">=</span> exp_dat_clumped<span class="operator">$</span>samplesize.exposure <span class="comment"># Array of sample sizes</span></span><br><span class="line"><span class="punctuation">)</span></span><br></pre></td></tr></table></figure>
  247. <figure class="highlight r"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">MR_calc_r2_F <span class="operator">=</span> <span class="keyword">function</span><span class="punctuation">(</span>beta<span class="punctuation">,</span> eaf<span class="punctuation">,</span> N<span class="punctuation">,</span> se<span class="punctuation">)</span><span class="punctuation">&#123;</span></span><br><span class="line"> <span class="comment"># https://doi.org/10.1038/s41467-020-14389-8</span></span><br><span class="line"> <span class="comment"># https://doi.org/10.1371/journal.pone.0120758</span></span><br><span class="line"> r2 <span class="operator">=</span> <span class="punctuation">(</span><span class="number">2</span> <span class="operator">*</span> <span class="punctuation">(</span>beta<span class="operator">^</span><span class="number">2</span><span class="punctuation">)</span> <span class="operator">*</span> eaf <span class="operator">*</span> <span class="punctuation">(</span><span class="number">1</span> <span class="operator">-</span> eaf<span class="punctuation">)</span><span class="punctuation">)</span> <span class="operator">/</span></span><br><span class="line"> <span class="punctuation">(</span><span class="number">2</span> <span class="operator">*</span> <span class="punctuation">(</span>beta<span class="operator">^</span><span class="number">2</span><span class="punctuation">)</span> <span class="operator">*</span> eaf <span class="operator">*</span> <span class="punctuation">(</span><span class="number">1</span> <span class="operator">-</span> eaf<span class="punctuation">)</span> <span class="operator">+</span></span><br><span class="line"> <span class="number">2</span> <span class="operator">*</span> N <span class="operator">*</span> eaf <span class="operator">*</span> <span class="punctuation">(</span><span class="number">1</span> <span class="operator">-</span> eaf<span class="punctuation">)</span> <span class="operator">*</span> se<span class="operator">^</span><span class="number">2</span><span class="punctuation">)</span></span><br><span class="line"> <span class="built_in">F</span> <span class="operator">=</span> r2 <span class="operator">*</span> <span class="punctuation">(</span>N <span class="operator">-</span> <span class="number">2</span><span class="punctuation">)</span> <span class="operator">/</span> <span class="punctuation">(</span><span class="number">1</span> <span class="operator">-</span> r2<span class="punctuation">)</span></span><br><span class="line"> print<span class="punctuation">(</span>mean<span class="punctuation">(</span><span class="built_in">F</span><span class="punctuation">)</span><span class="punctuation">)</span></span><br><span class="line"> <span class="built_in">return</span><span class="punctuation">(</span>dplyr<span class="operator">::</span>tibble<span class="punctuation">(</span>r2<span class="operator">=</span>r2<span class="punctuation">,</span> <span class="built_in">F</span><span class="operator">=</span><span class="built_in">F</span><span class="punctuation">)</span><span class="punctuation">)</span></span><br><span class="line"><span class="punctuation">&#125;</span></span><br><span class="line">MR_calc_r2_F<span class="punctuation">(</span></span><br><span class="line"> beta <span class="operator">=</span> exp_dat_clumped<span class="operator">$</span>beta.exposure<span class="punctuation">,</span> <span class="comment"># Vector of Log odds ratio. beta = log(OR)</span></span><br><span class="line"> eaf <span class="operator">=</span> exp_dat_clumped<span class="operator">$</span>eaf.exposure<span class="punctuation">,</span> <span class="comment"># Vector of allele frequencies.</span></span><br><span class="line"> N <span class="operator">=</span> exp_dat_clumped<span class="operator">$</span>samplesize.exposure<span class="punctuation">,</span> <span class="comment"># Array of sample sizes</span></span><br><span class="line"> se <span class="operator">=</span> exp_dat_clumped<span class="operator">$</span>se.exposure <span class="comment"># Vector of SE.</span></span><br><span class="line"><span class="punctuation">)</span> <span class="comment"># 取 F&gt;10 的</span></span><br></pre></td></tr></table></figure>
  248. <h2 id="获取结局数据">获取结局数据</h2>
  249. <h3 id="IEU">IEU</h3>
  250. <figure class="highlight r"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">out_gwas <span class="operator">=</span> TwoSampleMR<span class="operator">::</span>extract_outcome_data<span class="punctuation">(</span>snps <span class="operator">=</span> exp_gwas<span class="operator">$</span>SNP<span class="punctuation">,</span> outcomes <span class="operator">=</span> <span class="string">&#x27;ieu-a-7&#x27;</span><span class="punctuation">)</span></span><br></pre></td></tr></table></figure>
  251. <h3 id="UK-Biobank-2">UK_Biobank</h3>
  252. <figure class="highlight r"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">anxiety_hyperten_liberal <span class="operator">&lt;-</span> TwoSampleMR<span class="operator">::</span>extract_outcome_data<span class="punctuation">(</span>snps <span class="operator">=</span> exp_dat_clumped<span class="operator">$</span>SNP<span class="punctuation">,</span> outcomes <span class="operator">=</span> <span class="string">&quot;ukb-b-11311&quot;</span><span class="punctuation">)</span></span><br></pre></td></tr></table></figure>
  253. <h3 id="PGC的示例">PGC的示例</h3>
  254. <figure class="highlight r"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">df_gwas <span class="operator">=</span> read.table<span class="punctuation">(</span>gzfile<span class="punctuation">(</span><span class="string">&#x27;~/upload/GWAS/PGC/ADHD2022_iPSYCH_deCODE_PGC.meta.gz&#x27;</span><span class="punctuation">)</span><span class="punctuation">,</span> header <span class="operator">=</span> <span class="built_in">T</span><span class="punctuation">)</span></span><br><span class="line">head<span class="punctuation">(</span>df_gwas<span class="punctuation">)</span></span><br><span class="line">df_gwas <span class="operator">=</span> df_gwas<span class="punctuation">[</span>df_gwas<span class="operator">$</span>SNP <span class="operator">%in%</span> exp_gwas<span class="operator">$</span>SNP<span class="punctuation">,</span><span class="punctuation">]</span></span><br><span class="line">out_gwas <span class="operator">=</span> data.frame<span class="punctuation">(</span></span><br><span class="line"> SNP <span class="operator">=</span> df_gwas<span class="operator">$</span>SNP<span class="punctuation">,</span></span><br><span class="line"> chr <span class="operator">=</span> <span class="built_in">as.character</span><span class="punctuation">(</span>df_gwas<span class="operator">$</span>CHR<span class="punctuation">)</span><span class="punctuation">,</span></span><br><span class="line"> pos <span class="operator">=</span> df_gwas<span class="operator">$</span>BP<span class="punctuation">,</span></span><br><span class="line"> beta.outcome <span class="operator">=</span> <span class="built_in">log</span><span class="punctuation">(</span>df_gwas<span class="operator">$</span>OR<span class="punctuation">)</span><span class="punctuation">,</span></span><br><span class="line"> se.outcome <span class="operator">=</span> df_gwas<span class="operator">$</span>SE<span class="punctuation">,</span></span><br><span class="line"> samplesize.outcome <span class="operator">=</span> df_gwas<span class="operator">$</span>Nca <span class="operator">+</span> df_gwas<span class="operator">$</span>Nco<span class="punctuation">,</span></span><br><span class="line"> pval.outcome <span class="operator">=</span> df_gwas<span class="operator">$</span>P<span class="punctuation">,</span></span><br><span class="line"> eaf.outcome <span class="operator">=</span> with<span class="punctuation">(</span>df_gwas<span class="punctuation">,</span> <span class="punctuation">(</span>FRQ_A_38691<span class="operator">*</span>Nca<span class="operator">+</span>FRQ_U_186843<span class="operator">*</span>Nco<span class="punctuation">)</span><span class="operator">/</span><span class="punctuation">(</span>Nca<span class="operator">+</span>Nco<span class="punctuation">)</span><span class="punctuation">)</span><span class="punctuation">,</span></span><br><span class="line"> effect_allele.outcome <span class="operator">=</span> df_gwas<span class="operator">$</span>A1<span class="punctuation">,</span></span><br><span class="line"> other_allele.outcome <span class="operator">=</span> df_gwas<span class="operator">$</span>A2<span class="punctuation">,</span></span><br><span class="line"> outcome <span class="operator">=</span> <span class="string">&#x27;ADHD&#x27;</span><span class="punctuation">,</span></span><br><span class="line"> id.outcome <span class="operator">=</span> <span class="string">&#x27;ADHD2022_iPSYCH_deCODE_PGC&#x27;</span> </span><br><span class="line"><span class="punctuation">)</span></span><br><span class="line">out_gwas <span class="operator">=</span> subset<span class="punctuation">(</span>out_gwas<span class="punctuation">,</span> pval.outcome <span class="operator">&gt;</span> <span class="number">5e-08</span><span class="punctuation">)</span> <span class="comment"># 排他性假设</span></span><br></pre></td></tr></table></figure>
  255. <h2 id="附加-代理SNP">附加 代理SNP</h2>
  256. <p>一部分暴露的SNPs在结局中找不到,可以找和这部分SNPs连锁不平衡的SNPs来代替。相关网站:<a target="_blank" rel="noopener" href="https://snipa.org/snipa3/">snipa</a></p>
  257. <h2 id="Harmonization">Harmonization</h2>
  258. <ul>
  259. <li>将Exposure-SNP及Outcome-SNP等位基因方向协同</li>
  260. <li>根据EAF大小,剔除不能判断方向的回文SNP</li>
  261. <li>剔除incompatible SNP</li>
  262. </ul>
  263. <figure class="highlight r"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">dat <span class="operator">&lt;-</span> TwoSampleMR<span class="operator">::</span>harmonise_data<span class="punctuation">(</span></span><br><span class="line"> exposure_dat <span class="operator">=</span> exp_gwas<span class="punctuation">,</span> </span><br><span class="line"> outcome_dat <span class="operator">=</span> out_gwas</span><br><span class="line"><span class="punctuation">)</span></span><br></pre></td></tr></table></figure>
  264. <h2 id="附加-一键报告">附加 一键报告</h2>
  265. <figure class="highlight r"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">TwoSampleMR<span class="operator">::</span>mr_report<span class="punctuation">(</span>dat<span class="punctuation">,</span> output_type <span class="operator">=</span> <span class="string">&quot;md&quot;</span><span class="punctuation">)</span></span><br></pre></td></tr></table></figure>
  266. <h2 id="MR分析">MR分析</h2>
  267. <h3 id="回归分析">回归分析</h3>
  268. <figure class="highlight r"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">TwoSampleMR<span class="operator">::</span>mr_method_list<span class="punctuation">(</span><span class="punctuation">)</span> <span class="comment"># 查看mr支持的MR分析方法</span></span><br><span class="line">mr_regression <span class="operator">=</span> TwoSampleMR<span class="operator">::</span>mr<span class="punctuation">(</span>dat<span class="punctuation">,</span> method_list <span class="operator">=</span> <span class="built_in">c</span><span class="punctuation">(</span><span class="string">&#x27;mr_ivw&#x27;</span><span class="punctuation">,</span> <span class="string">&#x27;mr_egger_regression&#x27;</span><span class="punctuation">,</span> <span class="string">&#x27;mr_weighted_median&#x27;</span><span class="punctuation">)</span><span class="punctuation">)</span></span><br><span class="line">mr_regression_or <span class="operator">=</span> TwoSampleMR<span class="operator">::</span>generate_odds_ratios<span class="punctuation">(</span>mr_res <span class="operator">=</span> mr_regression<span class="punctuation">)</span> <span class="comment"># 分类变量</span></span><br><span class="line"><span class="punctuation">&#123;</span>pdf<span class="punctuation">(</span>file <span class="operator">=</span> <span class="string">&#x27;MR.BMIvsADHD.plot.pdf&#x27;</span><span class="punctuation">,</span> width <span class="operator">=</span> <span class="number">6</span><span class="punctuation">,</span> height <span class="operator">=</span> <span class="number">6</span><span class="punctuation">)</span>; <span class="comment"># 导出 PDF 开始</span></span><br><span class="line">print<span class="punctuation">(</span>TwoSampleMR<span class="operator">::</span>mr_scatter_plot<span class="punctuation">(</span>mr_results <span class="operator">=</span> mr_regression<span class="punctuation">,</span> dat <span class="operator">=</span> dat<span class="punctuation">)</span><span class="punctuation">)</span>; <span class="comment"># 返回的是一个ggplot2对象</span></span><br><span class="line">dev.off<span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">&#125;</span> <span class="comment"># 导出 PDF 结束</span></span><br></pre></td></tr></table></figure>
  269. <p><img src="https://img.limour.top/2023/10/15/652bd26b9010d.webp" srcset="https://jscdn.limour.top/gh/Limour-dev/Sakurairo_Vision/load_svg/inload.svg" lazyload alt="mr_scatter_plot"></p>
  270. <h3 id="异质性检测">异质性检测</h3>
  271. <ul>
  272. <li>有异质性用随机效应模型<code>ivw</code>,无异质性用固定效应模型(也可以用随机效应模型,两者结果一致)</li>
  273. <li>异质性可能带来多效性,如果没有多效性,则可以说异质性没有带来多效性</li>
  274. </ul>
  275. <figure class="highlight r"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">TwoSampleMR<span class="operator">::</span>mr_heterogeneity<span class="punctuation">(</span>dat<span class="punctuation">)</span> <span class="comment"># ivw的 Q_pval &lt; 0.05 则说明有异质性</span></span><br><span class="line">heterogeneity_presso <span class="operator">=</span> TwoSampleMR<span class="operator">::</span>run_mr_presso<span class="punctuation">(</span>dat<span class="punctuation">,</span> NbDistribution <span class="operator">=</span> <span class="number">3000</span><span class="punctuation">)</span> <span class="comment"># NbDistribution越高分辨率越高,找不到离群的SNP时需要提高</span></span><br><span class="line">heterogeneity_presso<span class="punctuation">[[</span><span class="number">1</span><span class="punctuation">]</span><span class="punctuation">]</span><span class="operator">$</span>`MR-PRESSO results`<span class="operator">$</span>`Global Test`<span class="operator">$</span>Pvalue <span class="comment"># &lt; 0.05 说明有异质性</span></span><br><span class="line">heterogeneity_presso<span class="punctuation">[[</span><span class="number">1</span><span class="punctuation">]</span><span class="punctuation">]</span><span class="operator">$</span>`MR-PRESSO results`<span class="operator">$</span>`Distortion Test`<span class="operator">$</span>`Outliers Indices` <span class="comment"># 显示离群的SNP,将其剔除后重新分析</span></span><br></pre></td></tr></table></figure>
  276. <h3 id="水平多效性">水平多效性</h3>
  277. <ul>
  278. <li>P &lt; 0.05 说明不满足独立性假设,建议放弃继续做这个课题</li>
  279. <li>P &lt; 0.05 拒绝了截距为0的假设,说明SNP效应为0时依然有影响(截距存在),有其他因素在起作用</li>
  280. </ul>
  281. <figure class="highlight r"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">TwoSampleMR<span class="operator">::</span>mr_pleiotropy_test<span class="punctuation">(</span>dat<span class="punctuation">)</span></span><br></pre></td></tr></table></figure>
  282. <h3 id="敏感性分析">敏感性分析</h3>
  283. <ul>
  284. <li>Leave-one-out analysis</li>
  285. <li>所有结果都不应该存在跨过0的情况,否则说明结果不稳定,不再能说明因果关系</li>
  286. </ul>
  287. <figure class="highlight r"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">mr_loo <span class="operator">&lt;-</span> TwoSampleMR<span class="operator">::</span>mr_leaveoneout<span class="punctuation">(</span>dat<span class="punctuation">)</span></span><br><span class="line"><span class="punctuation">&#123;</span>pdf<span class="punctuation">(</span>file <span class="operator">=</span> <span class="string">&#x27;MR.BMIvsADHD.leaveoneout.plot.pdf&#x27;</span><span class="punctuation">,</span> width <span class="operator">=</span> <span class="number">6</span><span class="punctuation">,</span> height <span class="operator">=</span> <span class="number">6</span><span class="punctuation">)</span>; <span class="comment"># 导出 PDF 开始</span></span><br><span class="line">print<span class="punctuation">(</span>TwoSampleMR<span class="operator">::</span>mr_leaveoneout_plot<span class="punctuation">(</span>leaveoneout_results <span class="operator">=</span> mr_loo<span class="punctuation">)</span><span class="punctuation">)</span>; <span class="comment"># 返回的是一个ggplot2对象</span></span><br><span class="line">dev.off<span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">&#125;</span> <span class="comment"># 导出 PDF 结束</span></span><br></pre></td></tr></table></figure>
  288. <h3 id="单SNP分析">单SNP分析</h3>
  289. <ul>
  290. <li>对每个暴露-结果组合进行多次分析,每次使用不同的单 SNP 进行分析</li>
  291. </ul>
  292. <figure class="highlight r"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">mr_res_single <span class="operator">&lt;-</span> TwoSampleMR<span class="operator">::</span>mr_singlesnp<span class="punctuation">(</span>dat<span class="punctuation">)</span></span><br><span class="line">TwoSampleMR<span class="operator">::</span>mr_funnel_plot<span class="punctuation">(</span>mr_res_single<span class="punctuation">)</span></span><br><span class="line">TwoSampleMR<span class="operator">::</span>mr_forest_plot<span class="punctuation">(</span>mr_res_single<span class="punctuation">)</span></span><br></pre></td></tr></table></figure>
  293. <h3 id="方向性检测">方向性检测</h3>
  294. <figure class="highlight r"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">TwoSampleMR<span class="operator">::</span>directionality_test<span class="punctuation">(</span>dat<span class="punctuation">)</span> <span class="comment"># TRUE表示确实是暴露导致了结果</span></span><br></pre></td></tr></table></figure>
  295. <h2 id="附加-稳健回归">附加 稳健回归</h2>
  296. <figure class="highlight r"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">dat2 <span class="operator">&lt;-</span> TwoSampleMR<span class="operator">::</span>dat_to_MRInput<span class="punctuation">(</span>dat<span class="punctuation">)</span></span><br><span class="line">mr_ivw_robust <span class="operator">&lt;-</span> MendelianRandomization<span class="operator">::</span>mr_ivw<span class="punctuation">(</span>dat2<span class="punctuation">[[</span><span class="number">1</span><span class="punctuation">]</span><span class="punctuation">]</span><span class="punctuation">,</span> model<span class="operator">=</span> <span class="string">&quot;default&quot;</span><span class="punctuation">,</span> <span class="comment"># “random”指的就是随机效应模型,“fixed”指的是固定效应模型</span></span><br><span class="line"> robust <span class="operator">=</span> <span class="literal">TRUE</span><span class="punctuation">,</span> penalized <span class="operator">=</span> <span class="literal">TRUE</span><span class="punctuation">,</span>correl <span class="operator">=</span> <span class="literal">FALSE</span><span class="punctuation">,</span> <span class="comment"># 参数penalized代表下调异常值的权重</span></span><br><span class="line"> weights <span class="operator">=</span><span class="string">&quot;simple&quot;</span><span class="punctuation">,</span> psi <span class="operator">=</span> <span class="number">0</span><span class="punctuation">,</span>distribution <span class="operator">=</span> <span class="string">&quot;normal&quot;</span><span class="punctuation">,</span>alpha <span class="operator">=</span> <span class="number">0.05</span><span class="punctuation">)</span></span><br></pre></td></tr></table></figure>
  297. <h2 id="附加-绘制森林图">附加 绘制森林图</h2>
  298. <ul>
  299. <li><a href="/Forest-plot-displays-the-results-of-regression-analysis">美化森林图</a></li>
  300. </ul>
  301. <h2 id="附加-计算Power">附加 计算Power</h2>
  302. <ul>
  303. <li><a target="_blank" rel="noopener" href="https://doi.org/10.1093/ije/dyt179">Calculating statistical power in Mendelian randomization studies</a></li>
  304. <li><a target="_blank" rel="noopener" href="https://shiny.cnsgenomics.com/mRnd/">Power calculations for Mendelian Randomization</a></li>
  305. <li>Sample size: 结局总的样本量,不是暴露的样本量</li>
  306. <li>K: 结局中病例的比例,case/(case+control)</li>
  307. <li>OR: IVW的OR值,exp(beta)</li>
  308. <li>R2: MR_calc_r2_F 计算得到的所有R2的sum</li>
  309. </ul>
  310. </div>
  311. <hr/>
  312. <div>
  313. <div class="post-metas my-3">
  314. <div class="post-meta">
  315. <i class="iconfont icon-tags"></i>
  316. <a href="/tags/SNP/" class="print-no-link">#SNP</a>
  317. <a href="/tags/MR/" class="print-no-link">#MR</a>
  318. </div>
  319. </div>
  320. <div class="license-box my-3">
  321. <div class="license-title">
  322. <div>【学习】孟德尔随机化</div>
  323. <div>https://hexo.limour.top/Mendelian-Randomization</div>
  324. </div>
  325. <div class="license-meta">
  326. <div class="license-meta-item">
  327. <div>Author</div>
  328. <div>Limour</div>
  329. </div>
  330. <div class="license-meta-item license-meta-date">
  331. <div>Posted on</div>
  332. <div>October 14, 2023</div>
  333. </div>
  334. <div class="license-meta-item license-meta-date">
  335. <div>Updated on</div>
  336. <div>March 19, 2024</div>
  337. </div>
  338. <div class="license-meta-item">
  339. <div>Licensed under</div>
  340. <div>
  341. <a class="print-no-link" target="_blank" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
  342. <span class="hint--top hint--rounded" aria-label="BY - Attribution">
  343. <i class="iconfont icon-by"></i>
  344. </span>
  345. </a>
  346. <a class="print-no-link" target="_blank" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
  347. <span class="hint--top hint--rounded" aria-label="NC - Non-commercial">
  348. <i class="iconfont icon-nc"></i>
  349. </span>
  350. </a>
  351. <a class="print-no-link" target="_blank" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
  352. <span class="hint--top hint--rounded" aria-label="SA - Share-alike">
  353. <i class="iconfont icon-sa"></i>
  354. </span>
  355. </a>
  356. </div>
  357. </div>
  358. </div>
  359. <div class="license-icon iconfont"></div>
  360. </div>
  361. <div class="post-prevnext my-3">
  362. <article class="post-prev col-6">
  363. <a href="/Protocol-for-intranet-penetration-based-on-QUIC" title="【探索】基于QUIC的内网穿透协议">
  364. <i class="iconfont icon-arrowleft"></i>
  365. <span class="hidden-mobile">【探索】基于QUIC的内网穿透协议</span>
  366. <span class="visible-mobile">Previous</span>
  367. </a>
  368. </article>
  369. <article class="post-next col-6">
  370. <a href="/Aggregating-Azure-and-OpenAI-APIs-with-OneAPI" title="【记录】使用one-api聚合Azure和OpenAI的API">
  371. <span class="hidden-mobile">【记录】使用one-api聚合Azure和OpenAI的API</span>
  372. <span class="visible-mobile">Next</span>
  373. <i class="iconfont icon-arrowright"></i>
  374. </a>
  375. </article>
  376. </div>
  377. </div>
  378. <article id="comments" lazyload>
  379. <div id="waline"></div>
  380. <script type="text/javascript">
  381. Fluid.utils.loadComments('#waline', function() {
  382. Fluid.utils.createCssLink('https://cdn.staticfile.org/waline/2.15.5/waline.min.css')
  383. Fluid.utils.createScript('https://cdn.staticfile.org/waline/2.15.5/waline.min.js', function() {
  384. var options = Object.assign(
  385. {"serverURL":"https://comments.limour.top","path":"window.location.pathname","meta":["nick","mail","link"],"requiredMeta":["nick"],"lang":"zh-CN","emoji":["https://jscdn.limour.top/gh/walinejs/emojis/weibo"],"dark":"html[data-user-color-scheme=\"dark\"]","wordLimit":0,"pageSize":10},
  386. {
  387. el: '#waline',
  388. path: window.location.pathname
  389. }
  390. )
  391. Waline.init(options);
  392. Fluid.utils.waitElementVisible('#waline .vcontent', () => {
  393. var imgSelector = '#waline .vcontent img:not(.vemoji)';
  394. Fluid.plugins.imageCaption(imgSelector);
  395. Fluid.plugins.fancyBox(imgSelector);
  396. })
  397. });
  398. });
  399. </script>
  400. <noscript>Please enable JavaScript to view the comments</noscript>
  401. </article>
  402. </article>
  403. </div>
  404. </div>
  405. </div>
  406. <div class="side-col d-none d-lg-block col-lg-2">
  407. <aside class="sidebar" style="margin-left: -1rem">
  408. <div id="toc">
  409. <p class="toc-header">
  410. <i class="iconfont icon-list"></i>
  411. <span>Table of Contents</span>
  412. </p>
  413. <div class="toc-body" id="toc-body"></div>
  414. </div>
  415. </aside>
  416. </div>
  417. </div>
  418. </div>
  419. <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
  420. <i class="iconfont icon-arrowup" aria-hidden="true"></i>
  421. </a>
  422. <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
  423. aria-hidden="true">
  424. <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
  425. <div class="modal-content">
  426. <div class="modal-header text-center">
  427. <h4 class="modal-title w-100 font-weight-bold">Search</h4>
  428. <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
  429. <span aria-hidden="true">&times;</span>
  430. </button>
  431. </div>
  432. <div class="modal-body mx-3">
  433. <div class="md-form mb-5">
  434. <input type="text" id="local-search-input" class="form-control validate">
  435. <label data-error="x" data-success="v" for="local-search-input">Keyword</label>
  436. </div>
  437. <div class="list-group" id="local-search-result"></div>
  438. </div>
  439. </div>
  440. </div>
  441. </div>
  442. </main>
  443. <footer>
  444. <div class="footer-inner">
  445. <div class="footer-content">
  446. <a target="_blank" rel="nofollow noopener" href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=43130202000203"><img src="https://img.limour.top/2023/08/27/64eadeb81d6a0.webp" srcset="https://jscdn.limour.top/gh/Limour-dev/Sakurairo_Vision/load_svg/inload.svg" lazyload>湘公网安备43130202000203号 </a> <a target="_blank" rel="nofollow noopener" href="https://beian.miit.gov.cn/">湘ICP备20008299号 </a> <a target="_blank" rel="nofollow noopener" href="https://icp.gov.moe/?keyword=20210128">萌ICP备20210128号</a> <br> <a href="https://www.foreverblog.cn/" target="_blank"> <img src="https://img.foreverblog.cn/logo_en_default.png" srcset="https://jscdn.limour.top/gh/Limour-dev/Sakurairo_Vision/load_svg/inload.svg" lazyload alt="" style="width:auto;height:24px"> </a> <br> <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/limour-blog/limour-blog.github.io" target="_blank" rel="nofollow noopener"><span>SRC</span></a> <i class="iconfont icon-love"></i> <a href="https://web.archive.org/web/20231130095837/https://effectiveacceleration.tech/" target="_blank" rel="nofollow noopener"><span>e/Acc</span></a>
  447. </div>
  448. </div>
  449. </footer>
  450. <!-- Scripts -->
  451. <script src="https://jscdn.limour.top/npm/nprogress@0.2.0/nprogress.min.js" ></script>
  452. <link rel="stylesheet" href="https://jscdn.limour.top/npm/nprogress@0.2.0/nprogress.min.css" />
  453. <script>
  454. NProgress.configure({"showSpinner":false,"trickleSpeed":100})
  455. NProgress.start()
  456. window.addEventListener('load', function() {
  457. NProgress.done();
  458. })
  459. </script>
  460. <script src="https://jscdn.limour.top/npm/jquery@3.6.4/dist/jquery.min.js" ></script>
  461. <script src="https://jscdn.limour.top/npm/bootstrap@4.6.1/dist/js/bootstrap.min.js" ></script>
  462. <script src="/js/events.js" ></script>
  463. <script src="/js/plugins.js" ></script>
  464. <script src="/js/img-lazyload.js" ></script>
  465. <script>
  466. Fluid.utils.createScript('https://jscdn.limour.top/npm/tocbot@4.20.1/dist/tocbot.min.js', function() {
  467. var toc = jQuery('#toc');
  468. if (toc.length === 0 || !window.tocbot) { return; }
  469. var boardCtn = jQuery('#board-ctn');
  470. var boardTop = boardCtn.offset().top;
  471. window.tocbot.init(Object.assign({
  472. tocSelector : '#toc-body',
  473. contentSelector : '.markdown-body',
  474. linkClass : 'tocbot-link',
  475. activeLinkClass : 'tocbot-active-link',
  476. listClass : 'tocbot-list',
  477. isCollapsedClass: 'tocbot-is-collapsed',
  478. collapsibleClass: 'tocbot-is-collapsible',
  479. scrollSmooth : true,
  480. includeTitleTags: true,
  481. headingsOffset : -boardTop,
  482. }, CONFIG.toc));
  483. if (toc.find('.toc-list-item').length > 0) {
  484. toc.css('visibility', 'visible');
  485. }
  486. Fluid.events.registerRefreshCallback(function() {
  487. if ('tocbot' in window) {
  488. tocbot.refresh();
  489. var toc = jQuery('#toc');
  490. if (toc.length === 0 || !tocbot) {
  491. return;
  492. }
  493. if (toc.find('.toc-list-item').length > 0) {
  494. toc.css('visibility', 'visible');
  495. }
  496. }
  497. });
  498. });
  499. </script>
  500. <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>
  501. <script>Fluid.plugins.codeWidget();</script>
  502. <script>
  503. Fluid.utils.createScript('https://jscdn.limour.top/npm/anchor-js@4.3.1/anchor.min.js', function() {
  504. window.anchors.options = {
  505. placement: CONFIG.anchorjs.placement,
  506. visible : CONFIG.anchorjs.visible
  507. };
  508. if (CONFIG.anchorjs.icon) {
  509. window.anchors.options.icon = CONFIG.anchorjs.icon;
  510. }
  511. var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
  512. var res = [];
  513. for (var item of el) {
  514. res.push('.markdown-body > ' + item.trim());
  515. }
  516. if (CONFIG.anchorjs.placement === 'left') {
  517. window.anchors.options.class = 'anchorjs-link-left';
  518. }
  519. window.anchors.add(res.join(', '));
  520. Fluid.events.registerRefreshCallback(function() {
  521. if ('anchors' in window) {
  522. anchors.removeAll();
  523. var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
  524. var res = [];
  525. for (var item of el) {
  526. res.push('.markdown-body > ' + item.trim());
  527. }
  528. if (CONFIG.anchorjs.placement === 'left') {
  529. anchors.options.class = 'anchorjs-link-left';
  530. }
  531. anchors.add(res.join(', '));
  532. }
  533. });
  534. });
  535. </script>
  536. <script>Fluid.plugins.imageCaption();</script>
  537. <script src="/js/local-search.js" ></script>
  538. <!-- 主题的启动项,将它保持在最底部 -->
  539. <!-- the boot of the theme, keep it at the bottom -->
  540. <script src="/js/boot.js" ></script>
  541. <noscript>
  542. <div class="noscript-warning">Blog works best with JavaScript enabled</div>
  543. </noscript>
  544. <!-- hexo injector body_end start -->
  545. <script defer src="/theme-inject/timeliness.js"></script>
  546. <!-- hexo injector body_end end --></body>
  547. </html>