Last updated: 2021-09-09

Checks: 6 1

Knit directory: ctwas_applied/

This reproducible R Markdown analysis was created with workflowr (version 1.6.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


The R Markdown file has unstaged changes. To know which version of the R Markdown file created these results, you’ll want to first commit it to the Git repo. If you’re still working on the analysis, you can ignore this warning. When you’re finished, you can run wflow_publish to commit the R Markdown file and build the HTML.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20210726) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version 59e5f4d. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Unstaged changes:
    Modified:   analysis/ukb-d-30500_irnt_Liver.Rmd
    Modified:   analysis/ukb-d-30500_irnt_Whole_Blood.Rmd
    Modified:   analysis/ukb-d-30600_irnt_Liver.Rmd
    Modified:   analysis/ukb-d-30600_irnt_Whole_Blood.Rmd
    Modified:   analysis/ukb-d-30610_irnt_Liver.Rmd
    Modified:   analysis/ukb-d-30610_irnt_Whole_Blood.Rmd
    Modified:   analysis/ukb-d-30620_irnt_Liver.Rmd
    Modified:   analysis/ukb-d-30620_irnt_Whole_Blood.Rmd
    Modified:   analysis/ukb-d-30630_irnt_Liver.Rmd
    Modified:   analysis/ukb-d-30630_irnt_Whole_Blood.Rmd
    Modified:   analysis/ukb-d-30640_irnt_Liver.Rmd
    Modified:   analysis/ukb-d-30640_irnt_Whole_Blood.Rmd
    Modified:   analysis/ukb-d-30650_irnt_Liver.Rmd
    Modified:   analysis/ukb-d-30650_irnt_Whole_Blood.Rmd
    Modified:   analysis/ukb-d-30660_irnt_Liver.Rmd
    Modified:   analysis/ukb-d-30660_irnt_Whole_Blood.Rmd
    Modified:   analysis/ukb-d-30670_irnt_Liver.Rmd
    Modified:   analysis/ukb-d-30670_irnt_Whole_Blood.Rmd
    Modified:   analysis/ukb-d-30680_irnt_Liver.Rmd
    Modified:   analysis/ukb-d-30690_irnt_Liver.Rmd
    Modified:   analysis/ukb-d-30690_irnt_Whole_Blood.Rmd
    Modified:   analysis/ukb-d-30700_irnt_Liver.Rmd
    Modified:   analysis/ukb-d-30700_irnt_Whole_Blood.Rmd
    Modified:   analysis/ukb-d-30710_irnt_Liver.Rmd
    Modified:   analysis/ukb-d-30710_irnt_Whole_Blood.Rmd
    Modified:   analysis/ukb-d-30720_irnt_Liver.Rmd
    Modified:   analysis/ukb-d-30720_irnt_Whole_Blood.Rmd
    Modified:   analysis/ukb-d-30730_irnt_Liver.Rmd
    Modified:   analysis/ukb-d-30740_irnt_Liver.Rmd
    Modified:   analysis/ukb-d-30750_irnt_Liver.Rmd
    Modified:   analysis/ukb-d-30760_irnt_Liver.Rmd
    Modified:   analysis/ukb-d-30770_irnt_Liver.Rmd
    Modified:   analysis/ukb-d-30780_irnt_Liver.Rmd
    Modified:   analysis/ukb-d-30790_irnt_Liver.Rmd
    Modified:   analysis/ukb-d-30800_irnt_Liver.Rmd
    Modified:   analysis/ukb-d-30810_irnt_Liver.Rmd
    Modified:   analysis/ukb-d-30820_irnt_Liver.Rmd
    Modified:   analysis/ukb-d-30830_irnt_Liver.Rmd
    Modified:   analysis/ukb-d-30840_irnt_Liver.Rmd
    Modified:   analysis/ukb-d-30850_irnt_Liver.Rmd
    Modified:   analysis/ukb-d-30860_irnt_Liver.Rmd
    Modified:   analysis/ukb-d-30870_irnt_Liver.Rmd
    Modified:   analysis/ukb-d-30880_irnt_Liver.Rmd
    Modified:   analysis/ukb-d-30890_irnt_Liver.Rmd

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/ukb-d-30720_irnt_Whole_Blood.Rmd) and HTML (docs/ukb-d-30720_irnt_Whole_Blood.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd cbf7408 wesleycrouse 2021-09-08 adding enrichment to reports
html cbf7408 wesleycrouse 2021-09-08 adding enrichment to reports
Rmd 4970e3e wesleycrouse 2021-09-08 updating reports
html 4970e3e wesleycrouse 2021-09-08 updating reports
Rmd dfd2b5f wesleycrouse 2021-09-07 regenerating reports
html dfd2b5f wesleycrouse 2021-09-07 regenerating reports
Rmd 61b53b3 wesleycrouse 2021-09-06 updated PVE calculation
html 61b53b3 wesleycrouse 2021-09-06 updated PVE calculation
Rmd 837dd01 wesleycrouse 2021-09-01 adding additional fixedsigma report
Rmd d0a5417 wesleycrouse 2021-08-30 adding new reports to the index
Rmd 0922de7 wesleycrouse 2021-08-18 updating all reports with locus plots
html 0922de7 wesleycrouse 2021-08-18 updating all reports with locus plots
html 1c62980 wesleycrouse 2021-08-11 Updating reports
Rmd 5981e80 wesleycrouse 2021-08-11 Adding more reports
html 5981e80 wesleycrouse 2021-08-11 Adding more reports
Rmd 05a98b7 wesleycrouse 2021-08-07 adding additional results
html 05a98b7 wesleycrouse 2021-08-07 adding additional results
html 03e541c wesleycrouse 2021-07-29 Cleaning up report generation
Rmd 276893d wesleycrouse 2021-07-29 Updating reports
html 276893d wesleycrouse 2021-07-29 Updating reports

Overview

These are the results of a ctwas analysis of the UK Biobank trait Cystatin C (quantile) using Whole_Blood gene weights.

The GWAS was conducted by the Neale Lab, and the biomarker traits we analyzed are discussed here. Summary statistics were obtained from IEU OpenGWAS using GWAS ID: ukb-d-30720_irnt. Results were obtained from from IEU rather than Neale Lab because they are in a standardard format (GWAS VCF). Note that 3 of the 34 biomarker traits were not available from IEU and were excluded from analysis.

The weights are mashr GTEx v8 models on Whole_Blood eQTL obtained from PredictDB. We performed a full harmonization of the variants, including recovering strand ambiguous variants. This procedure is discussed in a separate document. (TO-DO: add report that describes harmonization)

LD matrices were computed from a 10% subset of Neale lab subjects. Subjects were matched using the plate and well information from genotyping. We included only biallelic variants with MAF>0.01 in the original Neale Lab GWAS. (TO-DO: add more details [number of subjects, variants, etc])

Weight QC

TO-DO: add enhanced QC reporting (total number of weights, why each variant was missing for all genes)

qclist_all <- list()

qc_files <- paste0(results_dir, "/", list.files(results_dir, pattern="exprqc.Rd"))

for (i in 1:length(qc_files)){
  load(qc_files[i])
  chr <- unlist(strsplit(rev(unlist(strsplit(qc_files[i], "_")))[1], "[.]"))[1]
  qclist_all[[chr]] <- cbind(do.call(rbind, lapply(qclist,unlist)), as.numeric(substring(chr,4)))
}

qclist_all <- data.frame(do.call(rbind, qclist_all))
colnames(qclist_all)[ncol(qclist_all)] <- "chr"

rm(qclist, wgtlist, z_gene_chr)

#number of imputed weights
nrow(qclist_all)
[1] 11095
#number of imputed weights by chromosome
table(qclist_all$chr)

   1    2    3    4    5    6    7    8    9   10   11   12   13   14   15 
1129  747  624  400  479  621  560  383  404  430  682  652  192  362  331 
  16   17   18   19   20   21   22 
 551  725  159  911  313  130  310 
#proportion of imputed weights without missing variants
mean(qclist_all$nmiss==0)
[1] 0.762776

Load ctwas results

#load ctwas results
ctwas_res <- data.table::fread(paste0(results_dir, "/", analysis_id, "_ctwas.susieIrss.txt"))

#make unique identifier for regions
ctwas_res$region_tag <- paste(ctwas_res$region_tag1, ctwas_res$region_tag2, sep="_")

#compute PVE for each gene/SNP
ctwas_res$PVE = ctwas_res$susie_pip*ctwas_res$mu2/sample_size #check PVE calculation

#separate gene and SNP results
ctwas_gene_res <- ctwas_res[ctwas_res$type == "gene", ]
ctwas_gene_res <- data.frame(ctwas_gene_res)
ctwas_snp_res <- ctwas_res[ctwas_res$type == "SNP", ]
ctwas_snp_res <- data.frame(ctwas_snp_res)

#add gene information to results
sqlite <- RSQLite::dbDriver("SQLite")
db = RSQLite::dbConnect(sqlite, paste0("/project2/compbio/predictdb/mashr_models/mashr_", weight, ".db"))
query <- function(...) RSQLite::dbGetQuery(db, ...)
gene_info <- query("select gene, genename from extra")
gene_info <- query("select gene, genename, gene_type from extra")
RSQLite::dbDisconnect(db)

ctwas_gene_res <- cbind(ctwas_gene_res, gene_info[sapply(ctwas_gene_res$id, match, gene_info$gene), c("genename", "gene_type")])

#add z score to results
load(paste0(results_dir, "/", analysis_id, "_expr_z_gene.Rd"))
ctwas_gene_res$z <- z_gene[ctwas_gene_res$id,]$z

#load(paste0(results_dir, "/", analysis_id, "_expr_z_snp.Rd")) #for new version, stored after harmonization
z_snp <- readRDS(paste0(results_dir, "/", trait_id, ".RDS")) #for old version, unharmonized

z_snp <- z_snp[z_snp$id %in% ctwas_snp_res$id,] #subset snps to those included in analysis, note some are duplicated, need to match which allele was used
ctwas_snp_res$z <- z_snp$z[match(ctwas_snp_res$id, z_snp$id)] #for duplicated snps, this arbitrarily uses the first allele
ctwas_snp_res$z_flag <- as.numeric(ctwas_snp_res$id %in% z_snp$id[duplicated(z_snp$id)]) #mark the unclear z scores, flag=1

#formatting and rounding for tables
ctwas_gene_res$z <- round(ctwas_gene_res$z,2)
ctwas_snp_res$z <- round(ctwas_snp_res$z,2)
ctwas_gene_res$susie_pip <- round(ctwas_gene_res$susie_pip,3)
ctwas_snp_res$susie_pip <- round(ctwas_snp_res$susie_pip,3)
ctwas_gene_res$mu2 <- round(ctwas_gene_res$mu2,2)
ctwas_snp_res$mu2 <- round(ctwas_snp_res$mu2,2)
ctwas_gene_res$PVE <- signif(ctwas_gene_res$PVE, 2)
ctwas_snp_res$PVE <- signif(ctwas_snp_res$PVE, 2)

#merge gene and snp results with added information
ctwas_gene_res$z_flag=NA
ctwas_snp_res$genename=NA
ctwas_snp_res$gene_type=NA

ctwas_res <- rbind(ctwas_gene_res,
                   ctwas_snp_res[,colnames(ctwas_gene_res)])

#store columns to report
report_cols <- colnames(ctwas_gene_res)[!(colnames(ctwas_gene_res) %in% c("type", "region_tag1", "region_tag2", "cs_index", "gene_type", "z_flag", "id", "chrom", "pos"))]
first_cols <- c("genename", "region_tag")
report_cols <- c(first_cols, report_cols[!(report_cols %in% first_cols)])

report_cols_snps <- c("id", report_cols[-1])

#get number of SNPs from s1 results; adjust for thin
ctwas_res_s1 <- data.table::fread(paste0(results_dir, "/", analysis_id, "_ctwas.s1.susieIrss.txt"))
n_snps <- sum(ctwas_res_s1$type=="SNP")/thin
rm(ctwas_res_s1)

Check convergence of parameters

library(ggplot2)
library(cowplot)

********************************************************
Note: As of version 1.0.0, cowplot does not change the
  default ggplot2 theme anymore. To recover the previous
  behavior, execute:
  theme_set(theme_cowplot())
********************************************************
load(paste0(results_dir, "/", analysis_id, "_ctwas.s2.susieIrssres.Rd"))
  
df <- data.frame(niter = rep(1:ncol(group_prior_rec), 2),
                 value = c(group_prior_rec[1,], group_prior_rec[2,]),
                 group = rep(c("Gene", "SNP"), each = ncol(group_prior_rec)))
df$group <- as.factor(df$group)

df$value[df$group=="SNP"] <- df$value[df$group=="SNP"]*thin #adjust parameter to account for thin argument

p_pi <- ggplot(df, aes(x=niter, y=value, group=group)) +
  geom_line(aes(color=group)) +
  geom_point(aes(color=group)) +
  xlab("Iteration") + ylab(bquote(pi)) +
  ggtitle("Prior mean") +
  theme_cowplot()

df <- data.frame(niter = rep(1:ncol(group_prior_var_rec), 2),
                 value = c(group_prior_var_rec[1,], group_prior_var_rec[2,]),
                 group = rep(c("Gene", "SNP"), each = ncol(group_prior_var_rec)))
df$group <- as.factor(df$group)
p_sigma2 <- ggplot(df, aes(x=niter, y=value, group=group)) +
  geom_line(aes(color=group)) +
  geom_point(aes(color=group)) +
  xlab("Iteration") + ylab(bquote(sigma^2)) +
  ggtitle("Prior variance") +
  theme_cowplot()

plot_grid(p_pi, p_sigma2)

Version Author Date
dfd2b5f wesleycrouse 2021-09-07
#estimated group prior
estimated_group_prior <- group_prior_rec[,ncol(group_prior_rec)]
names(estimated_group_prior) <- c("gene", "snp")
estimated_group_prior["snp"] <- estimated_group_prior["snp"]*thin #adjust parameter to account for thin argument
print(estimated_group_prior)
        gene          snp 
0.0113419558 0.0002237702 
#estimated group prior variance
estimated_group_prior_var <- group_prior_var_rec[,ncol(group_prior_var_rec)]
names(estimated_group_prior_var) <- c("gene", "snp")
print(estimated_group_prior_var)
    gene      snp 
16.02701 19.13712 
#report sample size
print(sample_size)
[1] 344264
#report group size
group_size <- c(nrow(ctwas_gene_res), n_snps)
print(group_size)
[1]   11095 8697330
#estimated group PVE
estimated_group_pve <- estimated_group_prior_var*estimated_group_prior*group_size/sample_size #check PVE calculation
names(estimated_group_pve) <- c("gene", "snp")
print(estimated_group_pve)
      gene        snp 
0.00585836 0.10818652 
#compare sum(PIP*mu2/sample_size) with above PVE calculation
c(sum(ctwas_gene_res$PVE),sum(ctwas_snp_res$PVE))
[1] 0.02292221 1.45616039

Genes with highest PIPs

#distribution of PIPs
hist(ctwas_gene_res$susie_pip, xlim=c(0,1), main="Distribution of Gene PIPs")

Version Author Date
dfd2b5f wesleycrouse 2021-09-07
#genes with PIP>0.8 or 20 highest PIPs
head(ctwas_gene_res[order(-ctwas_gene_res$susie_pip),report_cols], max(sum(ctwas_gene_res$susie_pip>0.8), 20))
      genename region_tag susie_pip   mu2     PVE     z
982     CDC14A       1_61     0.993 59.02 1.7e-04 -7.83
9813      MUC1       1_77     0.992 73.30 2.1e-04 -9.76
3338     DCAF4      14_34     0.992 58.38 1.7e-04  7.95
1445     MMP11       22_6     0.989 26.13 7.5e-05  4.82
6206    ZNF827       4_95     0.979 32.53 9.3e-05 -5.26
6729       CDA       1_14     0.973 24.23 6.8e-05  4.77
380      RAI14       5_23     0.973 25.61 7.2e-05  4.86
10816     MBD5       2_88     0.972 65.88 1.9e-04  8.51
6010     PTGES       9_67     0.969 25.73 7.2e-05  4.48
6446     CXXC1      18_28     0.955 24.04 6.7e-05 -4.62
6598      NRG1       8_31     0.954 44.15 1.2e-04 -5.09
8999    LPCAT4      15_10     0.953 23.50 6.5e-05 -4.77
3750      MEA1       6_33     0.941 25.36 6.9e-05  5.66
6986     LSM12      17_26     0.919 20.56 5.5e-05 -4.00
5012    TRIM29      11_72     0.893 25.19 6.5e-05  4.83
5558    ZNF697       1_73     0.885 26.03 6.7e-05  5.33
3979      VIL1      2_129     0.864 94.23 2.4e-04  9.95
11105     MEG3      14_52     0.836 33.60 8.2e-05  6.33
10110 C15orf52      15_14     0.811 22.43 5.3e-05  4.68
4915     TEX10       9_50     0.786 22.32 5.1e-05  4.22

Genes with largest effect sizes

#plot PIP vs effect size
plot(ctwas_gene_res$susie_pip, ctwas_gene_res$mu2, xlab="PIP", ylab="mu^2", main="Gene PIPs vs Effect Size")

Version Author Date
dfd2b5f wesleycrouse 2021-09-07
#genes with 20 largest effect sizes
head(ctwas_gene_res[order(-ctwas_gene_res$mu2),report_cols],20)
      genename region_tag susie_pip      mu2     PVE      z
4687    TMEM60       7_49     0.000 19035.32 0.0e+00 -11.57
1732      CST3      20_17     0.000 19019.98 0.0e+00 142.78
4733      AHI1       6_89     0.000  6890.72 0.0e+00  -3.41
168      SPRTN      1_118     0.000  6846.48 7.7e-06   3.61
3138     EXOC8      1_118     0.000  4922.91 1.2e-08   3.29
11094     APTR       7_49     0.000  3561.07 0.0e+00  -2.79
417       MAP4       3_34     0.000  2313.10 6.0e-07   2.66
98       PHTF2       7_49     0.000  2119.66 0.0e+00  -1.05
3140     TSNAX      1_118     0.000   960.31 0.0e+00   2.70
7365    ZNF589       3_34     0.001   843.67 3.4e-06  -5.58
2818   SLC12A7        5_2     0.000   733.57 2.0e-09   1.78
11334   SPINK8       3_34     0.003   718.47 5.3e-06  -5.74
7363    CDC25A       3_34     0.001   706.17 2.7e-06  -5.43
3838      GZF1      20_17     0.000   643.44 0.0e+00 -13.59
7145     DISC1      1_118     0.000   582.22 0.0e+00  -2.64
271     SLC7A9      19_23     0.000   359.86 7.8e-09  -9.90
3990    PTPN12       7_49     0.000   214.68 0.0e+00  -1.88
3839      NAPB      20_17     0.000   200.74 0.0e+00 -15.40
7366    PLXNB1       3_34     0.136   186.15 7.4e-05   6.40
7367    CCDC51       3_34     0.167   183.91 8.9e-05   6.44

Genes with highest PVE

#genes with 20 highest pve
head(ctwas_gene_res[order(-ctwas_gene_res$PVE),report_cols],20)
      genename region_tag susie_pip    mu2     PVE      z
3979      VIL1      2_129     0.864  94.23 2.4e-04   9.95
9813      MUC1       1_77     0.992  73.30 2.1e-04  -9.76
10816     MBD5       2_88     0.972  65.88 1.9e-04   8.51
982     CDC14A       1_61     0.993  59.02 1.7e-04  -7.83
3338     DCAF4      14_34     0.992  58.38 1.7e-04   7.95
6598      NRG1       8_31     0.954  44.15 1.2e-04  -5.09
7091      NEXN       1_48     0.767  47.62 1.1e-04   8.14
5657      ACP1        2_1     0.355  99.40 1.0e-04 -10.52
6206    ZNF827       4_95     0.979  32.53 9.3e-05  -5.26
7367    CCDC51       3_34     0.167 183.91 8.9e-05   6.44
11380     TMA7       3_34     0.167 183.91 8.9e-05   6.44
11105     MEG3      14_52     0.836  33.60 8.2e-05   6.33
10392     SND1       7_79     0.344  78.10 7.8e-05   9.19
2872    COL7A1       3_34     0.525  50.47 7.7e-05  -5.36
10739  METTL10      10_78     0.498  51.95 7.5e-05  -9.13
1445     MMP11       22_6     0.989  26.13 7.5e-05   4.82
7366    PLXNB1       3_34     0.136 186.15 7.4e-05   6.40
380      RAI14       5_23     0.973  25.61 7.2e-05   4.86
6010     PTGES       9_67     0.969  25.73 7.2e-05   4.48
4564     PSRC1       1_67     0.768  31.98 7.1e-05   5.71

Genes with largest z scores

#genes with 20 largest z scores
head(ctwas_gene_res[order(-abs(ctwas_gene_res$z)),report_cols],20)
          genename region_tag susie_pip      mu2     PVE      z
1732          CST3      20_17     0.000 19019.98 0.0e+00 142.78
3837          CD93      20_16     0.000   183.61 0.0e+00  20.22
8173         LMAN2      5_106     0.011   152.51 4.8e-06  16.22
3839          NAPB      20_17     0.000   200.74 0.0e+00 -15.40
3838          GZF1      20_17     0.000   643.44 0.0e+00 -13.59
5875         CRIP3       6_33     0.004   143.26 1.8e-06 -13.58
4046          IRF5       7_79     0.000   127.01 1.6e-09  13.27
7712            C2       6_26     0.000   118.10 1.4e-11  12.31
10808         NEU1       6_26     0.000   116.94 9.3e-12 -12.28
10825         APOM       6_26     0.000   114.94 1.0e-11 -12.25
11652          C4A       6_26     0.000   112.91 7.4e-13 -12.23
11047        CLIC1       6_26     0.000   113.20 4.7e-12 -12.18
11218          C4B       6_26     0.000   104.80 1.4e-13  11.79
4687        TMEM60       7_49     0.000 19035.32 0.0e+00 -11.57
11346 RP4-737E23.2      20_16     0.000   116.81 0.0e+00 -11.40
2611         ALDH2      12_67     0.020   126.81 7.5e-06 -11.33
11891  RP3-473L9.4      12_67     0.006   151.75 2.8e-06 -11.25
8691       MAP3K11      11_36     0.001   113.23 4.8e-07  11.00
1210      MAPKAPK5      12_67     0.017   100.02 5.0e-06  10.55
1227         ERP29      12_67     0.017    99.70 4.9e-06  10.54

Comparing z scores and PIPs

#set nominal signifiance threshold for z scores
alpha <- 0.05

#bonferroni adjusted threshold for z scores
sig_thresh <- qnorm(1-(alpha/nrow(ctwas_gene_res)/2), lower=T)

#Q-Q plot for z scores
obs_z <- ctwas_gene_res$z[order(ctwas_gene_res$z)]
exp_z <- qnorm((1:nrow(ctwas_gene_res))/nrow(ctwas_gene_res))

plot(exp_z, obs_z, xlab="Expected z", ylab="Observed z", main="Gene z score Q-Q plot")
abline(a=0,b=1)

Version Author Date
dfd2b5f wesleycrouse 2021-09-07
#plot z score vs PIP
plot(abs(ctwas_gene_res$z), ctwas_gene_res$susie_pip, xlab="abs(z)", ylab="PIP")
abline(v=sig_thresh, col="red", lty=2)

Version Author Date
dfd2b5f wesleycrouse 2021-09-07
#proportion of significant z scores
mean(abs(ctwas_gene_res$z) > sig_thresh)
[1] 0.03262731
#genes with most significant z scores
head(ctwas_gene_res[order(-abs(ctwas_gene_res$z)),report_cols],20)
          genename region_tag susie_pip      mu2     PVE      z
1732          CST3      20_17     0.000 19019.98 0.0e+00 142.78
3837          CD93      20_16     0.000   183.61 0.0e+00  20.22
8173         LMAN2      5_106     0.011   152.51 4.8e-06  16.22
3839          NAPB      20_17     0.000   200.74 0.0e+00 -15.40
3838          GZF1      20_17     0.000   643.44 0.0e+00 -13.59
5875         CRIP3       6_33     0.004   143.26 1.8e-06 -13.58
4046          IRF5       7_79     0.000   127.01 1.6e-09  13.27
7712            C2       6_26     0.000   118.10 1.4e-11  12.31
10808         NEU1       6_26     0.000   116.94 9.3e-12 -12.28
10825         APOM       6_26     0.000   114.94 1.0e-11 -12.25
11652          C4A       6_26     0.000   112.91 7.4e-13 -12.23
11047        CLIC1       6_26     0.000   113.20 4.7e-12 -12.18
11218          C4B       6_26     0.000   104.80 1.4e-13  11.79
4687        TMEM60       7_49     0.000 19035.32 0.0e+00 -11.57
11346 RP4-737E23.2      20_16     0.000   116.81 0.0e+00 -11.40
2611         ALDH2      12_67     0.020   126.81 7.5e-06 -11.33
11891  RP3-473L9.4      12_67     0.006   151.75 2.8e-06 -11.25
8691       MAP3K11      11_36     0.001   113.23 4.8e-07  11.00
1210      MAPKAPK5      12_67     0.017   100.02 5.0e-06  10.55
1227         ERP29      12_67     0.017    99.70 4.9e-06  10.54

Locus plots for genes and SNPs

ctwas_gene_res_sortz <- ctwas_gene_res[order(-abs(ctwas_gene_res$z)),]

n_plots <- 5
for (region_tag_plot in head(unique(ctwas_gene_res_sortz$region_tag), n_plots)){
  ctwas_res_region <-  ctwas_res[ctwas_res$region_tag==region_tag_plot,]
  start <- min(ctwas_res_region$pos)
  end <- max(ctwas_res_region$pos)
  
  ctwas_res_region <- ctwas_res_region[order(ctwas_res_region$pos),]
  ctwas_res_region_gene <- ctwas_res_region[ctwas_res_region$type=="gene",]
  ctwas_res_region_snp <- ctwas_res_region[ctwas_res_region$type=="SNP",]
  
  #region name
  print(paste0("Region: ", region_tag_plot))
  
  #table of genes in region
  print(ctwas_res_region_gene[,report_cols])
  
  par(mfrow=c(4,1))
  
  #gene z scores
  plot(ctwas_res_region_gene$pos, abs(ctwas_res_region_gene$z), xlab="Position", ylab="abs(gene_z)", xlim=c(start,end),
   ylim=c(0,max(sig_thresh, abs(ctwas_res_region_gene$z))),
   main=paste0("Region: ", region_tag_plot))
  abline(h=sig_thresh,col="red",lty=2)
  
  #significance threshold for SNPs
  alpha_snp <- 5*10^(-8)
  sig_thresh_snp <- qnorm(1-alpha_snp/2, lower=T)
  
  #snp z scores
  plot(ctwas_res_region_snp$pos, abs(ctwas_res_region_snp$z), xlab="Position", ylab="abs(snp_z)",xlim=c(start,end),
   ylim=c(0,max(sig_thresh_snp, max(abs(ctwas_res_region_snp$z)))))
  abline(h=sig_thresh_snp,col="purple",lty=2)
  
  #gene pips
  plot(ctwas_res_region_gene$pos, ctwas_res_region_gene$susie_pip, xlab="Position", ylab="Gene PIP", xlim=c(start,end), ylim=c(0,1))
  abline(h=0.8,col="blue",lty=2)
  
  #snp pips
  plot(ctwas_res_region_snp$pos, ctwas_res_region_snp$susie_pip, xlab="Position", ylab="SNP PIP", xlim=c(start,end), ylim=c(0,1))
  abline(h=0.8,col="blue",lty=2)
}
[1] "Region: 20_17"
     genename region_tag susie_pip      mu2 PVE      z
4423     NXT1      20_17         0    25.62   0  -0.27
3838     GZF1      20_17         0   643.44   0 -13.59
3839     NAPB      20_17         0   200.74   0 -15.40
1732     CST3      20_17         0 19019.98   0 142.78

Version Author Date
dfd2b5f wesleycrouse 2021-09-07
[1] "Region: 20_16"
          genename region_tag susie_pip    mu2 PVE      z
3837          CD93      20_16         0 183.61   0  20.22
11346 RP4-737E23.2      20_16         0 116.81   0 -11.40

Version Author Date
dfd2b5f wesleycrouse 2021-09-07
[1] "Region: 5_106"
      genename region_tag susie_pip    mu2     PVE     z
3537  KIAA1191      5_106     0.006   6.77 1.1e-07 -0.84
8898      CLTB      5_106     0.005   4.72 6.6e-08  0.06
8282     SIMC1      5_106     0.007   7.72 1.5e-07  0.93
420      NOP16      5_106     0.005   5.83 9.0e-08  0.62
848      CDHR2      5_106     0.005   5.01 7.2e-08  0.19
5864     RNF44      5_106     0.014  14.62 6.2e-07 -1.53
8185    GPRIN1      5_106     0.006   6.47 1.1e-07  0.51
419    TSPAN17      5_106     0.007   7.62 1.5e-07  0.54
6932       HK3      5_106     0.005   5.84 9.1e-08 -0.37
1153     UIMC1      5_106     0.026  16.67 1.3e-06 -1.55
6929     FGFR4      5_106     0.008  23.98 5.3e-07 -4.88
7613      NSD1      5_106     0.085  20.07 5.0e-06 -4.09
8175     RAB24      5_106     0.036  25.55 2.7e-06 -5.38
8176   PRELID1      5_106     0.027  16.68 1.3e-06  3.09
11015     MXD3      5_106     0.025  13.90 1.0e-06 -1.43
8173     LMAN2      5_106     0.011 152.51 4.8e-06 16.22
4277      PRR7      5_106     0.005   7.80 1.1e-07  2.42
10351   PDLIM7      5_106     0.016  26.05 1.2e-06 -4.41
9581     DDX41      5_106     0.005   6.72 9.4e-08  1.83
5866      DOK3      5_106     0.009   8.86 2.2e-07 -0.22
5861   FAM193B      5_106     0.014  18.16 7.5e-07  2.67
9732     TMED9      5_106     0.005   5.70 8.9e-08  0.37
313    B4GALT7      5_106     0.006   7.59 1.4e-07  1.16
8280   FAM153A      5_106     0.005   5.02 7.0e-08  0.76

Version Author Date
dfd2b5f wesleycrouse 2021-09-07
[1] "Region: 6_33"
         genename region_tag susie_pip    mu2     PVE      z
12013 RP11-7K24.3       6_33     0.008  15.61 3.5e-07  -1.68
4979         TAF8       6_33     0.004   8.34 9.0e-08  -0.90
2754       GUCA1B       6_33     0.003   5.32 4.1e-08   0.53
425        MRPS10       6_33     0.010  16.08 4.7e-07   1.56
3722       TRERF1       6_33     0.003   7.79 7.9e-08   0.82
293          UBR2       6_33     0.003   5.29 4.0e-08   1.17
2755        PRPH2       6_33     0.242  41.14 2.9e-05   5.25
3743         TBCC       6_33     0.004   8.10 8.3e-08   0.74
2756     GLTSCR1L       6_33     0.004  10.34 1.3e-07  -2.05
11174    C6orf226       6_33     0.003   6.66 4.9e-08   1.69
4947        CNPY3       6_33     0.233  45.95 3.1e-05  -4.72
3732         PEX6       6_33     0.018  22.85 1.2e-06  -3.43
3748         GNMT       6_33     0.008  18.34 4.4e-07   3.43
2757      PPP2R5D       6_33     0.003  10.48 8.1e-08   2.56
3727        RRP36       6_33     0.003   6.15 5.4e-08  -0.08
3750         MEA1       6_33     0.941  25.36 6.9e-05   5.66
3747       KLHDC3       6_33     0.013  20.35 7.8e-07   1.75
406          CUL7       6_33     0.009  16.52 4.3e-07   1.42
2758        MRPL2       6_33     0.006  15.84 2.6e-07   2.72
2759         PTK7       6_33     0.012  19.56 6.7e-07   1.84
2760         CUL9       6_33     0.009  22.35 5.7e-07  -2.44
2761        DNPH1       6_33     0.003  16.24 1.5e-07  -2.04
5875        CRIP3       6_33     0.004 143.26 1.8e-06 -13.58
8462       ZNF318       6_33     0.047  31.15 4.2e-06  -2.52
3731       ABCC10       6_33     0.620  30.76 5.5e-05  -1.49
8460         DLK2       6_33     0.004  13.41 1.4e-07   3.39
4957        TJAP1       6_33     0.004  11.41 1.2e-07  -1.06
4953        YIPF3       6_33     0.012  21.50 7.4e-07   2.73
3730         XPO5       6_33     0.012  31.37 1.1e-06   5.19
8370         POLH       6_33     0.006  15.68 2.9e-07  -1.79
8581       GTPBP2       6_33     0.006  14.17 2.6e-07   0.78
3745     MAD2L1BP       6_33     0.003   7.87 7.0e-08  -1.41
8579        RSPH9       6_33     0.012  43.16 1.5e-06   6.28
1381      MRPS18A       6_33     0.024  22.86 1.6e-06   1.58
2768        VEGFA       6_33     0.005  11.88 1.6e-07   2.03

Version Author Date
dfd2b5f wesleycrouse 2021-09-07
[1] "Region: 7_79"
            genename region_tag susie_pip    mu2     PVE     z
32              ARF5       7_79     0.001  56.94 1.0e-07 -4.07
10392           SND1       7_79     0.344  78.10 7.8e-05  9.19
12576       SND1-IT1       7_79     0.000  36.73 4.4e-10  5.99
4042           LRRC4       7_79     0.000  38.28 2.3e-08  2.35
8822             LEP       7_79     0.000   5.16 6.8e-11 -0.79
2198           RBM28       7_79     0.000  15.62 5.0e-10 -2.11
11230          PRRT4       7_79     0.000   5.93 7.4e-11  1.04
2200          IMPDH1       7_79     0.000   5.98 8.7e-11  0.00
4689          HILPDA       7_79     0.001  55.92 1.5e-07  3.48
7538         METTL2B       7_79     0.002  64.10 3.1e-07  4.04
12375   RP11-212P7.2       7_79     0.000  10.11 2.5e-10 -0.52
12227 RP11-274B21.10       7_79     0.000   4.88 6.0e-11  0.83
10893        FAM71F2       7_79     0.000   4.83 5.8e-11 -0.69
12222  RP11-274B21.9       7_79     0.000  18.72 1.1e-09  1.39
4043            CALU       7_79     0.000   5.91 7.1e-11  1.60
4048          OPN1SW       7_79     0.000  34.02 7.6e-09 -2.88
4044         CCDC136       7_79     0.000   4.95 5.9e-11  0.07
4041            FLNC       7_79     0.000   9.55 2.1e-10  0.51
4036         ATP6V1F       7_79     0.000  11.59 2.3e-10 -1.98
12341  RP11-309L24.4       7_79     0.000   9.14 1.5e-10  1.65
4692             KCP       7_79     0.000   5.23 6.3e-11  0.05
4046            IRF5       7_79     0.000 127.01 1.6e-09 13.27
594            TNPO3       7_79     0.000  64.53 9.6e-09 -7.62
6693         TSPAN33       7_79     0.000   8.94 1.3e-10  2.42
6694          AHCYL2       7_79     0.000   8.38 1.5e-10 -1.08
11542          SMKR1       7_79     0.000  11.09 2.9e-10  1.31
2211            NRF1       7_79     0.000  13.04 6.5e-10 -2.19
12379  RP11-448A19.1       7_79     0.000   9.10 5.2e-10 -2.00
9944           UBE2H       7_79     0.048  23.45 3.3e-06 -4.42
1300          ZC3HC1       7_79     0.028  34.36 2.8e-06  5.04
4047         KLHDC10       7_79     0.005  59.93 9.5e-07 -4.84
2215            MEST       7_79     0.000   5.31 6.8e-11 -0.45
6703            CPA5       7_79     0.000  15.03 5.3e-10 -1.29
1299            CPA1       7_79     0.000  20.24 1.3e-09 -2.06
6710           COPG2       7_79     0.000   6.77 1.0e-10 -0.60
12104          KLF14       7_79     0.000   5.24 6.8e-11  0.55

Version Author Date
dfd2b5f wesleycrouse 2021-09-07

SNPs with highest PIPs

#snps with PIP>0.8 or 20 highest PIPs
head(ctwas_snp_res[order(-ctwas_snp_res$susie_pip),report_cols_snps],
max(sum(ctwas_snp_res$susie_pip>0.8), 20))
                 id region_tag susie_pip      mu2     PVE       z
21116    rs71658797       1_48     1.000    73.25 2.1e-04    9.85
30192     rs1730862       1_66     1.000    72.58 2.1e-04   -8.64
56568   rs766167074      1_118     1.000  7488.98 2.2e-02   -3.36
99527   rs141849010       2_69     1.000   111.94 3.3e-04   10.82
115440     rs863678      2_106     1.000   200.01 5.8e-04   12.03
122552   rs72926961      2_120     1.000   241.05 7.0e-04   15.67
193631    rs7642977      3_118     1.000    76.25 2.2e-04    8.90
221581  rs111470070       4_52     1.000    78.48 2.3e-04    7.90
258767  rs766378231        5_2     1.000  4893.44 1.4e-02    3.04
258769  rs544289197        5_2     1.000  4853.67 1.4e-02    2.95
275069  rs113088001       5_31     1.000    44.44 1.3e-04   -5.32
279582   rs11743158       5_41     1.000    87.46 2.5e-04    9.57
312886    rs7447593      5_106     1.000   182.82 5.3e-04   18.10
314983    rs7763581        6_2     1.000    40.40 1.2e-04   -5.67
317108     rs630258        6_7     1.000   103.32 3.0e-04   11.48
344019     rs194944       6_56     1.000   118.04 3.4e-04   10.92
360291  rs199804242       6_89     1.000 31695.80 9.2e-02    4.44
372720   rs78148157        7_3     1.000   116.74 3.4e-04   -7.23
372721   rs13241427        7_3     1.000   157.96 4.6e-04   11.36
390104     rs700752       7_34     1.000   137.65 4.0e-04   11.82
398507   rs10277379       7_49     1.000 33305.88 9.7e-02   10.56
398510  rs761767938       7_49     1.000 43248.80 1.3e-01    9.38
398515   rs11406602       7_49     1.000 39412.01 1.1e-01    9.38
398518    rs1544459       7_49     1.000 42689.71 1.2e-01    9.72
413107    rs3757387       7_79     1.000   211.31 6.1e-04   16.58
421500   rs11767572       7_97     1.000    47.90 1.4e-04    6.26
435132    rs4871905       8_24     1.000   278.40 8.1e-04   19.28
490431    rs1360200       9_45     1.000    47.89 1.4e-04   -7.01
500752  rs141350020       9_62     1.000    41.18 1.2e-04   -6.65
505570  rs113790047       10_3     1.000   120.71 3.5e-04   11.91
560626  rs369062552      11_21     1.000   298.79 8.7e-04   14.85
560636   rs34830202      11_21     1.000   318.88 9.3e-04  -15.76
596614   rs11616030      12_11     1.000    61.70 1.8e-04   -7.93
597639   rs11056397      12_13     1.000    78.53 2.3e-04   -8.54
610335    rs6581124      12_35     1.000    42.89 1.2e-04   -6.34
626208    rs7970581      12_68     1.000    40.80 1.2e-04   -6.35
628975    rs1169300      12_74     1.000   167.31 4.9e-04   13.19
644055  rs141110756      13_21     1.000   163.60 4.8e-04  -13.98
645954    rs7999449      13_25     1.000 18958.36 5.5e-02    3.82
645956  rs775834524      13_25     1.000 18906.05 5.5e-02    3.86
706562  rs145727191      15_35     1.000    48.28 1.4e-04    8.96
708109    rs7174325      15_38     1.000    76.60 2.2e-04    4.22
727663   rs12927956      16_27     1.000   127.98 3.7e-04    9.45
770855     rs162000      18_14     1.000    46.88 1.4e-04    6.99
795441  rs771303621      19_19     1.000  2897.49 8.4e-03   -2.34
800896     rs814573      19_31     1.000    68.30 2.0e-04   -9.01
800978     rs346738      19_31     1.000    37.80 1.1e-04   -6.49
813679   rs80346074      20_14     1.000    35.48 1.0e-04   -5.75
814043    rs6082726      20_15     1.000    78.15 2.3e-04    9.17
814194    rs6113933      20_16     1.000   279.22 8.1e-04  -22.57
814251    rs2050735      20_16     1.000   251.77 7.3e-04  -19.85
814269    rs6137887      20_16     1.000   782.70 2.3e-03  -33.20
814360  rs113822376      20_17     1.000   349.87 1.0e-03   26.33
814389   rs73102315      20_17     1.000  3362.59 9.8e-03  -43.87
814391    rs3827142      20_17     1.000 19616.61 5.7e-02 -143.60
814868   rs73101426      20_18     1.000    68.43 2.0e-04   -8.63
815023   rs13039195      20_18     1.000    80.19 2.3e-04   -8.00
815075    rs6076340      20_19     1.000    57.42 1.7e-04    1.18
815118  rs117932602      20_19     1.000    66.66 1.9e-04    7.57
815243    rs6084065      20_19     1.000    96.03 2.8e-04   -9.53
821793     rs209955      20_32     1.000    96.38 2.8e-04   11.08
821797    rs2585441      20_32     1.000    52.91 1.5e-04    7.34
832744    rs2834321      21_15     1.000    74.01 2.1e-04   10.08
833592     rs219783      21_16     1.000    67.36 2.0e-04   -8.10
902658    rs2307874       3_34     1.000  2587.89 7.5e-03   -2.74
1049809  rs71176182      19_23     1.000  2025.33 5.9e-03    3.69
27957    rs12407689       1_62     0.999    45.50 1.3e-04    6.66
38566     rs9425587       1_84     0.999    59.46 1.7e-04    7.69
72247      rs780093       2_16     0.999    54.85 1.6e-04    8.48
127040    rs2068218      2_128     0.999    32.10 9.3e-05   -5.41
346376     rs854922       6_61     0.999    34.95 1.0e-04    5.42
612005   rs61931197      12_40     0.999    34.78 1.0e-04    5.70
701411   rs57194033      15_25     0.999    47.68 1.4e-04   -6.65
725746   rs76597446      16_23     0.999    44.56 1.3e-04    6.80
727497    rs7205341      16_27     0.999    70.27 2.0e-04    8.38
750750    rs3760511      17_22     0.999    32.04 9.3e-05    5.67
750966     rs530253      17_23     0.999    47.90 1.4e-04   -7.08
934874    rs7742789       6_33     0.999   202.24 5.9e-04  -14.41
70261     rs3771257       2_12     0.998    33.73 9.8e-05   -5.51
79707    rs77981979       2_30     0.998    32.07 9.3e-05    5.54
323617    rs1980449       6_19     0.998    43.43 1.3e-04   -6.51
323792  rs115740542       6_20     0.998    34.67 1.0e-04    5.96
324277  rs187257713       6_21     0.998    33.94 9.8e-05   -6.33
505090   rs12380852       9_73     0.998    32.86 9.5e-05    6.56
538378  rs117081694      10_64     0.998    32.56 9.4e-05   -5.62
550400  rs186376420       11_2     0.998    43.95 1.3e-04   -6.85
664159     rs630943      13_59     0.998    31.03 9.0e-05   -5.30
701382    rs7162116      15_25     0.998    51.74 1.5e-04    8.38
714075    rs8037855      15_48     0.998    66.93 1.9e-04   11.40
716559  rs138922864       16_3     0.998    35.60 1.0e-04    5.77
740623    rs4843216      16_52     0.998    31.41 9.1e-05    4.09
814415    rs6515382      20_17     0.998  1436.85 4.2e-03   52.69
821820    rs6068816      20_32     0.998    36.41 1.1e-04   -5.82
837167   rs73907568      21_23     0.998    31.29 9.1e-05    5.42
99519   rs142743147       2_69     0.997    31.21 9.0e-05    5.33
237505  rs115336319       4_83     0.997    30.78 8.9e-05   -4.40
324596  rs138975185       6_22     0.997    32.64 9.5e-05   -5.94
435122     rs310311       8_24     0.997   122.25 3.5e-04  -14.62
706591    rs2955742      15_36     0.997    56.91 1.6e-04    7.22
813902   rs13044691      20_15     0.997    32.12 9.3e-05   -4.09
814174  rs112734453      20_16     0.997   157.44 4.6e-04  -16.69
349588    rs9496567       6_67     0.996    29.85 8.6e-05    5.30
460640  rs376277175       8_79     0.996    39.58 1.1e-04   -7.81
702443     rs340029      15_27     0.996    40.41 1.2e-04    6.22
743754  rs181752000       17_7     0.996    33.29 9.6e-05    4.75
213824     rs723585       4_40     0.994    75.04 2.2e-04   -8.70
317141    rs3799511        6_7     0.994    40.56 1.2e-04   -4.52
421484     rs288762       7_97     0.994   112.61 3.3e-04   12.52
483692  rs117451470       9_30     0.994    29.02 8.4e-05   -4.89
421751   rs12697965       7_98     0.993    36.92 1.1e-04    8.26
626096   rs35287743      12_66     0.993    33.04 9.5e-05    6.11
629928    rs1055941      12_75     0.993    38.09 1.1e-04    6.36
701428   rs11071331      15_25     0.993    41.59 1.2e-04    2.82
723530    rs7203451      16_19     0.993   251.46 7.3e-04  -12.43
30496    rs11102041       1_69     0.992    77.87 2.2e-04   -6.06
258835   rs62331274        5_2     0.992    58.59 1.7e-04    5.92
714064   rs11634241      15_48     0.992   164.71 4.7e-04   15.47
756486  rs139064373      17_36     0.992    27.76 8.0e-05   -3.98
379917   rs17644994       7_17     0.991    36.12 1.0e-04    6.34
505077    rs1886296       9_73     0.991    29.56 8.5e-05    6.18
113115    rs7594986      2_103     0.990    61.35 1.8e-04    7.46
593138     rs723672       12_2     0.990    28.76 8.3e-05    5.20
39168    rs34484492       1_85     0.989    32.28 9.3e-05   -5.95
97447    rs11123169       2_67     0.989    54.57 1.6e-04   -7.35
566278   rs11381239      11_29     0.988    37.24 1.1e-04    6.71
787402    rs8108787       19_2     0.988    30.93 8.9e-05   -5.38
1027144  rs72811597      16_54     0.988    60.18 1.7e-04   -7.10
99649     rs2311597       2_70     0.987    67.43 1.9e-04   -8.18
607844   rs11830037      12_30     0.987    29.50 8.5e-05    5.71
233974   rs10024666       4_75     0.986    27.17 7.8e-05    4.93
331448    rs9357429       6_34     0.985    28.98 8.3e-05   -5.21
714051   rs75422555      15_47     0.985    33.77 9.7e-05   -6.70
310546    rs1422755      5_102     0.984    34.75 9.9e-05    5.71
421803   rs11761498       7_98     0.984    57.79 1.7e-04    7.88
578777   rs57569860      11_52     0.984    26.53 7.6e-05    4.87
826144   rs78581838       21_2     0.984    38.12 1.1e-04   -6.35
982067    rs3184504      12_67     0.984   783.03 2.2e-03  -27.94
30494   rs201469841       1_69     0.983    45.87 1.3e-04   -0.98
321647    rs3763278       6_15     0.983    29.82 8.5e-05    4.39
950138   rs11557049       8_50     0.983    44.16 1.3e-04    6.79
78830      rs588206       2_28     0.982    39.10 1.1e-04    6.25
31942   rs149803516       1_71     0.981    30.88 8.8e-05   -5.35
351725   rs12196331       6_71     0.981    29.87 8.5e-05    5.73
637489   rs79490353       13_7     0.980    27.15 7.7e-05    4.58
313742    rs4701140      5_108     0.979    26.93 7.7e-05    4.90
285747    rs3952745       5_53     0.978    28.11 8.0e-05   -5.36
326475    rs1793893       6_26     0.978    84.77 2.4e-04    8.96
56606     rs1769794      1_118     0.977  4174.83 1.2e-02    5.93
548933   rs75184896      10_84     0.976    26.82 7.6e-05    4.92
324962    rs3130253       6_23     0.975    38.80 1.1e-04   -5.88
743725    rs9898876       17_7     0.975    49.26 1.4e-04    6.21
813699    rs6082285      20_15     0.974    34.02 9.6e-05    5.54
228593    rs6532770       4_66     0.972    36.10 1.0e-04    6.09
331361   rs10223666       6_34     0.972   228.23 6.4e-04   15.67
689806   rs55964922      14_53     0.972    27.55 7.8e-05   -5.26
328595   rs56144236       6_27     0.971    28.81 8.1e-05   -5.74
551193    rs1983100       11_3     0.971    36.11 1.0e-04    5.82
688126   rs72698888      14_49     0.970    26.67 7.5e-05    4.87
474891   rs16931379       9_12     0.966    28.97 8.1e-05   -5.17
813491    rs6112780      20_14     0.966    26.17 7.3e-05    4.36
815667  rs142348466      20_19     0.966    40.50 1.1e-04   -5.72
26398     rs9432440       1_58     0.965    33.21 9.3e-05    5.86
110180    rs1980154       2_96     0.965    33.49 9.4e-05    6.27
465109   rs10094480       8_87     0.961    31.97 8.9e-05   -5.39
659533  rs565714342      13_49     0.960    31.10 8.7e-05    5.46
732995     rs244423      16_37     0.960    78.33 2.2e-04  -10.67
2539     rs61772085        1_6     0.959    30.55 8.5e-05    5.72
390211  rs113473694       7_35     0.958    26.26 7.3e-05   -4.71
63057     rs4335411      1_131     0.957    25.28 7.0e-05   -4.73
346551    rs9359877       6_61     0.957    26.99 7.5e-05    5.68
275091     rs255749       5_31     0.956    32.70 9.1e-05    4.79
531028    rs1649987      10_50     0.956    26.06 7.2e-05   -4.86
139044   rs59302296        3_7     0.953    28.34 7.8e-05    5.13
3355       rs205474        1_9     0.951    29.53 8.2e-05   -5.34
329151     rs493871       6_28     0.951    31.63 8.7e-05    5.07
832738    rs2154568      21_15     0.951    37.05 1.0e-04    7.63
522079    rs4935194      10_33     0.945    31.27 8.6e-05    6.79
609609  rs113897279      12_33     0.944    26.62 7.3e-05    4.77
301858   rs12109255       5_84     0.943    26.87 7.4e-05   -4.96
455064    rs1786344       8_69     0.942    26.57 7.3e-05    4.66
703320    rs8041454      15_29     0.942    61.46 1.7e-04   -9.80
789404  rs146992497       19_6     0.941    23.55 6.4e-05    4.47
982129  rs150383897      12_67     0.941    92.18 2.5e-04    6.13
813449   rs61571241      20_14     0.940    25.21 6.9e-05    4.03
333883   rs76572975       6_39     0.937    37.64 1.0e-04   -6.96
258689     rs386057        5_1     0.936    45.40 1.2e-04   -6.21
3329       rs284317        1_7     0.935    25.29 6.9e-05   -4.00
11713     rs2484713       1_27     0.934    35.02 9.5e-05    5.68
516692   rs11007559      10_21     0.934    29.30 8.0e-05    5.17
844247   rs71195055      22_16     0.934    35.90 9.7e-05    6.17
77961    rs13428381       2_27     0.933    33.87 9.2e-05   -6.15
99866    rs35275076       2_70     0.933    88.84 2.4e-04   10.97
343550    rs2444819       6_55     0.933    47.42 1.3e-04    7.14
582200  rs117680242      11_59     0.933    25.55 6.9e-05    4.54
91965    rs11686739       2_54     0.929    27.55 7.4e-05    4.82
142942     rs711731       3_15     0.927    25.23 6.8e-05    4.67
331239    rs1015149       6_32     0.926    26.99 7.3e-05   -5.21
776080   rs12954053      18_24     0.926    30.52 8.2e-05    4.84
235047   rs17296659       4_78     0.925    33.41 9.0e-05   -5.66
701432    rs7166305      15_25     0.924    56.48 1.5e-04   -4.72
301104     rs156094       5_83     0.923    28.21 7.6e-05   -5.14
271775    rs3096211       5_26     0.921    30.49 8.2e-05    3.95
346378    rs1209058       6_61     0.921    33.04 8.8e-05   -7.35
421749    rs6967289       7_98     0.919    45.75 1.2e-04    7.69
813516    rs6046722      20_14     0.919    25.61 6.8e-05   -4.63
587923   rs73018243      11_75     0.916    24.03 6.4e-05   -4.45
727688   rs72803263      16_27     0.916    25.55 6.8e-05    3.06
274901    rs9716017       5_31     0.915    29.95 8.0e-05   -4.77
462427    rs4604455       8_83     0.912    26.11 6.9e-05   -5.41
32781     rs1975283       1_72     0.909    57.01 1.5e-04   -7.61
746135    rs1005395      17_13     0.909    23.96 6.3e-05    4.42
763141   rs28454947      17_46     0.908    26.70 7.0e-05    5.30
371476    rs9456260      6_110     0.907    25.64 6.8e-05    4.93
14937     rs2780869       1_35     0.906    31.23 8.2e-05   -5.45
522077   rs35182775      10_33     0.906    32.61 8.6e-05   -7.34
708709   rs62027546      15_38     0.906    26.31 6.9e-05    4.75
22836     rs6661091       1_50     0.902    55.20 1.4e-04    7.49
492288  rs141649706       9_48     0.898    25.98 6.8e-05   -5.14
837813   rs34526805       22_1     0.898    26.66 7.0e-05    4.94
707400       rs3128      15_37     0.897    25.86 6.7e-05    3.93
730931   rs79574106      16_33     0.897    24.94 6.5e-05    4.64
137038    rs4621315        3_4     0.896    25.58 6.7e-05    4.78
317074   rs10458103        6_7     0.896    52.00 1.4e-04    9.14
373143   rs62442558        7_4     0.896    25.94 6.8e-05    4.86
817645    rs6029393      20_24     0.896    40.11 1.0e-04   -6.18
550195    rs7115054       11_2     0.895   106.40 2.8e-04    9.67
708107   rs12442871      15_38     0.895    59.34 1.5e-04   -1.35
258757   rs10040050        5_2     0.893  4507.85 1.2e-02    3.65
644384   rs77871802      13_21     0.893    34.43 8.9e-05   -5.49
814888  rs147493439      20_18     0.890    28.35 7.3e-05    1.72
33182   rs148295181       1_74     0.886    23.07 5.9e-05   -4.25
156772    rs1866264       3_46     0.884    32.35 8.3e-05   -5.50
703122    rs4569205      15_28     0.883    31.82 8.2e-05    5.55
802188  rs116922356      19_34     0.883    26.24 6.7e-05   -4.61
571181   rs12420758      11_38     0.882    35.70 9.1e-05   -6.35
325460    rs2248162       6_26     0.881   116.96 3.0e-04  -10.90
437238  rs139800483       8_29     0.881    25.31 6.5e-05   -4.70
579536    rs7934169      11_54     0.880    23.71 6.1e-05   -4.37
46839    rs72739200      1_100     0.879    25.62 6.5e-05    4.65
79276      rs935375       2_29     0.879    25.35 6.5e-05   -4.77
793558    rs8113096      19_15     0.879    24.26 6.2e-05   -3.41
815951  rs138112660      20_20     0.878    25.11 6.4e-05   -4.35
372717    rs4487642        7_3     0.877    51.35 1.3e-04   -3.40
787869    rs1064543       19_2     0.874    26.25 6.7e-05    4.75
695431   rs12908082      15_11     0.870    24.70 6.2e-05   -4.47
113601  rs139389756      2_104     0.868    24.67 6.2e-05    4.55
299255   rs12153431       5_79     0.867    37.00 9.3e-05    5.44
569090    rs4938939      11_34     0.862    29.00 7.3e-05    5.09
630110   rs11057830      12_76     0.861    24.30 6.1e-05    4.39
111742    rs7607980      2_100     0.857    38.33 9.5e-05    6.04
873224   rs75246752       1_73     0.857    31.40 7.8e-05    5.17
12710   rs115398900       1_30     0.856    24.33 6.1e-05   -4.44
231507   rs56011514       4_71     0.855    26.34 6.5e-05    4.81
561044   rs10835944      11_22     0.855    26.39 6.6e-05   -4.50
548987    rs2767419      10_85     0.852    24.21 6.0e-05   -4.45
560977    rs6484575      11_22     0.852    27.34 6.8e-05    3.73
57789   rs113358743      1_122     0.851    26.15 6.5e-05    4.60
639880   rs57217617      13_13     0.849    24.74 6.1e-05    4.59
360290    rs2327654       6_89     0.847 31753.42 7.8e-02    4.57
697213    rs2016840      15_17     0.842    25.55 6.3e-05   -4.68
225537    rs9996470       4_60     0.840    27.06 6.6e-05   -4.86
816162  rs111791178      20_21     0.840    28.35 6.9e-05    5.59
736805    rs9928026      16_44     0.839    76.34 1.9e-04   -8.23
31666     rs6679677       1_70     0.838    24.90 6.1e-05    4.46
119904   rs10207044      2_113     0.837    26.57 6.5e-05    5.12
732235   rs11390603      16_36     0.837    26.31 6.4e-05   -4.57
804964  rs371808578      19_38     0.834    30.66 7.4e-05    5.34
256613  rs181147923      4_120     0.833    26.81 6.5e-05    4.66
570891   rs75592015      11_37     0.832    26.90 6.5e-05    4.90
1005444  rs56261560      14_52     0.830    32.81 7.9e-05    5.48
190987     rs822362      3_114     0.829    79.09 1.9e-04    9.06
36834    rs72691538       1_82     0.828    26.67 6.4e-05   -4.60
151026  rs146456061       3_35     0.824    27.82 6.7e-05   -4.57
221700   rs17253722       4_52     0.824   668.27 1.6e-03   29.86
793759    rs3794991      19_15     0.824    38.42 9.2e-05    5.98
282840   rs17263175       5_47     0.823    23.82 5.7e-05    4.31
825558    rs6062681      20_38     0.822    26.98 6.4e-05   -4.89
272178  rs149976817       5_27     0.819    23.50 5.6e-05    4.11
365320    rs4870114       6_99     0.816    28.45 6.7e-05    5.06
194393   rs13059257      3_120     0.815    31.90 7.6e-05    5.38
324930    rs1233385       6_23     0.815    74.60 1.8e-04    9.07
144505   rs11711833       3_18     0.814    67.08 1.6e-04   -8.28
708467   rs28587326      15_38     0.814    32.55 7.7e-05    5.45
791961  rs144089403      19_11     0.813    27.04 6.4e-05   -4.53
32514     rs3949262       1_72     0.812    29.24 6.9e-05   -5.07
608421    rs1878234      12_31     0.811    32.75 7.7e-05   -5.71
115500   rs72940807      2_106     0.810    30.96 7.3e-05    6.69
950124   rs77732976       8_50     0.806    31.22 7.3e-05   -5.46
258616  rs142220278        5_1     0.803    26.77 6.2e-05    3.95

SNPs with largest effect sizes

#plot PIP vs effect size
plot(ctwas_snp_res$susie_pip, ctwas_snp_res$mu2, xlab="PIP", ylab="mu^2", main="SNP PIPs vs Effect Size")

Version Author Date
dfd2b5f wesleycrouse 2021-09-07
#SNPs with 50 largest effect sizes
head(ctwas_snp_res[order(-ctwas_snp_res$mu2),report_cols_snps],50)
                id region_tag susie_pip      mu2     PVE       z
398510 rs761767938       7_49     1.000 43248.80 1.3e-01    9.38
398518   rs1544459       7_49     1.000 42689.71 1.2e-01    9.72
398514  rs11972122       7_49     0.000 39427.03 2.1e-06    9.25
398515  rs11406602       7_49     1.000 39412.01 1.1e-01    9.38
398519   rs1544458       7_49     0.000 38833.39 0.0e+00    9.45
398509   rs6465794       7_49     0.000 38228.80 0.0e+00    8.90
398508   rs6465793       7_49     0.000 38228.22 0.0e+00    8.90
398539  rs10272350       7_49     0.000 38164.98 0.0e+00    9.12
398543   rs2463008       7_49     0.000 36310.83 0.0e+00    9.80
398549  rs10267180       7_49     0.000 36294.23 0.0e+00    9.74
398489  rs13240016       7_49     0.000 36167.87 0.0e+00    8.60
398498   rs7799383       7_49     0.000 35303.88 0.0e+00    8.13
398507  rs10277379       7_49     1.000 33305.88 9.7e-02   10.56
398501   rs7795371       7_49     0.000 32839.76 0.0e+00   10.68
360290   rs2327654       6_89     0.847 31753.42 7.8e-02    4.57
360307   rs6923513       6_89     0.630 31752.03 5.8e-02    4.56
360291 rs199804242       6_89     1.000 31695.80 9.2e-02    4.44
360294 rs113527452       6_89     0.000 31585.57 1.6e-12    4.54
360299 rs200796875       6_89     0.000 31396.72 0.0e+00    4.41
360312   rs7756915       6_89     0.000 31196.78 0.0e+00    4.41
360305   rs6570040       6_89     0.000 29946.62 0.0e+00    4.50
398563    rs848470       7_49     0.000 29931.63 0.0e+00   -7.24
360292   rs6570031       6_89     0.000 29876.06 0.0e+00    4.51
360293   rs9389323       6_89     0.000 29859.53 0.0e+00    4.46
360309   rs9321531       6_89     0.000 26220.45 0.0e+00    4.48
360282   rs9321528       6_89     0.000 25902.76 0.0e+00    5.03
398457   rs9640663       7_49     0.000 24891.63 0.0e+00    7.45
398453   rs2868787       7_49     0.000 24889.65 0.0e+00    7.42
360310   rs9494389       6_89     0.000 24614.08 0.0e+00    4.10
360314   rs5880262       6_89     0.000 24554.47 0.0e+00    3.92
398468   rs4727451       7_49     0.000 24523.03 0.0e+00    7.20
398487  rs58729654       7_49     0.000 24450.56 0.0e+00    8.05
398481   rs6465771       7_49     0.000 23923.30 0.0e+00    7.31
360288   rs2208574       6_89     0.000 23765.61 0.0e+00    4.35
360287   rs1033755       6_89     0.000 23755.83 0.0e+00    4.19
398573  rs34022094       7_49     0.000 23346.89 0.0e+00   -6.60
360285   rs2038551       6_89     0.000 23342.48 0.0e+00    5.03
398571    rs848458       7_49     0.000 23331.34 0.0e+00   -6.51
360296   rs9494377       6_89     0.000 23319.90 0.0e+00    4.07
360283   rs2038550       6_89     0.000 23278.70 0.0e+00    4.97
398447   rs1972568       7_49     0.000 22171.27 0.0e+00    7.28
398438   rs7788492       7_49     0.000 22164.41 0.0e+00    7.20
398440  rs67630171       7_49     0.000 22151.85 0.0e+00    7.17
398439   rs4729540       7_49     0.000 22139.74 0.0e+00    7.22
398445   rs7806750       7_49     0.000 22120.00 0.0e+00    7.25
398435   rs7357107       7_49     0.000 22117.77 0.0e+00    7.22
398527   rs4729772       7_49     0.000 20835.71 0.0e+00    8.90
398466  rs12705075       7_49     0.000 19747.39 0.0e+00    7.41
814391   rs3827142      20_17     1.000 19616.61 5.7e-02 -143.60
814392   rs5030707      20_17     0.000 19478.55 0.0e+00 -142.96

SNPs with highest PVE

#SNPs with 50 highest pve
head(ctwas_snp_res[order(-ctwas_snp_res$PVE),report_cols_snps],50)
                 id region_tag susie_pip      mu2     PVE       z
398510  rs761767938       7_49     1.000 43248.80 0.13000    9.38
398518    rs1544459       7_49     1.000 42689.71 0.12000    9.72
398515   rs11406602       7_49     1.000 39412.01 0.11000    9.38
398507   rs10277379       7_49     1.000 33305.88 0.09700   10.56
360291  rs199804242       6_89     1.000 31695.80 0.09200    4.44
360290    rs2327654       6_89     0.847 31753.42 0.07800    4.57
360307    rs6923513       6_89     0.630 31752.03 0.05800    4.56
814391    rs3827142      20_17     1.000 19616.61 0.05700 -143.60
645954    rs7999449      13_25     1.000 18958.36 0.05500    3.82
645956  rs775834524      13_25     1.000 18906.05 0.05500    3.86
56568   rs766167074      1_118     1.000  7488.98 0.02200   -3.36
258767  rs766378231        5_2     1.000  4893.44 0.01400    3.04
258769  rs544289197        5_2     1.000  4853.67 0.01400    2.95
56606     rs1769794      1_118     0.977  4174.83 0.01200    5.93
258757   rs10040050        5_2     0.893  4507.85 0.01200    3.65
814389   rs73102315      20_17     1.000  3362.59 0.00980  -43.87
795441  rs771303621      19_19     1.000  2897.49 0.00840   -2.34
902658    rs2307874       3_34     1.000  2587.89 0.00750   -2.74
56565    rs10489611      1_118     0.318  7474.24 0.00690   -3.63
56559     rs2256908      1_118     0.290  7473.83 0.00630   -3.64
1049809  rs71176182      19_23     1.000  2025.33 0.00590    3.69
56562     rs2790891      1_118     0.268  7473.78 0.00580   -3.63
56563     rs2491405      1_118     0.268  7473.78 0.00580   -3.63
56566     rs2486737      1_118     0.267  7474.13 0.00580   -3.63
795443  rs111064632      19_19     0.676  2893.03 0.00570   -2.24
56567      rs971534      1_118     0.235  7474.06 0.00510   -3.62
814415    rs6515382      20_17     0.998  1436.85 0.00420   52.69
795447   rs12151080      19_19     0.414  2885.73 0.00350   -2.30
795445    rs6511437      19_19     0.381  2890.96 0.00320   -2.28
1049771  rs10414879      19_23     0.399  2090.26 0.00240    3.88
814269    rs6137887      20_16     1.000   782.70 0.00230  -33.20
982067    rs3184504      12_67     0.984   783.03 0.00220  -27.94
902680     rs800762       3_34     0.281  2579.90 0.00210   -2.80
221700   rs17253722       4_52     0.824   668.27 0.00160   29.86
56555     rs1076804      1_118     0.063  7462.76 0.00140   -3.63
258756   rs10040611        5_2     0.107  4493.21 0.00140    3.87
56575     rs2211176      1_118     0.059  7469.69 0.00130   -3.59
56576     rs2790882      1_118     0.059  7469.69 0.00130   -3.59
1049769  rs28633567      19_23     0.221  2090.96 0.00130    3.84
902674    rs1684942       3_34     0.155  2571.89 0.00120   -2.88
795448   rs28410659      19_19     0.135  2888.05 0.00110   -2.26
1049765   rs8109247      19_23     0.176  2087.43 0.00110    3.89
814360  rs113822376      20_17     1.000   349.87 0.00100   26.33
560636   rs34830202      11_21     1.000   318.88 0.00093  -15.76
902661   rs55721964       3_34     0.124  2573.36 0.00093   -2.79
560626  rs369062552      11_21     1.000   298.79 0.00087   14.85
795449    rs8105841      19_19     0.104  2887.50 0.00087   -2.26
419891   rs10224210       7_94     0.746   395.75 0.00086   20.73
723534    rs9933330      16_19     0.680   418.30 0.00083  -19.23
435132    rs4871905       8_24     1.000   278.40 0.00081   19.28

SNPs with largest z scores

#SNPs with 50 largest z scores
head(ctwas_snp_res[order(-abs(ctwas_snp_res$z)),report_cols_snps],50)
                id region_tag susie_pip      mu2     PVE       z
814391   rs3827142      20_17     1.000 19616.61 5.7e-02 -143.60
814392   rs5030707      20_17     0.000 19478.55 0.0e+00 -142.96
814387  rs13039536      20_17     0.000 19449.48 0.0e+00 -142.76
814383   rs8121283      20_17     0.000 18959.33 0.0e+00 -140.90
814385   rs8121405      20_17     0.000 18937.23 0.0e+00 -140.84
814384   rs8115417      20_17     0.000 18929.82 0.0e+00 -140.80
814380  rs57549987      20_17     0.000 18929.36 0.0e+00 -140.79
814379   rs1555355      20_17     0.000 18926.33 0.0e+00 -140.78
814382   rs6036471      20_17     0.000 18909.42 0.0e+00 -140.73
814377  rs56077567      20_17     0.000 18852.63 0.0e+00 -140.52
814381   rs6036470      20_17     0.000 18807.64 0.0e+00 -140.48
814376  rs13043266      20_17     0.000 18744.50 0.0e+00 -140.24
814371   rs4815223      20_17     0.000 18308.48 0.0e+00 -138.69
814373  rs34792920      20_17     0.000 18226.74 0.0e+00 -138.52
814372   rs6048925      20_17     0.000 18344.63 0.0e+00 -138.45
814394 rs199651024      20_17     0.000 14005.18 0.0e+00 -128.69
814370 rs200582457      20_17     0.000 10315.16 0.0e+00  -99.72
814432   rs4629231      20_17     0.000  6442.47 0.0e+00  -90.22
814410  rs77770287      20_17     0.000  6290.29 0.0e+00  -89.45
814412   rs2226058      20_17     0.000  6252.34 0.0e+00  -89.20
814386 rs200585819      20_17     0.000  9333.59 0.0e+00  -84.58
814374    rs726217      20_17     0.000  9271.32 0.0e+00   84.19
814405   rs2983605      20_17     0.000  8374.73 0.0e+00   78.56
814415   rs6515382      20_17     0.998  1436.85 4.2e-03   52.69
814414   rs1538909      20_17     0.000  1991.95 0.0e+00  -52.55
814417   rs7263473      20_17     0.002  1419.60 9.7e-06   52.49
814431  rs75841856      20_17     0.000  1400.90 3.2e-12   52.15
814416   rs6036488      20_17     0.000  1949.33 0.0e+00  -52.06
814433   rs6083243      20_17     0.000  1393.68 0.0e+00  -45.68
814422  rs62208893      20_17     0.000  1388.45 0.0e+00  -45.65
814421   rs6132654      20_17     0.000  1388.22 0.0e+00  -45.64
814436  rs11087433      20_17     0.000  1386.72 0.0e+00  -45.64
814439   rs6049062      20_17     0.000  1384.99 0.0e+00  -45.59
814448  rs35488686      20_17     0.000  1291.33 0.0e+00   45.52
814389  rs73102315      20_17     1.000  3362.59 9.8e-03  -43.87
814378  rs62208864      20_17     0.000   839.80 0.0e+00   43.59
814429  rs35783127      20_17     0.000  1027.60 0.0e+00   41.94
814423  rs35627338      20_17     0.000  1019.36 0.0e+00   41.79
814435   rs4380313      20_17     0.000  1018.84 0.0e+00   41.78
814427   rs8121966      20_17     0.000  1017.33 0.0e+00   41.77
814437  rs60609640      20_17     0.000  1017.08 0.0e+00   41.74
814411  rs10854252      20_17     0.000   649.49 0.0e+00   40.06
814452   rs6114276      20_17     0.000  1384.62 0.0e+00  -39.78
814463   rs6114287      20_17     0.000  1382.70 0.0e+00  -39.66
814474  rs72490829      20_17     0.000  1387.19 0.0e+00  -39.66
814488   rs6106724      20_17     0.000  1382.54 0.0e+00  -39.62
814489   rs8115480      20_17     0.000  1382.72 0.0e+00  -39.62
814483   rs6106721      20_17     0.000  1380.43 0.0e+00  -39.61
814499   rs6114316      20_17     0.000  1382.99 0.0e+00  -39.61
814466 rs144538582      20_17     0.000  1088.01 0.0e+00   36.48

Gene set enrichment for genes with PIP>0.8

#GO enrichment analysis
library(enrichR)
Welcome to enrichR
Checking connection ... 
Enrichr ... Connection is Live!
FlyEnrichr ... Connection is available!
WormEnrichr ... Connection is available!
YeastEnrichr ... Connection is available!
FishEnrichr ... Connection is available!
dbs <- c("GO_Biological_Process_2021", "GO_Cellular_Component_2021", "GO_Molecular_Function_2021")
genes <- ctwas_gene_res$genename[ctwas_gene_res$susie_pip>0.8]

#number of genes for gene set enrichment
length(genes)
[1] 19
if (length(genes)>0){
  GO_enrichment <- enrichr(genes, dbs)

  for (db in dbs){
    print(db)
    df <- GO_enrichment[[db]]
    df <- df[df$Adjusted.P.value<0.05,c("Term", "Overlap", "Adjusted.P.value", "Genes")]
    print(df)
  }
  
  #DisGeNET enrichment
  
  # devtools::install_bitbucket("ibi_group/disgenet2r")
  library(disgenet2r)
  
  disgenet_api_key <- get_disgenet_api_key(
                    email = "wesleycrouse@gmail.com", 
                    password = "uchicago1" )
  
  Sys.setenv(DISGENET_API_KEY= disgenet_api_key)
  
  res_enrich <-disease_enrichment(entities=genes, vocabulary = "HGNC",
                               database = "CURATED" )
  
  df <- res_enrich@qresult[1:10, c("Description", "FDR", "Ratio",  "BgRatio")]
  print(df)
  
  #WebGestalt enrichment
  library(WebGestaltR)
  
  background <- ctwas_gene_res$genename
  
  #listGeneSet()
  databases <- c("pathway_KEGG", "disease_GLAD4U", "disease_OMIM")
  
  enrichResult <- WebGestaltR(enrichMethod="ORA", organism="hsapiens",
                              interestGene=genes, referenceGene=background,
                              enrichDatabase=databases, interestGeneType="genesymbol",
                              referenceGeneType="genesymbol", isOutput=F)
  print(enrichResult[,c("description", "size", "overlap", "FDR", "database", "userId")])
}
Uploading data to Enrichr... Done.
  Querying GO_Biological_Process_2021... Done.
  Querying GO_Cellular_Component_2021... Done.
  Querying GO_Molecular_Function_2021... Done.
Parsing results... Done.
[1] "GO_Biological_Process_2021"
[1] Term             Overlap          Adjusted.P.value Genes           
<0 rows> (or 0-length row.names)
[1] "GO_Cellular_Component_2021"
[1] Term             Overlap          Adjusted.P.value Genes           
<0 rows> (or 0-length row.names)
[1] "GO_Molecular_Function_2021"
[1] Term             Overlap          Adjusted.P.value Genes           
<0 rows> (or 0-length row.names)
LSM12 gene(s) from the input list not found in DisGeNET CURATEDC15orf52 gene(s) from the input list not found in DisGeNET CURATEDCXXC1 gene(s) from the input list not found in DisGeNET CURATEDMEA1 gene(s) from the input list not found in DisGeNET CURATEDRAI14 gene(s) from the input list not found in DisGeNET CURATEDZNF697 gene(s) from the input list not found in DisGeNET CURATEDZNF827 gene(s) from the input list not found in DisGeNET CURATEDDCAF4 gene(s) from the input list not found in DisGeNET CURATEDLPCAT4 gene(s) from the input list not found in DisGeNET CURATED
                                   Description        FDR Ratio  BgRatio
76            DEAFNESS, AUTOSOMAL RECESSIVE 32 0.02447949  1/10   1/9703
78           Medullary cystic kidney disease 1 0.02447949  1/10   1/9703
81    Mental Retardation, Autosomal Dominant 1 0.02447949  1/10   1/9703
91               2q23.1 microdeletion syndrome 0.02447949  1/10   1/9703
77 Uniparental disomy, paternal, chromosome 14 0.05869628  1/10   3/9703
21                              Hydronephrosis 0.06981173  1/10   5/9703
37                                    Polyuria 0.06981173  1/10   5/9703
6                          Cannabis Dependence 0.08439931  1/10  17/9703
8               Neoplastic Cell Transformation 0.08439931  2/10 139/9703
11                         Prelingual Deafness 0.08439931  1/10  20/9703
******************************************

*                                        *

*          Welcome to WebGestaltR !      *

*                                        *

******************************************
Loading the functional categories...
Loading the ID list...
Loading the reference list...
Performing the enrichment analysis...
               description size overlap         FDR       database
1 Neoplasms, Squamous Cell  246       6 0.009657657 disease_GLAD4U
2           Adenocarcinoma  203       5 0.034821659 disease_GLAD4U
                             userId
1 MUC1;VIL1;PTGES;TRIM29;MEG3;MMP11
2        MUC1;VIL1;PTGES;MEG3;MMP11

sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Scientific Linux 7.4 (Nitrogen)

Matrix products: default
BLAS/LAPACK: /software/openblas-0.2.19-el7-x86_64/lib/libopenblas_haswellp-r0.2.19.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] WebGestaltR_0.4.4 disgenet2r_0.99.2 enrichR_3.0       cowplot_1.0.0    
[5] ggplot2_3.3.3    

loaded via a namespace (and not attached):
  [1] bitops_1.0-6                matrixStats_0.57.0         
  [3] fs_1.3.1                    bit64_4.0.5                
  [5] doParallel_1.0.16           progress_1.2.2             
  [7] httr_1.4.1                  rprojroot_2.0.2            
  [9] GenomeInfoDb_1.20.0         doRNG_1.8.2                
 [11] tools_3.6.1                 utf8_1.2.1                 
 [13] R6_2.5.0                    DBI_1.1.1                  
 [15] BiocGenerics_0.30.0         colorspace_1.4-1           
 [17] withr_2.4.1                 tidyselect_1.1.0           
 [19] prettyunits_1.0.2           bit_4.0.4                  
 [21] curl_3.3                    compiler_3.6.1             
 [23] git2r_0.26.1                Biobase_2.44.0             
 [25] DelayedArray_0.10.0         rtracklayer_1.44.0         
 [27] labeling_0.3                scales_1.1.0               
 [29] readr_1.4.0                 apcluster_1.4.8            
 [31] stringr_1.4.0               digest_0.6.20              
 [33] Rsamtools_2.0.0             svglite_1.2.2              
 [35] rmarkdown_1.13              XVector_0.24.0             
 [37] pkgconfig_2.0.3             htmltools_0.3.6            
 [39] fastmap_1.1.0               BSgenome_1.52.0            
 [41] rlang_0.4.11                RSQLite_2.2.7              
 [43] generics_0.0.2              farver_2.1.0               
 [45] jsonlite_1.6                BiocParallel_1.18.0        
 [47] dplyr_1.0.7                 VariantAnnotation_1.30.1   
 [49] RCurl_1.98-1.1              magrittr_2.0.1             
 [51] GenomeInfoDbData_1.2.1      Matrix_1.2-18              
 [53] Rcpp_1.0.6                  munsell_0.5.0              
 [55] S4Vectors_0.22.1            fansi_0.5.0                
 [57] gdtools_0.1.9               lifecycle_1.0.0            
 [59] stringi_1.4.3               whisker_0.3-2              
 [61] yaml_2.2.0                  SummarizedExperiment_1.14.1
 [63] zlibbioc_1.30.0             plyr_1.8.4                 
 [65] grid_3.6.1                  blob_1.2.1                 
 [67] parallel_3.6.1              promises_1.0.1             
 [69] crayon_1.4.1                lattice_0.20-38            
 [71] Biostrings_2.52.0           GenomicFeatures_1.36.3     
 [73] hms_1.1.0                   knitr_1.23                 
 [75] pillar_1.6.1                igraph_1.2.4.1             
 [77] GenomicRanges_1.36.0        rjson_0.2.20               
 [79] rngtools_1.5                codetools_0.2-16           
 [81] reshape2_1.4.3              biomaRt_2.40.1             
 [83] stats4_3.6.1                XML_3.98-1.20              
 [85] glue_1.4.2                  evaluate_0.14              
 [87] data.table_1.14.0           foreach_1.5.1              
 [89] vctrs_0.3.8                 httpuv_1.5.1               
 [91] gtable_0.3.0                purrr_0.3.4                
 [93] assertthat_0.2.1            cachem_1.0.5               
 [95] xfun_0.8                    later_0.8.0                
 [97] tibble_3.1.2                iterators_1.0.13           
 [99] GenomicAlignments_1.20.1    AnnotationDbi_1.46.0       
[101] memoise_2.0.0               IRanges_2.18.1             
[103] workflowr_1.6.2             ellipsis_0.3.2