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 version 4.0.0 (2020-04-24)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 18.04.4 LTS
#> 
#> Matrix products: default
#> BLAS:   /home/biocbuild/bbs-3.11-bioc/R/lib/libRblas.so
#> LAPACK: /home/biocbuild/bbs-3.11-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.8       ComplexHeatmap_2.4.0 ALPS_1.2.0          
#> 
#> loaded via a namespace (and not attached):
#>   [1] tidyselect_1.0.0                        
#>   [2] RSQLite_2.2.0                           
#>   [3] AnnotationDbi_1.50.0                    
#>   [4] htmlwidgets_1.5.1                       
#>   [5] BiocParallel_1.22.0                     
#>   [6] scatterpie_0.1.4                        
#>   [7] munsell_0.5.0                           
#>   [8] colorspace_1.4-1                        
#>   [9] GOSemSim_2.14.0                         
#>  [10] Biobase_2.48.0                          
#>  [11] TxDb.Hsapiens.UCSC.hg38.knownGene_3.10.0
#>  [12] knitr_1.28                              
#>  [13] rstudioapi_0.11                         
#>  [14] stats4_4.0.0                            
#>  [15] DOSE_3.14.0                             
#>  [16] labeling_0.3                            
#>  [17] urltools_1.7.3                          
#>  [18] GenomeInfoDbData_1.2.3                  
#>  [19] polyclip_1.10-0                         
#>  [20] bit64_0.9-7                             
#>  [21] farver_2.0.3                            
#>  [22] vctrs_0.2.4                             
#>  [23] xfun_0.13                               
#>  [24] biovizBase_1.36.0                       
#>  [25] BiocFileCache_1.12.0                    
#>  [26] ggseqlogo_0.1                           
#>  [27] R6_2.4.1                                
#>  [28] GenomeInfoDb_1.24.0                     
#>  [29] clue_0.3-57                             
#>  [30] graphlayouts_0.7.0                      
#>  [31] AnnotationFilter_1.12.0                 
#>  [32] bitops_1.0-6                            
#>  [33] reshape_0.8.8                           
#>  [34] fgsea_1.14.0                            
#>  [35] gridGraphics_0.5-0                      
#>  [36] DelayedArray_0.14.0                     
#>  [37] assertthat_0.2.1                        
#>  [38] scales_1.1.0                            
#>  [39] ggraph_2.0.2                            
#>  [40] nnet_7.3-14                             
#>  [41] enrichplot_1.8.0                        
#>  [42] gtable_0.3.0                            
#>  [43] tidygraph_1.1.2                         
#>  [44] ensembldb_2.12.0                        
#>  [45] rlang_0.4.5                             
#>  [46] genefilter_1.70.0                       
#>  [47] GlobalOptions_0.1.1                     
#>  [48] splines_4.0.0                           
#>  [49] rtracklayer_1.48.0                      
#>  [50] lazyeval_0.2.2                          
#>  [51] acepack_1.4.1                           
#>  [52] dichromat_2.0-0                         
#>  [53] europepmc_0.3                           
#>  [54] checkmate_2.0.0                         
#>  [55] BiocManager_1.30.10                     
#>  [56] yaml_2.2.1                              
#>  [57] reshape2_1.4.4                          
#>  [58] GenomicFeatures_1.40.0                  
#>  [59] backports_1.1.6                         
#>  [60] gghalves_0.1.0                          
#>  [61] qvalue_2.20.0                           
#>  [62] Hmisc_4.4-0                             
#>  [63] tools_4.0.0                             
#>  [64] ggplotify_0.0.5                         
#>  [65] ggplot2_3.3.0                           
#>  [66] ellipsis_0.3.0                          
#>  [67] gplots_3.0.3                            
#>  [68] RColorBrewer_1.1-2                      
#>  [69] BiocGenerics_0.34.0                     
#>  [70] ggridges_0.5.2                          
#>  [71] Rcpp_1.0.4.6                            
#>  [72] plyr_1.8.6                              
#>  [73] base64enc_0.1-3                         
#>  [74] progress_1.2.2                          
#>  [75] zlibbioc_1.34.0                         
#>  [76] purrr_0.3.4                             
#>  [77] RCurl_1.98-1.2                          
#>  [78] prettyunits_1.1.1                       
#>  [79] rpart_4.1-15                            
#>  [80] openssl_1.4.1                           
#>  [81] GetoptLong_0.1.8                        
#>  [82] viridis_0.5.1                           
#>  [83] cowplot_1.0.0                           
#>  [84] S4Vectors_0.26.0                        
#>  [85] SummarizedExperiment_1.18.0             
#>  [86] ggrepel_0.8.2                           
#>  [87] cluster_2.1.0                           
#>  [88] magrittr_1.5                            
#>  [89] data.table_1.12.8                       
#>  [90] DO.db_2.9                               
#>  [91] triebeard_0.3.0                         
#>  [92] ProtGenerics_1.20.0                     
#>  [93] matrixStats_0.56.0                      
#>  [94] hms_0.5.3                               
#>  [95] evaluate_0.14                           
#>  [96] xtable_1.8-4                            
#>  [97] XML_3.99-0.3                            
#>  [98] jpeg_0.1-8.1                            
#>  [99] shape_1.4.4                             
#> [100] IRanges_2.22.0                          
#> [101] gridExtra_2.3                           
#> [102] compiler_4.0.0                          
#> [103] biomaRt_2.44.0                          
#> [104] tibble_3.0.1                            
#> [105] KernSmooth_2.23-17                      
#> [106] crayon_1.3.4                            
#> [107] htmltools_0.4.0                         
#> [108] Formula_1.2-3                           
#> [109] tidyr_1.0.2                             
#> [110] DBI_1.1.0                               
#> [111] tweenr_1.0.1                            
#> [112] corrplot_0.84                           
#> [113] ChIPseeker_1.24.0                       
#> [114] dbplyr_1.4.3                            
#> [115] MASS_7.3-51.6                           
#> [116] rappdirs_0.3.1                          
#> [117] boot_1.3-25                             
#> [118] Matrix_1.2-18                           
#> [119] gdata_2.18.0                            
#> [120] parallel_4.0.0                          
#> [121] Gviz_1.32.0                             
#> [122] igraph_1.2.5                            
#> [123] GenomicRanges_1.40.0                    
#> [124] pkgconfig_2.0.3                         
#> [125] TxDb.Hsapiens.UCSC.hg19.knownGene_3.2.2 
#> [126] rvcheck_0.1.8                           
#> [127] GenomicAlignments_1.24.0                
#> [128] foreign_0.8-79                          
#> [129] xml2_1.3.2                              
#> [130] annotate_1.66.0                         
#> [131] XVector_0.28.0                          
#> [132] stringr_1.4.0                           
#> [133] VariantAnnotation_1.34.0                
#> [134] digest_0.6.25                           
#> [135] Biostrings_2.56.0                       
#> [136] rmarkdown_2.1                           
#> [137] fastmatch_1.1-0                         
#> [138] htmlTable_1.13.3                        
#> [139] curl_4.3                                
#> [140] Rsamtools_2.4.0                         
#> [141] gtools_3.8.2                            
#> [142] rjson_0.2.20                            
#> [143] lifecycle_0.2.0                         
#> [144] jsonlite_1.6.1                          
#> [145] viridisLite_0.3.0                       
#> [146] askpass_1.1                             
#> [147] BSgenome_1.56.0                         
#> [148] pillar_1.4.3                            
#> [149] lattice_0.20-41                         
#> [150] GGally_1.5.0                            
#> [151] httr_1.4.1                              
#> [152] plotrix_3.7-8                           
#> [153] survival_3.1-12                         
#> [154] GO.db_3.10.0                            
#> [155] glue_1.4.0                              
#> [156] png_0.1-7                               
#> [157] bit_1.1-15.2                            
#> [158] ggforce_0.3.1                           
#> [159] stringi_1.4.6                           
#> [160] blob_1.2.1                              
#> [161] org.Hs.eg.db_3.10.0                     
#> [162] latticeExtra_0.6-29                     
#> [163] caTools_1.18.0                          
#> [164] memoise_1.1.0                           
#> [165] dplyr_0.8.5

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). American Association for the Advancement of Science. 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.