verena-zuber / demo_AMD

MIT License
30 stars 13 forks source link

Genetic correlation between metabolites #2

Closed rtabassu closed 4 years ago

rtabassu commented 4 years ago

Hi, you suggested that metabolites with high genetic correlation based on genetic instruments should be excluded. Could you suggest a method to calculate the genetic correlation based on a few selected variants? Thanks!

verena-zuber commented 4 years ago

Thanks rtabassu, the genetic correlation is simply the correlation between the genetic associations (or beta's) of the risk factors measured on the SNPs you use as instrumental variables. If your input matrix is betaX (dimension n (#SNPs) x p (#risk factors)) you can compute the correlation matrix (dimension pxp) using cor and plot using the library ggplot2 and reshape:

cor_beta = cor(betaX) dim(cor_beta) melted_cormat = melt(cor_beta)

print( ggplot(data = melted_cormat, aes(Var2, Var1, fill = value))+ geom_tile(color = "white")+ scale_fill_gradient2(low = "blue", high = "red", mid = "white", midpoint = 0, limit = c(-1,1), space = "Lab", name="Correlation \n between betas") + theme_minimal()+ theme(axis.text.x = element_text(angle = 45, vjust = 1, size = 12, hjust = 1))+ coord_fixed()+ theme( axis.title.x = element_blank(), axis.title.y = element_blank() ) )

rtabassu commented 4 years ago

Hi Verena,

Thanks for the prompt reply. Yes, I realized so and found the code in one of your scripts in github.

Best,

Rubina

Rubina Tabassum, PhD Postdoctoral Researcher Institute for Molecular Medicine Finland (FIMM) University of Helsinki, Finland

From: Verena Zuber notifications@github.com Reply-To: verena-zuber/demo_AMD reply@reply.github.com Date: Thursday, 4 June 2020 at 11:10 To: verena-zuber/demo_AMD demo_AMD@noreply.github.com Cc: "Tabassum, Rubina" rubina.tabassum@helsinki.fi, Author author@noreply.github.com Subject: Re: [verena-zuber/demo_AMD] Genetic correlation between metabolites (#2)

Thanks rtabassu, the genetic correlation is simply the correlation between the genetic associations (or beta's) of the risk factors measured on the SNPs you use as instrumental variables. If your input matrix is betaX (dimension n (#SNPs) x p (#risk factors)) you can compute the correlation matrix (dimension pxp) using cor and plot using the library ggplot2 and reshape:

cor_beta = cor(betaX) dim(cor_beta) melted_cormat = melt(cor_beta)

print( ggplot(data = melted_cormat, aes(Var2, Var1, fill = value))+ geom_tile(color = "white")+ scale_fill_gradient2(low = "blue", high = "red", mid = "white", midpoint = 0, limit = c(-1,1), space = "Lab", name="Correlation \n between betas") + theme_minimal()+ theme(axis.text.x = element_text(angle = 45, vjust = 1, size = 12, hjust = 1))+ coord_fixed()+ theme( axis.title.x = element_blank(), axis.title.y = element_blank() ) )

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/verena-zuber/demo_AMD/issues/2#issuecomment-638684409, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AP2VEGNBXPBJSIYW7BETT4LRU5JFFANCNFSM4NSLJTOA.

verena-zuber commented 4 years ago

Dear Rubina, great happy to hear this, I am closing the issue now. But please do get in touch if you have any other question or if you have any comments or feedback on the code. Hope to make this into a proper R-package soon.

Thanks for your interest, Verena