Last updated: 2024-10-23

Checks: 6 1

Knit directory: multigroup_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 is untracked by Git. 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(20231112) 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 e90aeef. 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:


Untracked files:
    Untracked:  analysis/methylation_analysis.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.


There are no past versions. Publish this analysis with wflow_publish() to start tracking its development.


── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ lubridate 1.9.3     ✔ tibble    3.2.1
✔ purrr     1.0.2     ✔ tidyr     1.3.1
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::between()     masks data.table::between()
✖ dplyr::combine()     masks gridExtra::combine()
✖ dplyr::filter()      masks stats::filter()
✖ dplyr::first()       masks data.table::first()
✖ lubridate::hour()    masks data.table::hour()
✖ lubridate::isoweek() masks data.table::isoweek()
✖ dplyr::lag()         masks stats::lag()
✖ dplyr::last()        masks data.table::last()
✖ lubridate::mday()    masks data.table::mday()
✖ lubridate::minute()  masks data.table::minute()
✖ lubridate::month()   masks data.table::month()
✖ lubridate::quarter() masks data.table::quarter()
✖ lubridate::second()  masks data.table::second()
✖ purrr::transpose()   masks data.table::transpose()
✖ tidyr::unite()       masks ggVennDiagram::unite()
✖ lubridate::wday()    masks data.table::wday()
✖ lubridate::week()    masks data.table::week()
✖ lubridate::yday()    masks data.table::yday()
✖ lubridate::year()    masks data.table::year()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors

Attaching package: 'magrittr'


The following object is masked from 'package:purrr':

    set_names


The following object is masked from 'package:tidyr':

    extract

Fusion Lasso model of DNA methylation

I built lasso model of DNA methylation with FUSION for Whole Blood and Colon Transverse. Similar to meQTL mapping, for each CpG site, I extracted surrounding 500kb genptypes and train lasso models with cross validation. With heritability cutoff p<0.001, I have about 10,500 and 37,500 CpG sites in whole blood and colon transverse. Among which, 2452 and 28505 CpG sites are also in QTL mapping. Colon have more overlaps than whole blood. The average cross-validation R2 for lasso in whole blood and colon transverse are 0.260 and 0.231. In the single QTL approach (qval < 0.001), we have 7,720 and 91,466 CpG sites.

cTWAS parameters with methylation lasso models

### Percent of heritability with methylation lasso models

ctwas_parameters <- readRDS("/project/xinhe/shengqian/cTWAS_analysis/data/ibd_multi_top/ibd_multi_top.ctwas_parameters.RDS")
pve_pie_by_type_multi <- plot_piechart(ctwas_parameters = ctwas_parameters, colors = colors, by = "type")
pve_pie_by_context_multi <- plot_piechart(ctwas_parameters = ctwas_parameters, colors = colors, by = "context")
gridExtra::grid.arrange(pve_pie_by_type_multi,pve_pie_by_context_multi, ncol = 2)

Top cTWAS genes with methylation lasso models

gwas_n <- 59957
finemap_res <- readRDS("/project/xinhe/shengqian/cTWAS_analysis/data/ibd_multi/ibd_multi.finemap_regions_res.RDS")
gene_annot <- readRDS("/project2/xinhe/shared_data/multigroup_ctwas/weights/mapping_files/PredictDB_E_S_M_mapping.RDS")
susie_alpha_res <- anno_susie_alpha_res(finemap_res$susie_alpha_res,
                                        mapping_table = gene_annot,
                                        map_by = "molecular_id",
                                        drop_unmapped = TRUE)
2024-10-23 14:59:48 INFO::Annotating susie alpha result ...
2024-10-23 14:59:48 INFO::Map molecular traits to genes
2024-10-23 14:59:51 INFO::Split PIPs for molecular traits mapped to multiple genes
combined_pip_by_type <- combine_gene_pips(susie_alpha_res, 
                                             group_by = "gene_name",
                                             by = "type",
                                             method = "combine_cs",
                                             filter_cs = TRUE,
                                             include_cs_id = FALSE)

combined_pip_by_context <- combine_gene_pips(susie_alpha_res, 
                                             group_by = "gene_name",
                                             by = "context",
                                             method = "combine_cs",
                                             filter_cs = TRUE,
                                             include_cs_id = FALSE)

DT::datatable(combined_pip_by_type[combined_pip_by_type$combined_pip>0.8,],caption = htmltools::tags$caption( style = 'caption-side: topleft; text-align = left; color:black;','Combined PIP by omics'),options = list(pageLength = 10) )
DT::datatable(combined_pip_by_context[combined_pip_by_context$combined_pip>0.8,],caption = htmltools::tags$caption( style = 'caption-side: topleft; text-align = left; color:black;','Combined PIP by tissue'),options = list(pageLength = 10) )

cTWAS parameters with methylation single QTL models

### Percent of heritability with methylation single QTL models

ctwas_parameters <- readRDS("/project/xinhe/shengqian/cTWAS_analysis/data/ibd_multi/ibd_multi.ctwas_parameters.RDS")
pve_pie_by_type_multi <- plot_piechart(ctwas_parameters = ctwas_parameters, colors = colors, by = "type")
pve_pie_by_context_multi <- plot_piechart(ctwas_parameters = ctwas_parameters, colors = colors, by = "context")
gridExtra::grid.arrange(pve_pie_by_type_multi,pve_pie_by_context_multi, ncol = 2)

Top cTWAS genes with methylation single QTL models

gwas_n <- 59957
finemap_res <- readRDS("/project/xinhe/shengqian/cTWAS_analysis/data/ibd_multi_top/ibd_multi_top.finemap_regions_res.RDS")
gene_annot <- readRDS("/project2/xinhe/shared_data/multigroup_ctwas/weights/mapping_files/PredictDB_E_S_M_mapping.RDS")

susie_alpha_res <- anno_susie_alpha_res(finemap_res$susie_alpha_res,
                                        mapping_table = gene_annot,
                                        map_by = "molecular_id",
                                        drop_unmapped = TRUE)
2024-10-23 15:00:04 INFO::Annotating susie alpha result ...
2024-10-23 15:00:04 INFO::Map molecular traits to genes
2024-10-23 15:00:05 INFO::Split PIPs for molecular traits mapped to multiple genes
combined_pip_by_type <- combine_gene_pips(susie_alpha_res, 
                                          group_by = "gene_name",
                                          by = "type",
                                          method = "combine_cs",
                                          filter_cs = TRUE,
                                          include_cs_id = FALSE)

combined_pip_by_context <- combine_gene_pips(susie_alpha_res, 
                                             group_by = "gene_name",
                                             by = "context",
                                             method = "combine_cs",
                                             filter_cs = TRUE,
                                             include_cs_id = FALSE)

DT::datatable(combined_pip_by_type[combined_pip_by_type$combined_pip>0.8,],caption = htmltools::tags$caption( style = 'caption-side: topleft; text-align = left; color:black;','Combined PIP by omics'),options = list(pageLength = 10) )
DT::datatable(combined_pip_by_context[combined_pip_by_context$combined_pip>0.8,],caption = htmltools::tags$caption( style = 'caption-side: topleft; text-align = left; color:black;','Combined PIP by tissue'),options = list(pageLength = 10) )

sessionInfo()
R version 4.2.0 (2022-04-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /software/openblas-0.3.13-el7-x86_64/lib/libopenblas_haswellp-r0.3.13.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] pheatmap_1.0.12     magrittr_2.0.3      RSQLite_2.3.7      
 [4] lubridate_1.9.3     forcats_1.0.0       stringr_1.5.1      
 [7] dplyr_1.1.4         purrr_1.0.2         readr_2.1.5        
[10] tidyr_1.3.1         tibble_3.2.1        tidyverse_2.0.0    
[13] ctwas_0.4.15        data.table_1.16.0   gridExtra_2.3      
[16] ggVennDiagram_1.5.2 ggplot2_3.5.1       workflowr_1.7.0    

loaded via a namespace (and not attached):
  [1] colorspace_2.1-1            rjson_0.2.23               
  [3] rprojroot_2.0.3             XVector_0.38.0             
  [5] locuszoomr_0.3.5            GenomicRanges_1.50.2       
  [7] fs_1.6.4                    rstudioapi_0.14            
  [9] farver_2.1.2                DT_0.22                    
 [11] ggrepel_0.9.6               bit64_4.5.2                
 [13] AnnotationDbi_1.60.2        fansi_1.0.6                
 [15] xml2_1.3.3                  logging_0.10-108           
 [17] codetools_0.2-18            cachem_1.1.0               
 [19] knitr_1.48                  jsonlite_1.8.9             
 [21] Rsamtools_2.14.0            dbplyr_2.5.0               
 [23] png_0.1-7                   compiler_4.2.0             
 [25] httr_1.4.7                  Matrix_1.5-3               
 [27] fastmap_1.2.0               lazyeval_0.2.2             
 [29] cli_3.6.3                   later_1.3.2                
 [31] htmltools_0.5.8.1           prettyunits_1.2.0          
 [33] tools_4.2.0                 gtable_0.3.5               
 [35] glue_1.7.0                  GenomeInfoDbData_1.2.9     
 [37] rappdirs_0.3.3              Rcpp_1.0.13                
 [39] Biobase_2.58.0              jquerylib_0.1.4            
 [41] vctrs_0.6.5                 Biostrings_2.66.0          
 [43] rtracklayer_1.58.0          crosstalk_1.2.1            
 [45] xfun_0.47                   ps_1.7.1                   
 [47] timechange_0.3.0            irlba_2.3.5.1              
 [49] lifecycle_1.0.4             restfulr_0.0.15            
 [51] ensembldb_2.22.0            XML_3.99-0.14              
 [53] getPass_0.2-2               zlibbioc_1.44.0            
 [55] zoo_1.8-12                  scales_1.3.0               
 [57] gggrid_0.2-0                hms_1.1.3                  
 [59] promises_1.3.0              MatrixGenerics_1.10.0      
 [61] ProtGenerics_1.30.0         parallel_4.2.0             
 [63] SummarizedExperiment_1.28.0 RColorBrewer_1.1-3         
 [65] AnnotationFilter_1.22.0     LDlinkR_1.4.0              
 [67] yaml_2.3.10                 curl_5.2.3                 
 [69] memoise_2.0.1               sass_0.4.9                 
 [71] biomaRt_2.54.1              stringi_1.8.4              
 [73] highr_0.11                  S4Vectors_0.36.2           
 [75] BiocIO_1.8.0                GenomicFeatures_1.50.4     
 [77] BiocGenerics_0.44.0         filelock_1.0.3             
 [79] BiocParallel_1.32.6         GenomeInfoDb_1.34.9        
 [81] rlang_1.1.4                 pkgconfig_2.0.3            
 [83] matrixStats_1.4.1           bitops_1.0-8               
 [85] evaluate_1.0.0              lattice_0.20-45            
 [87] labeling_0.4.3              GenomicAlignments_1.34.1   
 [89] htmlwidgets_1.6.4           cowplot_1.1.3              
 [91] bit_4.5.0                   processx_3.7.0             
 [93] tidyselect_1.2.1            R6_2.5.1                   
 [95] IRanges_2.32.0              generics_0.1.3             
 [97] DelayedArray_0.24.0         DBI_1.2.3                  
 [99] pgenlibr_0.3.7              pillar_1.9.0               
[101] whisker_0.4                 withr_3.0.1                
[103] mixsqp_0.3-54               KEGGREST_1.38.0            
[105] RCurl_1.98-1.16             crayon_1.5.3               
[107] utf8_1.2.4                  BiocFileCache_2.6.1        
[109] plotly_4.10.4               tzdb_0.4.0                 
[111] rmarkdown_2.28              progress_1.2.3             
[113] grid_4.2.0                  blob_1.2.4                 
[115] callr_3.7.2                 git2r_0.30.1               
[117] digest_0.6.37               httpuv_1.6.5               
[119] stats4_4.2.0                munsell_0.5.1              
[121] viridisLite_0.4.2           bslib_0.8.0