-
Notifications
You must be signed in to change notification settings - Fork 2
/
meta.Rmd
63 lines (48 loc) · 1.75 KB
/
meta.Rmd
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
---
title: "Tutorial 4: Meta analysis"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Tutorial 4: Meta analysis}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
eval = FALSE
)
```
```{r setup}
#library(gwasglue2)
library(ieugwasr)
devtools::load_all("../") # this was added just for development
```
Meta-analysis is a statistical combination of the results from two or more separate studies. In gwasglue2, we use the fixed-effect model which assumes that one true effect size underlies all the studies in the meta-analysis.
We are going to perform meta-analysis for two different studies of cardiac heart disease (chd), in the HMGCR (3-hydroxy-3-methylglutaryl-CoA reductase) gene region.
Firt, we choose the IEU ids for the chd trait.
```{r}
ids <- c( "ieu-a-7", "ukb-d-I9_IHD")
```
Then, we obtain the metadata using `ieugwasr::gwasinfo()` for each study and create a metadata object.
```{r}
metadata <- lapply(seq_along(ids), function(i){
m <- create_metadata(ieugwasr::gwasinfo(ids[i]))
})
```
In the <dataset> code bellow, we create an harmonised `dataset` object from the summary sets for each study.
```{r dataset, include = TRUE}
# create dataset
hmgcr_chrpos <- "5:74132993-75132993"
dataset <- lapply(seq_along(ids), function(i){
# create summarysets
s <- create_summaryset(ieugwasr::associations(variants = hmgcr_chrpos, id =ids[i]), metadata=metadata[[i]])
}) %>%
# create dataset
create_dataset(., harmonise = TRUE, tolerance = 0.08, action = 1)
```
Finally, we perform the meta-analysis in <meta> to create a new summary set
```{r meta, include = TRUE}
meta_chd <- dataset%>%
meta_analysis(.)
```