Skip to content

Instantly share code, notes, and snippets.

@explodecomputer
Created March 24, 2023 16:47
Show Gist options
  • Save explodecomputer/adc9dc586d66720b9c74757ddbd9277f to your computer and use it in GitHub Desktop.
Save explodecomputer/adc9dc586d66720b9c74757ddbd9277f to your computer and use it in GitHub Desktop.
Data for exercise
library(ieugwasr)
library(dplyr)
ukb <- tophits("ukb-d-I9_IHD")
bbj <- tophits("bbj-a-159", pop="EAS", r2=0.0011)
table(duplicated(c(ukb$rsid, bbj$rsid)))
cl <- bind_rows(ukb, bbj) %>% select(rsid, p) %>% ld_clump()
a <- associations(cl$rsid, c("bbj-a-159", "ukb-d-I9_IHD"))
table(a$rsid %in% bbj$rsid)
table(a$rsid %in% ukb$rsid)
temp <- a %>% select(rsid, position, chr, ea, nea) %>% filter(!duplicated(rsid))
temp <- inner_join(temp, a %>% filter(id == "ukb-d-I9_IHD") %>% select(rsid, ukb_beta=beta, ukb_se=se, ukb_pval=p, ukb_eaf=eaf))
temp <- inner_join(temp, a %>% filter(id == "bbj-a-159") %>% select(rsid, bbj_beta=beta, bbj_se=se, bbj_pval=p, bbj_eaf=eaf))
temp
table(temp$ukb_pval < 5e-8, temp$bbj_pval < 5e-8)
temp[sample(1:nrow(temp),10),] %>% arrange(bbj_pval) %>% write.csv(., "ex.csv")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment