Contents

library(MungeSumstats)

MungeSumstats now offers high throughput query and import functionality to data from the MRC IEU Open GWAS Project.

1 Find GWAS datasets

#### Search for datasets ####
metagwas <- MungeSumstats::find_sumstats(traits = c("parkinson","alzheimer"), 
                                         min_sample_size = 1000)
head(metagwas,3)
ids <- (dplyr::arrange(metagwas, nsnp))$id  
##          id               trait group_name year    author
## 1 ieu-a-298 Alzheimer's disease     public 2013   Lambert
## 2   ieu-b-2 Alzheimer's disease     public 2019 Kunkle BW
## 3 ieu-a-297 Alzheimer's disease     public 2013   Lambert
##                                                                                                                                                                                                                                                                                                                    consortium
## 1                                                                                                                                                                                                                                                                                                                        IGAP
## 2 Alzheimer Disease Genetics Consortium (ADGC), European Alzheimer's Disease Initiative (EADI), Cohorts for Heart and Aging Research in Genomic Epidemiology Consortium (CHARGE), Genetic and Environmental Risk in AD/Defining Genetic, Polygenic and Environmental Risk for Alzheimer's Disease Consortium (GERAD/PERADES),
## 3                                                                                                                                                                                                                                                                                                                        IGAP
##                 sex population     unit     nsnp sample_size       build
## 1 Males and Females   European log odds    11633       74046 HG19/GRCh37
## 2 Males and Females   European       NA 10528610       63926 HG19/GRCh37
## 3 Males and Females   European log odds  7055882       54162 HG19/GRCh37
##   category                subcategory ontology mr priority     pmid sd
## 1  Disease Psychiatric / neurological       NA  1        1 24162737 NA
## 2   Binary Psychiatric / neurological       NA  1        0 30820047 NA
## 3  Disease Psychiatric / neurological       NA  1        2 24162737 NA
##                                                                      note ncase
## 1 Exposure only; Effect allele frequencies are missing; forward(+) strand 25580
## 2                                                                      NA 21982
## 3                Effect allele frequencies are missing; forward(+) strand 17008
##   ncontrol     N
## 1    48466 74046
## 2    41944 63926
## 3    37154 54162

2 Import full results

You can supply import_sumstats() with a list of as many OpenGWAS IDs as you want, but we’ll just give one to save time.

datasets <- MungeSumstats::import_sumstats(ids = "ieu-a-298",
                                           ref_genome = "GRCH37")

2.1 Summarise results

By default, import_sumstats results a named list where the names are the Open GWAS dataset IDs and the items are the respective paths to the formatted summary statistics.

print(datasets)
## $`ieu-a-298`
## [1] "/tmp/RtmpB9qXKP/ieu-a-298.tsv.gz"

You can easily turn this into a data.frame as well.

results_df <- data.frame(id=names(datasets), 
                         path=unlist(datasets))
print(results_df)
##                  id                             path
## ieu-a-298 ieu-a-298 /tmp/RtmpB9qXKP/ieu-a-298.tsv.gz

3 Import full results (parallel)

Optional: Speed up with multi-threaded download via axel.

datasets <- MungeSumstats::import_sumstats(ids = ids, 
                                           vcf_download = TRUE, 
                                           download_method = "axel", 
                                           nThread = max(2,future::availableCores()-2))

4 Further functionality

See the Getting started vignette for more information on how to use MungeSumstats and its functionality.

5 Session Info

utils::sessionInfo()
## R version 4.3.0 RC (2023-04-13 r84257)
## Platform: x86_64-apple-darwin20 (64-bit)
## Running under: macOS Monterey 12.6.4
## 
## Matrix products: default
## BLAS:   /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRblas.0.dylib 
## LAPACK: /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0
## 
## locale:
## [1] C/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
## 
## time zone: America/New_York
## tzcode source: internal
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] MungeSumstats_1.8.0 BiocStyle_2.28.0   
## 
## loaded via a namespace (and not attached):
##   [1] tidyselect_1.2.0                           
##   [2] dplyr_1.1.2                                
##   [3] blob_1.2.4                                 
##   [4] filelock_1.0.2                             
##   [5] R.utils_2.12.2                             
##   [6] Biostrings_2.68.0                          
##   [7] bitops_1.0-7                               
##   [8] fastmap_1.1.1                              
##   [9] RCurl_1.98-1.12                            
##  [10] BiocFileCache_2.8.0                        
##  [11] VariantAnnotation_1.46.0                   
##  [12] GenomicAlignments_1.36.0                   
##  [13] XML_3.99-0.14                              
##  [14] digest_0.6.31                              
##  [15] lifecycle_1.0.3                            
##  [16] KEGGREST_1.40.0                            
##  [17] RSQLite_2.3.1                              
##  [18] googleAuthR_2.0.1                          
##  [19] magrittr_2.0.3                             
##  [20] compiler_4.3.0                             
##  [21] rlang_1.1.1                                
##  [22] sass_0.4.6                                 
##  [23] progress_1.2.2                             
##  [24] tools_4.3.0                                
##  [25] utf8_1.2.3                                 
##  [26] yaml_2.3.7                                 
##  [27] data.table_1.14.8                          
##  [28] rtracklayer_1.60.0                         
##  [29] knitr_1.42                                 
##  [30] prettyunits_1.1.1                          
##  [31] S4Arrays_1.0.4                             
##  [32] bit_4.0.5                                  
##  [33] curl_5.0.0                                 
##  [34] DelayedArray_0.26.2                        
##  [35] xml2_1.3.4                                 
##  [36] BiocParallel_1.34.1                        
##  [37] BiocGenerics_0.46.0                        
##  [38] R.oo_1.25.0                                
##  [39] grid_4.3.0                                 
##  [40] stats4_4.3.0                               
##  [41] fansi_1.0.4                                
##  [42] biomaRt_2.56.0                             
##  [43] SummarizedExperiment_1.30.1                
##  [44] cli_3.6.1                                  
##  [45] rmarkdown_2.21                             
##  [46] crayon_1.5.2                               
##  [47] generics_0.1.3                             
##  [48] BSgenome.Hsapiens.1000genomes.hs37d5_0.99.1
##  [49] httr_1.4.6                                 
##  [50] rjson_0.2.21                               
##  [51] DBI_1.1.3                                  
##  [52] cachem_1.0.8                               
##  [53] stringr_1.5.0                              
##  [54] zlibbioc_1.46.0                            
##  [55] assertthat_0.2.1                           
##  [56] parallel_4.3.0                             
##  [57] AnnotationDbi_1.62.1                       
##  [58] BiocManager_1.30.20                        
##  [59] XVector_0.40.0                             
##  [60] restfulr_0.0.15                            
##  [61] matrixStats_0.63.0                         
##  [62] vctrs_0.6.2                                
##  [63] Matrix_1.5-4                               
##  [64] jsonlite_1.8.4                             
##  [65] bookdown_0.34                              
##  [66] IRanges_2.34.0                             
##  [67] hms_1.1.3                                  
##  [68] S4Vectors_0.38.1                           
##  [69] bit64_4.0.5                                
##  [70] GenomicFiles_1.36.0                        
##  [71] GenomicFeatures_1.52.0                     
##  [72] jquerylib_0.1.4                            
##  [73] glue_1.6.2                                 
##  [74] codetools_0.2-19                           
##  [75] stringi_1.7.12                             
##  [76] GenomeInfoDb_1.36.0                        
##  [77] BiocIO_1.10.0                              
##  [78] GenomicRanges_1.52.0                       
##  [79] tibble_3.2.1                               
##  [80] pillar_1.9.0                               
##  [81] SNPlocs.Hsapiens.dbSNP155.GRCh37_0.99.24   
##  [82] rappdirs_0.3.3                             
##  [83] htmltools_0.5.5                            
##  [84] GenomeInfoDbData_1.2.10                    
##  [85] BSgenome_1.68.0                            
##  [86] R6_2.5.1                                   
##  [87] dbplyr_2.3.2                               
##  [88] evaluate_0.21                              
##  [89] lattice_0.21-8                             
##  [90] Biobase_2.60.0                             
##  [91] R.methodsS3_1.8.2                          
##  [92] png_0.1-8                                  
##  [93] Rsamtools_2.16.0                           
##  [94] gargle_1.4.0                               
##  [95] memoise_2.0.1                              
##  [96] bslib_0.4.2                                
##  [97] xfun_0.39                                  
##  [98] fs_1.6.2                                   
##  [99] MatrixGenerics_1.12.0                      
## [100] pkgconfig_2.0.3