Contents

1 Installation

BiocManager::install("TADCompare")

2 Introduction

Using the output of TADCompare and TimeCompare, we can do a range of analyses. One common one is gene ontology enrichment analysis to determine the pathways in which genes near TAD boundaries occur in. To do this, we use rGREAT an R package for performing gene ontology enrichment analysis.

3 Performing gene ontology analysis using TADCompare

In the first example, we show how to perform gene ontology enrichment using differential boundaries. Here, we perform the analysis on shifted boundaries detected in matrix 1.

library(rGREAT)
# Reading in data
data("rao_chr22_prim")
data("rao_chr22_rep")

# Performing differential analysis
results <- TADCompare(rao_chr22_prim, rao_chr22_rep, resolution = 50000)

# Saving the results into its own data frame
TAD_Frame <- results$TAD_Frame

# Filter data to only include complex boundaries enriched in the second
# contact matrix
TAD_Frame <- TAD_Frame %>% dplyr::filter((Type == "Shifted") & 
                                         (Enriched_In == "Matrix 2"))

# Assign a chromosome and convert to a bed format
TAD_Frame <- TAD_Frame %>% dplyr::select(Boundary) %>% mutate(chr = "chr22", 
    start = Boundary, end = Boundary) %>% dplyr::select(chr, start, end)

# Set up rGREAT job with default parameters
great_shift <- submitGreatJob(TAD_Frame, request_interval = 1, version = "2.0")

# Submit the job
enrichment_table <- getEnrichmentTables(great_shift)

# Subset to only include vital information
enrichment_table <- bind_rows(enrichment_table, .id = "source") %>% 
  dplyr::select(Ontology = source, Description = name, 
                `P-value` = Hyper_Raw_PValue)

# Print head organizaed by p-values
head(enrichment_table %>% dplyr::arrange(`P-value`))
##                Ontology                                          Description
## 1 GO Molecular Function                   gamma-glutamyltransferase activity
## 2 GO Biological Process                     glutathione biosynthetic process
## 3 GO Cellular Component         anchored to external side of plasma membrane
## 4 GO Cellular Component        intrinsic to external side of plasma membrane
## 5 GO Biological Process                         peptide biosynthetic process
## 6 GO Molecular Function transferase activity, transferring amino-acyl groups
##       P-value
## 1 0.001802360
## 2 0.002927596
## 3 0.003152529
## 4 0.004051881
## 5 0.004725996
## 6 0.004950625

The first column, “Ontology”, is simply the domain from which the corresponding ontology (“Description” column) comes from. Here, we use the default, which is the GO ontologies. For more available ontologies, see the rGREAT vignette. “Description” is the pathway itself. “P-value” is the unadjusted hypergeometric p-value, as output by rGREAT. rGREAT also provides binomial p-values (Binom_Raw_Pvalue, Binom_Adjp_BH) and adjusted hypergeometric p-values (Hyper_Adjp_BH).

Now we demonstrate how to perform the same analysis but for all boundary types simultaneously. In this case, we use time-varying data.

# Read in time course data
data("time_mats")
# Identifying boundaries
results <- TimeCompare(time_mats, resolution = 50000)

# Pulling out the frame of TADs
TAD_Frame <- results$TAD_Bounds

# Getting coordinates for TAD boundaries and converting into bed format
Bound_List <- lapply(unique(TAD_Frame$Category), function(x) {
    TAD_Frame %>% filter((Category == x)) %>% mutate(chr = "chr22") %>% 
        dplyr::select(chr, Coordinate) %>% 
        mutate(start = Coordinate, end = Coordinate) %>% 
        dplyr::select(chr, start, end)
})

# Performing rGREAT analysis for each boundary Category
TAD_Enrich <- lapply(Bound_List, function(x) {
  getEnrichmentTables(submitGreatJob(x, request_interval = 1, version = "2.0"))
})

# Name list of data frames to keep track of which enrichment belongs to which
names(TAD_Enrich) <- unique(TAD_Frame$Category)

# Bind each category of pathway and create new column for each pathway
TAD_Enrich <- lapply(names(TAD_Enrich), function(x) {
  bind_rows(lapply(TAD_Enrich[[x]], function(y) {
    y %>% mutate(Category = x)
  }), .id = "source")
})

# Bind each boundary category together and pull out important variables
enrichment_table <- bind_rows(TAD_Enrich) %>% 
  dplyr::select(Ontology = source, Description = name, 
                `P-value` = Hyper_Raw_PValue, Category)

# Get the top enriched pathways
head(enrichment_table %>% dplyr::arrange(`P-value`))
##                Ontology
## 1 GO Biological Process
## 2 GO Molecular Function
## 3 GO Biological Process
## 4 GO Biological Process
## 5 GO Biological Process
## 6 GO Molecular Function
##                                                Description      P-value
## 1 positive regulation of B cell receptor signaling pathway 0.0002254283
## 2                               lipid transporter activity 0.0003760684
## 3          regulation of B cell receptor signaling pathway 0.0004508185
## 4                               Schwann cell proliferation 0.0006761897
## 5                            lipoprotein metabolic process 0.0007139088
## 6        peptide-methionine (R)-S-oxide reductase activity 0.0009015354
##              Category
## 1         Dynamic TAD
## 2   Highly Common TAD
## 3         Dynamic TAD
## 4 Early Appearing TAD
## 5   Highly Common TAD
## 6   Highly Common TAD

These columns are the same as the differential analysis but with an extra column, “Category”, indicating the type of time-varying TAD boundary.

4 Session Info

sessionInfo()
## R version 4.2.1 (2022-06-23)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 20.04.5 LTS
## 
## Matrix products: default
## BLAS:   /home/biocbuild/bbs-3.16-bioc/R/lib/libRblas.so
## LAPACK: /home/biocbuild/bbs-3.16-bioc/R/lib/libRlapack.so
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_GB              LC_COLLATE=C              
##  [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] stats4    stats     graphics  grDevices utils     datasets  methods  
## [8] base     
## 
## other attached packages:
##  [1] rGREAT_2.0.0         GenomicRanges_1.50.0 GenomeInfoDb_1.34.0 
##  [4] IRanges_2.32.0       S4Vectors_0.36.0     BiocGenerics_0.44.0 
##  [7] microbenchmark_1.4.9 TADCompare_1.8.0     SpectralTAD_1.14.0  
## [10] dplyr_1.0.10         BiocStyle_2.26.0    
## 
## loaded via a namespace (and not attached):
##   [1] utf8_1.2.2                              
##   [2] R.utils_2.12.1                          
##   [3] tidyselect_1.2.0                        
##   [4] RSQLite_2.2.18                          
##   [5] AnnotationDbi_1.60.0                    
##   [6] htmlwidgets_1.5.4                       
##   [7] grid_4.2.1                              
##   [8] BiocParallel_1.32.0                     
##   [9] munsell_0.5.0                           
##  [10] codetools_0.2-18                        
##  [11] DT_0.26                                 
##  [12] future_1.28.0                           
##  [13] CGHbase_1.58.0                          
##  [14] withr_2.5.0                             
##  [15] QDNAseq_1.34.0                          
##  [16] colorspace_2.0-3                        
##  [17] Biobase_2.58.0                          
##  [18] filelock_1.0.2                          
##  [19] TxDb.Hsapiens.UCSC.hg38.knownGene_3.16.0
##  [20] highr_0.9                               
##  [21] knitr_1.40                              
##  [22] CGHcall_2.60.0                          
##  [23] ggsignif_0.6.4                          
##  [24] listenv_0.8.0                           
##  [25] MatrixGenerics_1.10.0                   
##  [26] GenomeInfoDbData_1.2.9                  
##  [27] bit64_4.0.5                             
##  [28] pheatmap_1.0.12                         
##  [29] rhdf5_2.42.0                            
##  [30] parallelly_1.32.1                       
##  [31] vctrs_0.5.0                             
##  [32] generics_0.1.3                          
##  [33] TH.data_1.1-1                           
##  [34] xfun_0.34                               
##  [35] BiocFileCache_2.6.0                     
##  [36] R6_2.5.1                                
##  [37] doParallel_1.0.17                       
##  [38] HiCcompare_1.20.0                       
##  [39] bitops_1.0-7                            
##  [40] rhdf5filters_1.10.0                     
##  [41] cachem_1.0.6                            
##  [42] DelayedArray_0.24.0                     
##  [43] assertthat_0.2.1                        
##  [44] promises_1.2.0.1                        
##  [45] BiocIO_1.8.0                            
##  [46] scales_1.2.1                            
##  [47] multcomp_1.4-20                         
##  [48] gtable_0.3.1                            
##  [49] globals_0.16.1                          
##  [50] sandwich_3.0-2                          
##  [51] rlang_1.0.6                             
##  [52] GlobalOptions_0.1.2                     
##  [53] splines_4.2.1                           
##  [54] rtracklayer_1.58.0                      
##  [55] rstatix_0.7.0                           
##  [56] impute_1.72.0                           
##  [57] broom_1.0.1                             
##  [58] BiocManager_1.30.19                     
##  [59] yaml_2.3.6                              
##  [60] reshape2_1.4.4                          
##  [61] abind_1.4-5                             
##  [62] GenomicFeatures_1.50.0                  
##  [63] backports_1.4.1                         
##  [64] httpuv_1.6.6                            
##  [65] tools_4.2.1                             
##  [66] bookdown_0.29                           
##  [67] ggplot2_3.3.6                           
##  [68] ellipsis_0.3.2                          
##  [69] jquerylib_0.1.4                         
##  [70] RColorBrewer_1.1-3                      
##  [71] DNAcopy_1.72.0                          
##  [72] Rcpp_1.0.9                              
##  [73] plyr_1.8.7                              
##  [74] progress_1.2.2                          
##  [75] zlibbioc_1.44.0                         
##  [76] purrr_0.3.5                             
##  [77] RCurl_1.98-1.9                          
##  [78] prettyunits_1.1.1                       
##  [79] ggpubr_0.4.0                            
##  [80] GetoptLong_1.0.5                        
##  [81] cowplot_1.1.1                           
##  [82] zoo_1.8-11                              
##  [83] SummarizedExperiment_1.28.0             
##  [84] magrittr_2.0.3                          
##  [85] data.table_1.14.4                       
##  [86] magick_2.7.3                            
##  [87] circlize_0.4.15                         
##  [88] mvtnorm_1.1-3                           
##  [89] matrixStats_0.62.0                      
##  [90] xtable_1.8-4                            
##  [91] hms_1.1.2                               
##  [92] mime_0.12                               
##  [93] evaluate_0.17                           
##  [94] XML_3.99-0.12                           
##  [95] gridExtra_2.3                           
##  [96] shape_1.4.6                             
##  [97] compiler_4.2.1                          
##  [98] biomaRt_2.54.0                          
##  [99] tibble_3.1.8                            
## [100] KernSmooth_2.23-20                      
## [101] crayon_1.5.2                            
## [102] R.oo_1.25.0                             
## [103] htmltools_0.5.3                         
## [104] mgcv_1.8-41                             
## [105] later_1.3.0                             
## [106] tidyr_1.2.1                             
## [107] DBI_1.1.3                               
## [108] dbplyr_2.2.1                            
## [109] MASS_7.3-58.1                           
## [110] rappdirs_0.3.3                          
## [111] Matrix_1.5-1                            
## [112] car_3.1-1                               
## [113] cli_3.4.1                               
## [114] marray_1.76.0                           
## [115] R.methodsS3_1.8.2                       
## [116] parallel_4.2.1                          
## [117] pkgconfig_2.0.3                         
## [118] TxDb.Hsapiens.UCSC.hg19.knownGene_3.2.2 
## [119] GenomicAlignments_1.34.0                
## [120] xml2_1.3.3                              
## [121] InteractionSet_1.26.0                   
## [122] foreach_1.5.2                           
## [123] bslib_0.4.0                             
## [124] XVector_0.38.0                          
## [125] stringr_1.4.1                           
## [126] digest_0.6.30                           
## [127] Biostrings_2.66.0                       
## [128] rmarkdown_2.17                          
## [129] restfulr_0.0.15                         
## [130] curl_4.3.3                              
## [131] shiny_1.7.3                             
## [132] Rsamtools_2.14.0                        
## [133] gtools_3.9.3                            
## [134] PRIMME_3.2-3                            
## [135] rjson_0.2.21                            
## [136] lifecycle_1.0.3                         
## [137] nlme_3.1-160                            
## [138] jsonlite_1.8.3                          
## [139] Rhdf5lib_1.20.0                         
## [140] carData_3.0-5                           
## [141] limma_3.54.0                            
## [142] fansi_1.0.3                             
## [143] pillar_1.8.1                            
## [144] lattice_0.20-45                         
## [145] KEGGREST_1.38.0                         
## [146] fastmap_1.1.0                           
## [147] httr_1.4.4                              
## [148] survival_3.4-0                          
## [149] GO.db_3.16.0                            
## [150] glue_1.6.2                              
## [151] png_0.1-7                               
## [152] iterators_1.0.14                        
## [153] bit_4.0.4                               
## [154] stringi_1.7.8                           
## [155] sass_0.4.2                              
## [156] blob_1.2.3                              
## [157] org.Hs.eg.db_3.16.0                     
## [158] memoise_2.0.1                           
## [159] future.apply_1.9.1