Last active
March 16, 2021 18:31
-
-
Save nievergeltlab/0b4d6307441698cfee4bcb00da09d71e to your computer and use it in GitHub Desktop.
Compare two sets of genetic correlations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(data.table) | |
d1 <- fread('rgdifferences.csv',data.table=F) | |
#772 traits, so 0.05/772 = 6.476684e-05 | |
#I like it better with all correlatios shown. I';ll grey out the NS ones! | |
d1$color <- "grey" | |
d1[which(d1$p <= 6.476684e-05 | d1$p_trauma <= 6.476684e-05),]$color <- "black" #significant in at least one | |
#How many are significant in at least one? Answer=299. 0.05/299 = 0.0001672241 | |
table(d1$color) | |
#Note to caroline - adjusting for the number of traits that were significant in at least one | |
#analysis only changes the bonferron therehsold to add two traits: Qualifications: O levels/GCSEs or equivalent. Seen a psychiatrist for nerves_ anxiety_ tension or depression | |
#imo its not worth doing that | |
#Since neuroticism is listed twice, I only report one of them for plotting, hence my count goes from 23 to 22 traits. | |
#I set the threshold to 0.00000809 to avoid this being plotted | |
#Therefore I keep on the strict threshold anyway, but what I do instead is plot the traits where | |
#Zifference is trauma - ptsd | |
d1[which(d1$p <= 6.476684e-05 & d1$p_trauma <= 6.476684e-05 & d1$Pdifference <= 0.00000809 & d1$Zdifference < 0),]$color <- "blue" | |
d1[which(d1$p <= 6.476684e-05 & d1$p_trauma <= 6.476684e-05 & d1$Pdifference <= 0.00000809 & d1$Zdifference > 0 ),]$color <- "red" | |
#Driving slowly is a trait associated with PTSD but the direction | |
pdf("rg_ptsd_v_trauma.pdf",7,7) | |
plot(d1$rg_trauma,d1$rg,col=d1$color,pch=19,cex.axis=1.45,cex.lab=1.45, xlim=c(-1,1),ylim=c(-1,1),xlab="rg LT", ylab="rg PTSD") | |
abline(0,1,lwd=2) | |
d1s <- subset(d1,color=="blue") | |
d1s2 <- subset(d1,color=="red") | |
#List only the top 10 | |
text(d1s[c(1,4,7),]$rg_trauma,d1s[c(1,4,7),]$rg, labels=d1s[c(1,4,7),]$trait, cex= 1, pos=2) | |
text(d1s[c(2,5,8),]$rg_trauma,d1s[c(2,5,8),]$rg, labels=d1s[c(2,5,8),]$trait, cex= 1, pos=3) | |
text(d1s[c(3,6,9,10),]$rg_trauma,d1s[c(3,6,9,10),]$rg, labels=d1s[c(3,6,9,10),]$trait, cex= 1, pos=4) | |
text(d1s2$rg_trauma,d1s2$rg, labels=d1s2$trait, cex= 1, pos=4) | |
dev.off() | |
#Do with MVP vs ukbb.. | |
d4 <- fread('lt_vs_mvp.csv',data.table=F) | |
d4$color <- "grey" | |
d4[which(d4$p_mvp <= 6.476684e-05 & d4$p_lt <= 6.476684e-05),]$color <- "black" #only significant in both | |
d4[which(d4$p_mvp <= 6.476684e-05 & d4$p_lt <= 6.476684e-05 & d4$pdiff <= 6.476684e-05 & d4$Zdiff > 0),]$color <- "red" | |
d4[which(d4$p_mvp <= 6.476684e-05 & d4$p_lt <= 6.476684e-05 & d4$pdiff <= 6.476684e-05& d4$Zdiff < 0 ),]$color <- "blue" | |
pdf("rg_MVPptsd_v_trauma.pdf",7,7) | |
plot(d4$rg_lt,d4$rg_mvp,col=d4$color,pch=19,cex.axis=1.25,cex.lab=1.45, xlim=c(-1,1),ylim=c(-1,1),xlab="rg LT", ylab="rg MVP PTSD") | |
abline(0,1,lwd=2) | |
d4s <- subset(d4,color=="blue") | |
d4s2 <- subset(d4,color=="red") | |
text(d4s$rg_lt,d4s$rg_mvp, labels=d4s$trait2, cex= 1, pos=2) | |
text(d4s2$rg_lt,d4s2$rg_mvp, labels=d4s2$trait2, cex= 1, pos=4) | |
dev.off() | |
#MVP and PGC PTSD have massive overlap 90% correlated | |
d2 <- fread('MVP.EUR.TOT.txt.gz_f2.premunge2.2d4b1c2c-0f1b-402b-b7dc-670725621c70.rg.results.csv',data.table=F) | |
names(d2)[2] <- "trait" | |
d3 <- merge(d4,d2,by='trait') | |
plot(d3$rg.x,d3$rg.y) | |
cor.test(d3$rg.x,d3$rg.y) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment