View source: R/import_OpenGWAS.R
import_OpenGWAS | R Documentation |
A function which imports OpenGWAS.
import_OpenGWAS(
opengwas_id,
region,
method = "TwoSampleMR",
verbose = TRUE,
...
)
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. |
By default, method="TwoSampleMR" should work in all cases with some controls over variant filtering. If a VCF file, \insertCitelyon21;textualpQTLtools, is known to exist, one can specify method="gwasvcf" to extract a chunk of data.
A summary statistic object. With method="TwoSampleMR" the result is in TwoSampleMR outcome format.
Adapted function.
extract_outcome_data
## Not run:
options(width=200)
# 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)
od <- pQTLtools::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"))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.