Skip to content

Instantly share code, notes, and snippets.

@explodecomputer
Created October 15, 2023 21:50
Show Gist options
  • Save explodecomputer/8285b2f926290d9829b7915649421a83 to your computer and use it in GitHub Desktop.
Save explodecomputer/8285b2f926290d9829b7915649421a83 to your computer and use it in GitHub Desktop.
Instrument strength of pQTLs
library(readxl)
library(dplyr)
download.file("https://www.biorxiv.org/content/biorxiv/early/2022/06/18/2022.06.17.496443/DC2/embed/media-2.xlsx?download=true", here("data", "media-2.xlsx"))
a <- read_xlsx(here("data", "media-2.xlsx"), sheet="ST6", skip=2) %>%
dplyr::select(
exposure="Assay Target",
id.exposure="Assay Target",
SNP="rsID",
beta.exposure="BETA (discovery, wrt. A1)",
se.exposure="SE (discovery)",
pval.exposure="log10(p) (discovery)",
eaf.exposure="A1FREQ (discovery)",
snpid="Variant ID (CHROM:GENPOS (hg37):A0:A1:imp:v1)",
cistrans.exposure=`cis/trans`) %>%
mutate(pval.exposure = 10^-pval.exposure) %>%
tidyr::separate(snpid, sep=":", into=c("chr.exposure","pos.exposure","other_allele.exposure", "effect_allele.exposure", "imp", "v"))
a$n <- 35571
a$F <- a$beta.exposure^2 / a$se.exposure^2
a$r2 <- a$F / (a$F + a$n-1)
write.csv(a, file="~/Downloads/pqtl_instrument_strength.csv")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment