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 Under development (unstable) (2021-10-19 r81077)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 20.04.3 LTS
## 
## Matrix products: default
## BLAS:   /home/biocbuild/bbs-3.15-bioc/R/lib/libRblas.so
## LAPACK: /home/biocbuild/bbs-3.15-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_1.27.0        GenomicRanges_1.47.1 GenomeInfoDb_1.31.0 
##  [4] IRanges_2.29.0       S4Vectors_0.33.0     BiocGenerics_0.41.0 
##  [7] microbenchmark_1.4-7 TADCompare_1.5.0     SpectralTAD_1.11.0  
## [10] dplyr_1.0.7          BiocStyle_2.23.0    
## 
## loaded via a namespace (and not attached):
##   [1] readxl_1.3.1                backports_1.3.0            
##   [3] plyr_1.8.6                  splines_4.2.0              
##   [5] BiocParallel_1.29.0         listenv_0.8.0              
##   [7] ggplot2_3.3.5               CGHcall_2.57.0             
##   [9] TH.data_1.1-0               digest_0.6.28              
##  [11] htmltools_0.5.2             magick_2.7.3               
##  [13] fansi_0.5.0                 magrittr_2.0.1             
##  [15] InteractionSet_1.23.0       openxlsx_4.2.4             
##  [17] limma_3.51.0                globals_0.14.0             
##  [19] Biostrings_2.63.0           matrixStats_0.61.0         
##  [21] R.utils_2.11.0              sandwich_3.0-1             
##  [23] colorspace_2.0-2            haven_2.4.3                
##  [25] xfun_0.27                   crayon_1.4.1               
##  [27] RCurl_1.98-1.5              jsonlite_1.7.2             
##  [29] impute_1.69.0               survival_3.2-13            
##  [31] zoo_1.8-9                   glue_1.4.2                 
##  [33] gtable_0.3.0                zlibbioc_1.41.0            
##  [35] XVector_0.35.0              GetoptLong_1.0.5           
##  [37] DelayedArray_0.21.0         car_3.0-11                 
##  [39] Rhdf5lib_1.17.0             future.apply_1.8.1         
##  [41] HiCcompare_1.17.0           abind_1.4-5                
##  [43] scales_1.1.1                pheatmap_1.0.12            
##  [45] mvtnorm_1.1-3               DBI_1.1.1                  
##  [47] CGHbase_1.55.0              rstatix_0.7.0              
##  [49] Rcpp_1.0.7                  foreign_0.8-81             
##  [51] RColorBrewer_1.1-2          ellipsis_0.3.2             
##  [53] pkgconfig_2.0.3             R.methodsS3_1.8.1          
##  [55] sass_0.4.0                  utf8_1.2.2                 
##  [57] DNAcopy_1.69.0              tidyselect_1.1.1           
##  [59] rlang_0.4.12                reshape2_1.4.4             
##  [61] munsell_0.5.0               cellranger_1.1.0           
##  [63] tools_4.2.0                 generics_0.1.1             
##  [65] broom_0.7.9                 evaluate_0.14              
##  [67] stringr_1.4.0               fastmap_1.1.0              
##  [69] yaml_2.2.1                  knitr_1.36                 
##  [71] zip_2.2.0                   purrr_0.3.4                
##  [73] future_1.22.1               nlme_3.1-153               
##  [75] R.oo_1.24.0                 compiler_4.2.0             
##  [77] curl_4.3.2                  ggsignif_0.6.3             
##  [79] marray_1.73.0               tibble_3.1.5               
##  [81] bslib_0.3.1                 stringi_1.7.5              
##  [83] QDNAseq_1.31.0              highr_0.9                  
##  [85] forcats_0.5.1               lattice_0.20-45            
##  [87] Matrix_1.3-4                vctrs_0.3.8                
##  [89] pillar_1.6.4                lifecycle_1.0.1            
##  [91] rhdf5filters_1.7.0          BiocManager_1.30.16        
##  [93] GlobalOptions_0.1.2         jquerylib_0.1.4            
##  [95] data.table_1.14.2           cowplot_1.1.1              
##  [97] bitops_1.0-7                PRIMME_3.2-1               
##  [99] R6_2.5.1                    bookdown_0.24              
## [101] KernSmooth_2.23-20          gridExtra_2.3              
## [103] rio_0.5.27                  parallelly_1.28.1          
## [105] codetools_0.2-18            MASS_7.3-54                
## [107] gtools_3.9.2                assertthat_0.2.1           
## [109] rhdf5_2.39.0                SummarizedExperiment_1.25.0
## [111] rjson_0.2.20                Rsamtools_2.11.0           
## [113] multcomp_1.4-17             GenomeInfoDbData_1.2.7     
## [115] mgcv_1.8-38                 parallel_4.2.0             
## [117] hms_1.1.1                   grid_4.2.0                 
## [119] tidyr_1.1.4                 rmarkdown_2.11             
## [121] MatrixGenerics_1.7.0        carData_3.0-4              
## [123] ggpubr_0.4.0                Biobase_2.55.0