-
Notifications
You must be signed in to change notification settings - Fork 0
/
mrcieu-twosamplemr.html
1310 lines (757 loc) · 49 KB
/
mrcieu-twosamplemr.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html class="theme-next gemini use-motion" lang="zh-Hans">
<head>
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">
<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />
<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />
<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />
<link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">
<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">
<link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">
<meta name="keywords" content="孟德尔随机化," />
<meta name="description" content="安装 第一次使用的时候需要安装 1234567install.packages(‘devtools’)# 安装最新版的TwoSampleMR包devtools::install_github(‘MRCIEU/TwoSampleMR’)# 安装指定版本的TwoSampleMR包devtools::install_github(‘MRCIEU/[email protected]’) 加载安装好的包">
<meta property="og:type" content="article">
<meta property="og:title" content="coding-TwoSampleMR">
<meta property="og:url" content="https://datawine.github.io/mrcieu-twosamplemr.html">
<meta property="og:site_name" content="Datawine's Blog">
<meta property="og:description" content="安装 第一次使用的时候需要安装 1234567install.packages(‘devtools’)# 安装最新版的TwoSampleMR包devtools::install_github(‘MRCIEU/TwoSampleMR’)# 安装指定版本的TwoSampleMR包devtools::install_github(‘MRCIEU/[email protected]’) 加载安装好的包">
<meta property="og:locale">
<meta property="article:published_time" content="2022-08-11T07:21:31.000Z">
<meta property="article:modified_time" content="2022-08-11T07:22:53.131Z">
<meta property="article:author" content="Datawine">
<meta property="article:tag" content="孟德尔随机化">
<meta name="twitter:card" content="summary">
<script type="text/javascript" id="hexo.configurations">
var NexT = window.NexT || {};
var CONFIG = {
root: '',
scheme: 'Gemini',
version: '5.1.4',
sidebar: {"position":"left","display":"post","offset":12,"b2t":true,"scrollpercent":true,"onmobile":false},
fancybox: true,
tabs: true,
motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
duoshuo: {
userId: '0',
author: '博主'
},
algolia: {
applicationID: '',
apiKey: '',
indexName: '',
hits: {"per_page":10},
labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
}
};
</script>
<link rel="canonical" href="https://datawine.github.io/mrcieu-twosamplemr.html"/>
<title>coding-TwoSampleMR | Datawine's Blog</title><meta name="robots" content="noindex">
<meta name="generator" content="Hexo 6.1.0"></head>
<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">
<div class="container sidebar-position-left page-post-detail">
<div class="headband"></div>
<header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
<div class="header-inner"><div class="site-brand-wrapper">
<div class="site-meta ">
<div class="custom-logo-site-title">
<a href="/" class="brand" rel="start">
<span class="logo-line-before"><i></i></span>
<span class="site-title">Datawine's Blog</span>
<span class="logo-line-after"><i></i></span>
</a>
</div>
<p class="site-subtitle"></p>
</div>
<div class="site-nav-toggle">
<button>
<span class="btn-bar"></span>
<span class="btn-bar"></span>
<span class="btn-bar"></span>
</button>
</div>
</div>
<nav class="site-nav">
<ul id="menu" class="menu">
<li class="menu-item menu-item-home">
<a href="/" rel="section">
<i class="menu-item-icon fa fa-fw fa-home"></i> <br />
首页
</a>
</li>
<li class="menu-item menu-item-tags">
<a href="/tags/" rel="section">
<i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
标签
</a>
</li>
<li class="menu-item menu-item-categories">
<a href="/categories/" rel="section">
<i class="menu-item-icon fa fa-fw fa-th"></i> <br />
分类
</a>
</li>
<li class="menu-item menu-item-archives">
<a href="/archives/" rel="section">
<i class="menu-item-icon fa fa-fw fa-question-circle"></i> <br />
归档
</a>
</li>
<li class="menu-item menu-item-sitemap">
<a href="/sitemap.xml" rel="section">
<i class="menu-item-icon fa fa-fw fa-sitemap"></i> <br />
站点地图
</a>
</li>
<li class="menu-item menu-item-search">
<a href="javascript:;" class="popup-trigger">
<i class="menu-item-icon fa fa-search fa-fw"></i> <br />
搜索
</a>
</li>
</ul>
<div class="site-search">
<div class="popup search-popup local-search-popup">
<div class="local-search-header clearfix">
<span class="search-icon">
<i class="fa fa-search"></i>
</span>
<span class="popup-btn-close">
<i class="fa fa-times-circle"></i>
</span>
<div class="local-search-input-wrapper">
<input autocomplete="off"
placeholder="搜索..." spellcheck="false"
type="text" id="local-search-input">
</div>
</div>
<div id="local-search-result"></div>
</div>
</div>
</nav>
</div>
</header>
<main id="main" class="main">
<div class="main-inner">
<div class="content-wrap">
<div id="content" class="content">
<div id="posts" class="posts-expand">
<article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
<div class="post-block">
<link itemprop="mainEntityOfPage" href="https://datawine.github.io/mrcieu-twosamplemr.html">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="">
<meta itemprop="description" content="">
<meta itemprop="image" content="/images/avatar.gif">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Datawine's Blog">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">coding-TwoSampleMR</h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建于" itemprop="dateCreated datePublished" datetime="2022-08-11T15:21:31+08:00">
2022-08-11
</time>
</span>
<span class="post-category" >
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-folder-o"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/%E5%AD%A6%E4%B9%A0/" itemprop="url" rel="index">
<span itemprop="name">学习</span>
</a>
</span>
</span>
<span class="post-comments-count">
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-comment-o"></i>
</span>
<a href="/mrcieu-twosamplemr.html#SOHUCS" itemprop="discussionUrl">
<span id="changyan_count_unit" class="post-comments-count hc-comment-count" data-xid="mrcieu-twosamplemr.html" itemprop="commentsCount"></span>
</a>
<span class="post-meta-divider">|</span>
<span class="page-pv"><i class="fa fa-file-o">本文总阅读量</i>
<span class="busuanzi-value" id="busuanzi_value_page_pv" ></span>次
</span>
<div class="post-wordcount">
<span class="post-meta-item-icon">
<i class="fa fa-file-word-o"></i>
</span>
<span class="post-meta-item-text">字数统计:</span>
<span title="字数统计">
2.1k
</span>
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-clock-o"></i>
</span>
<span class="post-meta-item-text">阅读时长 ≈</span>
<span title="阅读时长">
7
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="安装">安装</h1>
<p>第一次使用的时候需要安装</p>
<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></pre></td><td class="code"><pre><span class="line">install.packages<span class="punctuation">(</span>‘devtools’<span class="punctuation">)</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 安装最新版的TwoSampleMR包</span></span><br><span class="line">devtools<span class="operator">::</span>install_github<span class="punctuation">(</span>‘MRCIEU<span class="operator">/</span>TwoSampleMR’<span class="punctuation">)</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 安装指定版本的TwoSampleMR包</span></span><br><span class="line">devtools<span class="operator">::</span>install_github<span class="punctuation">(</span>‘MRCIEU<span class="operator">/</span>TwoSampleMR<span class="operator">@</span><span class="number">0.4</span>.26’<span class="punctuation">)</span></span><br></pre></td></tr></table></figure>
<p>加载安装好的包</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">library(TwoSampleMR)</span><br></pre></td></tr></table></figure>
<p>显示以下输出</p>
<figure class="highlight plaintext"><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 version 0.5.6 </span><br><span class="line">[>] New: Option to use non-European LD reference panels for clumping etc</span><br><span class="line">[>] Some studies temporarily quarantined to verify effect allele</span><br><span class="line">[>] See news(package='TwoSampleMR') and https://gwas.mrcieu.ac.uk for further details</span><br></pre></td></tr></table></figure>
<h1 id="读取暴露文件">读取暴露文件</h1>
<p>有两种读取暴露文件的方法</p>
<ul>
<li>使用TwoSampleMR获取MR base提供的数据</li>
<li>使用TwoSampleMR包读取本地文件</li>
</ul>
<h2 id="使用twosamplemr获取mr-base提供的数据">使用TwoSampleMR获取MR
base提供的数据</h2>
<p>因为MR base提供了很多数据,因此需要选择要使用的数据,也就是暴露的ID。
假设我们选择的暴露是BMI,它的id是<code>ieu-a-2</code></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">bmi <- extract_instruments(outcomes='ieu-a-2', access_token=NULL) # 获取暴露数据</span><br><span class="line">head(bmi) # 查看暴露数据</span><br></pre></td></tr></table></figure>
<p>以下的还不知道是什么意思</p>
<p>关于extract_instruments()的使用,有几个参数需要大家注意一下:</p>
<p>(1)第一个就是access_token这个参数,对于中国大陆地区的用户必须设置该参数为access_token=NULL,这样才能顺利获取数据,否则就需要开VPN获取谷歌授权。</p>
<p>(2)第二个是参数p1,它是用来指定暴露中SNP的p值的,它的默认值是p1=5e-8,因此只有p值小于5e-8的SNP才会提取出来。当然如果没有SNP小于5e-8的话,我们通常可以设置p1=1e-5,不过这个时候就需要认真评估弱工具变量偏倚了。</p>
<p>(3)第三个重要参数是clump以及与之相关的r2和kb,clump是一个逻辑型参数,只有clump=TRUE和clump=FALSE这两种情况。如果选择了参数值为clump=FALSE的话,那么r2和kb这两个参数就无效了,也即先不去除含有连锁不平衡的SNP。当clump=TRUE时,我们可以用r2和kb来确定去除连锁不平衡SNP的条件,具体内容我会在下期内容中进行详细讲解。默认情况下是clump=TRUE,r2=0.001和kb=10000。</p>
<h2
id="使用twosamplemr包读取本地文件">使用TwoSampleMR包读取本地文件</h2>
<p>可以看这篇<a
target="_blank" rel="noopener" href="https://mp.weixin.qq.com/s?__biz=MjM5MTIzNjI1OA==&mid=2247484572&idx=1&sn=397f6cf594d83a1aa85c8dfc4ad009a6&chksm=a6b9ed5191ce6447472eda838c7fbddb575f5215955ce52551a6dde4d0721ffd84747a351f2d&scene=21#wechat_redirect">推送</a>。
我自己就还没试过</p>
<h1 id="去除连锁不平衡ld">去除连锁不平衡(LD)</h1>
<p>我们可以选择在提取数据的时候去除连锁不平衡的IV,也可以先提取数据,再去除。效果是完全一样的。</p>
<h2 id="背景知识">背景知识</h2>
<p>在做MR研究时,我们有一步非常重要,那就是去除存在连锁不平衡的IV。连锁不平衡主要是使用两个参数r2和kb来衡量:</p>
<p>(1)r2:它是0~1之间的数据,r2=1表示两个SNP间是完全的连锁不平衡关系,r2=0则表示两个SNP间是完全连锁平衡的,也即这两个SNP的分配是完全随机的。</p>
<p>(2)kb:它其实就是指考虑连锁不平衡的区域长度。在遗传学上我们认为在染色体上距离很近的遗传位点通常是“捆绑”在一起遗传给后代的,这也就导致距离很近的位点之间的r2会很大。在TwoSampleMR包中,我们去除连锁不平衡主要考虑的也是这两个参数。</p>
<p>举个例子,如果设置r2=0.001和kb=10000,那这就表示去掉在10000kb范围内与最显著SNP的r2大于0.001的SNP;而设置成r2=0.3和kb=1000,那这表示的就是去掉在1000kb范围内与最显著SNP的r2大于0.3的SNP。</p>
<p>从上面的解读中不难看出,随着r2的变小与kb的变大,被去除的存在连锁不平衡的SNP会越来越多,而最终剩下的IV会越来越少。在我之前的推送中曾以实例和大家探讨了IV数目对结果的影响(孟德尔随机化之高密度脂蛋白胆固醇(HDL-C)与心肌梗死的因果关系),一般IV个数越少,存在的混杂和多效性也就越少,但相应的统计效力不足;而IV数目的增多虽然能提高统计效力,但也会带来更多的偏倚。因此,调节好参数r2和kb就显得是一门技术活了!</p>
<h2 id="在提取时去除ld">在提取时去除LD</h2>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">bmi <- extract_instruments(outcomes='ieu-a-2', clump=TRUE, r2=0.01, kb=5000, access_token=NULL)</span><br></pre></td></tr></table></figure>
<h2 id="先提取数据再去除ld">先提取数据,再去除LD</h2>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">bmi <- extract_instruments(outcomes='ieu-a-2', clump=FALSE, access_token=NULL)</span><br><span class="line">exp_dat <- clump_data(bmi, clump_r2=0.01, clump_kb=5000)</span><br></pre></td></tr></table></figure>
<h1 id="提取iv在结局中的信息">提取IV在结局中的信息</h1>
<p>在读取完暴露文件并去除掉存在连锁不平衡的SNP后,我们接下来要做的一件事就是提取IV在结局中的信息,完成这一步主要有两种方法:</p>
<p>(1)利用TwoSampleMR获取MR base提供的结局信息</p>
<p>(2)读取自己结局的GWAS文件并提取相关信息</p>
<p>第一种方法使用起来非常简洁高效,可以批量读取多个结局文件,但是存在的问题是有的结局数据可能有问题(真的吗);</p>
<p>第二种方法一次读取一个GWAS文件,如果批量处理的话可能会占用大量内存,得不偿失。接下来我将为大家详细介绍一下这两种方法,希望大家能明白这两种读取方法的差异。</p>
<h2
id="读取自己结局的gwas文件并提取相关信息">读取自己结局的GWAS文件并提取相关信息</h2>
<p>首先咱们先提取IV的信息并去除存在连锁不平衡的SNP,这里咱们还是以BMI作为暴露,但是ID号需要改成'ieu-a-835',这主要是因为之前ID号’ieu-a-2’的GWAS是在混合人群中做的(也即把欧洲人、非洲人等不同人群合在一起做的GWAS),而’ieu-a-835’则是在欧洲人中做的。在之前的理论学习中,我曾和大家解释过人群的混杂会带来估计结果的偏倚,因此我们需要选择遗传背景一致的人群进行MR研究(如暴露和结局的GWAS都是在欧洲人群中进行的)。</p>
<figure class="highlight plaintext"><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></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">library(TwoSampleMR)</span><br><span class="line">bmi_exp <- extract_instruments(</span><br><span class="line"> outcomes='ieu-a-835',</span><br><span class="line"> clump=TRUE, r2=0.01,</span><br><span class="line"> kb=5000,access_token = NULL</span><br><span class="line"> )</span><br><span class="line">dim(bmi_exp)</span><br><span class="line"># [1] 80 15</span><br><span class="line">t2d_out <- extract_outcome_data(</span><br><span class="line"> snps=bmi_exp$SNP,</span><br><span class="line"> outcomes='ieu-a-26',</span><br><span class="line"> proxies = FALSE,</span><br><span class="line"> maf_threshold = 0.01,</span><br><span class="line"> access_token = NULL</span><br><span class="line">)</span><br><span class="line">dim(t2d_out)</span><br></pre></td></tr></table></figure>
<p>这里我要和大家简单介绍一下extract_outcome_data()函数的关键参数:</p>
<p>snps:它是一串以rs开头的SNP ID</p>
<p>outcomes:它是outcome在MR base中的ID;</p>
<p>proxies:它表示是否使用代理SNP,默认值是TRUE,也即当一个SNP在outcome中找不到时可以使用与其存在强连锁不平衡的SNP信息来替代,我个人喜欢设置成FALSE。</p>
<p>maf_threshold:它表示的是SNP在outcome中的最小等位基因频率,默认值是0.3,不过大样本GWAS可以适当调低,我这里设置的是0.01。</p>
<p>access_token:大陆用户必须设置成access_token=NULL。</p>
<h2 id="利用twosamplemr获取mr-base提供的结局信息">利用TwoSampleMR获取MR
base提供的结局信息</h2>
<p>见<a
target="_blank" rel="noopener" href="https://mp.weixin.qq.com/s?__biz=MjM5MTIzNjI1OA==&mid=2247484596&idx=1&sn=b0176d1e98bc75ef71c0855d4de6cc6d&chksm=a6b9ed7991ce646f645199399a3046739d7830d50b570ceab932b0f0b581bcf25418417c990e&scene=21#wechat_redirect">推送</a></p>
<h1 id="计算并解读mr结果">计算并解读MR结果</h1>
<figure class="highlight plaintext"><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></pre></td><td class="code"><pre><span class="line">mydata <- harmonise_data(</span><br><span class="line"> exposure_dat=bmi_exp,</span><br><span class="line"> outcome_dat=t2d_out,</span><br><span class="line"> action= 2</span><br><span class="line"> )</span><br></pre></td></tr></table></figure>
<p>最后,咱们只要简单使用mr()函数即可,代码如下:</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">res <- mr(mydata)</span><br><span class="line">res</span><br></pre></td></tr></table></figure>
<p>除了上述5种计算方法外,TwoSampleMR包还提供了很多计算方法,比如随机效应模型和固定效应模型等,感兴趣的朋友可以通过mr_method_list()函数来了解。</p>
<h1 id="敏感性分析">敏感性分析</h1>
<p>(1)异质性检验(Heterogeneity
test):主要是检验各个IV之间的差异,如果不同IV之间的差异大,那么这些IV的异质性就大。</p>
<p>(2)多效性检验 (Pleiotropy
test):主要检验多个IV是否存在水平多效性,常用MR
Egger法的截距项表示,如果该截距项与0差异很大,说明存在水平多效性。除此以外,MR-PRESSO包也是常用的检验水平多效性的R包。</p>
<p>(3)逐个剔除检验 (Leave-one-out sensitivity
test):主要是逐个剔除IV后计算剩下IV的MR结果,如果剔除某个IV后其它IV估计出来的MR结果和总结果差异很大,说明MR结果对该IV是敏感的。</p>
<h2 id="异质性检验">异质性检验</h2>
<h2 id="多效性检验">多效性检验</h2>
<h2 id="逐个剔除检验">逐个剔除检验</h2>
<h1 id="画图">画图</h1>
<!-- flag of hidden posts -->
</div>
<footer class="post-footer">
<div class="post-tags">
<a href="/tags/%E5%AD%9F%E5%BE%B7%E5%B0%94%E9%9A%8F%E6%9C%BA%E5%8C%96/" rel="tag"># 孟德尔随机化</a>
</div>
</footer>
</div>
</article>
<div class="post-spread">
</div>
</div>
</div>
<div class="comments" id="comments">
<div id="SOHUCS"></div>
</div>
</div>
<div class="sidebar-toggle">
<div class="sidebar-toggle-line-wrap">
<span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
<span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
<span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
</div>
</div>
<aside id="sidebar" class="sidebar">
<div class="sidebar-inner">
<ul class="sidebar-nav motion-element">
<li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
文章目录
</li>
<li class="sidebar-nav-overview" data-target="site-overview-wrap">
站点概览
</li>
</ul>
<section class="site-overview-wrap sidebar-panel">
<div class="site-overview">
<div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
<p class="site-author-name" itemprop="name"></p>
<p class="site-description motion-element" itemprop="description"></p>
</div>
<nav class="site-state motion-element">
<div class="site-state-item site-state-posts">
<a href="/archives/">
<span class="site-state-item-count">29</span>
<span class="site-state-item-name">日志</span>
</a>
</div>
<div class="site-state-item site-state-categories">
<a href="/categories/index.html">
<span class="site-state-item-count">6</span>
<span class="site-state-item-name">分类</span>
</a>
</div>
<div class="site-state-item site-state-tags">
<a href="/tags/index.html">
<span class="site-state-item-count">55</span>
<span class="site-state-item-name">标签</span>
</a>
</div>
</nav>
<div class="links-of-author motion-element">
<span class="links-of-author-item">
<a href="https://github.com/datawine" target="_blank" title="GitHub">
<i class="fa fa-fw fa-globe"></i>GitHub</a>
</span>
</div>
</div>
</section>
<!--noindex-->
<section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
<div class="post-toc">
<div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%AE%89%E8%A3%85"><span class="nav-number">1.</span> <span class="nav-text">安装</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E8%AF%BB%E5%8F%96%E6%9A%B4%E9%9C%B2%E6%96%87%E4%BB%B6"><span class="nav-number">2.</span> <span class="nav-text">读取暴露文件</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%BD%BF%E7%94%A8twosamplemr%E8%8E%B7%E5%8F%96mr-base%E6%8F%90%E4%BE%9B%E7%9A%84%E6%95%B0%E6%8D%AE"><span class="nav-number">2.1.</span> <span class="nav-text">使用TwoSampleMR获取MR
base提供的数据</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%BD%BF%E7%94%A8twosamplemr%E5%8C%85%E8%AF%BB%E5%8F%96%E6%9C%AC%E5%9C%B0%E6%96%87%E4%BB%B6"><span class="nav-number">2.2.</span> <span class="nav-text">使用TwoSampleMR包读取本地文件</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%8E%BB%E9%99%A4%E8%BF%9E%E9%94%81%E4%B8%8D%E5%B9%B3%E8%A1%A1ld"><span class="nav-number">3.</span> <span class="nav-text">去除连锁不平衡(LD)</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E8%83%8C%E6%99%AF%E7%9F%A5%E8%AF%86"><span class="nav-number">3.1.</span> <span class="nav-text">背景知识</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%9C%A8%E6%8F%90%E5%8F%96%E6%97%B6%E5%8E%BB%E9%99%A4ld"><span class="nav-number">3.2.</span> <span class="nav-text">在提取时去除LD</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%85%88%E6%8F%90%E5%8F%96%E6%95%B0%E6%8D%AE%E5%86%8D%E5%8E%BB%E9%99%A4ld"><span class="nav-number">3.3.</span> <span class="nav-text">先提取数据,再去除LD</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E6%8F%90%E5%8F%96iv%E5%9C%A8%E7%BB%93%E5%B1%80%E4%B8%AD%E7%9A%84%E4%BF%A1%E6%81%AF"><span class="nav-number">4.</span> <span class="nav-text">提取IV在结局中的信息</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E8%AF%BB%E5%8F%96%E8%87%AA%E5%B7%B1%E7%BB%93%E5%B1%80%E7%9A%84gwas%E6%96%87%E4%BB%B6%E5%B9%B6%E6%8F%90%E5%8F%96%E7%9B%B8%E5%85%B3%E4%BF%A1%E6%81%AF"><span class="nav-number">4.1.</span> <span class="nav-text">读取自己结局的GWAS文件并提取相关信息</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%88%A9%E7%94%A8twosamplemr%E8%8E%B7%E5%8F%96mr-base%E6%8F%90%E4%BE%9B%E7%9A%84%E7%BB%93%E5%B1%80%E4%BF%A1%E6%81%AF"><span class="nav-number">4.2.</span> <span class="nav-text">利用TwoSampleMR获取MR
base提供的结局信息</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E8%AE%A1%E7%AE%97%E5%B9%B6%E8%A7%A3%E8%AF%BBmr%E7%BB%93%E6%9E%9C"><span class="nav-number">5.</span> <span class="nav-text">计算并解读MR结果</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E6%95%8F%E6%84%9F%E6%80%A7%E5%88%86%E6%9E%90"><span class="nav-number">6.</span> <span class="nav-text">敏感性分析</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%BC%82%E8%B4%A8%E6%80%A7%E6%A3%80%E9%AA%8C"><span class="nav-number">6.1.</span> <span class="nav-text">异质性检验</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%A4%9A%E6%95%88%E6%80%A7%E6%A3%80%E9%AA%8C"><span class="nav-number">6.2.</span> <span class="nav-text">多效性检验</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E9%80%90%E4%B8%AA%E5%89%94%E9%99%A4%E6%A3%80%E9%AA%8C"><span class="nav-number">6.3.</span> <span class="nav-text">逐个剔除检验</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E7%94%BB%E5%9B%BE"><span class="nav-number">7.</span> <span class="nav-text">画图</span></a></li></ol></div>
</div>
</section>
<!--/noindex-->
<div class="back-to-top">
<i class="fa fa-arrow-up"></i>
<span id="scrollpercent"><span>0</span>%</span>
</div>
</div>
</aside>
</div>
</main>
<footer id="footer" class="footer">
<div class="footer-inner">
<div class="copyright">© <span itemprop="copyrightYear">2024</span>
<span class="with-love">
<i class="fa fa-user"></i>
</span>
<span class="author" itemprop="copyrightHolder">Datawine</span>
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-area-chart"></i>
</span>
<span class="post-meta-item-text">Site words total count:</span>
<span title="Site words total count">32.8k</span>
</div>
<div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>
<span class="post-meta-divider">|</span>
<div class="theme-info">主题 — <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Gemini</a> v5.1.4</div>
<div class="busuanzi-count">
<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<span class="site-uv">
<i class="fa fa-user">本站访客数</i>
<span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
人次
</span>
<span class="site-pv">
<i class="fa fa-eye">本站总访问量</i>
<span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
次
</span>
</div>
</div>
</footer>
</div>
<script type="text/javascript">
if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
window.Promise = null;
}
</script>
<script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
<script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
<script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
<script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
<script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
<script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
<script type="text/javascript" src="/lib/three/three.min.js"></script>
<script type="text/javascript" src="/lib/three/three-waves.min.js"></script>
<script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/affix.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>
<script type="text/javascript">
(function(){
var appid = 'cyw3QwzdC';
var conf = 'cbf53c79ec118123e02b0e1a5676be66';
var width = window.innerWidth || document.documentElement.clientWidth;
if (width < 960) {
window.document.write('<script id="changyan_mobile_js" charset="utf-8" type="text/javascript" src="https://changyan.sohu.com/upload/mobile/wap-js/changyan_mobile.js?client_id=' + appid + '&conf=' + conf + '"><\/script>'); } else { var loadJs=function(d,a){var c=document.getElementsByTagName("head")[0]||document.head||document.documentElement;var b=document.createElement("script");b.setAttribute("type","text/javascript");b.setAttribute("charset","UTF-8");b.setAttribute("src",d);if(typeof a==="function"){if(window.attachEvent){b.onreadystatechange=function(){var e=b.readyState;if(e==="loaded"||e==="complete"){b.onreadystatechange=null;a()}}}else{b.onload=a}}c.appendChild(b)};loadJs("https://changyan.sohu.com/upload/changyan.js",function(){
window.changyan.api.config({appid:appid,conf:conf})});
}
})();
</script>
<script type="text/javascript" src="https://assets.changyan.sohu.com/upload/plugins/plugins.count.js"></script>
<script type="text/javascript">
// Popup Window;
var isfetched = false;
var isXml = true;
// Search DB path;
var search_path = "search.xml";
if (search_path.length === 0) {
search_path = "search.xml";
} else if (/json$/i.test(search_path)) {
isXml = false;
}
var path = "/" + search_path;
// monitor main search box;
var onPopupClose = function (e) {
$('.popup').hide();
$('#local-search-input').val('');
$('.search-result-list').remove();
$('#no-result').remove();
$(".local-search-pop-overlay").remove();
$('body').css('overflow', '');
}
function proceedsearch() {
$("body")
.append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
.css('overflow', 'hidden');
$('.search-popup-overlay').click(onPopupClose);
$('.popup').toggle();
var $localSearchInput = $('#local-search-input');
$localSearchInput.attr("autocapitalize", "none");
$localSearchInput.attr("autocorrect", "off");
$localSearchInput.focus();
}
// search function;
var searchFunc = function(path, search_id, content_id) {
'use strict';
// start loading animation
$("body")
.append('<div class="search-popup-overlay local-search-pop-overlay">' +
'<div id="search-loading-icon">' +
'<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
'</div>' +
'</div>')
.css('overflow', 'hidden');
$("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');
$.ajax({
url: path,
dataType: isXml ? "xml" : "json",
async: true,
success: function(res) {
// get the contents from search data
isfetched = true;
$('.popup').detach().appendTo('.header-inner');
var datas = isXml ? $("entry", res).map(function() {
return {
title: $("title", this).text(),
content: $("content",this).text(),
url: $("url" , this).text()
};
}).get() : res;
var input = document.getElementById(search_id);