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-30720_irnt_Liver.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-30700_irnt_Whole_Blood.Rmd) and HTML (docs/ukb-d-30700_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 Creatinine (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-30700_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.0126890811 0.0002128067 
#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 
22.2112 20.0238 
#report sample size
print(sample_size)
[1] 344104
#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.009087404 0.107703036 
#compare sum(PIP*mu2/sample_size) with above PVE calculation
c(sum(ctwas_gene_res$PVE),sum(ctwas_snp_res$PVE))
[1] 0.07180211 2.48330981

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
9813           MUC1       1_77     1.000    90.14 2.6e-04 -7.02
6117           TBX6      16_24     1.000    47.19 1.4e-04  6.38
10765       ZDHHC18       1_18     0.999    75.48 2.2e-04 -8.72
1980          FCGRT      19_34     0.999 14001.37 4.1e-02  3.17
5095        DNAJC13       3_82     0.977    37.97 1.1e-04 -6.22
982          CDC14A       1_61     0.973    69.67 2.0e-04 -8.40
3750           MEA1       6_33     0.971    26.64 7.5e-05  4.51
6646           DRC1       2_15     0.958    22.87 6.4e-05 -4.41
9247          FUCA1       1_17     0.954    28.76 8.0e-05  5.36
10816          MBD5       2_88     0.950   114.28 3.2e-04 11.58
11271 RP11-274B18.4       9_30     0.948    37.19 1.0e-04  7.45
5939           BIN3       8_23     0.938    58.33 1.6e-04 -7.76
12181         EGLN2      19_30     0.936    24.61 6.7e-05 -4.86
6183       FAM177A1       14_9     0.935    26.82 7.3e-05 -5.26
2782             C7       5_27     0.926    23.13 6.2e-05  4.26
1693           PTK6      20_37     0.914    55.28 1.5e-04 -7.40
4564          PSRC1       1_67     0.907   116.07 3.1e-04 11.10
23             M6PR       12_9     0.900    21.95 5.7e-05 -4.10
1433           PALM       19_2     0.891    21.70 5.6e-05  3.99
9106         PNPLA2       11_1     0.886    21.13 5.4e-05 -4.55
9540        COL18A1      21_23     0.881    32.90 8.4e-05 -5.87
10557        MAN1A2       1_72     0.850    22.56 5.6e-05  4.37
8021           FADD      11_39     0.828    30.19 7.3e-05 -5.15
8866            ABO       9_70     0.826    28.63 6.9e-05  6.43

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 25335.61 0.0000 -13.43
1980     FCGRT      19_34     0.999 14001.37 0.0410   3.17
168      SPRTN      1_118     0.000 13307.64 0.0000   4.87
10381    ZGPAT      20_38     0.000 10070.55 0.0000   5.41
4733      AHI1       6_89     0.000  9908.69 0.0000  -2.01
3138     EXOC8      1_118     0.000  9550.60 0.0000   3.37
1699    ARFRP1      20_38     0.000  9243.26 0.0000  -2.37
10436    STMN3      20_38     0.000  7605.90 0.0000   4.86
11094     APTR       7_49     0.000  4894.91 0.0000  -3.02
5520      RCN3      19_34     0.000  4469.32 0.0000   3.07
1694     GMEB2      20_38     0.000  4226.51 0.0000  -4.55
8332      MGMT      10_81     0.630  3239.13 0.0059   6.97
11906    RTEL1      20_38     0.000  2795.24 0.0000   1.50
8603     ZMAT3      3_110     0.000  2209.38 0.0000  -1.78
3140     TSNAX      1_118     0.000  1855.72 0.0000   2.75
98       PHTF2       7_49     0.000  1553.17 0.0000  -3.12
7145     DISC1      1_118     0.000  1127.17 0.0000  -2.86
8165     CPT1C      19_34     0.000  1011.26 0.0000  -3.22
8416    KCNMB3      3_110     0.000   988.51 0.0000   0.31
11612 TNFRSF6B      20_38     0.000   701.18 0.0000   1.76

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
1980          FCGRT      19_34     0.999 14001.37 4.1e-02  3.17
8332           MGMT      10_81     0.630  3239.13 5.9e-03  6.97
8497       SPATA5L1      15_17     0.310   451.96 4.1e-04 25.90
10816          MBD5       2_88     0.950   114.28 3.2e-04 11.58
4564          PSRC1       1_67     0.907   116.07 3.1e-04 11.10
9813           MUC1       1_77     1.000    90.14 2.6e-04 -7.02
10765       ZDHHC18       1_18     0.999    75.48 2.2e-04 -8.72
982          CDC14A       1_61     0.973    69.67 2.0e-04 -8.40
10711       L3MBTL3       6_86     0.763    85.30 1.9e-04  9.36
5939           BIN3       8_23     0.938    58.33 1.6e-04 -7.76
1693           PTK6      20_37     0.914    55.28 1.5e-04 -7.40
6117           TBX6      16_24     1.000    47.19 1.4e-04  6.38
5657           ACP1        2_1     0.687    56.30 1.1e-04 -7.38
5095        DNAJC13       3_82     0.977    37.97 1.1e-04 -6.22
11271 RP11-274B18.4       9_30     0.948    37.19 1.0e-04  7.45
4947          CNPY3       6_33     0.637    48.51 9.0e-05 -4.51
9054          WDR73      15_39     0.661    46.96 9.0e-05  6.83
9540        COL18A1      21_23     0.881    32.90 8.4e-05 -5.87
7091           NEXN       1_48     0.502    56.33 8.2e-05  7.67
9247          FUCA1       1_17     0.954    28.76 8.0e-05  5.36

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
8497       SPATA5L1      15_17     0.310   451.96 4.1e-04  25.90
8498           GATM      15_17     0.003   241.79 2.4e-06 -17.70
3821           MED1      17_23     0.038   174.93 1.9e-05 -15.68
3060          ALMS1       2_48     0.019   196.46 1.1e-05 -14.49
4687         TMEM60       7_49     0.000 25335.61 0.0e+00 -13.43
5464           PNMT      17_23     0.002   133.15 6.7e-07 -13.08
271          SLC7A9      19_23     0.002   101.08 6.2e-07 -12.59
12374 RP11-434P11.2       2_48     0.019   132.23 7.2e-06 -11.86
1740           PIGU      20_21     0.012    83.60 2.9e-06  11.67
10816          MBD5       2_88     0.950   114.28 3.2e-04  11.58
4564          PSRC1       1_67     0.907   116.07 3.1e-04  11.10
3467           TBX2      17_36     0.014    92.13 3.6e-06 -10.94
7865         FBXO22      15_35     0.207    63.83 3.8e-05  10.62
6970          PGAP3      17_23     0.000    72.27 9.1e-08 -10.23
2868          TFDP2       3_87     0.000    37.15 2.6e-08  10.06
6290        ZFP36L2       2_27     0.030    79.10 7.0e-06 -10.04
8173          LMAN2      5_106     0.037    56.80 6.1e-06  10.04
5463          MIEN1      17_23     0.000    68.80 8.3e-08  10.04
5312         MAN2C1      15_35     0.000   102.05 1.7e-08   9.89
8194          SNUPN      15_35     0.000   105.62 5.7e-09   9.66

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.03325822
#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
8497       SPATA5L1      15_17     0.310   451.96 4.1e-04  25.90
8498           GATM      15_17     0.003   241.79 2.4e-06 -17.70
3821           MED1      17_23     0.038   174.93 1.9e-05 -15.68
3060          ALMS1       2_48     0.019   196.46 1.1e-05 -14.49
4687         TMEM60       7_49     0.000 25335.61 0.0e+00 -13.43
5464           PNMT      17_23     0.002   133.15 6.7e-07 -13.08
271          SLC7A9      19_23     0.002   101.08 6.2e-07 -12.59
12374 RP11-434P11.2       2_48     0.019   132.23 7.2e-06 -11.86
1740           PIGU      20_21     0.012    83.60 2.9e-06  11.67
10816          MBD5       2_88     0.950   114.28 3.2e-04  11.58
4564          PSRC1       1_67     0.907   116.07 3.1e-04  11.10
3467           TBX2      17_36     0.014    92.13 3.6e-06 -10.94
7865         FBXO22      15_35     0.207    63.83 3.8e-05  10.62
6970          PGAP3      17_23     0.000    72.27 9.1e-08 -10.23
2868          TFDP2       3_87     0.000    37.15 2.6e-08  10.06
6290        ZFP36L2       2_27     0.030    79.10 7.0e-06 -10.04
8173          LMAN2      5_106     0.037    56.80 6.1e-06  10.04
5463          MIEN1      17_23     0.000    68.80 8.3e-08  10.04
5312         MAN2C1      15_35     0.000   102.05 1.7e-08   9.89
8194          SNUPN      15_35     0.000   105.62 5.7e-09   9.66

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: 15_17"
           genename region_tag susie_pip    mu2     PVE      z
7782          CASC4      15_17     0.010  14.27 4.0e-07   2.28
11335         PATL2      15_17     0.005  12.63 1.7e-07   2.44
7780            B2M      15_17     0.003   5.11 5.0e-08  -0.44
9861         TRIM69      15_17     0.003   5.83 5.7e-08   1.11
5293           SORD      15_17     0.056  23.28 3.8e-06  -3.09
5042          DUOX1      15_17     0.006  17.61 3.2e-07  -5.32
8498           GATM      15_17     0.003 241.79 2.4e-06 -17.70
8497       SPATA5L1      15_17     0.310 451.96 4.1e-04  25.90
12481  RP11-96O20.5      15_17     0.004  38.41 4.2e-07   2.50
5023          SQRDL      15_17     0.004   5.22 5.4e-08   0.50
12408 CTD-2306A12.1      15_17     0.010  31.20 9.4e-07   5.28

Version Author Date
dfd2b5f wesleycrouse 2021-09-07
[1] "Region: 17_23"
           genename region_tag susie_pip    mu2     PVE      z
12395          EPOP      17_23     0.005  35.90 5.3e-07  -3.51
12545   CTB-58E17.1      17_23     0.005  34.74 4.5e-07  -3.48
12454         MLLT6      17_23     0.008  40.47 9.3e-07  -3.69
12546         CISD3      17_23     0.003  27.26 2.1e-07   2.77
12530         PCGF2      17_23     0.000   6.00 6.4e-09  -1.26
12543         PSMB3      17_23     0.000   4.98 5.3e-09   0.62
12506       PIP4K2B      17_23     0.000   7.66 1.1e-08  -0.81
12393         CWC25      17_23     0.000   5.87 6.5e-09   0.27
20            LASP1      17_23     0.000   6.74 7.9e-09  -1.52
12077     LINC00672      17_23     0.007  31.64 6.4e-07  -4.96
6969         PLXDC1      17_23     0.000   6.86 7.2e-09  -0.78
5465          STAC2      17_23     0.001  12.94 3.0e-08  -1.89
3821           MED1      17_23     0.038 174.93 1.9e-05 -15.68
12394 RP11-390P24.1      17_23     0.000  28.76 3.6e-08   5.92
4321        PPP1R1B      17_23     0.001  68.68 1.5e-07  -8.73
4319         STARD3      17_23     0.000  16.86 1.8e-08   3.95
8762           TCAP      17_23     0.001  14.12 2.8e-08   2.43
5464           PNMT      17_23     0.002 133.15 6.7e-07 -13.08
5461          ERBB2      17_23     0.000  51.46 5.4e-08  -8.54
6970          PGAP3      17_23     0.000  72.27 9.1e-08 -10.23
5463          MIEN1      17_23     0.000  68.80 8.3e-08  10.04
5462           GRB7      17_23     0.136  30.22 1.2e-05  -6.69
831           GSDMB      17_23     0.000  33.35 3.7e-08  -7.83
8537         ORMDL3      17_23     0.000  30.46 3.3e-08  -7.37
7994          GSDMA      17_23     0.000   6.81 8.7e-09   3.38
2359          PSMD3      17_23     0.001  20.30 7.9e-08   2.06
154           MED24      17_23     0.001   9.00 1.5e-08  -2.03
3899           THRA      17_23     0.000  13.13 1.4e-08   3.20
3900          NR1D1      17_23     0.003  25.99 2.3e-07  -1.84
2360          CASC3      17_23     0.468  29.43 4.0e-05   3.06
2361       RAPGEFL1      17_23     0.006  19.68 3.2e-07  -1.95
8464          WIPF2      17_23     0.000   5.94 6.6e-09  -1.34
1346           CDC6      17_23     0.000   5.56 7.0e-09   0.33
4320           RARA      17_23     0.005  30.69 4.3e-07  -2.11
5466         IGFBP4      17_23     0.007  19.77 3.8e-07  -2.96
4318           TNS4      17_23     0.009  27.00 6.8e-07   2.82
830         SMARCE1      17_23     0.001  13.94 4.4e-08   1.51

Version Author Date
dfd2b5f wesleycrouse 2021-09-07
[1] "Region: 2_48"
           genename region_tag susie_pip    mu2     PVE      z
4742      RAB11FIP5       2_48     0.008  11.19 2.5e-07  -2.41
4743          SMYD5       2_48     0.009   7.50 2.0e-07  -1.29
4739         PRADC1       2_48     0.012  22.12 7.8e-07   3.79
4741           CCT7       2_48     0.012  22.12 7.8e-07   3.79
7156         FBXO41       2_48     0.008   5.71 1.3e-07  -0.92
3060          ALMS1       2_48     0.019 196.46 1.1e-05 -14.49
5699          TPRKB       2_48     0.010   8.59 2.5e-07  -1.39
12374 RP11-434P11.2       2_48     0.019 132.23 7.2e-06 -11.86
3708         STAMBP       2_48     0.025  28.91 2.1e-06   4.11
7157          ACTG2       2_48     0.012   8.53 3.0e-07   0.34
2928          DGUOK       2_48     0.008   5.17 1.2e-07  -0.39
11157  RP11-287D1.4       2_48     0.078  28.29 6.4e-06  -2.99
2929          MOB1A       2_48     0.023  15.05 1.0e-06  -1.83
648          MTHFD2       2_48     0.008   5.34 1.3e-07  -0.56
10123        SLC4A5       2_48     0.011   7.56 2.4e-07  -0.49
10870         DCTN1       2_48     0.010   6.65 2.0e-07   0.04
70            WDR54       2_48     0.133  19.73 7.6e-06  -3.57
12621       C2orf81       2_48     0.133  19.73 7.6e-06  -3.57
2931           RTKN       2_48     0.009   9.79 2.6e-07  -2.18
2963         INO80B       2_48     0.029  15.36 1.3e-06   3.06
11530          WBP1       2_48     0.036  18.65 1.9e-06   3.19
2964           MOGS       2_48     0.008   5.29 1.2e-07  -1.00
2965          TTC31       2_48     0.145  19.51 8.2e-06  -3.62
4745        CCDC142       2_48     0.145  19.51 8.2e-06   3.62
9269           LBX2       2_48     0.302  21.70 1.9e-05  -3.81
2966          PCGF1       2_48     0.015  11.11 4.7e-07   1.27
5702           DQX1       2_48     0.016  12.02 5.6e-07   0.80
2972          HTRA2       2_48     0.008   7.00 1.6e-07   1.13
2973          LOXL3       2_48     0.012   8.61 3.0e-07   0.94
2974           DOK1       2_48     0.012   8.50 2.9e-07   0.88
6778           M1AP       2_48     0.012   8.04 2.7e-07   0.62
4740         SEMA4F       2_48     0.008   5.35 1.3e-07  -0.26
6781            HK2       2_48     0.008   4.83 1.1e-07  -0.13
2976          POLE4       2_48     0.021  14.67 8.9e-07  -1.78
10866     LINC01291       2_48     0.016  12.51 6.0e-07  -1.66

Version Author Date
dfd2b5f wesleycrouse 2021-09-07
[1] "Region: 7_49"
      genename region_tag susie_pip      mu2 PVE      z
4686   CCDC146       7_49         0    11.98   0  -1.47
3992      FGL2       7_49         0   118.44   0  -1.89
9888      GSAP       7_49         0    31.81   0  -0.02
3990    PTPN12       7_49         0   321.86   0  -2.99
11094     APTR       7_49         0  4894.91   0  -3.02
4687    TMEM60       7_49         0 25335.61   0 -13.43
98       PHTF2       7_49         0  1553.17   0  -3.12

Version Author Date
dfd2b5f wesleycrouse 2021-09-07
[1] "Region: 19_23"
          genename region_tag susie_pip    mu2     PVE      z
8119        ZNF507      19_23     0.001   8.33 3.4e-08   0.81
9215       DPY19L3      19_23     0.002   9.98 4.5e-08   1.36
2030         PDCD5      19_23     0.099  30.97 8.9e-06  -0.72
2031       ANKRD27      19_23     0.005  35.16 5.3e-07   5.40
11069       NUDT19      19_23     0.012  25.27 9.0e-07  -1.64
12135 CTD-2538C1.2      19_23     0.003  39.67 3.7e-07  -5.90
271         SLC7A9      19_23     0.002 101.08 6.2e-07 -12.59
912        GPATCH1      19_23     0.001   7.41 2.4e-08   1.51
4335        FAAP24      19_23     0.001  15.72 4.8e-08   5.31
3475         CEP89      19_23     0.001  16.20 5.1e-08   4.13
4333         RHPN2      19_23     0.004  17.42 1.8e-07  -1.31
4249          LRP3      19_23     0.001   8.73 3.0e-08  -0.70
7728         WDR88      19_23     0.002  14.17 8.5e-08  -1.25
4248       SLC7A10      19_23     0.001   7.98 3.1e-08   0.66
11668        CEBPA      19_23     0.001   5.70 1.8e-08   0.28
6370         CEBPG      19_23     0.002  10.60 6.9e-08   0.72
3706          PEPD      19_23     0.003  12.82 1.1e-07  -1.32
3707         CHST8      19_23     0.152  39.11 1.7e-05   3.17

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
30942    rs61818825       1_69     1.000   154.78 4.5e-04  12.64
38249     rs9425587       1_84     1.000    41.88 1.2e-04   6.25
41811    rs79091515       1_92     1.000    79.73 2.3e-04   9.80
54821      rs287613      1_116     1.000   765.18 2.2e-03  -3.26
54827    rs71180790      1_116     1.000   756.90 2.2e-03  -3.16
55787   rs766167074      1_118     1.000 14204.25 4.1e-02  -4.30
70934      rs780093       2_16     1.000   180.99 5.3e-04  17.73
70935     rs6744393       2_16     1.000    80.80 2.3e-04  12.12
77784    rs11689011       2_29     1.000    38.12 1.1e-04  -5.98
96134    rs11123169       2_67     1.000    73.72 2.1e-04  -8.05
98214   rs141849010       2_69     1.000    54.77 1.6e-04   7.31
111772    rs7565788      2_103     1.000    65.17 1.9e-04   9.30
114127     rs863678      2_106     1.000   167.24 4.9e-04  11.18
123499   rs11887861      2_124     1.000   304.88 8.9e-04 -11.03
188766  rs146797780      3_110     1.000 10967.96 3.2e-02   2.47
188767    rs7636471      3_110     1.000 10985.80 3.2e-02   2.53
193387    rs7642977      3_118     1.000    51.62 1.5e-04   7.37
212377   rs66998340       4_36     1.000  1259.35 3.7e-03  -3.18
259108     rs386057        5_1     1.000    58.66 1.7e-04  -7.24
259254   rs62331274        5_2     1.000    44.21 1.3e-04   6.71
280051   rs11743158       5_41     1.000   109.93 3.2e-04  10.79
313352   rs35716097      5_106     1.000   179.83 5.2e-04  18.22
313355    rs7447593      5_106     1.000   214.92 6.2e-04  19.58
317575   rs13193887        6_7     1.000    99.64 2.9e-04  10.02
324171   rs62394272       6_20     1.000    75.38 2.2e-04  -9.05
329064   rs56144236       6_27     1.000    47.57 1.4e-04  -4.54
331864   rs10223666       6_34     1.000   253.90 7.4e-04  16.43
360794  rs199804242       6_89     1.000 44599.12 1.3e-01   5.05
367762    rs3119311      6_104     1.000 47841.01 1.4e-01  16.16
367803   rs60425481      6_104     1.000 65229.65 1.9e-01   2.37
372265   rs78148157        7_3     1.000   214.43 6.2e-04 -11.39
372266   rs13241427        7_3     1.000   196.95 5.7e-04  12.32
388851     rs700752       7_34     1.000   126.18 3.7e-04  10.76
397908   rs10277379       7_49     1.000 43077.45 1.3e-01  12.60
397911  rs761767938       7_49     1.000 55686.95 1.6e-01  11.05
397919    rs1544459       7_49     1.000 55059.40 1.6e-01  11.28
427517       rs2428       8_11     1.000   753.56 2.2e-03  -8.02
427522  rs758184196       8_11     1.000   745.28 2.2e-03   2.64
427776    rs7012814       8_12     1.000    79.57 2.3e-04 -10.88
434136    rs4871905       8_24     1.000   229.84 6.7e-04  16.47
463421    rs6996786       8_84     1.000  3786.74 1.1e-02   1.60
463428  rs200311702       8_84     1.000  3697.65 1.1e-02   3.90
468898   rs72693377       8_94     1.000    50.94 1.5e-04   7.24
503275    rs1886296       9_73     1.000    45.88 1.3e-04  -3.91
503288   rs12380852       9_73     1.000    44.52 1.3e-04   4.33
503768  rs113790047       10_3     1.000   138.76 4.0e-04  12.47
520275   rs35182775      10_33     1.000   104.73 3.0e-04 -10.82
535865    rs1408345      10_64     1.000    37.09 1.1e-04   5.68
546578     rs231889       11_2     1.000    59.24 1.7e-04  -8.73
556802  rs369062552      11_21     1.000   317.92 9.2e-04  15.06
556812   rs34830202      11_21     1.000   353.93 1.0e-03 -16.29
567315   rs72917317      11_38     1.000    72.62 2.1e-04  -7.67
588638    rs3782860       12_1     1.000   196.99 5.7e-04  12.41
592217   rs11616030      12_11     1.000    58.10 1.7e-04  -7.64
593242   rs11056397      12_13     1.000    48.27 1.4e-04  -6.76
604943    rs2682323      12_33     1.000    56.69 1.6e-04  -7.02
605957    rs7397189      12_36     1.000    74.22 2.2e-04  -8.81
640719    rs7325692      13_21     1.000   356.93 1.0e-03  -4.38
640735  rs577954961      13_21     1.000   337.10 9.8e-04  -1.94
640869    rs1326122      13_21     1.000    68.36 2.0e-04   8.48
671262   rs72681869      14_20     1.000    63.64 1.8e-04  -8.12
704614    rs2472297      15_35     1.000   119.56 3.5e-04 -11.99
704856  rs145727191      15_35     1.000    79.42 2.3e-04  11.21
704885    rs2955742      15_36     1.000    63.21 1.8e-04   8.90
706403    rs7174325      15_38     1.000    37.27 1.1e-04   5.72
714086  rs138922864       16_3     1.000    42.53 1.2e-04   6.32
724857   rs12927956      16_27     1.000   117.34 3.4e-04   9.37
730882    rs7187317      16_40     1.000    45.91 1.3e-04   5.50
744611  rs139356332      17_16     1.000    52.09 1.5e-04   8.03
744623    rs7222869      17_16     1.000    43.38 1.3e-04  -8.09
748270   rs12453645      17_23     1.000    84.03 2.4e-04  13.02
753957    rs3032584      17_35     1.000   246.27 7.2e-04  16.69
754015   rs11650989      17_36     1.000   244.55 7.1e-04 -19.89
768352     rs162000      18_14     1.000    59.07 1.7e-04   7.75
774726    rs2878889      18_27     1.000    45.17 1.3e-04  -6.53
796338   rs11084684      19_23     1.000    86.62 2.5e-04   9.12
797391    rs1137844      19_24     1.000    64.12 1.9e-04  -8.09
798992     rs814573      19_31     1.000    71.98 2.1e-04  -8.73
819086     rs209955      20_32     1.000    63.71 1.9e-04   8.91
819090    rs2585441      20_32     1.000    82.94 2.4e-04   9.27
819113    rs6068816      20_32     1.000    43.21 1.3e-04  -6.75
820301    rs6025623      20_33     1.000    48.73 1.4e-04   7.26
837382    rs2103861       22_9     1.000    34.92 1.0e-04  -5.69
919036   rs57751786       6_32     1.000  2248.62 6.5e-03   2.80
935867   rs73025562      6_103     1.000   105.99 3.1e-04  -5.85
997442  rs201524046      10_81     1.000 17288.34 5.0e-02  -6.50
997461  rs568584257      10_81     1.000 17229.70 5.0e-02  -2.04
1068185 rs374141296      19_34     1.000 14014.15 4.1e-02  -3.31
1078141 rs202143810      20_38     1.000 13977.63 4.1e-02  -6.50
126296  rs112068790      2_129     0.999    37.66 1.1e-04  -7.53
198929    rs4533774       4_11     0.999    46.60 1.4e-04   6.65
221337  rs111470070       4_52     0.999    49.91 1.4e-04   5.66
230294    rs2903386       4_69     0.999    43.35 1.3e-04  -5.51
327674  rs116339629       6_26     0.999    51.11 1.5e-04  -5.78
427516  rs117209427       8_11     0.999    45.54 1.3e-04   1.60
830211     rs219783      21_16     0.999    53.89 1.6e-04  -7.26
1068182 rs113176985      19_34     0.999 13925.53 4.0e-02  -3.09
346879     rs854922       6_61     0.998    31.81 9.2e-05   4.64
503283   rs72773787       9_73     0.998    41.58 1.2e-04   4.15
730868   rs62053193      16_40     0.998    36.39 1.1e-04   4.57
197268  rs115976359        4_7     0.997    29.88 8.7e-05  -5.34
334386   rs76572975       6_39     0.997    37.23 1.1e-04  -7.13
546375   rs17885785       11_2     0.997    85.17 2.5e-04   8.76
546576  rs186376420       11_2     0.997    47.52 1.4e-04  -7.99
791998   rs35218652      19_15     0.997    53.77 1.6e-04   5.10
969980  rs142540788       9_50     0.997    35.19 1.0e-04  -5.60
15966     rs2474382       1_38     0.996    29.38 8.5e-05  -5.51
27507    rs12407689       1_62     0.996    33.06 9.6e-05   5.50
30939    rs78366259       1_69     0.996    31.55 9.1e-05   4.65
526457   rs72797524      10_46     0.996    30.86 8.9e-05  -5.41
271236    rs4703440       5_23     0.995    53.87 1.6e-04   7.02
482381   rs56030777       9_25     0.995    31.30 9.1e-05   4.66
755927    rs8072180      17_39     0.995    60.54 1.8e-04   8.03
813325   rs34106705      20_20     0.995    41.78 1.2e-04   6.72
126305    rs6747041      2_129     0.994    96.73 2.8e-04 -11.00
420885     rs288762       7_97     0.994   115.37 3.3e-04  10.61
687095   rs75432828      14_52     0.993    55.80 1.6e-04   7.71
695820   rs74009639      15_17     0.993   177.64 5.1e-04  11.23
322116    rs3763278       6_15     0.992    34.68 1.0e-04   5.03
191198   rs13069721      3_115     0.991    42.07 1.2e-04  -6.50
428015   rs10093915       8_13     0.990    62.99 1.8e-04   9.30
748148     rs530253      17_23     0.990    35.04 1.0e-04  -6.36
948634   rs11557049       8_50     0.990    63.33 1.8e-04   7.79
360153    rs9373056       6_88     0.989    54.71 1.6e-04  -8.43
272748   rs17395128       5_26     0.988    33.79 9.7e-05  -5.73
369985    rs1445288      6_108     0.988    31.05 8.9e-05   5.37
427330    rs2976846       8_11     0.988   247.27 7.1e-04  -8.89
739946    rs4790812       17_2     0.988    28.48 8.2e-05   5.01
194149   rs13059257      3_120     0.987    70.44 2.0e-04   7.67
210730   rs11732881       4_34     0.987    39.69 1.1e-04  -5.92
739032   rs34404057      16_54     0.987    90.83 2.6e-04   8.82
102959    rs7602029       2_81     0.985    42.35 1.2e-04   6.84
271346   rs11740818       5_23     0.985    32.43 9.3e-05  -5.28
275538  rs113088001       5_31     0.985    56.40 1.6e-04  -9.88
820243    rs6099616      20_33     0.985    29.78 8.5e-05   5.82
242660  rs115900720       4_94     0.984    28.03 8.0e-05  -4.91
436874   rs12544558       8_31     0.984    58.58 1.7e-04  -6.14
566474    rs4601790      11_36     0.983    58.52 1.7e-04   2.39
744637   rs56700256      17_16     0.983    26.63 7.6e-05   4.85
166732    rs7640740       3_66     0.982    33.90 9.7e-05  -5.61
750262  rs137906947      17_27     0.982    29.69 8.5e-05   5.17
406117     rs543883       7_65     0.980    26.98 7.7e-05   4.94
699701   rs11855136      15_25     0.978    27.41 7.8e-05   4.96
589633   rs12370932       12_3     0.977    33.32 9.5e-05  -4.53
721061    rs9933330      16_19     0.976   542.73 1.5e-03 -24.08
80905     rs3106204       2_36     0.975    57.19 1.6e-04   7.63
148130     rs811970       3_28     0.975    29.63 8.4e-05  -5.18
52660    rs61830291      1_112     0.974    74.25 2.1e-04  -8.72
676420    rs1997896      14_33     0.974    39.18 1.1e-04  -5.79
482677   rs11557154       9_27     0.972    35.69 1.0e-04  -6.02
110237    rs4667700       2_99     0.970    26.19 7.4e-05  -4.74
612436    rs1848968      12_48     0.970    39.48 1.1e-04  -6.17
843546   rs28477160      22_20     0.970    27.02 7.6e-05   4.16
470051    rs1538532        9_3     0.969    25.54 7.2e-05   4.74
838106     rs740219      22_10     0.967    35.78 1.0e-04  -3.87
412508    rs3757387       7_79     0.966    51.23 1.4e-04   8.53
490258    rs1360200       9_45     0.966    29.89 8.4e-05  -5.32
275537    rs1694060       5_31     0.965    49.91 1.4e-04  -7.45
779328  rs532969215      18_35     0.964    25.75 7.2e-05  -4.81
420946    rs6459970       7_97     0.963    31.24 8.7e-05   5.84
684369    rs8013584      14_47     0.962    27.96 7.8e-05   5.85
14356     rs1331858       1_35     0.961    58.26 1.6e-04  -7.81
454393   rs28628213       8_67     0.961    26.15 7.3e-05   4.73
800242     rs281380      19_33     0.961    50.26 1.4e-04  -6.97
660746     rs750598      13_59     0.960    60.12 1.7e-04   7.90
111802    rs7594986      2_103     0.959    46.98 1.3e-04   8.14
362706   rs12216122       6_94     0.959    28.16 7.8e-05   4.96
150989  rs146456061       3_35     0.958    29.91 8.3e-05  -4.46
498516   rs10817912       9_60     0.958    66.14 1.8e-04  -7.47
749763    rs2074292      17_27     0.958    32.01 8.9e-05  -5.39
387213   rs11761217       7_30     0.957    25.62 7.1e-05   4.63
842070   rs13055886      22_18     0.957    58.55 1.6e-04   6.98
76648    rs13428381       2_27     0.956    63.39 1.8e-04  -8.30
116068   rs11690832      2_110     0.955    35.03 9.7e-05   6.62
514890   rs11007559      10_21     0.954    34.63 9.6e-05   5.82
540294    rs1932558      10_73     0.954    26.03 7.2e-05   4.86
22386     rs6661091       1_50     0.949    78.81 2.2e-04   8.98
1028420 rs117139138      15_39     0.947    31.44 8.7e-05   4.96
382347   rs67971665       7_23     0.946    43.63 1.2e-04  -6.48
576675   rs10892860      11_57     0.946    26.81 7.4e-05   4.92
447742    rs2941452       8_55     0.940    38.60 1.1e-04  -5.34
798113    rs2228068      19_26     0.940    30.23 8.3e-05  -3.70
317481    rs9378483        6_7     0.938    25.11 6.8e-05  -3.71
273000    rs4957118       5_26     0.937    40.08 1.1e-04   7.31
841940   rs12484310      22_18     0.936    26.41 7.2e-05   4.72
561600   rs10219383      11_28     0.935    25.95 7.1e-05  -4.87
997445   rs74160216      10_81     0.935 17223.42 4.7e-02  -2.10
125727    rs2068218      2_128     0.928    24.41 6.6e-05  -4.13
52382      rs884127      1_112     0.927    27.49 7.4e-05  -4.85
360810    rs6923513       6_89     0.926 44673.08 1.2e-01   5.13
715474  rs148361522       16_6     0.926    24.13 6.5e-05  -4.50
807324    rs7264882       20_8     0.925    28.91 7.8e-05   5.18
259111  rs185228153        5_1     0.924    27.28 7.3e-05   3.20
284117  rs115912456       5_49     0.922    23.45 6.3e-05   4.43
150664  rs116643069       3_35     0.921    29.76 8.0e-05   3.37
447716    rs2672853       8_55     0.921    27.21 7.3e-05  -4.11
590057   rs78470967       12_5     0.919    25.38 6.8e-05  -5.22
110208   rs75483173       2_98     0.917    25.42 6.8e-05  -4.66
75661    rs13418726       2_26     0.916    34.00 9.1e-05  -5.70
304083    rs1800888       5_87     0.916    23.70 6.3e-05  -4.09
537928    rs2050996      10_69     0.916    35.77 9.5e-05   5.81
467810   rs56114972       8_92     0.911    24.26 6.4e-05  -4.15
704886  rs143214734      15_36     0.910    25.17 6.7e-05   4.16
421206    rs2530736       7_98     0.909    37.49 9.9e-05   5.99
885901    rs3806357      1_102     0.909    43.29 1.1e-04   5.28
586128    rs3935795      11_80     0.908    26.71 7.0e-05   5.10
604024    rs1878234      12_31     0.908    26.73 7.1e-05  -4.48
186148    rs6770214      3_105     0.907    24.69 6.5e-05  -4.59
359581    rs7753497       6_87     0.907    37.65 9.9e-05   7.44
738917  rs117652610      16_54     0.907    36.65 9.7e-05  -5.48
706802   rs28587782      15_38     0.906    45.82 1.2e-04   7.38
589697   rs79997404       12_3     0.905   110.48 2.9e-04  10.75
210069     rs278933       4_33     0.903    25.87 6.8e-05   4.71
352691    rs9285397       6_73     0.903    77.76 2.0e-04  -9.26
26002   rs138475481       1_58     0.901    37.95 9.9e-05   6.48
286216    rs3952745       5_53     0.901    25.55 6.7e-05  -5.13
790305   rs10854127      19_11     0.901    45.41 1.2e-04   6.60
744635    rs7224838      17_16     0.900    39.14 1.0e-04   6.57
231858    rs6533522       4_72     0.899    24.73 6.5e-05  -4.53
694439   rs62006522      15_13     0.898    24.68 6.4e-05  -3.68
721054    rs9923532      16_19     0.898   197.49 5.2e-04  10.53
317620    rs2842369        6_7     0.897    28.45 7.4e-05   5.18
421147  rs118063067       7_98     0.897    63.14 1.6e-04  -7.44
243619   rs10013413       4_96     0.896    32.40 8.4e-05  -5.40
557630    rs7938708      11_22     0.891    24.53 6.4e-05   4.40
365724    rs6939382       6_99     0.890    24.26 6.3e-05   4.35
586094    rs6590328      11_80     0.886    36.02 9.3e-05  -5.90
80810    rs10182366       2_36     0.885    57.31 1.5e-04  -7.54
724691    rs7205341      16_27     0.885    39.03 1.0e-04   5.97
434126     rs310311       8_24     0.877    88.97 2.3e-04 -11.91
792235    rs3794991      19_15     0.876    49.26 1.3e-04   7.01
397345      rs17685       7_48     0.875    85.96 2.2e-04  -9.47
636527    rs1539547      13_13     0.873    23.76 6.0e-05  -4.39
60782     rs1148917      1_130     0.872    25.42 6.4e-05   4.68
150364   rs73083115       3_33     0.872    25.60 6.5e-05   2.94
745665  rs117859452      17_18     0.872    26.23 6.6e-05   4.54
351301    rs6571142       6_70     0.870    24.01 6.1e-05  -4.35
114187   rs72940807      2_106     0.869    39.91 1.0e-04   8.03
711595   rs59646751      15_48     0.867    67.44 1.7e-04   8.23
128408   rs13029395      2_133     0.865    30.38 7.6e-05  -5.65
301424   rs62383025       5_82     0.864    29.82 7.5e-05   5.45
203955   rs61359609       4_20     0.863    39.72 1.0e-04  -6.41
491447    rs2185973       9_47     0.860    27.74 6.9e-05  -4.82
577259     rs625505      11_58     0.860    24.49 6.1e-05  -4.42
142780     rs697025       3_17     0.856    25.26 6.3e-05  -4.67
471010   rs10974435        9_4     0.854    33.52 8.3e-05  -6.63
7412       rs641452       1_16     0.852    46.23 1.1e-04  -7.05
360260    rs2327426       6_88     0.852    47.82 1.2e-04   6.61
96069     rs3811056       2_66     0.851    28.30 7.0e-05   4.73
694814   rs75855252      15_14     0.851    23.99 5.9e-05  -4.04
230283   rs57251748       4_69     0.850    25.89 6.4e-05  -2.91
46765   rs145759918      1_101     0.849    25.83 6.4e-05  -4.94
111834    rs6433115      2_103     0.848    29.09 7.2e-05  -5.77
31023   rs142669954       1_70     0.845    27.92 6.9e-05   5.24
625488   rs80019595      12_74     0.843    53.36 1.3e-04   7.36
613280    rs7137360      12_50     0.840    44.66 1.1e-04   6.48
47757    rs12024377      1_104     0.835    32.76 8.0e-05  -5.36
694989    rs4419033      15_15     0.835   117.17 2.8e-04  10.88
114860   rs12464787      2_108     0.834    30.20 7.3e-05   6.39
77558    rs74449116       2_28     0.830    26.02 6.3e-05   4.55
935871     rs662138      6_103     0.828   158.37 3.8e-04  -9.59
11263     rs2484713       1_27     0.827    57.37 1.4e-04   7.58
236752   rs10031936       4_81     0.825    24.23 5.8e-05  -4.32
611597    rs1690139      12_46     0.825    25.39 6.1e-05  -4.26
959298    rs4744712       9_30     0.825   191.72 4.6e-04 -15.18
48107     rs2075864      1_105     0.824    65.74 1.6e-04   8.32
304057    rs6885118       5_87     0.824    25.35 6.1e-05   4.24
359052    rs2326970       6_86     0.823    24.18 5.8e-05  -4.29
693531   rs12908082      15_11     0.822    25.34 6.1e-05  -4.42
98300     rs4241160       2_69     0.820    26.80 6.4e-05   4.31
829363    rs2834321      21_15     0.818    89.05 2.1e-04   9.57
763244     rs940131       18_4     0.816    72.26 1.7e-04   8.61
60212     rs2171975      1_128     0.815    74.60 1.8e-04  -8.72
91382   rs146133332       2_55     0.812    24.68 5.8e-05  -4.30
465011   rs57286830       8_87     0.812    24.90 5.9e-05  -4.38
546371    rs7115054       11_2     0.812    90.10 2.1e-04   8.84
728884    rs7204242      16_35     0.812    26.01 6.1e-05   4.75
736677   rs56404731      16_49     0.812    33.15 7.8e-05  -5.59
330791   rs10947659       6_29     0.811    25.95 6.1e-05   4.50
346875    rs7744005       6_61     0.810    48.05 1.1e-04   6.50
803806     rs535376       20_2     0.810    26.94 6.3e-05   4.72
592078   rs12824533      12_11     0.807    25.59 6.0e-05  -4.56
405058     rs438635       7_63     0.806    59.29 1.4e-04   7.36
152779   rs35364740       3_39     0.805    28.10 6.6e-05   5.00
436242  rs139800483       8_29     0.803    25.68 6.0e-05  -4.62
186467   rs59976239      3_105     0.802    25.00 5.8e-05  -4.41

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
367799   rs3106169      6_104     0.727 65299.07 1.4e-01 10.90
367808   rs3106167      6_104     0.707 65298.74 1.3e-01 10.90
367800   rs3127598      6_104     0.124 65297.69 2.4e-02 10.89
367792  rs11755965      6_104     0.000 65277.12 9.3e-05 10.88
367803  rs60425481      6_104     1.000 65229.65 1.9e-01  2.37
367783  rs12194962      6_104     0.000 65138.10 0.0e+00 10.83
367801   rs3127597      6_104     0.000 65090.06 0.0e+00 10.77
397911 rs761767938       7_49     1.000 55686.95 1.6e-01 11.05
397919   rs1544459       7_49     1.000 55059.40 1.6e-01 11.28
397915  rs11972122       7_49     0.000 50191.90 3.4e-10 10.18
397916  rs11406602       7_49     0.000 50151.29 1.3e-06 10.20
397920   rs1544458       7_49     0.000 49300.08 0.0e+00 10.31
397910   rs6465794       7_49     0.000 48649.90 1.1e-16 10.03
397909   rs6465793       7_49     0.000 48649.24 1.3e-16 10.03
397940  rs10272350       7_49     0.000 48547.02 0.0e+00  9.89
367762   rs3119311      6_104     1.000 47841.01 1.4e-01 16.16
397944   rs2463008       7_49     0.000 46270.92 0.0e+00 10.84
397950  rs10267180       7_49     0.000 46256.79 0.0e+00 10.79
397890  rs13240016       7_49     0.000 46016.51 0.0e+00  9.61
397899   rs7799383       7_49     0.000 44900.07 0.0e+00  9.62
360810   rs6923513       6_89     0.926 44673.08 1.2e-01  5.13
360793   rs2327654       6_89     0.497 44669.12 6.5e-02  5.11
360794 rs199804242       6_89     1.000 44599.12 1.3e-01  5.05
360797 rs113527452       6_89     0.000 44435.59 8.6e-17  5.09
360802 rs200796875       6_89     0.000 44172.54 0.0e+00  4.95
360815   rs7756915       6_89     0.000 43901.26 0.0e+00  5.15
397908  rs10277379       7_49     1.000 43077.45 1.3e-01 12.60
397902   rs7795371       7_49     0.000 42373.83 1.8e-13 12.47
360808   rs6570040       6_89     0.000 42122.91 0.0e+00  4.88
360795   rs6570031       6_89     0.000 42016.05 0.0e+00  4.82
360796   rs9389323       6_89     0.000 41996.95 0.0e+00  4.80
397964    rs848470       7_49     0.000 38010.54 0.0e+00 -8.16
360812   rs9321531       6_89     0.000 36862.30 0.0e+00  4.53
360785   rs9321528       6_89     0.000 36409.70 0.0e+00  5.35
367756   rs3127579      6_104     0.000 35020.27 0.0e+00 17.91
360813   rs9494389       6_89     0.000 34614.86 0.0e+00  4.31
360817   rs5880262       6_89     0.000 34557.75 0.0e+00  4.66
360791   rs2208574       6_89     0.000 33410.58 0.0e+00  4.50
360790   rs1033755       6_89     0.000 33393.74 0.0e+00  4.27
360788   rs2038551       6_89     0.000 32802.19 0.0e+00  5.25
360799   rs9494377       6_89     0.000 32794.31 0.0e+00  4.32
360786   rs2038550       6_89     0.000 32714.39 0.0e+00  5.22
397858   rs9640663       7_49     0.000 32157.23 0.0e+00  8.74
397854   rs2868787       7_49     0.000 32156.75 0.0e+00  8.72
397888  rs58729654       7_49     0.000 31636.52 0.0e+00 10.11
397869   rs4727451       7_49     0.000 31610.83 0.0e+00  8.48
367750  rs10945658      6_104     0.000 30669.92 0.0e+00 18.00
367749   rs3119308      6_104     0.000 30597.65 0.0e+00 18.00
367745   rs3103352      6_104     0.000 30569.41 0.0e+00 17.77
367741   rs3101821      6_104     0.000 30461.44 0.0e+00 17.74

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
367803   rs60425481      6_104     1.000 65229.65 0.1900  2.37
397911  rs761767938       7_49     1.000 55686.95 0.1600 11.05
397919    rs1544459       7_49     1.000 55059.40 0.1600 11.28
367762    rs3119311      6_104     1.000 47841.01 0.1400 16.16
367799    rs3106169      6_104     0.727 65299.07 0.1400 10.90
360794  rs199804242       6_89     1.000 44599.12 0.1300  5.05
367808    rs3106167      6_104     0.707 65298.74 0.1300 10.90
397908   rs10277379       7_49     1.000 43077.45 0.1300 12.60
360810    rs6923513       6_89     0.926 44673.08 0.1200  5.13
360793    rs2327654       6_89     0.497 44669.12 0.0650  5.11
997442  rs201524046      10_81     1.000 17288.34 0.0500 -6.50
997461  rs568584257      10_81     1.000 17229.70 0.0500 -2.04
997445   rs74160216      10_81     0.935 17223.42 0.0470 -2.10
55787   rs766167074      1_118     1.000 14204.25 0.0410 -4.30
1068185 rs374141296      19_34     1.000 14014.15 0.0410 -3.31
1078141 rs202143810      20_38     1.000 13977.63 0.0410 -6.50
1068182 rs113176985      19_34     0.999 13925.53 0.0400 -3.09
188766  rs146797780      3_110     1.000 10967.96 0.0320  2.47
188767    rs7636471      3_110     1.000 10985.80 0.0320  2.53
1078138   rs6089961      20_38     0.666 13797.88 0.0270 -6.78
1078140   rs2738758      20_38     0.666 13797.88 0.0270 -6.78
367800    rs3127598      6_104     0.124 65297.69 0.0240 10.89
1068173  rs61371437      19_34     0.573 13897.49 0.0230 -3.04
55784    rs10489611      1_118     0.465 14114.83 0.0190 -4.67
55778     rs2256908      1_118     0.366 14113.84 0.0150 -4.67
1078121   rs2750483      20_38     0.356 13793.46 0.0140 -6.79
55786      rs971534      1_118     0.288 14114.60 0.0120 -4.65
55785     rs2486737      1_118     0.267 14114.55 0.0110 -4.65
463421    rs6996786       8_84     1.000  3786.74 0.0110  1.60
463428  rs200311702       8_84     1.000  3697.65 0.0110  3.90
55781     rs2790891      1_118     0.250 14113.61 0.0100 -4.66
55782     rs2491405      1_118     0.250 14113.61 0.0100 -4.66
1078119  rs35201382      20_38     0.243 13793.57 0.0097 -6.77
1078120  rs67468102      20_38     0.242 13791.57 0.0097 -6.78
55794     rs2211176      1_118     0.231 14108.98 0.0095 -4.66
55795     rs2790882      1_118     0.231 14108.98 0.0095 -4.66
1068163    rs739349      19_34     0.201 13847.58 0.0081 -3.09
1078116   rs2315009      20_38     0.186 13789.24 0.0075 -6.79
919036   rs57751786       6_32     1.000  2248.62 0.0065  2.80
1068164    rs756628      19_34     0.158 13847.47 0.0064 -3.09
55793     rs2248646      1_118     0.154 14108.16 0.0063 -4.65
55774     rs1076804      1_118     0.122 14093.39 0.0050 -4.68
919038    rs9369250       6_32     0.629  2250.40 0.0041  3.22
212377   rs66998340       4_36     1.000  1259.35 0.0037 -3.18
919025     rs714050       6_32     0.533  2250.13 0.0035  3.21
212380     rs728294       4_36     0.771  1291.25 0.0029 -3.21
212378    rs4359873       4_36     0.728  1291.23 0.0027 -3.21
919033    rs9369249       6_32     0.407  2249.54 0.0027  3.21
54821      rs287613      1_116     1.000   765.18 0.0022 -3.26
54827    rs71180790      1_116     1.000   756.90 0.0022 -3.16

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
695810   rs1145077      15_17     0.372 450.25 4.9e-04  27.01
695807   rs1153855      15_17     0.308 449.62 4.0e-04  27.00
695812   rs1346267      15_17     0.238 448.90 3.1e-04  26.98
695806  rs35410548      15_17     0.084 444.59 1.1e-04  26.89
221456  rs17253722       4_52     0.698 493.38 1.0e-03  26.25
221455  rs60529470       4_52     0.302 491.49 4.3e-04  26.19
695814   rs1145074      15_17     0.373 456.94 5.0e-04  26.09
695809   rs2114501      15_17     0.111 452.61 1.5e-04  26.00
695802   rs4775909      15_17     0.066 451.19 8.6e-05  25.98
695804   rs4625670      15_17     0.056 450.38 7.4e-05  25.96
695803  rs77940260      15_17     0.040 449.26 5.2e-05  25.91
695805   rs3047503      15_17     0.040 449.18 5.2e-05  25.91
695800 rs143910737      15_17     0.013 446.11 1.6e-05  25.78
695811   rs1153852      15_17     0.001 412.73 1.5e-06  25.47
695798  rs35715322      15_17     0.001 392.97 6.9e-07  25.39
695817   rs2433616      15_17     0.001 392.53 1.0e-06  24.72
695799   rs1613559      15_17     0.001 410.04 7.5e-07  24.70
695797  rs12593370      15_17     0.001 403.98 7.2e-07  24.56
221469  rs13146163       4_52     0.001 417.67 7.2e-07  24.33
695796  rs66893308      15_17     0.001 365.84 8.4e-07  24.15
721061   rs9933330      16_19     0.976 542.73 1.5e-03 -24.08
721059  rs28544423      16_19     0.023 535.25 3.6e-05 -23.84
721055  rs35830321      16_19     0.000 521.47 6.1e-10 -23.73
419292  rs10224210       7_94     0.667 520.88 1.0e-03  23.69
419294  rs10224002       7_94     0.335 521.32 5.1e-04  23.66
721056  rs12934320      16_19     0.000 526.28 5.4e-07 -23.62
721058  rs28640218      16_19     0.000 521.39 1.1e-08 -23.54
695795   rs2015295      15_17     0.001 308.19 7.1e-07  22.29
695793  rs11636114      15_17     0.001 301.86 7.7e-07 -22.11
695790  rs77342224      15_17     0.001 298.39 8.0e-07 -21.99
695787  rs12909625      15_17     0.001 276.96 1.0e-06 -21.16
695788  rs12909883      15_17     0.001 277.01 1.0e-06 -21.16
695789   rs8041874      15_17     0.001 276.58 1.0e-06 -21.15
695783  rs11854325      15_17     0.001 270.43 9.7e-07 -20.90
695784  rs11632778      15_17     0.001 270.15 9.9e-07 -20.89
221431  rs72657813       4_52     0.000 285.68 1.1e-07  20.55
221472   rs2068062       4_52     0.000 257.98 4.6e-08  20.55
221473  rs13106227       4_52     0.000 256.92 4.4e-08  20.53
221474  rs11730486       4_52     0.000 256.43 4.4e-08  20.52
221424   rs3839121       4_52     0.000 283.38 9.6e-08  20.51
221475   rs4859683       4_52     0.000 255.55 4.3e-08  20.50
695786  rs12910143      15_17     0.001 291.71 8.2e-07 -20.47
419290  rs66497154       7_94     0.001 381.75 8.3e-07  20.35
221440  rs59795151       4_52     0.000 265.90 6.2e-08  20.13
221476   rs4493564       4_52     0.000 240.48 3.2e-08  20.12
754015  rs11650989      17_36     1.000 244.55 7.1e-04 -19.89
721060   rs7193058      16_19     0.000 425.06 2.8e-10  19.85
272708    rs700231       5_26     0.586 203.85 3.5e-04  19.81
272710    rs700237       5_26     0.404 202.71 2.4e-04  19.79
313355   rs7447593      5_106     1.000 214.92 6.2e-04  19.58

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] 24
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)
MAN1A2 gene(s) from the input list not found in DisGeNET CURATEDFAM177A1 gene(s) from the input list not found in DisGeNET CURATEDRP11-274B18.4 gene(s) from the input list not found in DisGeNET CURATEDFCGRT gene(s) from the input list not found in DisGeNET CURATEDPTK6 gene(s) from the input list not found in DisGeNET CURATEDBIN3 gene(s) from the input list not found in DisGeNET CURATEDZDHHC18 gene(s) from the input list not found in DisGeNET CURATEDPALM gene(s) from the input list not found in DisGeNET CURATEDMEA1 gene(s) from the input list not found in DisGeNET CURATEDPSRC1 gene(s) from the input list not found in DisGeNET CURATED
                                   Description         FDR Ratio BgRatio
15               Fucosidase Deficiency Disease 0.008008658  1/14  1/9703
48                          Fucosidosis Type I 0.008008658  1/14  1/9703
49                         Fucosidosis Type II 0.008008658  1/14  1/9703
50                               Severe myopia 0.008008658  1/14  1/9703
54                  Vitreoretinal degeneration 0.008008658  1/14  1/9703
79            DEAFNESS, AUTOSOMAL RECESSIVE 32 0.008008658  1/14  1/9703
80                           Knobloch syndrome 0.008008658  1/14  1/9703
81 Neutral Lipid Storage Disease with Myopathy 0.008008658  1/14  1/9703
83           Complement Component 7 Deficiency 0.008008658  1/14  1/9703
84           Medullary cystic kidney disease 1 0.008008658  1/14  1/9703
******************************************

*                                        *

*          Welcome to WebGestaltR !      *

*                                        *

******************************************
Loading the functional categories...
Loading the ID list...
Loading the reference list...
Performing the enrichment analysis...
Warning in oraEnrichment(interestGeneList, referenceGeneList, geneSet,
minNum = minNum, : No significant gene set is identified based on FDR 0.05!
NULL

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