Skip to contents

A function which imports OpenGWAS.

Usage

import_OpenGWAS(
  opengwas_id,
  region,
  method = "TwoSampleMR",
  verbose = TRUE,
  ...
)

Arguments

opengwas_id

An OpenGWAS id.

region

chr:start-end.

method

Method to extract GWAS data.

verbose

Extra information.

...

Parameters to pass to TwoSampleMR outcome extraction.

Value

A summary statistic object. With method="TwoSampleMR" the result is in TwoSampleMR outcome format.

Details

This function is derived from SCALLOP/INF work. By default, method="TwoSampleMR" should work in all cases which also has some controls over variant filtering. If a VCF file is known to exist, one can specify method="gwasvcf" to extract a chunk of data.

Note

Adapted function.

References

Lyon M, Andrews SJ, Elsworth B, Gaunt TR, Hemani G, Marcora E. The variant call format provides efficient and robust storage of GWAS summary statistics. bioRxiv 2020.05.29.115824; doi: https://doi.org/10.1101/2020.05.29.115824

Examples

if (FALSE) {
options(width=200)
library(pQTLtools)
# method="TwoSampleMR"
# GSMR data preparation for Crohn's disease in the LTA region
opengwas_id <- "ebi-a-GCST004132"
region <- "6:30539831-32542101"
n <- 2/(1/12194 + 1/28072)
require(dplyr)
od <- import_OpenGWAS(opengwas_id,region) %>%
      dplyr::distinct() %>%
      dplyr::mutate(snpid=gap::chr_pos_a1_a2(chr,pos,effect_allele.outcome,other_allele.outcome),
                    effect_allele.outcome=toupper(effect_allele.outcome),
                    other_allele.outcome=toupper(other_allele.outcome)) %>%
      dplyr::select(snpid,effect_allele.outcome,other_allele.outcome,eaf.outcome,
                    beta.outcome,se.outcome,pval.outcome,samplesize.outcome) %>%
      setNames(c("SNP","A1","A2","freq","b","se","p","N")) %>%
      dplyr::group_by(SNP) %>%
      dplyr::slice(which.min(p)) %>%
      data.frame()
od[is.na(od$N),"N"] <- n
write.table(od,quote=FALSE,row.names=FALSE)
# method="gwasvcf"
gwasvcf::set_bcftools(path=file.path(HPC_WORK,"bin","bcftools"))
# MPV ARHGEF3 region
opengwas_id <- "ebi-a-GCST004599"
region <- "3:56649749-57049749"
mpv_ARHGEF3 <- import_OpenGWAS(opengwas_id,region,method="gwasvcf")
# all immune-related
INF <- Sys.getenv("INF")
HPC_WORK <- Sys.getenv("HPC_WORK")
opengwas_ids <- scan(file.path(INF,"OpenGWAS","ieu.list"),what="")
unavail <- c("ieu-b-18","finn-a-M13_SLE","finn-a-D3_SARCOIDOSIS")
opengwas_ids <- subset(opengwas_ids,!opengwas_ids %in% unavail)
region <- "1:100-2000000"
summary_list = purrr::map(opengwas_ids[1:2], ~import_OpenGWAS(., region, method="gwasvcf"))
}