knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(rms2)
# library(devtools)
# load_all()

Create new rms2 class for the outcome GWAS of interest

x <- rms2$new("ukb-b-2227")

Get the GWAS hits for that dataset

x$extract_gwashits()
x$gwashits

Scan OpenGWAS for associations with the second GWAS hit

x$scan_rsid(x$gwashits$rsid[2])
x$rsid_scan

Perform colocalisation for each of the candidate associations

x$coloc_scan(x$gwashits$rsid[2])
x$coloc_result

Example of plotting a region (extracts LD matrix)

x$plot_coloc(x$gwashits$rsid[2], x$rsid_scan[[x$gwashits$rsid[2]]]$id[1])

Perform MR for all the candidate traits (though could also exclude the traits that don't colocalise)

x$mr(x$gwashits$rsid[2], exclude_rsid_region=TRUE)
x$mr_scan[[x$gwashits$rsid[2]]] %>% dplyr::select(exposure, b, se, pval)

Perform multivariable MR of candidate traits. Excluding the alternative GWAS of number of children fathered as this is synonymous with the outcome

x$mvmr(x$gwashits$rsid[2], traitlist=x$rsid_scan[[x$gwashits$rsid[2]]]$id[-5])
x$mv_dat[[x$gwashits$rsid[2]]][["result"]][[1]] %>% dplyr::select(exposure, b, se, pval)

Perform feature selection and re-estimate associations after that. It updates the result from the standard MVMR analysis

x$mvmr_lasso(x$gwashits$rsid[2])
x$mv_dat[[x$gwashits$rsid[2]]][["result"]][[1]] %>% dplyr::select(exposure, b, se, pval)

Note that this might lead to under-estimated standard errors so it should be used for estimation rather than hypothesis testing

Todo



explodecomputer/rms2 documentation built on Dec. 20, 2021, 7:39 a.m.