Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikelove/de7099918ef3a992dcacbab97bc49879 to your computer and use it in GitHub Desktop.
Save mikelove/de7099918ef3a992dcacbab97bc49879 to your computer and use it in GitHub Desktop.
Processing data from Dan Liang Nature Neuroscience paper
snp_hg38 rsid refAllele altAllele lfcASCA lfcQTL lfcEQTL
chr2:208557023:C:G rs1036014 C G 0.679909666011761 0.2499407877 0.2194325508
chr4:9924989:T:C rs10939614 T C -2.21500762508123 -0.355952769 -0.2118339332
chr7:138187033:C:T rs17603855 C T -1.73696246880911 -0.4433277822 -0.4808215973
chr7:139495451:C:G rs2530731 C G -1.77729493517346 -0.6283644361 -0.3881908065
chr11:86515916:G:C rs2125358 G C 1.36463250810021 0.4783681025 0.4154173162
chr14:22848616:A:G rs17882077 A G -1.34268551797455 -0.2681226196 -0.2210454793
chr18:25019730:G:A rs10502466 G A 0.716207533070227 0.2821604048 0.2185292588
chr21:43270976:A:G rs2838227 A G 0.8181622133663 0.304950793 0.4107778657
library(readr)
library(dplyr)
library(tibble)
library(tidyr)
# variants are from Liang 2021
# https://pubmed.ncbi.nlm.nih.gov/34017130/
# doi: 10.1038/s41593-021-00858-w
# Dan's file are hg38
qtl <- read_csv("Supplementary Table 3-Table 1.csv") %>%
rename(snp_hg38 = SNP, chr = seqnames) %>%
select(-A1, -A2)
asca <- read.csv("Supplementary Table 6-Table 1.csv") %>%
tibble() %>%
filter(CellType == "Neuron") %>%
mutate(sameCoding = refAllele == caQTL_A1) %>% # A1 is denominator in QTL
mutate(caQTL_Beta = caQTL_Beta * ifelse(sameCoding, 1, -1)) %>%
select(rsid,
refAllele, altAllele,
lfcASCA=log2FoldChange, lfcQTL=caQTL_Beta,
fdrASCA=padj, pvalQTL=caQTL_P)
tab <- qtl %>% filter(InPeak, CellType == "Neuron") %>%
drop_na(rsid) %>%
inner_join(asca, by="rsid") %>%
filter(pvalQTL < 1e-3) %>%
filter(!duplicated(peakid))
# 68 rows...
library(ggplot2)
ggplot(tab, aes(lfcQTL, lfcASCA)) + geom_point()
eqtl <- read_csv("Supplementary Table 4-Table 1.csv") %>%
filter(Type == "NeuroncaQTLandeQTL") %>%
rename(snp_hg38 = SNP) %>%
select(-seqnames, -peakstart, -peakend, -peakid)
tab <- tab %>% inner_join(eqtl, by="snp_hg38") %>%
mutate(lfcEQTL = eBeta * ifelse(sign(lfcQTL) == sign(caBeta), 1, -1)) %>%
group_by(rsid) %>%
filter(eP == min(eP))
# 8 rows
ggplot(tab, aes(lfcQTL, lfcASCA, color=lfcEQTL)) + geom_point(size=2) +
scale_color_gradient2(low="red",mid="white",high="blue") +
geom_hline(yintercept=0) + geom_vline(xintercept=0) +
ggtitle("Neuronal caQTL + ASCA + eQTL, in own peak")
out <- tab %>% select(snp_hg38, rsid, refAllele, altAllele, lfcASCA, lfcQTL, lfcEQTL)
write.csv(out, file="Liang_2021_inpeak_caQTL_ASCA_eQTL_neurons.csv", row.names=FALSE, quote=FALSE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment