Last updated: 2022-03-05

Checks: 5 2

Knit directory: cTWAS_analysis/

This reproducible R Markdown analysis was created with workflowr (version 1.7.0). 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(20211220) 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.

Using absolute paths to the files within your workflowr project makes it difficult for you and others to run your code on a different machine. Change the absolute path(s) below to the suggested relative path(s) to make your code more reproducible.

absolute relative
/project2/xinhe/shengqian/cTWAS/cTWAS_analysis/data/ data
/project2/xinhe/shengqian/cTWAS/cTWAS_analysis/code/ctwas_config.R code/ctwas_config.R

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 4a5db1c. 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:


Ignored files:
    Ignored:    .ipynb_checkpoints/
    Ignored:    data/AF/

Untracked files:
    Untracked:  Rplot.png
    Untracked:  analysis/.ipynb_checkpoints/
    Untracked:  code/.ipynb_checkpoints/
    Untracked:  code/AF_out/
    Untracked:  code/Autism_out/
    Untracked:  code/BMI_S_out/
    Untracked:  code/BMI_out/
    Untracked:  code/Glucose_out/
    Untracked:  code/LDL_S_out/
    Untracked:  code/SCZ_S_out/
    Untracked:  code/SCZ_out/
    Untracked:  code/T2D_out/
    Untracked:  code/ctwas_config.R
    Untracked:  code/mapping.R
    Untracked:  code/out/
    Untracked:  code/run_AF_analysis.sbatch
    Untracked:  code/run_AF_analysis.sh
    Untracked:  code/run_AF_ctwas_rss_LDR.R
    Untracked:  code/run_Autism_analysis.sbatch
    Untracked:  code/run_Autism_analysis.sh
    Untracked:  code/run_Autism_ctwas_rss_LDR.R
    Untracked:  code/run_BMI_analysis.sbatch
    Untracked:  code/run_BMI_analysis.sh
    Untracked:  code/run_BMI_analysis_S.sbatch
    Untracked:  code/run_BMI_analysis_S.sh
    Untracked:  code/run_BMI_ctwas_rss_LDR.R
    Untracked:  code/run_BMI_ctwas_rss_LDR_S.R
    Untracked:  code/run_Glucose_analysis.sbatch
    Untracked:  code/run_Glucose_analysis.sh
    Untracked:  code/run_Glucose_ctwas_rss_LDR.R
    Untracked:  code/run_LDL_analysis_S.sbatch
    Untracked:  code/run_LDL_analysis_S.sh
    Untracked:  code/run_LDL_ctwas_rss_LDR_S.R
    Untracked:  code/run_SCZ_analysis.sbatch
    Untracked:  code/run_SCZ_analysis.sh
    Untracked:  code/run_SCZ_analysis_S.sbatch
    Untracked:  code/run_SCZ_analysis_S.sh
    Untracked:  code/run_SCZ_ctwas_rss_LDR.R
    Untracked:  code/run_SCZ_ctwas_rss_LDR_S.R
    Untracked:  code/run_T2D_analysis.sbatch
    Untracked:  code/run_T2D_analysis.sh
    Untracked:  code/run_T2D_ctwas_rss_LDR.R
    Untracked:  code/wflow_build.R
    Untracked:  code/wflow_build.sbatch
    Untracked:  data/.ipynb_checkpoints/
    Untracked:  data/BMI/
    Untracked:  data/SCZ/
    Untracked:  data/SCZ_S/
    Untracked:  data/T2D/
    Untracked:  data/UKBB/
    Untracked:  data/UKBB_SNPs_Info.text
    Untracked:  data/gene_OMIM.txt
    Untracked:  data/gene_pip_0.8.txt
    Untracked:  data/mashr_Heart_Atrial_Appendage.db
    Untracked:  data/mashr_sqtl/
    Untracked:  data/summary_known_genes_annotations.xlsx
    Untracked:  data/untitled.txt

Unstaged changes:
    Modified:   analysis/BMI_Brain_Putamen_basal_ganglia.Rmd
    Modified:   analysis/SCZ_Brain_Amygdala.Rmd
    Modified:   analysis/SCZ_Brain_Anterior_cingulate_cortex_BA24.Rmd
    Modified:   analysis/SCZ_Brain_Caudate_basal_ganglia.Rmd
    Modified:   analysis/SCZ_Brain_Cerebellar_Hemisphere.Rmd
    Modified:   analysis/SCZ_Brain_Cerebellum.Rmd
    Modified:   analysis/SCZ_Brain_Cortex.Rmd
    Modified:   analysis/SCZ_Brain_Frontal_Cortex_BA9.Rmd
    Modified:   analysis/SCZ_Brain_Hippocampus.Rmd
    Modified:   analysis/SCZ_Brain_Hypothalamus.Rmd
    Modified:   analysis/SCZ_Brain_Nucleus_accumbens_basal_ganglia.Rmd
    Modified:   analysis/SCZ_Brain_Spinal_cord_cervical_c-1.Rmd
    Modified:   analysis/SCZ_Brain_Substantia_nigra.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/SCZ_Brain_Substantia_nigra.Rmd) and HTML (docs/SCZ_Brain_Substantia_nigra.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 4a5db1c sq-96 2022-03-03 update
html 4a5db1c sq-96 2022-03-03 update
html 75a1466 sq-96 2022-02-27 Build site.
Rmd 1c69dd2 sq-96 2022-02-27 update
html ff6403a sq-96 2022-02-27 Build site.
Rmd 3dd5b4c sq-96 2022-02-27 update

Weight QC

#number of imputed weights
nrow(qclist_all)
[1] 10096
#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  16  17  18  19  20 
970 724 606 388 494 522 474 399 398 404 602 577 222 334 344 461 597 153 768 314 
 21  22 
112 233 
#number of imputed weights without missing variants
sum(qclist_all$nmiss==0)
[1] 8298
#proportion of imputed weights without missing variants
mean(qclist_all$nmiss==0)
[1] 0.8219

Check convergence of parameters

Version Author Date
ff6403a sq-96 2022-02-27
#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.0079186 0.0002633 
#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 
11.493  8.624 
#report sample size
print(sample_size)
[1] 82315
#report group size
group_size <- c(nrow(ctwas_gene_res), n_snps)
print(group_size)
[1]   10096 7573890
#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.01116 0.20896 
#compare sum(PIP*mu2/sample_size) with above PVE calculation
c(sum(ctwas_gene_res$PVE),sum(ctwas_snp_res$PVE))
[1] 0.04909 1.56331

Genes with highest PIPs

Version Author Date
ff6403a sq-96 2022-02-27
          genename region_tag susie_pip   mu2       PVE      z num_eqtl
4961         FURIN      15_42    0.9778 46.16 0.0005483 -7.000        1
10000       ZNF823      19_10    0.9709 29.75 0.0003509  5.455        1
11036   AC012074.2       2_15    0.8479 22.88 0.0002357  4.620        2
247          VSIG2      11_77    0.7885 26.23 0.0002512 -3.818        1
10995    HIST1H2BN       6_21    0.7676 94.50 0.0008812 10.773        1
8494        DIRAS1       19_3    0.7586 25.35 0.0002337  4.867        2
5687       ARFGAP2      11_29    0.6907 24.40 0.0002047  4.740        1
2668        PDCD10      3_103    0.5732 21.86 0.0001522 -4.033        2
2900        MAP7D1       1_22    0.5726 24.30 0.0001691  4.907        1
8526          LY6H       8_94    0.5552 21.43 0.0001446  4.042        2
12597       EBLN3P       9_28    0.5351 23.06 0.0001499 -4.450        1
10218   LIN28B-AS1       6_70    0.5284 23.56 0.0001512 -4.651        1
10923    LINC01305      2_105    0.5020 23.25 0.0001418  4.523        1
5807         PLBD2      12_68    0.4878 21.18 0.0001255  3.986        1
8611       ZNF354C      5_108    0.4600 24.48 0.0001368 -3.965        1
2371           MDK      11_28    0.4596 39.12 0.0002184 -6.357        1
5246        CEP170      1_128    0.4510 25.69 0.0001408 -4.678        1
98           ELAC2      17_11    0.4364 30.58 0.0001622  4.227        1
1618      PPP1R16B      20_23    0.4354 35.67 0.0001887  6.091        1
11529 RP11-65M17.3      11_66    0.4267 22.40 0.0001161  4.330        1

Genes with largest effect sizes

Version Author Date
ff6403a sq-96 2022-02-27
       genename region_tag susie_pip     mu2       PVE       z num_eqtl
6375   ARHGAP27      17_27 0.000e+00 2296.94 0.000e+00 -2.0935        1
62        KMT2E       7_65 1.106e-05 1474.23 1.981e-07 -5.7816        2
8739   HLA-DQB1       6_26 5.596e-14  848.22 5.766e-16  4.1487        1
10292    HSPA1A       6_26 3.034e-13  234.54 8.645e-16  7.1259        1
8149      DCAKD      17_27 0.000e+00  119.02 0.000e+00 -2.8009        2
4321      SRPK2       7_65 0.000e+00   99.65 0.000e+00 -1.1604        1
10995 HIST1H2BN       6_21 7.676e-01   94.50 8.812e-04 10.7729        1
8901      ACBD4      17_27 0.000e+00   91.02 0.000e+00  0.1106        2
10526     CLIC1       6_26 2.818e-13   85.62 2.931e-16  0.4634        1
9454     HEXIM1      17_27 0.000e+00   69.44 0.000e+00 -2.8451        1
9418     BTN3A2       6_20 1.425e-02   67.98 1.177e-05  9.0770        3
2212      GOSR2      17_27 0.000e+00   67.64 0.000e+00 -2.5096        1
10868    SAPCD1       6_26 3.779e-12   64.23 2.949e-15  2.7814        1
10298      MSH5       6_26 5.906e-14   57.52 4.127e-17  0.7907        2
1217       PUS7       7_65 0.000e+00   56.76 0.000e+00 -2.8339        2
8834  HIST1H2BC       6_20 1.538e-02   54.00 1.009e-05 -8.0277        1
9552    ZSCAN23       6_22 4.653e-02   52.42 2.963e-05 -7.5541        2
4600      PGBD1       6_22 8.004e-03   50.72 4.932e-06 -6.3599        2
11951 LINC01415      18_30 1.610e-01   49.98 9.776e-05 -5.3243        1
4961      FURIN      15_42 9.778e-01   46.16 5.483e-04 -7.0004        1

Genes with highest PVE

           genename region_tag susie_pip   mu2       PVE      z num_eqtl
10995     HIST1H2BN       6_21    0.7676 94.50 0.0008812 10.773        1
4961          FURIN      15_42    0.9778 46.16 0.0005483 -7.000        1
10000        ZNF823      19_10    0.9709 29.75 0.0003509  5.455        1
247           VSIG2      11_77    0.7885 26.23 0.0002512 -3.818        1
11036    AC012074.2       2_15    0.8479 22.88 0.0002357  4.620        2
8494         DIRAS1       19_3    0.7586 25.35 0.0002337  4.867        2
2371            MDK      11_28    0.4596 39.12 0.0002184 -6.357        1
5687        ARFGAP2      11_29    0.6907 24.40 0.0002047  4.740        1
1618       PPP1R16B      20_23    0.4354 35.67 0.0001887  6.091        1
426          ARID1B      6_102    0.3795 37.06 0.0001709 -3.907        1
2900         MAP7D1       1_22    0.5726 24.30 0.0001691  4.907        1
98            ELAC2      17_11    0.4364 30.58 0.0001622  4.227        1
2668         PDCD10      3_103    0.5732 21.86 0.0001522 -4.033        2
10218    LIN28B-AS1       6_70    0.5284 23.56 0.0001512 -4.651        1
12597        EBLN3P       9_28    0.5351 23.06 0.0001499 -4.450        1
8526           LY6H       8_94    0.5552 21.43 0.0001446  4.042        2
10923     LINC01305      2_105    0.5020 23.25 0.0001418  4.523        1
5246         CEP170      1_128    0.4510 25.69 0.0001408 -4.678        1
12007 RP11-247A12.7       9_66    0.2911 39.33 0.0001391  4.243        2
8611        ZNF354C      5_108    0.4600 24.48 0.0001368 -3.965        1

Genes with largest z scores

       genename region_tag susie_pip    mu2       PVE      z num_eqtl
10995 HIST1H2BN       6_21 7.676e-01  94.50 8.812e-04 10.773        1
9418     BTN3A2       6_20 1.425e-02  67.98 1.177e-05  9.077        3
8834  HIST1H2BC       6_20 1.538e-02  54.00 1.009e-05 -8.028        1
9552    ZSCAN23       6_22 4.653e-02  52.42 2.963e-05 -7.554        2
2539     TRIM38       6_20 1.187e-02  45.99 6.630e-06 -7.478        2
6323    ZSCAN12       6_22 1.556e-02  39.73 7.511e-06  7.193        2
10292    HSPA1A       6_26 3.034e-13 234.54 8.645e-16  7.126        1
4961      FURIN      15_42 9.778e-01  46.16 5.483e-04 -7.000        1
5665    CYP17A1      10_66 4.682e-03  31.84 1.811e-06 -6.720        1
4600      PGBD1       6_22 8.004e-03  50.72 4.932e-06 -6.360        2
2371        MDK      11_28 4.596e-01  39.12 2.184e-04 -6.357        1
2778     KCNJ13      2_137 1.584e-01  35.34 6.800e-05 -6.333        1
1137   PPP1R13B      14_54 6.061e-02  44.26 3.259e-05 -6.297        1
8821     HARBI1      11_28 1.622e-01  36.44 7.181e-05  6.169        1
10439   DNAJC19      3_111 2.146e-01  37.89 9.879e-05  6.158        1
3921   C12orf65      12_75 3.691e-03  36.50 1.637e-06 -6.141        1
9960        NMB      15_39 1.706e-01  42.26 8.760e-05  6.132        1
9514    ZKSCAN4       6_22 1.111e-02  28.19 3.805e-06 -6.092        1
1618   PPP1R16B      20_23 4.354e-01  35.67 1.887e-04  6.091        1
10577     AS3MT      10_66 6.259e-03  31.85 2.422e-06  6.055        2

Comparing z scores and PIPs

Version Author Date
ff6403a sq-96 2022-02-27

Version Author Date
ff6403a sq-96 2022-02-27
[1] 0.006933

GO enrichment analysis for genes with PIP>0.5

#number of genes for gene set enrichment
length(genes)
[1] 13
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"

Version Author Date
ff6403a sq-96 2022-02-27
                                                                                                                 Term
1                                                             positive regulation of MAP kinase activity (GO:0043406)
2                                                                      regulation of MAP kinase activity (GO:0043405)
3                                        positive regulation of protein serine/threonine kinase activity (GO:0071902)
4                                     negative regulation of transforming growth factor beta1 production (GO:0032911)
5                              regulation of low-density lipoprotein particle receptor catabolic process (GO:0032803)
6  negative regulation of blood vessel endothelial cell proliferation involved in sprouting angiogenesis (GO:1903588)
7                                                                        Golgi transport vesicle coating (GO:0048200)
8                                                                          COPI coating of Golgi vesicle (GO:0048205)
9                                                                            COPI-coated vesicle budding (GO:0035964)
10                                             regulation of transforming growth factor beta1 production (GO:0032908)
11                                                                   establishment of Golgi localization (GO:0051683)
12                                     negative regulation of transforming growth factor beta production (GO:0071635)
13                                             negative regulation of cellular protein catabolic process (GO:1903363)
14                                                                    cellular response to acetylcholine (GO:1905145)
15                                                                             signal peptide processing (GO:0006465)
16                                                                                     Golgi inheritance (GO:0048313)
17                                 intrinsic apoptotic signaling pathway in response to oxidative stress (GO:0008631)
18                                                                                    Golgi localization (GO:0051645)
19                              negative regulation of cell migration involved in sprouting angiogenesis (GO:0090051)
20                                                                         regulation of lipase activity (GO:0060191)
21                                                                                 stress fiber assembly (GO:0043149)
22                                        positive regulation of membrane protein ectodomain proteolysis (GO:0051044)
23                                                            contractile actin filament bundle assembly (GO:0030038)
24                                                                     epiboly involved in wound healing (GO:0090505)
25          regulation of blood vessel endothelial cell proliferation involved in sprouting angiogenesis (GO:1903587)
26                                                                      regulation of Golgi organization (GO:1903358)
27                                                                       regulation of catabolic process (GO:0009894)
28                              positive regulation of stress-activated protein kinase signaling cascade (GO:0070304)
29                                                                   positive regulation of MAPK cascade (GO:0043410)
30                                                              acetylcholine receptor signaling pathway (GO:0095500)
31                                                             regulation of lipoprotein lipase activity (GO:0051004)
32                                                 regulation of membrane protein ectodomain proteolysis (GO:0051043)
33                                                                      regulation of peptidase activity (GO:0052547)
34                                                                     wound healing, spreading of cells (GO:0044319)
   Overlap Adjusted.P.value         Genes
1     2/69          0.04473 PDCD10;DIRAS1
2     2/97          0.04473 PDCD10;DIRAS1
3    2/106          0.04473 PDCD10;DIRAS1
4      1/5          0.04473         FURIN
5      1/5          0.04473         FURIN
6      1/6          0.04473        PDCD10
7      1/6          0.04473       ARFGAP2
8      1/6          0.04473       ARFGAP2
9      1/6          0.04473       ARFGAP2
10     1/7          0.04473         FURIN
11     1/8          0.04473        PDCD10
12    1/10          0.04473         FURIN
13    1/10          0.04473         FURIN
14    1/10          0.04473          LY6H
15    1/11          0.04473         FURIN
16    1/11          0.04473        PDCD10
17    1/12          0.04473        PDCD10
18    1/12          0.04473        PDCD10
19    1/14          0.04473        PDCD10
20    1/14          0.04473         FURIN
21    1/15          0.04473        PDCD10
22    1/15          0.04473         FURIN
23    1/15          0.04473        PDCD10
24    1/16          0.04473        PDCD10
25    1/16          0.04473        PDCD10
26    1/17          0.04490        PDCD10
27    1/18          0.04490         FURIN
28    1/18          0.04490        PDCD10
29   2/274          0.04727 PDCD10;DIRAS1
30    1/21          0.04727          LY6H
31    1/21          0.04727         FURIN
32    1/22          0.04796         FURIN
33    1/23          0.04861         FURIN
34    1/24          0.04921        PDCD10
[1] "GO_Cellular_Component_2021"

Version Author Date
ff6403a sq-96 2022-02-27
[1] Term             Overlap          Adjusted.P.value Genes           
<0 rows> (or 0-length row.names)
[1] "GO_Molecular_Function_2021"

Version Author Date
ff6403a sq-96 2022-02-27
                                         Term Overlap Adjusted.P.value Genes
1    nerve growth factor binding (GO:0048406)     1/5          0.03978 FURIN
2 acetylcholine receptor binding (GO:0033130)     1/8          0.03978  LY6H
3           neurotrophin binding (GO:0043121)     1/8          0.03978 FURIN

DisGeNET enrichment analysis for genes with PIP>0.5

                                Description      FDR Ratio  BgRatio
13       Cerebral Cavernous Malformations 3 0.002319   1/3   1/9703
15 Familial cerebral cavernous malformation 0.002319   1/3   1/9703
14            Cavernous Hemangioma of Brain 0.004637   1/3   3/9703
1                                 Carcinoma 0.062703   1/3 164/9703
3                  Animal Mammary Neoplasms 0.062703   1/3 142/9703
4           Mammary Neoplasms, Experimental 0.062703   1/3 155/9703
6                      Anaplastic carcinoma 0.062703   1/3 163/9703
7                   Carcinoma, Spindle-Cell 0.062703   1/3 163/9703
8                Undifferentiated carcinoma 0.062703   1/3 163/9703
9                            Carcinomatosis 0.062703   1/3 163/9703

WebGestalt enrichment analysis for genes with PIP>0.5

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

PIP Manhattan Plot

Version Author Date
ff6403a sq-96 2022-02-27

Sensitivity, specificity and precision for silver standard genes

#number of genes in known annotations
print(length(known_annotations))
[1] 130
#number of genes in known annotations with imputed expression
print(sum(known_annotations %in% ctwas_gene_res$genename))
[1] 58
#significance threshold for TWAS
print(sig_thresh)
[1] 4.567
#number of ctwas genes
length(ctwas_genes)
[1] 3
#number of TWAS genes
length(twas_genes)
[1] 70
#show novel genes (ctwas genes with not in TWAS genes)
ctwas_gene_res[ctwas_gene_res$genename %in% novel_genes,report_cols]
[1] genename   region_tag susie_pip  mu2        PVE        z          num_eqtl  
<0 rows> (or 0-length row.names)
#sensitivity / recall
print(sensitivity)
  ctwas    TWAS 
0.01538 0.04615 
#specificity
print(specificity)
 ctwas   TWAS 
0.9999 0.9936 
#precision / PPV
print(precision)
  ctwas    TWAS 
0.66667 0.08571 

Version Author Date
75a1466 sq-96 2022-02-27
ff6403a sq-96 2022-02-27

cTWAS is more precise than TWAS in distinguishing silver standard and bystander genes

#number of genes in known annotations (with imputed expression)
print(length(known_annotations))
[1] 58
#number of bystander genes (with imputed expression)
print(length(unrelated_genes))
[1] 619
#subset results to genes in known annotations or bystanders
ctwas_gene_res_subset <- ctwas_gene_res[ctwas_gene_res$genename %in% c(known_annotations, unrelated_genes),]

#assign ctwas and TWAS genes
ctwas_genes <- ctwas_gene_res_subset$genename[ctwas_gene_res_subset$susie_pip>0.8]
twas_genes <- ctwas_gene_res_subset$genename[abs(ctwas_gene_res_subset$z)>sig_thresh]

#significance threshold for TWAS
print(sig_thresh)
[1] 4.567
#number of ctwas genes (in known annotations or bystanders)
length(ctwas_genes)
[1] 2
#number of TWAS genes (in known annotations or bystanders)
length(twas_genes)
[1] 22
#sensitivity / recall
sensitivity
  ctwas    TWAS 
0.03448 0.10345 
#specificity / (1 - False Positive Rate)
specificity
 ctwas   TWAS 
1.0000 0.9742 
#precision / PPV / (1 - False Discovery Rate)
precision
 ctwas   TWAS 
1.0000 0.2727 

Version Author Date
4a5db1c sq-96 2022-03-03

Version Author Date
4a5db1c sq-96 2022-03-03
pip_range <- (0:1000)/1000
sensitivity <- rep(NA, length(pip_range))
specificity <- rep(NA, length(pip_range))

for (index in 1:length(pip_range)){
  pip <- pip_range[index]
  ctwas_genes <- ctwas_gene_res_subset$genename[ctwas_gene_res_subset$susie_pip>=pip]
  sensitivity[index] <- sum(ctwas_genes %in% known_annotations)/length(known_annotations)
  specificity[index] <- sum(!(unrelated_genes %in% ctwas_genes))/length(unrelated_genes)
}

plot(1-specificity, sensitivity, type="l", xlim=c(0,1), ylim=c(0,1), main="", xlab="1 - Specificity", ylab="Sensitivity")
title(expression("ROC Curve for cTWAS (black) and TWAS (" * phantom("red") * ")"))
title(expression(phantom("ROC Curve for cTWAS (black) and TWAS (") * "red" * phantom(")")), col.main="red")

sig_thresh_range <- seq(from=0, to=max(abs(ctwas_gene_res_subset$z)), length.out=length(pip_range))

for (index in 1:length(sig_thresh_range)){
  sig_thresh_plot <- sig_thresh_range[index]
  twas_genes <- ctwas_gene_res_subset$genename[abs(ctwas_gene_res_subset$z)>=sig_thresh_plot]
  sensitivity[index] <- sum(twas_genes %in% known_annotations)/length(known_annotations)
  specificity[index] <- sum(!(unrelated_genes %in% twas_genes))/length(unrelated_genes)
}

lines(1-specificity, sensitivity, xlim=c(0,1), ylim=c(0,1), col="red", lty=1)

abline(a=0,b=1,lty=3)

#add previously computed points from the analysis
ctwas_genes <- ctwas_gene_res_subset$genename[ctwas_gene_res_subset$susie_pip>0.8]
twas_genes <- ctwas_gene_res_subset$genename[abs(ctwas_gene_res_subset$z)>sig_thresh]

points(1-specificity_plot["ctwas"], sensitivity_plot["ctwas"], pch=21, bg="black")
points(1-specificity_plot["TWAS"], sensitivity_plot["TWAS"], pch=21, bg="red")

Version Author Date
4a5db1c sq-96 2022-03-03

Undetected silver standard genes have low TWAS z-scores or stronger signal from nearby variants

#table of outcomes for silver standard genes
-sort(-table(silver_standard_case))
silver_standard_case
          Not Imputed Insignificant z-score         Nearby SNP(s) 
                   72                    52                     4 
 Detected (PIP > 0.8) 
                    2 
#show inconclusive genes
silver_standard_case[silver_standard_case=="Inconclusive"]
named character(0)

Version Author Date
4a5db1c sq-96 2022-03-03

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] readxl_1.3.1      forcats_0.5.1     stringr_1.4.0     dplyr_1.0.7      
 [5] purrr_0.3.4       readr_2.1.1       tidyr_1.1.4       tidyverse_1.3.1  
 [9] tibble_3.1.6      WebGestaltR_0.4.4 disgenet2r_0.99.2 enrichR_3.0      
[13] cowplot_1.0.0     ggplot2_3.3.5     workflowr_1.7.0  

loaded via a namespace (and not attached):
 [1] fs_1.5.2          lubridate_1.8.0   bit64_4.0.5       doParallel_1.0.17
 [5] httr_1.4.2        rprojroot_2.0.2   tools_3.6.1       backports_1.4.1  
 [9] doRNG_1.8.2       utf8_1.2.2        R6_2.5.1          vipor_0.4.5      
[13] DBI_1.1.2         colorspace_2.0-2  withr_2.4.3       ggrastr_1.0.1    
[17] tidyselect_1.1.1  processx_3.5.2    bit_4.0.4         curl_4.3.2       
[21] compiler_3.6.1    git2r_0.26.1      rvest_1.0.2       cli_3.1.0        
[25] Cairo_1.5-12.2    xml2_1.3.3        labeling_0.4.2    scales_1.1.1     
[29] callr_3.7.0       apcluster_1.4.8   digest_0.6.29     rmarkdown_2.11   
[33] svglite_1.2.2     pkgconfig_2.0.3   htmltools_0.5.2   dbplyr_2.1.1     
[37] fastmap_1.1.0     highr_0.9         rlang_1.0.1       rstudioapi_0.13  
[41] RSQLite_2.2.8     jquerylib_0.1.4   farver_2.1.0      generics_0.1.1   
[45] jsonlite_1.7.2    vroom_1.5.7       magrittr_2.0.2    Matrix_1.2-18    
[49] ggbeeswarm_0.6.0  Rcpp_1.0.8        munsell_0.5.0     fansi_1.0.2      
[53] gdtools_0.1.9     lifecycle_1.0.1   stringi_1.7.6     whisker_0.3-2    
[57] yaml_2.2.1        plyr_1.8.6        grid_3.6.1        blob_1.2.2       
[61] ggrepel_0.9.1     parallel_3.6.1    promises_1.0.1    crayon_1.5.0     
[65] lattice_0.20-38   haven_2.4.3       hms_1.1.1         knitr_1.36       
[69] ps_1.6.0          pillar_1.6.4      igraph_1.2.10     rjson_0.2.20     
[73] rngtools_1.5.2    reshape2_1.4.4    codetools_0.2-16  reprex_2.0.1     
[77] glue_1.6.2        evaluate_0.14     getPass_0.2-2     modelr_0.1.8     
[81] data.table_1.14.2 vctrs_0.3.8       tzdb_0.2.0        httpuv_1.5.1     
[85] foreach_1.5.2     cellranger_1.1.0  gtable_0.3.0      assertthat_0.2.1 
[89] cachem_1.0.6      xfun_0.29         broom_0.7.10      later_0.8.0      
[93] iterators_1.0.14  beeswarm_0.2.3    memoise_2.0.1     ellipsis_0.3.2