suppressMessages(silent <- lapply(
c("biomaRt", "tidyverse","vroom", "ggrastr", "hudson"),
character.only=T))
library, = function (..., useNA = 'always') base::table(..., useNA = useNA) table
="Veg5yr1"
p
="/Users/mike/Documents/Research/Vegetarian/regenie-GWAS/sumstats-raw/noBMI/"
dir="Interactive.GWAS"
outdir
=list()
chrfor (c in 1:22){
=vroom(paste(
chr[[c]]"/Veg5yr1_GWAS_chr",c,"_",p,".regenie", sep=""), show_col_types = FALSE,progress = FALSE)
dir,
}
=do.call(rbind,chr)
file
="/Users/mike/Documents/Research/Vegetarian/regenie-GWAS/sumstats-raw/adjBMI"
dirbmi=list()
bmifor (c in 1:22){
=vroom(paste(
bmi[[c]]"/Veg5yr1_GWAS_chr",c,"_",p,".regenie", sep=""), show_col_types = FALSE,progress = FALSE)
dirbmi,
}
=do.call(rbind,bmi)
filebmi
# interactive GWAS
$P=10^(-file$LOG10P)
file=file%>%select(-LOG10P)
filecolnames(file)=c("CHR", "POS", "SNP",
"ALLELE0","ALLELE1","A1FREQ","INFO" ,"N",
"TEST","BETA","SE","CHISQ","EXTRA","pvalue")
$Link=ifelse(file$pvalue<5e-05,
filepaste0("https://www.ncbi.nlm.nih.gov/snp/",
$SNP),
fileNA)
$Hover= ifelse(file$pvalue<5e-05,
filepaste0("SNP: ", file$SNP,
"\nPOS: ", file$CHR, ":", file$POS,
"\nAllele: ", file$ALLELE1,
"\np-value: ", formatC(file$pvalue, format = "e", digits = 3),
"\nBeta (SE): ", paste(signif(filebmi$BETA, digits = 4), "(", signif(filebmi$SE, digits = 4),")"),
"\nN: ", file$N),
NA)
$P=10^(-filebmi$LOG10P)
filebmi=filebmi%>%select(-LOG10P)
filebmicolnames(filebmi)=c("CHR", "POS", "SNP",
"ALLELE0","ALLELE1","A1FREQ","INFO" ,"N",
"TEST","BETA","SE","CHISQ","EXTRA","pvalue")
$Link=ifelse(filebmi$pvalue<5e-05,
filebmipaste0("https://www.ncbi.nlm.nih.gov/snp/",
$SNP),
filebmiNA)
$Hover= ifelse(filebmi$pvalue<5e-05,
filebmipaste0("SNP: ", filebmi$SNP,
"\nPOS: ", filebmi$CHR, ":", filebmi$POS,
"\nAllele: ", filebmi$ALLELE1,
"\np-value: ", formatC(filebmi$pvalue, format = "e", digits = 3),
"\nBeta (SE): ", paste(signif(filebmi$BETA, digits = 4), "(", signif(filebmi$SE, digits = 4),")"),
"\nN: ", filebmi$N),
NA)
igmirror(top=file, bottom=filebmi,
tline=5e-08,
bline=5e-08,
toptitle="GWAS of Vegetarianism (no BMI in model)",
bottomtitle = "GWAS of Vegetarianism (BMI adjusted)",
highlight_p = c(5e-05, 5e-05),
highlighter="green",
file=paste0(outdir, "/PlotVegGWAS.html")
)
="/Users/mike/Documents/Research/Vegetarian/regenie-GWAS/MAGMA/sumstats"
dir="/Users/mike/Documents/Research/Vegetarian/MAGMA5/sumstats/noBMI"
dirncbi="Interactive.GWAS.gene"
outdirdir.create(outdir)
#Prep gene annotation file
=as_tibble(read.table(paste0(dirncbi, "/NCBI37.3.gene.loc")))
geneloccolnames(geneloc)=c("GENE","CHR","START","STOP", "STRAND", "GENE_NAME")
=geneloc%>%filter(CHR!="X" & CHR!="Y")
geneloc$CHR=as.integer(geneloc$CHR)
geneloc=geneloc%>%select(GENE, GENE_NAME)
geneloc
=read_table(paste0(dir, "/2.geneanalysis.genes.out"))
file=read_table(paste0(dir, "/2.geneanalysis.BMI.genes.out"))
filebmi
#only use ID and name as start and stop will be different because of the +2kb and -1kb window added during analysis
=left_join(file,geneloc)
file=file%>%select(GENE_NAME, everything())
file
=left_join(filebmi,geneloc)
filebmi=filebmi%>%select(GENE_NAME, everything())
filebmi
#Set colnames to hudson format
colnames(file)=c("SNP","GENE_ID_NUMBER", "CHR", "POS",
"STOP","NSNPS","NPARAM",
"N","ZSTAT","pvalue",
"P_SNPWISE_MEAN", "P_SNPWISE_TOP1")
colnames(filebmi)=c("SNP","GENE_ID_NUMBER", "CHR", "POS",
"STOP","NSNPS","NPARAM",
"N","ZSTAT","pvalue",
"P_SNPWISE_MEAN", "P_SNPWISE_TOP1")
#Add Link col
$Link=ifelse(file$pvalue<1e-3,paste0("https://www.ncbi.nlm.nih.gov/gene/?term=", file$SNP),NA)
file$Link=ifelse(file$pvalue<1e-3,paste0("https://www.ncbi.nlm.nih.gov/gene/?term=", filebmi$SNP),NA)
filebmi
#Add Hover col
$Hover= ifelse(file$pvalue<1e-3,paste0("Gene: ", file$SNP,
file"\nStart-Stop: ", file$CHR, ":", file$POS, "-", file$STOP,
"\nNSNPS: ", file$NSNPS,
"\nNPARAM: ", file$NPARAM,
"\nP_MULTI: ", formatC(file$pvalue, format = "e", digits = 3),
"\nP_SNPWISE_MEAN: ", formatC(file$P_SNPWISE_MEAN, format = "e", digits = 3),
"\nP_SNPWISE_TOP1: ", formatC(file$P_SNPWISE_TOP1, format = "e", digits = 3),
"\nN: ", file$N), NA)
$Hover= ifelse(filebmi$pvalue<1e-3,paste0("Gene: ", filebmi$SNP,
filebmi"\nStart-Stop: ", filebmi$CHR, ":", filebmi$POS, "-", filebmi$STOP,
"\nNSNPS: ", filebmi$NSNPS,
"\nNPARAM: ", filebmi$NPARAM,
"\nP_MULTI: ", formatC(filebmi$pvalue, format = "e", digits = 3),
"\nP_SNPWISE_MEAN: ", formatC(filebmi$P_SNPWISE_MEAN, format = "e", digits = 3),
"\nP_SNPWISE_TOP1: ", formatC(filebmi$P_SNPWISE_TOP1, format = "e", digits = 3),
"\nN: ", filebmi$N) , NA)
#Run Hudson
igmirror(top=file, bottom=filebmi,
tline=2.75e-06,
bline=2.75e-06,
toptitle="GWAS of Vegetarianism (gene-level; no BMI in model)",
bottomtitle = "GWAS of Vegetarianism (gene-level; BMI adjusted)",
highlight_p = c(1e-3,1e-3),
highlighter="#2DEDDD",
file=paste0(outdir, "/PlotVegGWAS.genelevel")
)
=c("Alanine_aminotransferase_rint", "Albumin_rint", "Alkaline_phosphatase_rint",
pheno1"Apolipoprotein_A_rint", "Apolipoprotein_B_rint", "Aspartate_aminotransferase_rint" ,
"C_reactive_protein_rint", "Calcium_rint", "Cholesterol_rint", "Creatinine_rint" ,
"Cystatin_C_rint", "Direct_bilirubin_rint", "Gamma_glutamyltransferase_rint",
"HbA1c_rint", "HDL_cholesterol_rint", "IGF_1_rint" ,
"LDL_direct_rint", "Lipoprotein_A_rint",
"Phosphate_rint", "SHBG_rint", "Testosterone_rint" ,
"Total_bilirubin_rint", "Total_protein_rint", "Triglycerides_rint",
"Urate_rint", "Urea_rint", "Vitamin_D_rint", "eGFR_rint" ,
"bioavailableTest_rint", "freeTest_rint")
=paste0(pheno, ".adjBMI.1df.tsv")
phenob=paste0(pheno1, ".1df.tsv")
pheno
=c("Alanine aminotransferase", "Albumin", "Alkaline phosphatase",
phenotypenames"Apolipoprotein A", "Apolipoprotein B", "Aspartate aminotransferase" ,
"C-reactive protein", "Calcium", "Cholesterol", "Creatinine" ,
"Cystatin C", "Direct bilirubin", "Gamma glutamyltransferase",
"HbA1c", "HDL cholesterol", "IGF 1" ,
"LDL direct", "Lipoprotein A",
"Phosphate", "SHBG", "Total testosterone" ,
"Total bilirubin", "Total protein", "Triglycerides",
"Urate", "Urea", "Vitamin D", "eGFR" ,
"Bioavailable testosterone", "Free testosterone")
="/Users/mike/Documents/Research/Vegetarian/GEM5/summary/noBMI/"
dir="/Users/mike/Documents/Research/Vegetarian/GEM5/summary/adjBMI/"
dirbmi="Interactive.GWIS.variant"
outdir
for (p in 1:length(pheno)){
=vroom(paste0(dir, pheno[p]), show_col_types = FALSE,progress = FALSE)
file=vroom(paste0(dirbmi, phenob[p]), show_col_types = FALSE,progress = FALSE)
filebmi
filebmi
#Set colnames to hudson format
colnames(file)=c("SNP", "CHR", "POS",
"ALLELE0","ALLELE1","N","A1FREQ",
"N_nonveg","effect_allele_frequency_nonveg","N_veg",
"effect_allele_frequency_veg", "beta_marginal" ,
"robust_SE_beta_marginal", "beta_mainG", "beta_interaction",
"robust_SE_beta_mainG","robust_SE_beta_interaction",
"robust_Cov_main_int","robust_p_value_Marginal", "pvalue" ,
"robust_p_value_joint")
colnames(filebmi)=c("SNP", "CHR", "POS",
"ALLELE0","ALLELE1","N","A1FREQ",
"N_nonveg","effect_allele_frequency_nonveg","N_veg",
"effect_allele_frequency_veg", "beta_marginal" ,
"robust_SE_beta_marginal", "beta_mainG", "beta_interaction",
"robust_SE_beta_mainG","robust_SE_beta_interaction",
"robust_Cov_main_int","robust_p_value_Marginal", "pvalue" ,
"robust_p_value_joint")
#Add Link col
$Link=ifelse(file$pvalue<5e-05,
filepaste0("https://www.ncbi.nlm.nih.gov/snp/",
$SNP),
fileNA)
$Link=ifelse(filebmi$pvalue<5e-05,
filebmipaste0("https://www.ncbi.nlm.nih.gov/snp/",
$SNP),
filebmiNA)
#Add Hover col
$Hover= ifelse(file$pvalue<5e-05,
filepaste0("rsID: ", file$SNP,
"\nCHR:POS: ", file$CHR, ":", file$POS,
"\nEA/NEA: ", paste0(file$ALLELE1, "/", file$ALLELE0),
"\nEA freq: ", file$A1FREQ,
"\nBeta (SE) Interaction : ", paste0(signif(file$beta_interaction, digits = 3), " (", signif(file$robust_SE_beta_interaction, digits = 3),")"),
"\nP-value interaction: ", formatC(file$pvalue, format = "e", digits = 3),
"\nBeta (SE) Marginal : ", paste0(signif(file$beta_marginal, digits = 3), " (", signif(file$robust_SE_beta_marginal, digits = 3),")"),
"\nP-value marginal: ", formatC(file$robust_p_value_Marginal, format = "e", digits = 3),
"\nN: ", file$N),
NA)
$Hover= ifelse(filebmi$pvalue<5e-05,
filebmipaste0("rsID: ", filebmi$SNP,
"\nCHR:POS: ", filebmi$CHR, ":", filebmi$POS,
"\nEA/NEA: ", paste0(filebmi$ALLELE1, "/", filebmi$ALLELE0),
"\nEA freq: ", filebmi$A1FREQ,
"\nBeta (SE) Interaction : ", paste0(signif(filebmi$beta_interaction, digits = 3), " (", signif(filebmi$robust_SE_beta_interaction, digits = 3),")"),
"\nP-value interaction: ", formatC(filebmi$pvalue, format = "e", digits = 3),
"\nBeta (SE) Marginal : ", paste0(signif(filebmi$beta_marginal, digits = 3), " (", signif(filebmi$robust_SE_beta_marginal, digits = 3),")"),
"\nP-value marginal: ", formatC(filebmi$robust_p_value_Marginal, format = "e", digits = 3),
"\nN: ", filebmi$N),
NA)
#Run Hudson
igmirror(top=file, bottom=filebmi,
tline=5e-08,
bline=5e-08,
toptitle=paste(phenotypenames[p], "Interaction"),
bottomtitle = paste(phenotypenames[p], "Interaction (BMI-adjusted)"),
highlight_p = c(5e-05, 5e-05),
highlighter="#36E072",
file=paste0(outdir, "/",pheno1[p])
) }
="/Users/mike/Documents/Research/Vegetarian/MAGMA5/sumstats/noBMI"
dir="/Users/mike/Documents/Research/Vegetarian/MAGMA5/sumstats/adjBMI"
dirbmi="Interactive.GWIS.gene"
outdir
#Prep gene annotation file
=as_tibble(read.table(paste0(dir, "/NCBI37.3.gene.loc")))
geneloccolnames(geneloc)=c("GENE","CHR","START","STOP", "STRAND", "GENE_NAME")
=geneloc%>%filter(CHR!="X" & CHR!="Y")
geneloc$CHR=as.integer(geneloc$CHR)
geneloc=geneloc%>%select(GENE, GENE_NAME)
geneloc
for (p in 1:length(pheno)){
=read_table(paste0(dir, "/",pheno1[p],"/2.geneanalysis.genes.out"))
file=read_table(paste0(dirbmi, "/",pheno1[p],"/2.geneanalysis.genes.out"))
filebmi
#only use ID and name as start and stop will be different because of the +2kb and -1kb window added during analysis
=left_join(file,geneloc)
file=file%>%select(GENE_NAME, everything())
file
=left_join(filebmi,geneloc)
filebmi=filebmi%>%select(GENE_NAME, everything())
filebmi
#Set colnames to hudson format
colnames(file)=c("SNP","GENE_ID_NUMBER", "CHR", "POS",
"STOP","NSNPS","NPARAM",
"N","ZSTAT","pvalue",
"P_SNPWISE_MEAN", "P_SNPWISE_TOP1")
colnames(filebmi)=c("SNP","GENE_ID_NUMBER", "CHR", "POS",
"STOP","NSNPS","NPARAM",
"N","ZSTAT","pvalue",
"P_SNPWISE_MEAN", "P_SNPWISE_TOP1")
#Add Link col
$Link=ifelse(file$pvalue<1e-3,paste0("https://www.ncbi.nlm.nih.gov/gene/?term=", file$SNP),NA)
file$Link=ifelse(file$pvalue<1e-3,paste0("https://www.ncbi.nlm.nih.gov/gene/?term=", filebmi$SNP),NA)
filebmi
#Add Hover col
$Hover= ifelse(file$pvalue<1e-3,paste0("Gene: ", file$SNP,
file"\nStart-Stop: ", file$CHR, ":", file$POS, "-", file$STOP,
"\nNSNPS: ", file$NSNPS,
"\nNPARAM: ", file$NPARAM,
"\nP_MULTI: ", formatC(file$pvalue, format = "e", digits = 3),
"\nP_SNPWISE_MEAN: ", formatC(file$P_SNPWISE_MEAN, format = "e", digits = 3),
"\nP_SNPWISE_TOP1: ", formatC(file$P_SNPWISE_TOP1, format = "e", digits = 3),
"\nN: ", file$N), NA)
$Hover= ifelse(filebmi$pvalue<1e-3,paste0("Gene: ", filebmi$SNP,
filebmi"\nStart-Stop: ", filebmi$CHR, ":", filebmi$POS, "-", filebmi$STOP,
"\nNSNPS: ", filebmi$NSNPS,
"\nNPARAM: ", filebmi$NPARAM,
"\nP_MULTI: ", formatC(filebmi$pvalue, format = "e", digits = 3),
"\nP_SNPWISE_MEAN: ", formatC(filebmi$P_SNPWISE_MEAN, format = "e", digits = 3),
"\nP_SNPWISE_TOP1: ", formatC(filebmi$P_SNPWISE_TOP1, format = "e", digits = 3),
"\nN: ", filebmi$N) , NA)
#Run Hudson
igmirror(top=file, bottom=filebmi,
tline=2.75e-06,
bline=2.75e-06,
toptitle=paste(phenotypenames[p], "Interaction gene-level"),
bottomtitle = paste(phenotypenames[p], "Interaction (BMI-adjusted) gene-level"),
highlight_p = c(1e-3,1e-3),
highlighter="#2DEDDD",
file=paste0(outdir, "/", pheno1[p],".gene")
)
}