1 ALPS-Introduction

ALPS (AnaLysis routines for ePigenomicS data) is an R package (Venu 2019) that provides tools for the analysis and to produce publication-ready visualizations, mainly aimed at genome-wide epigenomics data, e.g. ChIP-seq, ATAC-seq etc.

1.1 Bigwig files

Bigwig files evolved to be a multi-purpose compressed binary format to store genome-wide data at base pair level. Bigwig files are mostly used to store genome-wide quantitative data such as ChIP-seq, ATAC-seq, WGBS, GRO-seq etc. Following figure illsutrates the important usecases with bigwig files.

1.2 Generate bigwig files

There are multiple ways one can generate bigwig files from BAM files, using UCSC kent utils (ucscGenomeBrowser 2019) or with the deeptools bamCoverage function (Ramírez et al. 2014), which is the easiest way. Once the normalized bigwig files are generated and peaks are identified from BAM files, one would seldom use BAM files again in the entire workflow. The requirements of all downstream processes can be satisified with normalized bigwig files, e.g quantifying normalized read counts at peaks or promoters, visualizing enrichments in genome broswer or igv.

After the peaks are identified, the immediate steps would be to quantify normalized read counts at the identified peaks in order to perform explorative data analysis (EDA), PCA, unsupervised clustering to identify patterns among samples under consideration and generate novel biological insights.

1.3 ALPS - workflow

ALPS package is designed in a way to start with a minimal set of input and to reach a rich source of insights from the data. At the most, most functions in ALPS require a data table with paths to bigwig files and associated sample meta information. Various functions will utilize this data table and generate downstream outputs. The package produces publication quality visualizations, of which most can be customized within R using ggplot2 ecosystem.

Following is the overview of the ALPS workflow and available functions

2 Installation

Install the ALPS package with the following code

3 Example usecases with ALPS

To demonstrate the utility of different functions, ALPS package comes with a set of example files that were taken from TCGA consortium’s ATAC-seq data from here published at (Corces et al. 2018).

Following steps walk you through loading the example data and how to use different function and how to integrate function’s output with other R/bioconductor packages to ease the workflow process.

3.1 Calculate enrichments at genomic regions

Most of the explorative analyses in epigenomics starts with quantifying enrichments or methylations at a set of genomic regions e.g. promoter regions or identified peak regions. This quantifications will be used as an input to downstream analyses such as PCA, clustering. The function multiBigwig_summary takes sample data table with bigwig paths and corresponding bed file paths calculates enrichments at genomic regions. This function is a wrapper around rtracklayer bigwig utilities (Lawrence, Gentleman, and Carey 2009). The function simultaneously generates the consensus peak-set from all the bed files present in input data table before calculating enrichments.

Read data table from ALPS package

Now run the function multiBigwig_summary to calculate enrichments from all bigwig files by simultaneosly preparing consensus peak-set from all bed files in the column bed_path

With little teaking, the output from multiBigwig_summary can be very easily integrated with other R/bioconductor packages for explorative analysis, PCA or clustering.

The function get_variable_regions takes the output of multiBigwig_summary or a similar format and returns a n number of scaled variable regions, which can directly be used with tools such as ComplexHeatmap (Gu, Eils, and Schlesner 2016).

Following is an example on how to integrate multiBigwig_summary output to ComplexHeatmap via get_variable_regions

3.2 Perform correlation among replicates/groups

It is often of high interest in genome-wide quantitative data to check the correlations among replicates within a subgroup to identify specific patterns in the data. plot_correlation function is designed for such use cases. The function is compatible with the output of multiBigwig_summary and also with other tools output with similar format

Instead of correlations of replicates within and across groups, one can also do group level correlations after averaging all samples within a group. The argument plot_type = "group_level" in plot_correlation exactly does this.

Either replicate_level or group_level plot appearance can be further modified with arguments that passed to corrplot::corrplot or GGally::ggpairs respectively.

3.3 Plot enrichments across groups

Once the group-specific genomic regions (or peaks) identified with various differential enrichments packages, e.g. DESeq2, diffBind, QSEA, one would be interested to visualize enrichment qunatities across all samples of all groups to show magnitude of differnce in enrichments. plot_enrichments function takes a data.frame of enrichments, either the output from multiBigwig_summary or a similar format and plots enrichments in a combination of box and violin plots. The function is motivated by the paper (Allen M 2018) and a ggplot2 extension gghalves (Frederik 2019). There are two ways one can plot enrichment differences, one way is to directly plot group level enrichments after averaging all samples within a group for each region and the other way is plotting paired conditions for each group, e.g. untreated, treated enrichments for a transcription factor. In both cases function needs a sample_metadata table along with the enrichments data.frame.

Following example illustrates the uses of plot_enrichments function uses in different settings. If plot_type = "separate", function plots group level enrichments

If plot_type = "overlap", function plots box plots along with overlap violins to show the distributions in paired conditions. The sample_metadata for these plots require one more additional column which describes sample status. See the following example

## plot_type == "overlap"

enrichemnts_4_overlapviolins <- system.file("extdata/overlap_violins",
                                      "enrichemnts_4_overlapviolins.txt",
                                      package = "ALPS", mustWork = TRUE)
enrichemnts_4_overlapviolins <- read.delim(enrichemnts_4_overlapviolins, header = TRUE)

## metadata associated with above enrichments

data_table_4_overlapviolins <- system.file("extdata/overlap_violins",
                                        "data_table_4_overlapviolins.txt",
                                        package = "ALPS", mustWork = TRUE)
data_table_4_overlapviolins <- read.delim(data_table_4_overlapviolins, header = TRUE)

## enrichments table
enrichemnts_4_overlapviolins %>% head
#>     chr   start     end         s1        s2         s3        s4          s5
#> 1 chr21 5101659 5102227 0.25526578 0.4611994 0.21438043 0.1573575 -0.05081961
#> 2 chr21 5128223 5128741 0.82057469 0.9359073 0.66987324 0.8718381  0.31443426
#> 3 chr21 5154593 5155112 0.80378039 0.8452937 0.61775645 0.5620449  0.29282731
#> 4 chr21 5220488 5221005 0.04583463 0.7161867 0.04999978 0.5506898  0.41634277
#> 5 chr21 5221136 5221912 0.87553172 0.1238063 0.94939878 0.5923653  0.24742289
#> 6 chr21 5223327 5223826 0.12800909 0.5948275 0.58255203 0.7278129 -0.14432328
#>          s6          s7        s8
#> 1 0.5747147  0.56832485 0.3590694
#> 2 1.1137688 -0.20168400 0.8110701
#> 3 0.8309985 -0.04550986 0.9127605
#> 4 0.8684639  0.37864897 0.3802162
#> 5 0.3206298 -0.13936118 0.7587155
#> 6 0.3536091  0.48731594 0.8615313

## metadata table
data_table_4_overlapviolins %>% head
#>   bw_path sample_id sample_status group color_code
#> 1 path.bw        s1     untreated   tf1       gray
#> 2 path.bw        s2     untreated   tf2       gray
#> 3 path.bw        s3     untreated   tf1       gray
#> 4 path.bw        s4     untreated   tf2       gray
#> 5 path.bw        s5       treated   tf1        red
#> 6 path.bw        s6       treated   tf2        red

There are additional arguments available for both separate and overlap to modify the appearance (please check ?plot_enrichments), moreover the function returns a ggplot2 object which enables the user to change additional components of the plot.

3.4 Plot UCSC genome browser like plots

In any genome-wide epigenomic analyses, it is often interesting to check enrichments at certain genomic loci, e.g. various histone modifications at a genomic region that define a chromatin state or co-binding of different transcription factors at a promoter or enhancer element. The classical way to acheive this task is to load all bigwig files into IGV or create a data hub at UCSC and navigate to the region of interest. This is not always practical and needs a substantial manual effort, in addition one requires a UCSC genome browser server in order to get this task done with the unpublished data.

To circumvent this problem, several R/bioconductor packages were designed (e.g. Gviz, karyoploteR). Even within R environment, one needs to put a significant effort to create UCSC genome browser like figures. The function plot_broswer_tracks in ALPS package requires a minimal input of a data table and a genomic region and produces a publication quality browser like plot. The function uses utilities within Gviz package to generate the visualizations (Hahne and Ivanek 2016).

Following code snippet illustrates how one can use this function

3.5 Annotate genomic regions

One of the usual tasks in genome-wide epigenomic analyses is to identify the genomic locations of peaks/binding sites. This gives an overview of where a particular transcription factor frequently binds or where a particular type of histone modifications are observed. The function get_genomic_annotations utilizes the above data table and returns the percentage of peaks or binding sites found in each of the genomic features such as promoters, UTRs, intergenetic regions etc. This function is a wrapper around ChIPseeker’s annotatePeak function (Yu, Wang, and He 2015).

Function also offers an option with merge_level to merge overlaping peaks from different samples at different levels.

  • all creates a consensus peak set by merging overlaping peaks from all samples present in the data_table
  • group_level creates a group level consensus peak set. Meaning overlaping peaks from all samples of each group will be merged
  • none does not create any consensus peak set. Per-sample genomic annotations will be returned

3.6 Plot genomic annotations

The results returned from get_genomic_annotations can directly be passed to the function plot_genomic_annotations to visualize the percentages of peaks in each feature. The function can produce visualizations either as bar plot or heatmap

3.7 Plot motif representations

Transcription factors bind to DNA sequences with particular nucleotide stretches. A collection of all binding sites for a transcription factor can be represented by a sequence motif. Typically, transcription factor enrichment analyses utilizes these motif information and provide whether a given transcription factor is enriched in a given set of genomic regions, e.g. enhancers. Currently, there are number of different databases which provide transcription factor motifs in very different format. The function plot_motif_logo takes input from various databases e.g. MEME, TRANSFAC, JASPAR, HOMER or a simple PFM and plots binding site representations either as a sequence logo or a barplot. Barplot representation has a several advantages over sequence logo which are described here. The logo plot utilizes the function ggseqlogo from ggseqlogo package (Wagih 2017).

Following example illustrates how to use the function to plot motif representations

4 Acknowledgements

ALPS package benefited suggestions from

5 Session info

sessionInfo()
#> R Under development (unstable) (2021-03-18 r80099)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 20.04.2 LTS
#> 
#> Matrix products: default
#> BLAS:   /home/biocbuild/bbs-3.13-bioc/R/lib/libRblas.so
#> LAPACK: /home/biocbuild/bbs-3.13-bioc/R/lib/libRlapack.so
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_US.UTF-8        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] grid      stats     graphics  grDevices utils     datasets  methods  
#> [8] base     
#> 
#> other attached packages:
#> [1] circlize_0.4.12      ComplexHeatmap_2.7.8 ALPS_1.5.0          
#> 
#> loaded via a namespace (and not attached):
#>   [1] utf8_1.2.1                              
#>   [2] tidyselect_1.1.0                        
#>   [3] RSQLite_2.2.4                           
#>   [4] AnnotationDbi_1.53.1                    
#>   [5] htmlwidgets_1.5.3                       
#>   [6] BiocParallel_1.25.5                     
#>   [7] scatterpie_0.1.5                        
#>   [8] munsell_0.5.0                           
#>   [9] codetools_0.2-18                        
#>  [10] colorspace_2.0-0                        
#>  [11] GOSemSim_2.17.1                         
#>  [12] TxDb.Hsapiens.UCSC.hg38.knownGene_3.10.0
#>  [13] Biobase_2.51.0                          
#>  [14] filelock_1.0.2                          
#>  [15] highr_0.8                               
#>  [16] knitr_1.31                              
#>  [17] rstudioapi_0.13                         
#>  [18] stats4_4.1.0                            
#>  [19] DOSE_3.17.0                             
#>  [20] labeling_0.4.2                          
#>  [21] MatrixGenerics_1.3.1                    
#>  [22] GenomeInfoDbData_1.2.4                  
#>  [23] polyclip_1.10-0                         
#>  [24] bit64_4.0.5                             
#>  [25] farver_2.1.0                            
#>  [26] vctrs_0.3.6                             
#>  [27] treeio_1.15.6                           
#>  [28] generics_0.1.0                          
#>  [29] xfun_0.22                               
#>  [30] biovizBase_1.39.0                       
#>  [31] BiocFileCache_1.15.1                    
#>  [32] ggseqlogo_0.1                           
#>  [33] doParallel_1.0.16                       
#>  [34] R6_2.5.0                                
#>  [35] GenomeInfoDb_1.27.8                     
#>  [36] clue_0.3-58                             
#>  [37] graphlayouts_0.7.1                      
#>  [38] AnnotationFilter_1.15.0                 
#>  [39] bitops_1.0-6                            
#>  [40] cachem_1.0.4                            
#>  [41] reshape_0.8.8                           
#>  [42] fgsea_1.17.0                            
#>  [43] DelayedArray_0.17.9                     
#>  [44] assertthat_0.2.1                        
#>  [45] BiocIO_1.1.2                            
#>  [46] scales_1.1.1                            
#>  [47] ggraph_2.0.5                            
#>  [48] nnet_7.3-15                             
#>  [49] enrichplot_1.11.2                       
#>  [50] debugme_1.1.0                           
#>  [51] gtable_0.3.0                            
#>  [52] Cairo_1.5-12.2                          
#>  [53] ensembldb_2.15.2                        
#>  [54] tidygraph_1.2.0                         
#>  [55] rlang_0.4.10                            
#>  [56] genefilter_1.73.1                       
#>  [57] GlobalOptions_0.1.2                     
#>  [58] splines_4.1.0                           
#>  [59] rtracklayer_1.51.5                      
#>  [60] lazyeval_0.2.2                          
#>  [61] dichromat_2.0-0                         
#>  [62] checkmate_2.0.0                         
#>  [63] BiocManager_1.30.10                     
#>  [64] yaml_2.2.1                              
#>  [65] reshape2_1.4.4                          
#>  [66] GenomicFeatures_1.43.7                  
#>  [67] backports_1.2.1                         
#>  [68] gghalves_0.1.1                          
#>  [69] qvalue_2.23.0                           
#>  [70] Hmisc_4.5-0                             
#>  [71] tools_4.1.0                             
#>  [72] ggplot2_3.3.3                           
#>  [73] ellipsis_0.3.1                          
#>  [74] gplots_3.1.1                            
#>  [75] jquerylib_0.1.3                         
#>  [76] RColorBrewer_1.1-2                      
#>  [77] BiocGenerics_0.37.1                     
#>  [78] Rcpp_1.0.6                              
#>  [79] plyr_1.8.6                              
#>  [80] base64enc_0.1-3                         
#>  [81] progress_1.2.2                          
#>  [82] zlibbioc_1.37.0                         
#>  [83] purrr_0.3.4                             
#>  [84] RCurl_1.98-1.3                          
#>  [85] prettyunits_1.1.1                       
#>  [86] rpart_4.1-15                            
#>  [87] openssl_1.4.3                           
#>  [88] GetoptLong_1.0.5                        
#>  [89] viridis_0.5.1                           
#>  [90] cowplot_1.1.1                           
#>  [91] S4Vectors_0.29.9                        
#>  [92] SummarizedExperiment_1.21.1             
#>  [93] ggrepel_0.9.1                           
#>  [94] cluster_2.1.1                           
#>  [95] magrittr_2.0.1                          
#>  [96] magick_2.7.0                            
#>  [97] data.table_1.14.0                       
#>  [98] DO.db_2.9                               
#>  [99] ProtGenerics_1.23.7                     
#> [100] matrixStats_0.58.0                      
#> [101] xtable_1.8-4                            
#> [102] hms_1.0.0                               
#> [103] patchwork_1.1.1                         
#> [104] evaluate_0.14                           
#> [105] XML_3.99-0.6                            
#> [106] jpeg_0.1-8.1                            
#> [107] shape_1.4.5                             
#> [108] IRanges_2.25.6                          
#> [109] gridExtra_2.3                           
#> [110] compiler_4.1.0                          
#> [111] biomaRt_2.47.5                          
#> [112] tibble_3.1.0                            
#> [113] KernSmooth_2.23-18                      
#> [114] crayon_1.4.1                            
#> [115] shadowtext_0.0.7                        
#> [116] htmltools_0.5.1.1                       
#> [117] Formula_1.2-4                           
#> [118] tidyr_1.1.3                             
#> [119] aplot_0.0.6                             
#> [120] DBI_1.1.1                               
#> [121] tweenr_1.0.1                            
#> [122] corrplot_0.84                           
#> [123] ChIPseeker_1.27.3                       
#> [124] dbplyr_2.1.0                            
#> [125] MASS_7.3-53.1                           
#> [126] rappdirs_0.3.3                          
#> [127] boot_1.3-27                             
#> [128] Matrix_1.3-2                            
#> [129] parallel_4.1.0                          
#> [130] Gviz_1.35.5                             
#> [131] igraph_1.2.6                            
#> [132] GenomicRanges_1.43.3                    
#> [133] pkgconfig_2.0.3                         
#> [134] TxDb.Hsapiens.UCSC.hg19.knownGene_3.2.2 
#> [135] rvcheck_0.1.8                           
#> [136] GenomicAlignments_1.27.2                
#> [137] foreign_0.8-81                          
#> [138] foreach_1.5.1                           
#> [139] xml2_1.3.2                              
#> [140] annotate_1.69.2                         
#> [141] ggtree_2.5.1                            
#> [142] bslib_0.2.4                             
#> [143] XVector_0.31.1                          
#> [144] stringr_1.4.0                           
#> [145] VariantAnnotation_1.37.1                
#> [146] digest_0.6.27                           
#> [147] Biostrings_2.59.2                       
#> [148] rmarkdown_2.7                           
#> [149] fastmatch_1.1-0                         
#> [150] tidytree_0.3.3                          
#> [151] htmlTable_2.1.0                         
#> [152] restfulr_0.0.13                         
#> [153] curl_4.3                                
#> [154] Rsamtools_2.7.1                         
#> [155] gtools_3.8.2                            
#> [156] rjson_0.2.20                            
#> [157] lifecycle_1.0.0                         
#> [158] nlme_3.1-152                            
#> [159] jsonlite_1.7.2                          
#> [160] viridisLite_0.3.0                       
#> [161] askpass_1.1                             
#> [162] BSgenome_1.59.2                         
#> [163] fansi_0.4.2                             
#> [164] pillar_1.5.1                            
#> [165] lattice_0.20-41                         
#> [166] GGally_2.1.1                            
#> [167] KEGGREST_1.31.1                         
#> [168] fastmap_1.1.0                           
#> [169] httr_1.4.2                              
#> [170] plotrix_3.8-1                           
#> [171] survival_3.2-10                         
#> [172] GO.db_3.12.1                            
#> [173] glue_1.4.2                              
#> [174] iterators_1.0.13                        
#> [175] png_0.1-7                               
#> [176] bit_4.0.4                               
#> [177] ggforce_0.3.3                           
#> [178] stringi_1.5.3                           
#> [179] sass_0.3.1                              
#> [180] blob_1.2.1                              
#> [181] org.Hs.eg.db_3.12.0                     
#> [182] latticeExtra_0.6-29                     
#> [183] caTools_1.18.1                          
#> [184] memoise_2.0.0                           
#> [185] dplyr_1.0.5                             
#> [186] ape_5.4-1

References

Allen M, Whitaker K, Poggiali D. 2018. “Raincloud plots: a multi-platform tool for robust data visualization.” PeerJ Preprints 6:E27137v1.

Corces, M. Ryan, Jeffrey M. Granja, Shadi Shams, Bryan H. Louie, Jose A. Seoane, Wanding Zhou, Tiago C. Silva, et al. 2018. “The Chromatin Accessibility Landscape of Primary Human Cancers.” Edited by Rehan Akbani, Christopher C. Benz, Evan A. Boyle, Bradley M. Broom, Andrew D. Cherniack, Brian Craft, John A. Demchok, et al. Science 362 (6413). https://doi.org/10.1126/science.aav1898.

Frederik, Tiedemann. 2019. “gghalves: Easy half-half geoms in ggplot2.” https://cran.r-project.org/web/packages/gghalves.

Gu, Zuguang, Roland Eils, and Matthias Schlesner. 2016. “Complex heatmaps reveal patterns and correlations in multidimensional genomic data.” Bioinformatics 32 (18): 2847–9. https://doi.org/10.1093/bioinformatics/btw313.

Hahne, Florian, and Robert Ivanek. 2016. “Visualizing Genomic Data Using Gviz and Bioconductor.” In Statistical Genomics: Methods and Protocols, edited by Sean Mathé Ewyand Davis, 335–51. New York, NY: Springer New York. https://doi.org/10.1007/978-1-4939-3578-9_16.

Lawrence, Michael, Robert Gentleman, and Vincent Carey. 2009. “rtracklayer: an R package for interfacing with genome browsers.” Bioinformatics 25 (14): 1841–2. https://doi.org/10.1093/bioinformatics/btp328.

Ramírez, Fidel, Friederike Dündar, Sarah Diehl, Björn A. Grüning, and Thomas Manke. 2014. “deepTools: a flexible platform for exploring deep-sequencing data.” Nucleic Acids Research 42 (W1): W187–W191. https://doi.org/10.1093/nar/gku365.

ucscGenomeBrowser. 2019. “UCSC Genome Browser source tree.” https://github.com/ucscGenomeBrowser/kent.

Venu, Thatikonda. 2019. “ALPS: AnaLysis routines for ePigenomicS data.” https://github.com/itsvenu.

Yu, Guangchuang, Li-Gen Wang, and Qing-Yu He. 2015. “ChIPseeker: An R/Bioconductor Package for Chip Peak Annotation, Comparison and Visualization.” Bioinformatics 31 (14): 2382–3. https://doi.org/10.1093/bioinformatics/btv145.